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

Fix PVVX decoder and add unit test #65

Merged
merged 1 commit into from
Feb 2, 2022
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
5 changes: 3 additions & 2 deletions src/devices/LYWSD03MMC_PVVX_json.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "common_props.h"

const char* _LYWSD03MMC_PVVX_json = "{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_PVVX\",\"condition\":[\"servicedata\",30,\"index\",6,\"38c1a4\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,4,true],\"post_proc\":[\"/\",100]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",16,4,true],\"post_proc\":[\"/\",100]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,2,false]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",1000]}}}";
const char* _LYWSD03MMC_PVVX_json = "{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_PVVX\",\"condition\":[\"servicedata\",\"=\",30,\"index\",6,\"38c1a4\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,4,true],\"post_proc\":[\"/\",100]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",16,4,true],\"post_proc\":[\"/\",100]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,2,false]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",1000]}}}";

/* R""""(
{
"brand":"Xiaomi",
"model":"LYWSD03MMC",
"model_id":"LYWSD03MMC_PVVX",
"condition":["servicedata", 30, "index",6 , "38c1a4"],
"condition":["servicedata", "=", 30, "index",6 , "38c1a4"],
"properties":{
"tempc":{
"decoder":["value_from_hex_data", "servicedata", 12, 4, true],
Expand Down
3 changes: 3 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const char* expected_servicedata[] = {
"{\"brand\":\"Xiaomi\",\"model\":\"Formaldehyde detector\",\"model_id\":\"JQJCY01YM\",\"hum\":59.5}",
"{\"brand\":\"Xiaomi\",\"model\":\"Formaldehyde detector\",\"model_id\":\"JQJCY01YM\",\"for\":0.08}",
"{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_ATC\",\"tempc\":32.5,\"tempf\":90.5,\"hum\":62,\"batt\":81,\"volt\":2.939}",
"{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_PVVX\",\"tempc\":21.12,\"tempf\":70.016,\"hum\":50.53,\"batt\":100,\"volt\":3.143}",
"{\"brand\":\"Qingping\",\"model\":\"Motion & Light\",\"model_id\":\"CGPR1\",\"lux\":0}",
};

Expand Down Expand Up @@ -104,6 +105,7 @@ const char* test_servicedata[][2] = {
{"Formaldehyde detector", "5020df02283a5c014357480610025302"},
{"Formaldehyde detector", "5020df025b3a5c014357481010020800"},
{"LYWSD03MMC_ATC", "a4c138d5d49801453e510b7b62"},
{"LYWSD03MMC_PVVX", "5601cf38c1a44008bd13470c64cc0f"},
{"Qingping Motion & Light", "0812443660342d580201530f0118090400000000"},
};

Expand Down Expand Up @@ -138,6 +140,7 @@ TheengsDecoder::BLE_ID_NUM test_svcdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::JQJCY01YM,
TheengsDecoder::BLE_ID_NUM::JQJCY01YM,
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_ATC,
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX,
TheengsDecoder::BLE_ID_NUM::CGPR1,
};

Expand Down