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

KKM K6P & K9 Beacons #347

Merged
merged 1 commit into from
Jun 4, 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
12 changes: 12 additions & 0 deletions docs/devices/KKM_K6P.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# KKM Long Range Beacon K6P

|Model Id|[K6P](https://github.com/theengs/decoder/blob/development/src/devices/KKM_K6P_json.h)|
|-|-|
|Brand|KKM|
|Model|Long Range K6P|
|Short Description|Long Range Sensor Beacon|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|ER14505|
|Exchanged data|temperature, humidity, voltage|
|Encrypted|No|
12 changes: 12 additions & 0 deletions docs/devices/KKM_K9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# KKM Tracking Beacon K9

|Model Id|[K9](https://github.com/theengs/decoder/blob/development/src/devices/KKM_K9_json.h)|
|-|-|
|Brand|KKM|
|Model|Tracking K9|
|Short Description|Pallet Tracking Beacon|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|ER14505|
|Exchanged data|temperature, humidity, voltage, acceleration x/y/z-axis (optional - without recognised as K6P)|
|Encrypted|No|
2 changes: 2 additions & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class TheengsDecoder {
XMTZC04HM,
XMTZC05HM,
TPMS,
KKM_K6P,
KKM_K9,
LYWSD03MMC_ATC,
LYWSD03MMC_PVVX,
CGPR1,
Expand Down
4 changes: 4 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#include "devices/Skale_json.h"
#include "devices/SmartDry_json.h"
#include "devices/TPMS_json.h"
#include "devices/KKM_K6P_json.h"
#include "devices/KKM_K9_json.h"
#include "devices/ThermoBeacon_json.h"
#include "devices/XMTZC04HM_json.h"
#include "devices/XMTZC05HM_json.h"
Expand Down Expand Up @@ -114,6 +116,8 @@ const char* _devices[][2] = {
{_XMTZC04HM_json, _XMTZC04HM_json_props},
{_XMTZC05HM_json, _XMTZC05HM_json_props},
{_TPMS_json, _TPMS_json_props},
{_KKM_K6P_json, _KKM_K6P_json_props},
{_KKM_K9_json, _KKM_K9_json_props},
{_LYWSD03MMC_json_ATC, _LYWSD03MMC_json_props},
{_LYWSD03MMC_json_PVVX, _LYWSD03MMC_json_props},
{_CGPR1_json, _CGPR1_json_props},
Expand Down
50 changes: 50 additions & 0 deletions src/devices/KKM_K6P_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const char* _KKM_K6P_json = "{\"brand\":\"KKM\",\"model\":\"Long Range K6P\",\"model_id\":\"K6P\",\"tag\":\"01\",\"condition\":[\"servicedata\",\"=\",18,\"index\",0,\"210107\",\"&\",\"uuid\",\"index\",0,\"feaa\"],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,flase],\"post_proc\":[\"/\",100]},\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",10,2,false,true],\"post_proc\":[\"+\",\".cal\"]},\"_.cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false],\"post_proc\":[\"/\",100]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"+\",\".cal\"]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,4,false,false],\"post_proc\":[\"/\",1000]}}}";
/*R""""(
{
"brand":"KKM",
"model":"Long Range K6P",
"model_id":"K6P",
"tag":"01",
"condition":["servicedata", "=", 18, "index", 0, "210107", "&", "uuid", "index", 0, "feaa"],
"properties":{
".cal":{
"decoder":["value_from_hex_data", "servicedata", 12, 2, false, flase],
"post_proc":["/", 100]
},
"tempc":{
"decoder":["value_from_hex_data", "servicedata", 10, 2, false, true],
"post_proc":["+", ".cal"]
},
"_.cal":{
"decoder":["value_from_hex_data", "servicedata", 12, 2, false, false],
"post_proc":["/", 100]
},
"hum":{
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["+", ".cal"]
},
"volt":{
"decoder":["value_from_hex_data", "servicedata", 6, 4, false, false],
"post_proc":["/", 1000]
}
}
})"""";*/

const char* _KKM_K6P_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"}}}";
/*R""""(
{
"properties":{
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"volt":{
"unit":"V",
"name":"voltage"
}
}
})"""";*/
74 changes: 74 additions & 0 deletions src/devices/KKM_K9_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const char* _KKM_K9_json = "{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"tag\":\"0708\",\"condition\":[\"servicedata\",\"=\",30,\"index\",0,\"21010f\",\"&\",\"uuid\",\"index\",0,\"feaa\"],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,flase],\"post_proc\":[\"/\",100]},\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",10,2,false,true],\"post_proc\":[\"+\",\".cal\"]},\"_.cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false],\"post_proc\":[\"/\",100]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,2,false,false],\"post_proc\":[\"+\",\".cal\"]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,4,false,false],\"post_proc\":[\"/\",1000]},\"accx\":{\"condition\":[\"servicedata\",0,\"21010f\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",18,4,false,true]},\"accy\":{\"condition\":[\"servicedata\",0,\"21010f\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,4,false,true]},\"accz\":{\"condition\":[\"servicedata\",0,\"21010f\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",26,4,false,true]}}}";
/*R""""(
{
"brand":"KKM",
"model":"Tracking K9",
"model_id":"K9",
"tag":"0708",
"condition":["servicedata", "=", 30, "index", 0, "21010f", "&", "uuid", "index", 0, "feaa"],
"properties":{
".cal":{
"decoder":["value_from_hex_data", "servicedata", 12, 2, false, flase],
"post_proc":["/", 100]
},
"tempc":{
"decoder":["value_from_hex_data", "servicedata", 10, 2, false, true],
"post_proc":["+", ".cal"]
},
"_.cal":{
"decoder":["value_from_hex_data", "servicedata", 12, 2, false, false],
"post_proc":["/", 100]
},
"hum":{
"decoder":["value_from_hex_data", "servicedata", 14, 2, false, false],
"post_proc":["+", ".cal"]
},
"volt":{
"decoder":["value_from_hex_data", "servicedata", 6, 4, false, false],
"post_proc":["/", 1000]
},
"accx":{
"condition":["servicedata", 0, "21010f"],
"decoder":["value_from_hex_data", "servicedata", 18, 4, false, true]
},
"accy":{
"condition":["servicedata", 0, "21010f"],
"decoder":["value_from_hex_data", "servicedata", 22, 4, false, true]
},
"accz":{
"condition":["servicedata", 0, "21010f"],
"decoder":["value_from_hex_data", "servicedata", 26, 4, false, true]
}
}
})"""";*/

