# RadioLib: CC1101 Class Reference

CC1101 Class Reference

Control class for CC1101 module. More...

`#include <CC1101.h>`

Inheritance diagram for CC1101:

## Public Member Functions

| CC1101 (Module *module)
| Default constructor. More...
int16_t | begin (float freq=RADIOLIB_CC1101_DEFAULT_FREQ, float br=RADIOLIB_CC1101_DEFAULT_BR, float freqDev=RADIOLIB_CC1101_DEFAULT_FREQDEV, float rxBw=RADIOLIB_CC1101_DEFAULT_RXBW, int8_t pwr=RADIOLIB_CC1101_DEFAULT_POWER, uint8_t preambleLength=RADIOLIB_CC1101_DEFAULT_PREAMBLELEN)
| Initialization method. More...
void | reset ()
| Reset method - resets the chip using manual reset sequence (without RESET pin).
int16_t | transmit (const uint8_t *data, size_t len, uint8_t addr=0) 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 | standby () override
| Sets the module to standby mode. More...
int16_t | standby (uint8_t mode) override
| Sets the module to standby. More...
int16_t | transmitDirect (uint32_t frf=0) override
| Starts synchronous direct mode transmission. More...
int16_t | receiveDirect () override
| Starts synchronous direct mode reception. More...
int16_t | transmitDirectAsync (uint32_t frf=0)
| Starts asynchronous direct mode transmission. More...
int16_t | receiveDirectAsync ()
| Starts asynchronous 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), uint32_t dir)
| 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), uint32_t dir)
| Sets interrupt service routine to call when GDO2 activates. More...
void | clearGdo2Action ()
| Clears interrupt service routine to call when GDO0 activates.
void | setPacketReceivedAction (void(*func)(void)) override
| Sets interrupt service routine to call when a packet is received. More...
void | clearPacketReceivedAction () override
| Clears interrupt service routine to call when a packet is received.
void | setPacketSentAction (void(*func)(void)) override
| Sets interrupt service routine to call when a packet is sent. More...
void | clearPacketSentAction () override
| Clears interrupt service routine to call when a packet is sent.
int16_t | startTransmit (const uint8_t *data, size_t len, uint8_t addr=0) override
| Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. More...
int16_t | finishTransmit () override
| Clean up after transmission is done. More...
int16_t | startReceive () override
| Interrupt-driven receive method. GDO0 will be activated when full packet is received. More...
int16_t | startReceive (uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len) override
| Interrupt-driven receive method, implemented for compatibility with PhysicalLayer. More...
int16_t | readData (uint8_t *data, size_t len) override
| Reads data received after calling startReceive method. When the packet length is not known in advance, getPacketLength method must be called BEFORE calling readData! More...
int16_t | setFrequency (float freq) override
| 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) override
| Sets bit rate. Allowed values range from 0.025 to 600.0 kbps. More...
int16_t | setBitRateTolerance (uint8_t brt)
| Sets bit rate tolerance in BSCFG register. Allowed values are 0:(0%), 1(3,125%), 2:(6,25%) and 3:(12,5%). More...
int16_t | setRxBandwidth (float rxBw)
| Sets receiver bandwidth. Allowed values are 58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650 and 812 kHz. More...
int16_t | autoSetRxBandwidth ()
| calculates and sets Rx bandwidth based on the freq, baud and freq uncertainty. Reimplement of atlas0fd00m's (RfCat) CalculatePktChanBw function. Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw. More...
int16_t | setFrequencyDeviation (float freqDev) override
| Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz. More...
int16_t | getFrequencyDeviation (float *freqDev)
| Gets frequency deviation. More...
int16_t | setOutputPower (int8_t pwr) override
| Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm. More...
int16_t | checkOutputPower (int8_t power, int8_t *clipped) override
| Check if output power is configurable. This method is needed for compatibility with PhysicalLayer::checkOutputPower. More...
int16_t | checkOutputPower (int8_t power, int8_t *clipped, uint8_t *raw)
| Check if output power is configurable. 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, uint8_t qualityThreshold)
| 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 () override
| Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. In direct or asynchronous direct mode, returns the current RSSI level. More...
uint8_t | getLQI () const
| Gets LQI (Link Quality Indicator) of the last received packet. More...
size_t | getPacketLength (bool update=true) override
| Query modem for the packet length of received payload. More...
int16_t | fixedPacketLengthMode (uint8_t len=RADIOLIB_CC1101_MAX_PACKET_LENGTH)
| Set modem in fixed packet length mode. More...
int16_t | variablePacketLengthMode (uint8_t maxLen=RADIOLIB_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 enable=true)
| Enable CRC filtering and generation. More...
int16_t | setPromiscuousMode (bool enable=true, bool requireCarrierSense=false)
| Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC). More...
bool | getPromiscuousMode ()
| Get whether the modem is in promiscuous mode: no packet filtering (e.g., no preamble, sync word, address, CRC). More...
int16_t | setDataShaping (uint8_t sh) override
| Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping. More...
int16_t | setEncoding (uint8_t encoding) override
| Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER, and RADIOLIB_ENCODING_WHITENING. Note that encoding on CC1101 is applied to the entire stream including preamble, sync word, and CRC. More...
void | setRfSwitchPins (uint32_t rxEn, uint32_t txEn)
| Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes: When idle both pins will be LOW, during TX the `txEn` pin will be HIGH, during RX the `rxPin` will be HIGH. More...
void | setRfSwitchTable (const uint32_t(&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[])
| Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes. More...
uint8_t | randomByte () override
| Get one truly random byte from RSSI noise. More...
int16_t | getChipVersion ()
| Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working. More...
void | setDirectAction (void(*func)(void)) override
| Set interrupt service routine function to call when data bit is receveid in direct mode. More...
void | readBit (uint32_t pin) override
| Function to read and process data bit in direct reception mode. More...
int16_t | setDIOMapping (uint32_t pin, uint32_t value) override
| Configure DIO pin mapping to get a given signal on a DIO pin (if available). More...
int16_t | transmit (const char *str, uint8_t addr=0)
| C-string transmit method. More...
virtual int16_t | transmit (const uint8_t *data, size_t len, uint8_t addr=0)
| Binary transmit method. Must be implemented in module class. More...
virtual int16_t | receive (uint8_t *data, size_t len)
| Binary receive method. Must be implemented in module class. 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 (const uint8_t *data, size_t len, uint8_t addr=0)
| Interrupt-driven binary transmit method. More...
virtual int16_t | readData (uint8_t *data, size_t len)
| Reads data that was received after calling startReceive method. More...
Public Member Functions inherited from PhysicalLayer
| PhysicalLayer (float step, size_t maxLen)
| Default constructor. More...
int16_t | transmit (const char *str, uint8_t addr=0)
| C-string transmit method. More...
virtual int16_t | sleep ()
| Sets module to sleep. 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 | invertIQ (bool enable)
| Set IQ inversion. Must be implemented in module class if the module supports it. More...
virtual int16_t | setSyncWord (uint8_t *sync, size_t len)
| Set sync word. Must be implemented in module class if the module supports it. More...
virtual int16_t | setPreambleLength (size_t len)
| Set preamble length. Must be implemented in module class if the module supports it. More...
virtual int16_t | setDataRate (DataRate_t dr)
| Set data. Must be implemented in module class if the module supports it. More...
virtual int16_t | checkDataRate (DataRate_t dr)
| Check the data rate can be configured by this module. Must be implemented in module class if the module supports it. More...
float | getFreqStep () const
| Gets the module frequency step size that was set in constructor. More...
virtual float | getSNR ()
| Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem. More...
virtual RadioLibTime_t | getTimeOnAir (size_t len)
| Get expected time-on-air for a given size of payload. More...
virtual RadioLibTime_t | calculateRxTimeout (RadioLibTime_t timeoutUs)
| Calculate the timeout value for this specific module / series (in number of symbols or units of time). More...
uint32_t | getIrqMapped (RadioLibIrqFlags_t irq)
| Convert from radio-agnostic IRQ flags to radio-specific flags. More...
int16_t | checkIrq (RadioLibIrqType_t irq)
| Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone). More...
int16_t | setIrq (RadioLibIrqFlags_t irq)
| Set interrupt on specific IRQ bit(s) (e.g. RxTimeout, CadDone). Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags! More...
int16_t | clearIrq (RadioLibIrqFlags_t irq)
| Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags! More...
virtual uint32_t | getIrqFlags ()
| Read currently active IRQ flags. Must be implemented in module class. More...
virtual int16_t | setIrqFlags (uint32_t irq)
| Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented in module class. More...
virtual int16_t | clearIrqFlags (uint32_t irq)
| Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone). Must be implemented in module class. More...
virtual int16_t | startChannelScan ()
| Interrupt-driven channel activity detection method. Interrupt will be activated when packet is detected. Must be implemented in module class. More...
virtual int16_t | startChannelScan (const ChannelScanConfig_t &config)
| Interrupt-driven channel activity detection method. interrupt will be activated when packet is detected. Must be implemented in module class. More...
virtual int16_t | getChannelScanResult ()
| Read the channel scan result. More...
virtual int16_t | scanChannel ()
| Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules, or RSSI measurement for FSK modules. More...
virtual int16_t | scanChannel (const ChannelScanConfig_t &config)
| Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules, or RSSI measurement for FSK modules. 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 void | setChannelScanAction (void(*func)(void))
| Sets interrupt service routine to call when a channel scan is finished. More...
virtual void | clearChannelScanAction ()
| Clears interrupt service routine to call when a channel scan is finished.

