<?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>Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65799/thingy-91-azure-iot-hub</link><description>Hi, 
 I am trying to use the thingy91 to publish some sensor data to an Azure IoT Hub, I&amp;#39;ve tried to look at mqtt_simple and modified &amp;quot;asset_tracker&amp;quot; application but I couldn&amp;#39;t succeed. 
 so is there any example showing how to publish data to Azure IoT</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Oct 2020 06:21:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65799/thingy-91-azure-iot-hub" /><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/274456?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 06:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ced698b-ad76-4c23-8422-a7d15a62d823</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Did you also &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/net/azure_iot_hub.html#provisioning-of-the-certificates"&gt;follow the provisioning steps&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/274295?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 11:51:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25ad8fb7-f0f7-4a6d-9639-10730f3d9d16</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;yes, Please look at&amp;nbsp;certificates.h&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
 */
//#include &amp;quot;ca-cert.pem&amp;quot;
static const unsigned char ca_certificate[] =
&amp;quot;-----BEGIN CERTIFICATE-----\r\n&amp;quot;
&amp;quot;MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\r\n&amp;quot;
&amp;quot;RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\r\n&amp;quot;
&amp;quot;VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\r\n&amp;quot;
&amp;quot;DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\r\n&amp;quot;
&amp;quot;ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\r\n&amp;quot;
&amp;quot;VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\r\n&amp;quot;
&amp;quot;mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\r\n&amp;quot;
&amp;quot;IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\r\n&amp;quot;
&amp;quot;mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\r\n&amp;quot;
&amp;quot;XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\r\n&amp;quot;
&amp;quot;dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\r\n&amp;quot;
&amp;quot;jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\r\n&amp;quot;
&amp;quot;BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\r\n&amp;quot;
&amp;quot;DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\r\n&amp;quot;
&amp;quot;9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\r\n&amp;quot;
&amp;quot;jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\r\n&amp;quot;
&amp;quot;Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\r\n&amp;quot;
&amp;quot;ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\r\n&amp;quot;
&amp;quot;R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\r\n&amp;quot;
&amp;quot;-----END CERTIFICATE-----\r\n&amp;quot;
;

static const unsigned char private_key[] = {
#include &amp;quot;private-key.pem&amp;quot;
};

static const unsigned char device_certificate[] = {
#include &amp;quot;client-cert.pem&amp;quot;
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/274228?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 08:45:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4b3857d-4b67-40b4-b1b8-f9423d508551</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Looks like you still have an issue with your certificates, often giving -95 (&lt;a href="https://github.com/eblot/newlib/blob/2a63fa0fd26ffb6603f69d9e369e944fe449c246/newlib/libc/machine/cris/sys/errno.h#L129"&gt;EOPNOTSUPP&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;#&lt;span&gt;define&lt;/span&gt; &lt;span&gt;EOPNOTSUPP&lt;/span&gt; &lt;span&gt;95&lt;/span&gt; &lt;span&gt;/* Operation not supported on transport endpoint */&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Have you added the certificates correctly to &lt;em&gt;nrf\samples\nrf9160\azure_iot_hub\certs\certificates.h&lt;/em&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/274220?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 08:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff58d0ef-4037-40d7-9e99-7a4a712240f5</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Is there any update about my case using the &amp;quot;&lt;span&gt;Azure IoT Hub sample&amp;quot;&lt;/span&gt;? are there missing configurations should I add to &lt;em&gt;prj_thingy91_nrf9160ns.conf? I got the same results using both devices of Thingy91.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273836?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 15:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a55ba3c-03af-4692-9414-ca35cda4feb0</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;I have succeeded to compile my code after running &lt;strong&gt;#west update&lt;/strong&gt; , but I got an error to connect to Azure IoT hub:&lt;/p&gt;
&lt;p&gt;Please look at the log file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;+CSCON: 0
RRC mode: Idle
*** Booting Zephyr OS build zephyr-v2.4.0-198-ga4ead9805140  ***
Flash regions		Domain		Permissions
00 00 0x00000 0x08000 	Secure		rwxl
01 31 0x08000 0x100000 	Non-Secure	rwxl

Non-secure callable region 0 placed in flash region 0 with size 32.

SRAM region		Domain		Permissions
00 07 0x00000 0x10000 	Secure		rwxl
08 31 0x10000 0x40000 	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0               Non-Secure	OK
01 NRF_CLOCK            Non-Secure	OK
02 NRF_RTC0             Non-Secure	OK
03 NRF_RTC1             Non-Secure	OK
04 NRF_NVMC             Non-Secure	OK
05 NRF_UARTE1           Non-Secure	OK
06 NRF_UARTE2           Secure		SKIP
07 NRF_TWIM2            Non-Secure	OK
08 NRF_SPIM3            Non-Secure	OK
09 NRF_TIMER0           Non-Secure	OK
10 NRF_TIMER1           Non-Secure	OK
11 NRF_TIMER2           Non-Secure	OK
12 NRF_SAADC            Non-Secure	OK
13 NRF_PWM0             Non-Secure	OK
14 NRF_PWM1             Non-Secure	OK
15 NRF_PWM2             Non-Secure	OK
16 NRF_PWM3             Non-Secure	OK
17 NRF_WDT              Non-Secure	OK
18 NRF_IPC              Non-Secure	OK
19 NRF_VMC              Non-Secure	OK
20 NRF_FPU              Non-Secure	OK
21 NRF_EGU1             Non-Secure	OK
22 NRF_EGU2             Non-Secure	OK
23 NRF_DPPIC            Non-Secure	OK
24 NRF_GPIOTE1          Non-Secure	OK
25 NRF_REGULATORS       Non-Secure	OK

SPM: NS image at 0xc000
SPM: NS MSP at 0x200271c8
SPM: NS reset vector at 0x1077d
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build zephyr-v2.4.0-198-ga4ead9805140  ***
Azure IoT Hub sample started
Connecting to LTE network
+CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
LTE cell changed: Cell ID: 80390154, Tracking area: 34306
PSM parameter update: TAU: -1, Active time: -1
+CSCON: 1
RRC mode: Connected
+CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
Network registration status: Connected - home network
Connected to LTE network
AZURE_IOT_HUB_EVT_CONNECTING
azure_iot_hub_connect failed: -95
[00:00:03.208,160] &#x1B;[0m&amp;lt;dbg&amp;gt; azure_iot_hub.broker_init: IPv4 Address found 13.79.172.43&#x1B;[0m
[00:00:03.793,762] &#x1B;[1;31m&amp;lt;err&amp;gt; azure_iot_hub: mqtt_connect, error: -95&#x1B;[0m
+CSCON: 0
RRC mode: Idle
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve added the below to&amp;nbsp;&lt;em&gt;prj_thingy91_nrf9160ns.conf&lt;/em&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;strong&gt;CONFIG_AZURE_IOT_HUB_DEVICE_ID=&amp;quot;Thingy91&amp;quot;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;strong&gt;CONFIG_AZURE_IOT_HUB_HOSTNAME=&amp;quot;Nordic.azure-devices.net&amp;quot;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
In addition to , I&amp;#39;ve added the password into&amp;nbsp;&lt;em&gt;azure_iot_hub.c &lt;/em&gt;as follows&lt;em&gt;:&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int client_broker_init(struct mqtt_client *const client, bool dps)
{
	int err;
	static sec_tag_t sec_tag_list[] = { CONFIG_AZURE_IOT_HUB_SEC_TAG };
	struct mqtt_sec_config *tls_cfg = &amp;amp;(client-&amp;gt;transport).tls.config;

	mqtt_client_init(client);

	err = broker_init(dps);
	if (err) {
		return err;
	}

	/* The following parameters differ between DPS and IoT hub:
	 *	client-&amp;gt;user_name
	 *	tls_cfg-&amp;gt;hostname
	 */
	
	char * token =&amp;quot;SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&amp;amp;se=3600001600713127&amp;quot;;
	struct mqtt_utf8 pass;
	pass.utf8 = (uint8_t*)token ;
	pass.size = (uint32_t)strlen(token);

	client-&amp;gt;broker			= &amp;amp;broker;
	client-&amp;gt;evt_cb			= mqtt_evt_handler;
	client-&amp;gt;client_id.utf8	= conn_config.device_id;
	client-&amp;gt;client_id.size	= strlen(conn_config.device_id);
	client-&amp;gt;password		= &amp;amp;pass;&lt;/pre&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273490?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 12:24:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff6395ae-8264-428a-9b37-8b312c6f8765</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="Tarek_Deri"]&lt;strong&gt;Part 1: #&amp;nbsp;west flash --erase &lt;/strong&gt;it works correctly, thanks.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Excellent!&lt;/p&gt;
[quote user="Tarek_Deri"]&lt;strong&gt;Part 2:&lt;/strong&gt;I followed the below steps and got some errors:[/quote]
&lt;p&gt;&amp;nbsp;Have you run west update after doing git pull?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273444?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 10:53:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d977661-945c-43f4-a9ee-5069cd8fa29a</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;&lt;strong&gt;Part 1: #&amp;nbsp;west flash --erase &lt;/strong&gt;it works correctly, thanks.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Part 2:&lt;/strong&gt;I followed the below steps and got some errors:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;#C:\ncs\nrf\samples\nrf9160&amp;gt;git checkout master
#git pull
#cd azure_iot_hub
#copy NUL prj_thingy91_nrf9160ns.conf
#cd ../../../..
C:\ncs&amp;gt;
#set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
#set GNUARMEMB_TOOLCHAIN_PATH=c:\gnuarmemb
#zephyr\zephyr-env.cmd
#cd nrf\samples\nrf9160\azure_iot_hub
#west build -b thingy91_nrf9160ns -d build
-- west build: generating a build system
Including boilerplate (Zephyr base): C:/ncs/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/ncs/nrf/samples/nrf9160/azure_iot_hub
-- Zephyr version: 2.3.0-rc1 (C:/ncs/zephyr)
-- Found Python3: C:/Python38/python.exe (found suitable exact version &amp;quot;3.8.5&amp;quot;) found components: Interpreter
-- Board: thingy91_nrf9160ns
No board named &amp;#39;thingy91_nrf9160ns&amp;#39; found
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at C:/ncs/zephyr/cmake/extensions.cmake:1486 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable &amp;quot;CC&amp;quot; or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  C:/ncs/zephyr/cmake/app/boilerplate.cmake:409 (print_usage)
  C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


CMake Error at C:/ncs/zephyr/cmake/extensions.cmake:1486 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable &amp;quot;CXX&amp;quot; or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  C:/ncs/zephyr/cmake/app/boilerplate.cmake:409 (print_usage)
  C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
See also &amp;quot;C:/ncs/nrf/samples/nrf9160/azure_iot_hub/build/CMakeFiles/CMakeOutput.log&amp;quot;.
See also &amp;quot;C:/ncs/nrf/samples/nrf9160/azure_iot_hub/build/CMakeFiles/CMakeError.log&amp;quot;.
FATAL ERROR: command exited with status 1: &amp;#39;C:\Program Files\CMake\bin\cmake.EXE&amp;#39; &amp;#39;-BC:\ncs\nrf\samples\nrf9160\azure_iot_hub\build&amp;#39; &amp;#39;-SC:\ncs\nrf\samples\nrf9160\azure_iot_hub&amp;#39; -GNinja -DBOARD=thingy91_nrf9160ns
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;-The prj_thingy91_nrf9160ns.conf file filled with below configuration&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="sql"&gt;#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# General config
CONFIG_LOG=y

# NEWLIB C
CONFIG_NEWLIB_LIBC=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# BSD library
CONFIG_BSD_LIBRARY=y

# AT Host
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y
CONFIG_AT_CMD_THREAD_STACK_SIZE=2048

# Azure IoT Hub library
CONFIG_AZURE_IOT_HUB=y
CONFIG_AZURE_IOT_HUB_DEVICE_ID=&amp;quot;Thingy91&amp;quot;
# Host name must be configured if DPS is not used
CONFIG_AZURE_IOT_HUB_HOSTNAME=&amp;quot;Nordic.azure-devices.net&amp;quot;
# Change the security tag to the tag where Azure IoT Hub certificates
# are provisioned
CONFIG_AZURE_IOT_HUB_SEC_TAG=10

# Uncomment and configure the options below to use DPS for device provisioning
# CONFIG_AZURE_IOT_HUB_DPS=y
# CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE=&amp;quot;&amp;quot;

# Uncomment to get more verbose logging when debugging
# CONFIG_AZURE_IOT_HUB_LOG_LEVEL_DBG=y

# LED control
CONFIG_DK_LIBRARY=y
CONFIG_DK_LIBRARY_INVERT_LEDS=n

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=4096

CONFIG_HW_STACK_PROTECTION=y

# cJSON
CONFIG_CJSON_LIB=y

# Settings, needed for Azure Device Provisioning Service
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273257?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 13:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8a8759d-40f6-4102-bedc-fa354de3a519</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="Tarek_Deri"]I have to run the flash twice to program my device properly. any suggestions to solve this issue?[/quote]
&lt;p&gt;Can you try running west flash --erase?&lt;/p&gt;
[quote user="Tarek_Deri"]It is the same build image that has been flashed on two devices (Thingy91) and the same SIM card, please look at the log files of both devices to figure out why does it show this error message?[/quote]
&lt;p&gt;I will need some more time to look into this case. Have you tried an unmodified version of the Azure IoT Hub sample on both? Only adding relevant information to connect?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273223?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 12:23:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:119127d0-653f-4e23-a564-c8c2da13be30</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;1-I need to run #west flash twice to flash the build successfully:&lt;/strong&gt; Assum the Thingy91 has been flashed with an asset tracker application or any other image, after that, I&amp;#39;ve compiled my simple MQTT code&amp;nbsp;using:&lt;br /&gt;&lt;/span&gt;&lt;em&gt;#west build -b thingy91_nrf9160ns -d build&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;then I run the flash command at first time &lt;em&gt;#west flash&lt;/em&gt;,I noticed that Thingy91 gets stuck(not able to boot) and there is no data showing on the terminal (puTTY ), I&amp;#39;ve tried to resetThingy91&amp;nbsp;several times (power off-on) with no response.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;west flash
-- west flash: rebuilding
[0/16] Performing build step for &amp;#39;spm_subimage&amp;#39;
ninja: no work to do.
[1/6] Performing build step for &amp;#39;mcuboot_subimage&amp;#39;
ninja: no work to do.
[2/6] Running utility command for mcuboot_sign_target
-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: C:/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/merged.hex
Parsing hex file.
Erasing page at address 0x0.
Erasing page at address 0x1000.
Erasing page at address 0x2000.
Erasing page at address 0x3000.
Erasing page at address 0x4000.
Erasing page at address 0x5000.
Erasing page at address 0x6000.
Erasing page at address 0x7000.
Erasing page at address 0x8000.
Erasing page at address 0x9000.
Erasing page at address 0xC000.
Erasing page at address 0xD000.
Erasing page at address 0xE000.
Erasing page at address 0xF000.
Erasing page at address 0x10000.
Erasing page at address 0x11000.
Erasing page at address 0x12000.
Erasing page at address 0x13000.
Erasing page at address 0x14000.
Erasing page at address 0x15000.
Erasing page at address 0x16000.
Erasing page at address 0x17000.
Erasing page at address 0x18000.
Erasing page at address 0x19000.
Erasing page at address 0x1A000.
Erasing page at address 0x1B000.
Erasing page at address 0x1C000.
Erasing page at address 0x1D000.
Erasing page at address 0x1E000.
Erasing page at address 0x1F000.
Erasing page at address 0x20000.
Erasing page at address 0x21000.
Erasing page at address 0x22000.
Erasing page at address 0x23000.
Erasing page at address 0x24000.
Erasing page at address 0x25000.
Erasing page at address 0x26000.
Erasing page at address 0x27000.
Erasing page at address 0x28000.
Erasing page at address 0x29000.
Erasing page at address 0x2A000.
Erasing page at address 0x2B000.
Erasing page at address 0x2C000.
Erasing page at address 0x2D000.
Erasing page at address 0x2E000.
Erasing page at address 0x2F000.
Erasing page at address 0x30000.
Erasing page at address 0x31000.
Erasing page at address 0x32000.
Erasing page at address 0x33000.
Erasing page at address 0x34000.
Erasing page at address 0x35000.
Erasing page at address 0x36000.
Erasing page at address 0x37000.
Erasing page at address 0x38000.
Erasing page at address 0x39000.
Erasing page at address 0x3A000.
Erasing page at address 0x3B000.
Erasing page at address 0x3C000.
Erasing page at address 0x3D000.
Erasing page at address 0x3E000.
Erasing page at address 0x3F000.
Erasing page at address 0x40000.
Erasing page at address 0x41000.
Erasing page at address 0x42000.
Erasing page at address 0x43000.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
Applying system reset.
Run.
-- runners.nrfjprog: Board with serial number 50103495 flashed successfully.&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;when I repeat the same flash command&amp;nbsp;&lt;strong&gt;&lt;em&gt;#west flash&amp;nbsp;&lt;/em&gt;&lt;/strong&gt;the device boots up and showing all the data&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;west flash
-- west flash: rebuilding
[0/16] Performing build step for &amp;#39;spm_subimage&amp;#39;
ninja: no work to do.
[1/6] Performing build step for &amp;#39;mcuboot_subimage&amp;#39;
ninja: no work to do.
[2/6] Running utility command for mcuboot_sign_target
-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: C:/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/merged.hex
Parsing hex file.
Erasing page at address 0x0.
Erasing page at address 0x1000.
Erasing page at address 0x2000.
Erasing page at address 0x3000.
Erasing page at address 0x4000.
Erasing page at address 0x5000.
Erasing page at address 0x6000.
Erasing page at address 0x7000.
Erasing page at address 0x8000.
Erasing page at address 0x9000.
Erasing page at address 0xC000.
Erasing page at address 0xD000.
Erasing page at address 0xE000.
Erasing page at address 0xF000.
Erasing page at address 0x10000.
Erasing page at address 0x11000.
Erasing page at address 0x12000.
Erasing page at address 0x13000.
Erasing page at address 0x14000.
Erasing page at address 0x15000.
Erasing page at address 0x16000.
Erasing page at address 0x17000.
Erasing page at address 0x18000.
Erasing page at address 0x19000.
Erasing page at address 0x1A000.
Erasing page at address 0x1B000.
Erasing page at address 0x1C000.
Erasing page at address 0x1D000.
Erasing page at address 0x1E000.
Erasing page at address 0x1F000.
Erasing page at address 0x20000.
Erasing page at address 0x21000.
Erasing page at address 0x22000.
Erasing page at address 0x23000.
Erasing page at address 0x24000.
Erasing page at address 0x25000.
Erasing page at address 0x26000.
Erasing page at address 0x27000.
Erasing page at address 0x28000.
Erasing page at address 0x29000.
Erasing page at address 0x2A000.
Erasing page at address 0x2B000.
Erasing page at address 0x2C000.
Erasing page at address 0x2D000.
Erasing page at address 0x2E000.
Erasing page at address 0x2F000.
Erasing page at address 0x30000.
Erasing page at address 0x31000.
Erasing page at address 0x32000.
Erasing page at address 0x33000.
Erasing page at address 0x34000.
Erasing page at address 0x35000.
Erasing page at address 0x36000.
Erasing page at address 0x37000.
Erasing page at address 0x38000.
Erasing page at address 0x39000.
Erasing page at address 0x3A000.
Erasing page at address 0x3B000.
Erasing page at address 0x3C000.
Erasing page at address 0x3D000.
Erasing page at address 0x3E000.
Erasing page at address 0x3F000.
Erasing page at address 0x40000.
Erasing page at address 0x41000.
Erasing page at address 0x42000.
Erasing page at address 0x43000.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
Applying system reset.
Run.
-- runners.nrfjprog: Board with serial number 50103495 flashed successfully.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
Flash regions		Domain		Permissions
00 02 0x00000 0x18000 	Secure		rwxl
03 31 0x18000 0x100000 	Non-Secure	rwxl

Non-secure callable region 0 placed in flash region 2 with size 32.

SRAM region		Domain		Permissions
00 07 0x00000 0x10000 	Secure		rwxl
08 31 0x10000 0x40000 	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0               Non-Secure	OK
01 NRF_CLOCK            Non-Secure	OK
02 NRF_RTC0             Non-Secure	OK
03 NRF_RTC1             Non-Secure	OK
04 NRF_NVMC             Non-Secure	OK
05 NRF_UARTE1           Non-Secure	OK
06 NRF_UARTE2           Secure		SKIP
07 NRF_TWIM2            Non-Secure	OK
08 NRF_SPIM3            Non-Secure	OK
09 NRF_TIMER0           Non-Secure	OK
10 NRF_TIMER1           Non-Secure	OK
11 NRF_TIMER2           Non-Secure	OK
12 NRF_SAADC            Non-Secure	OK
13 NRF_PWM0             Non-Secure	OK
14 NRF_PWM1             Non-Secure	OK
15 NRF_PWM2             Non-Secure	OK
16 NRF_PWM3             Non-Secure	OK
17 NRF_WDT              Non-Secure	OK
18 NRF_IPC              Non-Secure	OK
19 NRF_VMC              Non-Secure	OK
20 NRF_FPU              Non-Secure	OK
21 NRF_EGU1             Non-Secure	OK
22 NRF_EGU2             Non-Secure	OK
23 NRF_DPPIC            Non-Secure	OK
24 NRF_GPIOTE1          Non-Secure	OK
25 NRF_REGULATORS       Non-Secure	OK

SPM: NS image at 0x18200
SPM: NS MSP at 0x2002e8f0
SPM: NS reset vector at 0x1d595
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
The MQTT simple for Azure IoT Hub get started
DNS correctly set
LTE Link Connecting ...
[00:00:00.211,944] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
[00:00:00.231,933] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
+CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:01.545,135] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:01.557,098] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
+CSCON: 1
[00:00:01.598,052] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification&#x1B;[0m
+CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:03.114,135] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:03.125,946] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
LTE Link Connected!
IPv4 Address found 13.79.172.43
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;so every time I have to run the flash twice to program my device properly. any suggestions to solve this issue?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;2-The first device &amp;quot;Thingy91&amp;quot; works properly&amp;nbsp;on one Thingy91 and showing&amp;nbsp;&amp;quot;ERROR: mqtt_connect -95&amp;quot;&amp;nbsp; on another device:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It is the same build image that has been flashed on two devices (Thingy91) and the same SIM card, please look at the log files of both devices to figure out why does it show this error message?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
Flash regions		Domain		Permissions
00 02 0x00000 0x18000 	Secure		rwxl
03 31 0x18000 0x100000 	Non-Secure	rwxl

Non-secure callable region 0 placed in flash region 2 with size 32.

SRAM region		Domain		Permissions
00 07 0x00000 0x10000 	Secure		rwxl
08 31 0x10000 0x40000 	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0               Non-Secure	OK
01 NRF_CLOCK            Non-Secure	OK
02 NRF_RTC0             Non-Secure	OK
03 NRF_RTC1             Non-Secure	OK
04 NRF_NVMC             Non-Secure	OK
05 NRF_UARTE1           Non-Secure	OK
06 NRF_UARTE2           Secure		SKIP
07 NRF_TWIM2            Non-Secure	OK
08 NRF_SPIM3            Non-Secure	OK
09 NRF_TIMER0           Non-Secure	OK
10 NRF_TIMER1           Non-Secure	OK
11 NRF_TIMER2           Non-Secure	OK
12 NRF_SAADC            Non-Secure	OK
13 NRF_PWM0             Non-Secure	OK
14 NRF_PWM1             Non-Secure	OK
15 NRF_PWM2             Non-Secure	OK
16 NRF_PWM3             Non-Secure	OK
17 NRF_WDT              Non-Secure	OK
18 NRF_IPC              Non-Secure	OK
19 NRF_VMC              Non-Secure	OK
20 NRF_FPU              Non-Secure	OK
21 NRF_EGU1             Non-Secure	OK
22 NRF_EGU2             Non-Secure	OK
23 NRF_DPPIC            Non-Secure	OK
24 NRF_GPIOTE1          Non-Secure	OK
25 NRF_REGULATORS       Non-Secure	OK

SPM: NS image at 0x18200
SPM: NS MSP at 0x2002e8f0
SPM: NS reset vector at 0x1d595
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
The MQTT simple for Azure IoT Hub get started
DNS correctly set
LTE Link Connecting ...
[00:00:00.211,944] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
[00:00:00.231,933] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
+CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:01.664,245] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:01.676,239] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
+CSCON: 1
[00:00:01.721,130] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification&#x1B;[0m
+CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:02.915,222] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:02.927,032] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
LTE Link Connected!
IPv4 Address found 13.79.172.43
username: Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30, size:57
password: SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&amp;amp;se=3600001600713127, size:145
MQTT_TRANSPORT_NON_SECURE --1--,0 :
 client_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:236 , err:0
[mqtt_evt_handler:205] MQTT client connected!
Subscribing to: /my/subscribe/topic len 19
sensor shwoing.... 
{ Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415}
Publishing: { Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415}
to topic: devices/Thingy91/messages/events/$.ct=application%2Fjson&amp;amp;$.ce=utf-8 len: 67
Message has been published , msg size is:{ Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415} 
sensor shwoing.... 
{ Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368}
Publishing: { Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368}
to topic: devices/Thingy91/messages/events/$.ct=application%2Fjson&amp;amp;$.ce=utf-8 len: 67
Message has been published , msg size is:{ Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368} 
+CSCON: 0
[00:00:30.237,182] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification&#x1B;[0m
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
Flash regions		Domain		Permissions
00 02 0x00000 0x18000 	Secure		rwxl
03 31 0x18000 0x100000 	Non-Secure	rwxl

Non-secure callable region 0 placed in flash region 2 with size 32.

SRAM region		Domain		Permissions
00 07 0x00000 0x10000 	Secure		rwxl
08 31 0x10000 0x40000 	Non-Secure	rwxl

Peripheral		Domain		Status
00 NRF_P0               Non-Secure	OK
01 NRF_CLOCK            Non-Secure	OK
02 NRF_RTC0             Non-Secure	OK
03 NRF_RTC1             Non-Secure	OK
04 NRF_NVMC             Non-Secure	OK
05 NRF_UARTE1           Non-Secure	OK
06 NRF_UARTE2           Secure		SKIP
07 NRF_TWIM2            Non-Secure	OK
08 NRF_SPIM3            Non-Secure	OK
09 NRF_TIMER0           Non-Secure	OK
10 NRF_TIMER1           Non-Secure	OK
11 NRF_TIMER2           Non-Secure	OK
12 NRF_SAADC            Non-Secure	OK
13 NRF_PWM0             Non-Secure	OK
14 NRF_PWM1             Non-Secure	OK
15 NRF_PWM2             Non-Secure	OK
16 NRF_PWM3             Non-Secure	OK
17 NRF_WDT              Non-Secure	OK
18 NRF_IPC              Non-Secure	OK
19 NRF_VMC              Non-Secure	OK
20 NRF_FPU              Non-Secure	OK
21 NRF_EGU1             Non-Secure	OK
22 NRF_EGU2             Non-Secure	OK
23 NRF_DPPIC            Non-Secure	OK
24 NRF_GPIOTE1          Non-Secure	OK
25 NRF_REGULATORS       Non-Secure	OK

SPM: NS image at 0x18200
SPM: NS MSP at 0x2002e8f0
SPM: NS reset vector at 0x1d595
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
The MQTT simple for Azure IoT Hub get started
DNS correctly set
LTE Link Connecting ...
[00:00:00.213,958] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
[00:00:00.233,947] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0&#x1B;[0m
+CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:01.685,485] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:01.697,418] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
+CSCON: 1
[00:00:01.738,403] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification&#x1B;[0m
+CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
[00:00:02.696,472] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
&#x1B;[0m
[00:00:02.708,221] &#x1B;[0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
&#x1B;[0m
LTE Link Connected!
IPv4 Address found 13.79.172.43
username: Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30, size:57
password: SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&amp;amp;se=3600001600713127, size:145
MQTT_TRANSPORT_NON_SECURE --1--,0 :
 mqtt_transport_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:93 , err:-95
 client_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:236 , err:-95
ERROR: mqtt_connect -95
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273184?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 10:54:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48e95e04-6e52-4028-9778-85b47e183bf6</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
[quote user="Tarek_Deri"]sorry for late replay, I was reading and learning how to use Zephyr API and kernel services&amp;nbsp;to communicate with peripherals.[/quote]
&lt;p&gt;No worries, fully understand the&amp;nbsp;prioritization.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user="Tarek_Deri"]1-I need to run #west flash twice to flash the build successfully.[/quote]
&lt;p&gt;&amp;nbsp;Can you elaborate? Are you getting an error?&lt;/p&gt;
[quote user="Tarek_Deri"]2-The first device &amp;quot;Thingy91&amp;quot; works properly and send data to Azure when pressing the button&amp;nbsp;, while the other one showing an error&amp;nbsp; &amp;quot;ERROR: mqtt_connect -95&amp;quot; , I&amp;#39;ve tried to&amp;nbsp;update the FW of modem and debug this issue by AT commands&lt;span&gt;, but still&amp;nbsp;didn&amp;#39;t figure out how to solve it. I&amp;#39;ve attached a log file for this issue.&amp;nbsp;&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;error&amp;nbsp; -95 is often seen when there is an issue with the certificates. Have followed the steps for&amp;nbsp;Prerequisites for connecting to Azure IoT Hub and &lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/net/azure_iot_hub.html#provisioning-of-the-certificates"&gt;Provisioning of the certificates&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;br /&gt;-Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/273066?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2020 23:07:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af190ef3-2752-4d4d-834d-949a6b3e617d</guid><dc:creator>Deri</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;sorry for late replay, I was reading and learning how to use Zephyr API and kernel services&amp;nbsp;to communicate with peripherals.&lt;br /&gt;I&amp;#39;ve modified the simple MQTT sample to&amp;nbsp;publish the temperature, the humidity of the sensor&amp;nbsp;to Azure IoT Hub, I am using j-link to flash Thingy91 and VScode with cmd terminal to compile and flash my code.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve used&amp;nbsp; &amp;quot;MQTT_TRANSPORT_NON_SECURE&amp;quot; and I tested the compiled code on two devices&amp;nbsp; &amp;quot;Thingy91&amp;quot;, I am facing two issues:&lt;/p&gt;
&lt;p&gt;1-I need to run #west flash twice to flash the build successfully.&lt;/p&gt;
&lt;p&gt;2-The first device &amp;quot;Thingy91&amp;quot; works properly and send data to Azure when pressing the button&amp;nbsp;, while the other one showing an error&amp;nbsp; &amp;quot;ERROR: mqtt_connect -95&amp;quot; , I&amp;#39;ve tried to&amp;nbsp;update the FW of modem and debug this issue by AT commands&lt;span&gt;, but still&amp;nbsp;didn&amp;#39;t figure out how to solve it. I&amp;#39;ve attached a log file for this issue.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#     prj_thingy91_nrf9160ns.conf
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y
CONFIG_LOG=y
CONFIG_LOG_IMMEDIATE=y
CONFIG_LEGACY_TIMEOUT_API=y


# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# LTE link control
#CONFIG_POWER_OPTIMIZATION_ENABLE=n
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y

CONFIG_LTE_NETWORK_MODE_NBIOT=n
CONFIG_LTE_LEGACY_PCO_MODE=n
CONFIG_LTE_PSM_REQ_RPTAU=&amp;quot;00000110&amp;quot;
CONFIG_LTE_PSM_REQ_RAT=&amp;quot;00000010&amp;quot;

CONFIG_LTE_LOCK_BANDS=y
# Enable band 2, 3, 4, 8, 12, 13 ,20 and 28
CONFIG_LTE_LOCK_BAND_MASK=&amp;quot;1000000010000001100010001110&amp;quot;

# AT Host
CONFIG_UART_INTERRUPT_DRIVEN=y 
CONFIG_AT_HOST_LIBRARY=y  


# Modem info
CONFIG_MODEM_INFO=y

# BSD library
CONFIG_BSD_LIBRARY=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

# nRF Cloud
CONFIG_CLOUD_API=y
CONFIG_NRF_CLOUD=y
CONFIG_NRF_CLOUD_LOG_LEVEL_DBG=y
CONFIG_NRF_CLOUD_AGPS=y
CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD=y
CONFIG_NRF_CLOUD_NONBLOCKING_SEND=y
# Needed for the cloud codec
CONFIG_CJSON_LIB=y
# Shorter to prevent NAT timeouts
CONFIG_MQTT_KEEPALIVE=120
# Don&amp;#39;t resubscribe to topics if broker remembers them
CONFIG_CLOUD_PERSISTENT_SESSIONS=y

# Sensors
CONFIG_SENSOR=y
#CONFIG_ACCEL_USE_EXTERNAL=y
#CONFIG_ACCEL_DEV_NAME=&amp;quot;ADXL362&amp;quot;
CONFIG_ADXL362=y
CONFIG_ADXL362_TRIGGER_GLOBAL_THREAD=y
CONFIG_ADXL362_ABS_REF_MODE=1
CONFIG_ADXL362_ACTIVITY_THRESHOLD=200
CONFIG_ADXL362_INACTIVITY_THRESHOLD=200
CONFIG_ADXL362_INTERRUPT_MODE=1
CONFIG_TEMP_USE_EXTERNAL=y
CONFIG_TEMP_DEV_NAME=&amp;quot;BME680&amp;quot;
CONFIG_ENVIRONMENT_DATA_SEND_INTERVAL=10

#CONFIG_SPI_NRFX_SPIM_MISO_NO_PULL=y
# Deselect CONFIG_BME680 if CONFIG_USE_BME680_BSEC is selected
CONFIG_BME680=y
CONFIG_USE_BME680_BSEC=n

# GPS
CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
CONFIG_NRF9160_GPS=y
CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
#CONFIG_GPS_USE_EXTERNAL=y
#CONFIG_GPS_DEV_NAME=&amp;quot;NRF9160_GPS&amp;quot;
#CONFIG_GPS_CONTROL_PSM_ENABLE_ON_START=y

#CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
#CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
#CONFIG_GPS_CONTROL_FIX_TRY_TIME=360
#CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP=n
#CONFIG_GPS_START_ON_MOTION=y

# Library for buttons and LEDs
CONFIG_DK_LIBRARY=y
CONFIG_DK_LIBRARY_INVERT_LEDS=n

# Console
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_GETCHAR=y

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_HW_STACK_PROTECTION=y

# Settings
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# MCUBOOT
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# AWS FOTA
CONFIG_AWS_FOTA=y
CONFIG_FOTA_DOWNLOAD=y
CONFIG_AWS_FOTA_LOG_LEVEL_DBG=y
CONFIG_AWS_JOBS_LOG_LEVEL_DBG=y
CONFIG_DFU_TARGET=y

# Download client (needed by AWS FOTA)
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096

# Fatal error
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_WATCHDOG=y

# Appliaction #all added for azure
CONFIG_MQTT_PUB_TOPIC=&amp;quot;devices/Thingy91/messages/events/$.ct=application%2Fjson&amp;amp;$.ce=utf-8&amp;quot;
CONFIG_MQTT_SUB_TOPIC=&amp;quot;/my/subscribe/topic&amp;quot;
CONFIG_MQTT_CLIENT_ID=&amp;quot;Thingy91&amp;quot;
CONFIG_MQTT_BROKER_HOSTNAME=&amp;quot;Nordic.azure-devices.net&amp;quot;
CONFIG_MQTT_BROKER_PORT=8883
    
CONFIG_MQTT_MESSAGE_BUFFER_SIZE=512
CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=512
# MQTT
CONFIG_MQTT_LIB=y  
CONFIG_MQTT_LIB_TLS=n
#CONFIG_AT_CMD_LOG_LEVEL_DBG=y
#CONFIG_SEC_TAG=4096  
#CONFIG_PEER_VERIFY=0  

#CONFIG_HEAP_MEM_POOL_SIZE=2048&lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;#   Kconfig
# Copyright (c) 2018 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

menu &amp;quot;MQTT simple sample&amp;quot;
config MQTT_PUB_TOPIC
	string &amp;quot;MQTT publish topic&amp;quot;
	default &amp;quot;devices/Thingy91/messages/events/&amp;quot;

config MQTT_SUB_TOPIC
	string &amp;quot;MQTT subscribe topic&amp;quot;
	default &amp;quot;my/subscribe/topic&amp;quot;

config MQTT_CLIENT_ID
	string &amp;quot;MQTT Client ID&amp;quot;
	default &amp;quot;Thingy91&amp;quot;

config MQTT_BROKER_HOSTNAME
	string &amp;quot;MQTT broker hostname&amp;quot;
	default &amp;quot;Nordic.azure-devices.net&amp;quot;

config MQTT_BROKER_PORT
	int &amp;quot;MQTT broker port&amp;quot;
	default 8883

config MQTT_MESSAGE_BUFFER_SIZE
	int &amp;quot;MQTT message buffer size&amp;quot;
	default 512

config MQTT_PAYLOAD_BUFFER_SIZE
	int &amp;quot;MQTT payload buffer size&amp;quot;
	default 512

endmenu

menu &amp;quot;Environment sensors&amp;quot;

config USE_BME680_BSEC
	bool &amp;quot;Use Bosch BME680 BSEC lib&amp;quot;
	default n
	help
	  Enable use of Bosch BSEC library. The library itself is not a part of
	  NCS and must be downloaded from Bosch Sensortec.

config BOSCH_BSEC_LIBRARY_PATH
	string &amp;quot;Path to Bosch BSEC library folder&amp;quot;
	default &amp;quot;$(ZEPHYR_BASE)/../nrf/ext/BSEC_1.4.7.4_Generic_Release&amp;quot;
	help
	  Path to the folder where the Bosch BSEC library is placed.

config ENVIRONMENT_DATA_SEND_INTERVAL
	int &amp;quot;Interval in seconds for sending environment data&amp;quot;
	default 30
	help
	  Interval between each sampling and sending of environment sensor data.
	  If the GPS is active, sensor data will not be sent before it is
	  stopped. The unit is seconds.

config ENVIRONMENT_DATA_BACKOFF_TIME
	int &amp;quot;Time to delay sending environment data if GPS active&amp;quot;
	default 20
	help
	  Time in seconds before retrying to send environment sensor data if
	  the GPS is active.

choice
	prompt &amp;quot;Temperature measurement device&amp;quot;
	default TEMP_USE_SIM
	help
	  Select which device will provide temperature data.

config TEMP_USE_SIM
	bool &amp;quot;Use simulated temperature data&amp;quot;
	select SENSOR
	select SENSOR_SIM
	help
	  Use sensor simulator to generate temperature data to send to
	  nRF Cloud.

config TEMP_USE_EXTERNAL
	bool &amp;quot;User provided temperature device&amp;quot;
	help
	  The user provides a temperature device that is
	  used for temperature measurement.

endchoice

if TEMP_USE_SIM
config TEMP_DEV_NAME
	string
	default SENSOR_SIM_DEV_NAME

config TEMP_TRIGGER
	bool
	default SENSOR_SIM_TRIGGER

config TEMP_SIM_BUTTON
	int &amp;quot;Button or switch to trigger &amp;#39;data ready&amp;#39; event&amp;quot;
	range 1 4 if BOARD_NRF9160DK_NRF9160NS
	range 1 1 if BOARD_THINGY91_NRF9160NS
	default 3 if BOARD_NRF9160DK_NRF9160NS
	default 1 if BOARD_THINGY91_NRF9160NS
	help
	  Button or switch number to use for triggering
	  a &amp;#39;data ready&amp;#39; event.
	  1 - Button 1
	  2 - Button 2
	  3 - Switch 1
	  4 - Switch 2
endif

if TEMP_USE_EXTERNAL

config TEMP_DEV_NAME
	string &amp;quot;Temperature device name&amp;quot;
	help
	  Device from which temperature data will be fetched and
	  sent to nRF Cloud.

endif

endmenu # Environment sensors

menu &amp;quot;User Interface&amp;quot;
	visible if USE_UI_MODULE

config UI_LED_USE_PWM
	bool &amp;quot;Use PWM to control LEDs&amp;quot;
	default y if BOARD_THINGY91_NRF9160NS
	select PWM if BOARD_THINGY91_NRF9160NS
	select PWM_0 if BOARD_THINGY91_NRF9160NS

if UI_LED_USE_PWM

config UI_LED_PWM_DEV_NAME
	string &amp;quot;PWM device name for RGB LED&amp;quot;
	default &amp;quot;PWM_0&amp;quot; if BOARD_THINGY91_NRF9160NS

config UI_LED_RED_PIN
	int &amp;quot;Red LED pin number&amp;quot;
	default 29 if BOARD_THINGY91_NRF9160NS

config UI_LED_GREEN_PIN
	int &amp;quot;Green LED pin number&amp;quot;
	default 30 if BOARD_THINGY91_NRF9160NS

config UI_LED_BLUE_PIN
	int &amp;quot;Blue LED pin number&amp;quot;
	default 31 if BOARD_THINGY91_NRF9160NS

endif # UI_LED_USE_PWM

config UI_BUZZER
	bool &amp;quot;Enable buzzer&amp;quot;
	default y if BOARD_THINGY91_NRF9160NS
	select PWM if BOARD_THINGY91_NRF9160NS
	select PWM_1 if BOARD_THINGY91_NRF9160NS

if UI_BUZZER

config UI_BUZZER_PWM_DEV_NAME
	string &amp;quot;PWM device name for buzzer&amp;quot;
	default &amp;quot;PWM_1&amp;quot; if BOARD_THINGY91_NRF9160NS

config UI_BUZZER_PIN
	int &amp;quot;Buzzer pin number&amp;quot;
	default 28 if BOARD_THINGY91_NRF9160NS

config UI_BUZZER_MIN_FREQUENCY
	int &amp;quot;Minimum buzzer frequency&amp;quot;
	default 100

config UI_BUZZER_MAX_FREQUENCY
	int &amp;quot;Maximum buzzer frequency&amp;quot;
	default 10000

endif # UI_BUZZER

config UI_NMOS
	bool &amp;quot;Enable NMOS control&amp;quot;
	default y if BOARD_THINGY91_NRF9160NS
	select PWM if BOARD_THINGY91_NRF9160NS
	select PWM_2 if BOARD_THINGY91_NRF9160NS

if UI_NMOS

config UI_NMOS_PWM_DEV_NAME
	string &amp;quot;PWM device name for buzzer&amp;quot;
	default &amp;quot;PWM_2&amp;quot; if BOARD_THINGY91_NRF9160NS

config UI_NMOS_1_PIN
	int &amp;quot;NMOS 1 pin&amp;quot;
	default 13 if BOARD_THINGY91_NRF9160NS

config UI_NMOS_2_PIN
	int &amp;quot;NMOS 2 pin&amp;quot;
	default 14 if BOARD_THINGY91_NRF9160NS

config UI_NMOS_3_PIN
	int &amp;quot;NMOS 3 pin&amp;quot;
	default 15 if BOARD_THINGY91_NRF9160NS

config UI_NMOS_4_PIN
	int &amp;quot;NMOS 4 pin&amp;quot;
	default 16 if BOARD_THINGY91_NRF9160NS

endif # UI_NMOS

endmenu

menu &amp;quot;Zephyr Kernel&amp;quot;
source &amp;quot;$ZEPHYR_BASE/Kconfig.zephyr&amp;quot;
endmenu
&lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;2020-10-05T22:33:38.313Z INFO Application data folder: C:\Users\tade\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
2020-10-05T22:33:38.358Z DEBUG App pc-nrfconnect-linkmonitor v1.1.6 official
2020-10-05T22:33:38.358Z DEBUG App path: C:\Users\tade\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
2020-10-05T22:33:38.358Z DEBUG nRFConnect 3.5.0 is supported by the app (^3.2.0)
2020-10-05T22:33:38.358Z DEBUG nRFConnect path: C:\Users\tade\AppData\Local\Programs\nrfconnect\resources\app.asar
2020-10-05T22:33:38.358Z DEBUG HomeDir: C:\Users\tade
2020-10-05T22:33:38.358Z DEBUG TmpDir: C:\Users\tade\AppData\Local\Temp
2020-10-05T22:33:41.043Z INFO Modem port is opened
2020-10-05T22:33:41.061Z DEBUG modem &amp;gt;&amp;gt; AT+CFUN?
2020-10-05T22:33:41.104Z DEBUG modem &amp;lt;&amp;lt; +CFUN: 1
2020-10-05T22:33:41.108Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.109Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.126Z DEBUG modem &amp;gt;&amp;gt; AT+CGSN=1
2020-10-05T22:33:41.142Z DEBUG modem &amp;lt;&amp;lt; +CGSN: &amp;quot;352656100440539&amp;quot;
2020-10-05T22:33:41.146Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.163Z DEBUG modem &amp;gt;&amp;gt; AT+CGMI
2020-10-05T22:33:41.179Z DEBUG modem &amp;lt;&amp;lt; Nordic Semiconductor ASA
2020-10-05T22:33:41.188Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.194Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.205Z DEBUG modem &amp;gt;&amp;gt; AT+CGMM
2020-10-05T22:33:41.221Z DEBUG modem &amp;lt;&amp;lt; nRF9160-SICA
2020-10-05T22:33:41.230Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.235Z DEBUG modem &amp;gt;&amp;gt; AT+CGMR
2020-10-05T22:33:41.256Z DEBUG modem &amp;lt;&amp;lt; mfw_nrf9160_1.2.1
2020-10-05T22:33:41.260Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.262Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.265Z INFO Nordic Semiconductor ASA nRF9160-SICA [mfw_nrf9160_1.2.1] SerNr: 352656100440539
2020-10-05T22:33:41.278Z DEBUG modem &amp;gt;&amp;gt; AT+CEMODE?
2020-10-05T22:33:41.295Z DEBUG modem &amp;lt;&amp;lt; +CEMODE: 2
2020-10-05T22:33:41.310Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.339Z DEBUG modem &amp;gt;&amp;gt; AT%XCBAND=?
2020-10-05T22:33:41.358Z DEBUG modem &amp;lt;&amp;lt; %XCBAND: (2,3,4,8,12,13,20,28)
2020-10-05T22:33:41.360Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.361Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.378Z DEBUG modem &amp;gt;&amp;gt; AT+CMEE?
2020-10-05T22:33:41.392Z DEBUG modem &amp;lt;&amp;lt; +CMEE: 0
2020-10-05T22:33:41.413Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.418Z DEBUG modem &amp;gt;&amp;gt; AT+CMEE=1
2020-10-05T22:33:41.434Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.443Z DEBUG modem &amp;gt;&amp;gt; AT+CNEC?
2020-10-05T22:33:41.461Z DEBUG modem &amp;lt;&amp;lt; +CNEC: 0
2020-10-05T22:33:41.471Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.476Z DEBUG modem &amp;gt;&amp;gt; AT+CNEC=24
2020-10-05T22:33:41.496Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.510Z DEBUG modem &amp;gt;&amp;gt; AT+CGEREP?
2020-10-05T22:33:41.528Z DEBUG modem &amp;lt;&amp;lt; +CGEREP: 0,0
2020-10-05T22:33:41.550Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.552Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.557Z DEBUG modem &amp;gt;&amp;gt; AT+CGDCONT?
2020-10-05T22:33:41.577Z DEBUG modem &amp;lt;&amp;lt; +CGDCONT: 0,&amp;quot;IP&amp;quot;,&amp;quot;services.telenor.se&amp;quot;,&amp;quot;100.117.174.228&amp;quot;,0,0
2020-10-05T22:33:41.579Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.597Z DEBUG modem &amp;gt;&amp;gt; AT+CGACT?
2020-10-05T22:33:41.616Z DEBUG modem &amp;lt;&amp;lt; +CGACT: 0,1
2020-10-05T22:33:41.642Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.645Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.671Z DEBUG modem &amp;gt;&amp;gt; AT+CGEREP=1
2020-10-05T22:33:41.689Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.695Z DEBUG modem &amp;gt;&amp;gt; AT+CIND=1,1,1
2020-10-05T22:33:41.713Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.722Z DEBUG modem &amp;gt;&amp;gt; AT+CEREG=2
2020-10-05T22:33:41.742Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.745Z DEBUG modem &amp;gt;&amp;gt; AT+CEREG?
2020-10-05T22:33:41.765Z DEBUG modem &amp;lt;&amp;lt; +CEREG: 2,1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7
2020-10-05T22:33:41.778Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.779Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.809Z DEBUG modem &amp;gt;&amp;gt; AT+COPS=3,2
2020-10-05T22:33:41.825Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.829Z DEBUG modem &amp;gt;&amp;gt; AT+COPS?
2020-10-05T22:33:41.846Z DEBUG modem &amp;lt;&amp;lt; +COPS: 0,2,&amp;quot;24008&amp;quot;,7
2020-10-05T22:33:41.862Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:41.864Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.883Z DEBUG modem &amp;gt;&amp;gt; AT%XCBAND
2020-10-05T22:33:41.899Z DEBUG modem &amp;lt;&amp;lt; %XCBAND: 20
2020-10-05T22:33:41.904Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.932Z DEBUG modem &amp;gt;&amp;gt; AT+CGDCONT?
2020-10-05T22:33:41.961Z DEBUG modem &amp;lt;&amp;lt; +CGDCONT: 0,&amp;quot;IP&amp;quot;,&amp;quot;services.telenor.se&amp;quot;,&amp;quot;100.117.174.228&amp;quot;,0,0
2020-10-05T22:33:41.963Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:41.979Z DEBUG modem &amp;gt;&amp;gt; AT+CGACT?
2020-10-05T22:33:41.996Z DEBUG modem &amp;lt;&amp;lt; +CGACT: 0,1
2020-10-05T22:33:42.013Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:42.020Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.033Z DEBUG modem &amp;gt;&amp;gt; AT%CESQ=1
2020-10-05T22:33:42.050Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.062Z DEBUG modem &amp;gt;&amp;gt; AT+CESQ
2020-10-05T22:33:42.083Z DEBUG modem &amp;lt;&amp;lt; +CESQ: 99,99,255,255,19,60
2020-10-05T22:33:42.095Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.106Z DEBUG modem &amp;gt;&amp;gt; AT%XSIM=1
2020-10-05T22:33:42.129Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.146Z DEBUG modem &amp;gt;&amp;gt; AT%XSIM?
2020-10-05T22:33:42.166Z DEBUG modem &amp;lt;&amp;lt; %XSIM: 1
2020-10-05T22:33:42.186Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:42.188Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.195Z DEBUG modem &amp;gt;&amp;gt; AT+CPIN?
2020-10-05T22:33:42.211Z DEBUG modem &amp;lt;&amp;lt; +CPIN: READY
2020-10-05T22:33:42.220Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.251Z DEBUG modem &amp;gt;&amp;gt; AT+CPINR=&amp;quot;SIM PIN&amp;quot;
2020-10-05T22:33:42.276Z DEBUG modem &amp;lt;&amp;lt; +CPINR: &amp;quot;SIM PIN&amp;quot;,3
2020-10-05T22:33:42.279Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:33:42.280Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.296Z DEBUG modem &amp;gt;&amp;gt; AT+CIMI
2020-10-05T22:33:42.313Z DEBUG modem &amp;lt;&amp;lt; 240084712615998
2020-10-05T22:33:42.329Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:33:42.334Z INFO IMSIdentity: 240084712615998
2020-10-05T22:34:07.746Z DEBUG modem &amp;lt;&amp;lt; *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
2020-10-05T22:34:07.753Z DEBUG modem &amp;lt;&amp;lt; Flash regionsDomainPermissions
2020-10-05T22:34:07.756Z DEBUG modem &amp;lt;&amp;lt; 00 02 0x00000 0x18000 Securerwxl
2020-10-05T22:34:07.759Z DEBUG modem &amp;lt;&amp;lt; 03 31 0x18000 0x100000 Non-Securerwxl
2020-10-05T22:34:07.764Z DEBUG modem &amp;lt;&amp;lt; Non-secure callable region 0 placed in flash region 2 with size 32.
2020-10-05T22:34:07.937Z DEBUG modem &amp;lt;&amp;lt; SRAM regionDomainPermissions
2020-10-05T22:34:07.943Z DEBUG modem &amp;lt;&amp;lt; 00 07 0x00000 0x10000 Securerwxl
2020-10-05T22:34:07.944Z DEBUG modem &amp;lt;&amp;lt; 08 31 0x10000 0x40000 Non-Securerwxl
2020-10-05T22:34:07.946Z DEBUG modem &amp;lt;&amp;lt; PeripheralDomainStatus
2020-10-05T22:34:07.954Z DEBUG modem &amp;lt;&amp;lt; 00 NRF_P0               Non-SecureOK
2020-10-05T22:34:07.955Z DEBUG modem &amp;lt;&amp;lt; 01 NRF_CLOCK            Non-SecureOK
2020-10-05T22:34:07.957Z DEBUG modem &amp;lt;&amp;lt; 02 NRF_RTC0             Non-SecureOK
2020-10-05T22:34:07.960Z DEBUG modem &amp;lt;&amp;lt; 03 NRF_RTC1             Non-SecureOK
2020-10-05T22:34:07.975Z DEBUG modem &amp;lt;&amp;lt; 04 NRF_NVMC             Non-SecureOK
2020-10-05T22:34:07.979Z DEBUG modem &amp;lt;&amp;lt; 05 NRF_UARTE1           Non-SecureOK
2020-10-05T22:34:07.982Z DEBUG modem &amp;lt;&amp;lt; 06 NRF_UARTE2           SecureSKIP
2020-10-05T22:34:07.985Z DEBUG modem &amp;lt;&amp;lt; 07 NRF_TWIM2            Non-SecureOK
2020-10-05T22:34:07.988Z DEBUG modem &amp;lt;&amp;lt; 08 NRF_SPIM3            Non-SecureOK
2020-10-05T22:34:07.989Z DEBUG modem &amp;lt;&amp;lt; 09 NRF_TIMER0           Non-SecureOK
2020-10-05T22:34:07.990Z DEBUG modem &amp;lt;&amp;lt; 10 NRF_TIMER1           Non-SecureOK
2020-10-05T22:34:07.991Z DEBUG modem &amp;lt;&amp;lt; 11 NRF_TIMER2           Non-SecureOK
2020-10-05T22:34:07.992Z DEBUG modem &amp;lt;&amp;lt; 12 NRF_SAADC            Non-SecureOK
2020-10-05T22:34:07.994Z DEBUG modem &amp;lt;&amp;lt; 13 NRF_PWM0             Non-SecureOK
2020-10-05T22:34:08.010Z DEBUG modem &amp;lt;&amp;lt; 14 NRF_PWM1             Non-SecureOK
2020-10-05T22:34:08.014Z DEBUG modem &amp;lt;&amp;lt; 15 NRF_PWM2             Non-SecureOK
2020-10-05T22:34:08.022Z DEBUG modem &amp;lt;&amp;lt; 16 NRF_PWM3             Non-SecureOK
2020-10-05T22:34:08.025Z DEBUG modem &amp;lt;&amp;lt; 17 NRF_WDT              Non-SecureOK
2020-10-05T22:34:08.028Z DEBUG modem &amp;lt;&amp;lt; 18 NRF_IPC              Non-SecureOK
2020-10-05T22:34:08.038Z DEBUG modem &amp;lt;&amp;lt; 19 NRF_VMC              Non-SecureOK
2020-10-05T22:34:08.040Z DEBUG modem &amp;lt;&amp;lt; 20 NRF_FPU              Non-SecureOK
2020-10-05T22:34:08.043Z DEBUG modem &amp;lt;&amp;lt; 21 NRF_EGU1             Non-SecureOK
2020-10-05T22:34:08.045Z DEBUG modem &amp;lt;&amp;lt; 22 NRF_EGU2             Non-SecureOK
2020-10-05T22:34:08.052Z DEBUG modem &amp;lt;&amp;lt; 23 NRF_DPPIC            Non-SecureOK
2020-10-05T22:34:08.070Z DEBUG modem &amp;lt;&amp;lt; 24 NRF_GPIOTE1          Non-SecureOK
2020-10-05T22:34:08.071Z DEBUG modem &amp;lt;&amp;lt; 25 NRF_REGULATORS       Non-SecureOK
2020-10-05T22:34:08.073Z DEBUG modem &amp;lt;&amp;lt; SPM: NS image at 0x18200
2020-10-05T22:34:08.075Z DEBUG modem &amp;lt;&amp;lt; SPM: NS MSP at 0x2002e8f0
2020-10-05T22:34:08.078Z DEBUG modem &amp;lt;&amp;lt; SPM: NS reset vector at 0x1d595
2020-10-05T22:34:08.080Z DEBUG modem &amp;lt;&amp;lt; SPM: prepare to jump to Non-Secure image.
2020-10-05T22:34:08.249Z DEBUG modem &amp;lt;&amp;lt; *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
2020-10-05T22:34:08.256Z DEBUG modem &amp;lt;&amp;lt; The MQTT simple for Azure IoT Hub get started
2020-10-05T22:34:08.268Z DEBUG modem &amp;lt;&amp;lt; DNS correctly set
2020-10-05T22:34:08.270Z DEBUG modem &amp;lt;&amp;lt; LTE Link Connecting ...
2020-10-05T22:34:08.278Z DEBUG modem &amp;lt;&amp;lt; [00:00:00.214,050] [0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0[0m
2020-10-05T22:34:08.335Z DEBUG modem &amp;lt;&amp;lt; [00:00:00.234,069] [0m&amp;lt;dbg&amp;gt; lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0[0m
2020-10-05T22:34:09.839Z DEBUG modem &amp;lt;&amp;lt; +CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
2020-10-05T22:34:09.850Z DEBUG modem &amp;lt;&amp;lt; [00:00:01.786,651] [0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 2,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,0,0,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
2020-10-05T22:34:09.852Z DEBUG modem &amp;lt;&amp;lt; [0m
2020-10-05T22:34:09.859Z DEBUG modem &amp;lt;&amp;lt; [00:00:01.798,583] [0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
2020-10-05T22:34:09.861Z DEBUG modem &amp;lt;&amp;lt; [0m
2020-10-05T22:34:09.891Z DEBUG modem &amp;lt;&amp;lt; +CSCON: 1
2020-10-05T22:34:09.896Z DEBUG modem &amp;lt;&amp;lt; [00:00:01.836,517] [0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification[0m
2020-10-05T22:34:11.353Z DEBUG modem &amp;lt;&amp;lt; +CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
2020-10-05T22:34:11.360Z DEBUG modem &amp;gt;&amp;gt; AT+COPS=3,2
2020-10-05T22:34:11.367Z DEBUG modem &amp;lt;&amp;lt; [00:00:03.300,140] [0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CEREG notification: +CEREG: 1,&amp;quot;8602&amp;quot;,&amp;quot;04CAA80A&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11&amp;quot;
2020-10-05T22:34:11.368Z DEBUG modem &amp;lt;&amp;lt; [0m
2020-10-05T22:34:11.372Z DEBUG modem &amp;lt;&amp;lt; [00:00:03.311,920] [0m&amp;lt;dbg&amp;gt; lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
2020-10-05T22:34:11.374Z DEBUG modem &amp;lt;&amp;lt; [0m
2020-10-05T22:34:11.377Z DEBUG modem &amp;lt;&amp;lt; LTE Link Connected!
2020-10-05T22:34:11.380Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:34:11.386Z DEBUG modem &amp;gt;&amp;gt; AT+COPS?
2020-10-05T22:34:11.394Z DEBUG modem &amp;lt;&amp;lt; +COPS: 0,2,&amp;quot;24008&amp;quot;,7
2020-10-05T22:34:11.408Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:34:11.412Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:34:11.426Z DEBUG modem &amp;gt;&amp;gt; AT%XCBAND
2020-10-05T22:34:11.443Z DEBUG modem &amp;lt;&amp;lt; %XCBAND: 20
2020-10-05T22:34:11.453Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:34:11.476Z DEBUG modem &amp;gt;&amp;gt; AT+CGDCONT?
2020-10-05T22:34:11.478Z DEBUG modem &amp;lt;&amp;lt; IPv4 Address found 13.79.172.43
2020-10-05T22:34:11.481Z DEBUG modem &amp;lt;&amp;lt; username: Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30, size:57
2020-10-05T22:34:11.488Z DEBUG modem &amp;lt;&amp;lt; password: SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&amp;amp;se=3600001600713127, size:145
2020-10-05T22:34:11.489Z DEBUG modem &amp;lt;&amp;lt; MQTPORT_NON_SECURE --1--,0 :
2020-10-05T22:34:11.495Z DEBUG modem &amp;lt;&amp;lt; +CGDCONT: 0,&amp;quot;IP&amp;quot;,&amp;quot;services.telenor.se&amp;quot;,&amp;quot;100.105.214.93&amp;quot;,0,0
2020-10-05T22:34:11.497Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:34:11.514Z DEBUG modem &amp;gt;&amp;gt; AT+CGACT?
2020-10-05T22:34:11.524Z DEBUG modem &amp;lt;&amp;lt; +CGACT: 0,1
2020-10-05T22:34:11.528Z DEBUG modem &amp;lt;&amp;lt; 
2020-10-05T22:34:11.530Z DEBUG modem &amp;lt;&amp;lt; OK
2020-10-05T22:34:11.608Z DEBUG modem &amp;lt;&amp;lt; ERROR: mqtt_connect -95
2020-10-05T22:34:24.326Z DEBUG modem &amp;lt;&amp;lt; +CSCON: 0
2020-10-05T22:34:24.333Z DEBUG modem &amp;lt;&amp;lt; [00:00:16.274,017] [0m&amp;lt;dbg&amp;gt; lte_lc.at_handler: +CSCON notification[0m
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2018 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;drivers/uart.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;random/rand32.h&amp;gt;
#include &amp;lt;net/mqtt.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;nrf_socket.h&amp;gt;
#include &amp;lt;modem/lte_lc.h&amp;gt;
#if defined(CONFIG_LWM2M_CARRIER)
#include &amp;lt;lwm2m_carrier.h&amp;gt;
#endif

#include &amp;lt;drivers/sensor.h&amp;gt;
#include &amp;lt;dk_buttons_and_leds.h&amp;gt; //Button and LED


#if defined(CONFIG_MQTT_LIB_TLS)
#include &amp;quot;certificates.h&amp;quot;
#if defined(CONFIG_MODEM_KEY_MGMT)
#include &amp;lt;modem/modem_key_mgmt.h&amp;gt;
#endif
#endif

/* 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];

/* The mqtt client struct */
static struct mqtt_client client;

/* MQTT Broker details. */
static struct sockaddr_storage broker;

/* Connected flag */
static bool connected;

/* File descriptor */
static struct pollfd fds;

////////////////////////////////////////////////
#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;, (unsigned int)err);
}

#endif /* defined(CONFIG_BSD_LIBRARY) */

#if defined(CONFIG_LWM2M_CARRIER)
K_SEM_DEFINE(carrier_registered, 0, 1);

void lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *event)
{
	switch (event-&amp;gt;type) {
	case LWM2M_CARRIER_EVENT_BSDLIB_INIT:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_BSDLIB_INIT\n&amp;quot;);
		break;
	case LWM2M_CARRIER_EVENT_CONNECT:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_CONNECT\n&amp;quot;);
		break;
	case LWM2M_CARRIER_EVENT_DISCONNECT:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_DISCONNECT\n&amp;quot;);
		break;
	case LWM2M_CARRIER_EVENT_READY:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_READY\n&amp;quot;);
		k_sem_give(&amp;amp;carrier_registered);
		break;
	case LWM2M_CARRIER_EVENT_FOTA_START:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_FOTA_START\n&amp;quot;);
		break;
	case LWM2M_CARRIER_EVENT_REBOOT:
		printk(&amp;quot;LWM2M_CARRIER_EVENT_REBOOT\n&amp;quot;);
		break;
	}
}
#endif /* defined(CONFIG_LWM2M_CARRIER) */

/**@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 publish data on the configured topic
 */
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 Function to subscribe to the configured topic
 */
static int subscribe(void)
{
	struct mqtt_topic subscribe_topic = {
		.topic = {
			.utf8 = CONFIG_MQTT_SUB_TOPIC,
			.size = strlen(CONFIG_MQTT_SUB_TOPIC)
		},
		.qos = MQTT_QOS_1_AT_LEAST_ONCE
	};

	const struct mqtt_subscription_list subscription_list = {
		.list = &amp;amp;subscribe_topic,
		.list_count = 1,
		.message_id = 1234
	};

	printk(&amp;quot;Subscribing to: %s len %u\n&amp;quot;, CONFIG_MQTT_SUB_TOPIC,
		(unsigned int)strlen(CONFIG_MQTT_SUB_TOPIC));

	return mqtt_subscribe(&amp;amp;client, &amp;amp;subscription_list);
}

/**@brief Function to read the published payload.
 */
static int publish_get_payload(struct mqtt_client *c, size_t length)
{
	u8_t *buf = payload_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(c, buf, end - buf);

		if (ret &amp;lt; 0) {
			int err;

			if (ret != -EAGAIN) {
				return ret;
			}

			printk(&amp;quot;mqtt_read_publish_payload: EAGAIN\n&amp;quot;);

			//err = poll(&amp;amp;fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE));
                        err = poll(&amp;amp;fds, 1,
				   CONFIG_MQTT_KEEPALIVE * MSEC_PER_SEC);
			if (err &amp;gt; 0 &amp;amp;&amp;amp; (fds.revents &amp;amp; POLLIN) == POLLIN) {
				continue;
			} else {
				return -EIO;
			}
		}

		if (ret == 0) {
			return -EIO;
		}

		buf += ret;
	}

	return 0;
}

/**@brief MQTT client event handler
 */
void mqtt_evt_handler(struct mqtt_client *const c,
		      const struct mqtt_evt *evt)
{
	int 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;
		}

		connected = true;
		printk(&amp;quot;[%s:%d] MQTT client connected!\n&amp;quot;, __func__, __LINE__);
		subscribe();
		break;

	case MQTT_EVT_DISCONNECT:
		printk(&amp;quot;[%s:%d] MQTT client disconnected %d\n&amp;quot;, __func__,
		       __LINE__, evt-&amp;gt;result);

		connected = false;
		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, p-&amp;gt;message.payload.len);
		if (err &amp;gt;= 0) {
			data_print(&amp;quot;Received: &amp;quot;, payload_buf,
				p-&amp;gt;message.payload.len);
			/* Echo back received data */
			data_publish(&amp;amp;client, MQTT_QOS_1_AT_LEAST_ONCE,
				payload_buf, p-&amp;gt;message.payload.len);
		} else {
			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);
			}
		}
	} 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;
		}
		//data_publish(&amp;amp;client, MQTT_QOS_1_AT_LEAST_ONCE,
				//payload_buf, p-&amp;gt;message.payload.len);
		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);
		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 int broker_init(void)
{
	int err;
	struct addrinfo *result;
	struct addrinfo *addr;
	struct addrinfo hints = {
		.ai_family = AF_INET,
		.ai_socktype = SOCK_STREAM
	};

	err = getaddrinfo(CONFIG_MQTT_BROKER_HOSTNAME, NULL, &amp;amp;hints, &amp;amp;result);
	if (err) {
		printk(&amp;quot;ERROR: getaddrinfo failed %d\n&amp;quot;, err);
		return -ECHILD;	
	}
	addr = result;
	/* Look for address of the broker. */
	while (addr != NULL) {
		/* IPv4 Address. */
		if (addr-&amp;gt;ai_addrlen == sizeof(struct sockaddr_in)) {
			struct sockaddr_in *broker4 =
				((struct sockaddr_in *)&amp;amp;broker);
			char ipv4_addr[NET_IPV4_ADDR_LEN];

			broker4-&amp;gt;sin_addr.s_addr =
				((struct sockaddr_in *)addr-&amp;gt;ai_addr)
				-&amp;gt;sin_addr.s_addr;
			broker4-&amp;gt;sin_family = AF_INET;
			broker4-&amp;gt;sin_port = htons(CONFIG_MQTT_BROKER_PORT);

			inet_ntop(AF_INET, &amp;amp;broker4-&amp;gt;sin_addr.s_addr,
				  ipv4_addr, sizeof(ipv4_addr));
			printk(&amp;quot;IPv4 Address found %s\n&amp;quot;, ipv4_addr);
			break;
		} else {
				printk(&amp;quot;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);
	return err;
}

/**@brief Initialize the MQTT client structure
 */
static int client_init(struct mqtt_client *client)
{
	int err;
	mqtt_client_init(client);
	err = broker_init();
	if (err) {
		printk(&amp;quot;Failed to initialize broker connection\n&amp;quot;);
		return err;
	}

	struct mqtt_utf8 pass,name; // define two structs and every struct has *utf8 and size
	char * token =&amp;quot;SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&amp;amp;se=3600001600713127&amp;quot;;
	//char * token =&amp;quot;SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&amp;amp;sig=%2B6CdJ2kI2VSv6wDtZIn%2BQI%2B94eDocpY6BEMAlrqqDmQ%3D&amp;amp;se=361601892258&amp;quot;;
	pass.size = (u32_t)strlen(token);
	pass.utf8 = (u8_t*)token;
	name.size = (u32_t)strlen(&amp;quot;Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30&amp;quot;);
	name.utf8 = (u8_t *)&amp;quot;Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30&amp;quot;;

	printk(&amp;quot;username: %s, size:%d\n&amp;quot;,name.utf8,name.size);
	printk(&amp;quot;password: %s, size:%d\n&amp;quot;,pass.utf8,pass.size);

	/* MQTT client configuration */
	client-&amp;gt;broker = &amp;amp;broker;
	client-&amp;gt;evt_cb = mqtt_evt_handler;
	client-&amp;gt;client_id.utf8 = (u8_t *)CONFIG_MQTT_CLIENT_ID;  
	client-&amp;gt;client_id.size = strlen(CONFIG_MQTT_CLIENT_ID); 
	client-&amp;gt;password = &amp;amp;pass;
	client-&amp;gt;user_name = &amp;amp;name;
	client-&amp;gt;protocol_version = MQTT_VERSION_3_1_1;

	//printk(client-&amp;gt;client_id.utf8);

	/* 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);
	client-&amp;gt;transport.type = MQTT_TRANSPORT_NON_SECURE;
	printk(&amp;quot;MQTT_TRANSPORT_NON_SECURE --1--,%d :\n&amp;quot;,client-&amp;gt;transport.type);

#if defined(CONFIG_MQTT_LIB_TLS)
    //struct mqtt_sec_config *tls_config = &amp;amp;client-&amp;gt;transport.tls.config;
    
    client-&amp;gt;transport.type = MQTT_TRANSPORT_SECURE;
    
    //tls_config-&amp;gt;peer_verify = CONFIG_PEER_VERIFY;
    //tls_config-&amp;gt;cipher_count = 0;
    //tls_config-&amp;gt;cipher_list = NULL;
    //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 = CONFIG_MQTT_BROKER_HOSTNAME;
#else /* MQTT transport configuration */
	client-&amp;gt;transport.type = MQTT_TRANSPORT_NON_SECURE;
	printk(&amp;quot;MQTT_TRANSPORT_NON_SECURE---2--\n&amp;quot;);
#endif /* defined(CONFIG_MQTT_LIB_TLS) */
	return err;
}

/**@brief Initialize the file descriptor structure used by poll.
 */
static int fds_init(struct mqtt_client *c)
{
	if (c-&amp;gt;transport.type == MQTT_TRANSPORT_NON_SECURE) {
		fds.fd = c-&amp;gt;transport.tcp.sock;
	} else {
#if defined(CONFIG_MQTT_LIB_TLS)
		fds.fd = c-&amp;gt;transport.tls.sock;
#else
		return -ENOTSUP;
#endif
	}

	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)
	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
		/* Do nothing, modem is already turned on
		 * and connected.
		 */
	} else {
#if defined(CONFIG_LWM2M_CARRIER)
		/* Wait for the LWM2M_CARRIER to configure the modem and
		 * start the connection.
		 */
		printk(&amp;quot;Waitng for carrier registration...\n&amp;quot;);
		k_sem_take(&amp;amp;carrier_registered, K_FOREVER);
		printk(&amp;quot;Registered!\n&amp;quot;);
#else /* defined(CONFIG_LWM2M_CARRIER) */
		int err;
		//Set manually DNS server
		struct nrf_in_addr dns;
		dns.s_addr = 134744072; // Google DNS, 8.8.8.8 in u32 rapresentation
		err = nrf_setdnsaddr(2, &amp;amp;dns);
		if (err ==0) {
      		printk(&amp;quot;DNS correctly set\n&amp;quot;);
    	} 
		else {
      		printk(&amp;quot;Error %d, DNS not set\n&amp;quot;, err);
    		}

		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 /* defined(CONFIG_LWM2M_CARRIER) */
	}
#endif /* defined(CONFIG_LTE_LINK_CONTROL) */
}

char* sensor (){

	struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, bosch_bme680)));
	struct sensor_value temp, press, humidity, gas_res;
	k_sleep(K_MSEC(3000));

	sensor_sample_fetch(dev);
	sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &amp;amp;temp);
	sensor_channel_get(dev, SENSOR_CHAN_PRESS, &amp;amp;press);
	sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &amp;amp;humidity);
	sensor_channel_get(dev, SENSOR_CHAN_GAS_RES, &amp;amp;gas_res);
	sprintf(payload_buf,&amp;quot;{ Temperature: %d.%d , Pressure: %d.%d , Humidity: %d.%d}&amp;quot;,
	temp.val1, temp.val2/1000, press.val1, press.val2/1000,
	humidity.val1, humidity.val2/1000);
	//printf(&amp;quot;payload_buf=%s\n&amp;quot;, payload_buf);
	return payload_buf;
}

