Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix: update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 3, 2023
1 parent 2e2a16b commit 055cbf2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/modules/location_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ BUILD_ASSERT(CONFIG_AT_MONITOR_HEAP_SIZE >= 1024,
"CONFIG_AT_MONITOR_HEAP_SIZE must be >= 1024 to fit neighbor cell measurements "
"and other notifications at the same time");

/* Use a timeout of 90 seconds for GNSS search. */
#define DATA_FETCH_TIMEOUT_GNSS_SEARCH 90

/* Use a timeout of 11 seconds to accommodate for neighbour cell measurements
* that can take up to 10.24 seconds.
*/
#define DATA_FETCH_TIMEOUT_NEIGHBORHOOD_SEARCH 11

struct location_msg_data {
union {
struct app_module_event app;
Expand Down Expand Up @@ -80,6 +72,13 @@ static struct module_stats {
uint8_t satellites_tracked;
} stats;

/* Indicates whether cloud location request is pending towards cloud service, that is,
* LOCATION_EVT_CLOUD_LOCATION_EXT_REQUEST has been received but not responded yet.
* This is specifically needed when cloud connection doesn't exist and there is a
* new sampling request. We can then cancel previous location request and do a new one.
*/
static bool cloud_location_request_pending;

static struct module_data self = {
.name = "location",
.msg_q = NULL,
Expand Down Expand Up @@ -296,6 +295,7 @@ static void search_start(void)

static void inactive_send(void)
{
cloud_location_request_pending = false;
SEND_EVENT(location, LOCATION_MODULE_EVT_INACTIVE);
}

Expand Down Expand Up @@ -501,6 +501,7 @@ void location_event_handler(const struct location_event_data *event_data)
case LOCATION_EVT_CLOUD_LOCATION_EXT_REQUEST:
LOG_DBG("Getting cloud location request");
send_cloud_location_update(&event_data->cloud_location_request);
cloud_location_request_pending = true;
break;
#endif

Expand Down Expand Up @@ -577,6 +578,16 @@ static void on_state_running_location_search(struct location_msg_data *msg)
return;
}

/* If cloud location request is pending data and cloud modules,
* we'll cancel current location request and start a new one
*/
if (cloud_location_request_pending) {
location_request_cancel();
cloud_location_request_pending = false;
search_start();
return;
}

LOG_DBG("Location request already active and will not be restarted");
LOG_DBG("Seeing this message sometimes is normal, especially, "
"when trying to acquire the first GNSS fix.");
Expand Down

0 comments on commit 055cbf2

Please sign in to comment.