Skip to content

Commit

Permalink
Watch test
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Nov 2, 2023
1 parent e5ef1df commit 342bd31
Show file tree
Hide file tree
Showing 4 changed files with 46 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 @@ -130,6 +130,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 @@ -91,6 +91,7 @@
#include "devices/BWBSDOO_json.h"
#include "devices/BM2_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 @@ -187,6 +188,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
34 changes: 34 additions & 0 deletions src/devices/APPLEWATCH_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const char* _APPLEWATCH_json = "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"tag\":\"0b\",\"condition\":[\"manufacturerdata\",\"=\",18,\"index\",0,\"4c001005\"],\"properties\":{\"state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,2],\"lookup\":[\"98\",\"unlocked\",\"18\",\"locked\"]},\"device\":{\"decoder\":[\"static_value\",\"Apple Watch\"]}}}";
/*R""""(
{
"brand":"Apple",
"model":"Apple Watch",
"model_id":"APPLEWATCH",
"tag":"0b",
"condition":["manufacturerdata", "=", 18, "index", 0, "4c001005"],
"properties":{
"state":{
"decoder":["string_from_hex_data", "manufacturerdata", 10, 2],
"lookup":["98", "unlocked",
"18", "locked"]
},
"device":{
"decoder":["static_value", "Apple Watch"]
}
}
})"""";*/

const char* _APPLEWATCH_json_props = "{\"properties\":{\"state\":{\"unit\":\"string\",\"name\":\"state\"},\"device\":{\"unit\":\"string\",\"name\":\"device\"}}}";
/*R""""(
{
"properties":{
"state":{
"unit":"string",
"name":"state"
},
"device":{
"unit":"string",
"name":"device"
}
}
})"""";*/
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ const char* expected_mfg[] = {
"{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"ORALB_BT\",\"type\":\"BODY\",\"state\":\"running\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":74}",
"{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"ORALB_BT\",\"type\":\"BODY\",\"state\":\"idle\",\"mode\":\"daily clean\",\"sector\":\"sector 1\",\"pressure\":32,\"time\":0}",
"{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"ORALB_BT\",\"type\":\"BODY\",\"state\":\"sleeping\",\"mode\":\"turbo\",\"sector\":\"sector 8\",\"pressure\":32,\"time\":135}",
"{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"state\":\"locked\",\"device\":\"Apple Watch\"}",
"{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"state\":\"unlocked\",\"device\":\"Apple Watch\"}",
"{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"device\":\"Apple Watch\"}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -488,6 +491,9 @@ const char* test_mfgdata[][3] = {
{"Braun", "Oral-B", "dc000471050332010e08032e04"},
{"Braun", "Oral-B", "dc000202060220000001010004"},
{"Braun", "Oral-B", "dc000202067320020f07080004"},
{"Apple", "Watch", "4c0010050b182068dd"},
{"Apple", "Watch", "4c0010050b982068dd"},
{"Apple", "Watch", "4c00100501145085dd"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -601,6 +607,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::ORALB_BT,
TheengsDecoder::BLE_ID_NUM::ORALB_BT,
TheengsDecoder::BLE_ID_NUM::ORALB_BT,
TheengsDecoder::BLE_ID_NUM::APPLEWATCH,
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 342bd31

Please sign in to comment.