mirror of https://github.com/espruino/BangleApps
bthometemp: use `ble_advert` module
parent
91dd1f6ec4
commit
beb02e6260
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Handle the case where other apps have set bleAdvert to an array
|
0.02: Handle the case where other apps have set bleAdvert to an array
|
||||||
|
0.03: Use the ble_advert module
|
||||||
|
|
|
@ -38,21 +38,7 @@ function onTemperature(p) {
|
||||||
pressure100&255,(pressure100>>8)&255,pressure100>>16
|
pressure100&255,(pressure100>>8)&255,pressure100>>16
|
||||||
];
|
];
|
||||||
|
|
||||||
if(Array.isArray(Bangle.bleAdvert)){
|
require("ble_advert").set(0xFCD2, advert);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the temperature in the most accurate way with pressure sensor
|
// 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);});
|
Bangle.getPressure().then(p =>{if (p) onTemperature(p);});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Bangle.bleAdvert) Bangle.bleAdvert = {};
|
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
drawTemperature();
|
drawTemperature();
|
||||||
}, 10000); // update every 10s
|
}, 10000); // update every 10s
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "bthometemp",
|
{ "id": "bthometemp",
|
||||||
"name": "BTHome Temperature and Pressure",
|
"name": "BTHome Temperature and Pressure",
|
||||||
"shortName":"BTHome T",
|
"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",
|
"description": "Displays temperature and pressure, and advertises them over bluetooth for Home Assistant using BTHome.io standard",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "bthome,bluetooth,temperature",
|
"tags": "bthome,bluetooth,temperature",
|
||||||
|
|
Loading…
Reference in New Issue