MeshNet
1.0.0
|
#include <NRF24L01_interface.h>
Public Member Functions | |
NRF24L01_RFI (RF24 &Radio, HardwareSPI &_spi, uint8_t IRQ_pin=255, ThreadLock *_lock=NULL) | |
Constructor. More... | |
~NRF24L01_RFI () override | |
bool | init () override |
Override this method to initialize radio and communication with it. More... | |
bool | deInit () override |
Override this method to de-initialize radio and communication with it. More... | |
bool | hasError () override |
Override this method to check if radio has some error or is not connected to MCU. If this method returns true, deInit() method in meshNet will be called. More... | |
bool | send (uint8_t *data, uint8_t dataSize) override |
Override this method to send data through radio. More... | |
bool | recv (uint8_t *data, uint8_t &dataSize, int8_t &rssi) override |
Override this method to read data from radio buffer. More... | |
uint8_t | available () override |
Override this method to get raw size of received frame in bytes. More... | |
bool | sleep () override |
Override this method to temporary power off the radio. If the radio cannot sleep, just return true. More... | |
bool | wakeUp () override |
Override this method to temporary power on (wake up) the radio from sleep. If the radio cannot sleep, just return true. More... | |
bool | checkInterference () override |
Override this method to check, if there is currently an interference in the air. If interference check cannot be done on selected radio, just return false. This method is used to check, if radio can send data or has to wait on another radio. More... | |
bool | setChannel (uint8_t channel) override |
Override this method to set radio channel. If channels cannot be set on selected radio, just return false. More... | |
bool | setPower (uint8_t power) override |
Override this method to set radio output power. If radio output power cannot be set, just return true. More... | |
bool | setFullSpeed (bool enableFullSpeed) override |
Override this method to set full or slow speed (data rate). If speed cannot be set, just return true. More... | |
bool | setReceiveInterruptCallback (void(*InterruptCallback)(void)) override |
Override this method to set receive message interrupt method. If interrupt cannot be set or is not supported, return false. More... | |
bool | interruptHandle () override |
This method has to be done, when ReceiveInterrupt happened. More... | |
void | handle () override |
This method is included in meshNet::handle() method and it is included in main loop. More... | |
void | printDetails (OSTREAM *stream) override |
This method is used to print radio details to stream (usually to Serial port). Method is also called, when "mesh radio info" command has been called in SerialConsole. More... | |
uint8_t | scanChannels (uint8_t startChannel, uint8_t endChannel, uint8_t retries=50, OSTREAM *stream=NULL) override |
This method has to scan all free channels and returns channel with minimum interferences. Method is also called, when "mesh radio scan channels <int:retries>" command has been called in SerialConsole. More... | |
uint8_t | scanChannels (uint8_t startChannel, uint8_t endChannel, OSTREAM *stream=NULL) override |
This method has to scan all free channels and returns channel with minimum interferences. Method is also called, when "mesh radio scan channels <int:retries>" command has been called in SerialConsole. Retries count is set to best value. More... | |
bool | scanChannelsWorking () override |
Checks if channel scan is processed now. More... | |
uint32_t | getChannelsWidth () override |
Gets width of each channels in kHz. More... | |
uint8_t * | getInternalTemporaryBuffer () override |
Gets pointer to internal temporary buffer with size of MaxFrameLength. This buffer can be used for temporary storing of received data. More... | |
![]() | |
RFInterface (const uint8_t maxFrameLength, const RFIType interfaceType, const bool canCheckInterference, const uint8_t maxChannelNumber, const uint8_t minChannelNumber, const uint8_t maxPowerValue, const uint8_t minPowerValue, const bool canSetSpeed, const uint32_t baseFrequency, ThreadLock *_lock) | |
Constructor - has to be overridden and parameters have to be set in overridden constructor. More... | |
virtual | ~RFInterface ()=0 |
Data Fields | |
uint8_t | internalTmpBuffer [NRF24L01_RFI_MAX_MSG_SIZE] |
![]() | |
const uint8_t | MaxFrameLength |
RF_NO_INTERNAL_TMP_BUFFER. More... | |
const RFIType | InterfaceType |
Interface type, see RFIType. More... | |
const bool | CanCheckInterference:1 |
True when interference can be checked. More... | |
const uint8_t | MaxChannelNumber |
Maximum channel number. When this value is equal or lower than MinChannelNumber, radio channel cannot be set. More... | |
const uint8_t | MinChannelNumber |
Minimum channel number. When this value is equal or higher than MaxChannelNumber, radio channel cannot be set. More... | |
const uint8_t | MaxPowerValue |
Maximum power level value. When this value is equal or lower than MinPowerValue, radio output power cannot be set. More... | |
const uint8_t | MinPowerValue |
Minimum power level value. When this value is equal or higher than MaxPowerValue, radio output power cannot be set. More... | |
const bool | CanSetSpeed:1 |
True when speed (data rate) can be set. More... | |
const uint32_t | BaseFrequency |
Frequency of channel 0 in kHz. More... | |
ThreadLock * | lock |
Thread lock, that is used to lock current methods. More... | |
Protected Attributes | |
RF24 * | radio = NULL |
RF_NO_INTERNAL_TMP_BUFFER. More... | |
HardwareSPI * | spi = NULL |
uint8_t | IRQ_Pin = 255 |
uint8_t | lastChannel = MinChannelNumber |
rf24_datarate_e | lastSpeed = RF24_250KBPS |
bool | scanWorking = false |
Static Protected Attributes | |
const static uint32_t | dummy_address = 0xE7E7E7UL |
NRF24L01_RFI::NRF24L01_RFI | ( | RF24 & | Radio, |
HardwareSPI & | _spi, | ||
uint8_t | IRQ_pin = 255 , |
||
ThreadLock * | _lock = NULL |
||
) |
Constructor.
Radio | Instance of RF24 radio class, that can communicate with NRF24L01. |
_spi | HardwareSPI instance, where Radio is connected. |
IRQ_pin | Pin number on MCU, where NRF's IRQ pin is connected. If set to 255, interrupt is disabled. |
_lock | Pointer to lock instance, which is used to lock SPI. If set to NULL, lock will not be used. |
|
override |
|
overridevirtual |
Override this method to get raw size of received frame in bytes.
Implements RFInterface.
|
overridevirtual |
Override this method to check, if there is currently an interference in the air. If interference check cannot be done on selected radio, just return false. This method is used to check, if radio can send data or has to wait on another radio.
Implements RFInterface.
|
overridevirtual |
Override this method to de-initialize radio and communication with it.
Implements RFInterface.
|
overridevirtual |
Gets width of each channels in kHz.
Implements RFInterface.
|
overridevirtual |
Gets pointer to internal temporary buffer with size of MaxFrameLength. This buffer can be used for temporary storing of received data.
Implements RFInterface.
|
overridevirtual |
This method is included in meshNet::handle() method and it is included in main loop.
Implements RFInterface.
|
overridevirtual |
Override this method to check if radio has some error or is not connected to MCU. If this method returns true, deInit() method in meshNet will be called.
Implements RFInterface.
|
overridevirtual |
Override this method to initialize radio and communication with it.
Implements RFInterface.
|
overridevirtual |
This method has to be done, when ReceiveInterrupt happened.
Implements RFInterface.
|
overridevirtual |
This method is used to print radio details to stream (usually to Serial port). Method is also called, when "mesh radio info" command has been called in SerialConsole.
stream | Stream, where to print details. |
Implements RFInterface.
|
overridevirtual |
Override this method to read data from radio buffer.
[out] | data | Buffer reserved for data to be recived. The size of buffer has to at least MaxFrameLength value. Internal temporary buffer can be used here, see getInternalTemporaryBuffer(). |
[in,out] | dataSize | Insert size of buffer. After calling, size of received data is assigned to this variable. |
[out] | rssi | RSSI value of current frame in dBm. If RSSI is unknown, set it to 0. |
Implements RFInterface.
|
inlineoverridevirtual |
This method has to scan all free channels and returns channel with minimum interferences. Method is also called, when "mesh radio scan channels <int:retries>" command has been called in SerialConsole. Retries count is set to best value.
stream | Stream, where to print details about scanning. If stream is NULL, no data will be printed. First line has to contain: "Retries: X" where the X is the number of retries for each channel. Second line has to contain: "Channel span: X" where the X is the number of skipped channels (those skipped channels has same interference count as previous channel). Value has to be greater than 0. Third line has to contain: "Base frequency: X" where the X is the frequency of channel 0 in kHz. Fourth line has to contain: "Channel width: X" where the X is the width of each channel in kHz. Each line has to contain this text: "C: I" where C is channel number and I is the number of retries, where interference has been found. |
startChannel | Channel, from which to start scanning. |
endChannel | Last scanned channel. |
Implements RFInterface.
|
overridevirtual |
This method has to scan all free channels and returns channel with minimum interferences. Method is also called, when "mesh radio scan channels <int:retries>" command has been called in SerialConsole.
stream | Stream, where to print details about scanning. If stream is NULL, no data will be printed. First line has to contain: "Retries: X" where the X is number of retries for each channel. Each line has to contain this text: "C: I" where C is channel number and I is the number of retries, where interference has been found. |
retries | Number of retries for each channel. |
startChannel | Channel, from which to start scanning. |
endChannel | Last scanned channel. |
Implements RFInterface.
|
overridevirtual |
Checks if channel scan is processed now.
Implements RFInterface.
|
overridevirtual |
Override this method to send data through radio.
[in] | data | Raw frame data to be sent. |
[in] | dataSize | Size of sending data. The size cannot exceed MaxFrameLength value. |
Implements RFInterface.
|
overridevirtual |
Override this method to set radio channel. If channels cannot be set on selected radio, just return false.
channel | Channel number to set. This value have to be between MaxChannelNumber (included) and MinChannelNumber (included). |
Implements RFInterface.
|
overridevirtual |
Override this method to set full or slow speed (data rate). If speed cannot be set, just return true.
enableFullSpeed | True to send data at full speed or false to send data at slow speed. |
Implements RFInterface.
|
overridevirtual |
Override this method to set radio output power. If radio output power cannot be set, just return true.
Implements RFInterface.
|
overridevirtual |
Override this method to set receive message interrupt method. If interrupt cannot be set or is not supported, return false.
InterruptCallback | Callback function, that is called when radio has received new packet. When InterruptCallback is nullptr, interrupt has to be detached. |
Implements RFInterface.
|
overridevirtual |
Override this method to temporary power off the radio. If the radio cannot sleep, just return true.
Implements RFInterface.
|
overridevirtual |
Override this method to temporary power on (wake up) the radio from sleep. If the radio cannot sleep, just return true.
Implements RFInterface.
|
staticprotected |
uint8_t NRF24L01_RFI::internalTmpBuffer[NRF24L01_RFI_MAX_MSG_SIZE] |
|
protected |
|
protected |
|
protected |
|
protected |
RF_NO_INTERNAL_TMP_BUFFER.
|
protected |
|
protected |