![]() |
libcyberradio
22.01.24
|
Generic radio transport class. More...
#include <RadioTransport.h>
Public Member Functions | |
| RadioTransport (bool json=false, bool debug=false) | |
| Constructs a RadioTransport object. More... | |
| virtual | ~RadioTransport () |
| Destroys a RadioTransport object. | |
| RadioTransport (const RadioTransport &other) | |
| Copies a RadioTransport object. More... | |
| RadioTransport & | operator= (const RadioTransport &other) |
| Assignment operator for RadioTransport objects. More... | |
| virtual bool | connect (const std::string &mode, const std::string &host_or_dev, const int port_or_baudrate) |
| Connects to the radio. More... | |
| virtual void | disconnect () |
| Disconnects from the radio. | |
| virtual bool | isConnected () const |
| Gets whether the transport is connected. More... | |
| void | setJson (bool json) |
| Allows user to set JSON. More... | |
| virtual bool | sendCommand (const std::string &cmdString, bool clearRx=true) |
| Sends a command to the radio over the transport. More... | |
| virtual BasicStringList | receive (double timeout=-1) |
| Receives a command response from the radio. More... | |
| virtual std::string | getLastCommandErrorInfo () const |
| Gets the error information for the last command. More... | |
| virtual void | setDebugName (const std::string &debug_name) |
| Sets the debug name for this object. More... | |
| virtual void | setDebugFile (FILE *debug_fp) |
| Sets the debug file pointer for this object. More... | |
| virtual void | setDebugTimeFormat (const std::string &debug_timefmt) |
| Sets the debug time format for this object. More... | |
| virtual int | debug (const char *format,...) |
| Outputs debug information. More... | |
| virtual const char * | debugBool (bool x) |
| Gets a debug output string for a Boolean value. More... | |
| virtual bool | isDebug () const |
| Gets whether this object produces debug output. More... | |
| virtual std::string | getDebugName () const |
| Gets the debug name for this object. More... | |
| virtual std::string | rawString (const std::string &data) |
| Gets a "raw" string representation of a given data string. More... | |
Protected Member Functions | |
| virtual bool | connectTcp (const std::string &host, int port) |
| Connects to the radio using TCP. More... | |
| virtual bool | connectUdp (const std::string &host, int port) |
| Connects to the radio using UDP. More... | |
| virtual bool | connectHttps (const std::string &host, int port) |
| Connects to the radio using HTTPS. More... | |
| virtual bool | connectTty (const std::string &dev, int baudrate) |
| Connects to the radio using a serial link. More... | |
| virtual bool | sendCommandTcp (const std::string &cmdString, bool clearRx=true) |
| Sends a command to the radio over TCP. More... | |
| virtual bool | sendCommandUdp (const std::string &cmdString, bool clearRx=true) |
| Sends a command to the radio over UDP. More... | |
| virtual bool | sendCommandHttps (const std::string &cmdString, bool clearRx=true) |
| Sends a command to the radio over HTTPS. More... | |
| virtual bool | sendCommandTty (const std::string &cmdString, bool clearRx=true) |
| Sends a command to the radio over TTY. More... | |
| virtual BasicStringList | receiveJson (double timeout=-1) |
| Receives a JSON-formatted command response from the radio. More... | |
| virtual BasicStringList | receiveJsonHttps (double timeout=-1) |
| Receives a JSON-formatted command response from the radio using HTTPS. More... | |
| virtual BasicStringList | receiveCli (double timeout=-1) |
| Receives a client (AT-command-style) command response from the radio. More... | |
| virtual BasicStringList | receiveCliTcp (double timeout=-1) |
| Receives a client (AT-command-style) command response over TCP. More... | |
| virtual BasicStringList | receiveCliUdp (double timeout=-1) |
| Receives a client (AT-command-style) command response over UDP. More... | |
| virtual BasicStringList | receiveCliTty (double timeout=-1) |
| Receives a client (AT-command-style) command response over TTY. More... | |
| virtual void | translateErrno () |
| Translates an errno value into an error message. | |
Generic radio transport class.
The radio transport class provides a unified interface for transmitting data to and from the radio, regardless of the connection method used (serial/TTY, TCP, UDP, or HTTPS).
Definition at line 38 of file RadioTransport.h.
| RadioTransport | ( | bool | json = false, |
| bool | debug = false |
||
| ) |
Constructs a RadioTransport object.
| json | Whether the transport should expect JSON-formatted commands and responses (Boolean). |
| debug | Whether the transport emits debug output (Boolean). |
Definition at line 32 of file RadioTransport.cpp.
| RadioTransport | ( | const RadioTransport & | other | ) |
Copies a RadioTransport object.
| other | The RadioTransport object to copy. |
Definition at line 66 of file RadioTransport.cpp.
|
virtual |
Connects to the radio.
| mode | The connection mode. One of "tty", "tcp", "udp", or "https". |
| host_or_dev | Either the host name or IP address (for TCP or UDP) or the serial device name (for TTY). |
| port_or_baudrate | Either the port number (for TCP or UDP) or the serial baud rate (for TTY).TCP |
Definition at line 104 of file RadioTransport.cpp.
|
protectedvirtual |
Connects to the radio using HTTPS.
| host | The host name or IP address. |
| port | The port number. |
Definition at line 297 of file RadioTransport.cpp.
|
protectedvirtual |
Connects to the radio using TCP.
| host | The host name or IP address. |
| port | The port number. |
Definition at line 226 of file RadioTransport.cpp.
|
protectedvirtual |
Connects to the radio using a serial link.
| dev | The device name for the serial port. |
| baudrate | The serial baud rate. |
Definition at line 334 of file RadioTransport.cpp.
|
protectedvirtual |
Connects to the radio using UDP.
| host | The host name or IP address. |
| port | The port number. |
Definition at line 261 of file RadioTransport.cpp.
|
virtualinherited |
Outputs debug information.
This method follows the same semantics as printf(). Output is preceded by a timestamp and the name of the object, if provided.
| format | The printf()-style format string. |
| ... | Comma-separated list of arguments to print. Note that these need to be arguments that can be supported natively through printf(). |
Definition at line 95 of file Debuggable.cpp.
|
virtualinherited |
Gets a debug output string for a Boolean value.
| x | Boolean value |
Definition at line 126 of file Debuggable.cpp.
|
virtualinherited |
Gets the debug name for this object.
Definition at line 138 of file Debuggable.cpp.
|
virtual |
Gets the error information for the last command.
Definition at line 221 of file RadioTransport.cpp.
|
virtual |
Gets whether the transport is connected.
Definition at line 161 of file RadioTransport.cpp.
|
virtualinherited |
Gets whether this object produces debug output.
Definition at line 133 of file Debuggable.cpp.
| RadioTransport & operator= | ( | const RadioTransport & | other | ) |
Assignment operator for RadioTransport objects.
| other | The RadioTransport object to copy. |
Definition at line 79 of file RadioTransport.cpp.
|
virtualinherited |
Gets a "raw" string representation of a given data string.
"Raw" string representations mimic Python string representations. Whitespace characters are denoted by backslash representations ("\\r", "\\n", "\\t", "\\v", "\\f"), while other non-printable characters are represented with hex representation ("\\x00", etc.)
| data | Data string |
Definition at line 143 of file Debuggable.cpp.
|
virtual |
Receives a command response from the radio.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 202 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a client (AT-command-style) command response from the radio.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 559 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a client (AT-command-style) command response over TCP.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 573 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a client (AT-command-style) command response over TTY.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 645 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a client (AT-command-style) command response over UDP.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 637 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a JSON-formatted command response from the radio.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 491 of file RadioTransport.cpp.
|
protectedvirtual |
Receives a JSON-formatted command response from the radio using HTTPS.
| timeout | The timeout value to use for receiving data. If -1, use the default timeout value for the transport. |
Definition at line 539 of file RadioTransport.cpp.
|
virtual |
Sends a command to the radio over the transport.
| cmdString | The command to send. |
| clearRx | Whether or not to clear the receive buffer before sending the command. |
Definition at line 172 of file RadioTransport.cpp.
|
protectedvirtual |
Sends a command to the radio over HTTPS.
| cmdString | The command to send. |
| clearRx | Whether or not to clear the receive buffer before sending the command. |
Definition at line 424 of file RadioTransport.cpp.
|
protectedvirtual |
Sends a command to the radio over TCP.
| cmdString | The command to send. |
| clearRx | Whether or not to clear the receive buffer before sending the command. |
Definition at line 382 of file RadioTransport.cpp.
|
protectedvirtual |
Sends a command to the radio over TTY.
| cmdString | The command to send. |
| clearRx | Whether or not to clear the receive buffer before sending the command. |
Definition at line 471 of file RadioTransport.cpp.
|
protectedvirtual |
Sends a command to the radio over UDP.
| cmdString | The command to send. |
| clearRx | Whether or not to clear the receive buffer before sending the command. |
Definition at line 403 of file RadioTransport.cpp.
|
virtualinherited |
Sets the debug file pointer for this object.
| debug_fp | File to send debug output to. |
Definition at line 81 of file Debuggable.cpp.
|
virtualinherited |
Sets the debug name for this object.
Use this method to set unique debug names for objects of the same class for easy differentiation.
| debug_name | Name for identifying this object in debug output. |
Definition at line 74 of file Debuggable.cpp.
|
virtualinherited |
Sets the debug time format for this object.
| debug_timefmt | Format string for displaying timestamp, as compatible with strftime(). If this is an empty string, don't display a timestamp. |
Definition at line 88 of file Debuggable.cpp.
| void setJson | ( | bool | json | ) |
Allows user to set JSON.
| json | True if Radio Uses JSON |
Definition at line 97 of file RadioTransport.cpp.