HopeRF
|
Basic message class for HopeRF data transceivers. More...
#include <HRFMessage.h>
Public Member Functions | |
HRFMessage (HardwareSerial *serial=&Serial) | |
virtual uint8_t | send (uint8_t *buf, uint8_t len) |
virtual uint8_t | available () |
virtual uint8_t | recv (uint8_t *buf, uint8_t *len) |
virtual uint8_t | rx_bad (void) |
virtual uint8_t | rx_good (void) |
virtual void | waitAvailable (void) |
Basic message class for HopeRF data transceivers.
Define low level unaddressed, unreliable message. HRFMessage have the format LEN payload FCS-LO FCS-HI. LEN is the total number of octets in the message, including the LEN and FCS octets FCS (16 bits) is the complement of CCITT CRC-16 of all octets in the message, including the LEN HRFMessage is unaddressed, and will be received by all HRFMessage nodes within range.
This class and others in this library provide easy methods for sending and receiving messages using the HM-TR. Several layers of classes are provided above this to provide a range of features from unacknowledged broadcasts to acknowledged, reliable addressed messages.
Although HopeRF HM-TR transceivers have an enable pin, this library make no use of that. Enabling and disabling of the transceiver when it is not required should be done by other code.
Although HopeRF HM-TR transceivers have a Config pin, this library make no use of that, since it must be enabled when the transceiver powers up. This librray assumes the transceiver has already been configured, typically using the HopeRF configuration program.
HRFMessage::HRFMessage | ( | HardwareSerial * | serial = &Serial | ) |
You can have multiple instances for HM-TR modules on multiple HardwareSerial ports.
[in] | serial | The instance of HardwareSerial to use for IO. Defaults to &Serial, the Arduino default serial port. |
|
virtual |
Referenced by recv().
|
virtual |
If a message is available (good checksum or not), copies up to *len octets to buf. If a message is copied, *len is set to the length
[in] | buf | Location to copy the received message |
[in] | len | Available space in buf. Set to the actual number of octets copied. |
Reimplemented in HRFDatagram.
References available().
Referenced by HRFDatagram::recvfrom().
|
virtual |
The bad message count starts at 0 at instantation time, and is incremented whenever a message with a bad length is received. This generally indicates a corrupt messages.
|
virtual |
The good message count starts at 0 at instantation time, and is incremented whenever a complete message is received,
|
virtual |
Send a message with the given length. Blocks and returns after the entire message has been sent. Any binary data is permitted.
[in] | buf | Pointer to the binary message to send |
[in] | len | Number of octets to send |
Referenced by HRFDatagram::sendto().
|
virtual |
Wait until at least 1 octet is available on the serial device On Arduino, polls the device. On Linux, blocks