ESPHome 2025.7.1
Loading...
Searching...
No Matches
esphome::sx126x::SX126x Class Reference

#include <sx126x.h>

Inheritance diagram for esphome::sx126x::SX126x:
esphome::Component esphome::spi::SPIDevice< spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_8MHZ > esphome::spi::SPIClient

Public Member Functions

size_t get_max_packet_size ()
 
float get_setup_priority () const override
 
void setup () override
 
void loop () override
 
void dump_config () override
 
void set_bandwidth (SX126xBw bandwidth)
 
void set_bitrate (uint32_t bitrate)
 
void set_busy_pin (InternalGPIOPin *busy_pin)
 
void set_coding_rate (uint8_t coding_rate)
 
void set_crc_enable (bool crc_enable)
 
void set_deviation (uint32_t deviation)
 
void set_dio1_pin (InternalGPIOPin *dio1_pin)
 
void set_frequency (uint32_t frequency)
 
void set_hw_version (const std::string &hw_version)
 
void set_mode_rx ()
 
void set_mode_tx ()
 
void set_mode_standby (SX126xStandbyMode mode)
 
void set_mode_sleep ()
 
void set_modulation (uint8_t modulation)
 
void set_pa_power (int8_t power)
 
void set_pa_ramp (uint8_t ramp)
 
void set_payload_length (uint8_t payload_length)
 
void set_preamble_detect (uint16_t preamble_detect)
 
void set_preamble_size (uint16_t preamble_size)
 
void set_rst_pin (InternalGPIOPin *rst_pin)
 
void set_rx_start (bool rx_start)
 
void set_rf_switch (bool rf_switch)
 
void set_shaping (uint8_t shaping)
 
void set_spreading_factor (uint8_t spreading_factor)
 
void set_sync_value (const std::vector< uint8_t > &sync_value)
 
void set_tcxo_voltage (uint8_t tcxo_voltage)
 
void set_tcxo_delay (uint32_t tcxo_delay)
 
void run_image_cal ()
 
void configure ()
 
SX126xError transmit_packet (const std::vector< uint8_t > &packet)
 
void register_listener (SX126xListener *listener)
 
Trigger< std::vector< uint8_t >, float, float > * get_packet_trigger () const
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop().
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual bool teardown ()
 Called during teardown to allow component to gracefully finish operations.
 
virtual void on_powerdown ()
 Called after teardown is complete to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
