Skip to content

Commit

Permalink
"no-mfgdata" model condition implementation (#509)
Browse files Browse the repository at this point in the history
"no-mfgdata" model condition implementation and application in the Tile tracker decoder

#505
  • Loading branch information
DigiH authored Jan 31, 2024
1 parent e397bdf commit 6f1835f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/participate/adding-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
4 changes: 3 additions & 1 deletion src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -609,7 +611,7 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
doc["track"] = true;
jsondata["track"] = doc["track"];
}

// bits[7-4]
data = getBinaryData(tagstring[2]);

Expand Down
4 changes: 2 additions & 2 deletions src/devices/tracker_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 6f1835f

Please sign in to comment.