Skip to content

Commit

Permalink
Oral-B Bluetooth Toothbrush (#440)
Browse files Browse the repository at this point in the history
Initial submission of Oral-B Bluetooth Toothbrush decoder
  • Loading branch information
DigiH authored Oct 30, 2023
1 parent 36a7a1f commit 88279fe
Show file tree
Hide file tree
Showing 4 changed files with 111 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 @@ -118,6 +118,7 @@ class TheengsDecoder {
ABN07,
ABTEMP,
AMPHIRO,
OralB_BT,
PH10,
TPTH,
MOPEKA,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
78 changes: 78 additions & 0 deletions src/devices/OralB_json.h
Original file line number Diff line number Diff line change
@@ -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"
}
}
})"""";*/
30 changes: 30 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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[]{
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 88279fe

Please sign in to comment.