virtual void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const char *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning (const char *message="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages.
 
const char * get_component_source () const
 Get the integration where this component was declared as a string.
 
bool should_warn_of_blocking (uint32_t blocking_time)
 
- Public Member Functions inherited from esphome::spi::SPIDevice< spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_8MHZ >
 SPIDevice ()
 
 SPIDevice (SPIComponent *parent, GPIOPin *cs_pin)
 
void spi_setup () override
 
void spi_teardown () override
 
void set_spi_parent (SPIComponent *parent)
 
void set_cs_pin (GPIOPin *cs)
 
void set_data_rate (uint32_t data_rate)
 
void set_bit_order (SPIBitOrder order)
 
void set_mode (SPIMode mode)
 
uint8_t read_byte ()
 
void read_array (uint8_t *data, size_t length)
 
void write (uint16_t data, size_t num_bits)
 Write a single data item, up to 32 bits.
 
void write_cmd_addr_data (size_t cmd_bits, uint32_t cmd, size_t addr_bits, uint32_t address, const uint8_t *data, size_t length, uint8_t bus_width=1)
 
void write_byte (uint8_t data)
 
void transfer_array (uint8_t *data, size_t length)
 Write the array data, replace with received data.
 
void transfer_array (std::array< uint8_t, N > &data)
 
uint8_t transfer_byte (uint8_t data)
 
void write_byte16 (uint16_t data)
 Write 16 bit data.
 
void write_array16 (const uint16_t *data, size_t length)
 Write an array of data as 16 bit values, byte-swapping if required.
 
void enable ()
 
void disable ()
 
void write_array (const uint8_t *data, size_t length)
 
void write_array (const std::array< uint8_t, N > &data)
 
void write_array (const std::vector< uint8_t > &data)
 
- Public Member Functions inherited from esphome::spi::SPIClient
 SPIClient (SPIBitOrder bit_order, SPIMode mode, uint32_t data_rate)
 
bool spi_is_ready ()
 
void set_release_device (bool release)
 
void set_write_only (bool write_only)
 

Protected Member Functions

void configure_fsk_ook_ ()
 
void configure_lora_ ()
 
void set_packet_params_ (uint8_t payload_length)
 
uint8_t read_fifo_ (uint8_t offset, std::vector< uint8_t > &packet)
 
void write_fifo_ (uint8_t offset, const std::vector< uint8_t > &packet)
 
void write_opcode_ (uint8_t opcode, uint8_t *data, uint8_t size)
 
uint8_t read_opcode_ (uint8_t opcode, uint8_t *data, uint8_t size)
 
void write_register_ (uint16_t reg, uint8_t *data, uint8_t size)
 
void read_register_ (uint16_t reg, uint8_t *data, uint8_t size)
 
void call_listeners_ (const std::vector< uint8_t > &packet, float rssi, float snr)
 
void wait_busy_ ()
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_setup ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function.
 
bool cancel_interval (const char *name)
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name.
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function.
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name.
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function.
 
bool cancel_timeout (const char *name)
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty.
 

Protected Attributes

Trigger< std::vector< uint8_t >, float, float > * packet_trigger_ {new Trigger<std::vector<uint8_t>, float, float>()}
 
std::vector< SX126xListener * > listeners_
 
std::vector< uint8_t > packet_
 
std::vector< uint8_t > sync_value_
 
InternalGPIOPinbusy_pin_ {nullptr}
 
InternalGPIOPindio1_pin_ {nullptr}
 
InternalGPIOPinrst_pin_ {nullptr}
 
std::string hw_version_
 
char version_ [16]
 
SX126xBw bandwidth_ {SX126X_BW_125000}
 
uint32_t bitrate_ {0}
 
uint32_t deviation_ {0}
 
uint32_t frequency_ {0}
 
uint32_t payload_length_ {0}
 
uint32_t tcxo_delay_ {0}
 
uint16_t preamble_detect_ {0}
 
uint16_t preamble_size_ {0}
 
uint8_t tcxo_voltage_ {0}
 
uint8_t coding_rate_ {0}
 
uint8_t modulation_ {PACKET_TYPE_LORA}
 
uint8_t pa_ramp_ {0}
 
uint8_t shaping_ {0}
 
uint8_t spreading_factor_ {0}
 
int8_t pa_power_ {0}
 
bool crc_enable_ {false}
 
bool rx_start_ {false}
 
bool rf_switch_ {false}
 
- Protected Attributes inherited from esphome::Component
const char * component_source_ {nullptr}
 
uint16_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_MS}
 Warn if blocked for this many ms (max 65.5s)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-1: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED) Bit 2: STATUS_LED_WARNING Bit 3: STATUS_LED_ERROR Bits 4-7: Unused - reserved for future expansion (50% of the bits are free)
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
- Protected Attributes inherited from esphome::spi::SPIClient
SPIBitOrder bit_order_ {BIT_ORDER_MSB_FIRST}
 
SPIMode mode_ {MODE0}
 
uint32_t data_rate_ {1000000}
 
SPIComponentparent_ {nullptr}
 
GPIOPincs_ {nullptr}
 
bool release_device_ {false}
 
bool write_only_ {false}
 
SPIDelegatedelegate_ {SPIDelegate::NULL_DELEGATE}
 

Detailed Description

Definition at line 56 of file sx126x.h.

Member Function Documentation

◆ call_listeners_()

void esphome::sx126x::SX126x::call_listeners_ ( const std::vector< uint8_t > & packet,
float rssi,
float snr )
protected

Definition at line 327 of file sx126x.cpp.

◆ configure()

void esphome::sx126x::SX126x::configure ( )