## Detailed Description

Control class for CC1101 module.

## Constructor & Destructor Documentation

## CC1101()

CC1101::CC1101 | ( | Module * | module | ) |

Default constructor.

Parameters

  module | Instance of Module that will be used to communicate with the radio.

## Member Function Documentation

## autoSetRxBandwidth()

int16_t CC1101::autoSetRxBandwidth | ( |  | ) |

calculates and sets Rx bandwidth based on the freq, baud and freq uncertainty. Reimplement of atlas0fd00m's (RfCat) CalculatePktChanBw function. Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw.

Returns
  Status Codes

## begin()

int16_t CC1101::begin | ( | float | freq = `RADIOLIB_CC1101_DEFAULT_FREQ`,
|  | float | br = `RADIOLIB_CC1101_DEFAULT_BR`,
|  | float | freqDev = `RADIOLIB_CC1101_DEFAULT_FREQDEV`,
|  | float | rxBw = `RADIOLIB_CC1101_DEFAULT_RXBW`,
|  | int8_t | pwr = `RADIOLIB_CC1101_DEFAULT_POWER`,
|  | uint8_t | preambleLength = `RADIOLIB_CC1101_DEFAULT_PREAMBLELEN`
| ) |  |

Initialization method.

Parameters

  freq | Carrier frequency in MHz. Defaults to 434 MHz.
  br | Bit rate to be used in kbps. Defaults to 4.8 kbps.
  freqDev | Frequency deviation from carrier frequency in kHz Defaults to 5.0 kHz.
  rxBw | Receiver bandwidth in kHz. Defaults to 135.0 kHz.
  pwr | Output power in dBm. Defaults to 10 dBm.
  preambleLength | Preamble Length in bits. Defaults to 16 bits.

