hi all,
the latest master fw-nrfconnect-nrf.
asset_tracker project gps_controller.
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 ?
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.
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)); } }