Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no-mfgdata" model condition implementation #509

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading