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

how to add gps_controller module at nrf9160

hi all,
the latest master fw-nrfconnect-nrf.
asset_tracker project gps_controller.
now ,i try add gps_control module to my project.
but it now work correct that gps_controller to callback gps_trigger_handler()
how to do it ?
HW:nrf9160-DK 0.8.5
SDK:latest master fw-nrfconnect-nrf.
prj :
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_NRF9160_GPS=y
CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
CONFIG_GPS_USE_EXTERNAL=y
CONFIG_GPS_DEV_NAME="NRF9160_GPS"
CONFIG_GPS_CONTROL=y
CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
CONFIG_GPS_CONTROL_FIX_TRY_TIME=90
CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP=n
# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
# BSD library
CONFIG_BSD_LIBRARY=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Kconfig:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2018 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
menu "GPS"
choice
prompt "GPS device"
default GPS_USE_SIM
help
Select from which device GPS data will be fetched.
config GPS_USE_SIM
bool "Use GPS simulator"
select GPS_SIM
select GPS_SIM_TRIGGER
help
Use simulated GPS data.
config GPS_USE_EXTERNAL
bool "User provided GPS device"
help
Provide a GPS device that location data will be fetched from and
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

main:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/
#include <zephyr.h>
#include <misc/printk.h>
#include <gps.h>
#include "gps_controller.h"
static struct k_delayed_work long_press_button_work;
static atomic_val_t send_data_enable;
static void gps_trigger_handler(struct device *dev, struct gps_trigger *trigger)
{
static u32_t fix_count;
ARG_UNUSED(trigger);
printk("get GPS count%d\n",fix_count);
if (++fix_count < CONFIG_GPS_CONTROL_FIX_COUNT) {
return;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • hi ,alseth

    i try to use mqtt and gps . 

     it can't get gps handle , and when entry PSM it seen also get mqtt.

    TTY : 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1266-g8711cfd5d348 *****
    [00:00:01.663,269] <dbg> nrf9160_gps.init: MAGPIO set: AT%XMAGPIO=1,0,0,1,1,1574,1577
    The MQTT simple sample started
    LTE Link Connecting ...
    LTE Link Connected!
    IPv4 Address found 52.59.134.73
    GPS initialized
    [mqtt_evt_handler:172] MQTT client connected!
    Subscribing to: my/sub/test len 11
    [mqtt_evt_handler:222] SUBACK packet id: 1234
    Starting GPS
    Enabling PSM
    PSM enabled
    [00:00:26.770,416] <dbg> nrf9160_gps.enable_gps: GPS mode is enabled
    [00:00:26.777,618] <dbg> nrf9160_gps.enable_gps: Functional mode: 1
    [00:00:26.784,729] <dbg> nrf9160_gps.start: GPS socket created
    [00:00:26.795,379] <dbg> nrf9160_gps.start: GPS operational
    GPS started successfully.
    Searching for satellites to get position fix. This may take several minutes.
    The device will attempt to get a fix for 180 seconds, before the GPS is stopped.
    GPS operation started
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    .config 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
    #
    # MQTT simple sample
    #
    CONFIG_MQTT_PUB_TOPIC="my/pub/test"
    CONFIG_MQTT_SUB_TOPIC="my/sub/test"
    CONFIG_MQTT_CLIENT_ID="89cb005b-7a23-4ad1-91c9-8e726711d92e"
    CONFIG_MQTT_BROKER_HOSTNAME="broker.mqttdashboard.com"
    CONFIG_MQTT_BROKER_PORT=1883
    CONFIG_MQTT_MESSAGE_BUFFER_SIZE=128
    CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=128
    # end of MQTT simple sample
    #
    # GPS
    #
    # CONFIG_GPS_USE_SIM is not set
    CONFIG_GPS_USE_EXTERNAL=y
    #
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * 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 <net/socket.h>
    #include <lte_lc.h>
    #include <gps.h>
    #include "gps_controller.h"
    /* Buffers for MQTT client. */
    static u8_t rx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    static u8_t tx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Reply
  • hi ,alseth

    i try to use mqtt and gps . 

     it can't get gps handle , and when entry PSM it seen also get mqtt.

    TTY : 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1266-g8711cfd5d348 *****
    [00:00:01.663,269] <dbg> nrf9160_gps.init: MAGPIO set: AT%XMAGPIO=1,0,0,1,1,1574,1577
    The MQTT simple sample started
    LTE Link Connecting ...
    LTE Link Connected!
    IPv4 Address found 52.59.134.73
    GPS initialized
    [mqtt_evt_handler:172] MQTT client connected!
    Subscribing to: my/sub/test len 11
    [mqtt_evt_handler:222] SUBACK packet id: 1234
    Starting GPS
    Enabling PSM
    PSM enabled
    [00:00:26.770,416] <dbg> nrf9160_gps.enable_gps: GPS mode is enabled
    [00:00:26.777,618] <dbg> nrf9160_gps.enable_gps: Functional mode: 1
    [00:00:26.784,729] <dbg> nrf9160_gps.start: GPS socket created
    [00:00:26.795,379] <dbg> nrf9160_gps.start: GPS operational
    GPS started successfully.
    Searching for satellites to get position fix. This may take several minutes.
    The device will attempt to get a fix for 180 seconds, before the GPS is stopped.
    GPS operation started
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    .config 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
    #
    # MQTT simple sample
    #
    CONFIG_MQTT_PUB_TOPIC="my/pub/test"
    CONFIG_MQTT_SUB_TOPIC="my/sub/test"
    CONFIG_MQTT_CLIENT_ID="89cb005b-7a23-4ad1-91c9-8e726711d92e"
    CONFIG_MQTT_BROKER_HOSTNAME="broker.mqttdashboard.com"
    CONFIG_MQTT_BROKER_PORT=1883
    CONFIG_MQTT_MESSAGE_BUFFER_SIZE=128
    CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=128
    # end of MQTT simple sample
    #
    # GPS
    #
    # CONFIG_GPS_USE_SIM is not set
    CONFIG_GPS_USE_EXTERNAL=y
    #
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * 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 <net/socket.h>
    #include <lte_lc.h>
    #include <gps.h>
    #include "gps_controller.h"
    /* Buffers for MQTT client. */
    static u8_t rx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    static u8_t tx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Children