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

Add RDL52832 decoder #138

Merged
merged 9 commits into from
Jul 10, 2022
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module.exports = {
'devices/CGDK2',
'devices/CGH1',
'devices/CGPR1',
'devices/RDL52832',
'devices/RuuviTag_RAWv1',
'devices/RuuviTag_RAWv2',
'devices/SBCU',
Expand Down
12 changes: 12 additions & 0 deletions docs/devices/RDL52832.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# RDL52832

|Model Id|[RDL52832](https://github.com/theengs/decoder/blob/development/src/devices/RDL52832_json.h)|
|-|-|
|Brand|Radioland|
|Model|RDL52832|
|Short Description|iBeacon with sensors|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|CR2032|
|Exchanged data|mfid, uuid, minor, major, txpower @ 1 m, temperature, humidity, acceleration|
|Encrypted|No|
3 changes: 2 additions & 1 deletion src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class TheengsDecoder {
HHCCPOT002,
BPARASITE,
BM2,
RDL52832,
IBEACON,
BLE_ID_MAX
};
Expand All @@ -105,7 +106,7 @@ class TheengsDecoder {
const char* dev_name, const char* svc_uuid);
std::string sanitizeJsonKey(const char* key_in);

size_t m_docMax = 7168;
size_t m_docMax = 12288;
size_t m_minSvcDataLen = 20;
size_t m_minMfgDataLen = 16;
};
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "devices/MUE4094RT_json.h"
#include "devices/Miband_json.h"
#include "devices/Mokobeacon_json.h"
#include "devices/RDL52832_json.h"
#include "devices/RuuviTag_RAWv1_json.h"
#include "devices/RuuviTag_RAWv2_json.h"
#include "devices/SBCU_json.h"
Expand Down Expand Up @@ -107,5 +108,6 @@ const char* _devices[][2] = {
{_HHCCPOT002_json, _HHCCPOT002_json_props},
{_BPARASITE_json, _BPARASITE_json_props},
{_BM2_json, _BM2_json_props},
{_RDL52832_json, _RDL52832_json_props},
{_ibeacon_json, _ibeacon_json_props},
};
153 changes: 153 additions & 0 deletions src/devices/RDL52832_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
const char* _RDL52832_json = "{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"condition\":[\"uuid\",\"index\",\"0\",\"0318\"],\"properties\":{\"mfid\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",0,4]},\"uuid\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",8,32]},\"major\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",40,4,false]},\"minor\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",44,4,false]},\"txpower\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",48,2,false]},\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",0,4,false,true],\"post_proc\":[\"/\", 256]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,4,false,true],\"post_proc\":[\"/\",256]},\".cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false],\"post_proc\":[\"/\",10]},\"accx\":{\"condition\":[\"servicedata\",8,\"0000\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\"]},\"_accx\":{\"condition\":[\"servicedata\",8,\"0001\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1]},\"__accx\":{\"condition\":[\"servicedata\",8,\"0100\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"*\",-1]},\"___accx\":{\"condition\":[\"servicedata\",8,\"0101\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1,\"*\",-1]},\"_.cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,2,false,false],\"post_proc\":[\"/\",10]},\"accy\":{\"condition\":[\"servicedata\",16,\"0000\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\"]},\"_accy\":{\"condition\":[\"servicedata\",16,\"0001\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1]},\"__accy\":{\"condition\":[\"servicedata\",16,\"0100\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"*\",-1]},\"___accy\":{\"condition\":[\"servicedata\",16,\"0101\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1,\"*\",-1]},\"__.cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,2,false,false],\"post_proc\":[\"/\",10]},\"accz\":{\"condition\":[\"servicedata\",24,\"0000\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\"]},\"_accz\":{\"condition\":[\"servicedata\",24,\"0001\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1]},\"__accz\":{\"condition\":[\"servicedata\",24,\"0100\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"*\",-1]},\"___accz\":{\"condition\":[\"servicedata\",24,\"0101\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,2,false,false],\"post_proc\":[\"/\",100,\"+\",\".cal\",\"+\",1,\"*\",-1]}}}";