Returns
  Status Codes

## checkOutputPower() [1/2]

int16_t CC1101::checkOutputPower | ( | int8_t | power,
|  | int8_t * | clipped
| ) |  |

overridevirtual

Check if output power is configurable. This method is needed for compatibility with PhysicalLayer::checkOutputPower.

Parameters

  power | Output power in dBm.
  clipped | Clipped output power value to what is possible within the module's range.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## checkOutputPower() [2/2]

int16_t CC1101::checkOutputPower | ( | int8_t | power,
|  | int8_t * | clipped,
|  | uint8_t * | raw
| ) |  |

Check if output power is configurable.

Parameters

  power | Output power in dBm.
  clipped | Clipped output power value to what is possible within the module's range.
  raw | Raw internal value.

Returns
  Status Codes

## disableAddressFiltering()

int16_t CC1101::disableAddressFiltering | ( |  | ) |

Disables address filtering. Calling this method will also erase previously set addresses.

Returns
  Status Codes

## disableSyncWordFiltering()

int16_t CC1101::disableSyncWordFiltering | ( | bool | requireCarrierSense = `false` | ) |

Disable preamble and sync word filtering and generation.

Parameters

  requireCarrierSense | Require carrier sense above threshold.

Returns
  Status Codes

## enableSyncWordFiltering()

