pyupm_hmtrp module¶
-
class
pyupm_hmtrp.
HMTRP
(uart=0)[source]¶ Bases:
object
API for the HM-TRP Serial RF Pro transceiver.
ID: hmtrp
Name: Serial RF Pro Module
Other Names: HMTRP-433 HMTRP-470 HMTRP-868 HMTRP-915
Category: wifi
Manufacturer: seeed
Connection: uart
Link:http://wiki.seeed.cc/Grove-Serial_RF_Pro/ 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.
C++ includes: hmtrp.hpp
-
GET_CONFIG
= 225¶
-
GET_MOD_SIGNAL_STR
= 120¶
-
GET_RF_SIGNAL_STR
= 167¶
-
RESET
= 240¶
-
SET_FREQUENCY
= 210¶
-
SET_FREQ_MODULATION
= 165¶
-
SET_RF_DATARATE
= 195¶
-
SET_RX_BW
= 180¶
-
SET_TX_POWER
= 150¶
-
SET_UART_SPEED
= 30¶
-
checkOK
()[source]¶ bool checkOK()
Looks for and verifies an OK response. This looks like “OKrn”
True if OK received
-
dataAvailable
(millis=0)[source]¶ 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).
True if there is data available for reading
-
getConfig
(freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)[source]¶ 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
True if successful
-
getModSignalStrength
(strength)[source]¶ uint8_t getModSignalStrength()
Gets the modulation signal strength.
Signal strength
std::runtime_error: if reading from the sensor failed
-
getModSignalStrengthNoParam
()[source]¶ uint8_t getModSignalStrength()
Gets the modulation signal strength.
Signal strength
std::runtime_error: if reading from the sensor failed
-
getRFSignalStrength
(strength)[source]¶ uint8_t getRFSignalStrength()
Gets the RF signal strength
Signal strength
std::runtime_error: if reading from the sensor failed
-
getRFSignalStrengthNoParam
()[source]¶ uint8_t getRFSignalStrength()
Gets the RF signal strength
Signal strength
std::runtime_error: if reading from the sensor failed
-
readData
(buffer, len, millis=-1)[source]¶ 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).
Number of bytes read; 0 if timed out and millis is >= 0
-
reset
()[source]¶ bool reset()
Resets the device to default parameters, except for the UART baud rate
True if successful
-
setFrequency
(freq)[source]¶ 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
True if successful
-
setFrequencyModulation
(modulation)[source]¶ 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)
True if successful
-
setRFDataRate
(rate)[source]¶ 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)
True if successful
-
setRXBandwidth
(rxBand)[source]¶ 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)
True if successful
-
setTransmitPower
(power)[source]¶ 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.
True if successful
-
setUARTSpeed
(speed)[source]¶ 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.
True if successful
-