Skip to content

Commit 0649a61

Browse files
tokangasrlubos
authored andcommitted
samples: nrf9160: modem_shell: add support for GNSS high accuracy
Added GNSS high accuracy fix support for the "location" command. Signed-off-by: Tommi Kangas <[email protected]>
1 parent f27cbca commit 0649a61

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

samples/nrf9160/modem_shell/src/location/location_shell.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static const char location_usage_str[] =
3232

3333
static const char location_get_usage_str[] =
3434
"Usage: location get [--method <method>] [--interval <secs>]\n"
35-
"[--gnss_accuracy <acc>] [--gnss_timeout <timeout in secs>]\n"
35+
"[--gnss_accuracy <acc>] [--gnss_num_fixes <number of fixes>] [--gnss_timeout <timeout in secs>]\n"
3636
"[--cellular_timeout <timeout in secs>] [--cellular_service <service_string>]\n"
3737
"[--wifi_timeout <timeout in secs>] [--wifi_service <service_string>]\n"
3838
"Options:\n"
@@ -41,7 +41,9 @@ static const char location_get_usage_str[] =
4141
" methods in priority order.\n"
4242
" --interval, Position update interval in seconds\n"
4343
" (default: 0 = single position)\n"
44-
" --gnss_accuracy, Used GNSS accuracy: 'low' or 'normal'\n"
44+
" --gnss_accuracy, Used GNSS accuracy: 'low', 'normal' or 'high'\n"
45+
" --gnss_num_fixes, Number of consecutive fix attempts (if gnss_accuracy\n"
46+
" set to 'high', default: 3)\n"
4547
" --gnss_timeout, GNSS timeout in seconds\n"
4648
" --cellular_timeout, Cellular timeout in seconds\n"
4749
" --cellular_service, Used cellular positioning service:\n"
@@ -57,10 +59,11 @@ enum {
5759
LOCATION_SHELL_OPT_INTERVAL = 1001,
5860
LOCATION_SHELL_OPT_GNSS_ACCURACY = 1002,
5961
LOCATION_SHELL_OPT_GNSS_TIMEOUT = 1003,
60-
LOCATION_SHELL_OPT_CELLULAR_TIMEOUT = 1004,
61-
LOCATION_SHELL_OPT_CELLULAR_SERVICE = 1005,
62-
LOCATION_SHELL_OPT_WIFI_TIMEOUT = 1006,
63-
LOCATION_SHELL_OPT_WIFI_SERVICE = 1007,
62+
LOCATION_SHELL_OPT_GNSS_NUM_FIXES = 1004,
63+
LOCATION_SHELL_OPT_CELLULAR_TIMEOUT = 1005,
64+
LOCATION_SHELL_OPT_CELLULAR_SERVICE = 1006,
65+
LOCATION_SHELL_OPT_WIFI_TIMEOUT = 1007,
66+
LOCATION_SHELL_OPT_WIFI_SERVICE = 1008,
6467
};
6568

6669
/* Specifying the expected options */
@@ -69,6 +72,7 @@ static struct option long_options[] = {
6972
{ "interval", required_argument, 0, LOCATION_SHELL_OPT_INTERVAL },
7073
{ "gnss_accuracy", required_argument, 0, LOCATION_SHELL_OPT_GNSS_ACCURACY },
7174
{ "gnss_timeout", required_argument, 0, LOCATION_SHELL_OPT_GNSS_TIMEOUT },
75+
{ "gnss_num_fixes", required_argument, 0, LOCATION_SHELL_OPT_GNSS_NUM_FIXES },
7276
{ "cellular_timeout", required_argument, 0, LOCATION_SHELL_OPT_CELLULAR_TIMEOUT },
7377
{ "cellular_service", required_argument, 0, LOCATION_SHELL_OPT_CELLULAR_SERVICE },
7478
{ "wifi_timeout", required_argument, 0, LOCATION_SHELL_OPT_WIFI_TIMEOUT },
@@ -190,6 +194,9 @@ int location_shell(const struct shell *shell, size_t argc, char **argv)
190194
enum location_accuracy gnss_accuracy = 0;
191195
bool gnss_accuracy_set = false;
192196

197+
int gnss_num_fixes = 0;
198+
bool gnss_num_fixes_set = false;
199+
193200
int cellular_timeout = 0;
194201
bool cellular_timeout_set = false;
195202
enum location_service cellular_service = LOCATION_SERVICE_ANY;
@@ -234,6 +241,11 @@ int location_shell(const struct shell *shell, size_t argc, char **argv)
234241
gnss_timeout_set = true;
235242
break;
236243

244+
case LOCATION_SHELL_OPT_GNSS_NUM_FIXES:
245+
gnss_num_fixes = atoi(optarg);
246+
gnss_num_fixes_set = true;
247+
break;
248+
237249
case LOCATION_SHELL_OPT_CELLULAR_TIMEOUT:
238250
cellular_timeout = atoi(optarg);
239251
cellular_timeout_set = true;
@@ -271,6 +283,8 @@ int location_shell(const struct shell *shell, size_t argc, char **argv)
271283
gnss_accuracy = LOCATION_ACCURACY_LOW;
272284
} else if (strcmp(optarg, "normal") == 0) {
273285
gnss_accuracy = LOCATION_ACCURACY_NORMAL;
286+
} else if (strcmp(optarg, "high") == 0) {
287+
gnss_accuracy = LOCATION_ACCURACY_HIGH;
274288
} else {
275289
mosh_error("Unknown GNSS accuracy. See usage:");
276290
goto show_usage;
@@ -339,6 +353,10 @@ int location_shell(const struct shell *shell, size_t argc, char **argv)
339353
if (gnss_accuracy_set) {
340354
config.methods[i].gnss.accuracy = gnss_accuracy;
341355
}
356+
if (gnss_num_fixes_set) {
357+
config.methods[i].gnss.num_consecutive_fixes =
358+
gnss_num_fixes;
359+
}
342360
} else if (config.methods[i].method == LOCATION_METHOD_CELLULAR) {
343361
config.methods[i].cellular.service = cellular_service;
344362
if (cellular_timeout_set) {

0 commit comments

Comments
 (0)