feat: ✨ add gatthrm bootloader code
parent
3b14f06dc9
commit
f1ae6c9215
|
|
@ -0,0 +1 @@
|
|||
0.01: Initial release.
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# BLE GATT Battery Service
|
||||
|
||||
Adds the GATT Battery Service to advertise the percentage of battery currently remaining over Bluetooth.
|
||||
|
||||
## Usage
|
||||
|
||||
This boot code runs in the background and has no user interface.
|
||||
|
||||
## Requests
|
||||
|
||||
If you have any suggestions or ideas please post in [this forum thread](http://forum.espruino.com/conversations/351959/),
|
||||
or [@jjok](https://github.com/jjok) in your Github issue.
|
||||
|
||||
## Creator
|
||||
|
||||
[Jonathan Jefferies](https://github.com/jjok)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -0,0 +1,43 @@
|
|||
(() => {
|
||||
function setupHRMAdvertising() {
|
||||
/*
|
||||
* This function preparse BLE heart rate Advertisement.
|
||||
*/
|
||||
NRF.setServices({
|
||||
0x180D: { // heart_rate
|
||||
0x2A37: { // heart_rate_measurement
|
||||
notify: true,
|
||||
value: [0x06, 0],
|
||||
}
|
||||
}
|
||||
}, { advertise: ['180D'] });
|
||||
|
||||
}
|
||||
|
||||
function updateBLEHeartRate(hrm) {
|
||||
/*
|
||||
* Send updated heart rate measurement via BLE
|
||||
*/
|
||||
if (hrm === undefined) return;
|
||||
try {
|
||||
NRF.updateServices({
|
||||
'180d': {
|
||||
'2a37': {
|
||||
value: [
|
||||
0x06, //
|
||||
hrm
|
||||
],
|
||||
notify: true
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// After setupHRMAdvertising() BLE needs to restart.
|
||||
// We force a disconnect if the Bangle was connected while setting HRM
|
||||
NRF.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
setupHRMAdvertising();
|
||||
Bangle.on("HRM", function (hrm) { updateBLEHeartRate(hrm.bpm); });
|
||||
})();
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"id": "bootgatthrm",
|
||||
"name": "BLE GATT HRM Service",
|
||||
"shortName": "BLE HRM Service",
|
||||
"version": "0.01",
|
||||
"description": "Adds the GATT HRM Service to advertise the measured HRM over Bluetooth.\n",
|
||||
"icon": "bluetooth.png",
|
||||
"type": "bootloader",
|
||||
"tags": "hrm,health,ble,bluetooth,gatt",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"gatthrm.boot.js","url":"boot.js"}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue