RF22
|
RF22 subclass for addressed, unreliable messages. More...
#include <RF22Datagram.h>
Public Member Functions | |
RF22Datagram (uint8_t thisAddress=0, uint8_t slaveSelectPin=SS, uint8_t interrupt=0) | |
boolean | init () |
void | setThisAddress (uint8_t thisAddress) |
boolean | sendto (uint8_t *buf, uint8_t len, uint8_t address) |
boolean | recvfrom (uint8_t *buf, uint8_t *len, uint8_t *from=NULL, uint8_t *to=NULL, uint8_t *id=NULL, uint8_t *flags=NULL) |
Protected Attributes | |
uint8_t | _thisAddress |
The address of this node. Defaults to 0. |
RF22 subclass for addressed, unreliable messages.
Extends RF22 to define addressed, unreliable datagrams. Every node has an 8 bit address (defaults to 0). Addresses (DEST and SRC) are 8 bit integers with an address of RF22_BROADCAST_ADDRESS (0xff) reserved for broadcast.
Part of the Arduino RF22 library for operating with HopeRF RF22 compatible transceivers (see http://www.hoperf.com).
IPGateway.pde, rf22_datagram_client.pde, and rf22_datagram_server.pde.
RF22Datagram::RF22Datagram | ( | uint8_t | thisAddress = 0 , |
uint8_t | slaveSelectPin = SS , |
||
uint8_t | interrupt = 0 |
||
) |
Constructor.
[in] | thisAddress | The address to assign to this node. Defaults to 0 |
[in] | slaveSelectPin | the Arduino pin number of the output to use to select the RF22 before accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega) |
[in] | interrupt | The interrupt number to use. Default is interrupt 0 (Arduino input pin 2) |
References _thisAddress.
boolean RF22Datagram::init | ( | ) |
Initialises this instance and the radio module connected to it. Overrides the init() function in RF22
Reimplemented from RF22.
Reimplemented in RF22Router.
References _thisAddress, and setThisAddress().
boolean RF22Datagram::recvfrom | ( | uint8_t * | buf, |
uint8_t * | len, | ||
uint8_t * | from = NULL , |
||
uint8_t * | to = NULL , |
||
uint8_t * | id = NULL , |
||
uint8_t * | flags = NULL |
||
) |
Turns the receiver on if it not already on. If there is a valid message available for this node, copy it to buf and return true 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 a message is copied, *len is set to the length. You should be sure to call this function frequently enough to not miss any messages It is recommended that you call it in your main loop.
[in] | buf | Location to copy the received message |
[in,out] | len | Pointer to 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 FROM address |
[in] | to | If present and not NULL, the referenced uint8_t will be set to the TO address |
[in] | id | If present and not NULL, the referenced uint8_t will be set to the ID |
[in] | flags | If present and not NULL, the referenced uint8_t will be set to the FLAGS (not just those addressed to this node). |
References RF22::headerFlags(), RF22::headerFrom(), RF22::headerId(), RF22::headerTo(), and RF22::recv().
Referenced by RF22ReliableDatagram::recvfromAck().
boolean RF22Datagram::sendto | ( | uint8_t * | buf, |
uint8_t | len, | ||
uint8_t | address | ||
) |
Sends a message to the node(s) with the given address RF22_BROADCAST_ADDRESS is a valid address which will cause the message to be accepted by all RF22Datagram nodes within range.
[in] | buf | Pointer to the binary message to send |
[in] | len | Number of octets to send (> 0) |
[in] | address | The address to send the message to. |
References RF22::send(), and RF22::setHeaderTo().
Referenced by RF22ReliableDatagram::acknowledge(), and RF22ReliableDatagram::sendtoWait().
void RF22Datagram::setThisAddress | ( | uint8_t | thisAddress | ) |
Sets the address of this node. Defaults to 0. This will be used to set the FROM address of all messages sent by this node. If all the nodes leave the address unset (ie 0), In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM).
[in] | thisAddress | The address of this node |
References _thisAddress, RF22::setHeaderFrom(), and RF22::spiWrite().
Referenced by init().