Skip to content

Commit

Permalink
Watch test
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Nov 6, 2023
1 parent 896ccf9 commit 8f22166
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class TheengsDecoder {
TILE,
TILEN,
JHT_F525,
APPLEWATCH,
IBEACON,
APPLE_CONT,
APPLE_CONTAT,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
27 changes: 27 additions & 0 deletions src/devices/APPLEWATCH_json.h
Original file line number Diff line number Diff line change
@@ -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"
}
}
})"""";*/
6 changes: 6 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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[]{
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 8f22166

Please sign in to comment.