* Update calculations for OneByone scales
Previously, the value reported for muscle mass was lean body mass
less skeletal mass. This was not a correct report for muscle mass
since it included additional values, such as organs and skin mass.
In addition, the impedance value previously used was incorrect.
There were, in fact, two different calculations being performed
for impedance based on data fields that were not relevant to it,
therefore the value for impedance was entirely incorrect, jumpy,
and unpredictable. In fact, the correct bytes for impedance are
the second and third bytes in the data packet received from the
scale, which produces correct and reasonable impedance values.
This commit corrects the prior errors, provides a calculation for
lean body mass, and calculates muscle mass based on the Janssen
formula;
https://journals.physiology.org/doi/pdf/10.1152/jappl.2000.89.2.465
* Muscle mass should be percent of total body weight, not absolute kg
* added code to register a new user and use a consent code for an existing scale
* BlueToothStandardWeightProfile: move access to SharedPreferences to wrapper functions;
* BlueToothStandardWeightProfile: rename CHARACTERISTIC_USER_BIRTHDAY to
CHARACTERISTIC_USER_DATE_OF_BIRTH to match Bluetooth documentation;
* Drop unused import: java.util.GregorianCalendar;
* BluetoothStandardWeightProfile: create new user if missing either consent
code or scale user index;
* BluetoothStandardWeightProfile: update user's initialWeight only for user
that is being currently created;
* BluetoothStandardWeightProfile: store user data after InitialWeight update;
* BluetoothStandardWeightProfile: fix user ID detection for weight and body composition measurements;
* BluetoothStandardWeightProfile: remove unused class variables;
* BluetoothStandardWeightProfile: simplify scale user selection code;
* BluetoothStandardWeightProfile: add wrapper to set user activity level when creating new scale user;
* BluetoothStandardWeightProfile: add wrapper to request scale measurement;
* BluetoothBeurerBF105: use base class methods to access SharedPreferences;
* BluetoothStandardWeightProfile: use scale user index to set user id in measurement database;
* BluetoothStandardWeightProfile: separate measurement parsing and storing;
* basic Beurer BF600 support;
Based on BluetoothBeurerBF105 by jensMF <jens.freudenthal@zoho.com>;
* BluetoothStandardWeightProfile: Update state machine: use enum with meaningful names instead of hard-coded integers;
* BluetoothBeurerBF600: fix new scale user creation.
Birthday in BF600 consists only from date, no time fields.
* BluetoothStandardWeightProfile: Add wrappers and SM states to request vendor-specific scale user-list;
* BluetoothBeurerBF600: read vendor specific user list, based on BluetoothBeurerBF105 by jensMF <jens.freudenthal@zoho.com>;
* BluetoothStandardWeightProfile: fix unbinding of userScaleIndex from app userId;
* Implement dialog to select existing scale user and enter scale user pin/consent code.
* BluetoothStandardWeightProfile: show warning if scale battery level below 10%;
* BluetoothStandardWeightProfile: When creating new scale user: request user to step on scale barefoot;
* Reconnect Bluetooth scale after user enters consent code or selects scale user;
* BluetoothFactory: threat Beurer BF850 and BF950 the same as BF600;
* BluetoothStandardWeightProfile: fix max stepNr warning message;
* BluetoothStandardWeightProfile: Refactor onBluetoothNotify(): move handling of User Control Point to separate function;
* BluetoothStandardWeightProfile: make debug messages about User Control Point more explicit;
* BluetoothStandardWeightProfile: make debug messages about unhandled notifications more explicit;
* BluetoothStandardWeightProfile: make decoding of weight and body composition measurements more verbose;
* BluetoothStandardWeightProfile: merge previous and new measurement if new measurement lacks user id (and timestamp);
Bluetooth scales usually implement both "Weight Scale Feature" and
"Body Composition Feature". It seems that scale first transmits weight
measurement (with user index and timestamp) and later transmits body
composition measurement (without user index and timestamp).
If previous measurement contains user index and new measurements does not
then merge them and store as one.
NOTE: On scales that implement only Weight Scale feature (or only Body
Composition feature) this commit will cause last measurement transmitted
to be delayed until disconnect.
* BluetoothStandardWeightProfile: Calculate lean body mass and bone mass;
Thanks to Adam Serbinski <adam@serbinski.com> for providing formulas!
* BluetoothStandardWeightProfile: remove redundant constant;
* BluetoothBeurerBF600: cosmetic: fix newline;
* BluetoothGattUuidBF600: show scale user initials (if set) instead of sale user index;
* BluetoothSwpSBF77 experimental support for SBF77 based on BF600 and BF105;
* BluetoothCommunication: Stop state machine only if setNotification operation was enqueued;
* BluetoothStandardWeightProfile: avoid hang if battery service is not implemented by connected device;
* BluetoothFactory: treat BF950 like SBF77;
* BluetoothSwpSBF77: show scale user initials (if set) instead of sale user index;
* BluetoothStandardWeightProfile: reuse common method to decode vendor specific scale user data;
* BluetoothBeurerBF600 and BluetoothSwpSBF77: show debug message if setNotifyVendorSpecificUserList() passed or failed;
* BluetoothSwpSBF77: Add UUID to send user initials to BF960;
* BluetoothSwpSBF77: send user activity level to scale (Beurer BF950 and SBF77);
* BluetoothSwpSBF77: Implement request to perform measurement (Beurer BF950 and SBF77);
* BluetoothSwpSBF77: cosmetic: fix white-space;
* update Blesses library version to 2.0.11
* usage of default scale user constructor
* move custom scale characteristics into their scale classes
* usage of string resources instead of hard coded strings
* BluetoothStandardWeightProfile: Fix writeBirthday() method according to Bluetooth GAAT_Specification_Supplement_v4 chapter 3.59.2;
Remove writeBirthday() overrides in classes that extends BluetoothStandardWeightProfile;
* BluetoothBeurerBF105: reuse state-machine and helper functions from BluetoothStandardWeightProfile;
* BluetoothBeurerBF105: use 0 instead of 1 when requesting user list;
Vendor application also seems to be using 0 (according to btsnoop_hci.log from BF105);
* BluetoothStandardWeightProfile: move user initials helper functions to base class;
* BluetoothCommunication: fix needReConnect() function;
Was broken by: update Blesses library to version to 2.0.11 (95e1d1298b);
* BluetoothBeurerBF105: move call to writeInitials() to base class;
* BluetoothBeurerBF600: write user initials if specific characteristic exists on scale;
Works on Beurer BF850. On Beurer BF600 there is no user initials;
* BluetoothSwpSBF77: write user initials if specific characteristic exists on scale;
Should work on Silvercrest SBF77 and Beurer BF950;
* BluetoothStandardWeightProfile: use resource strings instead of hard coded strings
* BluetoothStandardWeightProfile and BluetoothCommunication: catch IllegalArgumentException in setNotificationOn();
It seems that blessed library 2.0.11 (95e1d1298b)
returns non-null object from getCharacteristic() even if characteristic is not
available and then trows exception later;
* BluetoothStandardWeightProfile: fix crash when user name starts with space character;
* BluetoothStandardWeightProfile: fix crash when user name contains two words with two or more spaces between them;
* BluetoothSwpSBF77: prepare to merge BluetoothSwpSBF77 and BluetoothBeurerBF105;
Change function order in file to reduce diff;
* BluetoothSwpSBF77: cosmetic code formatting change;
* BluetoothStandardWeightProfile: stop state-machine after requesting scale user list;
Co-authored-by: jensMF <jens.freudenthal@zoho.com>
* BluetoothStandardWeightProfile: remove doubled call;
Co-authored-by: jensMF <jens.freudenthal@zoho.com>
* BluetoothStandardWeightProfile: make this class abstract and make stub functions abstract also;
* BluetoothStandardWeightProfile: convert VENDOR_SPECIFIC_MAX_USERS into abstract function;
* Refactor: Rename BluetoothSwpSBF77 to BluetoothBeurerBF950;
* BluetoothBeurerBF950: use BluetoothBeurerBF105 as base class; Affects BF950 and SBF77;
* BluetoothFactory: remove commented code about BluetoothStandardWeightProfile;
All mentioned scales have proper classes implemented;
* BluetoothStandardWeightProfile: fix bug: app requests to select scale user on each connection if scale have maximum number of users;
* update libraries to newest version and added some comments
Co-authored-by: jensMF <jens.freudenthal@zoho.com>
Co-authored-by: oliexdev <olie.xdev@googlemail.com>
The original values were obtained from a commercial scale user
manual, which was not consistent with ranges found from reputable
academic or health sources. This updates the range limits.
Values from paper "Skeletal muscle mass and distribution in 468
men and women aged 18-88 yr" by Ian Janssen et al;
https://journals.physiology.org/doi/pdf/10.1152/jappl.2000.89.1.81