diff options
Diffstat (limited to 'nrfdemo')
| -rw-r--r-- | nrfdemo/.vscode/c_cpp_properties.json | 20 | ||||
| -rw-r--r-- | nrfdemo/.vscode/settings.json | 10 | ||||
| -rw-r--r-- | nrfdemo/src/main.c | 81 |
3 files changed, 65 insertions, 46 deletions
diff --git a/nrfdemo/.vscode/c_cpp_properties.json b/nrfdemo/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..49fcd73 --- /dev/null +++ b/nrfdemo/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/home/mike/Documents/ncs/v2.7.0/zephyr/include/", + "/home/mike/Documents/ncs/v2.7.0/nrf/include/", + "/home/mike/Documents/ncs/v2.7.0/nrfxlib/nrf_modem/include/" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++14", + "intelliSenseMode": "linux-clang-x64", + "configurationProvider": "nordic-semiconductor.nrf-connect" + } + ], + "version": 4 +}
\ No newline at end of file diff --git a/nrfdemo/.vscode/settings.json b/nrfdemo/.vscode/settings.json index 66d426d..4523da1 100644 --- a/nrfdemo/.vscode/settings.json +++ b/nrfdemo/.vscode/settings.json @@ -1,5 +1,13 @@ { "files.associations": { - "bme680.h": "c" + "bme680.h": "c", + "mqtt_connection.h": "c", + "socket.h": "c", + "kernel.h": "c", + "nrf_modem_lib.h": "c", + "log.h": "c", + "lte_lc.h": "c", + "net_ip.h": "c", + "socket_select.h": "c" } }
\ No newline at end of file diff --git a/nrfdemo/src/main.c b/nrfdemo/src/main.c index 431e8cf..770b178 100644 --- a/nrfdemo/src/main.c +++ b/nrfdemo/src/main.c @@ -42,9 +42,8 @@ LOG_MODULE_REGISTER(mqtt_app, LOG_LEVEL_INF); static void lte_handler(const struct lte_lc_evt *const evt) { - LOG_INF("LTE handler"); - switch (evt->type) { - case LTE_LC_EVT_NW_REG_STATUS: + switch (evt->type) { + case LTE_LC_EVT_NW_REG_STATUS: if ((evt->nw_reg_status != LTE_LC_NW_REG_REGISTERED_HOME) && (evt->nw_reg_status != LTE_LC_NW_REG_REGISTERED_ROAMING)) { break; @@ -74,15 +73,6 @@ static int modem_configure(void) return err; } - /* lte_lc_init deprecated in >= v2.6.0 */ - #if NCS_VERSION_NUMBER < 0x20600 - err = lte_lc_init(); - if (err) { - LOG_ERR("Failed to initialize LTE link control library, error: %d", err); - return err; - } - #endif - LOG_INF("Connecting to LTE network"); err = lte_lc_connect_async(lte_handler); if (err) { @@ -93,39 +83,6 @@ static int modem_configure(void) k_sem_take(<e_connected, K_FOREVER); LOG_INF("Connected to LTE network"); - #if 1 - - /* Activate only the GNSS stack * / - if (lte_lc_func_mode_set(LTE_LC_FUNC_MODE_ACTIVATE_GNSS) != 0) { - LOG_ERR("Failed to activate GNSS functional mode"); - return 0; - } */ - - /* Register the GNSS event handler */ - if (nrf_modem_gnss_event_handler_set(gnss_event_handler) != 0) { - LOG_ERR("Failed to set GNSS event handler"); - return 0; - } - - /* Set the GNSS fix interval and GNSS fix retry period */ - //if (nrf_modem_gnss_fix_interval_set(CONFIG_GNSS_PERIODIC_INTERVAL) != 0) { - // LOG_ERR("Failed to set GNSS fix interval"); - // return 0; - //} - - //if (nrf_modem_gnss_fix_retry_set(CONFIG_GNSS_PERIODIC_TIMEOUT) != 0) { - // LOG_ERR("Failed to set GNSS fix retry"); - // return 0; - //} - - /* Start the GNSS receiver */ - LOG_INF("Starting GNSS"); - if (nrf_modem_gnss_start() != 0) { - LOG_ERR("Failed to start GNSS"); - return 0; - } - #endif - // Blink LED to indicate we connected to MQTT broker dk_set_led_on(DK_LED1); @@ -234,12 +191,46 @@ int main(void) LOG_ERR("Failed to initialize the buttons library"); } + + /* Activate only the GNSS stack */ + if (lte_lc_func_mode_set(LTE_LC_FUNC_MODE_ACTIVATE_GNSS) != 0) { + LOG_ERR("Failed to activate GNSS functional mode"); + return 0; + } + + /* Register the GNSS event handler */ + if (nrf_modem_gnss_event_handler_set(gnss_event_handler) != 0) { + LOG_ERR("Failed to set GNSS event handler"); + return 0; + } + + /* Set the GNSS fix interval and GNSS fix retry period */ + if (nrf_modem_gnss_fix_interval_set(1) != 0) { + LOG_ERR("Failed to set GNSS fix interval"); + return 0; + } + + if (nrf_modem_gnss_fix_retry_set(60) != 0) { + LOG_ERR("Failed to set GNSS fix retry"); + return 0; + } + + /* Start the GNSS receiver */ + LOG_INF("Starting GNSS"); + if (nrf_modem_gnss_start() != 0) { + LOG_ERR("Failed to start GNSS"); + return 0; + } + err = client_init(&client); if (err) { LOG_ERR("Failed to initialize MQTT client: %d", err); return 0; } + /* Log the current system uptime */ + gnss_start_time = k_uptime_get(); + do_connect: if (connect_attempt++ > 0) { LOG_INF("Reconnecting in %d seconds...", |
