android - Combine connection handler methods
parent
436a3dfd97
commit
966a867d60
|
|
@ -178,7 +178,7 @@
|
||||||
},options.timeout||30000)};
|
},options.timeout||30000)};
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Battery monitor
|
// Battery monitor
|
||||||
function sendBattery() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); }
|
function sendBattery() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); }
|
||||||
|
|
@ -209,20 +209,16 @@
|
||||||
if (settings.overwriteGps) { // if the overwrite option is set../
|
if (settings.overwriteGps) { // if the overwrite option is set../
|
||||||
const origSetGPSPower = Bangle.setGPSPower;
|
const origSetGPSPower = Bangle.setGPSPower;
|
||||||
// migrate all GPS clients to the other variant on connection events
|
// migrate all GPS clients to the other variant on connection events
|
||||||
let handleConnect = () => {
|
let handleConnection = (state) => {
|
||||||
let orig = Bangle._PWR.GPS;
|
if (Bangle.isGPSOn()){
|
||||||
delete Bangle._PWR.GPS;
|
let orig = Bangle._PWR.GPS;
|
||||||
origSetGPSPower(0);
|
delete Bangle._PWR.GPS;
|
||||||
Bangle._PWR.GPS = orig;
|
origSetGPSPower(state);
|
||||||
|
Bangle._PWR.GPS = orig;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let handleDisconnect = () => {
|
NRF.on('connect', ()=>{handleConnection(1);});
|
||||||
let orig = Bangle._PWR.GPS;
|
NRF.on('disconnect', ()=>{handleConnection(0);});
|
||||||
delete Bangle._PWR.GPS;
|
|
||||||
origSetGPSPower(1);
|
|
||||||
Bangle._PWR.GPS = orig;
|
|
||||||
};
|
|
||||||
NRF.on('connect', handleConnect);
|
|
||||||
NRF.on('disconnect', handleDisconnect);
|
|
||||||
|
|
||||||
// Work around Serial1 for GPS not working when connected to something
|
// Work around Serial1 for GPS not working when connected to something
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue