Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2023-06-09 11:03:16 +01:00
commit 1c95dacc26
8 changed files with 96 additions and 4 deletions

View File

@ -0,0 +1 @@
0.01: Initial release.

View File

@ -0,0 +1,16 @@
# BLE GATT HRM Service
Adds the GATT HRM Service to advertise the current HRM over Bluetooth.
## Usage
This boot code runs in the background and has no user interface.
## Creator
[Another Stranger](https://github.com/anotherstranger)
## Aknowledgements
Special thanks to [Jonathan Jefferies](https://github.com/jjok) for creating the
bootgattbat app, which was the inspiration for this App!

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

54
apps/bootgatthrm/boot.js Normal file
View File

@ -0,0 +1,54 @@
(() => {
function setupHRMAdvertising() {
/*
* This function prepares BLE heart rate Advertisement.
*/
NRF.setServices({
0x180D: { // heart_rate
0x2A37: { // heart_rate_measurement
notify: true,
value: [0x06, 0],
}
}
}, { advertise: [0x180d] });
}
function updateBLEHeartRate(hrm) {
/*
* Send updated heart rate measurement via BLE
*/
if (hrm === undefined || hrm.confidence < 50) return;
try {
NRF.updateServices({
0x180D: {
0x2A37: {
value: [
0x06, //
hrm.bpm
],
notify: true
}
}
});
} catch (error) {
if (error.message.includes("BLE restart")) {
/*
* BLE has to restart after service setup.
*/
NRF.disconnect();
}
else if (error.message.includes("UUID 0x2a37")) {
/*
* Setup service if it wasn't setup correctly for some reason
*/
setupHRMAdvertising();
} else {
console.log("[bootgatthrm]: Unexpected error occured while updating HRM over BLE! Error: " + error.message);
}
}
}
setupHRMAdvertising();
Bangle.on("HRM", function (hrm) { updateBLEHeartRate(hrm); });
})();

View File

@ -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"}
]
}

View File

@ -5,3 +5,4 @@
0.06: Tweaking colors for dark/light themes and low bpp screens
0.07: Memory usage improvements
0.08: Disable LCD on, on bluetooth status change
0.09: Fix widget not showing on blue background

View File

@ -1,7 +1,7 @@
{
"id": "widbt",
"name": "Bluetooth Widget",
"version": "0.08",
"version": "0.09",
"description": "Show the current Bluetooth connection status in the top right of the clock",
"icon": "widget.png",
"type": "widget",

View File

@ -1,9 +1,14 @@
WIDGETS["bluetooth"]={area:"tr",width:15,draw:function() {
g.reset();
if (NRF.getSecurityStatus().connected)
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
else
if (NRF.getSecurityStatus().connected) {
if (g.getBgColor() === 31) { // If background color is blue use cyan instead
g.setColor("#0ff");
} else {
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
}
} else {
g.setColor(g.theme.dark ? "#666" : "#999");
}
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),2+this.x,2+this.y);
},changed:function() {
WIDGETS["bluetooth"].draw();