Definition at line 122 of file sx126x.cpp.

◆ configure_fsk_ook_()

void esphome::sx126x::SX126x::configure_fsk_ook_ ( )
protected

◆ configure_lora_()

void esphome::sx126x::SX126x::configure_lora_ ( )
protected

◆ dump_config()

void esphome::sx126x::SX126x::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 462 of file sx126x.cpp.

◆ get_max_packet_size()

size_t esphome::sx126x::SX126x::get_max_packet_size ( )

Definition at line 255 of file sx126x.cpp.

◆ get_packet_trigger()

Trigger< std::vector< uint8_t >, float, float > * esphome::sx126x::SX126x::get_packet_trigger ( ) const
inline

Definition at line 96 of file sx126x.h.

◆ get_setup_priority()

float esphome::sx126x::SX126x::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 61 of file sx126x.h.

◆ loop()

void esphome::sx126x::SX126x::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 334 of file sx126x.cpp.

◆ read_fifo_()

uint8_t esphome::sx126x::SX126x::read_fifo_ ( uint8_t offset,
std::vector< uint8_t > & packet )
protected

Definition at line 33 of file sx126x.cpp.

◆ read_opcode_()

uint8_t esphome::sx126x::SX126x::read_opcode_ ( uint8_t opcode,
uint8_t * data,
uint8_t size )
protected

Definition at line 58 of file sx126x.cpp.

◆ read_register_()

void esphome::sx126x::SX126x::read_register_ ( uint16_t reg,
uint8_t * data,
uint8_t size )
protected

Definition at line 81 of file sx126x.cpp.

◆ register_listener()

void esphome::sx126x::SX126x::register_listener ( SX126xListener * listener)
inline

Definition at line 95 of file sx126x.h.

◆ run_image_cal()

void esphome::sx126x::SX126x::run_image_cal ( )

Definition at line 364 of file sx126x.cpp.

◆ set_bandwidth()

void esphome::sx126x::SX126x::set_bandwidth ( SX126xBw bandwidth)
inline

Definition at line 65 of file sx126x.h.

◆ set_bitrate()

void esphome::sx126x::SX126x::set_bitrate ( uint32_t bitrate)
inline

Definition at line 66 of file sx126x.h.

◆ set_busy_pin()

void esphome::sx126x::SX126x::set_busy_pin ( InternalGPIOPin * busy_pin)
inline

Definition at line 67 of file sx126x.h.

◆ set_coding_rate()

void esphome::sx126x::SX126x::set_coding_rate ( uint8_t coding_rate)
inline

Definition at line 68 of file sx126x.h.

◆ set_crc_enable()

void esphome::sx126x::SX126x::set_crc_enable ( bool crc_enable)
inline

Definition at line 69 of file sx126x.h.

◆ set_deviation()

void esphome::sx126x::SX126x::set_deviation ( uint32_t deviation)
inline

Definition at line 70 of file sx126x.h.

◆ set_dio1_pin()

void esphome::sx126x::SX126x::set_dio1_pin ( InternalGPIOPin * dio1_pin)
inline

Definition at line 71 of file sx126x.h.

◆ set_frequency()

void esphome::sx126x::SX126x::set_frequency ( uint32_t frequency)
inline

Definition at line 72 of file sx126x.h.

◆ set_hw_version()

void esphome::sx126x::SX126x::set_hw_version ( const std::string & hw_version)
inline

Definition at line 73 of file sx126x.h.

◆ set_mode_rx()

void esphome::sx126x::SX126x::set_mode_rx ( )

Definition at line 389 of file sx126x.cpp.

◆ set_mode_sleep()

void esphome::sx126x::SX126x::set_mode_sleep ( )

Definition at line 437 of file sx126x.cpp.

◆ set_mode_standby()

void esphome::sx126x::SX126x::set_mode_standby ( SX126xStandbyMode mode)

Definition at line 443 of file sx126x.cpp.

◆ set_mode_tx()

void esphome::sx126x::SX126x::set_mode_tx ( )

Definition at line 415 of file sx126x.cpp.

◆ set_modulation()

void esphome::sx126x::SX126x::set_modulation ( uint8_t modulation)
inline

Definition at line 78 of file sx126x.h.

◆ set_pa_power()

void esphome::sx126x::SX126x::set_pa_power ( int8_t power)
inline

Definition at line 79 of file sx126x.h.

◆ set_pa_ramp()

void esphome::sx126x::SX126x::set_pa_ramp ( uint8_t ramp)
inline

Definition at line 80 of file sx126x.h.

◆ set_packet_params_()

void esphome::sx126x::SX126x::set_packet_params_ ( uint8_t payload_length)
protected

Definition at line 262 of file sx126x.cpp.

◆ set_payload_length()

void esphome::sx126x::SX126x::set_payload_length ( uint8_t payload_length)
inline

Definition at line 81 of file sx126x.h.

◆ set_preamble_detect()

void esphome::sx126x::SX126x::set_preamble_detect ( uint16_t preamble_detect)
inline

Definition at line 82 of file sx126x.h.

◆ set_preamble_size()

void esphome::sx126x::SX126x::set_preamble_size ( uint16_t preamble_size)
inline

Definition at line 83 of file sx126x.h.

◆ set_rf_switch()

void esphome::sx126x::SX126x::set_rf_switch ( bool rf_switch)
inline

Definition at line 86 of file sx126x.h.

◆ set_rst_pin()

void esphome::sx126x::SX126x::set_rst_pin ( InternalGPIOPin * rst_pin)
inline

Definition at line 84 of file sx126x.h.

◆ set_rx_start()

void esphome::sx126x::SX126x::set_rx_start ( bool rx_start)
inline

Definition at line 85 of file sx126x.h.

◆ set_shaping()

void esphome::sx126x::SX126x::set_shaping ( uint8_t shaping)
inline

Definition at line 87 of file sx126x.h.

◆ set_spreading_factor()

void esphome::sx126x::SX126x::set_spreading_factor ( uint8_t spreading_factor)
inline

Definition at line 88 of file sx126x.h.

◆ set_sync_value()

void esphome::sx126x::SX126x::set_sync_value ( const std::vector< uint8_t > & sync_value)
inline

Definition at line 89 of file sx126x.h.

◆ set_tcxo_delay()

void esphome::sx126x::SX126x::set_tcxo_delay ( uint32_t tcxo_delay)
inline

Definition at line 91 of file sx126x.h.

◆ set_tcxo_voltage()

void esphome::sx126x::SX126x::set_tcxo_voltage ( uint8_t tcxo_voltage)
inline

Definition at line 90 of file sx126x.h.

◆ setup()

void esphome::sx126x::SX126x::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 107 of file sx126x.cpp.

◆ transmit_packet()

SX126xError esphome::sx126x::SX126x::transmit_packet ( const std::vector< uint8_t > & packet)

Definition at line 287 of file sx126x.cpp.

◆ wait_busy_()

void esphome::sx126x::SX126x::wait_busy_ ( )
protected

Definition at line 449 of file sx126x.cpp.

◆ write_fifo_()

void esphome::sx126x::SX126x::write_fifo_ ( uint8_t offset,
const std::vector< uint8_t > & packet )
protected

Definition at line 46 of file sx126x.cpp.

◆ write_opcode_()

void esphome::sx126x::SX126x::write_opcode_ ( uint8_t opcode,
uint8_t * data,
uint8_t size )
protected

Definition at line 70 of file sx126x.cpp.

◆ write_register_()

void esphome::sx126x::SX126x::write_register_ ( uint16_t reg,
uint8_t * data,
uint8_t size )
protected

Definition at line 94 of file sx126x.cpp.

Field Documentation

◆ bandwidth_

SX126xBw esphome::sx126x::SX126x::bandwidth_ {SX126X_BW_125000}
protected

Definition at line 119 of file sx126x.h.

◆ bitrate_

uint32_t esphome::sx126x::SX126x::bitrate_ {0}
protected

