• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Unable to decode weight machine value when bluetooth weight scale in KG mode in flutter

Resolved: Unable to decode weight machine value when bluetooth weight scale in KG mode in flutter

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

My weight scale has two modes:
when the device is in-lb(pound mode) the decode output response is correct
DEVICE OUTPUT :[3, 52, 18, 224, 7, 2, 25, 3, 49, 28]
EXPECTED VALUE: 46.6lb
ACTUAL VALUE : 46.6lb
When DEVICE IS IN LB MODE the output is CORRECT using below code
double getWeight(List<int> data, index) {. return (( 0xff & data[index + 1] ) << 8 | ( 0xff & data[index] ) << 0 ) / 100; }
Refer below link for the above code details: Flutter ble read weight scale characteristic value
But When the device unit is KG MODE, the decode output response is wrong
DEVICE OUTPUT :[2, 168, 12, 224, 7, 2, 25, 3, 51, 7]
EXPECTED VALUE: 46.7 lb
MY DECODED VALUE:32.4 lb
Consume please guide to decode it proper way for this issue?

Answer:

If you look for “3.244 Weight Scale Measurement” in the following document: https://www.bluetooth.com/specifications/specs/gatt-specification-supplement-6/
It says about the weight field:

This field is in kilograms with resolution 0.005 if the bit 0 of the Flag field is 0 or in pounds with a resolution of 0.01 if the bit 0 of the Flag field is 1.


So if the flag suggests you are in KG then you function is:

double getKgWeight(List data, index) {
return (( 0xff & data[index + 1] ) << 8 | ( 0xff & data[index] ) << 0 ) * 0.005; } [/code]

For lbs:

double getlbsWeight(List data, index) {
return (( 0xff & data[index + 1] ) << 8 | ( 0xff & data[index] ) << 0 ) * 0.01; } [/code]

If you have better answer, please add a comment about this, thank you!

bluetooth bluetooth-lowenergy flutter
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: TYPO3 SQL error: Field ‘tx_imagezoom_set’ doesn’t have a default value

26/03/2023

Resolved: std::regex_replace to replace multiple combinations

26/03/2023

Resolved: How can I copy files using the ansible.builtin.copy module and avoid conflicting file names?

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.