Skip to content

Commit

Permalink
NodOn NIU smart button decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Feb 16, 2024
1 parent 6a80f97 commit 16eac0e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/devices/NodOnNIU.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# NodOn NIU smart button

|Model Id|[NODONNIU](https://github.com/theengs/decoder/blob/development/src/devices/NODONNIU_json.h)|
|-|-|
|Brand|NodOn|
|Model|NIU smart button|
|Short Description|Bluetooth smart button|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|CR2032|
|Exchanged Data|button, color, battery|
|Encrypted|No|
|Device Tracker|✅|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class TheengsDecoder {
H5179,
HHCCJCY10,
MUE4094RT,
NODONNIU,
MOKOBEACON,
MOKOBEACONXPRO,
INODEEM,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "devices/MBXPRO_json.h"
#include "devices/MS_CDP_json.h"
#include "devices/MUE4094RT_json.h"
#include "devices/NODONNIU_json.h"
#include "devices/Miband_json.h"
#include "devices/XMTZC04HMKG_json.h"
#include "devices/XMTZC04HMLB_json.h"
Expand Down Expand Up @@ -156,6 +157,7 @@ const char* _devices[][2] = {
{_H5179_json, _H5179_json_props},
{_HHCCJCY10_json, _HHCCJCY10_json_props},
{_MUE4094RT_json, _MUE4094RT_json_props},
{_NODONNIU_json, _NODONNIU_json_props},
{_Mokobeacon_json, _Mokobeacon_json_props},
{_MBXPRO_json, _MBXPRO_json_props},
{_iNodeEM_json, _iNodeEM_json_props},
Expand Down
59 changes: 59 additions & 0 deletions src/devices/NodOnNIU_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const char* _NODONNIU_json = "{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"tag\":\"110e\",\"condition\":[\"servicedata\",\"=\",32,\"&\",\"uuid\",\"index\",0,\"0000\"],\"properties\":{\"button\":{\"decoder\":[\"string_from_hex_data\",\"servicedata\",30,2],\"lookup\":[\"01\",\"short click\",\"02\",\"double click\",\"03\",\"long press\",\"04\",\"button release\",\"05\",\"triple click\",\"06\",\"quadruple click\",\"07\",\"quintuple click\"]},\"color\":{\"decoder\":[\"string_from_hex_data\",\"servicedata\",20,4],\"lookup\":[\"0002\",\"White\",\"0003\",\"TechBlue\",\"0004\",\"CozyGrey\",\"0005\",\"Wazabi\",\"0006\",\"Lagoon\",\"0007\",\"Softberry\"]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,2,false,false],\"post_proc\":[\"&\",127]}}}";

/*
R""""(
{
"brand":"NodOn",
"model":"NIU smart button",
"model_id":"NODONNIU",
"tag":"110e",
"condition":["servicedata", "=", 32, "&", "uuid", "index", 0, "0000"],
"properties":{
"button":{
"decoder":["string_from_hex_data", "servicedata", 30, 2],
"lookup":["01", "short click",
"02", "double click",
"03", "long press",
"04", "button release",
"05", "triple click",
"06", "quadruple click",
"07", "quintuple click"]
},
"color":{
"decoder":["string_from_hex_data", "servicedata", 20, 4],
"lookup":["0002", "White",
"0003", "TechBlue",
"0004", "CozyGrey",
"0005", "Wazabi",
"0006", "Lagoon",
"0007", "Softberry"]
},
"batt":{
"decoder":["value_from_hex_data", "servicedata", 24, 2, false, false],
"post_proc":["&", 127]
}
}
})"""";
*/

const char* _NODONNIU_json_props = "{\"properties\":{\"button\":{\"unit\":\"string\",\"name\":\"button\"},\"color\":{\"unit\":\"string\",\"name\":\"color\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"}}}";

/*
R""""(
{
"properties": {
"button":{
"unit":"string",
"name":"button"
},
"color":{
"unit":"string",
"name":"color"
},
"batt":{
"unit":"%",
"name":"battery"
}
}
})"""";
*/
15 changes: 15 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ const char* expected_uuid[] = {
"{\"brand\":\"Xiaomi\",\"model\":\"MiLamp\",\"model_id\":\"MUE4094RT\",\"type\":\"CTMO\",\"cont\":true,\"motion\":true,\"darkness\":2}",
"{\"brand\":\"Xiaomi\",\"model\":\"MiLamp\",\"model_id\":\"MUE4094RT\",\"type\":\"CTMO\",\"cont\":true,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Jaalee\",\"model\":\"TH sensor\",\"model_id\":\"F525/F51C\",\"type\":\"THB\",\"acts\":true,\"tempc\":24.39116503,\"tempf\":75.90409705,\"hum\":23.86816205,\"batt\":100}",
"{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"type\":\"BTN\",\"acts\":true,\"cont\":true,\"track\":true,\"button\":\"short click\",\"color\":\"Lagoon\",\"batt\":99}",
"{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"type\":\"BTN\",\"acts\":true,\"cont\":true,\"track\":true,\"button\":\"double click\",\"color\":\"Lagoon\",\"batt\":99}",
"{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"type\":\"BTN\",\"acts\":true,\"cont\":true,\"track\":true,\"button\":\"long press\",\"color\":\"Lagoon\",\"batt\":96}",
"{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"type\":\"BTN\",\"acts\":true,\"cont\":true,\"track\":true,\"button\":\"button release\",\"color\":\"Lagoon\",\"batt\":98}",
"{\"brand\":\"NodOn\",\"model\":\"NIU smart button\",\"model_id\":\"NODONNIU\",\"type\":\"BTN\",\"acts\":true,\"cont\":true,\"track\":true,\"button\":\"triple click\",\"color\":\"CozyGrey\",\"batt\":89}",
};

const char* expected_mac_mfg[] = {
Expand Down Expand Up @@ -942,6 +947,11 @@ const char* test_uuid[][4] = {
{"MiLamp", "0xfe95", "servicedata", "4030dd030203000101"},
{"MiLamp", "0xfe95", "servicedata", "3030dd0301ffeeddccbbaa0d"},
{"Jaalee", "0xf51c", "manufacturerdata", "4c000215ebefd08370a247c89837e7b5634df52565823d1acc64"},
{"NodOn NIU", "0x0000", "servicedata", "02599c37d90287a521520006635ab801"},
{"NodOn NIU", "0x0000", "servicedata", "02599c37d90287a52152000663ee4b02"},
{"NodOn NIU", "0x0000", "servicedata", "02599c37d90287a52152000660259003"},
{"NodOn NIU", "0x0000", "servicedata", "02599c37d90287a521520006622b8104"},
{"NodOn NIU", "0x0000", "servicedata", "02599c37d90287a521520004595eb905"},
};

TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
Expand Down Expand Up @@ -1071,6 +1081,11 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
TheengsDecoder::BLE_ID_NUM::MUE4094RT,
TheengsDecoder::BLE_ID_NUM::MUE4094RT,
TheengsDecoder::BLE_ID_NUM::JAALEE,
TheengsDecoder::BLE_ID_NUM::NODONNIU,
TheengsDecoder::BLE_ID_NUM::NODONNIU,
TheengsDecoder::BLE_ID_NUM::NODONNIU,
TheengsDecoder::BLE_ID_NUM::NODONNIU,
TheengsDecoder::BLE_ID_NUM::NODONNIU,
};

// MAC manufacturer data test input [test name] [mac] [data]
Expand Down

0 comments on commit 16eac0e

Please sign in to comment.