ClusterDuck Protocol
|
Control class for CC1101 module. More...
#include <CC1101.h>
Public Member Functions | |
CC1101 (Module *module) | |
Default constructor. More... | |
int16_t | begin (float freq=868.0, float br=4.8, float freqDev=48.0, float rxBw=325.0, int8_t power=0, uint8_t preambleLength=4) |
Initialization method. More... | |
int16_t | transmit (uint8_t *data, size_t len, uint8_t addr=0) |
Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | receive (uint8_t *data, size_t len) |
Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | standby () |
Sets the module to standby mode. More... | |
int16_t | transmitDirect (uint32_t frf=0) |
Starts direct mode transmission. More... | |
int16_t | receiveDirect () |
Starts direct mode reception. More... | |
int16_t | packetMode () |
Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions. | |
void | setGdo0Action (void(*func)(void), uint8_t dir=FALLING) |
Sets interrupt service routine to call when GDO0 activates. More... | |
void | clearGdo0Action () |
Clears interrupt service routine to call when GDO0 activates. | |
void | setGdo2Action (void(*func)(void), uint8_t dir=FALLING) |
Sets interrupt service routine to call when GDO2 activates. More... | |
void | clearGdo2Action () |
Clears interrupt service routine to call when GDO0 activates. | |
int16_t | startTransmit (uint8_t *data, size_t len, uint8_t addr=0) |
Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More... | |
int16_t | startReceive () |
Interrupt-driven receive method. GDO0 will be activated when full packet is received. More... | |
int16_t | readData (uint8_t *data, size_t len) |
Reads data received after calling startReceive method. More... | |
int16_t | setFrequency (float freq) |
Sets carrier frequency. Allowed values are in bands 300.0 to 348.0 MHz, 387.0 to 464.0 MHz and 779.0 to 928.0 MHz. More... | |
int16_t | setBitRate (float br) |
Sets bit rate. Allowed values range from 0.025 to 600.0 kbps. More... | |
int16_t | setRxBandwidth (float rxBw) |
Sets receiver bandwidth. Allowed values range from 58.0 to 812.0 kHz. More... | |
int16_t | setFrequencyDeviation (float freqDev) |
Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz. More... | |
int16_t | setOutputPower (int8_t power) |
Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm. More... | |
int16_t | setSyncWord (uint8_t syncH, uint8_t syncL, uint8_t maxErrBits=0, bool requireCarrierSense=false) |
Sets 16-bit sync word as a two byte value. More... | |
int16_t | setSyncWord (uint8_t *syncWord, uint8_t len, uint8_t maxErrBits=0, bool requireCarrierSense=false) |
Sets 1 or 2 bytes of sync word. More... | |
int16_t | setPreambleLength (uint8_t preambleLength) |
Sets preamble length. More... | |
int16_t | setNodeAddress (uint8_t nodeAddr, uint8_t numBroadcastAddrs=0) |
Sets node and broadcast addresses. Calling this method will also enable address filtering. More... | |
int16_t | disableAddressFiltering () |
Disables address filtering. Calling this method will also erase previously set addresses. More... | |
int16_t | setOOK (bool enableOOK) |
Enables/disables OOK modulation instead of FSK. More... | |
float | getRSSI () |
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. More... | |
uint8_t | getLQI () |
Gets LQI (Link Quality Indicator) of the last received packet. More... | |
size_t | getPacketLength (bool update=true) |
Query modem for the packet length of received payload. More... | |
int16_t | fixedPacketLengthMode (uint8_t len=CC1101_MAX_PACKET_LENGTH) |
Set modem in fixed packet length mode. More... | |
int16_t | variablePacketLengthMode (uint8_t maxLen=CC1101_MAX_PACKET_LENGTH) |
Set modem in variable packet length mode. More... | |
int16_t | enableSyncWordFiltering (uint8_t maxErrBits=0, bool requireCarrierSense=false) |
Enable sync word filtering and generation. More... | |
int16_t | disableSyncWordFiltering (bool requireCarrierSense=false) |
Disable preamble and sync word filtering and generation. More... | |
int16_t | setCrcFiltering (bool crcOn=true) |
Enable CRC filtering and generation. More... | |
int16_t | setPromiscuousMode (bool promiscuous=true) |
Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC). More... | |
int16_t | setDataShaping (float sh) |
Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed value is 0.5. Set to 0 to disable data shaping. More... | |
int16_t | setEncoding (uint8_t encoding) |
Sets transmission encoding. 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)=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)=0 |
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)=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)=0 |
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 () |
Gets the module frequency step size that was set in constructor. More... | |
Control class for CC1101 module.
CC1101::CC1101 | ( | Module * | module | ) |
Default constructor.
mod | Instance of Module that will be used to communicate with the radio. |
int16_t CC1101::begin | ( | float | freq = 868.0 , |
float | br = 4.8 , |
||
float | freqDev = 48.0 , |
||
float | rxBw = 325.0 , |
||
int8_t | power = 0 , |
||
uint8_t | preambleLength = 4 |
||
) |
Initialization method.
freq | Carrier frequency in MHz. Defaults to 868.0 MHz. |
br | Bit rate to be used in kbps. Defaults to 4.8 kbps. |
freqDev | Frequency deviation from carrier frequency in kHz Defaults to 48.0 kHz. |
rxBw | Receiver bandwidth in kHz. Defaults to 325.0 kHz. |
power | Output power in dBm. Defaults to 0 dBm. |
preambleLength | Preamble Length in bytes. Defaults to 4 bytes. |
int16_t CC1101::disableAddressFiltering | ( | ) |
Disables address filtering. Calling this method will also erase previously set addresses.
int16_t CC1101::disableSyncWordFiltering | ( | bool | requireCarrierSense = false | ) |
Disable preamble and sync word filtering and generation.
requireCarrierSense | Require carrier sense above threshold. |
int16_t CC1101::enableSyncWordFiltering | ( | uint8_t | maxErrBits = 0 , |
bool | requireCarrierSense = false |
||
) |
Enable sync word filtering and generation.
numBits | Sync word length in bits. |
requireCarrierSense | Require carrier sense above threshold in addition to sync word. |
int16_t CC1101::fixedPacketLengthMode | ( | uint8_t | len = CC1101_MAX_PACKET_LENGTH | ) |
uint8_t CC1101::getLQI | ( | ) |
Gets LQI (Link Quality Indicator) of the last received packet.
|
virtual |
Query modem for the packet length of received payload.
update | Update received packet length. Will return cached value when set to false. |
Implements PhysicalLayer.
float CC1101::getRSSI | ( | ) |
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
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. |
|
virtual |
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. |
Implements PhysicalLayer.
virtual 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 received. Must be known in advance for binary transmissions. |
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 |
|
virtual |
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. |
Implements PhysicalLayer.
virtual 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. |
|
virtual |
int16_t CC1101::setBitRate | ( | float | br | ) |
Sets bit rate. Allowed values range from 0.025 to 600.0 kbps.
br | Bit rate to be set in kbps. |
int16_t CC1101::setCrcFiltering | ( | bool | crcOn = true | ) |
Enable CRC filtering and generation.
crcOn | Set or unset promiscuous mode. |
|
virtual |
Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed value is 0.5. Set to 0 to disable data shaping.
sh | Gaussian shaping bandwidth-time product that will be used for data shaping |
Implements PhysicalLayer.
|
virtual |
Sets transmission encoding.
encoding | Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening. |
Implements PhysicalLayer.
int16_t CC1101::setFrequency | ( | float | freq | ) |
Sets carrier frequency. Allowed values are in bands 300.0 to 348.0 MHz, 387.0 to 464.0 MHz and 779.0 to 928.0 MHz.
freq | Carrier frequency to be set in MHz. |
|
virtual |
Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz.
freqDev | Frequency deviation to be set in kHz. |
Implements PhysicalLayer.
void CC1101::setGdo0Action | ( | void(*)(void) | func, |
uint8_t | dir = FALLING |
||
) |
Sets interrupt service routine to call when GDO0 activates.
func | ISR to call. |
dir | Signal change direction. Defaults to FALLING. |
void CC1101::setGdo2Action | ( | void(*)(void) | func, |
uint8_t | dir = FALLING |
||
) |
Sets interrupt service routine to call when GDO2 activates.
func | ISR to call. |
dir | Signal change direction. Defaults to FALLING. |
int16_t CC1101::setNodeAddress | ( | uint8_t | nodeAddr, |
uint8_t | numBroadcastAddrs = 0 |
||
) |
Sets node and broadcast addresses. Calling this method will also enable address filtering.
nodeAddr | Node address to be set. |
numBroadcastAddrs | Number of broadcast addresses to be used. Can be set to 0 (no broadcast), 1 (broadcast at 0x00) or 2 (broadcast at 0x00 and 0xFF). |
int16_t CC1101::setOOK | ( | bool | enableOOK | ) |
Enables/disables OOK modulation instead of FSK.
enableOOK | Enable (true) or disable (false) OOK. |
int16_t CC1101::setOutputPower | ( | int8_t | power | ) |
Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.
power | Output power to be set in dBm. |
int16_t CC1101::setPreambleLength | ( | uint8_t | preambleLength | ) |
Sets preamble length.
preambleLength | Preamble length to be set (in bytes), allowed values: 2, 3, 4, 6, 8, 12, 16, 24 |
int16_t CC1101::setPromiscuousMode | ( | bool | promiscuous = true | ) |
Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).
promiscuous | Set or unset promiscuous mode. |
int16_t CC1101::setRxBandwidth | ( | float | rxBw | ) |
Sets receiver bandwidth. Allowed values range from 58.0 to 812.0 kHz.
rxBw | Receiver bandwidth to be set in kHz. |
int16_t CC1101::setSyncWord | ( | uint8_t * | syncWord, |
uint8_t | len, | ||
uint8_t | maxErrBits = 0 , |
||
bool | requireCarrierSense = false |
||
) |
Sets 1 or 2 bytes of sync word.
syncWord | Pointer to the array of sync word bytes. |
len | Sync word length in bytes. |
maxErrBits | Maximum allowed number of bit errors in received sync word. Defaults to 0. |
requireCarrierSense | Require carrier sense above threshold in addition to sync word. |
int16_t CC1101::setSyncWord | ( | uint8_t | syncH, |
uint8_t | syncL, | ||
uint8_t | maxErrBits = 0 , |
||
bool | requireCarrierSense = false |
||
) |
Sets 16-bit sync word as a two byte value.
syncH | MSB of the sync word. |
syncL | LSB of the sync word. |
maxErrBits | Maximum allowed number of bit errors in received sync word. Defaults to 0. |
requireCarrierSense | Require carrier sense above threshold in addition to sync word. |
|
virtual |
int16_t CC1101::startReceive | ( | ) |
Interrupt-driven receive method. GDO0 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. |
|
virtual |
Interrupt-driven 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 | Address to send the data to. Will only be added if address filtering was enabled. |
Implements PhysicalLayer.
virtual 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. |
|
virtual |
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 | Address to send the data to. Will only be added if address filtering was enabled. |
Implements PhysicalLayer.
virtual 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. |
|
virtual |
Starts direct mode transmission.
frf | Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY. |
Implements PhysicalLayer.
int16_t CC1101::variablePacketLengthMode | ( | uint8_t | maxLen = CC1101_MAX_PACKET_LENGTH | ) |