1
0
Fork 0

Merge branch 'feat/ble-advert-use'

master
Rob Pilling 2024-06-28 07:28:28 +01:00
commit 9050ffe684
7 changed files with 7 additions and 42 deletions

View File

@ -1,3 +1,4 @@
0.01: New app!
0.02: Advertise accelerometer data and sensor location
0.03: Use the bleAdvert module
0.04: Actually use the ble_advert module

View File

@ -1,4 +1,3 @@
var _a;
{
var __assign = Object.assign;
var Layout_1 = require("Layout");
@ -441,8 +440,6 @@ var _a;
NRF.setServices(ad, {
uart: false,
});
var bangle2 = Bangle;
var cycle = Array.isArray(bangle2.bleAdvert) ? bangle2.bleAdvert : [];
for (var id in ad) {
var serv = ad[id];
var value = void 0;
@ -450,11 +447,7 @@ var _a;
value = serv[ch].value;
break;
}
cycle.push((_a = {}, _a[id] = value || [], _a));
require("ble_advert").set(id, value || []);
}
bangle2.bleAdvert = cycle;
NRF.setAdvertising(cycle, {
interval: 100,
});
}
}

View File

@ -767,12 +767,6 @@ enableSensors();
},
);
type BleAdvert = { [key: string]: number[] };
const bangle2 = Bangle as {
bleAdvert?: BleAdvert | BleAdvert[];
};
const cycle = Array.isArray(bangle2.bleAdvert) ? bangle2.bleAdvert : [];
for(const id in ad){
const serv = ad[id as BleServ];
let value;
@ -783,16 +777,7 @@ enableSensors();
break;
}
cycle.push({ [id]: value || [] });
require("ble_advert").set(id, value || []);
}
bangle2.bleAdvert = cycle;
NRF.setAdvertising(
cycle,
{
interval: 100,
}
);
}
}

View File

@ -2,7 +2,7 @@
"id": "btadv",
"name": "btadv",
"shortName": "btadv",
"version": "0.03",
"version": "0.04",
"description": "Advertise & export live heart rate, accel, pressure, GPS & mag data over bluetooth",
"icon": "icon.png",
"tags": "health,tool,sensors,bluetooth",

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Handle the case where other apps have set bleAdvert to an array
0.03: Use the ble_advert module

View File

@ -38,21 +38,7 @@ function onTemperature(p) {
pressure100&255,(pressure100>>8)&255,pressure100>>16
];
if(Array.isArray(Bangle.bleAdvert)){
var found = false;
for(var ad in Bangle.bleAdvert){
if(ad[0xFCD2]){
ad[0xFCD2] = advert;
found = true;
break;
}
}
if(!found)
Bangle.bleAdvert.push({ 0xFCD2: advert });
}else{
Bangle.bleAdvert[0xFCD2] = advert;
}
NRF.setAdvertising(Bangle.bleAdvert);
require("ble_advert").set(0xFCD2, advert);
}
// Gets the temperature in the most accurate way with pressure sensor
@ -60,7 +46,6 @@ function drawTemperature() {
Bangle.getPressure().then(p =>{if (p) onTemperature(p);});
}
if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
setInterval(function() {
drawTemperature();
}, 10000); // update every 10s

View File

@ -1,7 +1,7 @@
{ "id": "bthometemp",
"name": "BTHome Temperature and Pressure",
"shortName":"BTHome T",
"version":"0.02",
"version":"0.03",
"description": "Displays temperature and pressure, and advertises them over bluetooth for Home Assistant using BTHome.io standard",
"icon": "app.png",
"tags": "bthome,bluetooth,temperature",