mirror of https://github.com/espruino/BangleApps
feat(sleepasandroid): add config file to save whether the integration is enabled.
parent
68ed8739b3
commit
ec3b20c5fc
|
@ -1,10 +1,16 @@
|
|||
# BLE GATT HRM Service
|
||||
# Sleep as Android Integration
|
||||
|
||||
Adds the GATT HRM Service to advertise the current HRM over Bluetooth.
|
||||
This app provides support for Sleep as Android using Gadgetbridge.
|
||||
|
||||
## Usage
|
||||
|
||||
This boot code runs in the background and has no user interface.
|
||||
For this to work you have to enable Sleep as Android support in Gadgetbridge and
|
||||
select your Banglejs device.
|
||||
|
||||
**Please Note**: This app does not activate the HRM sensor. It only listens to HRM events.
|
||||
You may want to adjust the HRM sampling rate in the Health APP. I recommend at least one sample
|
||||
every 10 minutes.
|
||||
|
||||
## Creator
|
||||
|
||||
|
@ -12,5 +18,5 @@ This boot code runs in the background and has no user interface.
|
|||
|
||||
## Aknowledgements
|
||||
|
||||
Special thanks to [Jonathan Jefferies](https://github.com/jjok) for creating the
|
||||
bootgattbat app, which was the inspiration for this App!
|
||||
Special thanks to [José Rebelo](https://github.com/joserebelo) and [Rob Pilling](https://github.com/bobrippling)
|
||||
for their Code Reviews and guidance.
|
||||
|
|
|
@ -46,7 +46,10 @@
|
|||
max_acceleration = {x: 0, y: 0, z: 0, mag: 0};
|
||||
}
|
||||
|
||||
setInterval(sendSleepAsAndroidData, 10000); // Sleep as Android wants a 10-second maximum
|
||||
Bangle.on("accel", updateAcceleration); // Log all acceleration events
|
||||
var config = require("Storage").readJSON("sleepasandroid.json") || {};
|
||||
if (config.enabled) { // Gadgetbridge needs to enable and disable tracking by writing {enabled: true} to "sleepasandroid.json" and reloading
|
||||
setInterval(sendSleepAsAndroidData, 10000); // Sleep as Android wants a 10-second maximum
|
||||
Bangle.on("accel", updateAcceleration); // Log all acceleration events
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
@ -1 +1 @@
|
|||
(()=>{function a(A){try {Bluetooth.println('');Bluetooth.println(JSON.stringify(A))} catch (_) {console.error('Failed to send message via Bluetooth:',_)}}var b={x:0,y:0,z:0,mag:0};function c(B){var C=B.mag,_c=b.mag;C>_c&&(b=B)}function d(){var _a=Bangle.getAccel(),_b=Bangle.getHealthStatus();a({t:'sleep_as_android',accel:{x:_a.x*9.80665,y:_a.y*9.80665,z:_a.z*9.80665},bpm:_b.bpm});b={x:0,y:0,z:0,mag:0}}setInterval(d,10000);Bangle.on('accel',c)})();
|
||||
(()=>{function a(A){try {Bluetooth.println('');Bluetooth.println(JSON.stringify(A))} catch (_) {console.error('Failed to send message via Bluetooth:',_)}}var b={x:0,y:0,z:0,mag:0},e=require('Storage').readJSON('sleepasandroid.json')||{};function c(B){var C=B.mag,_c=b.mag;C>_c&&(b=B)}function d(){var _a=Bangle.getAccel(),_b=Bangle.getHealthStatus();a({t:'sleep_as_android',accel:{x:_a.x*9.80665,y:_a.y*9.80665,z:_a.z*9.80665},bpm:_b.bpm});b={x:0,y:0,z:0,mag:0}}e.enabled&&(setInterval(d,10000),Bangle.on('accel',c))})();
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"enabled": false
|
||||
}
|
|
@ -16,6 +16,10 @@
|
|||
{
|
||||
"name": "sleepasandroid.boot.js",
|
||||
"url": "boot.min.js"
|
||||
},
|
||||
{
|
||||
"name": "sleepasandroid.json",
|
||||
"url": "config.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue