MySensors Library & Examples  2.3.2-62-ge298769
Classes | Macros | Typedefs | Enumerations
+ Collaboration diagram for SX126x:

Detailed Description

API declaration for SX126x.

SX126x driver-related log messages, format: [!]SYSTEM:[SUB SYSTEM:]MESSAGE

E SYS SUB Message Comment
SX126x INIT Initialise SX126x radio
SX126x INIT PWRPIN=%d Power pin number (if configured)
SX126x INIT BSYPIN=%d Busy pin number (if configured)
SX126x INIT IRQPIN=%d DIO1 pin number (if configured)
SX126x INIT RSTPIN=%d Reset pin number (if configured)
SX126x INIT ASWPIN=%d Antenna switch pin number (if configured)
SX126x INIT DIO3TCXO,VCONF:%dX,DELAY:%dms DIO 3 was configured as TCXO control with voltage (VCNONF) and start up delay (DELAY)ms
SX126x INIT TCXO,EXT External TCXO was configured
SX126x INIT DIO2AntSw DIO 2 was configured as antenna switch control
! SX126x INIT SANCHK FAIL Sanity check failed, check wiring or replace module
! SX126x INIT ERR:0x%X%X An error occured during init. See GetDeviceErrors in datasheet
SX126x RCV SEND ACK ACK request received, sending ACK back
SX126x PTC LEVEL=%d Set TX power level
SX126x SAC SEND ACK,TO=%d,RSSI=%d,SNR=%d Send ACK to node (TO), RSSI of received message (RSSI), SNR of message (SNR)
SX126x ATC ADJ TXL,cR=%d,tR=%d..%d,rTXL=%d Adjust TX level, current RSSI (cR), target RSSI range (tR), requested TX level (rTXL)
SX126x SWR SEND,TO=%d,RETRY=%d Send message to (TO), NACK retry counter (RETRY)
SX126x SWR ACK FROM=%d,SEQ=%d,RSSI=%d,SNR=%d ACK received from node (FROM), seq ID (SEQ), (RSSI), (SNR)
! SX126x SWR NACK No ACK received
! SX126x CAD Could not send, channel active
SX126x SPP PCT=%d,TX LEVEL=%d Set TX level percent (PCT), TX level (LEVEL)
SX126x PWD Power down radio
SX126x PWU Power up radio

SX126x modem configuration

BW = Bandwidth in kHz CR = Error correction code SF = Spreading factor, chips / symbol

CONFIG BW CR SF Comment air-time (15 bytes)
BW125CR45SF128 125 4/5 128 Default, medium range 50ms
BW500CR45SF128 500 4/5 128 Fast, short range 15ms
BW31_25CR48SF512 31.25 4/8 512 Slow, long range 900ms
BW125CR48SF4096 125 4/8 4096 Slow, long range 1500ms

See here for air-time calculation: https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc

Classes

union  sx126x_rxBufferStatus_t
 data type to receive RX buffer status More...
 
union  sx126x_packetStatus_t
 data type to receive packet status More...
 
union  sx126x_sleepParams_t
 sx126x sleep parameters More...
 
union  sx126x_cadParameters_t
 CAD parameters type. More...
 
struct  sx126x_modulationParams_t
 Typedef for the SX126x modulation settings. More...
 
struct  sx126x_paSettings_t
 PA settings parameters type. More...
 
struct  sx126x_txSettings_t
 Transmission settings parameters type. More...
 
union  sx126x_controlFlags_t
 Control flag data type. More...
 
struct  __attribute__
 FW config structure, stored in eeprom. More...
 
struct  sx126x_internal_t
 SX126x internal variables. More...
 

Macros

#define SX126x_SPI   hwSPI
 default SPI
 
#define DEFAULT_SX126x_IRQ_PIN   (2)
 DEFAULT_SX126x_IRQ_PIN.
 
#define DEFAULT_SX126x_CS_PIN   (SS)
 DEFAULT_SX126x_CS_PIN.
 
#define SX126x_XTAL_FREQ   ( double )32000000
 XTAL frequency.
 
#define SX126x_FREQ_DIV   ( double )pow( 2.0, 25.0 )
 Frequency divider.
 
#define SX126x_FREQ_STEP   ( double )( SX126x_XTAL_FREQ / SX126x_FREQ_DIV )
 Frequency step.
 
#define SX126x_BW125CR45SF128   SX126x_BW_125KHZ | SX126x_CODING_RATE_4_5, SX126x_SPREADING_FACTOR_128CPS | SX126x_RX_PAYLOAD_CRC_ON, SX126x_AGC_AUTO_ON
 0x72,0x74,0x04
 
#define SX126x_BW500CR45SF128   SX126x_BW_500KHZ | SX126x_CODING_RATE_4_5, SX126x_SPREADING_FACTOR_128CPS | SX126x_RX_PAYLOAD_CRC_ON, SX126x_AGC_AUTO_ON
 0x92,0x74,0x04
 
#define SX126x_BW31_25CR48SF512   SX126x_BW_31_25KHZ | SX126x_CODING_RATE_4_8, SX126x_SPREADING_FACTOR_512CPS | SX126x_RX_PAYLOAD_CRC_ON, SX126x_AGC_AUTO_ON
 0x48,0x94,0x04
 
#define SX126x_BW125CR48SF4096   SX126x_BW_125KHZ | SX126x_CODING_RATE_4_8, SX126x_SPREADING_FACTOR_4096CPS | SX126x_RX_PAYLOAD_CRC_ON, SX126x_AGC_AUTO_ON | SX126x_LOW_DATA_RATE_OPTIMIZE
 0x78,0xc4,0x0C
 
#define SX126x_BROADCAST_ADDRESS   (255u)
 Broadcasting address.
 
#define SX126x_ATC_TARGET_RANGE_DBM   (2u)
 ATC target range +/- dBm.
 
#define SX126x_RSSI_OFFSET   (137u)
 RSSI offset.
 
#define SX126x_TARGET_RSSI   (-70)
 RSSI target.
 
#define SX126x_PROMISCUOUS   (false)
 SX126x promiscuous mode.
 
#define SX126x_PACKET_HEADER_VERSION   (1u)
 SX126x packet header version.
 
#define SX126x_MIN_PACKET_HEADER_VERSION   (1u)
 Minimal SX126x packet header version.
 
#define SX126x_RETRY_TIMEOUT_MS   (500ul)
 Timeout for ACK, adjustments needed if modem configuration changed (air time different)
 
#define MY_SX126x_TX_TIMEOUT_MS   (5*1000ul)
 TX timeout.
 
#define MY_SX126x_TX_POWER_DBM   (13u)
 Set TX power level, default 13dBm (overridden if ATC mode enabled) More...
 
#define SX126x_169MHZ   (169000000ul)
 169 Mhz
 
#define SX126x_315MHZ   (315000000ul)
 315 Mhz
 
#define SX126x_434MHZ   (433920000ul)
 433.92 Mhz
 
#define SX126x_868MHZ   (868100000ul)
 868.1 Mhz
 
#define SX126x_915MHZ   (915000000ul)
 915 Mhz
 
#define SX126x_RETRIES   (5u)
 Retries in case of failed transmission.
 
#define SX126x_MAX_PACKET_LEN   (0x40u)
 This is the maximum number of bytes that can be carried by the LORA.
 
#define SX126x_PREAMBLE_LENGTH   (8u)
 Preamble length, default=8.
 
#define SX126x_CAD_TIMEOUT_MS   (2 * 1000ul)
 channel activity detection timeout
 
#define SX126x_POWERUP_DELAY_MS   3
 Power up time of the SX126x.
 
#define SX126x_SLEEP_WARM_START   0x04
 Retain configuration during sleep.
 
#define SX126x_REG_OCP   0x08E7
 SX126x register adresses. More...
 
#define SX126x_REG_LORASW   0x0740
 LoRa SyncWord.
 
#define SX126x_HEADER_LEN   sizeof(sx126x_header_t)
 Size header inside LoRa payload.
 
#define SX126x_MAX_PAYLOAD_LEN   (SX126x_MAX_PACKET_LEN - SX126x_HEADER_LEN)
 Max payload length.
 

Typedefs

typedef enum sx126xCommands_e sx126x_commands_t
 Commands for the SX126x chip.
 
typedef uint16_t sx126x_sequenceNumber_t
 Sequence number data type.
 
typedef uint8_t sx126x_RSSI_t
 RSSI data type.
 
typedef int8_t sx126x_SNR_t
 SNR data type.
 
typedef int8_t sx126x_powerLevel_t
 Power level in dBm.
 

Enumerations

