From 8f221666122f82e6dbc8f45c6463dc35ef7cbf2d Mon Sep 17 00:00:00 2001 From: DigiH Date: Thu, 2 Nov 2023 17:54:14 +0100 Subject: [PATCH] Watch test --- src/decoder.h | 1 + src/devices.h | 2 ++ src/devices/APPLEWATCH_json.h | 27 +++++++++++++++++++++++++++ tests/BLE/test_ble.cpp | 6 ++++++ 4 files changed, 36 insertions(+) create mode 100644 src/devices/APPLEWATCH_json.h diff --git a/src/decoder.h b/src/decoder.h index 2cc4fc8b2..b37787d26 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -131,6 +131,7 @@ class TheengsDecoder { TILE, TILEN, JHT_F525, + APPLEWATCH, IBEACON, APPLE_CONT, APPLE_CONTAT, diff --git a/src/devices.h b/src/devices.h index d09f3b966..1edd5e469 100644 --- a/src/devices.h +++ b/src/devices.h @@ -92,6 +92,7 @@ #include "devices/BM2_json.h" #include "devices/BM6_json.h" #include "devices/JHT_F525_json.h" +#include "devices/APPLEWATCH_json.h" #include "devices/iBeacon_json.h" #include "devices/APPLE_json.h" #include "devices/ServiceData_json.h" @@ -189,6 +190,7 @@ const char* _devices[][2] = { {_tracker_json_tile, _tracker_json_props}, {_tracker_json_tilename, _tracker_json_props}, {_JHT_F525_json, _JHT_F525_json_props}, + {_APPLEWATCH_json, _APPLEWATCH_json_props}, {_ibeacon_json, _ibeacon_json_props}, {_APPLE_json, _APPLE_json_props}, {_APPLE_json_at, _APPLE_json_props}, diff --git a/src/devices/APPLEWATCH_json.h b/src/devices/APPLEWATCH_json.h new file mode 100644 index 000000000..bf9263fb4 --- /dev/null +++ b/src/devices/APPLEWATCH_json.h @@ -0,0 +1,27 @@ +const char* _APPLEWATCH_json = "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"tag\":\"0b08\",\"condition\":[\"manufacturerdata\",\"index\",10,\"98\",\"|\",\"manufacturerdata\",\"index\",10,\"18\",\"&\",\"manufacturerdata\",\"=\",18,\"index\",0,\"4c001005\"],\"properties\":{\"state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,2],\"lookup\":[\"98\",\"unlocked\",\"18\",\"locked\"]}}}"; +/*R""""( +{ + "brand":"Apple", + "model":"Apple Watch", + "model_id":"APPLEWATCH", + "tag":"0b08", + "condition":["manufacturerdata", "index", 10, "98", "|", "manufacturerdata", "index", 10, "18", "&", "manufacturerdata", "=", 18, "index", 0, "4c001005"], + "properties":{ + "state":{ + "decoder":["string_from_hex_data", "manufacturerdata", 10, 2], + "lookup":["98", "unlocked", + "18", "locked"] + } + } +})"""";*/ + +const char* _APPLEWATCH_json_props = "{\"properties\":{\"state\":{\"unit\":\"string\",\"name\":\"state\"}}}"; +/*R""""( +{ + "properties":{ + "state":{ + "unit":"string", + "name":"state" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 2f1bc0b40..f1fee6a62 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -133,6 +133,8 @@ const char* expected_mfg[] = { "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"ORALB_BT\",\"type\":\"BODY\",\"state\":\"sleeping\",\"mode\":\"turbo\",\"sector\":\"sector 8\",\"pressure\":32,\"time\":135}", "{\"brand\":\"GENERIC\",\"model\":\"BM6 Battery Monitor\",\"model_id\":\"BM6\",\"type\":\"BATT\",\"track\":true,\"batt\":77,\"device\":\"BM6 Tracker\"}", "{\"brand\":\"GENERIC\",\"model\":\"BM6 Battery Monitor\",\"model_id\":\"BM6\",\"type\":\"BATT\",\"track\":true,\"batt\":78,\"device\":\"BM6 Tracker\"}", + "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"state\":\"locked\"}", + "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"state\":\"unlocked\"}", }; const char* expected_name_uuid_mfgsvcdata[] = { @@ -492,6 +494,8 @@ const char* test_mfgdata[][3] = { {"Braun", "Oral-B", "dc000202067320020f07080004"}, {"BM6", "Battery Monitor", "4c0002153ba29cd9a42c894856badaf2606ef777114d0000cd"}, {"BM6", "Battery Monitor", "4c0002153ba29cd9a42c894856badaf2606ef777114e0000cd"}, + {"Apple", "Watch", "4c0010050b182068dd"}, + {"Apple", "Watch", "4c0010050b982068dd"}, }; TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ @@ -607,6 +611,8 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::ORALB_BT, TheengsDecoder::BLE_ID_NUM::BM6, TheengsDecoder::BLE_ID_NUM::BM6, + TheengsDecoder::BLE_ID_NUM::APPLEWATCH, + TheengsDecoder::BLE_ID_NUM::APPLEWATCH, }; // uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]