pull/3474/head
deirdreobyrne 2024-06-26 19:30:14 +01:00 committed by GitHub
parent e0b3bb0cbe
commit 1a22dbbc5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 15 deletions

View File

@ -1,13 +1,11 @@
# BLE BTHome Battery Service # BLE BTHome Battery Service
Broadcasts battery remaining percentage over BLE using the [BTHome protocol](https://bthome.io/) Broadcasts battery remaining percentage over BLE using the [BTHome protocol](https://bthome.io/) - which makes for easy integration into [Home Assistant](https://www.home-assistant.io/)
## Usage ## Usage
This boot code runs in the background and has no user interface. 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 ## Creator
[Deirdre O'Byrne](https://github.com/deirdreobyrne) [Deirdre O'Byrne](https://github.com/deirdreobyrne)

View File

@ -1,17 +1,7 @@
var btHomeBatterySequence = 0; var btHomeBatterySequence = 0;
function advertiseBTHomeBattery() { function advertiseBTHomeBattery() {
var advert = [ 0x40, /* BTHome Device Information var advert = [0x40, 0x00, btHomeBatterySequence, 0x01, E.getBattery()];
bit 0: "Encryption flag"
bit 1-4: "Reserved for future use"
bit 5-7: "BTHome Version" */
0x00, // Sequence number
btHomeBatterySequence,
0x01, // Battery, 8 bit
E.getBattery()
];
if(Array.isArray(Bangle.bleAdvert)){ if(Array.isArray(Bangle.bleAdvert)){
var found = false; var found = false;

View File

@ -3,7 +3,7 @@
"name": "BLE BTHome Battery Service", "name": "BLE BTHome Battery Service",
"shortName": "BTHome Battery Service", "shortName": "BTHome Battery Service",
"version": "0.01", "version": "0.01",
"description": "Broadcasts battery remaining over bluetooth using the BTHome protocol.\n", "description": "Broadcasts battery remaining over bluetooth using the BTHome protocol - makes for easy integration with Home Assistant.\n",
"icon": "bluetooth.png", "icon": "bluetooth.png",
"type": "bootloader", "type": "bootloader",
"tags": "battery,ble,bluetooth,bthome", "tags": "battery,ble,bluetooth,bthome",