ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
radio_profile.h
Go to the documentation of this file.
1#pragma once
2#include "sx126x_reg.h"
3#include <array>
4#include <span>
5#include <algorithm>
6
7namespace esphome::sx126x {
43
44// Requested settings are separate from the last successfully applied profile.
45// Bounded sync storage makes profile snapshots allocation-free.
51 uint16_t crc_polynomial{0};
52 uint16_t crc_initial{0};
53 uint16_t whitening_initial{0};
54 uint16_t preamble_detect{0};
55 uint16_t preamble_size{0};
57 uint8_t crc_size{0};
58 uint8_t tcxo_voltage{0};
59 uint8_t coding_rate{0};
61 uint8_t pa_ramp{0};
62 uint8_t shaping{0};
63 uint8_t spreading_factor{0};
64 int8_t pa_power{0};
65 uint8_t payload_length{0};
66 bool sx1261{false};
67 bool crc_enable{false};
68 bool crc_inverted{false};
69 bool whitening_enable{false};
70 bool rx_start{false};
71 bool rf_switch{false};
72 std::array<uint8_t, 8> sync_value{};
73 uint8_t sync_size{0};
74 bool sync_valid{true};
75 void set_sync_value(std::span<const uint8_t> bytes) {
76 this->sync_valid = bytes.size() <= this->sync_value.size();
77 if (!this->sync_valid) {
78 return;
79 }
80 std::copy(bytes.begin(), bytes.end(), this->sync_value.begin());
81 this->sync_size = bytes.size();
82 }
83 size_t max_packet_size() const { return this->payload_length > 0 ? this->payload_length : 255; }
84};
85
86// The parts of the last successfully applied profile that runtime operations read.
87// SetPacketParams is encoded once; sends only change its payload length byte.
90 std::array<uint8_t, 9> packet_params{};
92 uint8_t payload_length{0};
94 bool rx_start{false};
95 size_t max_packet_size() const { return this->payload_length > 0 ? this->payload_length : 255; }
96};
97} // namespace esphome::sx126x
static void uint32_t
std::array< uint8_t, 9 > packet_params
void set_sync_value(std::span< const uint8_t > bytes)
std::array< uint8_t, 8 > sync_value