<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1</link><description>Hello 
 I&amp;#39;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&amp;#39;t find where change the value of type 1 mesagge to transmit, I look for it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 May 2021 20:40:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1" /><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/311909?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 20:40:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97508af7-8254-40a2-87ee-a659ce36c9dc</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi!&lt;/p&gt;
&lt;p&gt;Ok, no problem, thanks for your help!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Julio&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/311743?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 11:20:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c4f2150-d76b-48b6-a686-4cfedfe28442</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;Hi! I see.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is a bit out of my expertise and also very unrelated to your original inquiry. Could you please make a new ticket about this and you will be assigned an engineer who can answer it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Heidi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/310869?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 21:03:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49d5d417-7daf-43dd-b35a-5962e5d64d98</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi!&lt;/p&gt;
&lt;p&gt;I proved the AT%XMONITOR with my code and show me this values:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/valores_5F00_xmonitor.png" /&gt;&lt;/p&gt;
&lt;p&gt;I understand that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;active time: &amp;quot;00000010&amp;quot; means four seconds to pass of connected mode to idle mode&lt;/p&gt;
&lt;p&gt;periodic tau ext: &amp;quot;00011111&amp;quot; means 10 minutes x 31 = 310 minutes, I don&amp;acute;t understand with accuracy what controls this time&lt;/p&gt;
&lt;p&gt;periodic tau: &amp;quot;01011111&amp;quot; means 10 hours x 31 = 310 hours, this time is the time between ubication updates of modem, but this update is&amp;#39;t a message to cloud it is only to network knows the modem location&lt;/p&gt;
&lt;p&gt;Other question&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I run the example, this happens:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;RRC mode: Connected&lt;/p&gt;
&lt;p&gt;//aproximatly after 4 seconds&lt;/p&gt;
&lt;p&gt;RRC mode: Idle&lt;/p&gt;
&lt;p&gt;// aproximatly after 60 seconds&lt;/p&gt;
&lt;p&gt;RRC mode&lt;span&gt;: Connected&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and so on, but gps don&amp;#39;t active in any time&lt;/p&gt;
&lt;p&gt;how can I control the time between Idle and Conneted mode (in this case 60 seconds)?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/work_5F00_init-awsiot_5F00_gps.png" /&gt;&lt;/p&gt;
&lt;p&gt;The two last lines belong to agps example and I added to work init function in aws_iot sample, I undertand that in this code there are five threads, three for aws and two for gps control, is this correct?&lt;/p&gt;
&lt;p&gt;thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/309684?ContentTypeID=1</link><pubDate>Thu, 13 May 2021 19:38:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14f949de-2f8a-4551-91de-344eecbc7aaa</guid><dc:creator>Heidi</dc:creator><description>[quote user="tracking"]which function have each of them?[/quote]
&lt;p&gt;&amp;nbsp;The active timer determines the duration during which the device remains reachable for mobile terminated transactions on the transition from connected to idle mode.&lt;/p&gt;
&lt;p&gt;The periodic TAU timer determines how often the device will send a periodic tracking update to the network&lt;/p&gt;
&lt;p&gt;The extended periodic TAU timer just allows for a longer periodic TAU timer.&amp;nbsp;&lt;/p&gt;
[quote user="tracking"]can I control them?[/quote]
&lt;p&gt;&amp;nbsp;You can request values from the network using +CPSMS but the network can give you different values than what you requested.&amp;nbsp;&lt;/p&gt;
[quote user="tracking"]there are any relation whit these values?[/quote]
&lt;p&gt;&amp;nbsp;Yes, LTE_PSM_REQ_RPTAU is the requested periodic TAU and&amp;nbsp;LTE_PSM_REQ_RAT is the requested active time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="tracking"]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?[/quote]
&lt;p&gt;&amp;nbsp;60 seconds? From the %XMONITOR results, it says the periodic TAU is 36 minutes? Did you change these configurations?&lt;/p&gt;
&lt;p&gt;You will need to change the PSM configurations to give more time to the GPS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/308854?ContentTypeID=1</link><pubDate>Mon, 10 May 2021 00:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f22619ae-dd84-4a51-ad92-e437e617249e</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I read&amp;nbsp;&lt;a title="this" href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fref_at_commands%2FREF%2Fat_commands%2Fnw_service%2Fxmonitor_set.html" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt; documentation, but I stil without undertand these times:&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/307956#307956"]&lt;p&gt;Active-Time: 11100000 - deactivated&lt;/p&gt;
&lt;p&gt;Periodic-TAU-ext:&amp;nbsp;&lt;span&gt;11100000 - deactivated&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Periodic-TAU: 01001001 - 36 minutes&lt;/p&gt;[/quote]
&lt;p&gt;which function have each of them?&lt;/p&gt;
&lt;p&gt;can I control them?&lt;/p&gt;
&lt;p&gt;there are any relation whit these values? (autoconf.h agps sample)&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/valores-configurables-autoconfh.png" /&gt;&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/cambio-de-tiempo-aws_5F00_iot.png" /&gt;&lt;/p&gt;
&lt;p&gt;thanks in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/307956?ContentTypeID=1</link><pubDate>Mon, 03 May 2021 13:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c0aa33e-23ff-4662-a689-a659666ca6ea</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, you can find the documentation for the %XMONITOR AT Command &lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/xmonitor_set.html"&gt;here&lt;/a&gt;. From your result, we see&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Active-Time: 11100000 - deactivated&lt;/p&gt;
&lt;p&gt;Periodic-TAU-ext:&amp;nbsp;&lt;span&gt;11100000 - deactivated&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Periodic-TAU: 01001001 - 36 minutes&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="tracking"]which one is the modification? I had undertood that with this line&amp;nbsp;&lt;span&gt;(&lt;/span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L348"&gt;L348&lt;/a&gt;&lt;span&gt;)&lt;/span&gt; the modem change to psm o mode idle when the pakage was transmitted and in this condition the gps can work.[/quote]
&lt;p&gt;&amp;nbsp;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.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="tracking"]yes, I include gps driver, but I don&amp;#39;t know what cosiderations I must have with Cmakelists, Kconfig, prj.conf and other files&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;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.&amp;nbsp;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/prj.conf#L52"&gt;prj.conf L52&lt;/a&gt; adds CONFIG_NRF9160_GPS=y&amp;nbsp;to enable the GPS driver so you should include this as well.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/307715?ContentTypeID=1</link><pubDate>Fri, 30 Apr 2021 15:35:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07d8f690-54d2-4d83-9981-bc7b6757b4e5</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;thanks for that, but I don&amp;#39;t find how interprete the result&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/307545#307545"]You can use AT%XMONITOR to read the Active Time and Periodic TAU set by the network.[/quote]
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/tiempos-fijados-por-la-red.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/307545#307545"]Yes, you can use the modem_configure() in the AWS IoT sample, but you need to modify it to request PSM&amp;nbsp;(&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L348"&gt;L348&lt;/a&gt;).[/quote]
&lt;p&gt;which one is the modification? I had undertood that with this line&amp;nbsp;&lt;span&gt;(&lt;/span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L348"&gt;L348&lt;/a&gt;&lt;span&gt;)&lt;/span&gt; the modem change to psm o mode idle when the pakage was transmitted and in this condition the gps can work.&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/307545#307545"]Did you include the GPS driver (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L13"&gt;L13&lt;/a&gt;)?[/quote]
&lt;p&gt;yes, I include gps driver, but I don&amp;#39;t know what cosiderations I must have with Cmakelists, Kconfig, prj.conf and other files&amp;nbsp;&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/307545#307545"]Can I see your main.c file?[/quote]
&lt;p&gt;yes, of course&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#if defined(CONFIG_BSD_LIB)
#include &amp;lt;modem/lte_lc.h&amp;gt;
#include &amp;lt;modem/bsdlib.h&amp;gt;
#include &amp;lt;modem/at_cmd.h&amp;gt;
#include &amp;lt;modem/at_notif.h&amp;gt;
#include &amp;lt;modem/modem_info.h&amp;gt;
#include &amp;lt;bsd.h&amp;gt;
#endif
#include &amp;lt;net/aws_iot.h&amp;gt;
#include &amp;lt;power/reboot.h&amp;gt;
#include &amp;lt;date_time.h&amp;gt;
#include &amp;lt;dfu/mcuboot.h&amp;gt;
#include &amp;lt;cJSON.h&amp;gt;
#include &amp;lt;cJSON_os.h&amp;gt;
#include &amp;lt;drivers/gps.h&amp;gt;//corresponds to gps 
//#include &amp;lt;logging/log.h&amp;gt;//corresponds to gps

BUILD_ASSERT(!IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT),
		&amp;quot;This sample does not support LTE auto-init and connect&amp;quot;);

#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&amp;#225;

	err = gps_start(gps_dev, &amp;amp;gps_cfg);//loads api on device and initialize wiht gps_cfg configuration 
	if (err) {
		//LOG_ERR(&amp;quot;Failed to start GPS, error: %d&amp;quot;, err);//error in __log_level I don&amp;#39;t know why
                printk(&amp;quot;Failed to start GPS, error: %d&amp;quot;, err);
		return;
	}

	//LOG_INF(&amp;quot;Periodic GPS search started with interval %d s, timeout %d s&amp;quot;,  
	//	gps_cfg.interval, gps_cfg.timeout);
        printk(&amp;quot;Periodic GPS search started with interval %d s, timeout %d s&amp;quot;,  
		gps_cfg.interval, gps_cfg.timeout);
}
static void reboot_work_fn(struct k_work *work)
{
	//LOG_WRN(&amp;quot;Rebooting in 2 seconds...&amp;quot;);
        printk(&amp;quot;Rebooting in 2 seconds...&amp;quot;);
	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),
		      &amp;quot;\r\n\tLongitude:  %f\r\n\t&amp;quot;
		      &amp;quot;Latitude:   %f\r\n\t&amp;quot;
		      &amp;quot;Altitude:   %f\r\n\t&amp;quot;
		      &amp;quot;Speed:      %f\r\n\t&amp;quot;
		      &amp;quot;Heading:    %f\r\n\t&amp;quot;
		      &amp;quot;Date:       %02u-%02u-%02u\r\n\t&amp;quot;
		      &amp;quot;Time (UTC): %02u:%02u:%02u\r\n&amp;quot;,
		      pvt_data-&amp;gt;longitude, pvt_data-&amp;gt;latitude,
		      pvt_data-&amp;gt;altitude, pvt_data-&amp;gt;speed, pvt_data-&amp;gt;heading,
		      pvt_data-&amp;gt;datetime.day, pvt_data-&amp;gt;datetime.month,
		      pvt_data-&amp;gt;datetime.year, pvt_data-&amp;gt;datetime.hour,
		      pvt_data-&amp;gt;datetime.minute, pvt_data-&amp;gt;datetime.seconds);
	if (len &amp;lt; 0) {
		printk(&amp;quot;Could not construct PVT print&amp;quot;);
	} else {
		//printk(&amp;quot;%s&amp;quot;, log_strdup(buf));//I don&amp;#39;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-&amp;gt;type) {
	case GPS_EVT_SEARCH_STARTED:
		//LOG_INF(&amp;quot;GPS_EVT_SEARCH_STARTED&amp;quot;);
                printk(&amp;quot;GPS_EVT_SEARCH_STARTED&amp;quot;);
		start_search_timestamp = k_uptime_get();
		break;
	case GPS_EVT_SEARCH_STOPPED:
		//LOG_INF(&amp;quot;GPS_EVT_SEARCH_STOPPED&amp;quot;);
                printk(&amp;quot;GPS_EVT_SEARCH_STOPPED&amp;quot;);
		break;
	case GPS_EVT_SEARCH_TIMEOUT:
		//LOG_INF(&amp;quot;GPS_EVT_SEARCH_TIMEOUT&amp;quot;);
                printk(&amp;quot;GPS_EVT_SEARCH_TIMEOUT&amp;quot;);
		break;
	case GPS_EVT_OPERATION_BLOCKED:
		//LOG_INF(&amp;quot;GPS_EVT_OPERATION_BLOCKED&amp;quot;);
                printk(&amp;quot;GPS_EVT_OPERATION_BLOCKED&amp;quot;);
		break;
	case GPS_EVT_OPERATION_UNBLOCKED:
		//LOG_INF(&amp;quot;GPS_EVT_OPERATION_UNBLOCKED&amp;quot;);
                printk(&amp;quot;GPS_EVT_OPERATION_UNBLOCKED&amp;quot;);
		break;
	//case GPS_EVT_AGPS_DATA_NEEDED://this case is not used because do the conection but with nrfcloud
	//	//LOG_INF(&amp;quot;GPS_EVT_AGPS_DATA_NEEDED&amp;quot;);
        //          printk(&amp;quot;GPS_EVT_AGPS_DATA_NEEDED&amp;quot;);
	//	on_agps_needed(evt-&amp;gt;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(&amp;amp;evt-&amp;gt;pvt);
	//	break;
	case GPS_EVT_PVT_FIX:
		fix_timestamp = k_uptime_get();

		printk(&amp;quot;---------       FIX       ---------&amp;quot;);
		printk(&amp;quot;Time to fix: %d seconds&amp;quot;,
			(uint32_t)(fix_timestamp - start_search_timestamp) / 1000);
		print_pvt_data(&amp;amp;evt-&amp;gt;pvt);
		printk(&amp;quot;-----------------------------------&amp;quot;);
		break;
	//case GPS_EVT_NMEA_FIX://this case create and send the messagge but to nrfcloud
	//	send_nmea(evt-&amp;gt;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(&amp;amp;message_ts);
	if (err) {
		printk(&amp;quot;date_time_now, error: %d\n&amp;quot;, err);
		return err;
	}

#if defined(CONFIG_BSD_LIBRARY)
	/* Request battery voltage data from the modem. */
	err = modem_info_short_get(MODEM_INFO_BATTERY, &amp;amp;bat_voltage);
	if (err != sizeof(bat_voltage)) {
		printk(&amp;quot;modem_info_short_get, error: %d\n&amp;quot;, 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, &amp;quot;app_version&amp;quot;,
				    CONFIG_APP_VERSION);
	} else {
		err = 0;
	}

	err += json_add_number(reported_obj, &amp;quot;batv&amp;quot;, bat_voltage);
	err += json_add_number(reported_obj, &amp;quot;ts&amp;quot;, message_ts);
	err += json_add_obj(state_obj, &amp;quot;reported&amp;quot;, reported_obj);
	err += json_add_obj(root_obj, &amp;quot;state&amp;quot;, state_obj);

	if (err) {
		printk(&amp;quot;json_add, error: %d\n&amp;quot;, err);
		goto cleanup;
	}

	message = cJSON_Print(root_obj);
	if (message == NULL) {
		printk(&amp;quot;cJSON_Print, error: returned NULL\n&amp;quot;);
		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(&amp;quot;Publishing: %s to AWS IoT broker\n&amp;quot;, message);

	err = aws_iot_send(&amp;amp;tx_data);
	if (err) {
		printk(&amp;quot;aws_iot_send, error: %d\n&amp;quot;, 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(&amp;quot;aws_iot_connect, error: %d\n&amp;quot;, err);
	}

	printk(&amp;quot;Next connection retry in %d seconds\n&amp;quot;,
	       CONFIG_CONNECTION_RETRY_TIMEOUT_SECONDS);

	k_delayed_work_submit(&amp;amp;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(&amp;quot;shadow_update, error: %d\n&amp;quot;, err);
	}

	printk(&amp;quot;Next data publication in %d seconds\n&amp;quot;,
	       CONFIG_PUBLICATION_INTERVAL_SECONDS);

	k_delayed_work_submit(&amp;amp;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(&amp;quot;shadow_update, error: %d\n&amp;quot;, 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(&amp;quot;cJSON Parse failure&amp;quot;);
		return;
	}

	str = cJSON_Print(root_obj);
	if (str == NULL) {
		printk(&amp;quot;Failed to print JSON object&amp;quot;);
		goto clean_exit;
	}

	printf(&amp;quot;Data received from AWS IoT console:\nTopic: %.*s\nMessage: %s\n&amp;quot;,
	       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-&amp;gt;type) {
	case AWS_IOT_EVT_CONNECTING:
		printk(&amp;quot;AWS_IOT_EVT_CONNECTING\n&amp;quot;);
		break;
	case AWS_IOT_EVT_CONNECTED:
		printk(&amp;quot;AWS_IOT_EVT_CONNECTED\n&amp;quot;);

		k_delayed_work_cancel(&amp;amp;connect_work);

		if (evt-&amp;gt;data.persistent_session) {
			printk(&amp;quot;Persistent session enabled\n&amp;quot;);
		}

#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(&amp;amp;shadow_update_version_work, K_NO_WAIT);

		/** Start sequential shadow data updates.
		 */
		k_delayed_work_submit(&amp;amp;shadow_update_work,
				K_SECONDS(CONFIG_PUBLICATION_INTERVAL_SECONDS));

#if defined(CONFIG_BSD_LIBRARY)
		int err = lte_lc_psm_req(true);
		if (err) {
			printk(&amp;quot;Requesting PSM failed, error: %d\n&amp;quot;, err);
		}
#endif
		break;
	case AWS_IOT_EVT_READY:
		printk(&amp;quot;AWS_IOT_EVT_READY\n&amp;quot;);
		break;
	case AWS_IOT_EVT_DISCONNECTED:
		printk(&amp;quot;AWS_IOT_EVT_DISCONNECTED\n&amp;quot;);
		k_delayed_work_cancel(&amp;amp;shadow_update_work);

		if (k_delayed_work_pending(&amp;amp;connect_work)) {
			break;
		}

		k_delayed_work_submit(&amp;amp;connect_work, K_NO_WAIT);
		break;
	case AWS_IOT_EVT_DATA_RECEIVED:
		printk(&amp;quot;AWS_IOT_EVT_DATA_RECEIVED\n&amp;quot;);
		print_received_data(evt-&amp;gt;data.msg.ptr, evt-&amp;gt;data.msg.topic.str,
				    evt-&amp;gt;data.msg.topic.len);
		break;
	case AWS_IOT_EVT_FOTA_START:
		printk(&amp;quot;AWS_IOT_EVT_FOTA_START\n&amp;quot;);
		break;
	case AWS_IOT_EVT_FOTA_ERASE_PENDING:
		printk(&amp;quot;AWS_IOT_EVT_FOTA_ERASE_PENDING\n&amp;quot;);
		printk(&amp;quot;Disconnect LTE link or reboot\n&amp;quot;);
#if defined(CONFIG_BSD_LIBRARY)
		err = lte_lc_offline();
		if (err) {
			printk(&amp;quot;Error disconnecting from LTE\n&amp;quot;);
		}
#endif
		break;
	case AWS_IOT_EVT_FOTA_ERASE_DONE:
		printk(&amp;quot;AWS_FOTA_EVT_ERASE_DONE\n&amp;quot;);
		printk(&amp;quot;Reconnecting the LTE link&amp;quot;);
#if defined(CONFIG_BSD_LIBRARY)
		err = lte_lc_connect();
		if (err) {
			printk(&amp;quot;Error connecting to LTE\n&amp;quot;);
		}
#endif
		break;
	case AWS_IOT_EVT_FOTA_DONE:
		printk(&amp;quot;AWS_IOT_EVT_FOTA_DONE\n&amp;quot;);
		printk(&amp;quot;FOTA done, rebooting device\n&amp;quot;);
		aws_iot_disconnect();
		sys_reboot(0);
		break;
	case AWS_IOT_EVT_FOTA_DL_PROGRESS:
		printk(&amp;quot;AWS_IOT_EVT_FOTA_DL_PROGRESS, (%d%%)&amp;quot;,
		       evt-&amp;gt;data.fota_progress);
	case AWS_IOT_EVT_ERROR:
		printk(&amp;quot;AWS_IOT_EVT_ERROR, %d\n&amp;quot;, evt-&amp;gt;data.err);
		break;
	default:
		printk(&amp;quot;Unknown AWS IoT event type: %d\n&amp;quot;, evt-&amp;gt;type);
		break;
	}
}

static void work_init(void)
{
	k_delayed_work_init(&amp;amp;shadow_update_work, shadow_update_work_fn);
	k_delayed_work_init(&amp;amp;connect_work, connect_work_fn);
	k_delayed_work_init(&amp;amp;shadow_update_version_work,
			    shadow_update_version_work_fn);
        //add threads correponding to gps control 
	k_delayed_work_init(&amp;amp;gps_start_work, gps_start_work_fn);
	k_delayed_work_init(&amp;amp;reboot_work, reboot_work_fn);
}

#if defined(CONFIG_BSD_LIBRARY)
static void lte_handler(const struct lte_lc_evt *const evt)
{
	switch (evt-&amp;gt;type) {
	case LTE_LC_EVT_NW_REG_STATUS:
		if ((evt-&amp;gt;nw_reg_status != LTE_LC_NW_REG_REGISTERED_HOME) &amp;amp;&amp;amp;
		     (evt-&amp;gt;nw_reg_status != LTE_LC_NW_REG_REGISTERED_ROAMING)) {
			break;
		}

		printk(&amp;quot;Network registration status: %s\n&amp;quot;,
			evt-&amp;gt;nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME ?
			&amp;quot;Connected - home network&amp;quot; : &amp;quot;Connected - roaming&amp;quot;);

		k_sem_give(&amp;amp;lte_connected);
		break;
	case LTE_LC_EVT_PSM_UPDATE:
		printk(&amp;quot;PSM parameter update: TAU: %d, Active time: %d\n&amp;quot;,
			evt-&amp;gt;psm_cfg.tau, evt-&amp;gt;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),
			       &amp;quot;eDRX parameter update: eDRX: %f, PTW: %f&amp;quot;,
			       evt-&amp;gt;edrx_cfg.edrx, evt-&amp;gt;edrx_cfg.ptw);
		if (len &amp;gt; 0) {
			printk(&amp;quot;%s\n&amp;quot;, log_buf);
		}
		break;
	}
	case LTE_LC_EVT_RRC_UPDATE:
		printk(&amp;quot;RRC mode: %s\n&amp;quot;,
			evt-&amp;gt;rrc_mode == LTE_LC_RRC_MODE_CONNECTED ?
			&amp;quot;Connected&amp;quot; : &amp;quot;Idle&amp;quot;);
		break;
	case LTE_LC_EVT_CELL_UPDATE:
		printk(&amp;quot;LTE cell changed: Cell ID: %d, Tracking area: %d\n&amp;quot;,
			evt-&amp;gt;cell.id, evt-&amp;gt;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(&amp;quot;Modem could not be configured, error: %d\n&amp;quot;,
				err);
			return;
		}
	}
}

static void at_configure(void)
{
	int err;

	err = at_notif_init();
	__ASSERT(err == 0, &amp;quot;AT Notify could not be initialized.&amp;quot;);
	err = at_cmd_init();
	__ASSERT(err == 0, &amp;quot;AT CMD could not be established.&amp;quot;);
}

static void bsd_lib_modem_dfu_handler(void)
{
	int err;

	err = bsdlib_init();

	switch (err) {
	case MODEM_DFU_RESULT_OK:
		printk(&amp;quot;Modem update suceeded, reboot\n&amp;quot;);
		sys_reboot(SYS_REBOOT_COLD);
		break;
	case MODEM_DFU_RESULT_UUID_ERROR:
	case MODEM_DFU_RESULT_AUTH_ERROR:
		printk(&amp;quot;Modem update failed, error: %d\n&amp;quot;, err);
		printk(&amp;quot;Modem will use old firmware\n&amp;quot;);
		sys_reboot(SYS_REBOOT_COLD);
		break;
	case MODEM_DFU_RESULT_HARDWARE_ERROR:
	case MODEM_DFU_RESULT_INTERNAL_ERROR:
		printk(&amp;quot;Modem update malfunction, error: %d, reboot\n&amp;quot;, err);
		sys_reboot(SYS_REBOOT_COLD);
		break;
	default:
		break;
	}

	at_configure();
}
#endif

static int app_topics_subscribe(void)
{
	int err;
	char custom_topic[75] = &amp;quot;my-custom-topic/example&amp;quot;;
	char custom_topic_2[75] = &amp;quot;my-custom-topic/example_2&amp;quot;;

	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(&amp;quot;aws_iot_subscription_topics_add, error: %d\n&amp;quot;, err);
	}

	return err;
}

static void date_time_event_handler(const struct date_time_evt *evt)
{
	switch (evt-&amp;gt;type) {
	case DATE_TIME_OBTAINED_MODEM:
		printk(&amp;quot;DATE_TIME_OBTAINED_MODEM\n&amp;quot;);
		break;
	case DATE_TIME_OBTAINED_NTP:
		printk(&amp;quot;DATE_TIME_OBTAINED_NTP\n&amp;quot;);
		break;
	case DATE_TIME_OBTAINED_EXT:
		printk(&amp;quot;DATE_TIME_OBTAINED_EXT\n&amp;quot;);
		break;
	case DATE_TIME_NOT_OBTAINED:
		printk(&amp;quot;DATE_TIME_NOT_OBTAINED\n&amp;quot;);
		break;
	default:
		break;
	}

	/** Do not depend on obtained time, continue upon any event from the
	 *  date time library.
	 */
	k_sem_give(&amp;amp;date_time_obtained);
}

void main(void)
{
	int err;

	printk(&amp;quot;The AWS IoT sample started, version: %s\n&amp;quot;, 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(&amp;quot;AWS IoT library could not be initialized, error: %d\n&amp;quot;,
		       err);
	}

	/** Subscribe to customizable non-shadow specific topics
	 *  to AWS IoT backend.
	 */
	err = app_topics_subscribe();
	if (err) {
		printk(&amp;quot;Adding application specific topics failed, error: %d\n&amp;quot;,
			err);
	}

	work_init();//tiene agragados dos hilos correspondientes a gps
#if defined(CONFIG_BSD_LIBRARY)
	modem_configure();

	err = modem_info_init();
	if (err) {
		printk(&amp;quot;Failed initializing modem info module, error: %d\n&amp;quot;,
			err);
	}
//**************** START GPS FUNCTIONS **************
       
        gps_dev = device_get_binding(&amp;quot;NRF9160_GPS&amp;quot;);//binding gps with nrf9160
        if (gps_dev == NULL) {
		printk(&amp;quot;Could not get binding to nRF9160 GPS&amp;quot;);
	}

	err = gps_init(gps_dev, gps_handler);//initializes gps (gps_dev) and the actions control id by gps_handler
	if (err) {
		printk(&amp;quot;Could not initialize GPS, error: %d&amp;quot;, err);
	}
//**************** END GPS FUNCTION **************
	
        k_sem_take(&amp;amp;lte_connected, K_FOREVER);
#endif


	date_time_update_async(date_time_event_handler);

	err = k_sem_take(&amp;amp;date_time_obtained, K_SECONDS(DATE_TIME_TIMEOUT_S));
	if (err) {
		printk(&amp;quot;Date time, no callback event within %d seconds\n&amp;quot;,
			DATE_TIME_TIMEOUT_S);
	}

	k_delayed_work_submit(&amp;amp;connect_work, K_NO_WAIT);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/307545?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 15:55:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b95a6c15-b031-4847-9205-fa6423ef69b1</guid><dc:creator>Heidi</dc:creator><description>[quote user="tracking"]how can I know the timers set by the network where my UE is conneted?[/quote]
&lt;p&gt;&amp;nbsp;You can use AT%XMONITOR to read the Active Time and Periodic TAU set by the network.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, you can use the modem_configure() in the AWS IoT sample, but you need to modify it to request PSM&amp;nbsp;(&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L348"&gt;L348&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Did you include the GPS driver (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L13"&gt;L13&lt;/a&gt;)? Can I see your main.c file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/307109?ContentTypeID=1</link><pubDate>Tue, 27 Apr 2021 21:46:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c801cfd-6499-4764-aeb4-5c8b02d4d1df</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi!&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/306268#306268"]The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network[/quote]
&lt;p&gt;how can I know the timers set by the network where my UE is conneted?&lt;/p&gt;
[quote userid="82276" url="~/f/nordic-q-a/73312/aws-iot-how-change-the-messagge-type-1/305824#305824"]Then once the modem has been configured (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L398"&gt;L398&lt;/a&gt;) and the device binding for the nRF9160 GPS is complete (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L405"&gt;L405&lt;/a&gt;)[/quote]
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/not-get-binding.png" /&gt;&lt;/p&gt;
&lt;p&gt;I try to read about what is binding operation but don&amp;#39;t find documentation about this, the modem_configure(); in aws_iot (&lt;a title="L372" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L372" rel="noopener noreferrer" target="_blank"&gt;L372&lt;/a&gt;) is the same that agps (&lt;a title="L336" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L336" rel="noopener noreferrer" target="_blank"&gt;L336&lt;/a&gt;), I mean, can the gps work with the modem_configure(); of aws_iot?&lt;/p&gt;
&lt;p&gt;edit: I tried to debug but I don&amp;#39;t know how to verify or control the binding function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/306268?ContentTypeID=1</link><pubDate>Thu, 22 Apr 2021 09:41:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4877b08-34c3-4009-b80f-097ae3a553a2</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network. That&amp;#39;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.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s important to request a time long enough for the GPS to be able to get a fix though. &lt;a href="https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/nw_service/cpsms_set.html"&gt;AT+CPSMS&lt;/a&gt;&amp;nbsp;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.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/306195?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 21:35:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c37154b5-cd6e-49ca-b2e7-0d1e5181f333</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you very much I understand better now the gps manage, however I don&amp;#39;t undertand the modem manage because in&amp;nbsp;&amp;nbsp;&lt;a title="L348" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L348" rel="noopener noreferrer" target="_blank"&gt;L348&lt;/a&gt;&amp;nbsp;require psm mode but then don&amp;#39;t&amp;nbsp;go out of psm mode again.&lt;/p&gt;
&lt;p&gt;In documentation I find that gps works better with modem en PSM and eDRX mode but when I wanna transmit how I active the modem to connect and&amp;nbsp;transmit?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/305824?ContentTypeID=1</link><pubDate>Tue, 20 Apr 2021 11:34:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84ca5df1-a480-4e51-a5fb-4b7de470f82a</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi, let&amp;#39;s start in the main file.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;work_init() is called (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L396"&gt;L396&lt;/a&gt;) which&amp;nbsp;calls&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;k_delayed_work_init&lt;/span&gt;(&amp;amp;gps_start_work, gps_start_work_fn); (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L332"&gt;L332&lt;/a&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This initializes the work item&amp;nbsp;gps_start_work as a delayed work item with the handler &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L51"&gt;gps_start_work_fn&lt;/a&gt;(), which configures and starts the GPS.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then once the modem has been configured (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L398"&gt;L398&lt;/a&gt;) and the device binding for the nRF9160 GPS is complete (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L405"&gt;L405&lt;/a&gt;), the GPS is initialized (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L411"&gt;L411&lt;/a&gt;), which the device from the binding (gps_dev) and a &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c#L278-L321"&gt;gps_handler&lt;/a&gt;() that&amp;#39;s defined earlier.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; err = &lt;span&gt;gps_init&lt;/span&gt;(gps_dev, gps_handler); is defined in &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/include/drivers/gps.h#L366"&gt;nrf/include/drivers/gps.h L366&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/305664?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 23:46:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:303461bc-4803-428f-9a5e-692f32893a47</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Thank for your recomendation, I have a doubt whit AGPS sample, where is the recursivity or the interrup to take the gps data? I don&amp;#39;t understand that part&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/304231?ContentTypeID=1</link><pubDate>Mon, 12 Apr 2021 11:07:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:099d94b6-b1e0-4505-a4e5-3a4fb3bc7083</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;work_init() initializes three delayed work items (shadow_update_work, connect_work and shadow_update_version_work) prior to their first use (see: &lt;a href="https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html#submitting-a-delayed-work-item"&gt;Zephyr: Submitting a Delayed Work Item&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_modem_lib_dfu_handler() initializes the nRF Modem Libary (formerly called BSD Lib) which is the library used to run the modem on the nRF9160 SiP (see &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/include/modem/nrf_modem_lib.h#L24-L48"&gt;nrf_modem_lib.h#L24-L48&lt;/a&gt;&amp;nbsp;for a full description). It then has a switch case for the error code from the function. Lastly, it initializes the AT Cmd and AT Notif libraries.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I linked the meaning of the errors in my previous comment. EINVAL (22) is invalid argument. If you want to know why that function is returning this, you can take a look at where it is used in the code and the function definition (see &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/lib/lte_link_control/lte_lc.c#L1811-L1871"&gt;lte_lc.c#811-L1871&lt;/a&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Looks like the sample already requests to set the modem in PSM mode (see &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L250"&gt;main.c#L250&lt;/a&gt;), so you don&amp;#39;t have to think about this. Try integrating a GPS handler and GPS init function like in the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/agps/src/main.c"&gt;AGPS sample&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/303612?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 22:10:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e17dd49a-ec23-4684-84f2-f393b59f49c1</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi!&lt;/p&gt;
&lt;p&gt;I can see the errors thanks for that, now analazing the aws_iot sample to know how implement PSM or eDRX mode and I don&amp;acute;t undestand the&amp;nbsp;&lt;a title="work_init()" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L318" rel="noopener noreferrer" target="_blank"&gt;work_init()&lt;/a&gt;&amp;nbsp;function, how works&amp;nbsp;&lt;span&gt;k_delayed_work_init()?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I undertand that in main.c transmition is in&amp;nbsp;&lt;a title="L497" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L497" rel="noopener noreferrer" target="_blank"&gt;L497&lt;/a&gt;, but just after this line can I put LTE modem in PSM or eDRX mode and then activate GPS?&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;edition I: I don&amp;#39;t undertand what&amp;nbsp;&lt;a title="link" href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L398" rel="noopener noreferrer" target="_blank"&gt;nrf_modem_lib_dfu_handler()&lt;/a&gt;&amp;nbsp;does and what is the meaninig of this&amp;nbsp;#define MODEM_DFU_RESULT_OK 0x5500001u?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;edition II: how I can find the errors meaning? i.e. this function&amp;nbsp;&lt;a title="function" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/modem/lte_lc.html#api-documentation" rel="noopener noreferrer" target="_blank"&gt;lte_lc_func_mode_get()&lt;/a&gt;&amp;nbsp;return -22, but I can&amp;#39;t find its meaning&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/303454?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 11:22:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49427cc2-0729-4804-b864-70eec267649d</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;Hi!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The errors are defined in &lt;a href="https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h"&gt;newlib&amp;#39;s errno.h&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#&lt;/span&gt;&lt;span&gt;define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;EBADF&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;9&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;/* Bad file number */&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You are correct, the GPS and LTE functionality of the modem cannot work concurrently. So you can either put the modem in offline mode every time you want to use the GPS, though we do not recommend this method because the UE will disconnect from the network and has to go through the attach process every time you turn the modem back on which takes time and increases the current consumption of the application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Instead, you can find out of your network supports PSM or eDRX and then put the modem in one of these modes before activating the GPS.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/302913?ContentTypeID=1</link><pubDate>Sat, 03 Apr 2021 01:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47b5ed1c-cadd-47f0-873a-1f7c6d8011f5</guid><dc:creator>tracking</dc:creator><description>&lt;p&gt;Hi Heidi&lt;/p&gt;
&lt;p&gt;thanks for your response, I identify the lines you mention and I&amp;#39;ve saw the GPS sample and joint the samples in one, over aws iot sample I put the gps sample functions, the project compiles but in terminal show this&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/union-aws-y-gps.png" /&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what is err:9, I searched but i could not find&amp;nbsp; &amp;nbsp;and the failed to initializa modem I supose that is due to GPS and LTE cannot work concurrently, where I can find information about this manage&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS IoT how change the messagge type 1?</title><link>https://devzone.nordicsemi.com/thread/302422?ContentTypeID=1</link><pubDate>Mon, 29 Mar 2021 15:15:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:729cabc2-3acb-447d-b060-7ecaf9fb288f</guid><dc:creator>Heidi</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here are the relevant lines when modifying what message to post to AWS IoT.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L108-L109"&gt;L108-L109&lt;/a&gt;, the data (battery voltage and date and time) is added to the JSON objects. Here is where you would instead add the GPS data.&lt;/p&gt;
&lt;p&gt;Then the object is made into a message string in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L118"&gt;L118&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L125-L130"&gt;L125-L130&lt;/a&gt;&amp;nbsp;is where the struct that is used to transmit packages in the AWS IoT library is created.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And it is published in &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/aws_iot/src/main.c#L134"&gt;L134&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You will also need to add GPS functionality in the sample, as this is not included. Use the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/gps/README.html"&gt;GPS sample&lt;/a&gt; in NCS as a reference. Remember that GPS and LTE cannot work concurrently so you will either need to put the modem in PSM mode or turn it off before activating the GPS.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Heidi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>