RadioHead
|
Virtual Driver to encrypt/decrypt data. Can be used with any other RadioHead driver. More...
Public Member Functions | |
RHEncryptedDriver (RHGenericDriver &driver, BlockCipher &blockcipher) | |
virtual bool | init () |
virtual bool | available () |
virtual bool | recv (uint8_t *buf, uint8_t *len) |
virtual bool | send (const uint8_t *data, uint8_t len) |
virtual uint8_t | maxMessageLength () |
virtual bool | waitPacketSent () |
virtual bool | waitPacketSent (uint16_t timeout) |
virtual bool | waitAvailableTimeout (uint16_t timeout) |
virtual bool | waitCAD () |
void | setCADTimeout (unsigned long cad_timeout) |
virtual bool | isChannelActive () |
virtual void | setThisAddress (uint8_t thisAddress) |
virtual void | setHeaderTo (uint8_t to) |
virtual void | setHeaderFrom (uint8_t from) |
virtual void | setHeaderId (uint8_t id) |
virtual void | setHeaderFlags (uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC) |
virtual void | setPromiscuous (bool promiscuous) |
virtual uint8_t | headerTo () |
virtual uint8_t | headerFrom () |
virtual uint8_t | headerId () |
virtual uint8_t | headerFlags () |
int16_t | lastRssi () |
RHMode | mode () |
void | setMode (RHMode mode) |
Sets the operating mode of the transport. | |
virtual bool | sleep () |
virtual uint16_t | rxBad () |
virtual uint16_t | rxGood () |
virtual uint16_t | txGood () |
Public Member Functions inherited from RHGenericDriver | |
RHGenericDriver () | |
Constructor. | |
virtual | ~RHGenericDriver () |
Generic destructor to prevent warnings when objects are dynamically allocated. | |
virtual void | waitAvailable (uint16_t polldelay=0) |
virtual bool | waitAvailableTimeout (uint16_t timeout, uint16_t polldelay=0) |
void | setCADTimeout (unsigned long cad_timeout) |
Additional Inherited Members | |
Public Types inherited from RHGenericDriver | |
enum | RHMode { RHModeInitialising = 0 , RHModeSleep , RHModeIdle , RHModeTx , RHModeRx , RHModeCad } |
Defines different operating modes for the transport hardware. More... | |
Static Public Member Functions inherited from RHGenericDriver | |
static void | printBuffer (const char *prompt, const uint8_t *buf, uint8_t len) |
Protected Attributes inherited from RHGenericDriver | |
volatile RHMode | _mode |
The current transport operating mode. | |
uint8_t | _thisAddress |
This node id. | |
bool | _promiscuous |
Whether the transport is in promiscuous mode. | |
volatile uint8_t | _rxHeaderTo |
TO header in the last received mesasge. | |
volatile uint8_t | _rxHeaderFrom |
FROM header in the last received mesasge. | |
volatile uint8_t | _rxHeaderId |
ID header in the last received mesasge. | |
volatile uint8_t | _rxHeaderFlags |
FLAGS header in the last received mesasge. | |
uint8_t | _txHeaderTo |
TO header to send in all messages. | |
uint8_t | _txHeaderFrom |
FROM header to send in all messages. | |
uint8_t | _txHeaderId |
ID header to send in all messages. | |
uint8_t | _txHeaderFlags |
FLAGS header to send in all messages. | |
volatile int16_t | _lastRssi |
The value of the last received RSSI value, in some transport specific units. | |
volatile uint16_t | _rxBad |
Count of the number of bad messages (eg bad checksum etc) received. | |
volatile uint16_t | _rxGood |
Count of the number of successfully transmitted messaged. | |
volatile uint16_t | _txGood |
Count of the number of bad messages (correct checksum etc) received. | |
volatile bool | _cad |
Channel activity detected. | |
unsigned int | _cad_timeout |
Channel activity timeout in ms. | |
Virtual Driver to encrypt/decrypt data. Can be used with any other RadioHead driver.
This driver acts as a wrapper for any other RadioHead driver, adding encryption and decryption of messages that are passed to and from the actual radio driver. Only the message payload is encrypted, and not the to/from address or flags. Any of the encryption ciphers supported by ArduinoLibs Cryptographic Library http://rweather.github.io/arduinolibs/crypto.html may be used.
For successful communications, both sender and receiver must use the same cipher and the same key.
In order to enable this module you must uncomment #define RH_ENABLE_ENCRYPTION_MODULE at the bottom of RadioHead.h But ensure you have installed the Crypto directory from arduinolibs first: http://rweather.github.io/arduinolibs/index.html
RHEncryptedDriver::RHEncryptedDriver | ( | RHGenericDriver & | driver, |
BlockCipher & | blockcipher | ||
) |
Constructor. Adds a ciphering layer to messages sent and received by the actual transport driver.
[in] | driver | The RadioHead driver to use to transport messages. |
[in] | blockcipher | The blockcipher (from arduinolibs) that crypt/decrypt data. Ensure that the blockcipher has had its key set before sending or receiving messages. |
|
inlinevirtual |
Tests whether a new message is available from the Driver. On most drivers, this will also put the Driver into RHModeRx mode until a message is actually received by the transport, when it wil be returned to RHModeIdle. This can be called multiple times in a timeout loop
Implements RHGenericDriver.
References RHGenericDriver::available().
|
inlinevirtual |
Returns the FLAGS header of the last received message
Reimplemented from RHGenericDriver.
References RHGenericDriver::headerFlags().
|
inlinevirtual |
Returns the FROM header of the last received message
Reimplemented from RHGenericDriver.
References RHGenericDriver::headerFrom().
|
inlinevirtual |
Returns the ID header of the last received message
Reimplemented from RHGenericDriver.
References RHGenericDriver::headerId().
|
inlinevirtual |
Returns the TO header of the last received message
Reimplemented from RHGenericDriver.
References RHGenericDriver::headerTo().
|
inlinevirtual |
Calls the real driver's init()
Reimplemented from RHGenericDriver.
References RHGenericDriver::init().
|
inlinevirtual |
Determine if the currently selected radio channel is active. This is expected to be subclassed by specific radios to implement their Channel Activity Detection if supported. If the radio does not support CAD, returns true immediately. If a RadioHead radio supports isChannelActive() it will be documented in the radio specific documentation. This is called automatically by waitCAD().
Reimplemented from RHGenericDriver.
References RHGenericDriver::isChannelActive().
|
inlinevirtual |
Returns the most recent RSSI (Receiver Signal Strength Indicator). Usually it is the RSSI of the last received message, which is measured when the preamble is received. If you called readRssi() more recently, it will return that more recent value.
Reimplemented from RHGenericDriver.
References RHGenericDriver::lastRssi().
|
virtual |
Returns the maximum message length available in this Driver, which depends on the maximum length supported by the underlying transport driver.
Implements RHGenericDriver.
|
inlinevirtual |
Returns the operating mode of the library.
Reimplemented from RHGenericDriver.
References RHGenericDriver::mode().
Referenced by setMode().
|
virtual |
Turns the receiver on if it not already on. If there is a valid message available, copy it to buf and return true else return false. If a message is copied, *len is set to the length (Caution, 0 length messages are permitted). 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. |
Implements RHGenericDriver.
|
inlinevirtual |
Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc) which were rejected and not delivered to the application. Caution: not all drivers can correctly report this count. Some underlying hardware only report good packets.
Reimplemented from RHGenericDriver.
References RHGenericDriver::rxBad().
|
inlinevirtual |
Returns the count of the number of good received packets
Reimplemented from RHGenericDriver.
References RHGenericDriver::rxGood().
|
virtual |
Waits until any previous transmit packet is finished being transmitted with waitPacketSent(). Then optionally waits for Channel Activity Detection (CAD) to show the channnel is clear (if the radio supports CAD) by calling waitCAD(). Then loads a message into the transmitter and starts the transmitter. Note that a message length of 0 is permitted.
[in] | data | Array of data to be sent |
[in] | len | Number of bytes of data to send specify the maximum time in ms to wait. If 0 (the default) do not wait for CAD before transmitting. |
Implements RHGenericDriver.
|
inline |
Sets the Channel Activity Detection timeout in milliseconds to be used by waitCAD(). The default is 0, which means do not wait for CAD detection. CAD detection depends on support for isChannelActive() by your particular radio.
References RHGenericDriver::setCADTimeout().
|
inlinevirtual |
Sets and clears bits in the FLAGS header to be sent in all subsequent messages First it clears he FLAGS according to the clear argument, then sets the flags according to the set argument. The default for clear always clears the application specific flags.
[in] | set | bitmask of bits to be set. Flags are cleared with the clear mask before being set. |
[in] | clear | bitmask of flags to clear. Defaults to RH_FLAGS_APPLICATION_SPECIFIC which clears the application specific flags, resulting in new application specific flags identical to the set. |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setHeaderFlags().
|
inlinevirtual |
Sets the FROM header to be sent in all subsequent messages
[in] | from | The new FROM header value |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setHeaderFrom().
|
inlinevirtual |
Sets the ID header to be sent in all subsequent messages
[in] | id | The new ID header value |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setHeaderId().
|
inlinevirtual |
Sets the TO header to be sent in all subsequent messages
[in] | to | The new TO header value |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setHeaderTo().
|
inlinevirtual |
Sets the operating mode of the transport.
Reimplemented from RHGenericDriver.
References mode(), and RHGenericDriver::setMode().
|
inlinevirtual |
Tells the receiver to accept messages with any TO address, not just messages addressed to thisAddress or the broadcast address
[in] | promiscuous | true if you wish to receive messages with any TO address |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setPromiscuous().
|
inlinevirtual |
Sets the address of this node. Defaults to 0xFF. Subclasses or the user may want to change this. This will be used to test the adddress in incoming messages. In non-promiscuous mode, only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted. In promiscuous mode, all messages will be accepted regardless of the TO header. In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM). You would normally set the header FROM address to be the same as thisAddress (though you dont have to, allowing the possibilty of address spoofing).
[in] | thisAddress | The address of this node. |
Reimplemented from RHGenericDriver.
References RHGenericDriver::setThisAddress().
|
inlinevirtual |
Sets the transport hardware into low-power sleep mode (if supported). May be overridden by specific drivers to initialte sleep mode. If successful, the transport will stay in sleep mode until woken by changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc)
Reimplemented from RHGenericDriver.
References RHGenericDriver::sleep().
|
inlinevirtual |
Returns the count of the number of packets successfully transmitted (though not necessarily received by the destination)
Reimplemented from RHGenericDriver.
References RHGenericDriver::txGood().
|
inlinevirtual |
Starts the receiver and blocks until a received message is available or a timeout
[in] | timeout | Maximum time to wait in milliseconds. |
References RHGenericDriver::waitAvailableTimeout().
|
inlinevirtual |
Calls the waitCAD method in the driver
Reimplemented from RHGenericDriver.
References RHGenericDriver::waitCAD().
|
inlinevirtual |
Blocks until the transmitter is no longer transmitting.
Reimplemented from RHGenericDriver.
References RHGenericDriver::waitPacketSent().
|
inlinevirtual |
Blocks until the transmitter is no longer transmitting. or until the timeout occuers, whichever happens first
[in] | timeout | Maximum time to wait in milliseconds. |
Reimplemented from RHGenericDriver.
References RHGenericDriver::waitPacketSent().