/*R""""(
{
"brand":"Radioland",
"model":"RDL52832",
"model_id":"RDL52832",
"condition":["uuid", "index", 0, "0318"],
"properties":{
"mfid":{
"decoder":["string_from_hex_data", "manufacturerdata", 0, 4]
},
"uuid":{
"decoder":["string_from_hex_data", "manufacturerdata", 8, 32]
},
"major":{
"decoder":["value_from_hex_data", "manufacturerdata", 40, 4, false]
},
"minor":{
"decoder":["value_from_hex_data", "manufacturerdata", 44, 4, false]
},
"txpower":{
"decoder":["value_from_hex_data","manufacturerdata", 48, 2, false]
},
"tempc":{
"decoder":["value_from_hex_data", "servicedata", 0, 4, false, true],
"post_proc":["/", 256]
},
"hum":{
"decoder":["value_from_hex_data", "servicedata", 4, 4, false, true],
"post_proc":["/", 256]
},
".cal":{
"decoder":["value_from_hex_data", "servicedata", 12, 2, false, false],
"post_proc":["/", 10]
},
"accx":{
"condition":["servicedata", 8, "0000"],
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["/", 100, "+", ".cal"]
},
"_accx":{
"condition":["servicedata", 8, "0001"],
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1]
},
"__accx":{
"condition":["servicedata", 8, "0100"],
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "*", -1]
},
"___accx":{
"condition":["servicedata", 8, "0101"],
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1, "*", -1]
},
"_.cal":{
"decoder":["value_from_hex_data", "servicedata", 20, 2, false, false],
"post_proc":["/", 10]
},
"accy":{
"condition":["servicedata", 16, "0000"],
"decoder":["value_from_hex_data", "servicedata", 22, 2, false, false],
"post_proc":["/", 100, "+", ".cal"]
},
"_accy":{
"condition":["servicedata", 16, "0001"],
"decoder":["value_from_hex_data", "servicedata", 22, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1]
},
"__accy":{
"condition":["servicedata", 16, "0100"],
"decoder":["value_from_hex_data", "servicedata", 22, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "*", -1]
},
"___accy":{
"condition":["servicedata", 16, "0101"],
"decoder":["value_from_hex_data", "servicedata", 22, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1, "*", -1]
},
"__.cal":{
"decoder":["value_from_hex_data", "servicedata", 28, 2, false, false],
"post_proc":["/", 10]
},
"accz":{
"condition":["servicedata", 24, "0000"],
"decoder":["value_from_hex_data", "servicedata", 30, 2, false, false],
"post_proc":["/", 100, "+", ".cal"]
},
"_accz":{
"condition":["servicedata", 24, "0001"],
"decoder":["value_from_hex_data", "servicedata", 30, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1]
},
"__accz":{
"condition":["servicedata", 24, "0100"],
"decoder":["value_from_hex_data", "servicedata", 30, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "*", -1]
},
"___accz":{
"condition":["servicedata", 24, "0101"],
"decoder":["value_from_hex_data", "servicedata", 30, 2, false, false],
"post_proc":["/", 100, "+", ".cal", "+", 1, "*", -1]
}
}
})"""";*/

const char* _RDL52832_json_props = "{\"properties\":{\"mfid\":{\"unit\":\"hex\",\"name\":\"manufacturer id\"},\"uuid\":{\"unit\":\"hex\",\"name\":\"service uuid\"},\"major\":{\"unit\":\"hex\",\"name\":\"major value\"},\"minor\":{\"unit\":\"hex\",\"name\":\"minor value\"},\"txpower\":{\"unit\":\"dBm\",\"name\":\"tx power @ 1 m\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"accx\":{\"unit\":\"g\",\"name\":\"acceleration x\"},\"accy\":{\"unit\":\"g\",\"name\":\"acceleration y\"},\"accz\":{\"unit\":\"g\",\"name\":\"acceleration z\"}}}";
/*R""""(
{
"properties":{
"mfid":{
"unit":"hex",
"name":"manufacturer id"
},
"uuid":{
"unit":"hex",
"name":"service uuid"
},
"major":{
"unit":"hex",
"name":"major value"
},
"minor":{
"unit":"hex",
"name":"minor value"
},
"txpower":{
"unit":"dBm",
"name":"tx power @ 1 m"
},
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"accx":{
"unit":"g",
"name":"acceleration x"
},
"accy":{
"unit":"g",
"name":"acceleration y"
},
"accz":{
"unit":"g",
"name":"acceleration z"
}
}
})"""";*/
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ const char* expected_mfg[] = {

const char* expected_uuid_mfgsvcdata[] = {
"{\"brand\":\"Xiaomi\",\"model\":\"Miband\",\"model_id\":\"MiBand\",\"steps\":9101,\"act_bpm\":125}",
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":24.2265625,\"tempf\":75.6078125,\"hum\":47.19921875,\"accx\":-0.02,\"accy\":0.01,\"accz\":0.97}",
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":25.296875,\"tempf\":77.534375,\"hum\":58.22265625,\"accx\":0.14,\"accy\":0.09,\"accz\":-0.98}",
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":26.2734375,\"tempf\":79.2921875,\"hum\":61.203125,\"accx\":0.2,\"accy\":-0.96,\"accz\":0.15}",
};

const char* expected_uuid[] = {
Expand Down Expand Up @@ -309,10 +312,16 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
// uuid test input [test name] [uuid] [manufacturer data] [service data]
const char* test_uuid_mfgsvcdata[][4] = {
{"MiBand", "fee0", "57010202017dffffffffffffffffffffffffff02de7b8490725c2", "8d230000"},
{"RDL52832", "0318", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "183a2f33010000020000000100000907"},
{"RDL52832", "0318", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "194c3a39000001040000000901000908"},
{"RDL52832", "0318", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "1a463d34000002000100090600000105"},
};

TheengsDecoder::BLE_ID_NUM test_uuid_mfgsvcdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::MIBAND,
TheengsDecoder::BLE_ID_NUM::RDL52832,
TheengsDecoder::BLE_ID_NUM::RDL52832,
TheengsDecoder::BLE_ID_NUM::RDL52832,
};

// uuid test input [test name] [uuid] [data source] [data]
Expand Down