This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to turn on/off GPS while LTE is on?

I'm attempting t to turn on and off GPS function while LTE is on, but it doesn't work out. I merged mqtt_simple and gps example programs into a new project. What's wrong with the program?

In configure_gps_off_on function, buf stores "ERROR" in the line of bytes_received = recv(at_sock, buf, 2, 0),  which means that receiving data through socket does not work.

ncs version: 1.0.0

In version 1.0.0, is it possible to use LTE and GPS at the same time?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<prj.conf>
# General config
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
# Networking
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=4
# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
# BSD library
CONFIG_BSD_LIBRARY=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<main.c>
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/
#include <zephyr.h>
#include <stdio.h>
#include <uart.h>
#include <string.h>
#include <net/mqtt.h>
#include <nrf_socket.h>
#include <net/socket.h>
#include <lte_lc.h>
#include <stdio.h>
#define MQTT_USERNAME "username"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<result>
***** Booting Zephyr OS v1.14.99-ncs2-rc3 *****
The MQTT simple sample started
LTE Link Connecting ...
LTE Link Connected!
IPv4 Address found xxx.xx.xx.xxx
[mqtt_evt_handler:389] MQTT client connected!
Subscribing to: my/subscribe/topic len 18
Staring GPS application
at_commands[0] = AT%XSYSTEMMODE=1,0,1,0
at_commands[1] = AT%XMAGPIO=1,0,0,1,1,1574,1577
at_commands[2] = AT+CFUN=1
at_sock = 4
at_commands[i] = AT%XSYSTEMMODE=1,0,1,0
strlen(at_commands[i]) = 22
buf = ER
Error3
Failed to enable GPS
init_app fail
Getting GPS data...
---------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX