Skip to content

Commit

Permalink
modules: location: Revert to fallback and add debug prints
Browse files Browse the repository at this point in the history
Revert to fallback and add debug prints.
The fallback method gives error/timeout events for all sources.
This doesn't fit with the trigger logic as it expect location
search start and stop events per location source, not source.

Error/timeout events from the location module both translate to
location search done.

Dial down the log level from the location library now that we print
more verbose debug prints from the location module.

Also, move memfault module logging to the memfault overlay.

Signed-off-by: Simen S. Røstad <[email protected]>
  • Loading branch information
simensrostad committed Oct 10, 2024
1 parent 1a85f49 commit a4bd848
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/overlay-memfault.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

CONFIG_APP_MEMFAULT=y
CONFIG_APP_MEMFAULT_LOG_LEVEL_DBG=y
CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI=y
CONFIG_MEMFAULT_NCS_PROJECT_KEY=""
CONFIG_MEMFAULT_LOGGING_RAM_SIZE=4096
Expand Down
2 changes: 0 additions & 2 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,11 @@ CONFIG_APP_BATTERY_LOG_LEVEL_DBG=y
CONFIG_APP_LOCATION_LOG_LEVEL_DBG=y
CONFIG_APP_TRANSPORT_LOG_LEVEL_DBG=y
CONFIG_APP_TRIGGER_LOG_LEVEL_DBG=y
CONFIG_APP_MEMFAULT_LOG_LEVEL_DBG=y
CONFIG_APP_NETWORK_LOG_LEVEL_DBG=y
CONFIG_APP_LED_LOG_LEVEL_DBG=y
CONFIG_APP_ENVIRONMENTAL_LOG_LEVEL_DBG=y
CONFIG_APP_SHELL_LOG_LEVEL_DBG=y
CONFIG_APP_LOG_LEVEL_DBG=y
CONFIG_LOCATION_LOG_LEVEL_DBG=y

# Fuel Gage
CONFIG_NRF_FUEL_GAUGE=y
Expand Down
48 changes: 45 additions & 3 deletions app/src/modules/location/location.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ void trigger_location_update(void)
LOG_DBG("GNSS disabled");
}

config.mode = LOCATION_REQ_MODE_ALL;

LOG_DBG("location library initialized");

err = location_request(&config);
Expand Down Expand Up @@ -139,6 +137,31 @@ void handle_config_chan(const struct configuration *config)
}
}

static void location_print_data_details(enum location_method method,
const struct location_data_details *details)
{
LOG_DBG("Elapsed method time: %d ms", details->elapsed_time_method);
#if defined(CONFIG_LOCATION_METHOD_GNSS)
if (method == LOCATION_METHOD_GNSS) {
LOG_DBG("Satellites tracked: %d", details->gnss.satellites_tracked);
LOG_DBG("Satellites used: %d", details->gnss.satellites_used);
LOG_DBG("Elapsed GNSS time: %d ms", details->gnss.elapsed_time_gnss);
LOG_DBG("GNSS execution time: %d ms", details->gnss.pvt_data.execution_time);
}
#endif
#if defined(CONFIG_LOCATION_METHOD_CELLULAR)
if (method == LOCATION_METHOD_CELLULAR || method == LOCATION_METHOD_WIFI_CELLULAR) {
LOG_DBG("Neighbor cells: %d", details->cellular.ncells_count);
LOG_DBG("GCI cells: %d", details->cellular.gci_cells_count);
}
#endif
#if defined(CONFIG_LOCATION_METHOD_WIFI)
if (method == LOCATION_METHOD_WIFI || method == LOCATION_METHOD_WIFI_CELLULAR) {
LOG_DBG("Wi-Fi APs: %d", details->wifi.ap_count);
}
#endif
}

void location_task(void)
{
int err = 0;
Expand Down Expand Up @@ -250,9 +273,28 @@ static void location_event_handler(const struct location_event_data *event_data)
status_send(LOCATION_SEARCH_DONE);
break;
case LOCATION_EVT_ERROR:
LOG_WRN("Getting location failed");
LOG_WRN("Location request failed:");
LOG_WRN("Used method: %s (%d)", location_method_str(event_data->method),
event_data->method);

location_print_data_details(event_data->method, &event_data->error.details);

status_send(LOCATION_SEARCH_DONE);
break;
case LOCATION_EVT_FALLBACK:
LOG_DBG("Location request fallback has occurred:");
LOG_DBG("Failed method: %s (%d)", location_method_str(event_data->method),
event_data->method);
LOG_DBG("New method: %s (%d)", location_method_str(
event_data->fallback.next_method),
event_data->fallback.next_method);
LOG_DBG("Cause: %s",
(event_data->fallback.cause == LOCATION_EVT_TIMEOUT) ? "timeout" :
(event_data->fallback.cause == LOCATION_EVT_ERROR) ? "error" :
"unknown");

location_print_data_details(event_data->method, &event_data->fallback.details);
break;
default:
LOG_DBG("Getting location: Unknown event %d", event_data->id);
break;
Expand Down

0 comments on commit a4bd848

Please sign in to comment.