From e55c1566ee0ea9b8b943a4ae154f08272c210efa Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Fri, 13 Jan 2023 09:34:11 +0100 Subject: [PATCH] android - Fix GPS switched of when connected while writing to Serial1 --- apps/android/boot.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/android/boot.js b/apps/android/boot.js index 9ae75e228..a2c0acad9 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -228,6 +228,18 @@ }; NRF.on('connect', handleConnect); NRF.on('disconnect', handleDisconnect); + + // Work around Serial1 for GPS not working when connected to something + // + Serial1.println = (o => s => { + origSetGPSPower(1,"android_gpsserial"); + o(s); + })(Serial1.println); + Serial1.write = (o => s => { + origSetGPSPower(1,"android_gpsserial"); + o(s); + })(Serial1.println); + Bangle.setGBGPSPower = (isOn, appID) => { if (!Bangle._PWR) Bangle._PWR={}; if (!Bangle._PWR.GBGPS) Bangle._PWR.GBGPS=[]; @@ -240,6 +252,8 @@ }; // Replace set GPS power logic to suppress activation of gps (and instead request it from the phone) Bangle.setGPSPower = (isOn, appID) => { + // disable our own request for GPS power first + if (!isOn) origSetGPSPower(0,"android_gpsserial"); // if not connected use internal GPS power function if (!NRF.getSecurityStatus().connected) return origSetGPSPower(isOn, appID); return Bangle.setGBGPSPower(isOn, appID);