RF22
Public Member Functions | Protected Attributes
RF22Datagram Class Reference

RF22 subclass for addressed, unreliable messages. More...

#include <RF22Datagram.h>

Inheritance diagram for RF22Datagram:
RF22 RF22ReliableDatagram RF22Router RF22Mesh

List of all members.

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.

Detailed Description

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).

Examples:

IPGateway.pde, rf22_datagram_client.pde, and rf22_datagram_server.pde.


Constructor & Destructor Documentation

RF22Datagram::RF22Datagram ( uint8_t  thisAddress = 0,
uint8_t  slaveSelectPin = SS,
uint8_t  interrupt = 0 
)

Constructor.

Parameters:
[in]thisAddressThe address to assign to this node. Defaults to 0
[in]slaveSelectPinthe 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]interruptThe interrupt number to use. Default is interrupt 0 (Arduino input pin 2)

References _thisAddress.


Member Function Documentation

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.

Parameters:
[in]bufLocation to copy the received message
[in,out]lenPointer to available space in buf. Set to the actual number of octets copied.
[in]fromIf present and not NULL, the referenced uint8_t will be set to the FROM address
[in]toIf present and not NULL, the referenced uint8_t will be set to the TO address
[in]idIf present and not NULL, the referenced uint8_t will be set to the ID
[in]flagsIf present and not NULL, the referenced uint8_t will be set to the FLAGS (not just those addressed to this node).
Returns:
true if a valid message was copied to buf

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.

Parameters:
[in]bufPointer to the binary message to send
[in]lenNumber of octets to send (> 0)
[in]addressThe address to send the message to.
Returns:
true if the message was transmitted.

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).

Parameters:
[in]thisAddressThe address of this node

References _thisAddress, RF22::setHeaderFrom(), and RF22::spiWrite().

Referenced by init().


The documentation for this class was generated from the following files: