<?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_FOTA mix with GPS is exploding</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54036/aws_fota-mix-with-gps-is-exploding</link><description>Hello, 
 I tried to mix AWS_FOTA sample with GPS from asset_tracker (see code first screenshoot) and I get that error (see second screenshoot). Do someone have an idea please ? 
 
 
 I get this error message</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Nov 2019 11:33:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54036/aws_fota-mix-with-gps-is-exploding" /><item><title>RE: AWS_FOTA mix with GPS is exploding</title><link>https://devzone.nordicsemi.com/thread/219032?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2019 11:33:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05b6de7a-e975-4b6f-ba7d-ed60829878df</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi Fabien,&lt;/p&gt;
&lt;p&gt;It look like a stack is overflowing. You can identify which stack by looking up the thread ID in the map file (build/zephyr/zephyr.map). The thread ID is the address shown as &amp;quot;Current thread&amp;quot;, ie 0x20022498. You&amp;#39;ll probably have to remove the &amp;quot;0x&amp;quot; when searching in the map file. Alternatively, you can use GDB:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;west debug
info symbol 0x20022498&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hopefully you&amp;#39;ll be able to identify which thread&amp;#39;s stack is causing issues, and increase its size.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jan Tore&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS_FOTA mix with GPS is exploding</title><link>https://devzone.nordicsemi.com/thread/218765?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 09:48:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cea80d74-db9c-42ad-915c-c4d94879ff6c</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;LTE connection and GPS can&amp;#39;t be run simultaneously, unless PSM has also been set. &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/udp_with_psm"&gt;This example&lt;/a&gt; shows how to run both LTE and GPS concurrently.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS_FOTA mix with GPS is exploding</title><link>https://devzone.nordicsemi.com/thread/218655?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 16:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bd4a4ec-fe89-451b-b737-8e7dadb7d116</guid><dc:creator>Fabien Comte</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2019 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;bsd.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;
#include &amp;lt;at_cmd.h&amp;gt;
#include &amp;lt;at_notif.h&amp;gt;
#include &amp;lt;net/mqtt.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;net/bsdlib.h&amp;gt;
#include &amp;lt;net/aws_fota.h&amp;gt;
#include &amp;lt;dfu/mcuboot.h&amp;gt;
#include &amp;lt;misc/reboot.h&amp;gt;
#include &amp;lt;gps.h&amp;gt;
#include &amp;quot;gps_controller.h&amp;quot;

#define CONFIG_MQTT_PUB_TOPIC &amp;quot;Test&amp;quot;

#define CONFIG_GPS_CONTROL_FIX_COUNT 1

#if defined(CONFIG_USE_NRF_CLOUD)
#define NRF_CLOUD_SECURITY_TAG 16842753
#endif

#if defined(CONFIG_BSD_LIBRARY)
#include &amp;quot;nrf_inbuilt_key.h&amp;quot;
#endif

#if defined(CONFIG_PROVISION_CERTIFICATES)
#include &amp;quot;certificates.h&amp;quot;
#endif

#if !defined(CONFIG_CLOUD_CLIENT_ID)
#define IMEI_LEN 15
#define CLIENT_ID_LEN (IMEI_LEN + 4)
#else
#define CLIENT_ID_LEN (sizeof(CONFIG_CLOUD_CLIENT_ID) - 1)
#endif
static u8_t client_id_buf[CLIENT_ID_LEN+1];

/* 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];

/* MQTT Broker details. */
static struct sockaddr_storage broker_storage;

/* File descriptor */
static struct pollfd fds;

/* Set to true when application should teardown and reboot */
static bool do_reboot;

#if defined(CONFIG_BSD_LIBRARY)
/**@brief Recoverable BSD library error. */
void bsd_recoverable_error_handler(uint32_t err)
{
	printk(&amp;quot;bsdlib recoverable error: %u\n&amp;quot;, err);
}

#endif /* defined(CONFIG_BSD_LIBRARY) */

/* Topic for updating shadow topic with version number */
#define AWS &amp;quot;$aws/things/&amp;quot;
#define UPDATE_DELTA_TOPIC AWS &amp;quot;%s/shadow/update&amp;quot;
#define SHADOW_STATE_UPDATE \
&amp;quot;{\&amp;quot;state\&amp;quot;:{\&amp;quot;reported\&amp;quot;:{\&amp;quot;nrfcloud__dfu_v1__app_v\&amp;quot;:\&amp;quot;%s\&amp;quot;}}}&amp;quot;

static int update_device_shadow_version(struct mqtt_client *const client)
{
	struct mqtt_publish_param param;
	char update_delta_topic[strlen(AWS) + strlen(&amp;quot;/shadow/update&amp;quot;) +
				CLIENT_ID_LEN];
	u8_t shadow_update_payload[CONFIG_DEVICE_SHADOW_PAYLOAD_SIZE];

	int ret = snprintf(update_delta_topic,
			   sizeof(update_delta_topic),
			   UPDATE_DELTA_TOPIC,
			   client-&amp;gt;client_id.utf8);
	u32_t update_delta_topic_len = ret;

	if (ret &amp;gt;= sizeof(update_delta_topic)) {
		return -ENOMEM;
	} else if (ret &amp;lt; 0) {
		return ret;
	}

	ret = snprintf(shadow_update_payload,
		       sizeof(shadow_update_payload),
		       SHADOW_STATE_UPDATE,
		       CONFIG_APP_VERSION);
	u32_t shadow_update_payload_len = ret;

	if (ret &amp;gt;= sizeof(shadow_update_payload)) {
		return -ENOMEM;
	} else if (ret &amp;lt; 0) {
		return ret;
	}

	param.message.topic.qos = MQTT_QOS_1_AT_LEAST_ONCE;
	param.message.topic.topic.utf8 = update_delta_topic;
	param.message.topic.topic.size = update_delta_topic_len;
	param.message.payload.data = shadow_update_payload;
	param.message.payload.len = shadow_update_payload_len;
	param.message_id = sys_rand32_get();
	param.dup_flag = 0;
	param.retain_flag = 0;

	return mqtt_publish(client, &amp;amp;param);
}

/**@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(&amp;quot;%s%s\n&amp;quot;, prefix, buf);
}

/**@brief Function to read the published payload.
 */
static int publish_get_payload(struct mqtt_client *c,
			       u8_t *write_buf,
			       size_t length)
{
	u8_t *buf = write_buf;
	u8_t *end = buf + length;

	if (length &amp;gt; sizeof(payload_buf)) {
		return -EMSGSIZE;
	}
	while (buf &amp;lt; end) {
		int ret = mqtt_read_publish_payload_blocking(c, buf, end - buf);

		if (ret &amp;lt; 0) {
			return ret;
		} else if (ret == 0) {
			return -EIO;
		}
		buf += ret;
	}
	return 0;
}

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(&amp;quot;Publishing: &amp;quot;, data, len);
	printk(&amp;quot;to topic: %s len: %u\n&amp;quot;,
		CONFIG_MQTT_PUB_TOPIC,
		(unsigned int)strlen(CONFIG_MQTT_PUB_TOPIC));

	return mqtt_publish(c, &amp;amp;param);
}

/**@brief MQTT client event handler */
void mqtt_evt_handler(struct mqtt_client * const c,
		      const struct mqtt_evt *evt)
{
	int err;

	err = aws_fota_mqtt_evt_handler(c, evt);
	if (err &amp;gt; 0) {
		/* Event handled by FOTA library so we can skip it */
		return;
	} else if (err &amp;lt; 0) {
		printk(&amp;quot;aws_fota_mqtt_evt_handler: Failed! %d\n&amp;quot;, err);
	}

	switch (evt-&amp;gt;type) {
	case MQTT_EVT_CONNACK:
		if (evt-&amp;gt;result != 0) {
			printk(&amp;quot;MQTT connect failed %d\n&amp;quot;, evt-&amp;gt;result);
			break;
		}

		printk(&amp;quot;[%s:%d] MQTT client connected!\n&amp;quot;, __func__, __LINE__);
#if !defined(CONFIG_USE_NRF_CLOUD)
		err = update_device_shadow_version(c);
		if (err) {
			printk(&amp;quot;Unable to update device shadow err: %d\n&amp;quot;, err);
		}
#endif
		break;

	case MQTT_EVT_DISCONNECT:
		printk(&amp;quot;[%s:%d] MQTT client disconnected %d\n&amp;quot;, __func__,
		       __LINE__, evt-&amp;gt;result);
		break;

	case MQTT_EVT_PUBLISH: {
		const struct mqtt_publish_param *p = &amp;amp;evt-&amp;gt;param.publish;

		printk(&amp;quot;[%s:%d] MQTT PUBLISH result=%d len=%d\n&amp;quot;, __func__,
		       __LINE__, evt-&amp;gt;result, p-&amp;gt;message.payload.len);
		err = publish_get_payload(c,
					  payload_buf,
					  p-&amp;gt;message.payload.len);
		if (err) {
			printk(&amp;quot;mqtt_read_publish_payload: Failed! %d\n&amp;quot;, err);
			printk(&amp;quot;Disconnecting MQTT client...\n&amp;quot;);

			err = mqtt_disconnect(c);
			if (err) {
				printk(&amp;quot;Could not disconnect: %d\n&amp;quot;, err);
			}
		}

		if (p-&amp;gt;message.topic.qos == MQTT_QOS_1_AT_LEAST_ONCE) {
			const struct mqtt_puback_param ack = {
				.message_id = p-&amp;gt;message_id
			};

			/* Send acknowledgment. */
			err = mqtt_publish_qos1_ack(c, &amp;amp;ack);
			if (err) {
				printk(&amp;quot;unable to ack\n&amp;quot;);
			}
		}
		data_print(&amp;quot;Received: &amp;quot;, payload_buf, p-&amp;gt;message.payload.len);
		break;
	}

	case MQTT_EVT_PUBACK:
		if (evt-&amp;gt;result != 0) {
			printk(&amp;quot;MQTT PUBACK error %d\n&amp;quot;, evt-&amp;gt;result);
			break;
		}

		printk(&amp;quot;[%s:%d] PUBACK packet id: %u\n&amp;quot;, __func__, __LINE__,
		       evt-&amp;gt;param.puback.message_id);
		break;

	case MQTT_EVT_SUBACK:
		if (evt-&amp;gt;result != 0) {
			printk(&amp;quot;MQTT SUBACK error %d\n&amp;quot;, evt-&amp;gt;result);
			break;
		}

		printk(&amp;quot;[%s:%d] SUBACK packet id: %u\n&amp;quot;, __func__, __LINE__,
		       evt-&amp;gt;param.suback.message_id);


                char * test = &amp;quot;test&amp;quot;;
                            err = data_publish(c, MQTT_QOS_1_AT_LEAST_ONCE,
				test, strlen(test));

                if (err) {
				printk(&amp;quot;data_publish failed\n&amp;quot;);
			}
		break;

	default:
		printk(&amp;quot;[%s:%d] default: %d\n&amp;quot;, __func__, __LINE__,
		       evt-&amp;gt;type);
		break;
	}
}


/**@brief Resolves the configured hostname and
 * initializes the MQTT broker structure
 */
static void broker_init(const char *hostname)
{
	int err;
	struct addrinfo *result;
	struct addrinfo *addr;
	struct addrinfo hints = {
		.ai_family = AF_INET,
		.ai_socktype = SOCK_STREAM
	};

	err = getaddrinfo(hostname, NULL, &amp;amp;hints, &amp;amp;result);
	if (err) {
		printk(&amp;quot;ERROR: getaddrinfo failed %d\n&amp;quot;, err);

		return;
	}

	addr = result;
	err = -ENOENT;

	while (addr != NULL) {
		/* IPv4 Address. */
		if (addr-&amp;gt;ai_addrlen == sizeof(struct sockaddr_in)) {
			struct sockaddr_in *broker =
				((struct sockaddr_in *)&amp;amp;broker_storage);

			broker-&amp;gt;sin_addr.s_addr =
				((struct sockaddr_in *)addr-&amp;gt;ai_addr)
				-&amp;gt;sin_addr.s_addr;
			broker-&amp;gt;sin_family = AF_INET;
			broker-&amp;gt;sin_port = htons(CONFIG_MQTT_BROKER_PORT);

			printk(&amp;quot;IPv4 Address 0x%08x\n&amp;quot;,
				broker-&amp;gt;sin_addr.s_addr);
			break;
		} else if (addr-&amp;gt;ai_addrlen == sizeof(struct sockaddr_in6)) {
			/* IPv6 Address. */
			struct sockaddr_in6 *broker =
				((struct sockaddr_in6 *)&amp;amp;broker_storage);

			memcpy(broker-&amp;gt;sin6_addr.s6_addr,
				((struct sockaddr_in6 *)addr-&amp;gt;ai_addr)
				-&amp;gt;sin6_addr.s6_addr,
				sizeof(struct in6_addr));
			broker-&amp;gt;sin6_family = AF_INET6;
			broker-&amp;gt;sin6_port = htons(CONFIG_MQTT_BROKER_PORT);

			printk(&amp;quot;IPv6 Address&amp;quot;);
			break;
		} else {
			printk(&amp;quot;error: ai_addrlen = %u should be %u or %u\n&amp;quot;,
				(unsigned int)addr-&amp;gt;ai_addrlen,
				(unsigned int)sizeof(struct sockaddr_in),
				(unsigned int)sizeof(struct sockaddr_in6));
		}

		addr = addr-&amp;gt;ai_next;
		break;
	}

	/* Free the address. */
	freeaddrinfo(result);
}
#if defined(CONFIG_PROVISION_CERTIFICATES)
#warning Not for prodcution use. This should only be used once to provisioning the certificates please deselect the provision certificates configuration and compile again.
#define MAX_OF_2 MAX(sizeof(CLOUD_CA_CERTIFICATE),\
		     sizeof(CLOUD_CLIENT_PRIVATE_KEY))
#define MAX_LEN MAX(MAX_OF_2, sizeof(CLOUD_CLIENT_PUBLIC_CERTIFICATE))
static u8_t certificates[][MAX_LEN] = {{CLOUD_CA_CERTIFICATE},
				       {CLOUD_CLIENT_PRIVATE_KEY},
				       {CLOUD_CLIENT_PUBLIC_CERTIFICATE} };
static const size_t cert_len[] = {
	sizeof(CLOUD_CA_CERTIFICATE) - 1, sizeof(CLOUD_CLIENT_PRIVATE_KEY) - 1,
	sizeof(CLOUD_CLIENT_PUBLIC_CERTIFICATE) - 1
};
static int provision_certificates(void)
{
	int err;

	printk(&amp;quot;************************* WARNING *************************\n&amp;quot;);
	printk(&amp;quot;%s called do not use this in production!\n&amp;quot;, __func__);
	printk(&amp;quot;This will store the certificates in readable flash and leave\n&amp;quot;);
	printk(&amp;quot;them exposed on modem_traces. Only use this once for\n&amp;quot;);
	printk(&amp;quot;provisioning certificates for development to reduce flash tear.&amp;quot;
		&amp;quot;\n&amp;quot;);
	printk(&amp;quot;************************* WARNING *************************\n&amp;quot;);
	nrf_sec_tag_t sec_tag = CONFIG_CLOUD_CERT_SEC_TAG;
	nrf_key_mgnt_cred_type_t cred[] = {
		NRF_KEY_MGMT_CRED_TYPE_CA_CHAIN,
		NRF_KEY_MGMT_CRED_TYPE_PRIVATE_CERT,
		NRF_KEY_MGMT_CRED_TYPE_PUBLIC_CERT,
	};

	/* Delete certificates */
	for (nrf_key_mgnt_cred_type_t type = 0; type &amp;lt; 3; type++) {
		err = nrf_inbuilt_key_delete(sec_tag, type);
		printk(&amp;quot;nrf_inbuilt_key_delete(%u, %d) =&amp;gt; result=%d\n&amp;quot;,
				sec_tag, type, err);
	}

	/* Write certificates */
	for (nrf_key_mgnt_cred_type_t type = 0; type &amp;lt; 3; type++) {
		err = nrf_inbuilt_key_write(sec_tag, cred[type],
				certificates[type], cert_len[type]);
		printk(&amp;quot;nrf_inbuilt_key_write =&amp;gt; result=%d\n&amp;quot;, err);
	}
	return 0;
}
#endif

static int client_id_get(char *id_buf)
{
#if !defined(CONFIG_CLOUD_CLIENT_ID)
	enum at_cmd_state at_state;
	char imei_buf[IMEI_LEN + 5];
	int err = at_cmd_write(&amp;quot;AT+CGSN&amp;quot;, imei_buf, (IMEI_LEN + 5), &amp;amp;at_state);

	if (err) {
		printk(&amp;quot;Error when trying to do at_cmd_write: %d, at_state: %d&amp;quot;,
			err, at_state);
	}

	snprintf(id_buf, CLIENT_ID_LEN + 1, &amp;quot;nrf-%s&amp;quot;, imei_buf);
#else
	memcpy(id_buf, CONFIG_CLOUD_CLIENT_ID, CLIENT_ID_LEN + 1);
#endif /* !defined(NRF_CLOUD_CLIENT_ID) */
	return 0;
}

/**@brief Initialize the MQTT client structure */
static int client_init(struct mqtt_client *client, char *hostname)
{
	mqtt_client_init(client);
	broker_init(hostname);
	int ret = client_id_get(client_id_buf);

	printk(&amp;quot;client_id: %s\n&amp;quot;, client_id_buf);
	if (ret != 0) {
		return ret;
	}

	/* MQTT client configuration */
	client-&amp;gt;broker = &amp;amp;broker_storage;
	client-&amp;gt;evt_cb = mqtt_evt_handler;
	client-&amp;gt;client_id.utf8 = client_id_buf;
	client-&amp;gt;client_id.size = strlen(client_id_buf);
	client-&amp;gt;password = NULL;
	client-&amp;gt;user_name = NULL;
	client-&amp;gt;protocol_version = MQTT_VERSION_3_1_1;

	/* MQTT buffers configuration */
	client-&amp;gt;rx_buf = rx_buffer;
	client-&amp;gt;rx_buf_size = sizeof(rx_buffer);
	client-&amp;gt;tx_buf = tx_buffer;
	client-&amp;gt;tx_buf_size = sizeof(tx_buffer);

	/* MQTT transport configuration */
	client-&amp;gt;transport.type = MQTT_TRANSPORT_SECURE;

	static sec_tag_t sec_tag_list[] = {
#ifdef CONFIG_USE_NRF_CLOUD
		NRF_CLOUD_SECURITY_TAG
#else
		CONFIG_CLOUD_CERT_SEC_TAG
#endif
	};
	struct mqtt_sec_config *tls_config = &amp;amp;(client-&amp;gt;transport).tls.config;

	tls_config-&amp;gt;peer_verify = 2;
	tls_config-&amp;gt;cipher_list = NULL;
	tls_config-&amp;gt;cipher_count = 0;
	tls_config-&amp;gt;sec_tag_count = ARRAY_SIZE(sec_tag_list);
	tls_config-&amp;gt;sec_tag_list = sec_tag_list;
	tls_config-&amp;gt;hostname = hostname;

	return 0;
}

/**@brief Initialize the file descriptor structure used by poll. */
static int fds_init(struct mqtt_client *c)
{
	fds.fd = c-&amp;gt;transport.tls.sock;
	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)
	BUILD_ASSERT_MSG(!IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT),
			&amp;quot;This sample does not support auto init and connect&amp;quot;);
	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;);
	printk(&amp;quot;LTE Link Connecting ...\n&amp;quot;);
	err = lte_lc_init_and_connect();
	__ASSERT(err == 0, &amp;quot;LTE link could not be established.&amp;quot;);
	printk(&amp;quot;LTE Link Connected!\n&amp;quot;);
#endif
}

static void aws_fota_cb_handler(enum aws_fota_evt_id evt)
{
	switch (evt) {
	case AWS_FOTA_EVT_DONE:
		printk(&amp;quot;AWS_FOTA_EVT_DONE, rebooting to apply update.\n&amp;quot;);
		do_reboot = true;
		break;

	case AWS_FOTA_EVT_ERROR:
		printk(&amp;quot;AWS_FOTA_EVT_ERROR\n&amp;quot;);
		break;
	}
}



// GPS ---------------------------------------

static struct gps_data gps_data;
static char nmea_frame[256] = &amp;quot;&amp;quot;;
unsigned char gps_running = 1;

static void gps_trigger_handler(struct device *dev, struct gps_trigger *trigger)
{
	static u32_t fix_count = 0;

	ARG_UNUSED(trigger);

	if (++fix_count &amp;lt; CONFIG_GPS_CONTROL_FIX_COUNT) {
		return;
	}

	fix_count = 0;

	gps_sample_fetch(dev);
	gps_channel_get(dev, GPS_CHAN_NMEA, &amp;amp;gps_data);
	
	
	snprintf(nmea_frame, sizeof(nmea_frame), &amp;quot;%s&amp;quot;, gps_data.nmea.buf);
	

	gps_control_stop(K_NO_WAIT);
	gps_running = 0;
}


