HopeRF
|
Class for addressed, unreliable messages. More...
#include <HRFDatagram.h>
Public Member Functions | |
HRFDatagram (HardwareSerial *serial=&Serial, uint8_t thisAddress=0) | |
virtual void | setThisAddress (uint8_t thisAddress) |
virtual uint8_t | sendto (uint8_t address, uint8_t *buf, uint8_t len) |
virtual uint8_t | recvfrom (uint8_t *buf, uint8_t *len, uint8_t *from=NULL, uint8_t *to=NULL, uint8_t promiscuous=0) |
virtual uint8_t | recv (uint8_t *buf, uint8_t *len) |
Public Member Functions inherited from HRFMessage | |
HRFMessage (HardwareSerial *serial=&Serial) | |
virtual uint8_t | send (uint8_t *buf, uint8_t len) |
virtual uint8_t | available () |
virtual uint8_t | rx_bad (void) |
virtual uint8_t | rx_good (void) |
virtual void | waitAvailable (void) |
Protected Attributes | |
uint8_t | _thisAddress |
The address of this node. Defaults to 0. | |
Class for addressed, unreliable messages.
Extends HRFMessage to define addressed, unreliable datagrams. Every node has an 8 bit address (defaults to 0). Datagrams have format LEN DEST SRC payload FCS-LO FCS-HI. Addresses (DEST and SRC) are 8 bit integers with an address of HRF_BROADCAST_ADDRESS (0xff) reserved for broadcast.
Part of the Arduino HopeRF library for operating with HopeRF HM-TR transceivers (see http://www.hoperf.com).
HRFDatagram::HRFDatagram | ( | HardwareSerial * | serial = &Serial , |
uint8_t | thisAddress = 0 |
||
) |
[in] | serial | The instance of HardwareSerial to use for IO. Defaults to &Serial, |
[in] | thisAddress | The address to assign to this node. Defaults to 0 |
References setThisAddress().
|
virtual |
If there is a valid message available for this node, copy it to buf and return true else return false. You can't recover the SRC or DEST address with this call, so you would only use it if you do not intend to reply. 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 from HRFMessage.
References recvfrom().
|
virtual |
If there is a message available for this node, copy it to buf and return true If the message was valid (ie good FCS), return true else return false. The SRC address is placed in *from if present and not NULL. The DEST address is placed in *to if present and not NULL. If promiscuous is present and true, all messages will be returned, not just those addressed to this node. 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. |
[in] | from | If present and not NULL, the referenced uint8_t will be set to the SRC address |
[in] | to | If present and not NULL, the referenced uint8_t will be set to the DEST address |
[in] | promiscuous | If present and true, return all received messages (not just those addressed to this node). |
References _thisAddress, and HRFMessage::recv().
Referenced by recv(), HRFReliableDatagram::recvfromAck(), and HRFReliableDatagram::sendtoWait().
|
virtual |
Sends a message to the node(s) with the given address HRF_BROADCAST_ADDRESS is a valid address which will cause the message to be accepted by all HRFDatagram nodes within range.
[in] | address | The address to send the message to. |
[in] | buf | Pointer to the binary message to send |
[in] | len | Number of octets to send |
References _thisAddress, and HRFMessage::send().
Referenced by HRFReliableDatagram::recvfromAck(), and HRFReliableDatagram::sendtoWait().
|
virtual |
Sets the address of this node. Defaults to 0. If all the nodes leave the address unset (ie 0), HRFDatagram acts much the same as HRFMessage (with a bit more overhead). In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM). However, if you only have 2 nodes in the network, you can leave the addresses of each set to the default of 0.
[in] | thisAddress | The address of this node |
References _thisAddress.
Referenced by HRFDatagram().