Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BM6 Battery Monitor decoder #443

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/devices/BM2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
|Short Description|Battery capacity|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|12V|
|Power Source|8V-16V or 6V-20V (depending on model)|
|Exchanged Data|battery|
|Encrypted|No|
|Presence Tracker|✅|
Expand Down
13 changes: 13 additions & 0 deletions docs/devices/BM6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# BM6 Battery Monitor

|Model Id|[BM6](https://github.com/theengs/decoder/blob/development/src/devices/BM6_json.h)|
|-|-|
|Brand|GENERIC|
|Model|BM6 Battery Monitor|
|Short Description|Battery capacity|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|6V-20V|
|Exchanged Data|battery|
|Encrypted|No|
|Presence Tracker|✅|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class TheengsDecoder {
BPARASITE,
BWBSDOO,
BM2,
BM6,
RDL52832,
ABN03,
ABN07,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#include "devices/BPARASITE_json.h"
#include "devices/BWBSDOO_json.h"
#include "devices/BM2_json.h"
#include "devices/BM6_json.h"
#include "devices/JHT_F525_json.h"
#include "devices/iBeacon_json.h"
#include "devices/APPLE_json.h"
Expand Down Expand Up @@ -170,6 +171,7 @@ const char* _devices[][2] = {
{_BPARASITE_json, _BPARASITE_json_props},
{_BWBSDOO_json, _BWBSDOO_json_props},
{_BM2_json, _BM2_json_props},
{_BM6_json, _BM6_json_props},
{_RDL52832_json, _RDL52832_json_props},
{_ABN03_json, _ABN03_json_props},
{_ABN07_json, _ABN07_json_props},
Expand Down
32 changes: 32 additions & 0 deletions src/devices/BM6_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const char* _BM6_json = "{\"brand\":\"GENERIC\",\"model\":\"BM6 Battery Monitor\",\"model_id\":\"BM6\",\"tag\":\"0808\",\"condition\":[\"manufacturerdata\",\"=\",50,\"index\",0,\"4c0002153ba29cd9a42c894856badaf2606ef777\"],\"properties\":{\"batt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",42,2,false]},\"device\":{\"decoder\":[\"static_value\",\"BM6 Tracker\"]}}}";
/*R""""(
{
"brand":"GENERIC",
"model":"BM6 Battery Monitor",
"model_id":"BM6",
"tag":"0808",
"condition":["manufacturerdata", "=", 50, "index", 0, "4c0002153ba29cd9a42c894856badaf2606ef777"],
"properties":{
"batt":{
"decoder":["value_from_hex_data", "manufacturerdata", 42, 2, false]
},
"device":{
"decoder":["static_value", "BM6 Tracker"]
}
}
})"""";*/

const char* _BM6_json_props = "{\"properties\":{\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"device\":{\"unit\":\"string\",\"name\":\"tracker device\"}}}";
/*R""""(
{
"properties":{
"batt":{
"unit":"%",
"name":"battery"
},
"device":{
"unit":"string",
"name":"tracker device"
}
}
})"""";*/
6 changes: 6 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ 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\":\"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\"}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -488,6 +490,8 @@ const char* test_mfgdata[][3] = {
{"Braun", "Oral-B", "dc000471050332010e08032e04"},
{"Braun", "Oral-B", "dc000202060220000001010004"},
{"Braun", "Oral-B", "dc000202067320020f07080004"},
{"BM6", "Battery Monitor", "4c0002153ba29cd9a42c894856badaf2606ef777114d0000cd"},
{"BM6", "Battery Monitor", "4c0002153ba29cd9a42c894856badaf2606ef777114e0000cd"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -601,6 +605,8 @@ 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::BM6,
TheengsDecoder::BLE_ID_NUM::BM6,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down