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

AWS IoT how change the messagge type 1?

Hello 

I'm using nRF910 DK and need to transmit to aws iot core just like the sample aws iot does, but instead of battery voltage I need to transmit gps data.

In sample I don't find where change the value of type 1 mesagge to transmit, I look for it in the code but I can't find the function in charge of this.

thanks in advance for your help 

Julio

Parents Reply
  • The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network. That's not something the application has any control of. When the UE is in PSM, the GPS will be able to function and get a fix.

    It's important to request a time long enough for the GPS to be able to get a fix though. AT+CPSMS is used to request these parameters from the network. Be aware that you are free the request any values from the network, but the network can set different values.

Children
  • Hi Heidi!

    The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network

    how can I know the timers set by the network where my UE is conneted?

    Then once the modem has been configured (L398) and the device binding for the nRF9160 GPS is complete (L405)

    I have drawbacks in this part, I add the gsp_handler() and gps_init() of agps sample to aws_iot sample, omitting only cloud connection code, but at run time show this message:

    I try to read about what is binding operation but don't find documentation about this, the modem_configure(); in aws_iot (L372) is the same that agps (L336), I mean, can the gps work with the modem_configure(); of aws_iot?

    edit: I tried to debug but I don't know how to verify or control the binding function

  • tracking said:
    how can I know the timers set by the network where my UE is conneted?

     You can use AT%XMONITOR to read the Active Time and Periodic TAU set by the network. 

    Yes, you can use the modem_configure() in the AWS IoT sample, but you need to modify it to request PSM (L348). 

    Did you include the GPS driver (L13)? Can I see your main.c file?

  • thanks for that, but I don't find how interprete the result

    You can use AT%XMONITOR to read the Active Time and Periodic TAU set by the network.

    Yes, you can use the modem_configure() in the AWS IoT sample, but you need to modify it to request PSM (L348).

    which one is the modification? I had undertood that with this line (L348) the modem change to psm o mode idle when the pakage was transmitted and in this condition the gps can work.

    Did you include the GPS driver (L13)?

    yes, I include gps driver, but I don't know what cosiderations I must have with Cmakelists, Kconfig, prj.conf and other files 

    Can I see your main.c file?

    yes, of course

    /*
     * Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
     */
    
    #include <zephyr.h>
    #include <stdio.h>
    #include <stdlib.h>
    #if defined(CONFIG_BSD_LIB)
    #include <modem/lte_lc.h>
    #include <modem/bsdlib.h>
    #include <modem/at_cmd.h>
    #include <modem/at_notif.h>
    #include <modem/modem_info.h>
    #include <bsd.h>
    #endif
    #include <net/aws_iot.h>
    #include <power/reboot.h>
    #include <date_time.h>
    #include <dfu/mcuboot.h>
    #include <cJSON.h>
    #include <cJSON_os.h>
    #include <drivers/gps.h>//corresponds to gps 
    //#include <logging/log.h>//corresponds to gps
    
    BUILD_ASSERT(!IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT),
    		"This sample does not support LTE auto-init and connect");
    
    #define APP_TOPICS_COUNT CONFIG_AWS_IOT_APP_SUBSCRIPTION_LIST_COUNT
    
    /* Timeout in seconds in which the application will wait for an initial event
     * from the date time library.
     */
    #define DATE_TIME_TIMEOUT_S 15
    
    static struct k_delayed_work shadow_update_work;
    static struct k_delayed_work connect_work;
    static struct k_delayed_work shadow_update_version_work;
    static struct k_delayed_work gps_start_work;//corresponds to gps
    static struct k_delayed_work reboot_work;//corresponds to gps
    static const struct device *gps_dev;//corresponds to gps
    
    K_SEM_DEFINE(lte_connected, 0, 1);
    K_SEM_DEFINE(date_time_obtained, 0, 1);
    
    //**************** INICIO FUNCIONES DE GPS ***********************
    static void gps_start_work_fn(struct k_work *work)
    {
    	int err;
    	struct gps_config gps_cfg = {
    		.nav_mode = GPS_NAV_MODE_PERIODIC,
    		.power_mode = GPS_POWER_MODE_DISABLED,
    		.timeout = 120,
    		.interval = 240,
    		.priority = true,
    	};
    
    	ARG_UNUSED(work);//#define ARG_UNUSED(x) (void)(x) in gcc.h seems is to avoid warning when  
                              //argument is void que no tire warning si el argumento work no está
    
    	err = gps_start(gps_dev, &gps_cfg);//loads api on device and initialize wiht gps_cfg configuration 
    	if (err) {
    		//LOG_ERR("Failed to start GPS, error: %d", err);//error in __log_level I don't know why
                    printk("Failed to start GPS, error: %d", err);
    		return;
    	}
    
    	//LOG_INF("Periodic GPS search started with interval %d s, timeout %d s",  
    	//	gps_cfg.interval, gps_cfg.timeout);
            printk("Periodic GPS search started with interval %d s, timeout %d s",  
    		gps_cfg.interval, gps_cfg.timeout);
    }
    static void reboot_work_fn(struct k_work *work)
    {
    	//LOG_WRN("Rebooting in 2 seconds...");
            printk("Rebooting in 2 seconds...");
    	k_sleep(K_SECONDS(2));
    	sys_reboot(0);
    }
    static void print_pvt_data(struct gps_pvt *pvt_data)
    {
    	char buf[300];
    	size_t len;
    
    	len = snprintf(buf, sizeof(buf),
    		      "\r\n\tLongitude:  %f\r\n\t"
    		      "Latitude:   %f\r\n\t"
    		      "Altitude:   %f\r\n\t"
    		      "Speed:      %f\r\n\t"
    		      "Heading:    %f\r\n\t"
    		      "Date:       %02u-%02u-%02u\r\n\t"
    		      "Time (UTC): %02u:%02u:%02u\r\n",
    		      pvt_data->longitude, pvt_data->latitude,
    		      pvt_data->altitude, pvt_data->speed, pvt_data->heading,
    		      pvt_data->datetime.day, pvt_data->datetime.month,
    		      pvt_data->datetime.year, pvt_data->datetime.hour,
    		      pvt_data->datetime.minute, pvt_data->datetime.seconds);
    	if (len < 0) {
    		printk("Could not construct PVT print");
    	} else {
    		//printk("%s", log_strdup(buf));//I don't copy this function, I think is not important now
    	}
    }
    static uint64_t start_search_timestamp;
    static uint64_t fix_timestamp;
    static void gps_handler(const struct device *dev, struct gps_event *evt)
    {
    	ARG_UNUSED(dev);
    
    	switch (evt->type) {
    	case GPS_EVT_SEARCH_STARTED:
    		//LOG_INF("GPS_EVT_SEARCH_STARTED");
                    printk("GPS_EVT_SEARCH_STARTED");
    		start_search_timestamp = k_uptime_get();
    		break;
    	case GPS_EVT_SEARCH_STOPPED:
    		//LOG_INF("GPS_EVT_SEARCH_STOPPED");
                    printk("GPS_EVT_SEARCH_STOPPED");
    		break;
    	case GPS_EVT_SEARCH_TIMEOUT:
    		//LOG_INF("GPS_EVT_SEARCH_TIMEOUT");
                    printk("GPS_EVT_SEARCH_TIMEOUT");
    		break;
    	case GPS_EVT_OPERATION_BLOCKED:
    		//LOG_INF("GPS_EVT_OPERATION_BLOCKED");
                    printk("GPS_EVT_OPERATION_BLOCKED");
    		break;
    	case GPS_EVT_OPERATION_UNBLOCKED:
    		//LOG_INF("GPS_EVT_OPERATION_UNBLOCKED");
                    printk("GPS_EVT_OPERATION_UNBLOCKED");
    		break;
    	//case GPS_EVT_AGPS_DATA_NEEDED://this case is not used because do the conection but with nrfcloud
    	//	//LOG_INF("GPS_EVT_AGPS_DATA_NEEDED");
            //          printk("GPS_EVT_AGPS_DATA_NEEDED");
    	//	on_agps_needed(evt->agps_request);
    	//	break;
    	//case GPS_EVT_PVT://print status satelite, now I think is not important, I will add when gps initiates correctly 
    	//	print_satellite_stats(&evt->pvt);
    	//	break;
    	case GPS_EVT_PVT_FIX:
    		fix_timestamp = k_uptime_get();
    
    		printk("---------       FIX       ---------");
    		printk("Time to fix: %d seconds",
    			(uint32_t)(fix_timestamp - start_search_timestamp) / 1000);
    		print_pvt_data(&evt->pvt);
    		printk("-----------------------------------");
    		break;
    	//case GPS_EVT_NMEA_FIX://this case create and send the messagge but to nrfcloud
    	//	send_nmea(evt->nmea.buf);
    	//	break;
    	default:
    		break;
    	}
    }
    
    //**************** FIN FUNCIONES DE GPS ***********************
    static int json_add_obj(cJSON *parent, const char *str, cJSON *item)
    {
    	cJSON_AddItemToObject(parent, str, item);
    
    	return 0;
    }
    
    static int json_add_str(cJSON *parent, const char *str, const char *item)
    {
    	cJSON *json_str;
    
    	json_str = cJSON_CreateString(item);
    	if (json_str == NULL) {
    		return -ENOMEM;
    	}
    
    	return json_add_obj(parent, str, json_str);
    }
    
    static int json_add_number(cJSON *parent, const char *str, double item)
    {
    	cJSON *json_num;
    
    	json_num = cJSON_CreateNumber(item);
    	if (json_num == NULL) {
    		return -ENOMEM;
    	}
    
    	return json_add_obj(parent, str, json_num);
    }
    
    static int shadow_update(bool version_number_include)
    {
    	int err;
    	char *message;
    	int64_t message_ts;
    	int16_t bat_voltage = 0;
    
    	err = date_time_now(&message_ts);
    	if (err) {
    		printk("date_time_now, error: %d\n", err);
    		return err;
    	}
    
    #if defined(CONFIG_BSD_LIBRARY)
    	/* Request battery voltage data from the modem. */
    	err = modem_info_short_get(MODEM_INFO_BATTERY, &bat_voltage);
    	if (err != sizeof(bat_voltage)) {
    		printk("modem_info_short_get, error: %d\n", err);
    		return err;
    	}
    #endif
    
    	cJSON *root_obj = cJSON_CreateObject();
    	cJSON *state_obj = cJSON_CreateObject();
    	cJSON *reported_obj = cJSON_CreateObject();
    
    	if (root_obj == NULL || state_obj == NULL || reported_obj == NULL) {
    		cJSON_Delete(root_obj);
    		cJSON_Delete(state_obj);
    		cJSON_Delete(reported_obj);
    		err = -ENOMEM;
    		return err;
    	}
    
    	if (version_number_include) {
    		err = json_add_str(reported_obj, "app_version",
    				    CONFIG_APP_VERSION);
    	} else {
    		err = 0;
    	}
    
    	err += json_add_number(reported_obj, "batv", bat_voltage);
    	err += json_add_number(reported_obj, "ts", message_ts);
    	err += json_add_obj(state_obj, "reported", reported_obj);
    	err += json_add_obj(root_obj, "state", state_obj);
    
    	if (err) {
    		printk("json_add, error: %d\n", err);
    		goto cleanup;
    	}
    
    	message = cJSON_Print(root_obj);
    	if (message == NULL) {
    		printk("cJSON_Print, error: returned NULL\n");
    		err = -ENOMEM;
    		goto cleanup;
    	}
    
    	struct aws_iot_data tx_data = {
    		.qos = MQTT_QOS_0_AT_MOST_ONCE,
    		.topic.type = AWS_IOT_SHADOW_TOPIC_UPDATE,
    		.ptr = message,
    		.len = strlen(message)
    	};
    
    	printk("Publishing: %s to AWS IoT broker\n", message);
    
    	err = aws_iot_send(&tx_data);
    	if (err) {
    		printk("aws_iot_send, error: %d\n", err);
    	}
    
    	cJSON_FreeString(message);
    
    cleanup:
    
    	cJSON_Delete(root_obj);
    
    	return err;
    }
    
    static void connect_work_fn(struct k_work *work)
    {
    	int err;
    
    	err = aws_iot_connect(NULL);
    	if (err) {
    		printk("aws_iot_connect, error: %d\n", err);
    	}
    
    	printk("Next connection retry in %d seconds\n",
    	       CONFIG_CONNECTION_RETRY_TIMEOUT_SECONDS);
    
    	k_delayed_work_submit(&connect_work,
    			K_SECONDS(CONFIG_CONNECTION_RETRY_TIMEOUT_SECONDS));
    }
    
    static void shadow_update_work_fn(struct k_work *work)
    {
    	int err;
    
    	err = shadow_update(false);
    	if (err) {
    		printk("shadow_update, error: %d\n", err);
    	}
    
    	printk("Next data publication in %d seconds\n",
    	       CONFIG_PUBLICATION_INTERVAL_SECONDS);
    
    	k_delayed_work_submit(&shadow_update_work,
    			      K_SECONDS(CONFIG_PUBLICATION_INTERVAL_SECONDS));
    }
    
    static void shadow_update_version_work_fn(struct k_work *work)
    {
    	int err;
    
    	err = shadow_update(true);
    	if (err) {
    		printk("shadow_update, error: %d\n", err);
    	}
    }
    
    static void print_received_data(const char *buf, const char *topic,
    				size_t topic_len)
    {
    	char *str = NULL;
    	cJSON *root_obj = NULL;
    
    	root_obj = cJSON_Parse(buf);
    	if (root_obj == NULL) {
    		printk("cJSON Parse failure");
    		return;
    	}
    
    	str = cJSON_Print(root_obj);
    	if (str == NULL) {
    		printk("Failed to print JSON object");
    		goto clean_exit;
    	}
    
    	printf("Data received from AWS IoT console:\nTopic: %.*s\nMessage: %s\n",
    	       topic_len, topic, str);
    
    	cJSON_FreeString(str);
    
    clean_exit:
    	cJSON_Delete(root_obj);
    }
    
    void aws_iot_event_handler(const struct aws_iot_evt *const evt)
    {
    	switch (evt->type) {
    	case AWS_IOT_EVT_CONNECTING:
    		printk("AWS_IOT_EVT_CONNECTING\n");
    		break;
    	case AWS_IOT_EVT_CONNECTED:
    		printk("AWS_IOT_EVT_CONNECTED\n");
    
    		k_delayed_work_cancel(&connect_work);
    
    		if (evt->data.persistent_session) {
    			printk("Persistent session enabled\n");
    		}
    
    #if defined(CONFIG_BSD_LIBRARY)
    		/** Successfully connected to AWS IoT broker, mark image as
    		 *  working to avoid reverting to the former image upon reboot.
    		 */
    		boot_write_img_confirmed();
    #endif
    
    		/** Send version number to AWS IoT broker to verify that the
    		 *  FOTA update worked.
    		 */
    		k_delayed_work_submit(&shadow_update_version_work, K_NO_WAIT);
    
    		/** Start sequential shadow data updates.
    		 */
    		k_delayed_work_submit(&shadow_update_work,
    				K_SECONDS(CONFIG_PUBLICATION_INTERVAL_SECONDS));
    
    #if defined(CONFIG_BSD_LIBRARY)
    		int err = lte_lc_psm_req(true);
    		if (err) {
    			printk("Requesting PSM failed, error: %d\n", err);
    		}
    #endif
    		break;
    	case AWS_IOT_EVT_READY:
    		printk("AWS_IOT_EVT_READY\n");
    		break;
    	case AWS_IOT_EVT_DISCONNECTED:
    		printk("AWS_IOT_EVT_DISCONNECTED\n");
    		k_delayed_work_cancel(&shadow_update_work);
    
    		if (k_delayed_work_pending(&connect_work)) {
    			break;
    		}
    
    		k_delayed_work_submit(&connect_work, K_NO_WAIT);
    		break;
    	case AWS_IOT_EVT_DATA_RECEIVED:
    		printk("AWS_IOT_EVT_DATA_RECEIVED\n");
    		print_received_data(evt->data.msg.ptr, evt->data.msg.topic.str,
    				    evt->data.msg.topic.len);
    		break;
    	case AWS_IOT_EVT_FOTA_START:
    		printk("AWS_IOT_EVT_FOTA_START\n");
    		break;
    	case AWS_IOT_EVT_FOTA_ERASE_PENDING:
    		printk("AWS_IOT_EVT_FOTA_ERASE_PENDING\n");
    		printk("Disconnect LTE link or reboot\n");
    #if defined(CONFIG_BSD_LIBRARY)
    		err = lte_lc_offline();
    		if (err) {
    			printk("Error disconnecting from LTE\n");
    		}
    #endif
    		break;
    	case AWS_IOT_EVT_FOTA_ERASE_DONE:
    		printk("AWS_FOTA_EVT_ERASE_DONE\n");
    		printk("Reconnecting the LTE link");
    #if defined(CONFIG_BSD_LIBRARY)
    		err = lte_lc_connect();
    		if (err) {
    			printk("Error connecting to LTE\n");
    		}
    #endif
    		break;
    	case AWS_IOT_EVT_FOTA_DONE:
    		printk("AWS_IOT_EVT_FOTA_DONE\n");
    		printk("FOTA done, rebooting device\n");
    		aws_iot_disconnect();
    		sys_reboot(0);
    		break;
    	case AWS_IOT_EVT_FOTA_DL_PROGRESS:
    		printk("AWS_IOT_EVT_FOTA_DL_PROGRESS, (%d%%)",
    		       evt->data.fota_progress);
    	case AWS_IOT_EVT_ERROR:
    		printk("AWS_IOT_EVT_ERROR, %d\n", evt->data.err);
    		break;
    	default:
    		printk("Unknown AWS IoT event type: %d\n", evt->type);
    		break;
    	}
    }
    
    static void work_init(void)
    {
    	k_delayed_work_init(&shadow_update_work, shadow_update_work_fn);
    	k_delayed_work_init(&connect_work, connect_work_fn);
    	k_delayed_work_init(&shadow_update_version_work,
    			    shadow_update_version_work_fn);
            //add threads correponding to gps control 
    	k_delayed_work_init(&gps_start_work, gps_start_work_fn);
    	k_delayed_work_init(&reboot_work, reboot_work_fn);
    }
    
    #if defined(CONFIG_BSD_LIBRARY)
    static void lte_handler(const struct lte_lc_evt *const evt)
    {
    	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;
    		}
    
    		printk("Network registration status: %s\n",
    			evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME ?
    			"Connected - home network" : "Connected - roaming");
    
    		k_sem_give(&lte_connected);
    		break;
    	case LTE_LC_EVT_PSM_UPDATE:
    		printk("PSM parameter update: TAU: %d, Active time: %d\n",
    			evt->psm_cfg.tau, evt->psm_cfg.active_time);
    		break;
    	case LTE_LC_EVT_EDRX_UPDATE: {
    		char log_buf[60];
    		ssize_t len;
    
    		len = snprintf(log_buf, sizeof(log_buf),
    			       "eDRX parameter update: eDRX: %f, PTW: %f",
    			       evt->edrx_cfg.edrx, evt->edrx_cfg.ptw);
    		if (len > 0) {
    			printk("%s\n", log_buf);
    		}
    		break;
    	}
    	case LTE_LC_EVT_RRC_UPDATE:
    		printk("RRC mode: %s\n",
    			evt->rrc_mode == LTE_LC_RRC_MODE_CONNECTED ?
    			"Connected" : "Idle");
    		break;
    	case LTE_LC_EVT_CELL_UPDATE:
    		printk("LTE cell changed: Cell ID: %d, Tracking area: %d\n",
    			evt->cell.id, evt->cell.tac);
    		break;
    	default:
    		break;
    	}
    }
    
    static void modem_configure(void)
    {
    	int err;
    
    	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
    		/* Do nothing, modem is already configured and LTE connected. */
    	} else {
    		err = lte_lc_init_and_connect_async(lte_handler);
    		if (err) {
    			printk("Modem could not be configured, error: %d\n",
    				err);
    			return;
    		}
    	}
    }
    
    static void at_configure(void)
    {
    	int err;
    
    	err = at_notif_init();
    	__ASSERT(err == 0, "AT Notify could not be initialized.");
    	err = at_cmd_init();
    	__ASSERT(err == 0, "AT CMD could not be established.");
    }
    
    static void bsd_lib_modem_dfu_handler(void)
    {
    	int err;
    
    	err = bsdlib_init();
    
    	switch (err) {
    	case MODEM_DFU_RESULT_OK:
    		printk("Modem update suceeded, reboot\n");
    		sys_reboot(SYS_REBOOT_COLD);
    		break;
    	case MODEM_DFU_RESULT_UUID_ERROR:
    	case MODEM_DFU_RESULT_AUTH_ERROR:
    		printk("Modem update failed, error: %d\n", err);
    		printk("Modem will use old firmware\n");
    		sys_reboot(SYS_REBOOT_COLD);
    		break;
    	case MODEM_DFU_RESULT_HARDWARE_ERROR:
    	case MODEM_DFU_RESULT_INTERNAL_ERROR:
    		printk("Modem update malfunction, error: %d, reboot\n", err);
    		sys_reboot(SYS_REBOOT_COLD);
    		break;
    	default:
    		break;
    	}
    
    	at_configure();
    }
    #endif
    
    static int app_topics_subscribe(void)
    {
    	int err;
    	char custom_topic[75] = "my-custom-topic/example";
    	char custom_topic_2[75] = "my-custom-topic/example_2";
    
    	const struct aws_iot_topic_data topics_list[APP_TOPICS_COUNT] = {
    		[0].str = custom_topic,
    		[0].len = strlen(custom_topic),
    		[1].str = custom_topic_2,
    		[1].len = strlen(custom_topic_2)
    	};
    
    	err = aws_iot_subscription_topics_add(topics_list,
    					      ARRAY_SIZE(topics_list));
    	if (err) {
    		printk("aws_iot_subscription_topics_add, error: %d\n", err);
    	}
    
    	return err;
    }
    
    static void date_time_event_handler(const struct date_time_evt *evt)
    {
    	switch (evt->type) {
    	case DATE_TIME_OBTAINED_MODEM:
    		printk("DATE_TIME_OBTAINED_MODEM\n");
    		break;
    	case DATE_TIME_OBTAINED_NTP:
    		printk("DATE_TIME_OBTAINED_NTP\n");
    		break;
    	case DATE_TIME_OBTAINED_EXT:
    		printk("DATE_TIME_OBTAINED_EXT\n");
    		break;
    	case DATE_TIME_NOT_OBTAINED:
    		printk("DATE_TIME_NOT_OBTAINED\n");
    		break;
    	default:
    		break;
    	}
    
    	/** Do not depend on obtained time, continue upon any event from the
    	 *  date time library.
    	 */
    	k_sem_give(&date_time_obtained);
    }
    
    void main(void)
    {
    	int err;
    
    	printk("The AWS IoT sample started, version: %s\n", CONFIG_APP_VERSION);
    
    	cJSON_Init();
    
    #if defined(CONFIG_BSD_LIBRARY)
    	bsd_lib_modem_dfu_handler();
    #endif
    
    	err = aws_iot_init(NULL, aws_iot_event_handler);
    	if (err) {
    		printk("AWS IoT library could not be initialized, error: %d\n",
    		       err);
    	}
    
    	/** Subscribe to customizable non-shadow specific topics
    	 *  to AWS IoT backend.
    	 */
    	err = app_topics_subscribe();
    	if (err) {
    		printk("Adding application specific topics failed, error: %d\n",
    			err);
    	}
    
    	work_init();//tiene agragados dos hilos correspondientes a gps
    #if defined(CONFIG_BSD_LIBRARY)
    	modem_configure();
    
    	err = modem_info_init();
    	if (err) {
    		printk("Failed initializing modem info module, error: %d\n",
    			err);
    	}
    //**************** START GPS FUNCTIONS **************
           
            gps_dev = device_get_binding("NRF9160_GPS");//binding gps with nrf9160
            if (gps_dev == NULL) {
    		printk("Could not get binding to nRF9160 GPS");
    	}
    
    	err = gps_init(gps_dev, gps_handler);//initializes gps (gps_dev) and the actions control id by gps_handler
    	if (err) {
    		printk("Could not initialize GPS, error: %d", err);
    	}
    //**************** END GPS FUNCTION **************
    	
            k_sem_take(&lte_connected, K_FOREVER);
    #endif
    
    
    	date_time_update_async(date_time_event_handler);
    
    	err = k_sem_take(&date_time_obtained, K_SECONDS(DATE_TIME_TIMEOUT_S));
    	if (err) {
    		printk("Date time, no callback event within %d seconds\n",
    			DATE_TIME_TIMEOUT_S);
    	}
    
    	k_delayed_work_submit(&connect_work, K_NO_WAIT);
    }
    

  • Hi!

    So, you can find the documentation for the %XMONITOR AT Command here. From your result, we see 

    Active-Time: 11100000 - deactivated

    Periodic-TAU-ext: 11100000 - deactivated

    Periodic-TAU: 01001001 - 36 minutes

     

    tracking said:
    which one is the modification? I had undertood that with this line (L348) the modem change to psm o mode idle when the pakage was transmitted and in this condition the gps can work.

     Yes, L348 is the modification you need to add to the modem_configure() function in the AWS IoT sample to request PSM. And preferably the following four lines to catch any errors. 

    tracking said:
    yes, I include gps driver, but I don't know what cosiderations I must have with Cmakelists, Kconfig, prj.conf and other files 

     Then you go into these files in the AGPS sample and you see if there are any GPS-related considerations that you should include in your sample. prj.conf L52 adds CONFIG_NRF9160_GPS=y to enable the GPS driver so you should include this as well. 

  • Hi!

    I read this documentation, but I stil without undertand these times:

    Active-Time: 11100000 - deactivated

    Periodic-TAU-ext: 11100000 - deactivated

    Periodic-TAU: 01001001 - 36 minutes

    which function have each of them?

    can I control them?

    there are any relation whit these values? (autoconf.h agps sample)

    other question, in aws_iot sample I modified the time between publications to 300 (kconfig file), but the modem stil change connect and idle mode each 60 seconds, what more must I change to give more time to gps?

    thanks in advance

Related