From a806c5e4637a29cadb91657403e1f81e3e340707 Mon Sep 17 00:00:00 2001 From: Marius Gripp Date: Mon, 2 Sep 2019 15:12:22 +0200 Subject: [PATCH] recognize ota trigger mac when sniffing for new macs in wifi environment --- src/macsniff.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/macsniff.cpp b/src/macsniff.cpp index fdb37273..2ab8740e 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -94,6 +94,25 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { // Count only if MAC was not yet seen if (added) { + ESP_LOGD(TAG, "new Mac: %x:%x:%x:%x:%x:%x", + paddr[0], + paddr[1], + paddr[2], + paddr[3], + paddr[4], + paddr[5] + ); + // is newly found MAC the OTA trigger? + uint64_t addr48 = (((uint64_t)paddr[3]) | ((uint64_t)paddr[2] << 8) | + ((uint64_t)paddr[1] << 16) | ((uint64_t)paddr[0] << 24)); + if((int)(addr48-fota_trigger_mac) == 0) + { + ESP_LOGI(TAG, "OTA-MAC found, Update triggered"); + // initiate OTA update + uint8_t cmd[2] = {9, 9}; + rcommand(cmd, 2); + } + // increment counter and one blink led if (sniff_type == MAC_SNIFF_WIFI) { macs_wifi++; // increment Wifi MACs counter @@ -146,4 +165,4 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { // True if MAC WiFi/BLE was new return added; // function returns bool if a new and unique Wifi or BLE mac was // counted (true) or not (false) -} \ No newline at end of file +}