Skip to content

Commit 505c251

Browse files
tokangasrlubos
authored andcommitted
samples: use modem_antenna library for configuring GNSS LNA
Updated samples and applications to use the new modem_antenna library for configuring GNSS Low Noise Amplifier (LNA) instead of having the same implementation in multiple places. Signed-off-by: Tommi Kangas <[email protected]>
1 parent 4933069 commit 505c251

File tree

27 files changed

+44
-347
lines changed

27 files changed

+44
-347
lines changed

applications/asset_tracker_v2/doc/asset_tracker_v2_description.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ You can add the following optional configurations to configure the heap or to pr
243243
* :kconfig:option:`CONFIG_PDN_DEFAULTS_OVERRIDE` - Used for manual configuration of the APN. Set the option to ``y`` to override the default PDP context configuration.
244244
* :kconfig:option:`CONFIG_PDN_DEFAULT_APN` - Used for manual configuration of the APN. An example is ``apn.example.com``.
245245

246+
If you use an external GNSS antenna, add the following configuration:
247+
248+
* :kconfig:option:`CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL` - Selects an external GNSS antenna.
249+
246250
Configuration files
247251
===================
248252

@@ -292,7 +296,7 @@ See :ref:`Building with overlays <building_with_overlays>` for information on ho
292296
293297
.. note::
294298

295-
When you build the application for the nRF9160 DK v0.15.0 and later, set the :ref:`CONFIG_GNSS_MODULE_ANTENNA_EXTERNAL <CONFIG_GNSS_MODULE_ANTENNA_EXTERNAL>` option to ``y`` to achieve the best external antenna performance.
299+
When you build the application for the nRF9160 DK v0.15.0 and later, set the :kconfig:option:`CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL` option to ``y`` to achieve the best external antenna performance.
296300

297301
.. external_antenna_note_end
298302

applications/asset_tracker_v2/doc/gnss_module.rst

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ LNA configuration
4141
=================
4242

4343
Different devices have different antenna and LNA setups depending on the antenna type (onboard or external).
44-
The module has Kconfig options to control the LNA using either the COEX0 or MAGPIO interface of the nRF9160.
45-
See :ref:`configuration_options` for more details on how to configure the antenna and LNA.
44+
The application uses the :ref:`lib_modem_antenna` library for configuring the LNA.
45+
The library has Kconfig options to control the LNA using either the COEX0 or MAGPIO interface of the nRF9160.
46+
See the library documentation for more details on how to configure the antenna and LNA.
4647

4748
GPS assistance data
4849
===================
@@ -84,16 +85,6 @@ CONFIG_GNSS_MODULE_PVT
8485
CONFIG_GNSS_MODULE_NMEA
8586
Selects the NMEA format. Includes an NMEA string of the GGA type in the ``GNSS_EVT_DATA_READY`` events that are sent when the GNSS acquires a position fix.
8687

87-
.. _CONFIG_GNSS_MODULE_ANTENNA_ONBOARD:
88-
89-
CONFIG_GNSS_MODULE_ANTENNA_ONBOARD
90-
This configures the target to use an onboard GNSS antenna. Sends antenna configurations to the modem when you compile for Thingy:91 or nRF9160 DK.
91-
92-
.. _CONFIG_GNSS_MODULE_ANTENNA_EXTERNAL:
93-
94-
CONFIG_GNSS_MODULE_ANTENNA_EXTERNAL
95-
This configures the target to use an external GNSS antenna.
96-
9788
If P-GPS is used, the last known position from a GNSS fix can be stored and injected to the modem together with the relevant ephemeris.
9889
This may, depending on the use case and the device's movements, reduce the time to fix.
9990
To enable this feature, use the following option:

applications/asset_tracker_v2/src/modules/Kconfig.gnss_module

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,6 @@ config GNSS_MODULE_ELEVATION_MASK
4949
default NRF_CLOUD_AGPS_ELEVATION_MASK
5050
depends on NRF_CLOUD_AGPS_FILTERED
5151

52-
choice GNSS_MODULE_ANTENNA
53-
default GNSS_MODULE_ANTENNA_ONBOARD
54-
prompt "Select which antenna to use for GNSS"
55-
56-
config GNSS_MODULE_ANTENNA_ONBOARD
57-
bool "Use onboard antenna"
58-
59-
config GNSS_MODULE_ANTENNA_EXTERNAL
60-
bool "Use external antenna"
61-
62-
endchoice
63-
64-
config GNSS_MODULE_AT_MAGPIO
65-
string "AT%XMAGPIO command"
66-
default "AT\%XMAGPIO=1,0,0,1,1,1574,1577" if BOARD_NRF9160DK_NRF9160_NS
67-
default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160_NS
68-
help
69-
Defines what is the AT%XMAGPIO command to be sent to GNSS module. Leave
70-
empty if this command should not be sent.
71-
72-
config GNSS_MODULE_AT_COEX0
73-
string "AT%XCOEX0 command"
74-
default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GNSS_MODULE_ANTENNA_ONBOARD
75-
default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GNSS_MODULE_ANTENNA_EXTERNAL
76-
help
77-
Defines what is the AT%XCOEX0 command to be sent to GNSS module. Leave
78-
empty if this command should not be sent.
79-
8052
endif # GNSS_MODULE
8153

8254
module = GNSS_MODULE

applications/asset_tracker_v2/src/modules/gnss_module.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -508,43 +508,10 @@ static bool gnss_data_requested(enum app_module_data_type *data_list,
508508
return false;
509509
}
510510

