From 180d88d2d659caf52dea91df79a6247051680435 Mon Sep 17 00:00:00 2001 From: DigiH Date: Mon, 29 Jan 2024 15:13:40 +0100 Subject: [PATCH] "no-mfgdata" model condition implementation "no-mfgdata" model condition implementation and application in the Tile tracker decoder https://github.com/theengs/decoder/issues/505 --- docs/participate/adding-decoders.md | 2 ++ src/decoder.cpp | 4 +++- src/devices/tracker_json.h | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/participate/adding-decoders.md b/docs/participate/adding-decoders.md index 80c74d6c..775fb6ef 100644 --- a/docs/participate/adding-decoders.md +++ b/docs/participate/adding-decoders.md @@ -205,6 +205,8 @@ making sure the additional AND condition is at the end. This has the same result Example: `"condition": ["servicedata", "index", 30, "!", "abcd", "&", "servicedata", "index", 0, "1234"] If the value of the service data at index 30 is not 0xabcd and the data at index 0 is 0x1234, the result is a positive detection. +`condition` "no-mfgdata"; This single argument condition allows to test for the non-existence of manufacturerdata in the received advertising data. + ### Properties Properties is a nested JSON object containing one or more JSON objects. In the example above it looks like: ``` diff --git a/src/decoder.cpp b/src/decoder.cpp index 838f2dc5..8dc7d817 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -228,6 +228,8 @@ bool TheengsDecoder::checkDeviceMatch(const JsonArray& condition, break; } } + } else if (mfg_data == nullptr && strstr(cond_str, "no-mfgdata") != nullptr) { + match = true; } else if (dev_name != nullptr && strstr(cond_str, "name") != nullptr) { cmp_str = dev_name; } else if (svc_uuid != nullptr && strstr(cond_str, "uuid") != nullptr) { @@ -609,7 +611,7 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) { doc["track"] = true; jsondata["track"] = doc["track"]; } - + // bits[7-4] data = getBinaryData(tagstring[2]); diff --git a/src/devices/tracker_json.h b/src/devices/tracker_json.h index 11d5369d..7bbe69c8 100644 --- a/src/devices/tracker_json.h +++ b/src/devices/tracker_json.h @@ -58,14 +58,14 @@ const char* _tracker_json_tagit = "{\"brand\":\"Tag-It\",\"model\":\"Smart Track } })"""";*/ -const char* _tracker_json_tile = "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"tag\":\"100f\",\"condition\":[\"uuid\",\"index\",0,\"feed\",\"|\",\"uuid\",\"index\",0,\"feec\",\"|\",\"uuid\",\"index\",0,\"fd84\"],\"properties\":{\"device\":{\"decoder\":[\"static_value\",\"Tile Tracker\"]}}}"; +const char* _tracker_json_tile = "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"tag\":\"100f\",\"condition\":[\"uuid\",\"index\",0,\"feed\",\"|\",\"uuid\",\"index\",0,\"feec\",\"|\",\"uuid\",\"index\",0,\"fd84\",\"&\",\"no-mfgdata\"],\"properties\":{\"device\":{\"decoder\":[\"static_value\",\"Tile Tracker\"]}}}"; /*R""""( { "brand":"Tile", "model":"Smart Tracker", "model_id":"TILE", "tag":"100f", - "condition":["uuid", "index", 0, "feed", "|", "uuid", "index", 0, "feec", "|", "uuid", "index", 0, "fd84"], + "condition":["uuid", "index", 0, "feed", "|", "uuid", "index", 0, "feec", "|", "uuid", "index", 0, "fd84", "&", "no-mfgdata"], "properties":{ "device":{ "decoder":["static_value", "Tile Tracker"]