[sx127x] Avoid heap allocation for packet trigger (#13698)

This commit is contained in:
J. Nick Koston
2026-02-02 04:43:16 +01:00
committed by GitHub
parent 29f8d70b35
commit bfeb447178
2 changed files with 3 additions and 3 deletions

View File

@@ -300,7 +300,7 @@ void SX127x::call_listeners_(const std::vector<uint8_t> &packet, float rssi, flo
for (auto &listener : this->listeners_) {
listener->on_packet(packet, rssi, snr);
}
this->packet_trigger_->trigger(packet, rssi, snr);
this->packet_trigger_.trigger(packet, rssi, snr);
}
void SX127x::loop() {

View File

@@ -83,7 +83,7 @@ class SX127x : public Component,
void configure();
SX127xError transmit_packet(const std::vector<uint8_t> &packet);
void register_listener(SX127xListener *listener) { this->listeners_.push_back(listener); }
Trigger<std::vector<uint8_t>, float, float> *get_packet_trigger() const { return this->packet_trigger_; };
Trigger<std::vector<uint8_t>, float, float> *get_packet_trigger() { return &this->packet_trigger_; }
protected:
void configure_fsk_ook_();
@@ -94,7 +94,7 @@ class SX127x : public Component,
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);
Trigger<std::vector<uint8_t>, float, float> *packet_trigger_{new Trigger<std::vector<uint8_t>, float, float>()};
Trigger<std::vector<uint8_t>, float, float> packet_trigger_;
std::vector<SX127xListener *> listeners_;
std::vector<uint8_t> packet_;
std::vector<uint8_t> sync_value_;