Radio driver implementation for Semtech SX1272 plus variants. More...
#include <SX1276_LoRaRadio.h>
Public Member Functions | |
SX1276_LoRaRadio (PinName mosi=MBED_CONF_SX1276_LORA_DRIVER_SPI_MOSI, PinName miso=MBED_CONF_SX1276_LORA_DRIVER_SPI_MISO, PinName sclk=MBED_CONF_SX1276_LORA_DRIVER_SPI_SCLK, PinName nss=MBED_CONF_SX1276_LORA_DRIVER_SPI_CS, PinName reset=MBED_CONF_SX1276_LORA_DRIVER_RESET, PinName dio0=MBED_CONF_SX1276_LORA_DRIVER_DIO0, PinName dio1=MBED_CONF_SX1276_LORA_DRIVER_DIO1, PinName dio2=MBED_CONF_SX1276_LORA_DRIVER_DIO2, PinName dio3=MBED_CONF_SX1276_LORA_DRIVER_DIO3, PinName dio4=MBED_CONF_SX1276_LORA_DRIVER_DIO4, PinName dio5=MBED_CONF_SX1276_LORA_DRIVER_DIO5, PinName rf_switch_ctl1=MBED_CONF_SX1276_LORA_DRIVER_RF_SWITCH_CTL1, PinName rf_switch_ctl2=MBED_CONF_SX1276_LORA_DRIVER_RF_SWITCH_CTL2, PinName txctl=MBED_CONF_SX1276_LORA_DRIVER_TXCTL, PinName rxctl=MBED_CONF_SX1276_LORA_DRIVER_RXCTL, PinName ant_switch=MBED_CONF_SX1276_LORA_DRIVER_ANT_SWITCH, PinName pwr_amp_ctl=MBED_CONF_SX1276_LORA_DRIVER_PWR_AMP_CTL, PinName tcxo=MBED_CONF_SX1276_LORA_DRIVER_TCXO) | |
Use this constructor if pin definitions are provided manually. More... | |
virtual | ~SX1276_LoRaRadio () |
Destructor. More... | |
virtual void | init_radio (radio_events_t *events) |
Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps if any. More... | |
virtual void | radio_reset () |
Resets the radio module. More... | |
virtual void | sleep (void) |
Put the RF module in sleep mode. More... | |
virtual void | standby (void) |
Sets the radio in standby mode. More... | |
virtual void | set_rx_config (radio_modems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidth_afc, uint16_t preamble_len, uint16_t symb_timeout, bool fix_len, uint8_t payload_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, bool rx_continuous) |
Sets the reception parameters. More... | |
virtual void | set_tx_config (radio_modems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preamble_len, bool fix_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, uint32_t timeout) |
Sets the transmission parameters. More... | |
virtual void | send (uint8_t *buffer, uint8_t size) |
Sends the buffer of size. More... | |
virtual void | receive (uint32_t timeout) |
For backwards compatibility. More... | |
virtual void | receive (void) |
Sets the radio to receive. More... | |
virtual void | set_channel (uint32_t freq) |
Sets the carrier frequency. More... | |
virtual uint32_t | random (void) |
Generates a 32 bits random value based on the RSSI readings. More... | |
virtual uint8_t | get_status (void) |
Get radio status. More... | |
virtual void | set_max_payload_length (radio_modems_t modem, uint8_t max) |
Sets the maximum payload length. More... | |
virtual void | set_public_network (bool enable) |
Sets the network to public or private. More... | |
virtual uint32_t | time_on_air (radio_modems_t modem, uint8_t pkt_len) |
Computes the packet time on air for the given payload. More... | |
virtual bool | perform_carrier_sense (radio_modems_t modem, uint32_t freq, int16_t rssi_threshold, uint32_t max_carrier_sense_time) |
Perform carrier sensing. More... | |
virtual void | start_cad (void) |
Sets the radio in CAD mode. More... | |
virtual bool | check_rf_frequency (uint32_t frequency) |
Check if the given RF is in range. More... | |
virtual void | set_tx_continuous_wave (uint32_t freq, int8_t power, uint16_t time) |
Sets the radio in continuous wave transmission mode. More... | |
virtual void | lock (void) |
Acquire exclusive access. More... | |
virtual void | unlock (void) |
Release exclusive access. More... | |
Radio driver implementation for Semtech SX1272 plus variants.
Supports only SPI at the moment. Implements pure virtual LoRaRadio class.
Definition at line 61 of file SX1276_LoRaRadio.h.
SX1276_LoRaRadio | ( | PinName | mosi = MBED_CONF_SX1276_LORA_DRIVER_SPI_MOSI , |
PinName | miso = MBED_CONF_SX1276_LORA_DRIVER_SPI_MISO , |
||
PinName | sclk = MBED_CONF_SX1276_LORA_DRIVER_SPI_SCLK , |
||
PinName | nss = MBED_CONF_SX1276_LORA_DRIVER_SPI_CS , |
||
PinName | reset = MBED_CONF_SX1276_LORA_DRIVER_RESET , |
||
PinName | dio0 = MBED_CONF_SX1276_LORA_DRIVER_DIO0 , |
||
PinName | dio1 = MBED_CONF_SX1276_LORA_DRIVER_DIO1 , |
||
PinName | dio2 = MBED_CONF_SX1276_LORA_DRIVER_DIO2 , |
||
PinName | dio3 = MBED_CONF_SX1276_LORA_DRIVER_DIO3 , |
||
PinName | dio4 = MBED_CONF_SX1276_LORA_DRIVER_DIO4 , |
||
PinName | dio5 = MBED_CONF_SX1276_LORA_DRIVER_DIO5 , |
||
PinName | rf_switch_ctl1 = MBED_CONF_SX1276_LORA_DRIVER_RF_SWITCH_CTL1 , |
||
PinName | rf_switch_ctl2 = MBED_CONF_SX1276_LORA_DRIVER_RF_SWITCH_CTL2 , |
||
PinName | txctl = MBED_CONF_SX1276_LORA_DRIVER_TXCTL , |
||
PinName | rxctl = MBED_CONF_SX1276_LORA_DRIVER_RXCTL , |
||
PinName | ant_switch = MBED_CONF_SX1276_LORA_DRIVER_ANT_SWITCH , |
||
PinName | pwr_amp_ctl = MBED_CONF_SX1276_LORA_DRIVER_PWR_AMP_CTL , |
||
PinName | tcxo = MBED_CONF_SX1276_LORA_DRIVER_TCXO |
||
) |
Use this constructor if pin definitions are provided manually.
The pins that are marked NC are optional. It is assumed that these pins are not connected until/unless configured otherwise.
Note: Pin ant_switch is equivalent to RxTx pin at https://developer.mbed.org/components/SX1276MB1xAS/. Reading the state of this pin indicates if the radio module type is SX1276MB1LAS(North American frequency band supported) or SX1276MAS (European frequency band supported). Pin dio4 can be mapped to multiple pins on the board, please refer to schematic of your board. For reference look at https://developer.mbed.org/components/SX1276MB1xAS/
Most of the radio module control pins are not being used at the moment as the SX1276MB1xAS shield has not connected them. For consistency and future use we are leaving the pins in the constructor. For example, if in some setting SX1276 radio module gets connected to an external power amplifier or radio latch controls are connected.
|
virtual |
Destructor.
|
virtual |
Check if the given RF is in range.
frequency | frequency needed to be checked |
Implements LoRaRadio.
|
virtual |
Get radio status.
status | Radio status [RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING] |
Implements LoRaRadio.
|
virtual |
Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps if any.
events | Structure containing the driver callback functions |
Implements LoRaRadio.
|
virtual |
Acquire exclusive access.
Implements LoRaRadio.
|
virtual |
Perform carrier sensing.
Checks for a certain time if the RSSI is above a given threshold. This threshold determines if there is already a transmission going on in the channel or not.
modem | Type of the radio modem |
freq | Carrier frequency |
rssi_threshold | Threshold value of RSSI |
max_carrier_sense_time | time to sense the channel |
Implements LoRaRadio.
|
virtual |
Resets the radio module.
Implements LoRaRadio.
|
virtual |
Generates a 32 bits random value based on the RSSI readings.
Remark this function sets the radio in LoRa modem mode and disables all interrupts. After calling this function either Radio.SetRxConfig or Radio.SetTxConfig functions must be called.
Implements LoRaRadio.
|
virtual |
For backwards compatibility.
Definition at line 222 of file SX1276_LoRaRadio.h.
|
virtual |
Sets the radio to receive.
All necessary configuration options for reception are set in 'set_rx_config(parameters)' API.
Implements LoRaRadio.
|
virtual |
Sends the buffer of size.
Prepares the packet to be sent and sets the radio in transmission
buffer | Buffer pointer |
size | Buffer size |
Implements LoRaRadio.
|
virtual |
|
virtual |
Sets the maximum payload length.
modem | Radio modem to be used [0: FSK, 1: LoRa] |
max | Maximum payload length in bytes |
Implements LoRaRadio.
|
virtual |
Sets the network to public or private.
Updates the sync byte. Applies to LoRa modem only
enable | if true, it enables a public network |
Implements LoRaRadio.
|
virtual |
Sets the reception parameters.
modem | Radio modem to be used [0: FSK, 1: LoRa] |
bandwidth | Sets the bandwidth FSK : >= 2600 and <= 250000 Hz LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved] |
datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips] |
coderate | Sets the coding rate ( LoRa only ) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
bandwidth_afc | Sets the AFC Bandwidth ( FSK only ) FSK : >= 2600 and <= 250000 Hz LoRa: N/A ( set to 0 ) |
preamble_len | Sets the Preamble length ( LoRa only ) FSK : N/A ( set to 0 ) LoRa: Length in symbols ( the hardware adds 4 more symbols ) |
symb_timeout | Sets the RxSingle timeout value FSK : timeout number of bytes LoRa: timeout in symbols |
fixLen | Fixed length packets [0: variable, 1: fixed] |
payload_len | Sets payload length when fixed lenght is used |
crc_on | Enables/Disables the CRC [0: OFF, 1: ON] |
freq_hop_on | Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
hop_period | Number of symbols bewteen each hop (LoRa only) |
iq_inverted | Inverts IQ signals ( LoRa only ) FSK : N/A ( set to 0 ) LoRa: [0: not inverted, 1: inverted] |
rx_continuous | Sets the reception in continuous mode [false: single mode, true: continuous mode] |
Implements LoRaRadio.
|
virtual |
Sets the transmission parameters.
modem | Radio modem to be used [0: FSK, 1: LoRa] |
power | Sets the output power [dBm] |
fdev | Sets the frequency deviation ( FSK only ) FSK : [Hz] LoRa: 0 |
bandwidth | Sets the bandwidth ( LoRa only ) FSK : 0 LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved] |
datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips] |
coderate | Sets the coding rate ( LoRa only ) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
preamble_len | Sets the preamble length |
fix_len | Fixed length packets [0: variable, 1: fixed] |
crc_on | Enables disables the CRC [0: OFF, 1: ON] |
freq_hop_on | Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
hop_period | Number of symbols bewteen each hop (LoRa only) |
iq_inverted | Inverts IQ signals ( LoRa only ) FSK : N/A ( set to 0 ) LoRa: [0: not inverted, 1: inverted] |
timeout | Transmission timeout [ms] |
Implements LoRaRadio.
|
virtual |
Sets the radio in continuous wave transmission mode.
freq | Channel RF frequency |
power | Sets the output power [dBm] |
time | Transmission mode timeout [s] |
Implements LoRaRadio.
|
virtual |
Put the RF module in sleep mode.
Implements LoRaRadio.
|
virtual |
Sets the radio in standby mode.
Implements LoRaRadio.
|
virtual |
Sets the radio in CAD mode.
Implements LoRaRadio.
|
virtual |
Computes the packet time on air for the given payload.
Remark can only be called once SetRxConfig or SetTxConfig have been called
modem | Radio modem to be used [0: FSK, 1: LoRa] |
pkt_len | Packet payload length |
Implements LoRaRadio.
|
virtual |
Release exclusive access.
Implements LoRaRadio.