Skip to content

Commit 4be656c

Browse files
DigiHmelyux
andauthored
SonsorPush HT.w and HTP.xw decoders (#619)
Co-authored-by: melyux <10296053+melyux@users.noreply.github.com>
1 parent e75e066 commit 4be656c

9 files changed

Lines changed: 127 additions & 10 deletions

File tree

docs/devices/BC08.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|-|-|
55
|Brand|BlueCharm/KKM|
66
|Model|Beacon 08/04P/021 - K8/K4/K21|
7-
|Short Description|Water-Resistant (not the BC021/K21) MultiBeacon (KBeacon and iBeacon protocols supported)|
7+
|Short Description|Water-resistant (not the BC021/K21) MultiBeacon (KBeacon and iBeacon protocols supported)|
88
|Communication|BLE broadcast|
99
|Frequency|2.4Ghz|
1010
|Power Source|CR2477|

docs/devices/SensorP_HT.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SensorPush HT.w Smart Sensor
2+
3+
|Model Id|[SPHT](https://github.com/theengs/decoder/blob/development/src/devices/SensorP_HT_json.h)|
4+
|-|-|
5+
|Brand|SensorPush|
6+
|Model|HT.w Smart Sensor|
7+
|Short Description|Water-resistant temperature and humidity sensor|
8+
|Communication|BLE broadcast|
9+
|Frequency|2.4Ghz|
10+
|Power Source|CR2477|
11+
|Exchanged Data|temperature, humidity|
12+
|Encrypted|No|
13+
|Device Tracker|&#9989;|

docs/devices/SensorP_HTP.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SensorPush HTP.xw Smart Sensor
2+
3+
|Model Id|[SPHTP](https://github.com/theengs/decoder/blob/development/src/devices/SensorP_HTP_json.h)|
4+
|-|-|
5+
|Brand|SensorPush|
6+
|Model|HTP.xw Smart Sensor|
7+
|Short Description|Water-resistant temperature, humidity and barometric pressure sensor|
8+
|Communication|BLE broadcast|
9+
|Frequency|2.4Ghz|
10+
|Power Source|CR2477|
11+
|Exchanged Data|temperature, humidity, pressure|
12+
|Encrypted|No|
13+
|Device Tracker|&#9989;|

src/decoder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -732,18 +732,18 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
732732
temp_val += post_proc[i + 1].as<double>();
733733
break;
734734
case '%': {
735-
long val = (long)temp_val;
736-
temp_val = val % post_proc[i + 1].as<long>();
735+
long long val = (long long)temp_val;
736+
temp_val = (double)(val % post_proc[i + 1].as<long long>());
737737
break;
738738
}
739739
case '<': {
740-
long val = (long)temp_val;
741-
temp_val = val << post_proc[i + 1].as<unsigned int>();
740+
long long val = (long long)temp_val;
741+
temp_val = (double)(val << post_proc[i + 1].as<unsigned int>());
742742
break;
743743
}
744744
case '>': {
745-
long val = (long)temp_val;
746-
temp_val = val >> post_proc[i + 1].as<unsigned int>();
745+
long long val = (long long)temp_val;
746+
temp_val = (double)(val >> post_proc[i + 1].as<unsigned int>());
747747
break;
748748
}
749749
case '!': {
@@ -753,12 +753,12 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
753753
}
754754
case '&': {
755755
long long val = (long long)temp_val;
756-
temp_val = val & post_proc[i + 1].as<unsigned int>();
756+
temp_val = (double)(val & post_proc[i + 1].as<unsigned int>());
757757
break;
758758
}
759759
case '^': {
760760
long long val = (long long)temp_val;
761-
temp_val = val ^ post_proc[i + 1].as<unsigned int>();
761+
temp_val = (double)(val ^ post_proc[i + 1].as<unsigned int>());
762762
break;
763763
}
764764
}
@@ -778,7 +778,7 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
778778
}
779779
} else if (strncmp(post_proc[i].as<const char*>(), "abs", 3) == 0) {
780780
long long val = (long long)temp_val;
781-
temp_val = abs(val);
781+
temp_val = (double)abs(val);
782782
} else if (strncmp(post_proc[i].as<const char*>(), "SBBT-dir", 8) == 0) { // "SBBT" decoder specific post_proc
783783
if (temp_val < 0) {
784784
proc_str = "down";

src/decoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ class TheengsDecoder {
160160
IBEACON,
161161
APPLE_CONT,
162162
APPLE_CONTAT,
163+
SPHTP,
164+
SPHT,
163165
SERVICE_DATA,
164166
UT363BT,
165167
SE_RHT,

src/devices.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
#include "devices/HOLYIOT_json.h"
111111
#include "devices/iBeacon_json.h"
112112
#include "devices/APPLE_json.h"
113+
#include "devices/SensorP_HTP_json.h"
114+
#include "devices/SensorP_HT_json.h"
113115
#include "devices/ServiceData_json.h"
114116
#include "devices/UT363BT_json.h"
115117
#include "devices/SE_RHT_json.h"
@@ -243,6 +245,8 @@ const char* _devices[][2] = {
243245
{_ibeacon_json, _ibeacon_json_props},
244246
{_APPLE_json, _APPLE_json_props},
245247
{_APPLE_json_at, _APPLE_json_props},
248+
{_SensorPush_HTP_json, _SensorPush_HTP_json_props},
249+
{_SensorPush_HT_json, _SensorPush_HT_json_props},
246250
{_ServiceData_json, _ServiceData_json_props},
247251
{_UT363BT_json, _UT363BT_json_props},
248252
{_SE_RHT_json, _SE_RHT_json_props},

src/devices/SensorP_HTP_json.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const char* _SensorPush_HTP_json = "{\"brand\":\"SensorPush\",\"model\":\"HTP.xw\",\"model_id\":\"SPHTP\",\"tag\":\"0209\",\"condition\":[\"manufacturerdata\",\"=\",14,\"index\",0,\"00\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",2,12,true,true],\"post_proc\":[\"%\",72001,\"*\",0.0025,\"+\",-40]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",2,12,true,false],\"post_proc\":[\"%\",2880112001,\"/\",72001,\"*\",0.0025]},\"pres\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",2,12,true,false],\"post_proc\":[\"%\",273613520207001,\"/\",2880112001,\"+\",30000.0,\"/\",100.0]}}}";
2+
/* R""""(
3+
{
4+
"brand": "SensorPush",
5+
"model": "HTP.xw",
6+
"model_id": "SPHTP",
7+
"tag": "0209",
8+
"condition": ["manufacturerdata", "=", 14, "index", 0, "00"],
9+
"properties": {
10+
"tempc": {
11+
"decoder": ["value_from_hex_data", "manufacturerdata", 2, 12, true, true],
12+
"post_proc": ["%", 72001, "*", 0.0025, "+", -40]
13+
},
14+
"hum": {
15+
"decoder": ["value_from_hex_data", "manufacturerdata", 2, 12, true, false],
16+
"post_proc": ["%", 2880112001, "/", 72001, "*", 0.0025]
17+
},
18+
"pres":{
19+
"decoder": ["value_from_hex_data", "manufacturerdata", 2, 12, true, false],
20+
"post_proc": ["%", 273613520207001, "/", 2880112001, "+", 30000.0, "/", 100.0]
21+
}
22+
}
23+
})"""";*/
24+
25+
const char* _SensorPush_HTP_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"pres\":{\"unit\":\"hPa\",\"name\":\"pressure\"}}}";
26+
/*R""""(
27+
{
28+
"properties": {
29+
"tempc": {
30+
"unit":"°C",
31+
"name":"temperature"
32+
},
33+
"hum": {
34+
"unit":"%",
35+
"name":"humidity"
36+
},
37+
"pres": {
38+
"unit":"hPa",
39+
"name":"pressure"
40+
}
41+
}
42+
})"""";*/

src/devices/SensorP_HT_json.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const char* _SensorPush_HT_json = "{\"brand\":\"SensorPush\",\"model\":\"HT.w\",\"model_id\":\"SPHT\",\"tag\":\"0109\",\"condition\":[\"manufacturerdata\",\"=\",10,\"index\",0,\"04\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",2,8,true,true],\"post_proc\":[\"%\",66001,\"*\",0.0025,\"+\",-40]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",2,8,true,false],\"post_proc\":[\"%\",2640106001,\"/\",66001,\"*\",0.0025]}}}";
2+
/* R""""(
3+
{
4+
"brand": "SensorPush",
5+
"model": "HT.w",
6+
"model_id": "SPHT",
7+
"tag": "0109",
8+
"condition": ["manufacturerdata", "=", 10, "index", 0, "04"],
9+
"properties": {
10+
"tempc": {
11+
"decoder": ["value_from_hex_data", "manufacturerdata", 2, 8, true, true],
12+
"post_proc": ["%", 66001, "*", 0.0025, "+", -40]
13+
},
14+
"hum": {
15+
"decoder": ["value_from_hex_data", "manufacturerdata", 2, 8, true, false],
16+
"post_proc": ["%", 2640106001, "/", 66001, "*", 0.0025]
17+
}
18+
}
19+
})"""";*/
20+
21+
const char* _SensorPush_HT_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"}}}";
22+
/*R""""(
23+
{
24+
"properties": {
25+
"tempc": {
26+
"unit":"°C",
27+
"name":"temperature"
28+
},
29+
"hum": {
30+
"unit":"%",
31+
"name":"humidity"
32+
}
33+
}
34+
})"""";*/

