From 4c81e249eeba0c77c3de37235815d0aa96cea3bc Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sat, 13 Apr 2024 11:28:30 +0200 Subject: [PATCH] bthrm - Only buzz for disconnect if there was an actual connection before --- apps/bthrm/ChangeLog | 1 + apps/bthrm/lib.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/bthrm/ChangeLog b/apps/bthrm/ChangeLog index e53c5175a..0753534e4 100644 --- a/apps/bthrm/ChangeLog +++ b/apps/bthrm/ChangeLog @@ -45,3 +45,4 @@ 0.19: Move caching of characteristics into settings app Changed default of active scanning to false Fix setHRMPower method not returning new state + Only buzz for disconnect after switching on if there already was an actual connection diff --git a/apps/bthrm/lib.js b/apps/bthrm/lib.js index 07f9688dd..4786a361f 100644 --- a/apps/bthrm/lib.js +++ b/apps/bthrm/lib.js @@ -239,6 +239,7 @@ exports.enable = () => { } }; + let initialDisconnects = true; let buzzing = false; let onDisconnect = function(reason) { log("Disconnect: " + reason); @@ -252,7 +253,7 @@ exports.enable = () => { supportedCharacteristics["0x2a37"].active = false; if (!powerdownRequested) startFallback(); blockInit = false; - if (settings.warnDisconnect && !buzzing){ + if (settings.warnDisconnect && !buzzing && !initialDisconnects){ buzzing = true; Bangle.buzz(500,0.3).then(()=>waitingPromise(4500)).then(()=>{buzzing = false;}); } @@ -415,6 +416,7 @@ exports.enable = () => { return promise.then(()=>{ log("Connection established, waiting for notifications"); + initialDisconnects = false; clearRetryTimeout(true); }).catch((e) => { characteristics = []; @@ -435,6 +437,7 @@ exports.enable = () => { isOn = Bangle._PWR.BTHRM.length; // so now we know if we're really on if (isOn) { + initialDisconnects = true; powerdownRequested = false; switchFallback(); if (!Bangle.isBTHRMConnected()) initBt();