Skip to content

Commit

Permalink
Test Decoder
Browse files Browse the repository at this point in the history
changes
  • Loading branch information
DigiH committed Oct 22, 2024
1 parent d6fdd20 commit bea4230
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class TheengsDecoder {
GTAG,
BOSCHNYON,
JAALEE,
APPLEAIRPODS,
APPLEWATCH,
APPLEDEVICE,
IBEACON,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#include "devices/BM6_json.h"
#include "devices/TILT_json.h"
#include "devices/JAALEE_json.h"
#include "devices/APPLEAIRPODS_json.h"
#include "devices/APPLEWATCH_json.h"
#include "devices/APPLEDEVICE_json.h"
#include "devices/iBeacon_json.h"
Expand Down Expand Up @@ -227,6 +228,7 @@ const char* _devices[][2] = {
{_tracker_json_GTAG, _tracker_json_props},
{_tracker_json_NYON, _tracker_json_props},
{_JAALEE_json, _JAALEE_json_props},
{_APPLEAIRPODS_json, _APPLEAIRPODS_json_props},
{_APPLEWATCH_json, _APPLEWATCH_json_props},
{_APPLEDEVICE_json, _APPLEDEVICE_json_props},
{_ibeacon_json, _ibeacon_json_props},
Expand Down
25 changes: 25 additions & 0 deletions src/devices/APPLEAIRPODS_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const char* _APPLEAIRPODS_json = "{\"brand\":\"Test\",\"model\":\"Test (Pro)\",\"model_id\":\"APPLEAIRPODS\",\"tag\":\"0b08\",\"condition\":[\"manufacturerdata\",\"index\",8,\"01\",\"&\",\"manufacturerdata\",\">=\",26,\"index\",0,\"4c0007\"],\"properties\":{\"test\":{\"decoder\":[\"static_value\",\"Test Pods\"]}}}";
/*R""""(
{
"brand":"Test",
"model":"Test (Pro)",
"model_id":"APPLEAIRPODS",
"tag":"0b08",
"condition":["manufacturerdata", "index", 8, "01", "&", "manufacturerdata",">=", 26, "index", 0, "4c0007"],
"properties":{
"test":{
"decoder":["static_value", "Test Pods"]
}
}
})"""";*/

const char* _APPLEAIRPODS_json_props = "{\"properties\":{\"test\":{\"unit\":\"string\",\"name\":\"test\"}}}";
/*R""""(
{
"properties":{
"test":{
"unit":"string",
"name":"test"
}
}
})"""";*/
6 changes: 3 additions & 3 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ const char* expected_mfg[] = {
"{\"brand\":\"Apple\",\"model\":\"Apple Continuity\",\"model_id\":\"APPLE_CONT\",\"type\":\"RMAC\",\"device\":\"Apple device\"}",
"{\"brand\":\"Apple\",\"model\":\"Apple Continuity\",\"model_id\":\"APPLE_CONTAT\",\"type\":\"RMAC\",\"device\":\"Apple device\"}",
"{\"brand\":\"Apple\",\"model\":\"Apple Continuity\",\"model_id\":\"APPLE_CONTAT\",\"type\":\"RMAC\",\"device\":\"Apple device\"}",
"{\"brand\":\"Apple\",\"model\":\"Apple Continuity\",\"model_id\":\"APPLE_CONTAT\",\"type\":\"RMAC\",\"device\":\"Apple device\"}",
"{\"brand\":\"iTAG\",\"model\":\"Smart Tracker\",\"model_id\":\"ITAG\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"track\":true,\"device\":\"iTAG Tracker\"}",
"{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"track\":true,\"device\":\"Tile Tracker\"}",
"{\"brand\":\"Govee\",\"model\":\"Smart Air Quality Monitor\",\"model_id\":\"H5106\",\"type\":\"AIR\",\"cidc\":false,\"acts\":true,\"tempc\":22.7,\"tempf\":72.86,\"hum\":63.1,\"pm25\":2}",
Expand Down Expand Up @@ -168,6 +167,7 @@ const char* expected_mfg[] = {
"{\"brand\":\"Onset\",\"model\":\"Hobo Water Level Sensor\",\"model_id\":\"HOBOMX2001\",\"type\":\"UNIQ\",\"lvl_cm\":8.46760273,\"lvl_in\":3.333701862}",
"{\"brand\":\"Onset\",\"model\":\"Hobo Water Level Sensor\",\"model_id\":\"HOBOMX2001\",\"type\":\"UNIQ\",\"lvl_cm\":9.514185786,\"lvl_in\":3.745742436}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"tempc\":25.5,\"tempf\":77.9,\"hum\":50,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Test\",\"model\":\"Test (Pro)\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"BODY\",\"track\":true,\"prmac\":true,\"test\":\"Test Pods\"}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -604,7 +604,6 @@ const char* test_mfgdata[][3] = {
{"Apple", "Continuity", "4c0009060304c0a87b1e130c1adefc915b9ef8010401030c"},
{"Apple", "Continuity", "4c00130100"},
{"Apple", "Continuity", "4c001219003d9967e0d67bf55617939043e48fd6762144da3e35160300"},
{"Apple", "Continuity", "4c000719010e2022f58f00000a7d9fff27234873d4305e0fed1b39e2b8"},
{"Apple", "Continuity", "4c000c0e00a7582cd64fff2fe83046c99f5b10065a19e96670d8"},
{"Tracker iTAG", "iTAG", "8afc23eb"},
{"Tile name", "Tile", "xxxx"},
Expand Down Expand Up @@ -666,6 +665,7 @@ const char* test_mfgdata[][3] = {
{"Hobo Water Level", "", "c500073fd54f0106240000000800529501a0a06aad3d"},
{"Hobo Water Level", "", "c500073fd54f010624000000080092a901a0bcd9c23d"},
{"SwitchBot Outdoor Meter Manufacturerdata", "WoIOSensorTH", "6909aabbccddeeff8b0305993200"},
{"Apple", "AirPods", "4c000719010e2022f58f00000a7d9fff27234873d4305e0fed1b39e2b8"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -756,7 +756,6 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::APPLE_CONT,
TheengsDecoder::BLE_ID_NUM::APPLE_CONTAT,
TheengsDecoder::BLE_ID_NUM::APPLE_CONTAT,
TheengsDecoder::BLE_ID_NUM::APPLE_CONTAT,
TheengsDecoder::BLE_ID_NUM::ITAG,
TheengsDecoder::BLE_ID_NUM::TILEN,
TheengsDecoder::BLE_ID_NUM::H5106,
Expand Down Expand Up @@ -817,6 +816,7 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::HOBOMX2001,
TheengsDecoder::BLE_ID_NUM::HOBOMX2001,
TheengsDecoder::BLE_ID_NUM::SBOT_M,
TheengsDecoder::BLE_ID_NUM::APPLEAIRPODS,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down

0 comments on commit bea4230

Please sign in to comment.