diff --git a/src/decoder.h b/src/decoder.h index de7a6939..16a43651 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -118,6 +118,7 @@ class TheengsDecoder { ABN07, ABTEMP, AMPHIRO, + OralB_BT, PH10, TPTH, MOPEKA, diff --git a/src/devices.h b/src/devices.h index af1eefc4..a3435c86 100644 --- a/src/devices.h +++ b/src/devices.h @@ -75,6 +75,7 @@ #include "devices/ABN07_json.h" #include "devices/ABTemp_json.h" #include "devices/Amphiro_json.h" +#include "devices/OralB_json.h" #include "devices/PH10_json.h" #include "devices/TPTH_json.h" #include "devices/Mopeka_json.h" @@ -174,6 +175,7 @@ const char* _devices[][2] = { {_ABN07_json, _ABN07_json_props}, {_ABTemp_json, _ABTemp_json_props}, {_AMPHIRO_json, _AMPHIRO_json_props}, + {_OralB_json, _OralB_json_props}, {_PH10_json, _PH10_json_props}, {_TPTH_json, _TPTH_json_props}, {_Mopeka_json, _Mopeka_json_props}, diff --git a/src/devices/OralB_json.h b/src/devices/OralB_json.h new file mode 100644 index 00000000..3b659a21 --- /dev/null +++ b/src/devices/OralB_json.h @@ -0,0 +1,78 @@ +const char* _OralB_json = "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"tag\":\"0b\",\"condition\":[\"manufacturerdata\",\">=\",22,\"index\",0,\"dc00\"],\"properties\":{\"state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,2],\"lookup\":[\"01\",\"initialising\",\"02\",\"idle\",\"03\",\"running\",\"04\",\"charging\",\"73\",\"sleeping\"]},\"mode\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",18,2],\"lookup\":[\"00\",\"off\",\"01\",\"daily clean\",\"02\",\"sensitive\",\"03\",\"massage\",\"04\",\"whitening\",\"05\",\"deep clean\",\"06\",\"tongue cleaning\",\"07\",\"turbo\"]},\"sector\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",20,2],\"lookup\":[\"01\",\"sector 1\",\"02\",\"sector 2\",\"03\",\"sector 3\",\"04\",\"sector 4\",\"05\",\"sector 5\",\"06\",\"sector 6\",\"07\",\"sector 7\",\"08\",\"sector 8\"]},\"pressure\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",12,2,false,false]},\".cal\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",16,2,false,false]},\"time\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",14,2,false,false],\"post_proc\":[\"*\",60,\"+\",\".cal\"]}}}"; +/*R""""( +{ + "brand":"Oral-B", + "model":"BT Toothbrush", + "model_id":"OralB_BT", + "tag":"0b", + "condition":["manufacturerdata", ">=", 22, "index", 0, "dc00"], + "properties":{ + "state":{ + "decoder":["string_from_hex_data", "manufacturerdata", 10, 2], + "lookup":["01", "initialising", + "02", "idle", + "03", "running", + "04", "charging", + "73", "sleeping"] + }, + "mode":{ + "decoder":["string_from_hex_data", "manufacturerdata", 18, 2], + "lookup":["00", "off", + "01", "daily clean", + "02", "sensitive", + "03", "massage", + "04", "whitening", + "05", "deep clean", + "06", "tongue cleaning", + "07", "turbo"] + }, + "sector":{ + "decoder":["string_from_hex_data", "manufacturerdata", 20, 2], + "lookup":["01", "sector 1", + "02", "sector 2", + "03", "sector 3", + "04", "sector 4", + "05", "sector 5", + "06", "sector 6", + "07", "sector 7", + "08", "sector 8"] + }, + "pressure":{ + "decoder":["value_from_hex_data", "manufacturerdata", 12, 2, false, false] + }, + ".cal":{ + "decoder":["value_from_hex_data", "manufacturerdata", 16, 2, false, false] + }, + "time":{ + "decoder":["value_from_hex_data", "manufacturerdata", 14, 2, false, false], + "post_proc":["*", 60, "+", ".cal"] + } + } +})"""";*/ + +const char* _OralB_json_props = "{\"properties\":{\"state\":{\"unit\":\"string\",\"name\":\"state\"},\"mode\":{\"unit\":\"string\",\"name\":\"mode\"},\"sector\":{\"unit\":\"string\",\"name\":\"sector\"},\"pressure\":{\"unit\":\"int\",\"name\":\"pressure\"},\"time\":{\"unit\":\"int\",\"name\":\"time\"}}}"; +/*R""""( +{ + "properties":{ + "state":{ + "unit":"string", + "name":"state" + }, + "mode":{ + "unit":"string", + "name":"mode" + }, + "sector":{ + "unit":"string", + "name":"sector" + }, + "pressure":{ + "unit":"int", + "name":"pressure" + }, + "time":{ + "unit":"int", + "name":"time" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index d33a0cea..d884b3d9 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -121,6 +121,16 @@ const char* expected_mfg[] = { "{\"brand\":\"GENERIC\",\"model\":\"BM2 Battery Monitor\",\"model_id\":\"BM2\",\"type\":\"BATT\",\"track\":true,\"batt\":73,\"device\":\"BM2 Tracker\"}", "{\"brand\":\"Govee\",\"model\":\"Smart Thermo-Hygrometer\",\"model_id\":\"H5100/01/02/04/74/77\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":26,\"tempf\":78.8,\"hum\":51,\"batt\":100}", "{\"brand\":\"Govee\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"H5179\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":20.3,\"tempf\":68.54,\"hum\":57.2,\"batt\":65}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"idle\",\"mode\":\"off\",\"pressure\":54,\"time\":0}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"running\",\"mode\":\"daily clean\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":63}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"initialising\",\"mode\":\"sensitive\",\"sector\":\"sector 1\",\"pressure\":58,\"time\":0}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"charging\",\"mode\":\"massage\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":74}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"sleeping\",\"mode\":\"deep clean\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":74}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"running\",\"mode\":\"tongue cleaning\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":74}", + "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"OralB_BT\",\"type\":\"BODY\",\"state\":\"running\",\"mode\":\"turbo\",\"sector\":\"sector 3\",\"pressure\":50,\"time\":74}", + "{\"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}", }; const char* expected_name_uuid_mfgsvcdata[] = { @@ -468,6 +478,16 @@ const char* test_mfgdata[][3] = { {"BM2", "Li Battery Monitor", "4c000215655f83caae16a10a702e31f30d58dd82f441423149"}, {"H5104", "GVH5104_1234", "0100010103f99e64"}, {"H5179", "Govee_H5179_1234", "0188ec000101ee07581641"}, + {"Oral-B", "Oral-B", "dc0004710502360000000f0004"}, + {"Oral-B", "Oral-B", "dc000471050332010301030a04"}, + {"Oral-B", "Oral-B", "dc00047105013a000002010004"}, + {"Oral-B", "Oral-B", "dc000471050432010e03032e04"}, + {"Oral-B", "Oral-B", "dc000471057332010e05032e04"}, + {"Oral-B", "Oral-B", "dc000471050332010e06032e04"}, + {"Oral-B", "Oral-B", "dc000471050332010e07032e04"}, + {"Oral-B", "Oral-B", "dc000471050332010e08032e04"}, + {"Oral-B", "Oral-B", "dc000202060220000001010004"}, + {"Oral-B", "Oral-B", "dc000202067320020f07080004"}, }; TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ @@ -571,6 +591,16 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::BM2, TheengsDecoder::BLE_ID_NUM::H5102, TheengsDecoder::BLE_ID_NUM::H5179, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, + TheengsDecoder::BLE_ID_NUM::OralB_BT, }; // uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]