upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the HM-TRP Serial RF Pro transceiver. More...
UPM support for the HM-TRP Serial RF Pro transceiver. This was tested specifically with the Grove Serial RF Pro transceiver. In theory, this class should work with the following devices:
HM-TRP-433: 414000000-454000000Hz HM-TRP-470: 450000000-490000000Hz HM-TRP-868: 849000000-889000000Hz HM-TRP-915: 895000000-935000000Hz
The only difference is the transmit and receive frequencies supported.
By default, the device simply sends and receives any data presented on its UART interface. It can be put into a configuration mode by grounding the CONFIG pin on the transceiver.
Public Member Functions | |
HMTRP (int uart=HMTRP_DEFAULT_UART) | |
~HMTRP () | |
bool | dataAvailable (unsigned int millis=0) |
int | readData (char *buffer, int len, int millis=-1) |
int | writeData (char *buffer, int len) |
bool | setupTty (speed_t baud=B9600) |
bool | checkOK () |
bool | reset () |
bool | getConfig (uint32_t *freq, uint32_t *dataRate, uint16_t *rxBandwidth, uint8_t *modulation, uint8_t *txPower, uint32_t *uartBaud) |
bool | setFrequency (uint32_t freq) |
bool | setRFDataRate (uint32_t rate) |
bool | setRXBandwidth (uint16_t rxBand) |
bool | setFrequencyModulation (uint8_t modulation) |
bool | setTransmitPower (uint8_t power) |
bool | setUARTSpeed (uint32_t speed) |
bool | getRFSignalStrength (uint8_t *strength) |
uint8_t | getRFSignalStrength () |
bool | getModSignalStrength (uint8_t *strength) |
uint8_t | getModSignalStrength () |
HMTRP | ( | int | uart = HMTRP_DEFAULT_UART | ) |
HMTRP Serial RF Pro transceiver constructor
uart | Default UART to use (0 or 1) |
bool dataAvailable | ( | unsigned int | millis = 0 | ) |
Checks to see if there is data available for reading
millis | Number of milliseconds to wait; 0 means no waiting (default). |
int readData | ( | char * | buffer, |
int | len, | ||
int | millis = -1 |
||
) |
Reads any available data in a user-supplied buffer
buffer | Buffer to hold the data read |
len | Length of the buffer |
millis | Maximum time in milliseconds to wait for input. -1 means waiting forever (default). |
int writeData | ( | char * | buffer, |
int | len | ||
) |
Writes the data in the buffer to the device
buffer | Buffer to hold the data read |
len | Length of the buffer |
bool setupTty | ( | speed_t | baud = B9600 | ) |
Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).
baud | Desired baud rate. |
bool checkOK | ( | ) |
Looks for and verifies an OK response. This looks like "OK\r\n"
bool reset | ( | ) |
Resets the device to default parameters, except for the UART baud rate
bool getConfig | ( | uint32_t * | freq, |
uint32_t * | dataRate, | ||
uint16_t * | rxBandwidth, | ||
uint8_t * | modulation, | ||
uint8_t * | txPower, | ||
uint32_t * | uartBaud | ||
) |
Queries the radio to determine its configuration
freq | Operating frequency |
dataRate | TX/RX bit rate |
rxBandwidth | Receiving bandwidth in Khz |
modulation | Modulation frequency in Khz |
txPower | Transmission power (1-7) |
uartBaud | UART baud rate |
bool setFrequency | ( | uint32_t | freq | ) |
Sets the frequency. Note: this is limited depending on which HM-TRP device you are using. Consult the datasheet.
freq | Operating frequency |
bool setRFDataRate | ( | uint32_t | rate | ) |
Sets the RF data transmission rate. Valid values are between 1,200 and 115,200.
rate | Radio transmission rate in baud (1,200-115,200) |
bool setRXBandwidth | ( | uint16_t | rxBand | ) |
Sets the RX bandwidth. Valid values are between 30 and 620 (in Khz)
rxBand | RX bandwidth in Khz (30-620) |
bool setFrequencyModulation | ( | uint8_t | modulation | ) |
Sets the frequency modulation. Valid values are between 10 and 160 (in Khz)
modulation | Frequency modulation to use, in Khz (10-160) |
bool setTransmitPower | ( | uint8_t | power | ) |
Sets the transmit power level. Valid values are between 0 and 7, 7 being the maximum power.
power | Power level to use during transmission. Valid values are between 0 and 7. |
bool setUARTSpeed | ( | uint32_t | speed | ) |
Sets the configured baud rate of the UART. It is strongly recommended you do not change this, or you may lose the ability to communicate with the transceiver. Valid values are 1,200-115,200.
speed | Desired baud rate to configure the device to use Valid values are between 1,200 and 115,200. |
bool getRFSignalStrength | ( | uint8_t * | strength | ) |
Gets the RF signal strength
strength | Returned strength |
uint8_t getRFSignalStrength | ( | ) |
Gets the RF signal strength
std::runtime_error | if reading from the sensor failed |
bool getModSignalStrength | ( | uint8_t * | strength | ) |
Gets the modulation signal strength.
strength | Returned strength |
uint8_t getModSignalStrength | ( | ) |
Gets the modulation signal strength.
std::runtime_error | if reading from the sensor failed |