RF22

- Main Page
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
RF22Datagram Class Reference

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

`#include <RF22Datagram.h>`

Inheritance diagram for RF22Datagram:

## 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)
Public Member Functions inherited from RF22
| RF22 (uint8_t slaveSelectPin=SS, uint8_t interrupt=0, GenericSPIClass *spi=&Hardware_spi)
boolean | init ()
void | reset ()
uint8_t | spiRead (uint8_t reg)
void | spiWrite (uint8_t reg, uint8_t val)
void | spiBurstRead (uint8_t reg, uint8_t *dest, uint8_t len)
void | spiBurstWrite (uint8_t reg, const uint8_t *src, uint8_t len)
uint8_t | statusRead ()
uint8_t | adcRead (uint8_t adcsel=RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR, uint8_t adcref=RF22_ADCREF_BANDGAP_VOLTAGE, uint8_t adcgain=0, uint8_t adcoffs=0)
uint8_t | temperatureRead (uint8_t tsrange=RF22_TSRANGE_M64_64C, uint8_t tvoffs=0)
uint16_t | wutRead ()
void | setWutPeriod (uint16_t wtm, uint8_t wtr=0, uint8_t wtd=0)
boolean | setFrequency (float centre, float afcPullInRange=0.05)
boolean | setFHStepSize (uint8_t fhs)
boolean | setFHChannel (uint8_t fhch)
uint8_t | rssiRead ()
uint8_t | ezmacStatusRead ()
void | setMode (uint8_t mode)
void | setModeIdle ()
void | setModeRx ()
void | setModeTx ()
uint8_t | mode ()
void | setTxPower (uint8_t power)
void | setModemRegisters (const ModemConfig *config)
boolean | setModemConfig (ModemConfigChoice index)
boolean | available ()
void | waitAvailable ()
bool | waitAvailableTimeout (uint16_t timeout)
boolean | recv (uint8_t *buf, uint8_t *len)
boolean | send (const uint8_t *data, uint8_t len)
void | waitPacketSent ()
bool | waitPacketSent (uint16_t timeout)
void | setPromiscuous (boolean promiscuous)
uint8_t | headerTo ()
uint8_t | headerFrom ()
uint8_t | headerId ()
uint8_t | headerFlags ()
uint8_t | lastRssi ()
void | setPreambleLength (uint8_t nibbles)
void | setSyncWords (const uint8_t *syncWords, uint8_t len)
boolean | setCRCPolynomial (CRCPolynomial polynomial)

## Protected Attributes
uint8_t | _thisAddress
| The address of this node. Defaults to 0.
Protected Attributes inherited from RF22
GenericSPIClass * | _spi
volatile uint8_t | _mode
uint8_t | _idleMode
uint8_t | _slaveSelectPin
uint8_t | _interrupt
uint8_t | _deviceType
CRCPolynomial | _polynomial
volatile uint8_t | _bufLen
uint8_t | _buf [RF22_MAX_MESSAGE_LEN]
volatile boolean | _rxBufValid
volatile uint8_t | _txBufSentIndex
volatile uint16_t | _rxBad
volatile uint16_t | _rxGood
volatile uint16_t | _txGood
volatile uint8_t | _lastRssi

## Additional Inherited Members
Public Types inherited from RF22
enum | ModemConfigChoice { UnmodulatedCarrier = 0, FSK_PN9_Rb2Fd5, FSK_Rb2Fd5, FSK_Rb2_4Fd36, FSK_Rb4_8Fd45, FSK_Rb9_6Fd45, FSK_Rb19_2Fd9_6, FSK_Rb38_4Fd19_6, FSK_Rb57_6Fd28_8, FSK_Rb125Fd125, FSK_Rb_512Fd2_5, FSK_Rb_512Fd4_5, GFSK_Rb2Fd5, GFSK_Rb2_4Fd36, GFSK_Rb4_8Fd45, GFSK_Rb9_6Fd45, GFSK_Rb19_2Fd9_6, GFSK_Rb38_4Fd19_6, GFSK_Rb57_6Fd28_8, GFSK_Rb125Fd125, OOK_Rb1_2Bw75, OOK_Rb2_4Bw335, OOK_Rb4_8Bw335, OOK_Rb9_6Bw335, OOK_Rb19_2Bw335, OOK_Rb38_4Bw335, OOK_Rb40Bw335 }
enum | CRCPolynomial { CRC_CCITT = 0, CRC_16_IBM = 1, CRC_IEC_16 = 2, CRC_Biacheva = 3 }
| Defines the available choices for CRC Types of permitted CRC polynomials, to be passed to setCRCPolynomial() They deliberately have the same numeric values as the crc[1:0] field of Register RF22_REG_30_DATA_ACCESS_CONTROL. More...
Static Public Member Functions inherited from RF22
static void | printBuffer (const char *prompt, const uint8_t *buf, uint8_t len)
Protected Member Functions inherited from RF22
void | handleInterrupt ()
void | clearRxBuf ()
void | clearTxBuf ()
boolean | fillTxBuf (const uint8_t *data, uint8_t len)
boolean | appendTxBuf (const uint8_t *data, uint8_t len)
void | sendNextFragment ()
void | readNextFragment ()
void | resetFifos ()
void | resetRxFifo ()
void | resetTxFifo ()
virtual void | handleExternalInterrupt ()
virtual void | handleWakeupTimerInterrupt ()
void | setHeaderTo (uint8_t to)
void | setHeaderFrom (uint8_t from)
void | setHeaderId (uint8_t id)
void | setHeaderFlags (uint8_t flags)
void | startTransmit ()
void | restartTransmit ()
Static Protected Member Functions inherited from RF22
static void | isr0 ()
| Low level interrupt service routine for RF22 connected to interrupt 0.
static void | isr1 ()
| Low level interrupt service routine for RF22 connected to interrupt 1.
static void | isr2 ()
| Low level interrupt service routine for RF22 connected to interrupt 1.
Static Protected Attributes inherited from RF22
static RF22 * | _RF22ForInterrupt [] = {0, 0, 0}
| Array of instances connected to interrupts 0 and 1.

## 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] | 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.

## Member Function Documentation

boolean RF22Datagram::init | ( |  | ) |

Initialises this instance and the radio module connected to it. Overrides the init() function in RF22

References _thisAddress, RF22::init(), and setThisAddress().

Referenced by RF22Router::init().

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

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

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] | thisAddress | The 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:

- RF22Datagram.h
- RF22Datagram.cpp