From c2c55d67641fcc940c437863a9c49aa5dbc19cb3 Mon Sep 17 00:00:00 2001 From: Matt Way Date: Tue, 2 Jan 2024 21:56:22 +1100 Subject: [PATCH] Tracking rolling codes received from real hub --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7f64b26..0778834 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,9 @@ RFPowerView powerView(RF_CE_PIN, RF_CS_PIN, RF_IRQ_PIN, RF_ID); +uint8_t lastRollingCode1 = 0x3D; +uint8_t lastRollingCode2 = 0x96; + EspMQTTClient client( SECRET_WIFI_SSID, // Wifi SSID SECRET_WIFI_PASSWORD, // Wifi Password @@ -50,6 +53,12 @@ void loop() { } void processPacket(const Packet *packet) { + // Update last rolling codes each time a packet from a real hub is detected + if (packet->source == 0x0000) { + lastRollingCode1 = packet->rollingCode1; + lastRollingCode2 = packet->rollingCode2; + } + if (packet->type == PacketType::FIELDS) { FieldsParameters parameters = std::get(packet->parameters); for (size_t i = 0; i < parameters.fields.size(); i++) {