enum  sx126xCommands_e {
  SX126x_RESET_STATS = 0x00, SX126x_CLR_IRQSTATUS = 0x02, SX126x_CLR_ERROR = 0x07, SX126x_CFG_DIOIRQ = 0x08,
  SX126x_SET_LORASYMBTIMEOUT = 0xA0, SX126x_WRITE_REGISTER = 0x0D, SX126x_WRITE_BUFFER = 0x0E, SX126x_GET_STATS = 0x10,
  SX126x_GET_PACKETTYPE = 0x11, SX126x_GET_IRQSTATUS = 0x12, SX126x_GET_RXBUFFERSTATUS = 0x13, SX126x_GET_PACKETSTATUS = 0x14,
  SX126x_GET_RSSIINST = 0x15, SX126x_GET_ERROR = 0x17, SX126x_READ_REGISTER = 0x1D, SX126x_READ_BUFFER = 0x1E,
  SX126x_SET_STANDBY = 0x80, SX126x_SET_RX = 0x82, SX126x_SET_TX = 0x83, SX126x_SET_SLEEP = 0x84,
  SX126x_SET_RFFREQUENCY = 0x86, SX126x_SET_CADPARAMS = 0x88, SX126x_CALIBRATE = 0x89, SX126x_SET_PACKETTYPE = 0x8A,
  SX126x_SET_MODULATIONPARAMS = 0x8B, SX126x_SET_PACKETPARAMS = 0x8C, SX126x_SET_TXPARAMS = 0x8E, SX126x_SET_BUFFERBASEADDRESS = 0x8F,
  SX126x_SET_TXFALLBACKMODE = 0x93, SX126x_SET_RXDUTYCYCLE = 0x94, SX126x_SET_PACONFIG = 0x95, SX126x_SET_REGULATORMODE = 0x96,
  SX126x_SET_TCXOMODE = 0x97, SX126x_CALIBRATEIMAGE = 0x98, SX126x_SET_RFSWITCHMODE = 0x9D, SX126x_SET_STOPRXTIMERONPREAMBLE = 0x9F,
  SX126x_GET_STATUS = 0xC0, SX126x_SET_FS = 0xC1, SX126x_SET_CAD = 0xC5, SX126x_SET_TXCONTINUOUSWAVE = 0xD1,
  SX126x_SET_TXCONTINUOUSPREAMBLE = 0xD2
}
 Commands for the SX126x chip.
 
enum  sx126x_radioStandbyModes_t { SX126x_STDBY_RC = 0x00, SX126x_STDBY_XOSC = 0x01 }
 Declares the oscillator in use while in standby mode. More...
 
enum  sx126x_radioRegulatorMode_t { SX126x_USE_LDO = 0x00, SX126x_USE_DCDC = 0x01 }
 Declares the power regulation used to power the device. More...
 
enum  sx126x_radioPacketTypes_t { SX126x_PACKET_TYPE_GFSK = 0x00, SX126x_PACKET_TYPE_LORA = 0x01, SX126x_PACKET_TYPE_NONE = 0x0F }
 Declares the possible packet type (i.e. modem) used.
 
enum  sx126x_radioModes_t {
  SX126x_MODE_SLEEP = 0x00, SX126x_MODE_STDBY_RC, SX126x_MODE_STDBY_XOSC, SX126x_MODE_FS,
  SX126x_MODE_TX, SX126x_MODE_RX, SX126x_MODE_RX_DC, SX126x_MODE_CAD
}
 SX126x operation Modes. More...
 
enum  sx126x_loRaSpreadingFactors_t {
  LORA_SF5 = 0x05, LORA_SF6 = 0x06, LORA_SF7 = 0x07, LORA_SF8 = 0x08,
  LORA_SF9 = 0x09, LORA_SF10 = 0x0A, LORA_SF11 = 0x0B, LORA_SF12 = 0x0C
}
 LoRa spreading factors.
 
enum  sx126x_loRaBandwidths_t {
  LORA_BW_500 = 6, LORA_BW_250 = 5, LORA_BW_125 = 4, LORA_BW_062 = 3,
  LORA_BW_041 = 10, LORA_BW_031 = 2, LORA_BW_020 = 9, LORA_BW_015 = 1,
  LORA_BW_010 = 8, LORA_BW_007 = 0
}
 LoRa Bandwiths.
 
enum  sx126x_loRaCodingRates_t { LORA_CR_4_5 = 0x01, LORA_CR_4_6 = 0x02, LORA_CR_4_7 = 0x03, LORA_CR_4_8 = 0x04 }
 LoRa coding rates.
 
enum  sx126x_loRaCADSymbols_t {
  LORA_CAD_ON_1_SYMB = 0x00, LORA_CAD_ON_2_SYMB = 0x01, LORA_CAD_ON_4_SYMB = 0x02, LORA_CAD_ON_8_SYMB = 0x03,
  LORA_CAD_ON_16_SYMB = 0x04
}
 LoRa CAD number of symbols.
 
enum  sx126x_cadExitModes_t { SX126x_CAD_ONLY = 0x00, SX126x_CAD_RX = 0x01 }
 CAD exit type.
 
enum  SX126x_packetTypes_t { PACKET_TYPE_GFSK = 0x00, PACKET_TYPE_LORA = 0x01, PACKET_TYPE_NONE = 0x0F }
 SX126x packet types.
 
enum  sx126x_RampTimes_t {
  RADIO_RAMP_10_US = 0x00, RADIO_RAMP_20_US = 0x01, RADIO_RAMP_40_US = 0x02, RADIO_RAMP_80_US = 0x03,
  RADIO_RAMP_200_US = 0x04, RADIO_RAMP_800_US = 0x05, RADIO_RAMP_1700_US = 0x06, RADIO_RAMP_3400_US = 0x07
}
 Ramping time for power amplifier.
 
enum  sx126x_tcxoVoltage_t {
  SX126x_TCXO_1V6 = 0x00, SX126x_TCXO_1V7, SX126x_TCXO_1V8, SX126x_TCXO_2V2,
  SX126x_TCXO_2V4, SX126x_TCXO_2V7, SX126x_TCXO_3V0, SX126x_TCXO_3V3
}
 SX126x TCXO output voltages.
 
enum  sx126x_irqMasks_t {
  SX126x_IRQ_NONE = 0x0000, SX126x_IRQ_TX_DONE = 0x0001, SX126x_IRQ_RX_DONE = 0x0002, SX126x_IRQ_PREAMBLE_DETECTED = 0x0004,
  SX126x_IRQ_SYNCWORD_VALID = 0x0008, SX126x_IRQ_HEADER_VALID = 0x0010, SX126x_IRQ_HEADER_ERROR = 0x0020, SX126x_IRQ_CRC_ERROR = 0x0040,
  SX126x_IRQ_CAD_DONE = 0x0080, SX126x_IRQ_CAD_ACTIVITY_DETECTED = 0x0100, SX126x_IRQ_RX_TX_TIMEOUT = 0x0200, SX126x_IRQ_ALL = 0xFFFF
}
 IRQ masks.
 

Macro Definition Documentation

◆ MY_SX126x_TX_POWER_DBM

#define MY_SX126x_TX_POWER_DBM   (13u)

Set TX power level, default 13dBm (overridden if ATC mode enabled)

See here https://en.wikipedia.org/wiki/Short_Range_Devices

Definition at line 161 of file SX126x.h.

◆ SX126x_REG_OCP

#define SX126x_REG_OCP   0x08E7

SX126x register adresses.

Over current protection value

Definition at line 182 of file SX126x.h.

Enumeration Type Documentation

◆ sx126x_radioModes_t

SX126x operation Modes.

Enumerator
SX126x_MODE_SLEEP 

SX126x is in sleep mode.

SX126x_MODE_STDBY_RC 

SX126x is in standby mode with RC oscillator.

SX126x_MODE_STDBY_XOSC 

SX126x is in standby mode with XOSC oscillator.

SX126x_MODE_FS 

SX126x is in frequency synthesis mode.

SX126x_MODE_TX 

SX126x is in transmit mode.

SX126x_MODE_RX 

SX126x is in receive mode.

SX126x_MODE_RX_DC 

SX126x is in receive duty cycle mode.

SX126x_MODE_CAD 

SX126x is in channel activity detection mode.

Definition at line 302 of file SX126x.h.

◆ sx126x_radioRegulatorMode_t

Declares the power regulation used to power the device.

This command allows the user to specify if DC-DC or LDO is used for power regulation. Using only LDO implies that the Rx or Tx current is doubled

Definition at line 249 of file SX126x.h.

◆ sx126x_radioStandbyModes_t

Declares the oscillator in use while in standby mode.

Using the STDBY_RC standby mode allow to reduce the energy consumption STDBY_XOSC should be used for time critical applications

Definition at line 238 of file SX126x.h.