# RadioLib: ExternalRadio Class Reference

ExternalRadio Class Reference

Class to interface with external radio hardware. More...

`#include <ExternalRadio.h>`

Inheritance diagram for ExternalRadio:

## Public Member Functions

| ExternalRadio (RadioLibHal *hal, uint32_t pin=RADIOLIB_NC)
| Default constructor. More...
| ExternalRadio (const ExternalRadio &ext)
| Copy constructor. More...
ExternalRadio & | operator= (const ExternalRadio &ext)
| Overload for assignment operator. More...
| ~ExternalRadio ()
| Default destructor.
Module * | getMod () override
| Method to retrieve pointer to the underlying Module instance. More...
int16_t | setFrequencyDeviation (float freqDev) override
| Dummy implementation overriding PhysicalLayer. More...
int16_t | setDataShaping (uint8_t sh) override
| Dummy implementation overriding PhysicalLayer. More...
int16_t | setEncoding (uint8_t encoding) override
| Dummy implementation overriding PhysicalLayer. More...
int16_t | transmitDirect (uint32_t frf=0) override
| Direct transmission to drive external radio. 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 | transmit (uint8_t *data, size_t len, uint8_t addr=0)
| Binary transmit method. Must be implemented in module class. More...
virtual int16_t | sleep ()
| Sets module to sleep. More...
virtual int16_t | standby ()
| Sets module to standby. More...
virtual int16_t | standby (uint8_t mode)
| Sets module to a specific standby mode. More...
virtual int16_t | startReceive ()
| Sets module to received mode using its default configuration. More...
virtual int16_t | startReceive (uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len)
| Interrupt-driven receive method. A DIO pin will be activated when full packet is received. 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 (uint8_t *data, size_t len, uint8_t addr=0)
| Interrupt-driven binary transmit method. More...
virtual int16_t | finishTransmit ()
| Clean up after transmission is done. More...
virtual int16_t | readData (uint8_t *data, size_t len)
| Reads data that was received after calling startReceive method. More...
virtual int16_t | receiveDirect ()
| Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode. More...
virtual int16_t | setFrequency (float freq)
| Sets carrier frequency. Must be implemented in module class. More...
virtual int16_t | setBitRate (float br)
| Sets FSK bit rate. Only available in FSK mode. Must be implemented in module class. 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 | setOutputPower (int8_t power)
| Set output power. Must be implemented in module class if the module supports it. More...
virtual int16_t | checkOutputPower (int8_t power, int8_t *clipped)
| Check if output power is configurable. 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 size_t | getPacketLength (bool update=true)
| Query modem for the packet length of received payload. Must be implemented in module class. More...
virtual float | getRSSI ()
| Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. 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...
virtual int16_t | irqRxDoneRxTimeout (uint32_t &irqFlags, uint32_t &irqMask)
| Create the flags that make up RxDone and RxTimeout used for receiving downlinks. More...
virtual bool | isRxTimeout ()
| Check whether the IRQ bit for RxTimeout is set. 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 | 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...
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...
virtual uint8_t | randomByte ()
| Get one truly random byte from RSSI noise. Must be implemented in module class. 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...
virtual void | setDirectAction (void(*func)(void))
| Set interrupt service routine function to call when data bit is received in direct mode. Must be implemented in module class. More...
virtual void | readBit (uint32_t pin)
| Function to read and process data bit in direct reception mode. Must be implemented in module class. 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 (uint32_t pin, uint32_t value)
| Configure DIO pin mapping to get a given signal on a DIO pin (if available). More...
virtual void | setPacketReceivedAction (void(*func)(void))
| Sets interrupt service routine to call when a packet is received. More...
virtual void | clearPacketReceivedAction ()
| Clears interrupt service routine to call when a packet is received.
virtual void | setPacketSentAction (void(*func)(void))
| Sets interrupt service routine to call when a packet is sent. More...
virtual void | clearPacketSentAction ()
| Clears interrupt service routine to call when a packet is sent.
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

Class to interface with external radio hardware.

## Constructor & Destructor Documentation

## ExternalRadio() [1/2]

ExternalRadio::ExternalRadio | ( | RadioLibHal * | hal,
|  | uint32_t | pin = `RADIOLIB_NC`
| ) |  |

Default constructor.

Parameters

  hal | Pointer to the hardware abstraction layer to use.
  pin | Output pin when using direct transmission, defaults to unused pin.

## ExternalRadio() [2/2]

ExternalRadio::ExternalRadio | ( | const ExternalRadio & | ext | ) |

Copy constructor.

Parameters

  ext | ExternalRadio instance to copy.

## Member Function Documentation

## getMod()

Module * ExternalRadio::getMod | ( |  | ) |

overridevirtual

Method to retrieve pointer to the underlying Module instance.

Returns
  Pointer to the Module instance.

Implements PhysicalLayer.

## operator=()

ExternalRadio & ExternalRadio::operator= | ( | const ExternalRadio & | ext | ) |

Overload for assignment operator.

Parameters

  ext | rvalue ExternalRadio.

## setDataShaping()

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

overridevirtual

Dummy implementation overriding PhysicalLayer.

Parameters

  sh | Ignored.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setEncoding()

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

overridevirtual

Dummy implementation overriding PhysicalLayer.

Parameters

  encoding | Ignored.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## setFrequencyDeviation()

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

overridevirtual

Dummy implementation overriding PhysicalLayer.

Parameters

  freqDev | Ignored.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

## transmitDirect()

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

overridevirtual

Direct transmission to drive external radio.

Parameters

  frf | "Frequency" to control the output pin. If the frequency is higher than the one sent previously, the output pin will be set to logic high. Otherwise it will be set to logic low.

Returns
  Status Codes

Reimplemented from PhysicalLayer.

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

- src/protocols/ExternalRadio/ExternalRadio.h
- src/protocols/ExternalRadio/ExternalRadio.cpp