511-
static int lna_configure(void)
512-
{
513-
int err;
514-
const char *xmagpio_command = CONFIG_GNSS_MODULE_AT_MAGPIO;
515-
const char *xcoex0_command = CONFIG_GNSS_MODULE_AT_COEX0;
516-
517-
LOG_DBG("MAGPIO command: %s", log_strdup(xmagpio_command));
518-
LOG_DBG("COEX0 command: %s", log_strdup(xcoex0_command));
519-
520-
/* Make sure the AT command is not empty. */
521-
if (xmagpio_command[0] != '\0') {
522-
err = nrf_modem_at_printf("%s", xmagpio_command);
523-
if (err) {
524-
return err;
525-
}
526-
}
527-
528-
if (xcoex0_command[0] != '\0') {
529-
err = nrf_modem_at_printf("%s", xcoex0_command);
530-
if (err) {
531-
return err;
532-
}
533-
}
534-
535-
return 0;
536-
}
537-
538511
static int setup(void)
539512
{
540513
int err;
541514

542-
err = lna_configure();
543-
if (err) {
544-
LOG_ERR("Failed to configure LNA, error %d", err);
545-
return err;
546-
}
547-
548515
err = nrf_modem_gnss_event_handler_set(gnss_event_handler);
549516
if (err) {
550517
LOG_ERR("Failed to set GNSS event handler, error %d", err);

applications/asset_tracker_v2/tests/gnss_module/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ target_include_directories(app PRIVATE ${ZEPHYR_BASE}/../nrf/modules/cjson/inclu
3838
# Options that cannot be passed through Kconfig fragments.
3939
target_compile_options(app PRIVATE
4040
-DCONFIG_ASSET_TRACKER_V2_APP_VERSION_MAX_LEN=20
41-
-DCONFIG_GNSS_MODULE_NMEA
42-
-DCONFIG_GNSS_MODULE_AT_MAGPIO="AT%XMAGPIO"
43-
-DCONFIG_GNSS_MODULE_AT_COEX0="AT%XCOEX0")
41+
-DCONFIG_GNSS_MODULE_NMEA)

applications/asset_tracker_v2/tests/gnss_module/src/gnss_module_test.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ static void setup_gnss_module_in_init_state(void)
256256
__wrap_app_event_manager_free_ExpectAnyArgs();
257257
struct app_module_event *app_module_event = new_app_module_event();
258258

259-
/* AT%XMAGPIO and AT%XCOEX0 AT commands for LNA configuration. */
260-
__wrap_nrf_modem_at_printf_ExpectAnyArgsAndReturn(0);
261-
__wrap_nrf_modem_at_printf_ExpectAnyArgsAndReturn(0);
262-
263259
__wrap_nrf_modem_gnss_event_handler_set_AddCallback(
264260
&nrf_modem_gnss_event_handler_set_callback);
265261
__wrap_nrf_modem_gnss_event_handler_set_ExpectAnyArgsAndReturn(0);

samples/nrf9160/gnss/Kconfig

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,6 @@ config GNSS_SAMPLE_NMEA_ONLY
6060
help
6161
Outputs only NMEA strings from the GNSS.
6262

63-
choice
64-
default GNSS_SAMPLE_ANTENNA_ONBOARD
65-
prompt "Select which antenna to use for GNSS"
66-
67-
config GNSS_SAMPLE_ANTENNA_ONBOARD
68-
bool "Use onboard antenna"
69-
70-
config GNSS_SAMPLE_ANTENNA_EXTERNAL
71-
bool "Use external antenna"
72-
73-
endchoice
74-
75-
config GNSS_SAMPLE_AT_MAGPIO
76-
string "AT%XMAGPIO command"
77-
default "AT\%XMAGPIO=1,0,0,1,1,1574,1577" if BOARD_NRF9160DK_NRF9160_NS
78-
default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160_NS
79-
help
80-
Defines the AT%XMAGPIO command to be sent to GNSS module. Leave
81-
empty if this command should not be sent.
82-
83-
config GNSS_SAMPLE_AT_COEX0
84-
string "AT%XCOEX0 command"
85-
default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GNSS_SAMPLE_ANTENNA_ONBOARD
86-
default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GNSS_SAMPLE_ANTENNA_EXTERNAL
87-
help
88-
Defines the AT%XCOEX0 command to be sent to GNSS module. Leave
89-
empty if this command should not be sent.
90-
9163
endmenu
9264

9365
choice

samples/nrf9160/gnss/README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ CONFIG_GNSS_SAMPLE_LTE_ON_DEMAND - To disable LTE after assistance download
154154
When using assistance, LTE may block the GNSS operation and increase the time needed to get a fix.
155155
This configuration option disables LTE after the assistance data has been downloaded, so that GNSS can run without interruptions.
156156

157+
Additional configuration
158+
========================
159+
160+
Check and configure the following library option that is used by the sample:
161+
162+
* :kconfig:option:`CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL` - Selects an external GNSS antenna.
163+
157164
Building and running
158165
********************
159166

samples/nrf9160/gnss/prj.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ CONFIG_LOG=y
1515
CONFIG_LOG_MODE_IMMEDIATE=y
1616

1717
# GNSS sample
18-
# Enable to use an external GNSS antenna
19-
CONFIG_GNSS_SAMPLE_ANTENNA_EXTERNAL=n
2018
# Enable to use nRF Cloud A-GPS
2119
CONFIG_GNSS_SAMPLE_ASSISTANCE_NRF_CLOUD=n
2220

samples/nrf9160/gnss/src/main.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,6 @@ static void date_time_evt_handler(const struct date_time_evt *evt)
331331

332332
static int modem_init(void)
333333
{
334-
if (strlen(CONFIG_GNSS_SAMPLE_AT_MAGPIO) > 0) {
335-
if (nrf_modem_at_printf("%s", CONFIG_GNSS_SAMPLE_AT_MAGPIO) != 0) {
336-
LOG_ERR("Failed to set MAGPIO configuration");
337-
return -1;
338-
}
339-
}
340-
341-
if (strlen(CONFIG_GNSS_SAMPLE_AT_COEX0) > 0) {
342-
if (nrf_modem_at_printf("%s", CONFIG_GNSS_SAMPLE_AT_COEX0) != 0) {
343-
LOG_ERR("Failed to set COEX0 configuration");
344-
return -1;
345-
}
346-
}
347-
348334
if (IS_ENABLED(CONFIG_DATE_TIME)) {
349335
date_time_register_handler(date_time_evt_handler);
350336
}

0 commit comments

Comments
 (0)