tests/BLE/test_ble.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ const char* expected_mfg[] = {
196196
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":6.58}",
197197
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":4.3}",
198198
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":1.52}",
199+
"{\"brand\":\"SensorPush\",\"model\":\"HTP.xw\",\"model_id\":\"SPHTP\",\"type\":\"THBX\",\"cidc\":false,\"track\":true,\"tempc\":22.6625,\"tempf\":72.7925,\"hum\":46.0683703,\"pres\":989.6546067}",
200+
"{\"brand\":\"SensorPush\",\"model\":\"HTP.xw\",\"model_id\":\"SPHTP\",\"type\":\"THBX\",\"cidc\":false,\"track\":true,\"tempc\":21.165,\"tempf\":70.097,\"hum\":39.0133495,\"pres\":999.6239012}",
201+
"{\"brand\":\"SensorPush\",\"model\":\"HT.w\",\"model_id\":\"SPHT\",\"type\":\"THB\",\"cidc\":false,\"track\":true,\"tempc\":27.69,\"tempf\":81.842,\"hum\":36.53352559}",
199202
};
200203

201204
const char* expected_name_uuid_mfgsvcdata[] = {
@@ -733,6 +736,9 @@ const char* test_mfgdata[][3] = {
733736
{"UNI-T", "UT363 BT", "aabb1005372020362e35384d2f533430800475"},
734737
{"UNI-T", "UT363 BT", "aabb1005372020342e33304d2f533430800476"},
735738
{"UNI-T", "UT363 BT", "aabb1005372020312e35324d2f533430800472"},
739+
{"SensorPush", "", "0089e456bea6b4"},
740+
{"SensorPush", "", "0011ef464343b7"},
741+
{"SensorPush", "", "04E9187D39"},
736742
};
737743

738744
TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
@@ -912,6 +918,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
912918
TheengsDecoder::BLE_ID_NUM::UT363BT,
913919
TheengsDecoder::BLE_ID_NUM::UT363BT,
914920
TheengsDecoder::BLE_ID_NUM::UT363BT,
921+
TheengsDecoder::BLE_ID_NUM::SPHTP,
922+
TheengsDecoder::BLE_ID_NUM::SPHTP,
923+
TheengsDecoder::BLE_ID_NUM::SPHT,
915924
};
916925

917926
// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]

0 commit comments

Comments
 (0)