From 0088f40eb0598f9ead0ba137c5d5fc72da7669cd Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 25 Mar 2021 11:55:55 +0800 Subject: [PATCH] fix location-fill in problem not working (ht @hansi) --- .../geeksville/mesh/service/MeshService.kt | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 5f8a075d1..83e616cc1 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -952,17 +952,31 @@ class MeshService : Service(), Logging { private fun setupLocationRequest() { var desiredInterval = 0L - if (myNodeInfo?.hasGPS == true) - desiredInterval = - radioConfig?.preferences?.positionBroadcastSecs?.times(1000L) ?: 5 * 60 * 1000L - stopLocationRequests() - if (desiredInterval != 0L) { - debug("desired GPS assistance interval $desiredInterval") - startLocationRequests(desiredInterval) - } else { - debug("No GPS assistance desired, but sending UTC time to mesh") - sendPositionScoped() + val mi = myNodeInfo + val prefs = radioConfig?.preferences + if (mi != null && prefs != null) { + if (!mi.hasGPS) { + var broadcastSecs = prefs.positionBroadcastSecs + + desiredInterval = if(broadcastSecs == 0) // unset by device, use default + 15 * 60 * 1000 + else + broadcastSecs * 1000L + } + + if (prefs.locationShare == RadioConfigProtos.LocationSharing.LocDisabled) { + info("GPS location sharing is disabled") + desiredInterval = 0 + } + + if (desiredInterval != 0L) { + info("desired GPS assistance interval $desiredInterval") + startLocationRequests(desiredInterval) + } else { + info("No GPS assistance desired, but sending UTC time to mesh") + sendPositionScoped() + } } }