File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -1247,10 +1247,20 @@ JsonObject& process_sensors(int offset, JsonObject& BLEdata) {
12471247JsonObject& process_scale_v1 (JsonObject& BLEdata) {
12481248 const char * servicedata = BLEdata[" servicedata" ].as <const char *>();
12491249
1250- double weight = (double )value_from_hex_data (servicedata, 2 , 4 , true ) / 200 ;
1251-
1252- // Set Json value
1253- BLEdata.set (" weight" , (double )weight);
1250+ if (servicedata[0 ] == ' 2' ) { // stabilized
1251+ double weight = 0 ;
1252+ if (servicedata[1 ] == ' 2' ) { // kg
1253+ weight = (double )value_from_hex_data (servicedata, 2 , 4 , true ) / 200 ;
1254+ BLEdata.set (" unit" , " kg" );
1255+ } else if (servicedata[1 ] == ' 3' ) { // lbs
1256+ weight = (double )value_from_hex_data (servicedata, 2 , 4 , true ) / 100 ;
1257+ BLEdata.set (" unit" , " lbs" );
1258+ } else { // unknown unit
1259+ BLEdata.set (" unit" , " unknown" );
1260+ }
1261+ // Set Json value
1262+ BLEdata.set (" weight" , (double )weight);
1263+ }
12541264
12551265 return BLEdata;
12561266}
You can’t perform that action at this time.
0 commit comments