Add check on stabilisation fo weight and LBS handling (#868)
This commit is contained in:
1 parent
1b7f83c014
commit
452233258f
1 file changed
+14
-4
+14
-4
@@ -1247,10 +1247,20 @@ JsonObject& process_sensors(int offset, JsonObject& BLEdata) {
|
||||
JsonObject& process_scale_v1(JsonObject& BLEdata) {
|
||||
const char* servicedata = BLEdata["servicedata"].as<const char*>();
|
||||
|
||||
double weight = (double)value_from_hex_data(servicedata, 2, 4, true) / 200;
|
||||
|
||||
//Set Json value
|
||||
BLEdata.set("weight", (double)weight);
|
||||
if (servicedata[0] == '2') { // stabilized
|
||||
double weight = 0;
|
||||
if (servicedata[1] == '2') { //kg
|
||||
weight = (double)value_from_hex_data(servicedata, 2, 4, true) / 200;
|
||||
BLEdata.set("unit", "kg");
|
||||
} else if (servicedata[1] == '3') { //lbs
|
||||
weight = (double)value_from_hex_data(servicedata, 2, 4, true) / 100;
|
||||
BLEdata.set("unit", "lbs");
|
||||
} else { //unknown unit
|
||||
BLEdata.set("unit", "unknown");
|
||||
}
|
||||
//Set Json value
|
||||
BLEdata.set("weight", (double)weight);
|
||||
}
|
||||
|
||||
return BLEdata;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user