const char* _KKM_K9_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"},\"accx\":{\"unit\":\"m/s²\",\"name\":\"acceleration x\"},\"accy\":{\"unit\":\"m/s²\",\"name\":\"acceleration y\"},\"accz\":{\"unit\":\"m/s²\",\"name\":\"acceleration z\"}}}";
/*R""""(
{
"properties":{
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"volt":{
"unit":"V",
"name":"voltage"
},
"accx":{
"unit":"m/s²",
"name":"acceleration x"
},
"accy":{
"unit":"m/s²",
"name":"acceleration y"
},
"accz":{
"unit":"m/s²",
"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 @@ -264,6 +264,9 @@ const char* expected_uuid[] = {
"{\"brand\":\"BlueCharm\",\"model\":\"Beacon 08/04P/021\",\"model_id\":\"KSensor\",\"type\":\"ACEL\",\"track\":true,\"tempc\":22.26086957,\"tempf\":72.06956522,\"accx\":31,\"accy\":31,\"accz\":-859,\"volt\":3.162}",
"{\"brand\":\"BlueCharm\",\"model\":\"Beacon 08/04P/021\",\"model_id\":\"KSensor\",\"type\":\"ACEL\",\"track\":true,\"tempc\":30.35573123,\"tempf\":86.64031621,\"accx\":34,\"accy\":-14,\"accz\":977,\"volt\":3.03}",
"{\"brand\":\"BlueCharm\",\"model\":\"Beacon 08/04P/021\",\"model_id\":\"KSensor\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-14.92490119,\"tempf\":5.135177866,\"accx\":109,\"accy\":-31,\"accz\":1046,\"volt\":3.194}",
"{\"brand\":\"KKM\",\"model\":\"Long Range K6P\",\"model_id\":\"K6P\",\"type\":\"THB\",\"tempc\":21.79,\"tempf\":71.222,\"hum\":33.79,\"volt\":3.675}",
"{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":25.11,\"tempf\":77.198,\"hum\":43.11,\"volt\":3.672,\"accx\":-31,\"accy\":0,\"accz\":1015}",
"{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":25,\"tempf\":77,\"hum\":43,\"volt\":3.672,\"accx\":-31,\"accy\":0,\"accz\":1015}",
};

const char* expected_mac_mfg[] = {
Expand Down Expand Up @@ -718,6 +721,9 @@ const char* test_uuid[][4] = {
{"BlueCharm BC04P", "0xfeaa", "servicedata", "21010b0c5a1600001f001ffca5"},
{"BlueCharm BC021", "0xfeaa", "servicedata", "21010b0bd61e000022fff203d1"},
{"BlueCharm BC021", "0xfeaa", "servicedata", "21010b0c7af140006dffe10416"},
{"KKM K6P", "0xfeaa", "servicedata", "2101070e5b154f2169"},
{"KKM K9", "0xfeaa", "servicedata", "21010f0e58186f2a29ffe1000003f7"},
{"KKM K9", "0xfeaa", "servicedata", "21010f0e5818642a0dffe1000003f7"},
};

TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
Expand Down Expand Up @@ -819,6 +825,9 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
TheengsDecoder::BLE_ID_NUM::BC08,
TheengsDecoder::BLE_ID_NUM::BC08,
TheengsDecoder::BLE_ID_NUM::BC08,
TheengsDecoder::BLE_ID_NUM::KKM_K6P,
TheengsDecoder::BLE_ID_NUM::KKM_K9,
TheengsDecoder::BLE_ID_NUM::KKM_K9,
};

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