mirror of
https://github.com/colonelpanichacks/flock-you.git
synced 2026-06-10 14:13:30 -07:00
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.
This commit is contained in:
+7
-15
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user