int16_t CC1101::enableSyncWordFiltering | ( | uint8_t | maxErrBits = `0`,
|  | bool | requireCarrierSense = `false`
| ) |  |

Enable sync word filtering and generation.

Parameters

  maxErrBits | Maximum number of allowed error bits in sync word.
  requireCarrierSense | Require carrier sense above threshold in addition to sync word.

Returns
  Status Codes

## finishTransmit()

int16_t CC1101::finishTransmit | ( |  | ) |

overridevirtual

Clean up after transmission is done.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## fixedPacketLengthMode()

int16_t CC1101::fixedPacketLengthMode | ( | uint8_t | len = `RADIOLIB_CC1101_MAX_PACKET_LENGTH` | ) |

Set modem in fixed packet length mode.

Parameters

  len | Packet length.

Returns
  Status Codes

## getChipVersion()

int16_t CC1101::getChipVersion | ( |  | ) |

Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.

Returns
  Version register contents or Status Codes

## getFrequencyDeviation()

int16_t CC1101::getFrequencyDeviation | ( | float * | freqDev | ) |

Gets frequency deviation.

Parameters

  [out] | freqDev | Pointer to variable where to save the frequency deviation.

Returns
  Status Codes

## getLQI()

uint8_t CC1101::getLQI | ( |  | ) | const

Gets LQI (Link Quality Indicator) of the last received packet.

Returns
  Last packet LQI (lower is better).

## getPacketLength()

size_t CC1101::getPacketLength | ( | bool | update = `true` | ) |

overridevirtual

Query modem for the packet length of received payload.

Parameters

  update | Update received packet length. Will return cached value when set to false.

Returns
  Length of last received packet in bytes.

Reimplemented from PhysicalLayer.

## getPromiscuousMode()

bool CC1101::getPromiscuousMode | ( |  | ) |

Get whether the modem is in promiscuous mode: no packet filtering (e.g., no preamble, sync word, address, CRC).

Returns
  Whether the modem is in promiscuous mode.

## getRSSI()

float CC1101::getRSSI | ( |  | ) |

overridevirtual

Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. In direct or asynchronous direct mode, returns the current RSSI level.

Returns
  RSSI in dBm.

Reimplemented from PhysicalLayer.

## randomByte()

uint8_t CC1101::randomByte | ( |  | ) |

overridevirtual

Get one truly random byte from RSSI noise.

Returns
  TRNG byte.

Reimplemented from PhysicalLayer.

## readBit()

void CC1101::readBit | ( | uint32_t | pin | ) |

overridevirtual

Function to read and process data bit in direct reception mode.

Parameters

  pin | Pin on which to read.

Reimplemented from PhysicalLayer.

## readData() [1/2]

int16_t PhysicalLayer::readData

Reads data that was received after calling startReceive method.

Parameters

  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 retrieved automatically. When more bytes than received are requested, only the number of bytes requested will be returned.

Returns
  Status Codes

## readData() [2/2]

int16_t CC1101::readData | ( | uint8_t * | data,
|  | size_t | len
| ) |  |

overridevirtual

Reads data received after calling startReceive method. When the packet length is not known in advance, getPacketLength method must be called BEFORE calling readData!

Parameters

  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.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## receive() [1/2]

int16_t PhysicalLayer::receive

