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 :
#
# 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
# AT host library
CONFIG_AT_HOST_LIBRARY=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# Stacks and heaps
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=16384
# Disable native network stack to save some memory
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=n
CONFIG_NET_UDP=n
CONFIG_NET_TCP=n

Kconfig:
#
# 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
  sent to nRF Cloud
endchoice
rsource "src/gps_controller/Kconfig"
config GPS_DEV_NAME
 string "GPS device name"
 default GPS_SIM_DEV_NAME if GPS_USE_SIM
 help
  GPS device from which location data will be fetched and sent
  to nRF Cloud.
config GPS_TRIGGER
 bool
 default GPS_SIM_TRIGGER if GPS_USE_SIM
config GPS_SIM_TRIGGER_TIMER_MSEC
 int
 default 120000 if POWER_OPTIMIZATION_ENABLE
 default 2000
endmenu # GPS
menu "Zephyr Kernel"
source "$ZEPHYR_BASE/Kconfig.zephyr"
endmenu

main:
/*
 * 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;
 }
 printk("get  GPS then stop\n");
 fix_count = 0;
 
 gps_sample_fetch(dev);
 //gps_channel_get(dev, GPS_CHAN_NMEA, &gps_data);
 
 gps_control_stop(K_NO_WAIT);
 
}
static void long_press_handler(struct k_work *work)
{
 if (gps_control_is_enabled()) {
  printk("Stopping GPS\n");
  gps_control_disable();
 } else {
  printk("Starting GPS\n");
  gps_control_enable();
  gps_control_start(K_SECONDS(1));
 }
}
void initwork(void)
{
  k_delayed_work_init(&long_press_button_work, long_press_handler);
 gps_control_init(gps_trigger_handler);
k_delayed_work_submit(&long_press_button_work, K_SECONDS(5)); 
  return;
}
void main(void)
{
 printk("Hello World!\n");
        initwork();
        while(1)
        {
          k_sleep(K_MSEC(500));
        }
}

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 : 

    ***** 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
    [mqtt_evt_handler:187] MQTT PUBLISH result=0 len=9
    Received: test mqtt
    Publishing: test mqtt
    to topic: my/pub/test len: 11
    [mqtt_evt_handler:212] PUBACK packet id: 56248
    [00:03:26.819,671] <dbg> nrf9160_gps.stop: Stopping GPS
    GPS operation was stopped
    The device will try to get fix again in 30 seconds
    

    .config 

    # 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
    
    #
    # GPS_CONTROL
    #
    CONFIG_GPS_CONTROL=y
    CONFIG_GPS_CONTROL_ON_LONG_PRESS=y
    CONFIG_GPS_CONTROL_PSM_ENABLE_ON_START=y
    # CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP is not set
    CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
    CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
    CONFIG_GPS_CONTROL_FIX_TRY_TIME=180
    CONFIG_GPS_CONTROL_FIX_COUNT=3
    CONFIG_GPS_CONTROL_MAX_FAILED_FIX_ATTEMPTS=3
    # CONFIG_GPS_CONTROL_LOG_LEVEL_OFF is not set
    # CONFIG_GPS_CONTROL_LOG_LEVEL_ERR is not set
    # CONFIG_GPS_CONTROL_LOG_LEVEL_WRN is not set
    CONFIG_GPS_CONTROL_LOG_LEVEL_INF=y
    # CONFIG_GPS_CONTROL_LOG_LEVEL_DBG is not set
    CONFIG_GPS_CONTROL_LOG_LEVEL=3
    # end of GPS_CONTROL
    
    CONFIG_GPS_DEV_NAME="NRF9160_GPS"
    CONFIG_GPS_SIM_TRIGGER_TIMER_MSEC=2000
    # end of GPS
    
    #
    # Zephyr Kernel
    #
    
    #
    # Modules
    #
    
    #
    # Nordic nRF Connect
    #
    # CONFIG_SECURE_BOOT_CRYPTO_CLIENT is not set
    # CONFIG_SECURE_BOOT is not set
    
    #
    # Bluetooth Low Energy
    #
    # end of Bluetooth Low Energy
    
    # CONFIG_NRF_ESB is not set
    
    #
    # Networking
    #
    
    #
    # Application protocols
    #
    # CONFIG_MQTT_SOCKET_LIB is not set
    CONFIG_MQTT_KEEPALIVE=60
    # CONFIG_MQTT_LIB_TLS is not set
    # CONFIG_NRF_CLOUD is not set
    # CONFIG_DOWNLOAD_CLIENT is not set
    # CONFIG_FOTA_DOWNLOAD is not set
    # CONFIG_AWS_JOBS is not set
    # CONFIG_AWS_FOTA is not set
    # CONFIG_CLOUD_API is not set
    # end of Application protocols
    # end of Networking
    
    #
    # NFC
    #
    # CONFIG_NFC_NDEF is not set
    # CONFIG_NFC_NDEF_PARSER is not set
    # CONFIG_NFC_T2T_PARSER is not set
    # end of NFC
    
    # CONFIG_PROFILER is not set
    
    #
    # SPM
    #
    CONFIG_SPM=y
    # CONFIG_SPM_BUILD_STRATEGY_USE_HEX_FILE is not set
    # CONFIG_SPM_BUILD_STRATEGY_SKIP_BUILD is not set
    CONFIG_SPM_BUILD_STRATEGY_FROM_SOURCE=y
    # CONFIG_IS_SPM is not set
    # end of SPM
    
    CONFIG_ARM_ENTRY_VENEERS_LIB_NAME="libspmsecureentries.a"
    # CONFIG_FW_METADATA is not set
    # CONFIG_PPI_TRACE is not set
    
    #
    # Libraries
    #
    
    #
    # BSD Library for nrf91
    #
    CONFIG_BSD_LIBRARY=y
    CONFIG_BSD_LIBRARY_SYS_INIT=y
    # CONFIG_BSD_LIBRARY_TRACE_ENABLED is not set
    # end of BSD Library for nrf91
    
    #
    # AT Host Library for nrf91
    #
    CONFIG_AT_HOST_LIBRARY=y
    CONFIG_AT_HOST_UART_0=y
    # CONFIG_AT_HOST_UART_1 is not set
    # CONFIG_AT_HOST_UART_2 is not set
    CONFIG_AT_HOST_UART=0
    # CONFIG_NULL_TERMINATION is not set
    CONFIG_CR_TERMINATION=y
    # CONFIG_LF_TERMINATION is not set
    # CONFIG_CR_LF_TERMINATION is not set
    CONFIG_AT_HOST_TERMINATION=1
    # end of AT Host Library for nrf91
    
    # CONFIG_DK_LIBRARY is not set
    CONFIG_AT_CMD_PARSER=y
    # CONFIG_MODEM_INFO is not set
    # CONFIG_PDN_MANAGEMENT is not set
    # end of Libraries
    
    #
    # Device Drivers
    #
    # CONFIG_ADP536X is not set
    
    #
    # AT Command driver
    #
    CONFIG_AT_CMD=y
    CONFIG_AT_CMD_SYS_INIT=y
    CONFIG_AT_CMD_INIT_PRIORITY=40
    CONFIG_AT_CMD_THREAD_PRIO=10
    CONFIG_AT_CMD_THREAD_STACK_SIZE=1024
    CONFIG_AT_CMD_RESPONSE_MAX_LEN=1792
    # CONFIG_AT_CMD_LOG_LEVEL_OFF is not set
    # CONFIG_AT_CMD_LOG_LEVEL_ERR is not set
    # CONFIG_AT_CMD_LOG_LEVEL_WRN is not set
    CONFIG_AT_CMD_LOG_LEVEL_INF=y
    # CONFIG_AT_CMD_LOG_LEVEL_DBG is not set
    CONFIG_AT_CMD_LOG_LEVEL=3
    # end of AT Command driver
    
    # CONFIG_GPS_SIM is not set
    CONFIG_NRF9160_GPS=y
    CONFIG_NRF9160_GPS_DEV_NAME="NRF9160_GPS"
    CONFIG_NRF9160_GPS_FIX_CHECK_INTERVAL=1
    CONFIG_NRF9160_GPS_SET_MAGPIO=y
    CONFIG_NRF9160_GPS_MAGPIO_STRING="AT%XMAGPIO=1,0,0,1,1,1574,1577"
    
    #
    # NMEA strings
    #
    # CONFIG_NRF9160_GPS_NMEA_GSV is not set
    # CONFIG_NRF9160_GPS_NMEA_GSA is not set
    # CONFIG_NRF9160_GPS_NMEA_GLL is not set
    CONFIG_NRF9160_GPS_NMEA_GGA=y
    # CONFIG_NRF9160_GPS_NMEA_RMC is not set
    # end of NMEA strings
    
    CONFIG_NRF9160_GPS_INIT_PRIO=90
    CONFIG_NRF9160_GPS_THREAD_PRIORITY=10
    CONFIG_NRF9160_GPS_THREAD_STACK_SIZE=2048
    # CONFIG_NRF9160_GPS_LOG_LEVEL_OFF is not set
    # CONFIG_NRF9160_GPS_LOG_LEVEL_ERR is not set
    # CONFIG_NRF9160_GPS_LOG_LEVEL_WRN is not set
    # CONFIG_NRF9160_GPS_LOG_LEVEL_INF is not set
    CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
    CONFIG_NRF9160_GPS_LOG_LEVEL=4
    CONFIG_LTE_LINK_CONTROL=y
    # CONFIG_LTE_AUTO_INIT_AND_CONNECT is not set
    # CONFIG_LTE_LOCK_BANDS is not set
    CONFIG_LTE_PSM_REQ_RPTAU="00000011"
    CONFIG_LTE_PSM_REQ_RAT="00100001"
    # CONFIG_LTE_EDRX_REQ is not set
    CONFIG_LTE_EDRX_REQ_ACTT_TYPE="4"
    CONFIG_LTE_EDRX_REQ_VALUE="1000"
    # CONFIG_LTE_LEGACY_PCO_MODE is not set
    # CONFIG_LTE_PDP_CMD is not set
    CONFIG_LTE_NETWORK_MODE_LTE_M=y
    # CONFIG_LTE_NETWORK_MODE_NBIOT is not set
    # CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_OFF is not set
    # CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_ERR is not set
    # CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_WRN is not set
    CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_INF=y
    # CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG is not set
    CONFIG_LTE_LINK_CONTROL_LOG_LEVEL=3
    # CONFIG_ETH_RTT is not set
    # CONFIG_SENSOR is not set
    # CONFIG_ST25R3911B_LIB is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC is not set
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_BLOCKING is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_250PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_150PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_100PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_75PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_50PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_30PPM is not set
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_20PPM=y
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_10PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_5PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_2PPM is not set
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_1PPM is not set
    # end of Device Drivers
    
    #
    # External libraries
    #
    # CONFIG_CJSON_LIB is not set
    # end of External libraries
    
    # CONFIG_UNITY is not set
    # end of Nordic nRF Connect
    
    #
    # MCUboot
    #
    CONFIG_BOOT_SIGNATURE_KEY_FILE="root-rsa-2048.pem"
    # end of MCUboot
    
    #
    # Nordic nrfxlib
    #
    CONFIG_BSD_LIB=y
    # CONFIG_NRFXLIB_NFC is not set
    
    #
    # Crypto libraries for nRF5x SOCs.
    #
    CONFIG_NRFXLIB_CRYPTO=y
    CONFIG_NRF_OBERON=y
    # CONFIG_NRF_CC310_BL is not set
    # end of Crypto libraries for nRF5x SOCs.
    
    #
    # Nordic Security
    #
    # CONFIG_NORDIC_SECURITY_BACKEND is not set
    # end of Nordic Security
    # end of Nordic nrfxlib
    
    #
    # Optional modules. Make sure they're installed, via the project manifest.
    #
    # CONFIG_CIVETWEB is not set
    # CONFIG_LIBMETAL is not set
    # CONFIG_MBEDTLS is not set
    # CONFIG_MBEDTLS_TLS_VERSION_1_0 is not set
    # CONFIG_MBEDTLS_TLS_VERSION_1_1 is not set
    CONFIG_MBEDTLS_TLS_VERSION_1_2=y
    # CONFIG_MBEDTLS_DTLS is not set
    # CONFIG_MBEDTLS_SSL_EXPORT_KEYS is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ALL_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED is not set
    CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED=y
    # CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED is not set
    # CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_ALL_ENABLED is not set
    CONFIG_MBEDTLS_CIPHER_AES_ENABLED=y
    CONFIG_MBEDTLS_AES_ROM_TABLES=y
    # CONFIG_MBEDTLS_CIPHER_CAMELLIA_ENABLED is not set
    CONFIG_MBEDTLS_CIPHER_DES_ENABLED=y
    # CONFIG_MBEDTLS_CIPHER_ARC4_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_CHACHA20_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_BLOWFISH_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_CCM_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_MODE_XTS_ENABLED is not set
    # CONFIG_MBEDTLS_CIPHER_MODE_GCM_ENABLED is not set
    CONFIG_MBEDTLS_CIPHER_CBC_ENABLED=y
    # CONFIG_MBEDTLS_MAC_ALL_ENABLED is not set
    # CONFIG_MBEDTLS_MAC_MD4_ENABLED is not set
    CONFIG_MBEDTLS_MAC_MD5_ENABLED=y
    CONFIG_MBEDTLS_MAC_SHA1_ENABLED=y
    CONFIG_MBEDTLS_MAC_SHA256_ENABLED=y
    CONFIG_MBEDTLS_SHA256_SMALLER=y
    # CONFIG_MBEDTLS_MAC_SHA512_ENABLED is not set
    # CONFIG_MBEDTLS_MAC_POLY1305_ENABLED is not set
    # CONFIG_MBEDTLS_MAC_CMAC_ENABLED is not set
    CONFIG_MBEDTLS_CTR_DRBG_ENABLED=y
    # CONFIG_MBEDTLS_HMAC_DRBG_ENABLED is not set
    # CONFIG_MBEDTLS_GENPRIME_ENABLED is not set
    # CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT is not set
    # CONFIG_MBEDTLS_HAVE_ASM is not set
    # CONFIG_MBEDTLS_ENTROPY_ENABLED is not set
    # CONFIG_MBEDTLS_USER_CONFIG_ENABLE is not set
    # CONFIG_OPENAMP is not set
    
    #
    # QMSI
    #
    # end of QMSI
    
    # CONFIG_TINYCBOR is not set
    
    #
    # TLS configuration
    #
    
    #
    # Supported TLS version
    #
    # end of Supported TLS version
    
    #
    # Ciphersuite configuration
    #
    
    #
    # Supported key exchange modes
    #
    
    #
    # Supported cipher modes
    #
    
    #
    # Supported message authentication methods
    #
    # end of Ciphersuite configuration
    
    #
    # Random number generators
    #
    
    #
    # Other configurations
    #
    # end of TLS configuration
    # end of Modules
    
    CONFIG_BOARD="nrf9160_pca10090"
    CONFIG_FLASH_LOAD_SIZE=0x40000
    CONFIG_FLASH_LOAD_OFFSET=0x40000
    CONFIG_SOC="nRF9160_SICA"
    CONFIG_SOC_SERIES="nrf91"
    CONFIG_NUM_IRQS=65
    CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768
    # CONFIG_WATCHDOG is not set
    # CONFIG_UART_NS16550 is not set
    CONFIG_GPIO=y
    CONFIG_ISR_STACK_SIZE=2048
    CONFIG_CLOCK_CONTROL=y
    CONFIG_NRF_RTC_TIMER=y
    CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
    CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT=y
    CONFIG_SYS_POWER_MANAGEMENT=y
    CONFIG_BUILD_OUTPUT_HEX=y
    CONFIG_TEXT_SECTION_OFFSET=0
    CONFIG_FLASH_SIZE=1024
    CONFIG_FLASH_BASE_ADDRESS=0x0
    CONFIG_SRAM_SIZE=128
    CONFIG_SRAM_BASE_ADDRESS=0x20020000
    # CONFIG_SPI is not set
    # CONFIG_NET_L2_IEEE802154 is not set
    CONFIG_SOC_GECKO_EMU=y
    # CONFIG_BOARD_NRF9160_PCA10090 is not set
    CONFIG_BOARD_NRF9160_PCA10090NS=y
    
    #
    # Board Options
    #
    # CONFIG_BOARD_NRF52840_GPIO_RESET is not set
    # end of Board Options
    
    # CONFIG_SOC_SERIES_BEETLE is not set
    # CONFIG_SOC_SERIES_MPS2 is not set
    # CONFIG_SOC_SERIES_MUSCA is not set
    # CONFIG_SOC_SERIES_MUSCA_B1 is not set
    # CONFIG_SOC_SERIES_SAMD20 is not set
    # CONFIG_SOC_SERIES_SAMD21 is not set
    # CONFIG_SOC_SERIES_SAMR21 is not set
    # CONFIG_SOC_SERIES_SAM3X is not set
    # CONFIG_SOC_SERIES_SAM4S is not set
    # CONFIG_SOC_SERIES_SAME70 is not set
    # CONFIG_SOC_SERIES_PSOC62 is not set
    # CONFIG_SOC_SERIES_MEC1501X is not set
    # CONFIG_SOC_SERIES_MEC1701X is not set
    # CONFIG_SOC_SERIES_NRF51X is not set
    # CONFIG_SOC_SERIES_NRF52X is not set
    CONFIG_SOC_SERIES_NRF91X=y
    # CONFIG_SOC_SERIES_IMX_6X_M4 is not set
    # CONFIG_SOC_SERIES_IMX7_M4 is not set
    # CONFIG_SOC_SERIES_IMX_RT is not set
    # CONFIG_SOC_SERIES_KINETIS_K6X is not set
    # CONFIG_SOC_SERIES_KINETIS_KE1XF is not set
    # CONFIG_SOC_SERIES_KINETIS_KL2X is not set
    # CONFIG_SOC_SERIES_KINETIS_KWX is not set
    # CONFIG_SOC_SERIES_LPC54XXX is not set
    # CONFIG_SOC_SERIES_LPC55XXX is not set
    # CONFIG_SOC_SERIES_EFM32HG is not set
    # CONFIG_SOC_SERIES_EFM32PG12B is not set
    # CONFIG_SOC_SERIES_EFM32WG is not set
    # CONFIG_SOC_SERIES_EFR32FG1P is not set
    # CONFIG_SOC_SERIES_EFR32MG12P is not set
    # CONFIG_SOC_SERIES_STM32F0X is not set
    # CONFIG_SOC_SERIES_STM32F1X is not set
    # CONFIG_SOC_SERIES_STM32F2X is not set
    # CONFIG_SOC_SERIES_STM32F3X is not set
    # CONFIG_SOC_SERIES_STM32F4X is not set
    # CONFIG_SOC_SERIES_STM32F7X is not set
    # CONFIG_SOC_SERIES_STM32G0X is not set
    # CONFIG_SOC_SERIES_STM32H7X is not set
    # CONFIG_SOC_SERIES_STM32L0X is not set
    # CONFIG_SOC_SERIES_STM32L1X is not set
    # CONFIG_SOC_SERIES_STM32L4X is not set
    # CONFIG_SOC_SERIES_STM32MP1X is not set
    # CONFIG_SOC_SERIES_STM32WBX is not set
    # CONFIG_SOC_TI_LM3S6965 is not set
    # CONFIG_SOC_SERIES_CC13X2_CC26X2 is not set
    # CONFIG_SOC_SERIES_CC2650 is not set
    # CONFIG_SOC_SERIES_CC32XX is not set
    # CONFIG_SOC_SERIES_MSP432P4XX is not set
    
    #
    # Hardware Configuration
    #
    CONFIG_CPU_HAS_ARM_MPU=y
    CONFIG_CPU_HAS_NRF_IDAU=y
    CONFIG_SOC_FAMILY="nordic_nrf"
    CONFIG_SOC_FAMILY_NRF=y
    CONFIG_HAS_HW_NRF_CC310=y
    CONFIG_HAS_HW_NRF_CLOCK=y
    CONFIG_HAS_HW_NRF_DPPIC=y
    CONFIG_HAS_HW_NRF_EGU0=y
    CONFIG_HAS_HW_NRF_EGU1=y
    CONFIG_HAS_HW_NRF_EGU2=y
    CONFIG_HAS_HW_NRF_EGU3=y
    CONFIG_HAS_HW_NRF_EGU4=y
    CONFIG_HAS_HW_NRF_EGU5=y
    CONFIG_HAS_HW_NRF_GPIO0=y
    CONFIG_HAS_HW_NRF_GPIOTE=y
    CONFIG_HAS_HW_NRF_I2S=y
    CONFIG_HAS_HW_NRF_IPC=y
    CONFIG_HAS_HW_NRF_PDM=y
    CONFIG_HAS_HW_NRF_POWER=y
    CONFIG_HAS_HW_NRF_PWM0=y
    CONFIG_HAS_HW_NRF_PWM1=y
    CONFIG_HAS_HW_NRF_PWM2=y
    CONFIG_HAS_HW_NRF_PWM3=y
    CONFIG_HAS_HW_NRF_RTC0=y
    CONFIG_HAS_HW_NRF_RTC1=y
    CONFIG_HAS_HW_NRF_SAADC=y
    CONFIG_HAS_HW_NRF_SPIM0=y
    CONFIG_HAS_HW_NRF_SPIM1=y
    CONFIG_HAS_HW_NRF_SPIM2=y
    CONFIG_HAS_HW_NRF_SPIM3=y
    CONFIG_HAS_HW_NRF_SPIS0=y
    CONFIG_HAS_HW_NRF_SPIS1=y
    CONFIG_HAS_HW_NRF_SPIS2=y
    CONFIG_HAS_HW_NRF_SPIS3=y
    CONFIG_HAS_HW_NRF_SPU=y
    CONFIG_HAS_HW_NRF_TIMER0=y
    CONFIG_HAS_HW_NRF_TIMER1=y
    CONFIG_HAS_HW_NRF_TIMER2=y
    CONFIG_HAS_HW_NRF_TWIM0=y
    CONFIG_HAS_HW_NRF_TWIM1=y
    CONFIG_HAS_HW_NRF_TWIM2=y
    CONFIG_HAS_HW_NRF_TWIM3=y
    CONFIG_HAS_HW_NRF_TWIS0=y
    CONFIG_HAS_HW_NRF_TWIS1=y
    CONFIG_HAS_HW_NRF_TWIS2=y
    CONFIG_HAS_HW_NRF_TWIS3=y
    CONFIG_HAS_HW_NRF_UARTE0=y
    CONFIG_HAS_HW_NRF_UARTE1=y
    CONFIG_HAS_HW_NRF_UARTE2=y
    CONFIG_HAS_HW_NRF_UARTE3=y
    CONFIG_HAS_HW_NRF_WDT=y
    CONFIG_GPIO_AS_PINRESET=y
    CONFIG_NRF_ENABLE_ICACHE=y
    CONFIG_SOC_NRF9160=y
    CONFIG_SOC_NRF9160_SICA=y
    # CONFIG_SOC_LOG_LEVEL_OFF is not set
    # CONFIG_SOC_LOG_LEVEL_ERR is not set
    # CONFIG_SOC_LOG_LEVEL_WRN is not set
    CONFIG_SOC_LOG_LEVEL_INF=y
    # CONFIG_SOC_LOG_LEVEL_DBG is not set
    CONFIG_SOC_LOG_LEVEL=3
    # end of Hardware Configuration
    
    CONFIG_SOC_COMPATIBLE_NRF=y
    
    #
    # ARM Options
    #
    CONFIG_CPU_CORTEX=y
    CONFIG_CPU_CORTEX_M=y
    # CONFIG_BUILTIN_STACK_GUARD is not set
    CONFIG_ARM_NONSECURE_FIRMWARE=y
    
    #
    # ARM TrustZone Options
    #
    
    #
    # Non-secure firmware
    #
    CONFIG_ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS=y
    # end of ARM TrustZone Options
    
    #
    # Architecture Floating Point Options
    #
    CONFIG_FP_HARDABI=y
    # CONFIG_FP_SOFTABI is not set
    # end of Architecture Floating Point Options
    
    CONFIG_CPU_CORTEX_M33=y
    CONFIG_ISA_THUMB2=y
    CONFIG_CPU_CORTEX_M_HAS_SYSTICK=y
    CONFIG_CPU_CORTEX_M_HAS_BASEPRI=y
    CONFIG_CPU_CORTEX_M_HAS_VTOR=y
    CONFIG_CPU_CORTEX_M_HAS_SPLIM=y
    CONFIG_CPU_CORTEX_M_HAS_PROGRAMMABLE_FAULT_PRIOS=y
    CONFIG_CPU_CORTEX_M_HAS_CMSE=y
    CONFIG_ARMV7_M_ARMV8_M_MAINLINE=y
    CONFIG_ARMV8_M_MAINLINE=y
    CONFIG_ARMV8_M_SE=y
    CONFIG_ARMV7_M_ARMV8_M_FP=y
    CONFIG_ARMV8_M_DSP=y
    
    #
    # ARM Cortex-M options
    #
    CONFIG_LDREX_STREX_AVAILABLE=y
    CONFIG_DATA_ENDIANNESS_LITTLE=y
    CONFIG_STACK_ALIGN_DOUBLE_WORD=y
    # CONFIG_RUNTIME_NMI is not set
    CONFIG_FAULT_DUMP=2
    CONFIG_XIP=y
    # end of ARM Cortex-M options
    
    #
    # ARM Cortex-M0/M0+/M3/M4/M7/M23/M33 options
    #
    CONFIG_GEN_ISR_TABLES=y
    # CONFIG_ZERO_LATENCY_IRQS is not set
    CONFIG_PLATFORM_SPECIFIC_INIT=y
    # end of ARM Cortex-M0/M0+/M3/M4/M7/M23/M33 options
    
    CONFIG_ARM_MPU=y
    CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE=32
    # CONFIG_MPU_STACK_GUARD is not set
    # CONFIG_MPU_ALLOW_FLASH_WRITE is not set
    CONFIG_ARM_TRUSTZONE_M=y
    CONFIG_ARCH="arm"
    # end of ARM Options
    
    # CONFIG_ARC is not set
    CONFIG_ARM=y
    # CONFIG_X86 is not set
    # CONFIG_X86_64 is not set
    # CONFIG_NIOS2 is not set
    # CONFIG_RISCV is not set
    # CONFIG_XTENSA is not set
    # CONFIG_ARCH_POSIX is not set
    
    #
    # General Architecture Options
    #
    # CONFIG_ARCH_LOG_LEVEL_OFF is not set
    # CONFIG_ARCH_LOG_LEVEL_ERR is not set
    # CONFIG_ARCH_LOG_LEVEL_WRN is not set
    CONFIG_ARCH_LOG_LEVEL_INF=y
    # CONFIG_ARCH_LOG_LEVEL_DBG is not set
    CONFIG_ARCH_LOG_LEVEL=3
    # CONFIG_MPU_LOG_LEVEL_OFF is not set
    # CONFIG_MPU_LOG_LEVEL_ERR is not set
    # CONFIG_MPU_LOG_LEVEL_WRN is not set
    CONFIG_MPU_LOG_LEVEL_INF=y
    # CONFIG_MPU_LOG_LEVEL_DBG is not set
    CONFIG_MPU_LOG_LEVEL=3
    # CONFIG_TRUSTED_EXECUTION_SECURE is not set
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    # CONFIG_HW_STACK_PROTECTION is not set
    # CONFIG_USERSPACE is not set
    CONFIG_PRIVILEGED_STACK_SIZE=1024
    CONFIG_PRIVILEGED_STACK_TEXT_AREA=256
    CONFIG_KOBJECT_TEXT_AREA=256
    # CONFIG_STACK_GROWS_UP is not set
    
    #
    # Interrupt Configuration
    #
    # CONFIG_DYNAMIC_INTERRUPTS is not set
    CONFIG_GEN_IRQ_VECTOR_TABLE=y
    CONFIG_GEN_SW_ISR_TABLE=y
    CONFIG_ARCH_SW_ISR_TABLE_ALIGN=0
    CONFIG_GEN_IRQ_START_VECTOR=0
    # CONFIG_IRQ_OFFLOAD is not set
    # end of Interrupt Configuration
    # end of General Architecture Options
    
    CONFIG_ARCH_HAS_TRUSTED_EXECUTION=y
    CONFIG_ARCH_HAS_STACK_PROTECTION=y
    CONFIG_ARCH_HAS_USERSPACE=y
    CONFIG_ARCH_HAS_EXECUTABLE_PAGE_BIT=y
    CONFIG_ARCH_HAS_RAMFUNC_SUPPORT=y
    CONFIG_ARCH_HAS_THREAD_ABORT=y
    CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1=y
    CONFIG_CPU_HAS_TEE=y
    CONFIG_CPU_HAS_FPU=y
    CONFIG_CPU_HAS_MPU=y
    CONFIG_MEMORY_PROTECTION=y
    CONFIG_MPU_REQUIRES_NON_OVERLAPPING_REGIONS=y
    CONFIG_FLOAT=y
    CONFIG_FP_SHARING=y
    
    #
    # General Kernel Options
    #
    # CONFIG_KERNEL_LOG_LEVEL_OFF is not set
    # CONFIG_KERNEL_LOG_LEVEL_ERR is not set
    # CONFIG_KERNEL_LOG_LEVEL_WRN is not set
    CONFIG_KERNEL_LOG_LEVEL_INF=y
    # CONFIG_KERNEL_LOG_LEVEL_DBG is not set
    CONFIG_KERNEL_LOG_LEVEL=3
    CONFIG_MULTITHREADING=y
    CONFIG_NUM_COOP_PRIORITIES=16
    CONFIG_NUM_PREEMPT_PRIORITIES=15
    CONFIG_MAIN_THREAD_PRIORITY=7
    CONFIG_COOP_ENABLED=y
    CONFIG_PREEMPT_ENABLED=y
    CONFIG_PRIORITY_CEILING=0
    CONFIG_NUM_METAIRQ_PRIORITIES=0
    # CONFIG_SCHED_DEADLINE is not set
    # CONFIG_SCHED_CPU_MASK is not set
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_IDLE_STACK_SIZE=320
    CONFIG_THREAD_STACK_INFO=y
    # CONFIG_THREAD_CUSTOM_DATA is not set
    CONFIG_ERRNO=y
    CONFIG_SCHED_DUMB=y
    # CONFIG_SCHED_SCALABLE is not set
    # CONFIG_SCHED_MULTIQ is not set
    # CONFIG_WAITQ_SCALABLE is not set
    CONFIG_WAITQ_DUMB=y
    
    #
    # Kernel Debugging and Metrics
    #
    # CONFIG_INIT_STACKS is not set
    # CONFIG_KERNEL_DEBUG is not set
    CONFIG_BOOT_BANNER=y
    CONFIG_BOOT_DELAY=0
    # CONFIG_EXECUTION_BENCHMARKING is not set
    # CONFIG_THREAD_MONITOR is not set
    # CONFIG_THREAD_NAME is not set
    # end of Kernel Debugging and Metrics
    
    #
    # Work Queue Options
    #
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1024
    CONFIG_SYSTEM_WORKQUEUE_PRIORITY=-1
    CONFIG_OFFLOAD_WORKQUEUE_STACK_SIZE=1024
    CONFIG_OFFLOAD_WORKQUEUE_PRIORITY=-1
    # end of Work Queue Options
    
    #
    # Atomic Operations
    #
    CONFIG_ATOMIC_OPERATIONS_BUILTIN=y
    # end of Atomic Operations
    
    #
    # Timer API Options
    #
    CONFIG_TIMESLICING=y
    CONFIG_TIMESLICE_SIZE=0
    CONFIG_TIMESLICE_PRIORITY=0
    CONFIG_POLL=y
    # end of Timer API Options
    
    #
    # Other Kernel Object Options
    #
    CONFIG_NUM_MBOX_ASYNC_MSGS=10
    CONFIG_NUM_PIPE_ASYNC_MSGS=10
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    CONFIG_HEAP_MEM_POOL_MIN_SIZE=64
    # end of Other Kernel Object Options
    
    CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN=y
    CONFIG_SWAP_NONATOMIC=y
    CONFIG_SYS_CLOCK_EXISTS=y
    
    #
    # Initialization Priorities
    #
    CONFIG_KERNEL_INIT_PRIORITY_OBJECTS=30
    CONFIG_KERNEL_INIT_PRIORITY_DEFAULT=40
    CONFIG_KERNEL_INIT_PRIORITY_DEVICE=50
    CONFIG_APPLICATION_INIT_PRIORITY=90
    # end of Initialization Priorities
    
    #
    # Security Options
    #
    # CONFIG_STACK_CANARIES is not set
    CONFIG_STACK_POINTER_RANDOM=0
    # end of Security Options
    
    #
    # SMP Options
    #
    CONFIG_MP_NUM_CPUS=1
    # CONFIG_SCHED_IPI_SUPPORTED is not set
    # end of SMP Options
    
    CONFIG_TICKLESS_IDLE=y
    CONFIG_TICKLESS_IDLE_THRESH=3
    CONFIG_TICKLESS_KERNEL=y
    # CONFIG_SYS_POWER_DEEP_SLEEP_STATES is not set
    # CONFIG_SYS_PM_STATE_LOCK is not set
    # CONFIG_SYS_PM_DEBUG is not set
    CONFIG_SYS_PM_POLICY_RESIDENCY=y
    # CONFIG_SYS_PM_POLICY_DUMMY is not set
    # CONFIG_SYS_PM_POLICY_APP is not set
    CONFIG_SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_1=60000
    # CONFIG_SYS_PM_LOG_LEVEL_OFF is not set
    # CONFIG_SYS_PM_LOG_LEVEL_ERR is not set
    # CONFIG_SYS_PM_LOG_LEVEL_WRN is not set
    CONFIG_SYS_PM_LOG_LEVEL_INF=y
    # CONFIG_SYS_PM_LOG_LEVEL_DBG is not set
    CONFIG_SYS_PM_LOG_LEVEL=3
    # CONFIG_DEVICE_POWER_MANAGEMENT is not set
    # end of General Kernel Options
    
    CONFIG_HAS_DTS=y
    CONFIG_HAS_DTS_GPIO=y
    
    #
    # Device Drivers
    #
    # CONFIG_IEEE802154 is not set
    CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0"
    CONFIG_CONSOLE=y
    CONFIG_CONSOLE_INPUT_MAX_LINE_LEN=128
    CONFIG_CONSOLE_HAS_DRIVER=y
    # CONFIG_CONSOLE_HANDLER is not set
    CONFIG_UART_CONSOLE=y
    CONFIG_UART_CONSOLE_INIT_PRIORITY=60
    # CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS is not set
    # CONFIG_UART_CONSOLE_MCUMGR is not set
    # CONFIG_USB_UART_CONSOLE is not set
    # CONFIG_RAM_CONSOLE is not set
    # CONFIG_IPM_CONSOLE_SENDER is not set
    # CONFIG_IPM_CONSOLE_RECEIVER is not set
    # CONFIG_UART_PIPE is not set
    # CONFIG_UART_MCUMGR is not set
    # CONFIG_UART_CONSOLE_LOG_LEVEL_OFF is not set
    # CONFIG_UART_CONSOLE_LOG_LEVEL_ERR is not set
    # CONFIG_UART_CONSOLE_LOG_LEVEL_WRN is not set
    CONFIG_UART_CONSOLE_LOG_LEVEL_INF=y
    # CONFIG_UART_CONSOLE_LOG_LEVEL_DBG is not set
    CONFIG_UART_CONSOLE_LOG_LEVEL=3
    # CONFIG_SLIP is not set
    # CONFIG_NET_LOOPBACK is not set
    CONFIG_SERIAL=y
    
    #
    # Capabilities
    #
    CONFIG_SERIAL_HAS_DRIVER=y
    CONFIG_SERIAL_SUPPORT_ASYNC=y
    CONFIG_SERIAL_SUPPORT_INTERRUPT=y
    # CONFIG_UART_ASYNC_API is not set
    CONFIG_UART_INTERRUPT_DRIVEN=y
    # CONFIG_UART_LINE_CTRL is not set
    # CONFIG_UART_DRV_CMD is not set
    
    #
    # Serial Drivers
    #
    # CONFIG_UART_NSIM is not set
    CONFIG_UART_NRFX=y
    CONFIG_UART_0_NRF_UARTE=y
    CONFIG_UART_0_INTERRUPT_DRIVEN=y
    # CONFIG_UART_0_NRF_PARITY_BIT is not set
    # CONFIG_UART_0_NRF_FLOW_CONTROL is not set
    CONFIG_UART_0_NRF_TX_BUFFER_SIZE=32
    # CONFIG_UART_1_NRF_UARTE is not set
    # CONFIG_UART_2_NRF_UARTE is not set
    # CONFIG_UART_3_NRF_UARTE is not set
    CONFIG_NRF_UARTE_PERIPHERAL=y
    # CONFIG_UART_ALTERA_JTAG is not set
    
    #
    # Interrupt Controllers
    #
    # CONFIG_MULTI_LEVEL_INTERRUPTS is not set
    # end of Interrupt Controllers
    
    #
    # Timer Drivers
    #
    # CONFIG_CORTEX_M_SYSTICK is not set
    CONFIG_SYSTEM_CLOCK_DISABLE=y
    # CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME is not set
    # CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE is not set
    CONFIG_SYSTEM_CLOCK_INIT_PRIORITY=0
    CONFIG_TICKLESS_CAPABLE=y
    # end of Timer Drivers
    
    CONFIG_ENTROPY_GENERATOR=y
    # CONFIG_ENTROPY_NRF5_RNG is not set
    CONFIG_ENTROPY_NAME="ENTROPY_0"
    # CONFIG_GPIO_LOG_LEVEL_OFF is not set
    # CONFIG_GPIO_LOG_LEVEL_ERR is not set
    # CONFIG_GPIO_LOG_LEVEL_WRN is not set
    CONFIG_GPIO_LOG_LEVEL_INF=y
    # CONFIG_GPIO_LOG_LEVEL_DBG is not set
    CONFIG_GPIO_LOG_LEVEL=3
    # CONFIG_GPIO_SHELL is not set
    # CONFIG_GPIO_DW is not set
    # CONFIG_GPIO_SCH is not set
    CONFIG_GPIO_NRFX=y
    CONFIG_GPIO_NRF_INIT_PRIORITY=40
    CONFIG_GPIO_NRF_P0=y
    # CONFIG_GPIO_INTEL_APL is not set
    # CONFIG_SHARED_IRQ is not set
    # CONFIG_I2C is not set
    # CONFIG_I2S is not set
    # CONFIG_PWM is not set
    # CONFIG_PINMUX is not set
    # CONFIG_ADC is not set
    # CONFIG_RTC is not set
    # CONFIG_CLOCK_CONTROL_LOG_LEVEL_OFF is not set
    # CONFIG_CLOCK_CONTROL_LOG_LEVEL_ERR is not set
    # CONFIG_CLOCK_CONTROL_LOG_LEVEL_WRN is not set
    CONFIG_CLOCK_CONTROL_LOG_LEVEL_INF=y
    # CONFIG_CLOCK_CONTROL_LOG_LEVEL_DBG is not set
    CONFIG_CLOCK_CONTROL_LOG_LEVEL=3
    CONFIG_CLOCK_CONTROL_NRF=y
    # CONFIG_PTP_CLOCK is not set
    # CONFIG_IPM is not set
    # CONFIG_IPM_LOG_LEVEL_OFF is not set
    # CONFIG_IPM_LOG_LEVEL_ERR is not set
    # CONFIG_IPM_LOG_LEVEL_WRN is not set
    CONFIG_IPM_LOG_LEVEL_INF=y
    # CONFIG_IPM_LOG_LEVEL_DBG is not set
    CONFIG_IPM_LOG_LEVEL=3
    # CONFIG_FLASH is not set
    # CONFIG_COUNTER is not set
    # CONFIG_DMA is not set
    # CONFIG_USB is not set
    # CONFIG_CRYPTO is not set
    # CONFIG_DISPLAY is not set
    # CONFIG_LED_STRIP is not set
    # CONFIG_WIFI is not set
    # CONFIG_LED is not set
    # CONFIG_CAN is not set
    # CONFIG_MODEM is not set
    # CONFIG_AUDIO is not set
    # CONFIG_NEURAL_NET_ACCEL is not set
    # CONFIG_HWINFO is not set
    # CONFIG_ESPI is not set
    # end of Device Drivers
    
    #
    # C Library
    #
    CONFIG_NEWLIB_LIBC=y
    # CONFIG_NEWLIB_LIBC_FLOAT_PRINTF is not set
    # CONFIG_NEWLIB_LIBC_FLOAT_SCANF is not set
    CONFIG_STDOUT_CONSOLE=y
    # end of C Library
    
    #
    # Additional libraries
    #
    # CONFIG_LVGL is not set
    
    #
    # OS Support Library
    #
    # CONFIG_JSON_LIBRARY is not set
    # CONFIG_RING_BUFFER is not set
    # CONFIG_BASE64 is not set
    # end of OS Support Library
    
    CONFIG_POSIX_MAX_FDS=4
    # CONFIG_POSIX_API is not set
    # CONFIG_UPDATEHUB is not set
    # CONFIG_UPDATEHUB_LOG_LEVEL_OFF is not set
    # CONFIG_UPDATEHUB_LOG_LEVEL_ERR is not set
    # CONFIG_UPDATEHUB_LOG_LEVEL_WRN is not set
    CONFIG_UPDATEHUB_LOG_LEVEL_INF=y
    # CONFIG_UPDATEHUB_LOG_LEVEL_DBG is not set
    CONFIG_UPDATEHUB_LOG_LEVEL=3
    # end of Additional libraries
    
    # CONFIG_BT is not set
    # CONFIG_CONSOLE_SUBSYS is not set
    # CONFIG_CPLUSPLUS is not set
    
    #
    # System Monitoring Options
    #
    # CONFIG_PERFORMANCE_METRICS is not set
    # CONFIG_STATS is not set
    # end of System Monitoring Options
    
    #
    # Debugging Options
    #
    # CONFIG_DEBUG is not set
    # CONFIG_TRACING is not set
    # CONFIG_STACK_USAGE is not set
    # CONFIG_STACK_SENTINEL is not set
    CONFIG_PRINTK=y
    CONFIG_EARLY_CONSOLE=y
    # CONFIG_ASSERT is not set
    # CONFIG_FORCE_NO_ASSERT is not set
    # CONFIG_OBJECT_TRACING is not set
    # CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT is not set
    # CONFIG_DEBUG_INFO is not set
    # CONFIG_OPENOCD_SUPPORT is not set
    # CONFIG_TRACING_CPU_STATS is not set
    # CONFIG_TRACING_CTF is not set
    CONFIG_HAS_SEGGER_RTT=y
    # CONFIG_USE_SEGGER_RTT is not set
    # end of Debugging Options
    
    # CONFIG_DISK_ACCESS is not set
    
    #
    # File Systems
    #
    # CONFIG_FILE_SYSTEM is not set
    CONFIG_FS_LITTLEFS_NUM_FILES=4
    CONFIG_FS_LITTLEFS_NUM_DIRS=4
    CONFIG_FS_LITTLEFS_READ_SIZE=16
    CONFIG_FS_LITTLEFS_PROG_SIZE=16
    CONFIG_FS_LITTLEFS_CACHE_SIZE=64
    CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE=32
    CONFIG_FS_LITTLEFS_BLOCK_CYCLES=512
    # CONFIG_NVS is not set
    # end of File Systems
    
    CONFIG_LOG=y
    # CONFIG_LOG_RUNTIME_FILTERING is not set
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_LOG_OVERRIDE_LEVEL=0
    CONFIG_LOG_MAX_LEVEL=4
    
    #
    # Prepend log message with function name
    #
    # CONFIG_LOG_FUNC_NAME_PREFIX_ERR is not set
    # CONFIG_LOG_FUNC_NAME_PREFIX_WRN is not set
    # CONFIG_LOG_FUNC_NAME_PREFIX_INF is not set
    CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y
    # end of Prepend log message with function name
    
    # CONFIG_LOG_PRINTK is not set
    CONFIG_LOG_IMMEDIATE=y
    CONFIG_LOG_DOMAIN_ID=0
    # CONFIG_LOG_FRONTEND is not set
    CONFIG_LOG_BACKEND_UART=y
    # CONFIG_LOG_BACKEND_NET is not set
    CONFIG_LOG_BACKEND_SHOW_COLOR=y
    CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=y
    
    #
    # Management
    #
    # CONFIG_MCUMGR_SMP_BT is not set
    # CONFIG_MCUMGR_SMP_SHELL is not set
    # CONFIG_MCUMGR_SMP_UART is not set
    # CONFIG_MCUMGR is not set
    # end of Management
    
    #
    # Networking
    #
    CONFIG_NET_BUF=y
    CONFIG_NET_BUF_USER_DATA_SIZE=4
    # CONFIG_NET_BUF_LOG is not set
    # CONFIG_NET_BUF_LOG_LEVEL_OFF is not set
    # CONFIG_NET_BUF_LOG_LEVEL_ERR is not set
    # CONFIG_NET_BUF_LOG_LEVEL_WRN is not set
    CONFIG_NET_BUF_LOG_LEVEL_INF=y
    # CONFIG_NET_BUF_LOG_LEVEL_DBG is not set
    CONFIG_NET_BUF_LOG_LEVEL=3
    # CONFIG_NET_BUF_POOL_USAGE is not set
    CONFIG_NETWORKING=y
    # CONFIG_NET_HOSTNAME_ENABLE is not set
    
    #
    # Link layer options
    #
    # CONFIG_NET_L2_DUMMY is not set
    # CONFIG_NET_L2_BT_SHELL is not set
    # CONFIG_NET_L2_ETHERNET is not set
    # CONFIG_NET_L2_PPP is not set
    # CONFIG_NET_L2_WIFI_MGMT is not set
    # CONFIG_NET_L2_WIFI_SHELL is not set
    # CONFIG_NET_L2_CANBUS is not set
    # end of Link layer options
    
    #
    # IP stack
    #
    CONFIG_NET_INIT_PRIO=90
    # CONFIG_NET_IPV6 is not set
    # CONFIG_NET_IPV4 is not set
    # CONFIG_NET_SHELL is not set
    CONFIG_NET_TC_TX_COUNT=1
    CONFIG_NET_TC_RX_COUNT=1
    CONFIG_NET_TC_MAPPING_STRICT=y
    CONFIG_NET_TX_DEFAULT_PRIORITY=1
    CONFIG_NET_IP_ADDR_CHECK=y
    CONFIG_NET_MAX_ROUTERS=1
    # CONFIG_NET_TCP is not set
    # CONFIG_NET_UDP is not set
    CONFIG_NET_MAX_CONTEXTS=6
    # CONFIG_NET_CONTEXT_NET_PKT_POOL is not set
    CONFIG_NET_CONTEXT_SYNC_RECV=y
    CONFIG_NET_CONTEXT_CHECK=y
    # CONFIG_NET_CONTEXT_PRIORITY is not set
    # CONFIG_NET_CONTEXT_TIMESTAMP is not set
    # CONFIG_NET_CONTEXT_TXTIME is not set
    # CONFIG_NET_TEST is not set
    # CONFIG_NET_TRICKLE is not set
    CONFIG_NET_PKT_RX_COUNT=4
    CONFIG_NET_PKT_TX_COUNT=4
    CONFIG_NET_BUF_RX_COUNT=16
    CONFIG_NET_BUF_TX_COUNT=16
    CONFIG_NET_BUF_FIXED_DATA_SIZE=y
    # CONFIG_NET_BUF_VARIABLE_DATA_SIZE is not set
    CONFIG_NET_BUF_DATA_SIZE=128
    CONFIG_NET_DEFAULT_IF_FIRST=y
    # CONFIG_NET_DEFAULT_IF_OFFLOAD is not set
    # CONFIG_NET_PKT_TIMESTAMP is not set
    # CONFIG_NET_PKT_TXTIME is not set
    # CONFIG_NET_PROMISCUOUS_MODE is not set
    
    #
    # Stack usage
    #
    CONFIG_NET_TX_STACK_SIZE=1200
    CONFIG_NET_RX_STACK_SIZE=1500
    # end of Stack usage
    
    # CONFIG_NET_MGMT is not set
    # CONFIG_NET_STATISTICS is not set
    CONFIG_NET_OFFLOAD=y
    CONFIG_NET_OFFLOAD_LOG_LEVEL=0
    # CONFIG_NET_LOG is not set
    CONFIG_NET_PKT_LOG_LEVEL=0
    # CONFIG_NET_DEBUG_NET_PKT_ALLOC is not set
    CONFIG_NET_DEBUG_NET_PKT_EXTERNALS=0
    # CONFIG_NET_DEBUG_NET_PKT_NON_FRAGILE_ACCESS is not set
    CONFIG_NET_CORE_LOG_LEVEL=0
    CONFIG_NET_IF_LOG_LEVEL=0
    CONFIG_NET_TC_LOG_LEVEL=0
    CONFIG_NET_UTILS_LOG_LEVEL=0
    CONFIG_NET_CONTEXT_LOG_LEVEL=0
    CONFIG_NET_CONN_LOG_LEVEL=0
    CONFIG_NET_ROUTE_LOG_LEVEL=0
    # end of IP stack
    
    #
    # Network Protocols
    #
    # CONFIG_COAP is not set
    # CONFIG_DNS_RESOLVER is not set
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LOG_LEVEL=0
    # CONFIG_HTTP_PARSER is not set
    # CONFIG_HTTP_PARSER_URL is not set
    # CONFIG_LWM2M is not set
    # CONFIG_SOCKS is not set
    # CONFIG_SNTP is not set
    # end of Network Protocols
    
    #
    # Network Libraries
    #
    CONFIG_NET_CONFIG_AUTO_INIT=y
    CONFIG_NET_CONFIG_INIT_PRIO=95
    CONFIG_NET_CONFIG_INIT_TIMEOUT=30
    # CONFIG_NET_CONFIG_NEED_IPV6 is not set
    # CONFIG_NET_CONFIG_NEED_IPV4 is not set
    CONFIG_NET_CONFIG_LOG_LEVEL=0
    # CONFIG_NET_CONFIG_SETTINGS is not set
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_SOCKETS_POLL_MAX=3
    CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=3000
    # CONFIG_NET_SOCKETS_SOCKOPT_TLS is not set
    CONFIG_NET_SOCKETS_OFFLOAD=y
    # CONFIG_NET_SOCKETS_CAN is not set
    CONFIG_NET_SOCKETS_LOG_LEVEL=0
    # CONFIG_TLS_CREDENTIALS is not set
    # end of Network Libraries
    
    #
    # Network additional services
    #
    # end of Network additional services
    # end of Networking
    
    # CONFIG_SHELL is not set
    # CONFIG_IMG_MANAGER is not set
    CONFIG_TEST_RANDOM_GENERATOR=y
    CONFIG_TIMER_RANDOM_GENERATOR=y
    
    #
    # Storage
    #
    # end of Storage
    
    # CONFIG_SETTINGS is not set
    
    #
    # Testing
    #
    # CONFIG_ZTEST is not set
    # CONFIG_TEST is not set
    # CONFIG_TEST_SHELL is not set
    CONFIG_TEST_EXTRA_STACKSIZE=0
    # CONFIG_TEST_USERSPACE is not set
    # end of Testing
    
    # CONFIG_CHARACTER_FRAMEBUFFER is not set
    # CONFIG_JWT is not set
    
    #
    # External Sources
    #
    
    #
    # HALs
    #
    CONFIG_HAS_CMSIS=y
    # CONFIG_HAS_MEC_HAL is not set
    CONFIG_HAS_NRFX=y
    # end of HALs
    
    #
    # Cryptography
    #
    # CONFIG_TINYCRYPT is not set
    # end of Cryptography
    
    # CONFIG_FNMATCH is not set
    # end of External Sources
    
    #
    # Build and Link Features
    #
    
    #
    # Linker Options
    #
    CONFIG_KERNEL=y
    # CONFIG_LINKER_ORPHAN_SECTION_PLACE is not set
    CONFIG_LINKER_ORPHAN_SECTION_WARN=y
    # CONFIG_LINKER_ORPHAN_SECTION_ERROR is not set
    # CONFIG_CODE_DATA_RELOCATION is not set
    CONFIG_HAS_FLASH_LOAD_OFFSET=y
    # CONFIG_USE_CODE_PARTITION is not set
    # CONFIG_HAVE_CUSTOM_LINKER_SCRIPT is not set
    # CONFIG_CUSTOM_RODATA_LD is not set
    # CONFIG_CUSTOM_RWDATA_LD is not set
    # CONFIG_CUSTOM_SECTIONS_LD is not set
    # CONFIG_LINK_WHOLE_ARCHIVE is not set
    CONFIG_KERNEL_ENTRY="__start"
    CONFIG_LINKER_SORT_BY_ALIGNMENT=y
    # end of Linker Options
    
    #
    # Compiler Options
    #
    # CONFIG_NATIVE_APPLICATION is not set
    CONFIG_SIZE_OPTIMIZATIONS=y
    # CONFIG_SPEED_OPTIMIZATIONS is not set
    # CONFIG_DEBUG_OPTIMIZATIONS is not set
    # CONFIG_NO_OPTIMIZATIONS is not set
    CONFIG_COMPILER_OPT=""
    # end of Compiler Options
    
    #
    # Build Options
    #
    CONFIG_KERNEL_BIN_NAME="zephyr"
    CONFIG_OUTPUT_STAT=y
    CONFIG_OUTPUT_DISASSEMBLY=y
    CONFIG_OUTPUT_PRINT_MEMORY_USAGE=y
    CONFIG_BUILD_OUTPUT_BIN=y
    # CONFIG_BUILD_OUTPUT_EXE is not set
    # CONFIG_BUILD_OUTPUT_S19 is not set
    # CONFIG_BUILD_NO_GAP_FILL is not set
    # CONFIG_BUILD_OUTPUT_STRIPPED is not set
    # CONFIG_APPLICATION_DEFINED_SYSCALL is not set
    # end of Build Options
    # end of Build and Link Features
    
    #
    # Boot Options
    #
    # CONFIG_IS_BOOTLOADER is not set
    # CONFIG_BOOTLOADER_MCUBOOT is not set
    CONFIG_REBOOT=y
    # CONFIG_MISRA_SANE is not set
    # end of Boot Options
    
    #
    # Compatibility
    #
    CONFIG_COMPAT_INCLUDES=y
    # end of Compatibility
    # end of Zephyr Kernel
    

    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 <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];
    static u8_t payload_buf[CONFIG_MQTT_PAYLOAD_BUFFER_SIZE];
    
    /* The mqtt client struct */
    static struct mqtt_client client;
    
    /* MQTT Broker details. */
    static struct sockaddr_storage broker;
    
    /* Connected flag */
    static bool connected;
    
    /* File descriptor */
    static struct pollfd fds;
    
    static struct k_delayed_work long_press_button_work;
    static atomic_val_t gps_enable;
    static struct gps_data gps_data;
    #if defined(CONFIG_BSD_LIBRARY)
    
    /**@brief Recoverable BSD library error. */
    void bsd_recoverable_error_handler(uint32_t err)
    {
    	printk("bsdlib recoverable error: %u\n", err);
    }
    
    /**@brief Irrecoverable BSD library error. */
    void bsd_irrecoverable_error_handler(uint32_t err)
    {
    	printk("bsdlib irrecoverable error: %u\n", err);
    
    	__ASSERT_NO_MSG(false);
    }
    
    #endif /* defined(CONFIG_BSD_LIBRARY) */
    
    /**@brief Function to print strings without null-termination
     */
    static void data_print(u8_t *prefix, u8_t *data, size_t len)
    {
    	char buf[len + 1];
    
    	memcpy(buf, data, len);
    	buf[len] = 0;
    	printk("%s%s\n", prefix, buf);
    }
    
    /**@brief Function to publish data on the configured topic
     */
    static int data_publish(struct mqtt_client *c, enum mqtt_qos qos,
    	u8_t *data, size_t len)
    {
    	struct mqtt_publish_param param;
    
    	param.message.topic.qos = qos;
    	param.message.topic.topic.utf8 = CONFIG_MQTT_PUB_TOPIC;
    	param.message.topic.topic.size = strlen(CONFIG_MQTT_PUB_TOPIC);
    	param.message.payload.data = data;
    	param.message.payload.len = len;
    	param.message_id = sys_rand32_get();
    	param.dup_flag = 0;
    	param.retain_flag = 0;
    
    	data_print("Publishing: ", data, len);
    	printk("to topic: %s len: %u\n",
    		CONFIG_MQTT_PUB_TOPIC,
    		(unsigned int)strlen(CONFIG_MQTT_PUB_TOPIC));
    
    	return mqtt_publish(c, &param);
    }
    
    /**@brief Function to subscribe to the configured topic
     */
    static int subscribe(void)
    {
    	struct mqtt_topic subscribe_topic = {
    		.topic = {
    			.utf8 = CONFIG_MQTT_SUB_TOPIC,
    			.size = strlen(CONFIG_MQTT_SUB_TOPIC)
    		},
    		.qos = MQTT_QOS_1_AT_LEAST_ONCE
    	};
    
    	const struct mqtt_subscription_list subscription_list = {
    		.list = &subscribe_topic,
    		.list_count = 1,
    		.message_id = 1234
    	};
    
    	printk("Subscribing to: %s len %u\n", CONFIG_MQTT_SUB_TOPIC,
    		(unsigned int)strlen(CONFIG_MQTT_SUB_TOPIC));
    
    	return mqtt_subscribe(&client, &subscription_list);
    }
    
    /**@brief Function to read the published payload.
     */
    static int publish_get_payload(struct mqtt_client *c, size_t length)
    {
    	u8_t *buf = payload_buf;
    	u8_t *end = buf + length;
    
    	if (length > sizeof(payload_buf)) {
    		return -EMSGSIZE;
    	}
    
    	while (buf < end) {
    		int ret = mqtt_read_publish_payload(c, buf, end - buf);
    
    		if (ret < 0) {
    			int err;
    
    			if (ret != -EAGAIN) {
    				return ret;
    			}
    
    			printk("mqtt_read_publish_payload: EAGAIN\n");
    
    			err = poll(&fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE));
    			if (err > 0 && (fds.revents & POLLIN) == POLLIN) {
    				continue;
    			} else {
    				return -EIO;
    			}
    		}
    
    		if (ret == 0) {
    			return -EIO;
    		}
    
    		buf += ret;
    	}
    
    	return 0;
    }
    
    /**@brief MQTT client event handler
     */
    void mqtt_evt_handler(struct mqtt_client *const c,
    		      const struct mqtt_evt *evt)
    {
    	int err;
    
    	switch (evt->type) {
    	case MQTT_EVT_CONNACK:
    		if (evt->result != 0) {
    			printk("MQTT connect failed %d\n", evt->result);
    			break;
    		}
    
    		connected = true;
    		printk("[%s:%d] MQTT client connected!\n", __func__, __LINE__);
    		subscribe();
    		break;
    
    	case MQTT_EVT_DISCONNECT:
    		printk("[%s:%d] MQTT client disconnected %d\n", __func__,
    		       __LINE__, evt->result);
    
    		connected = false;
    		break;
    
    	case MQTT_EVT_PUBLISH: {
    		const struct mqtt_publish_param *p = &evt->param.publish;
    
    		printk("[%s:%d] MQTT PUBLISH result=%d len=%d\n", __func__,
    		       __LINE__, evt->result, p->message.payload.len);
    		err = publish_get_payload(c, p->message.payload.len);
    		if (err >= 0) {
    			data_print("Received: ", payload_buf,
    				p->message.payload.len);
    			/* Echo back received data */
    			data_publish(&client, MQTT_QOS_1_AT_LEAST_ONCE,
    				payload_buf, p->message.payload.len);
    		} else {
    			printk("mqtt_read_publish_payload: Failed! %d\n", err);
    			printk("Disconnecting MQTT client...\n");
    
    			err = mqtt_disconnect(c);
    			if (err) {
    				printk("Could not disconnect: %d\n", err);
    			}
    		}
    	} break;
    
    	case MQTT_EVT_PUBACK:
    		if (evt->result != 0) {
    			printk("MQTT PUBACK error %d\n", evt->result);
    			break;
    		}
    
    		printk("[%s:%d] PUBACK packet id: %u\n", __func__, __LINE__,
    				evt->param.puback.message_id);
    		break;
    
    	case MQTT_EVT_SUBACK:
    		if (evt->result != 0) {
    			printk("MQTT SUBACK error %d\n", evt->result);
    			break;
    		}
    
    		printk("[%s:%d] SUBACK packet id: %u\n", __func__, __LINE__,
    				evt->param.suback.message_id);
    		break;
    
    	default:
    		printk("[%s:%d] default: %d\n", __func__, __LINE__,
    				evt->type);
    		break;
    	}
    }
    
    /**@brief Resolves the configured hostname and
     * initializes the MQTT broker structure
     */
    static void broker_init(void)
    {
    	int err;
    	struct addrinfo *result;
    	struct addrinfo *addr;
    	struct addrinfo hints = {
    		.ai_family = AF_INET,
    		.ai_socktype = SOCK_STREAM
    	};
    
    	err = getaddrinfo(CONFIG_MQTT_BROKER_HOSTNAME, NULL, &hints, &result);
    	if (err) {
    		printk("ERROR: getaddrinfo failed %d\n", err);
    
    		return;
    	}
    
    	addr = result;
    	err = -ENOENT;
    
    	/* Look for address of the broker. */
    	while (addr != NULL) {
    		/* IPv4 Address. */
    		if (addr->ai_addrlen == sizeof(struct sockaddr_in)) {
    			struct sockaddr_in *broker4 =
    				((struct sockaddr_in *)&broker);
    			char ipv4_addr[NET_IPV4_ADDR_LEN];
    
    			broker4->sin_addr.s_addr =
    				((struct sockaddr_in *)addr->ai_addr)
    				->sin_addr.s_addr;
    			broker4->sin_family = AF_INET;
    			broker4->sin_port = htons(CONFIG_MQTT_BROKER_PORT);
    
    			inet_ntop(AF_INET, &broker4->sin_addr.s_addr,
    				  ipv4_addr, sizeof(ipv4_addr));
    			printk("IPv4 Address found %s\n", ipv4_addr);
    
    			break;
    		} else {
    			printk("ai_addrlen = %u should be %u or %u\n",
    				(unsigned int)addr->ai_addrlen,
    				(unsigned int)sizeof(struct sockaddr_in),
    				(unsigned int)sizeof(struct sockaddr_in6));
    		}
    
    		addr = addr->ai_next;
    		break;
    	}
    
    	/* Free the address. */
    	freeaddrinfo(result);
    }
    
    /**@brief Initialize the MQTT client structure
     */
    static void client_init(struct mqtt_client *client)
    {
    	mqtt_client_init(client);
    
    	broker_init();
    
    	/* MQTT client configuration */
    	client->broker = &broker;
    	client->evt_cb = mqtt_evt_handler;
    	client->client_id.utf8 = (u8_t *)CONFIG_MQTT_CLIENT_ID;
    	client->client_id.size = strlen(CONFIG_MQTT_CLIENT_ID);
    	client->password = NULL;
    	client->user_name = NULL;
    	client->protocol_version = MQTT_VERSION_3_1_1;
    
    	/* MQTT buffers configuration */
    	client->rx_buf = rx_buffer;
    	client->rx_buf_size = sizeof(rx_buffer);
    	client->tx_buf = tx_buffer;
    	client->tx_buf_size = sizeof(tx_buffer);
    
    	/* MQTT transport configuration */
    	client->transport.type = MQTT_TRANSPORT_NON_SECURE;
    }
    
    /**@brief Initialize the file descriptor structure used by poll.
     */
    static int fds_init(struct mqtt_client *c)
    {
    	if (c->transport.type == MQTT_TRANSPORT_NON_SECURE) {
    		fds.fd = c->transport.tcp.sock;
    	} else {
    #if defined(CONFIG_MQTT_LIB_TLS)
    		fds.fd = c->transport.tls.sock;
    #else
    		return -ENOTSUP;
    #endif
    	}
    
    	fds.events = POLLIN;
    
    	return 0;
    }
    
    /**@brief Configures modem to provide LTE link. Blocks until link is
     * successfully established.
     */
    static void modem_configure(void)
    {
    #if defined(CONFIG_LTE_LINK_CONTROL)
    	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
    		/* Do nothing, modem is already turned on
    		 * and connected.
    		 */
    	} else {
    		int err;
    
    		printk("LTE Link Connecting ...\n");
    		err = lte_lc_init_and_connect();
    		__ASSERT(err == 0, "LTE link could not be established.");
    		printk("LTE Link Connected!\n");
    	}
    #endif
    }
    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;
    	}
    	printk("get  GPS then stop\n");
    	fix_count = 0;
    
    	
    	gps_sample_fetch(dev);
    	gps_channel_get(dev, GPS_CHAN_NMEA, &gps_data);
    	printk("nmea %s\n",gps_data.nmea.buf);
    	gps_control_stop(K_NO_WAIT);
    	
    }
    
    static void long_press_handler(struct k_work *work)
    {
    	if (gps_control_is_enabled()) {
                    atomic_set(&gps_enable, 1);
    		printk("Stopping GPS\n");
    		gps_control_disable();
    	} else {
                    atomic_set(&gps_enable, 0);
    		printk("Starting GPS\n");
    		gps_control_enable();
    		gps_control_start(K_SECONDS(1));
    	}
    }
    void initgpswork(void)
    {
      k_delayed_work_init(&long_press_button_work, long_press_handler);
    
    	gps_control_init(gps_trigger_handler);
    k_delayed_work_submit(&long_press_button_work, K_SECONDS(10)); 
      return;
    }
    
    
    void main(void)
    {
    	int err;
    
    	printk("The MQTT simple sample started\n");
            atomic_set(&gps_enable, 0);
    	modem_configure();
    
    	client_init(&client);
            
            initgpswork();
    	
            err = mqtt_connect(&client);
    	if (err != 0) {
    		printk("ERROR: mqtt_connect %d\n", err);
    		return;
    	}
    
    	err = fds_init(&client);
    	if (err != 0) {
    		printk("ERROR: fds_init %d\n", err);
    		return;
    	}
    
    	while (1) {
                  if(atomic_get(&gps_enable))
                    k_sleep(K_MSEC(500));
                  else {
    		err = poll(&fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE));
    		if (err < 0) {
    			printk("ERROR: poll %d\n", errno);
    			break;
    		}
    
    		err = mqtt_live(&client);
    		if (err != 0) {
    			printk("ERROR: mqtt_live %d\n", err);
    			break;
    		}
    
    		if ((fds.revents & POLLIN) == POLLIN) {
    			err = mqtt_input(&client);
    			if (err != 0) {
    				printk("ERROR: mqtt_input %d\n", err);
    				break;
    			}
    		}
    
    		if ((fds.revents & POLLERR) == POLLERR) {
    			printk("POLLERR\n");
    			break;
    		}
    
    		if ((fds.revents & POLLNVAL) == POLLNVAL) {
    			printk("POLLNVAL\n");
    			break;
    		}
                    }
    	}
    
    	printk("Disconnecting MQTT client...\n");
    
    	err = mqtt_disconnect(&client);
    	if (err) {
    		printk("Could not disconnect MQTT client. Error: %d\n", err);
    	}
    }
    

  • the mqtt is tcp (http session),so i thing it not to do as my method.

    i will to do as the UDP & gps as git link.

    thank you .

Reply Children
No Data
Related