ESPHome 2025.7.1
Loading...
Searching...
No Matches
esphome::sx127x::SX127x Class Reference

#include <sx127x.h>

Inheritance diagram for esphome::sx127x::SX127x:
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_auto_cal (bool auto_cal)
 
void set_bandwidth (SX127xBw bandwidth)
 
void set_bitrate (uint32_t bitrate)
 
void set_bitsync (bool bitsync)
 
void set_coding_rate (uint8_t coding_rate)
 
void set_crc_enable (bool crc_enable)
 
void set_deviation (uint32_t deviation)
 
void set_dio0_pin (InternalGPIOPin *dio0_pin)
 
void set_frequency (uint32_t frequency)
 
void set_mode_rx ()
 
void set_mode_tx ()
 
void set_mode_standby ()
 
void set_mode_sleep ()
 
void set_modulation (uint8_t modulation)
 
void set_pa_pin (uint8_t pin)
 
void set_pa_power (uint8_t power)
 
void set_pa_ramp (uint8_t ramp)
 
void set_packet_mode (bool packet_mode)
 
void set_payload_length (uint8_t payload_length)
 
void set_preamble_errors (uint8_t preamble_errors)
 
void set_preamble_polarity (uint8_t preamble_polarity)
 
void set_preamble_size (uint16_t preamble_size)
 
void set_preamble_detect (uint8_t preamble_detect)
 
void set_rst_pin (InternalGPIOPin *rst_pin)
 
void set_rx_floor (float floor)
 
void set_rx_start (bool start)
 
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 run_image_cal ()
 
void configure ()
 
SX127xError transmit_packet (const std::vector< uint8_t > &packet)
 