Definition at line 120 of file sx126x.h.

◆ busy_pin_

InternalGPIOPin* esphome::sx126x::SX126x::busy_pin_ {nullptr}
protected

Definition at line 114 of file sx126x.h.

◆ coding_rate_

uint8_t esphome::sx126x::SX126x::coding_rate_ {0}
protected

Definition at line 128 of file sx126x.h.

◆ crc_enable_

bool esphome::sx126x::SX126x::crc_enable_ {false}
protected

Definition at line 134 of file sx126x.h.

◆ deviation_

uint32_t esphome::sx126x::SX126x::deviation_ {0}
protected

Definition at line 121 of file sx126x.h.

◆ dio1_pin_

InternalGPIOPin* esphome::sx126x::SX126x::dio1_pin_ {nullptr}
protected

Definition at line 115 of file sx126x.h.

◆ frequency_

uint32_t esphome::sx126x::SX126x::frequency_ {0}
protected

Definition at line 122 of file sx126x.h.

◆ hw_version_

std::string esphome::sx126x::SX126x::hw_version_
protected

Definition at line 117 of file sx126x.h.

◆ listeners_

std::vector<SX126xListener *> esphome::sx126x::SX126x::listeners_
protected

Definition at line 111 of file sx126x.h.

◆ modulation_

uint8_t esphome::sx126x::SX126x::modulation_ {PACKET_TYPE_LORA}
protected

Definition at line 129 of file sx126x.h.

◆ pa_power_

int8_t esphome::sx126x::SX126x::pa_power_ {0}
protected

Definition at line 133 of file sx126x.h.

◆ pa_ramp_

uint8_t esphome::sx126x::SX126x::pa_ramp_ {0}
protected

Definition at line 130 of file sx126x.h.

◆ packet_

std::vector<uint8_t> esphome::sx126x::SX126x::packet_
protected

Definition at line 112 of file sx126x.h.

◆ packet_trigger_

Trigger<std::vector<uint8_t>, float, float>* esphome::sx126x::SX126x::packet_trigger_ {new Trigger<std::vector<uint8_t>, float, float>()}
protected

Definition at line 110 of file sx126x.h.

◆ payload_length_

uint32_t esphome::sx126x::SX126x::payload_length_ {0}
protected

Definition at line 123 of file sx126x.h.

◆ preamble_detect_

uint16_t esphome::sx126x::SX126x::preamble_detect_ {0}
protected

Definition at line 125 of file sx126x.h.

◆ preamble_size_

uint16_t esphome::sx126x::SX126x::preamble_size_ {0}
protected

Definition at line 126 of file sx126x.h.

◆ rf_switch_

bool esphome::sx126x::SX126x::rf_switch_ {false}
protected

Definition at line 136 of file sx126x.h.

◆ rst_pin_

InternalGPIOPin* esphome::sx126x::SX126x::rst_pin_ {nullptr}
protected

Definition at line 116 of file sx126x.h.

◆ rx_start_

bool esphome::sx126x::SX126x::rx_start_ {false}
protected

Definition at line 135 of file sx126x.h.

◆ shaping_

uint8_t esphome::sx126x::SX126x::shaping_ {0}
protected

Definition at line 131 of file sx126x.h.

◆ spreading_factor_

uint8_t esphome::sx126x::SX126x::spreading_factor_ {0}
protected

Definition at line 132 of file sx126x.h.

◆ sync_value_

std::vector<uint8_t> esphome::sx126x::SX126x::sync_value_
protected

Definition at line 113 of file sx126x.h.

◆ tcxo_delay_

uint32_t esphome::sx126x::SX126x::tcxo_delay_ {0}
protected

Definition at line 124 of file sx126x.h.

◆ tcxo_voltage_

uint8_t esphome::sx126x::SX126x::tcxo_voltage_ {0}
protected

Definition at line 127 of file sx126x.h.

◆ version_

char esphome::sx126x::SX126x::version_[16]
protected

Definition at line 118 of file sx126x.h.


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