Binary receive method. Must be implemented in module class.

Parameters

  data | Pointer to array to save the received binary data.
  len | Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).

Returns
  Status Codes

## receive() [2/2]

int16_t CC1101::receive | ( | uint8_t * | data,
|  | size_t | len
| ) |  |

overridevirtual

Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters

  data | Binary data to be sent.
  len | Number of bytes to send.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## receiveDirect()

int16_t CC1101::receiveDirect | ( |  | ) |

overridevirtual

Starts synchronous direct mode reception.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## receiveDirectAsync()

int16_t CC1101::receiveDirectAsync | ( |  | ) |

Starts asynchronous direct mode reception.

Returns
  Status Codes

## setBitRate()

int16_t CC1101::setBitRate | ( | float | br | ) |

overridevirtual

Sets bit rate. Allowed values range from 0.025 to 600.0 kbps.

Parameters

  br | Bit rate to be set in kbps.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setBitRateTolerance()

int16_t CC1101::setBitRateTolerance | ( | uint8_t | brt | ) |

Sets bit rate tolerance in BSCFG register. Allowed values are 0:(0%), 1(3,125%), 2:(6,25%) and 3:(12,5%).

Parameters

  brt | Bit rate tolerance to be set.

Returns
  Status Codes

## setCrcFiltering()

int16_t CC1101::setCrcFiltering | ( | bool | enable = `true` | ) |

Enable CRC filtering and generation.

Parameters

  enable | Set or unset CRC generation and filtering.

Returns
  Status Codes

## setDataShaping()

int16_t CC1101::setDataShaping | ( | uint8_t | sh | ) |

overridevirtual

Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping.

Parameters

  sh | Gaussian shaping bandwidth-time product that will be used for data shaping.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setDIOMapping()

int16_t CC1101::setDIOMapping | ( | uint32_t | pin,
|  | uint32_t | value
| ) |  |

overridevirtual

Configure DIO pin mapping to get a given signal on a DIO pin (if available).

Parameters

  pin | Pin number onto which a signal is to be placed.
  value | The value that indicates which function to place on that pin. See chip datasheet for details.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setDirectAction()

void CC1101::setDirectAction | ( | void(*)(void) | func | ) |

overridevirtual

Set interrupt service routine function to call when data bit is receveid in direct mode.

Parameters

  func | Pointer to interrupt service routine.

Reimplemented from PhysicalLayer.

## setEncoding()

int16_t CC1101::setEncoding | ( | uint8_t | encoding | ) |

overridevirtual

Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER, and RADIOLIB_ENCODING_WHITENING. Note that encoding on CC1101 is applied to the entire stream including preamble, sync word, and CRC.

Parameters

  encoding | Encoding to be used.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setFrequency()

int16_t CC1101::setFrequency | ( | float | freq | ) |

overridevirtual

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.

Parameters

  freq | Carrier frequency to be set in MHz.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setFrequencyDeviation()

int16_t CC1101::setFrequencyDeviation | ( | float | freqDev | ) |

overridevirtual

Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz.

Parameters

  freqDev | Frequency deviation to be set in kHz.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setGdo0Action()

void CC1101::setGdo0Action | ( | void(*)(void) | func,
|  | uint32_t | dir
| ) |  |

Sets interrupt service routine to call when GDO0 activates.

Parameters

  func | ISR to call.
  dir | Signal change direction.

## setGdo2Action()

void CC1101::setGdo2Action | ( | void(*)(void) | func,
|  | uint32_t | dir
| ) |  |

Sets interrupt service routine to call when GDO2 activates.

Parameters

  func | ISR to call.
  dir | Signal change direction.

## setNodeAddress()

int16_t CC1101::setNodeAddress | ( | uint8_t | nodeAddr,
|  | uint8_t | numBroadcastAddrs = `0`
| ) |  |

Sets node and broadcast addresses. Calling this method will also enable address filtering.

Parameters

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

Returns
  Status Codes

## setOOK()

int16_t CC1101::setOOK | ( | bool | enableOOK | ) |