void register_listener (SX127xListener *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_mode_ (uint8_t modulation, uint8_t mode)
 
void write_fifo_ (const std::vector< uint8_t > &packet)
 
void read_fifo_ (std::vector< uint8_t > &packet)
 
void write_register_ (uint8_t reg, uint8_t value)
 
void call_listeners_ (const std::vector< uint8_t > &packet, float rssi, float snr)
 
uint8_t read_register_ (uint8_t reg)
 
- 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< SX127xListener * > listeners_
 
std::vector< uint8_t > packet_
 
std::vector< uint8_t > sync_value_
 
InternalGPIOPindio0_pin_ {nullptr}
 
InternalGPIOPinrst_pin_ {nullptr}
 
SX127xBw bandwidth_
 
uint32_t bitrate_
 
uint32_t deviation_
 
uint32_t frequency_
 
uint32_t payload_length_
 
uint16_t preamble_size_
 
uint8_t coding_rate_
 
uint8_t modulation_
 
uint8_t pa_pin_
 
uint8_t pa_power_
 
uint8_t pa_ramp_
 
uint8_t preamble_detect_
 
uint8_t preamble_errors_
 
uint8_t preamble_polarity_
 
uint8_t shaping_
 
uint8_t spreading_factor_
 
float rx_floor_
 
bool auto_cal_ {false}
 
bool bitsync_ {false}
 
bool crc_enable_ {false}
 
bool packet_mode_ {false}
 
bool rx_start_ {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 44 of file sx127x.h.

Member Function Documentation

◆ call_listeners_()

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

Definition at line 301 of file sx127x.cpp.

◆ configure()

void esphome::sx127x::SX127x::configure ( )

Definition at line 70 of file sx127x.cpp.

◆ configure_fsk_ook_()

void esphome::sx127x::SX127x::configure_fsk_ook_ ( )
protected

Definition at line 131 of file sx127x.cpp.

◆ configure_lora_()

void esphome::sx127x::SX127x::configure_lora_ ( )
protected

Definition at line 204 of file sx127x.cpp.

◆ dump_config()

void esphome::sx127x::SX127x::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 404 of file sx127x.cpp.

◆ get_max_packet_size()

size_t esphome::sx127x::SX127x::get_max_packet_size ( )

Definition at line 244 of file sx127x.cpp.

◆ get_packet_trigger()

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

Definition at line 86 of file sx127x.h.

◆ get_setup_priority()

float esphome::sx127x::SX127x::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 49 of file sx127x.h.

◆ loop()

void esphome::sx127x::SX127x::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 308 of file sx127x.cpp.

◆ read_fifo_()

void esphome::sx127x::SX127x::read_fifo_ ( std::vector< uint8_t > & packet)
protected

Definition at line 38 of file sx127x.cpp.

◆ read_register_()

uint8_t esphome::sx127x::SX127x::read_register_ ( uint8_t reg)
protected

Definition at line 23 of file sx127x.cpp.

◆ register_listener()

void esphome::sx127x::SX127x::register_listener ( SX127xListener * listener)
inline

Definition at line 85 of file sx127x.h.

◆ run_image_cal()

void esphome::sx127x::SX127x::run_image_cal ( )

Definition at line 341 of file sx127x.cpp.

◆ set_auto_cal()

void esphome::sx127x::SX127x::set_auto_cal ( bool auto_cal)
inline

Definition at line 53 of file sx127x.h.

◆ set_bandwidth()

void esphome::sx127x::SX127x::set_bandwidth ( SX127xBw bandwidth)
inline

Definition at line 54 of file sx127x.h.

◆ set_bitrate()

void esphome::sx127x::SX127x::set_bitrate ( uint32_t bitrate)
inline

Definition at line 55 of file sx127x.h.

◆ set_bitsync()

void esphome::sx127x::SX127x::set_bitsync ( bool bitsync)
inline

Definition at line 56 of file sx127x.h.

◆ set_coding_rate()

void esphome::sx127x::SX127x::set_coding_rate ( uint8_t coding_rate)
inline

Definition at line 57 of file sx127x.h.

◆ set_crc_enable()

void esphome::sx127x::SX127x::set_crc_enable ( bool crc_enable)
inline

Definition at line 58 of file sx127x.h.

◆ set_deviation()

void esphome::sx127x::SX127x::set_deviation ( uint32_t deviation)
inline

Definition at line 59 of file sx127x.h.

◆ set_dio0_pin()

void esphome::sx127x::SX127x::set_dio0_pin ( InternalGPIOPin * dio0_pin)
inline

Definition at line 60 of file sx127x.h.

◆ set_frequency()

void esphome::sx127x::SX127x::set_frequency ( uint32_t frequency)
inline

Definition at line 61 of file sx127x.h.

◆ set_mode_()

void esphome::sx127x::SX127x::set_mode_ ( uint8_t modulation,
uint8_t mode )
protected

Definition at line 365 of file sx127x.cpp.

◆ set_mode_rx()

void esphome::sx127x::SX127x::set_mode_rx ( )

Definition at line 384 of file sx127x.cpp.

◆ set_mode_sleep()

void esphome::sx127x::SX127x::set_mode_sleep ( )

Definition at line 402 of file sx127x.cpp.

◆ set_mode_standby()

void esphome::sx127x::SX127x::set_mode_standby ( )

Definition at line 400 of file sx127x.cpp.

◆ set_mode_tx()

void esphome::sx127x::SX127x::set_mode_tx ( )

Definition at line 392 of file sx127x.cpp.

◆ set_modulation()

void esphome::sx127x::SX127x::set_modulation ( uint8_t modulation)
inline

Definition at line 66 of file sx127x.h.

◆ set_pa_pin()

void esphome::sx127x::SX127x::set_pa_pin ( uint8_t pin)
inline

Definition at line 67 of file sx127x.h.

◆ set_pa_power()

void esphome::sx127x::SX127x::set_pa_power ( uint8_t power)
inline

Definition at line 68 of file sx127x.h.

◆ set_pa_ramp()

void esphome::sx127x::SX127x::set_pa_ramp ( uint8_t ramp)
inline

Definition at line 69 of file sx127x.h.

◆ set_packet_mode()

void esphome::sx127x::SX127x::set_packet_mode ( bool packet_mode)
inline

Definition at line 70 of file sx127x.h.

◆ set_payload_length()

void esphome::sx127x::SX127x::set_payload_length ( uint8_t payload_length)
inline

Definition at line 71 of file sx127x.h.

◆ set_preamble_detect()

void esphome::sx127x::SX127x::set_preamble_detect ( uint8_t preamble_detect)
inline

Definition at line 75 of file sx127x.h.

◆ set_preamble_errors()

void esphome::sx127x::SX127x::set_preamble_errors ( uint8_t preamble_errors)
inline

Definition at line 72 of file sx127x.h.

◆ set_preamble_polarity()

void esphome::sx127x::SX127x::set_preamble_polarity ( uint8_t preamble_polarity)
inline

Definition at line 73 of file sx127x.h.

◆ set_preamble_size()

void esphome::sx127x::SX127x::set_preamble_size ( uint16_t preamble_size)
inline

Definition at line 74 of file sx127x.h.

◆ set_rst_pin()

void esphome::sx127x::SX127x::set_rst_pin ( InternalGPIOPin * rst_pin)
inline

Definition at line 76 of file sx127x.h.

◆ set_rx_floor()

void esphome::sx127x::SX127x::set_rx_floor ( float floor)
inline

Definition at line 77 of file sx127x.h.

◆ set_rx_start()

void esphome::sx127x::SX127x::set_rx_start ( bool start)
inline

Definition at line 78 of file sx127x.h.

◆ set_shaping()

void esphome::sx127x::SX127x::set_shaping ( uint8_t shaping)
inline

Definition at line 79 of file sx127x.h.

◆ set_spreading_factor()

void esphome::sx127x::SX127x::set_spreading_factor ( uint8_t spreading_factor)
inline

Definition at line 80 of file sx127x.h.

◆ set_sync_value()

void esphome::sx127x::SX127x::set_sync_value ( const std::vector< uint8_t > & sync_value)
inline

Definition at line 81 of file sx127x.h.

◆ setup()

void esphome::sx127x::SX127x::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 52 of file sx127x.cpp.

◆ transmit_packet()

SX127xError esphome::sx127x::SX127x::transmit_packet ( const std::vector< uint8_t > & packet)

Definition at line 255 of file sx127x.cpp.

◆ write_fifo_()

void esphome::sx127x::SX127x::write_fifo_ ( const std::vector< uint8_t > & packet)
protected

Definition at line 45 of file sx127x.cpp.

◆ write_register_()

void esphome::sx127x::SX127x::write_register_ ( uint8_t reg,
uint8_t value )
protected

Definition at line 31 of file sx127x.cpp.

Field Documentation

◆ auto_cal_

bool esphome::sx127x::SX127x::auto_cal_ {false}
protected

Definition at line 120 of file sx127x.h.

◆ bandwidth_

SX127xBw esphome::sx127x::SX127x::bandwidth_
protected

Definition at line 103 of file sx127x.h.

◆ bitrate_

uint32_t esphome::sx127x::SX127x::bitrate_
protected

Definition at line 104 of file sx127x.h.

◆ bitsync_

bool esphome::sx127x::SX127x::bitsync_ {false}
protected

Definition at line 121 of file sx127x.h.

◆ coding_rate_

uint8_t esphome::sx127x::SX127x::coding_rate_
protected

Definition at line 109 of file sx127x.h.

◆ crc_enable_

bool esphome::sx127x::SX127x::crc_enable_ {false}
protected

Definition at line 122 of file sx127x.h.

◆ deviation_

uint32_t esphome::sx127x::SX127x::deviation_
protected

Definition at line 105 of file sx127x.h.

◆ dio0_pin_

InternalGPIOPin* esphome::sx127x::SX127x::dio0_pin_ {nullptr}
protected

Definition at line 101 of file sx127x.h.

◆ frequency_

uint32_t esphome::sx127x::SX127x::frequency_
protected

Definition at line 106 of file sx127x.h.

◆ listeners_

std::vector<SX127xListener *> esphome::sx127x::SX127x::listeners_
protected

Definition at line 98 of file sx127x.h.

◆ modulation_

uint8_t esphome::sx127x::SX127x::modulation_
protected

Definition at line 110 of file sx127x.h.

◆ pa_pin_

uint8_t esphome::sx127x::SX127x::pa_pin_
protected

Definition at line 111 of file sx127x.h.

◆ pa_power_

uint8_t esphome::sx127x::SX127x::pa_power_
protected

Definition at line 112 of file sx127x.h.

◆ pa_ramp_

uint8_t esphome::sx127x::SX127x::pa_ramp_
protected

Definition at line 113 of file sx127x.h.

◆ packet_

std::vector<uint8_t> esphome::sx127x::SX127x::packet_
protected

Definition at line 99 of file sx127x.h.

◆ packet_mode_

bool esphome::sx127x::SX127x::packet_mode_ {false}
protected

Definition at line 123 of file sx127x.h.

◆ packet_trigger_

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

Definition at line 97 of file sx127x.h.

◆ payload_length_

uint32_t esphome::sx127x::SX127x::payload_length_
protected

Definition at line 107 of file sx127x.h.

◆ preamble_detect_

uint8_t esphome::sx127x::SX127x::preamble_detect_
protected

Definition at line 114 of file sx127x.h.

◆ preamble_errors_

uint8_t esphome::sx127x::SX127x::preamble_errors_
protected

Definition at line 115 of file sx127x.h.

◆ preamble_polarity_

uint8_t esphome::sx127x::SX127x::preamble_polarity_
protected

Definition at line 116 of file sx127x.h.

◆ preamble_size_

uint16_t esphome::sx127x::SX127x::preamble_size_
protected

Definition at line 108 of file sx127x.h.

◆ rst_pin_

InternalGPIOPin* esphome::sx127x::SX127x::rst_pin_ {nullptr}
protected

Definition at line 102 of file sx127x.h.

◆ rx_floor_

float esphome::sx127x::SX127x::rx_floor_
protected

Definition at line 119 of file sx127x.h.

◆ rx_start_

bool esphome::sx127x::SX127x::rx_start_ {false}
protected

Definition at line 124 of file sx127x.h.

◆ shaping_

uint8_t esphome::sx127x::SX127x::shaping_
protected

Definition at line 117 of file sx127x.h.

◆ spreading_factor_

uint8_t esphome::sx127x::SX127x::spreading_factor_
protected

Definition at line 118 of file sx127x.h.

◆ sync_value_

std::vector<uint8_t> esphome::sx127x::SX127x::sync_value_
protected

Definition at line 100 of file sx127x.h.


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