From daf6f0d4f28a768632b5839fa0bbdc065a681174 Mon Sep 17 00:00:00 2001 From: DigiH Date: Fri, 16 Feb 2024 16:18:13 +0100 Subject: [PATCH] NodOn NIU smart button decoder --- docs/devices/NodOnNIU.md | 13 ++++++++ src/decoder.h | 1 + src/devices.h | 2 ++ src/devices/NodOnNIU_json.h | 59 +++++++++++++++++++++++++++++++++++++ tests/BLE/test_ble.cpp | 15 ++++++++++ 5 files changed, 90 insertions(+) create mode 100644 docs/devices/NodOnNIU.md create mode 100644 src/devices/NodOnNIU_json.h diff --git a/docs/devices/NodOnNIU.md b/docs/devices/NodOnNIU.md new file mode 100644 index 000000000..613869da4 --- /dev/null +++ b/docs/devices/NodOnNIU.md @@ -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|✅| diff --git a/src/decoder.h b/src/decoder.h index b65040947..1a9010fd0 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -89,6 +89,7 @@ class TheengsDecoder { H5179, HHCCJCY10, MUE4094RT, + NodOnNIU, MOKOBEACON, MOKOBEACONXPRO, INODEEM, diff --git a/src/devices.h b/src/devices.h index 8b28cb9d4..301f8de6d 100644 --- a/src/devices.h +++ b/src/devices.h @@ -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" @@ -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}, diff --git a/src/devices/NodOnNIU_json.h b/src/devices/NodOnNIU_json.h new file mode 100644 index 000000000..4793d9228 --- /dev/null +++ b/src/devices/NodOnNIU_json.h @@ -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" + } + } +})""""; +*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index b79a63d7a..5a4d44253 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -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[] = { @@ -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[]{ @@ -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]