static void button_handler(u32_t button_state, u32_t has_changed)
{	
	int err;
	char * data = sensor();
	printk(&amp;quot;sensor shwoing.... \n%s\n&amp;quot;, data); 
	err = data_publish(&amp;amp;client, MQTT_QOS_0_AT_MOST_ONCE, (u8_t *){data}, (size_t)strlen(data)); 
	//printk(&amp;quot;err=%d\n&amp;quot;, err);
	if (err == 0)
	{
		printk(&amp;quot;Message has been published , msg size is:%s \n&amp;quot;,(u8_t *){data});
	}
	else
	{
		printk(&amp;quot;err=%d\n&amp;quot;, err);
	}
}



void main(void)
{
	int err;
	printk(&amp;quot;The MQTT simple for Azure IoT Hub get started\n&amp;quot;);
	err = dk_buttons_init(button_handler);
	if (err) {
		printk(&amp;quot;Failed to initialize buttons (err %d)\n&amp;quot;, err);
		return;
	}

	modem_configure();

	err = client_init(&amp;amp;client);
	if (err != 0) {
		printk(&amp;quot;ERROR: client_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;
	}

	err = poll(&amp;amp;fds, 1, CONFIG_MQTT_KEEPALIVE * MSEC_PER_SEC);
    if (err &amp;lt; 0) {
            printk(&amp;quot;ERROR: poll %d\n&amp;quot;, errno);
    }

    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);
            }
    }
	
	
}

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/269036?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 14:56:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:556fe6a8-6b09-40c9-8f54-1715f387250b</guid><dc:creator>Markus Tacker (he/him)</dc:creator><description>&lt;p&gt;Note that we do not have Azure support in the Bifravst firmware, yet:&amp;nbsp;&lt;a href="https://github.com/bifravst/firmware/issues/43"&gt;github.com/.../43&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/268974?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 12:24:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07504cbb-950c-4742-8a9e-edecbd20f685</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;You may also want to look at &lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/2715"&gt;this github PR&lt;/a&gt; which will be part of NCS 1.4.0, when that is released.&lt;br /&gt;-Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thingy:91 + Azure IoT Hub</title><link>https://devzone.nordicsemi.com/thread/268969?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 12:19:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d13b1895-6854-476d-9c2c-820e5f522c6d</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Can you provide some more information on what is failing? Are you able to connect the server? Do you get any errors?&lt;br /&gt;&lt;br /&gt;We have an &lt;strong&gt;un&lt;/strong&gt;&lt;a href="https://bifravst.gitbook.io/bifravst/v/saga/bifravst-on-azure-wip/gettingstarted"&gt;official example project called Bifravst&lt;/a&gt; which will connect the Thingy:91 to Azure. This is however work in progress, and I urge to read through what is documented.&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>