From a6cc6c74aedfedda7f3e81d728cb4b8a9499c6c2 Mon Sep 17 00:00:00 2001 From: Doug Borg Date: Sat, 7 Feb 2026 21:46:51 -0700 Subject: [PATCH] Always emit is_raven and raven_fw in detection JSON Collapse the two-branch snprintf into a single call so every detection message includes is_raven (true/false) and raven_fw, making the format self-describing regardless of device type. --- src/main.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index da7e14d..08e1f33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -528,21 +528,13 @@ class FYBLECallbacks : public NimBLEAdvertisedDeviceCallbacks { fyGPSLat, fyGPSLon, fyGPSAcc); } char jsonBuf[512]; - int jsonLen; - if (isRaven) { - jsonLen = snprintf(jsonBuf, sizeof(jsonBuf), - "{\"event\":\"detection\",\"detection_method\":\"%s\"," - "\"protocol\":\"bluetooth_le\",\"mac_address\":\"%s\"," - "\"device_name\":\"%s\",\"rssi\":%d," - "\"is_raven\":true,\"raven_fw\":\"%s\"%s}", - method, addrStr.c_str(), name.c_str(), rssi, ravenFW, gpsBuf); - } else { - jsonLen = snprintf(jsonBuf, sizeof(jsonBuf), - "{\"event\":\"detection\",\"detection_method\":\"%s\"," - "\"protocol\":\"bluetooth_le\",\"mac_address\":\"%s\"," - "\"device_name\":\"%s\",\"rssi\":%d%s}", - method, addrStr.c_str(), name.c_str(), rssi, gpsBuf); - } + int jsonLen = snprintf(jsonBuf, sizeof(jsonBuf), + "{\"event\":\"detection\",\"detection_method\":\"%s\"," + "\"protocol\":\"bluetooth_le\",\"mac_address\":\"%s\"," + "\"device_name\":\"%s\",\"rssi\":%d," + "\"is_raven\":%s,\"raven_fw\":\"%s\"%s}", + method, addrStr.c_str(), name.c_str(), rssi, + isRaven ? "true" : "false", isRaven ? ravenFW : "", gpsBuf); printf("%s\n", jsonBuf); // Append newline for BLE framing and send if (jsonLen > 0 && jsonLen < (int)sizeof(jsonBuf) - 1) {