void main(void)
{
        nrf_gnss_data_frame_t gps_data;
        u8_t		      cnt = 0;

	int err;

	/* The mqtt client struct */
	struct mqtt_client client;

	printk(&amp;quot;MQTT AWS Jobs FOTA Sample, version: %s\n&amp;quot;, CONFIG_APP_VERSION);
	printk(&amp;quot;Initializing bsdlib\n&amp;quot;);
	err = bsdlib_init();
	switch (err) {
	case MODEM_DFU_RESULT_OK:
		printk(&amp;quot;Modem firmware update successful!\n&amp;quot;);
		printk(&amp;quot;Modem will run the new firmware after reboot\n&amp;quot;);
		//k_thread_suspend(k_current_get());
		sys_reboot(SYS_REBOOT_COLD);
		break;
	case MODEM_DFU_RESULT_UUID_ERROR:
	case MODEM_DFU_RESULT_AUTH_ERROR:
		printk(&amp;quot;Modem firmware update failed\n&amp;quot;);
		printk(&amp;quot;Modem will run non-updated firmware on reboot.\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 firmware update failed\n&amp;quot;);
		printk(&amp;quot;Fatal error.\n&amp;quot;);
		sys_reboot(SYS_REBOOT_COLD);
		break;
	case -1:
		printk(&amp;quot;Could not initialize bsdlib.\n&amp;quot;);
		printk(&amp;quot;Fatal error.\n&amp;quot;);
		sys_reboot(SYS_REBOOT_COLD);
		return;
	default:
		break;
	}
	printk(&amp;quot;Initialized bsdlib\n&amp;quot;);

#if defined(CONFIG_PROVISION_CERTIFICATES)
	provision_certificates();
#endif /* CONFIG_PROVISION_CERTIFICATES */
	modem_configure();

	client_init(&amp;amp;client, CONFIG_MQTT_BROKER_HOSTNAME);

	err = aws_fota_init(&amp;amp;client, CONFIG_APP_VERSION, aws_fota_cb_handler);
	if (err != 0) {
		printk(&amp;quot;ERROR: aws_fota_init %d\n&amp;quot;, err);
		return;
	}

	err = mqtt_connect(&amp;amp;client);
	if (err != 0) {
		printk(&amp;quot;ERROR: mqtt_connect %d\n&amp;quot;, err);
		return;
	}

	err = fds_init(&amp;amp;client);
	if (err != 0) {
		printk(&amp;quot;ERROR: fds_init %d\n&amp;quot;, err);
		return;
	}

	/* All initializations were successful mark image as working so that we
	 * will not revert upon reboot.
	 */
	boot_write_img_confirmed();
	
	gps_control_init(gps_trigger_handler);

	while (1) {

		if (gps_running == 0)
		{
			err = poll(&amp;amp;fds, 1, K_MSEC(500)/*K_SECONDS(CONFIG_MQTT_KEEPALIVE)*/);
			if (err &amp;lt; 0) {
				printk(&amp;quot;ERROR: poll %d\n&amp;quot;, errno);
				break;
			}
		
			err = mqtt_live(&amp;amp;client);
			if (err != 0) {
				printk(&amp;quot;ERROR: mqtt_live %d\n&amp;quot;, err);
				break;
			}

			if ((fds.revents &amp;amp; POLLIN) == POLLIN) {
				err = mqtt_input(&amp;amp;client);
				if (err != 0) {
					printk(&amp;quot;ERROR: mqtt_input %d\n&amp;quot;, err);
					break;
				}
			}

			if ((fds.revents &amp;amp; POLLERR) == POLLERR) {
				printk(&amp;quot;POLLERR\n&amp;quot;);
				break;
			}

			if ((fds.revents &amp;amp; POLLNVAL) == POLLNVAL) {
				printk(&amp;quot;POLLNVAL\n&amp;quot;);
				break;
			}
			
			
			gps_control_start(K_SECONDS(1));
			gps_running = 1;
		}
		else
		{
			k_sleep(K_MSEC(500));
		}

		if (do_reboot) {
			/* Teardown */
			mqtt_disconnect(&amp;amp;client);
			sys_reboot(0);
		}
	}

	printk(&amp;quot;Disconnecting MQTT client...\n&amp;quot;);

	err = mqtt_disconnect(&amp;amp;client);
	if (err) {
		printk(&amp;quot;Could not disconnect MQTT client. Error: %d\n&amp;quot;, err);
	}
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AWS_FOTA mix with GPS is exploding</title><link>https://devzone.nordicsemi.com/thread/218650?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 15:49:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad59b77f-c4b8-4a31-9b20-37fc1d41bac6</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;can you please paste your entire code here using the insert code option instead of posting a screenshot of it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>