diff --git a/apps/bthometemp/ChangeLog b/apps/bthometemp/ChangeLog index 480780ec5..94a60aa3e 100644 --- a/apps/bthometemp/ChangeLog +++ b/apps/bthometemp/ChangeLog @@ -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 diff --git a/apps/bthometemp/app.js b/apps/bthometemp/app.js index cf74c7937..f18e33c20 100644 --- a/apps/bthometemp/app.js +++ b/apps/bthometemp/app.js @@ -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 diff --git a/apps/bthometemp/metadata.json b/apps/bthometemp/metadata.json index fc6804f17..3e96d95f8 100644 --- a/apps/bthometemp/metadata.json +++ b/apps/bthometemp/metadata.json @@ -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",