Enables/disables OOK modulation instead of FSK.

Parameters

  enableOOK | Enable (true) or disable (false) OOK.

Returns
  Status Codes

## setOutputPower()

int16_t CC1101::setOutputPower | ( | int8_t | pwr | ) |

overridevirtual

Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.

Parameters

  pwr | Output power to be set in dBm.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setPacketReceivedAction()

void CC1101::setPacketReceivedAction | ( | void(*)(void) | func | ) |

overridevirtual

Sets interrupt service routine to call when a packet is received.

Parameters

  func | ISR to call.

Reimplemented from PhysicalLayer.

## setPacketSentAction()

void CC1101::setPacketSentAction | ( | void(*)(void) | func | ) |

overridevirtual

Sets interrupt service routine to call when a packet is sent.

Parameters

  func | ISR to call.

Reimplemented from PhysicalLayer.

## setPreambleLength()

int16_t CC1101::setPreambleLength | ( | uint8_t | preambleLength,
|  | uint8_t | qualityThreshold
| ) |  |

Sets preamble length.

Parameters

  preambleLength | Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
  qualityThreshold | Preamble quality threshold (PQT) to set.

Returns
  Status Codes

## setPromiscuousMode()

int16_t CC1101::setPromiscuousMode | ( | bool | enable = `true`,
|  | bool | requireCarrierSense = `false`
| ) |  |

Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address, CRC).

Parameters

  enable | Set or unset promiscuous mode.
  requireCarrierSense | Set carriersense required above threshold, defaults to false.

Returns
  Status Codes

## setRfSwitchPins()

void CC1101::setRfSwitchPins | ( | uint32_t | rxEn,
|  | uint32_t | txEn
| ) |  |

Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes: When idle both pins will be LOW, during TX the `txEn` pin will be HIGH, during RX the `rxPin` will be HIGH.

Radiolib will automatically set the pin mode and value of these pins, so do not control them from the sketch.

When more than two pins or more control over the output values are needed, use the setRfSwitchTable() function.

Parameters

  rxEn | RX enable pin.
  txEn | TX enable pin.

## setRfSwitchTable()

void CC1101::setRfSwitchTable | ( | const uint32_t(&) | pins[Module::RFSWITCH_MAX_PINS],
|  | const Module::RfSwitchMode_t | table[]
| ) |  |

Some modules contain external RF switch controlled by pins. This function gives RadioLib control over those pins to automatically switch between various modes.

Radiolib will automatically set the pin mode and value of these pins, so do not control them from the sketch.

Parameters

  pins | A reference to an array of pins to control. This should always be an array of 3 elements. If you need less pins, use RADIOLIB_NC for the unused elements.
  table | A reference to an array of pin values to use for each supported mode. Each element is an RfSwitchMode_T struct that lists the mode for which it applies and the values for each of the pins passed in the pins argument respectively.

The `pins` array will be copied into the Module object, so the original array can be deallocated after this call. However, a reference to the `table` array will be stored, so that array must remain valid as long RadioLib is being used.

The `mode` field in each table row should normally use any of the `MODE_*` constants from the Module::OpMode_t enum. However, some radios support additional modes and will define their own OpMode_t enum.

The length of the table is variable (to support radios that add additional modes), so the table must always be terminated with the special END_OF_MODE_TABLE value.

Normally all modes should be listed in the table, but for some radios, modes can be omitted to indicate they are not supported (e.g. when a radio has a high power and low power TX mode but external circuitry only supports low power). If applicable, this is documented in the radio class itself.

#### Example

For example, on a board that has an RF switch with an enable pin connected to PA0 and a TX/RX select pin connected to PA1:

// In global scope, define the pin array and mode table
static const uint32_t rfswitch_pins[] =
{PA0, PA1, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
{Module::MODE_IDLE, {LOW, LOW}},
{Module::MODE_RX, {HIGH, LOW}},
{Module::MODE_TX, {HIGH, HIGH}},
Module::END_OF_MODE_TABLE,
};
void setup() {
...
// Then somewhere in setup, pass them to radiolib
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
...
}
Module::MODE_TX
@ MODE_TX
Transmission mode.
Definition: Module.h:111
Module::MODE_IDLE
@ MODE_IDLE
Idle mode.
Definition: Module.h:105
Module::MODE_RX
@ MODE_RX
Receive mode.
Definition: Module.h:108
Module::RfSwitchMode_t
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition: Module.h:81

## setRxBandwidth()

int16_t CC1101::setRxBandwidth | ( | float | rxBw | ) |

Sets receiver bandwidth. Allowed values are 58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650 and 812 kHz.

Parameters

  rxBw | Receiver bandwidth to be set in kHz.

Returns
  Status Codes

## setSyncWord() [1/2]

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.

Parameters

  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.

Returns
  Status Codes

## setSyncWord() [2/2]

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.

Parameters

  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.

Returns
  Status Codes

## standby() [1/2]

int16_t CC1101::standby | ( |  | ) |

overridevirtual

Sets the module to standby mode.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## standby() [2/2]

int16_t CC1101::standby | ( | uint8_t | mode | ) |

overridevirtual

Sets the module to standby.

Parameters

  mode | Standby mode to be used. No effect, implemented only for PhysicalLayer compatibility.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## startReceive() [1/2]

int16_t CC1101::startReceive | ( |  | ) |

overridevirtual

Interrupt-driven receive method. GDO0 will be activated when full packet is received.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## startReceive() [2/2]

int16_t CC1101::startReceive | ( | uint32_t | timeout,
|  | uint32_t | irqFlags,
|  | uint32_t | irqMask,
|  | size_t | len
| ) |  |

overridevirtual

Interrupt-driven receive method, implemented for compatibility with PhysicalLayer.

Parameters

  timeout | Ignored.
  irqFlags | Ignored.
  irqMask | Ignored.
  len | Ignored.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## startTransmit() [1/3]

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.

Parameters

  str | C-string that will be transmitted.
  addr | Node address to transmit the packet to. Only used in FSK mode.

Returns
  Status Codes

## startTransmit() [2/3]

int16_t PhysicalLayer::startTransmit

Interrupt-driven binary transmit method.

Parameters

  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.

Returns
  Status Codes

## startTransmit() [3/3]

int16_t CC1101::startTransmit | ( | const uint8_t * | data,
|  | size_t | len,
|  | uint8_t | addr = `0`
| ) |  |

overridevirtual

Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters

  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.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## transmit() [1/3]

int16_t PhysicalLayer::transmit

C-string transmit method.

Parameters

  str | C-string that will be transmitted.
  addr | Node address to transmit the packet to. Only used in FSK mode.

Returns
  Status Codes

## transmit() [2/3]

int16_t PhysicalLayer::transmit

Binary transmit method. Must be implemented in module class.

Parameters

  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.

Returns
  Status Codes

## transmit() [3/3]

int16_t CC1101::transmit | ( | const uint8_t * | data,
|  | size_t | len,
|  | uint8_t | addr = `0`
| ) |  |

overridevirtual

Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.

Parameters

  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.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## transmitDirect()

int16_t CC1101::transmitDirect | ( | uint32_t | frf = `0` | ) |

overridevirtual

Starts synchronous direct mode transmission.

Parameters

  frf | Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## transmitDirectAsync()

int16_t CC1101::transmitDirectAsync | ( | uint32_t | frf = `0` | ) |

Starts asynchronous direct mode transmission.

Parameters

  frf | Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.

Returns
  Status Codes

## variablePacketLengthMode()

int16_t CC1101::variablePacketLengthMode | ( | uint8_t | maxLen = `RADIOLIB_CC1101_MAX_PACKET_LENGTH` | ) |

Set modem in variable packet length mode.

Parameters

  maxLen | Maximum packet length.

Returns
  Status Codes

The documentation for this class was generated from the following files:

- src/modules/CC1101/CC1101.h
- src/modules/CC1101/CC1101.cpp