ble-glucose
Advanced tools
Comparing version 0.2.1 to 0.2.2
38
index.js
@@ -90,3 +90,3 @@ /* | ||
const features = await glucoseFeature.readValue(); | ||
console.log('Glucose features:', features.getUint16().toString(2).padStart(8, '0')); | ||
console.log('Glucose features:', features.getUint16().toString(2).padStart(16, '0')); | ||
@@ -250,18 +250,17 @@ this.glucoseMeasurement = await this.glucoseService.getCharacteristic('glucose_measurement'); | ||
static getSFLOAT(value, units) { | ||
const SFLOAT = { | ||
POSITIVE_INFINITY: 0x07FE, | ||
NAN: 0x07FF, | ||
NRES: 0x0800, | ||
RESERVED_VALUE: 0x0801, | ||
NEGATIVE_INFINITY: 0x0802, | ||
}; | ||
switch (value) { | ||
case 0x07FF: | ||
return NaN; | ||
case 0x0800: | ||
return NaN; | ||
case 0x07FE: | ||
return Number.POSITIVE_INFINITY; | ||
case 0x0802: | ||
return Number.NEGATIVE_INFINITY; | ||
case 0x0801: | ||
return NaN; | ||
default: | ||
break; | ||
} | ||
const RESERVED_FLOAT_VALUES = [ | ||
Number.POSITIVE_INFINITY, | ||
NaN, | ||
NaN, | ||
NaN, | ||
Number.NEGATIVE_INFINITY, | ||
]; | ||
let exponent = value >> 12; | ||
@@ -282,8 +281,3 @@ let mantissa = value & 0x0FFF; | ||
if (mantissa >= SFLOAT.POSITIVE_INFINITY && | ||
mantissa <= SFLOAT.NEGATIVE_INFINITY) { | ||
return RESERVED_FLOAT_VALUES[mantissa - SFLOAT.POSITIVE_INFINITY]; | ||
} | ||
if (mantissa >= SFLOAT.NRES) { | ||
if (mantissa >= 0x0800) { | ||
mantissa = -((0x0FFF + 1) - mantissa); | ||
@@ -290,0 +284,0 @@ } |
{ | ||
"name": "ble-glucose", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Reads blood glucose values from Bluetooth LE enabled meters", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11542
261