Use NRF.getSecurityStatus().advertising for initial state

pull/2608/head
Rob Pilling 2023-03-06 12:04:58 +00:00
parent d9dc729abd
commit 832ec7a7a5
2 changed files with 15 additions and 6 deletions

View File

@ -2,9 +2,14 @@
(function () {
"ram";
var _a;
var state = NRF.getSecurityStatus().connected
? 2
: 0;
var state = (function () {
var status = NRF.getSecurityStatus();
if (status.connected)
return 2;
if (status.advertising)
return 1;
return 0;
})();
var width = function () { return state > 0 ? 15 : 0; };
var update = function (newState) {
state = newState;

View File

@ -7,9 +7,13 @@
Connected
}
let state: State = NRF.getSecurityStatus().connected
? State.Connected
: State.Asleep; // could be active, assuming not here
let state: State = (() => {
const status = NRF.getSecurityStatus();
if (status.connected) return State.Connected;
if (status.advertising) return State.Active;
return State.Asleep;
})();
const width = () => state > State.Asleep ? 15 : 0;