diff --git a/apps/bootbthomebatt/ChangeLog b/apps/bootbthomebatt/ChangeLog new file mode 100644 index 000000000..2a37193a3 --- /dev/null +++ b/apps/bootbthomebatt/ChangeLog @@ -0,0 +1 @@ +0.01: Initial release. diff --git a/apps/bootbthomebatt/README.md b/apps/bootbthomebatt/README.md new file mode 100644 index 000000000..990dcb16b --- /dev/null +++ b/apps/bootbthomebatt/README.md @@ -0,0 +1,13 @@ +# BLE BTHome Battery Service + +Broadcasts battery remaining percentage over BLE using the BTHome protocol + +## Usage + +This boot code runs in the background and has no user interface. + +Based on [BootGATTBat](https://github.com/espruino/BangleApps/tree/master/apps/bootgattbat) by [Jonathan Jefferies](https://github.com/jjok). + +## Creator + +[Deirdre O'Byrne](https://github.com/deirdreobyrne) diff --git a/apps/bootbthomebatt/bluetooth.png b/apps/bootbthomebatt/bluetooth.png new file mode 100644 index 000000000..1a884a62c Binary files /dev/null and b/apps/bootbthomebatt/bluetooth.png differ diff --git a/apps/bootbthomebatt/boot.js b/apps/bootbthomebatt/boot.js new file mode 100644 index 000000000..b585fb3c5 --- /dev/null +++ b/apps/bootbthomebatt/boot.js @@ -0,0 +1,10 @@ +(() => { + var btHomeSequenceNo = 0; + function advertiseBTHomeBattery() { + require("ble_advert").set(0xFCD2, [0x40,0x00,btHomeSequenceNo,0x01,E.getBattery()]); + btHomeSequenceNo = (btHomeSequenceNo + 1) & 255; + } + + setInterval(advertiseBTHomeBattery, 5 * 60 * 1000); + advertiseBattery(); +})(); diff --git a/apps/bootbthomebatt/metadata.json b/apps/bootbthomebatt/metadata.json new file mode 100644 index 000000000..9deebfdc0 --- /dev/null +++ b/apps/bootbthomebatt/metadata.json @@ -0,0 +1,15 @@ +{ + "id": "bootbthomebatt", + "name": "BLE BTHome Battery Service", + "shortName": "BTHome Battery Service", + "version": "0.01", + "description": "Broadcasts battery remaining over bluetooth using the BTHome protocol.\n", + "icon": "bluetooth.png", + "type": "bootloader", + "tags": "battery,ble,bluetooth,bthome", + "supports": ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"bthomebat.boot.js","url":"boot.js"} + ] +}