File: detect_example.cc

package info (click to toggle)
qdmr 0.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,532 kB
  • sloc: cpp: 57,457; xml: 8,326; python: 757; makefile: 78
file content (40 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "libdmrconf/usbdevice.hh"
#include "libdmrconf/anytone_radio.hh"

int main(void) {
  // Example code to detect an AnytoneDevice

  // First, search matching devices (only AnyTones)
  QList<USBDeviceDescriptor> devices = AnytoneInterface::detect();
  if (1 != devices.count()) {
    // Either none or more than one device found...
    return -1;
  }

  // A place to put error messages
  ErrorStack err;
  Radio *radio = AnytoneRadio::detect(devices.first(), RadioInfo(), err);
  if (nullptr == radio) {
    // There went something wrong, check err.
    return -1;
  }

  // Read codeplug from device blocking.
  if (! radio->startDownload(true, err)) {
    // Some download error, check err.
    delete radio;
    return -1;
  }

  // Decode codeplug into genericCodeplug
  Config genericCodeplug;
  if (! radio->codeplug().decode(&genericCodeplug, err)) {
    // Some decoding error, check err.
    delete radio;
    return -1;
  }

  // Do whatever you like with the codeplug.

  return 0;
}