RadioLib
Universal wireless communication library for Arduino
|
Control class for nRF24 module. More...
#include <nRF24.h>
Public Member Functions | |
nRF24 (Module *mod) | |
Default constructor. More... | |
Module * | getMod () |
int16_t | begin (int16_t freq=RADIOLIB_NRF24_DEFAULT_FREQ, int16_t dataRate=RADIOLIB_NRF24_DEFAULT_DR, int8_t power=RADIOLIB_NRF24_DEFAULT_POWER, uint8_t addrWidth=RADIOLIB_NRF24_DEFAULT_ADDRWIDTH) |
Initialization method. More... | |
int16_t | sleep () |
Sets the module to sleep mode. More... | |
int16_t | standby () override |
Sets the module to standby mode. More... | |
int16_t | standby (uint8_t mode) override |
Sets the module to standby. More... | |
int16_t | transmit (uint8_t *data, size_t len, uint8_t addr) override |
Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | receive (uint8_t *data, size_t len) override |
Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | transmitDirect (uint32_t frf=0) override |
Starts direct mode transmission. More... | |
int16_t | receiveDirect () override |
Dummy direct mode reception method, to ensure PhysicalLayer compatibility. More... | |
void | setIrqAction (void(*func)(void)) |
Sets interrupt service routine to call when IRQ activates. More... | |
int16_t | startTransmit (uint8_t *data, size_t len, uint8_t addr) override |
Interrupt-driven binary transmit method. IRQ will be activated when full packet is transmitted. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | finishTransmit () override |
Clean up after transmission is done. More... | |
int16_t | startReceive () |
Interrupt-driven receive method. IRQ will be activated when full packet is received. More... | |
int16_t | readData (uint8_t *data, size_t len) override |
Reads data received after calling startReceive method. More... | |
int16_t | setFrequency (float freq) |
Sets carrier frequency. Allowed values range from 2400 MHz to 2525 MHz. More... | |
int16_t | setBitRate (float br) |
Sets bit rate. Allowed values are 2000, 1000 or 250 kbps. More... | |
int16_t | setOutputPower (int8_t power) |
Sets output power. Allowed values are -18, -12, -6 or 0 dBm. More... | |
int16_t | setAddressWidth (uint8_t addrWidth) |
Sets address width of transmit and receive pipes in bytes. Allowed values are 3, 4 or 5 bytes. More... | |
int16_t | setTransmitPipe (uint8_t *addr) |
Sets address of transmit pipe. The address width must be the same as the same as the configured in setAddressWidth. More... | |
int16_t | setReceivePipe (uint8_t pipeNum, uint8_t *addr) |
Sets address of receive pipes 0 or 1. The address width must be the same as the same as the configured in setAddressWidth. More... | |
int16_t | setReceivePipe (uint8_t pipeNum, uint8_t addrByte) |
Sets address of receive pipes 2 - 5. The first 2 - 4 address bytes for these pipes are the same as for address pipe 1, only the last byte can be set. More... | |
int16_t | disablePipe (uint8_t pipeNum) |
Disables specified receive pipe. More... | |
int16_t | getStatus (uint8_t mask=0xFF) |
Gets nRF24 status register. More... | |
bool | isCarrierDetected () |
Checks if carrier was detected during last RX. More... | |
int16_t | setFrequencyDeviation (float freqDev) override |
Dummy configuration method, to ensure PhysicalLayer compatibility. More... | |
size_t | getPacketLength (bool update=true) override |
Query modem for the packet length of received payload. More... | |
int16_t | setCrcFiltering (bool crcOn=true) |
Enable CRC filtering and generation. More... | |
int16_t | setAutoAck (bool autoAckOn=true) |
Enable or disable auto-acknowledge packets on all pipes. More... | |
int16_t | setAutoAck (uint8_t pipeNum, bool autoAckOn) |
Enable or disable auto-acknowledge packets on given pipe. More... | |
int16_t | setDataShaping (uint8_t sh) override |
Dummy data shaping configuration method, to ensure PhysicalLayer compatibility. More... | |
int16_t | setEncoding (uint8_t encoding) override |
Dummy encoding configuration method, to ensure PhysicalLayer compatibility. More... | |
uint8_t | randomByte () |
Dummy random method, to ensure PhysicalLayer compatibility. More... | |
void | setDirectAction (void(*func)(void)) |
Dummy method, to ensure PhysicalLayer compatibility. More... | |
void | readBit (RADIOLIB_PIN_TYPE pin) |
Dummy method, to ensure PhysicalLayer compatibility. More... | |
int16_t | transmit (__FlashStringHelper *fstr, uint8_t addr=0) |
Arduino Flash String transmit method. More... | |
int16_t | transmit (String &str, uint8_t addr=0) |
Arduino String transmit method. More... | |
int16_t | transmit (const char *str, uint8_t addr=0) |
C-string transmit method. More... | |
virtual int16_t | transmit (uint8_t *data, size_t len, uint8_t addr=0) |
Binary transmit method. Must be implemented in module class. More... | |
int16_t | receive (String &str, size_t len=0) |
Arduino String receive method. More... | |
virtual int16_t | receive (uint8_t *data, size_t len) |
Binary receive method. Must be implemented in module class. More... | |
int16_t | startTransmit (String &str, uint8_t addr=0) |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More... | |
int16_t | startTransmit (const char *str, uint8_t addr=0) |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More... | |
virtual int16_t | startTransmit (uint8_t *data, size_t len, uint8_t addr=0) |
Interrupt-driven binary transmit method. More... | |
int16_t | readData (String &str, size_t len=0) |
Reads data that was received after calling startReceive method. More... | |
virtual int16_t | readData (uint8_t *data, size_t len) |
Reads data that was received after calling startReceive method. More... | |
![]() | |
PhysicalLayer (float freqStep, size_t maxPacketLength) | |
Default constructor. More... | |
int16_t | transmit (__FlashStringHelper *fstr, uint8_t addr=0) |
Arduino Flash String transmit method. More... | |
int16_t | transmit (String &str, uint8_t addr=0) |
Arduino String transmit method. More... | |
int16_t | transmit (const char *str, uint8_t addr=0) |
C-string transmit method. More... | |
int16_t | receive (String &str, size_t len=0) |
Arduino String receive method. More... | |
int16_t | startTransmit (String &str, uint8_t addr=0) |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More... | |
int16_t | startTransmit (const char *str, uint8_t addr=0) |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes. More... | |
int16_t | readData (String &str, size_t len=0) |
Reads data that was received after calling startReceive method. More... | |
float | getFreqStep () const |
Gets the module frequency step size that was set in constructor. More... | |
int32_t | random (int32_t max) |
Get truly random number in range 0 - max. More... | |
int32_t | random (int32_t min, int32_t max) |
Get truly random number in range min - max. More... | |
int16_t | startDirect () |
Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25. Only available in FSK mode. More... | |
int16_t | setDirectSyncWord (uint32_t syncWord, uint8_t len) |
Set sync word to be used to determine start of packet in direct reception mode. More... | |
int16_t | available () |
Get the number of direct mode bytes currently available in buffer. More... | |
void | dropSync () |
Forcefully drop synchronization. | |
uint8_t | read (bool drop=true) |
Get data from direct mode buffer. More... | |
virtual int16_t | setDIOMapping (RADIOLIB_PIN_TYPE pin, uint8_t value) |
Configure DIO pin mapping to get a given signal on a DIO pin (if available). More... | |
Control class for nRF24 module.
nRF24::nRF24 | ( | Module * | mod | ) |
Default constructor.
mod | Instance of Module that will be used to communicate with the radio. |
int16_t nRF24::begin | ( | int16_t | freq = RADIOLIB_NRF24_DEFAULT_FREQ , |
int16_t | dataRate = RADIOLIB_NRF24_DEFAULT_DR , |
||
int8_t | power = RADIOLIB_NRF24_DEFAULT_POWER , |
||
uint8_t | addrWidth = RADIOLIB_NRF24_DEFAULT_ADDRWIDTH |
||
) |
Initialization method.
freq | Carrier frequency in MHz. Defaults to 2400 MHz. |
dataRate | Data rate to be used in kbps. Defaults to 1000 kbps. |
power | Output power in dBm. Defaults to -12 dBm. |
addrWidth | Address width in bytes. Defaults to 5 bytes. |
int16_t nRF24::disablePipe | ( | uint8_t | pipeNum | ) |
|
overridevirtual |
|
overridevirtual |
Query modem for the packet length of received payload.
update | Update received packet length. Will return cached value when set to false. |
Reimplemented from PhysicalLayer.
int16_t nRF24::getStatus | ( | uint8_t | mask = 0xFF | ) |
Gets nRF24 status register.
mask | Bit mask to be used on the returned register value. |
bool nRF24::isCarrierDetected | ( | ) |
Checks if carrier was detected during last RX.
|
virtual |
Dummy random method, to ensure PhysicalLayer compatibility.
Reimplemented from PhysicalLayer.
|
virtual |
Dummy method, to ensure PhysicalLayer compatibility.
pin | Ignored. |
Reimplemented from PhysicalLayer.
int16_t PhysicalLayer::readData |
Reads data that was received after calling startReceive method.
str | Address of Arduino String to save the received data. |
len | Expected number of characters in the message. When set to 0, the packet length will be retreived automatically. When more bytes than received are requested, only the number of bytes requested will be returned. |
int16_t PhysicalLayer::readData |
Reads data that was received after calling startReceive method.
data | Pointer to array to save the received binary data. |
len | Number of bytes that will be read. When set to 0, the packet length will be retreived automatically. When more bytes than received are requested, only the number of bytes requested will be returned. |
|
overridevirtual |
Reads data received after calling startReceive method.
data | Pointer to array to save the received binary data. |
len | Number of bytes that will be received. Must be known in advance for binary transmissions. |
Reimplemented from PhysicalLayer.
int16_t PhysicalLayer::receive |
Arduino String receive method.
str | Address of Arduino String to save the received data. |
len | Expected number of characters in the message. Leave as 0 if expecting a unknown size packet |
int16_t PhysicalLayer::receive |
Binary receive method. Must be implemented in module class.
data | Pointer to array to save the received binary data. |
len | Number of bytes that will be received. Must be known in advance for binary transmissions. |
|
overridevirtual |
Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer.
data | Binary data to be sent. |
len | Number of bytes to send. |
Reimplemented from PhysicalLayer.
|
overridevirtual |
Dummy direct mode reception method, to ensure PhysicalLayer compatibility.
Reimplemented from PhysicalLayer.
int16_t nRF24::setAddressWidth | ( | uint8_t | addrWidth | ) |
Sets address width of transmit and receive pipes in bytes. Allowed values are 3, 4 or 5 bytes.
addrWidth | Address width to be set in bytes. |
int16_t nRF24::setAutoAck | ( | bool | autoAckOn = true | ) |
Enable or disable auto-acknowledge packets on all pipes.
autoAckOn | Enable (true) or disable (false) auto-acks. |
int16_t nRF24::setAutoAck | ( | uint8_t | pipeNum, |
bool | autoAckOn | ||
) |
Enable or disable auto-acknowledge packets on given pipe.
pipeNum | Number of pipe to which enable / disable auto-acks. |
autoAckOn | Enable (true) or disable (false) auto-acks. |
|
virtual |
Sets bit rate. Allowed values are 2000, 1000 or 250 kbps.
br | Bit rate to be set in kbps. |
Reimplemented from PhysicalLayer.
int16_t nRF24::setCrcFiltering | ( | bool | crcOn = true | ) |
|
overridevirtual |
Dummy data shaping configuration method, to ensure PhysicalLayer compatibility.
sh | Ignored. |
Reimplemented from PhysicalLayer.
|
virtual |
Dummy method, to ensure PhysicalLayer compatibility.
func | Ignored. |
Reimplemented from PhysicalLayer.
|
overridevirtual |
Dummy encoding configuration method, to ensure PhysicalLayer compatibility.
sh | Ignored. |
Reimplemented from PhysicalLayer.
|
virtual |
Sets carrier frequency. Allowed values range from 2400 MHz to 2525 MHz.
freq | Carrier frequency to be set in MHz. |
Reimplemented from PhysicalLayer.
|
overridevirtual |
Dummy configuration method, to ensure PhysicalLayer compatibility.
freqDev | Dummy frequency deviation parameter, no configuration will be changed. |
Reimplemented from PhysicalLayer.
void nRF24::setIrqAction | ( | void(*)(void) | func | ) |
Sets interrupt service routine to call when IRQ activates.
func | ISR to call. |
int16_t nRF24::setOutputPower | ( | int8_t | power | ) |
Sets output power. Allowed values are -18, -12, -6 or 0 dBm.
power | Output power to be set in dBm. |
int16_t nRF24::setReceivePipe | ( | uint8_t | pipeNum, |
uint8_t * | addr | ||
) |
Sets address of receive pipes 0 or 1. The address width must be the same as the same as the configured in setAddressWidth.
pipeNum | Number of pipe to which the address shall be set. Either 0 or 1, other pipes are handled using overloaded method. |
addr | Address from which nRF24 shall receive new packets on the specified pipe. |
int16_t nRF24::setReceivePipe | ( | uint8_t | pipeNum, |
uint8_t | addrByte | ||
) |
Sets address of receive pipes 2 - 5. The first 2 - 4 address bytes for these pipes are the same as for address pipe 1, only the last byte can be set.
pipeNum | Number of pipe to which the address shall be set. Allowed values range from 2 to 5. |
addrByte | LSB of address from which nRF24 shall receive new packets on the specified pipe. |
int16_t nRF24::setTransmitPipe | ( | uint8_t * | addr | ) |
Sets address of transmit pipe. The address width must be the same as the same as the configured in setAddressWidth.
addr | Address to which the next packet shall be transmitted. |
int16_t nRF24::sleep | ( | ) |
Sets the module to sleep mode.
|
overridevirtual |
|
overridevirtual |
Sets the module to standby.
mode | Standby mode to be used. |
Reimplemented from PhysicalLayer.
int16_t nRF24::startReceive | ( | ) |
Interrupt-driven receive method. IRQ will be activated when full packet is received.
int16_t PhysicalLayer::startTransmit |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.
str | C-string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::startTransmit |
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking. Interrupt pin will be activated when transmission finishes.
str | Address of Arduino String that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
|
overridevirtual |
Interrupt-driven binary transmit method. IRQ will be activated when full packet is transmitted. Overloads for string-based transmissions are implemented in PhysicalLayer.
data | Binary data to be sent. |
len | Number of bytes to send. |
addr | Dummy address parameter, to ensure PhysicalLayer compatibility. |
Reimplemented from PhysicalLayer.
int16_t PhysicalLayer::startTransmit |
Interrupt-driven binary transmit method.
data | Binary data that will be transmitted. |
len | Length of binary data to transmit (in bytes). |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::transmit |
Arduino Flash String transmit method.
str | Pointer to Arduino Flash String that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::transmit |
C-string transmit method.
str | C-string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
int16_t PhysicalLayer::transmit |
Arduino String transmit method.
str | Address of Arduino string that will be transmitted. |
addr | Node address to transmit the packet to. Only used in FSK mode. |
|
overridevirtual |
Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.
data | Binary data to be sent. |
len | Number of bytes to send. |
addr | Dummy address parameter, to ensure PhysicalLayer compatibility. |
Reimplemented from PhysicalLayer.
int16_t PhysicalLayer::transmit |
Binary transmit method. Must be implemented in module class.
data | Binary data that will be transmitted. |
len | Length of binary data to transmit (in bytes). |
addr | Node address to transmit the packet to. Only used in FSK mode. |
|
overridevirtual |
Starts direct mode transmission.
frf | Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY. |
Reimplemented from PhysicalLayer.