Tracking rolling codes received from real hub

This commit is contained in:
2024-01-02 21:56:22 +11:00
parent 2bc7835dce
commit c2c55d6764

View File

@@ -13,6 +13,9 @@
RFPowerView powerView(RF_CE_PIN, RF_CS_PIN, RF_IRQ_PIN, RF_ID); RFPowerView powerView(RF_CE_PIN, RF_CS_PIN, RF_IRQ_PIN, RF_ID);
uint8_t lastRollingCode1 = 0x3D;
uint8_t lastRollingCode2 = 0x96;
EspMQTTClient client( EspMQTTClient client(
SECRET_WIFI_SSID, // Wifi SSID SECRET_WIFI_SSID, // Wifi SSID
SECRET_WIFI_PASSWORD, // Wifi Password SECRET_WIFI_PASSWORD, // Wifi Password
@@ -50,6 +53,12 @@ void loop() {
} }
void processPacket(const Packet *packet) { 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) { if (packet->type == PacketType::FIELDS) {
FieldsParameters parameters = std::get<FieldsParameters>(packet->parameters); FieldsParameters parameters = std::get<FieldsParameters>(packet->parameters);
for (size_t i = 0; i < parameters.fields.size(); i++) { for (size_t i = 0; i < parameters.fields.size(); i++) {