<?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>exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101780/exploring-the-possibility-of-combining-merging-two-sample-codes</link><description>Hi, i was just wondering what is the limiting factor when combining/merging two nordic samples. In this case peripheral/central UART and sensor observer (client). I am able to build and run the script but the board will only have one of the two functionalities</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Aug 2023 11:46:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101780/exploring-the-possibility-of-combining-merging-two-sample-codes" /><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/439241?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2023 11:46:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9f8c9cc-88c8-431b-9c36-b036c7f75e7a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It does not look I am able to compile your source code without having known some other settings from your proj.conf and CMakeLists.txt.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;C:\ncs\v2.4.0\nrf\include\bluetooth\scan.h:223:36: error: &amp;#39;CONFIG_BT_SCAN_UUID_CNT&amp;#39; undeclared here (not in a function)&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 223 | const struct bt_uuid *uuid[CONFIG_BT_SCAN_UUID_CNT];&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:477:10: error: &amp;#39;const struct bt_conn_cb&amp;#39; has no member named &amp;#39;security_changed&amp;#39;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 477 | .security_changed = security_changed&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:477:29: warning: initialization of &amp;#39;_Bool (*)(struct bt_conn *, struct bt_le_conn_param *)&amp;#39; from incompatible pointer type &amp;#39;void (*)(struct bt_conn *, bt_security_t, enum bt_security_err)&amp;#39; [-Wincompatible-pointer-types]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 477 | .security_changed = security_changed&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:477:29: note: (near initialization for &amp;#39;bt_conn_cb_conn_callbacks.le_param_req&amp;#39;)&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;../../src/main.c: In function &amp;#39;scan_init&amp;#39;:&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:530:18: error: &amp;#39;struct bt_scan_init_param&amp;#39; has no member named &amp;#39;connect_if_match&amp;#39;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 530 | .connect_if_match = 1,&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:530:37: warning: initialization of &amp;#39;const struct bt_le_scan_param *&amp;#39; from &amp;#39;int&amp;#39; makes pointer from integer without a cast [-Wint-conversion]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 530 | .connect_if_match = 1,&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:530:37: note: (near initialization for &amp;#39;scan_init.scan_param&amp;#39;)&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:536:15: warning: implicit declaration of function &amp;#39;bt_scan_filter_add&amp;#39; [-Wimplicit-function-declaration]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 536 | err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_NUS_SERVICE);&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:542:15: warning: implicit declaration of function &amp;#39;bt_scan_filter_enable&amp;#39; [-Wimplicit-function-declaration]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 542 | err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;../../src/main.c: In function &amp;#39;main&amp;#39;:&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:661:16: warning: &amp;#39;return&amp;#39; with a value, in function returning void [-Wreturn-type]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 661 | return 0;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:591:6: note: declared here&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 591 | void main(void)&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;../../src/main.c: At top level:&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:497:13: warning: &amp;#39;scan_connecting&amp;#39; defined but not used [-Wunused-function]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 497 | static void scan_connecting(struct bt_scan_device_info *device_info,&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;c:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\src\main.c:492:13: warning: &amp;#39;scan_connecting_error&amp;#39; defined but not used [-Wunused-function]&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; 492 | static void scan_connecting_error(struct bt_scan_device_info *device_info)&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt; | ^~~~~~~~~~~~~~~~~~~~~&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;ninja: build stopped: subcommand failed.&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;FAILED: sensor_client-prefix/src/sensor_client-stamp/sensor_client-build &lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;cmd.exe /C &amp;quot;cd /D C:\ncs\v2.4.0\nrf\samples\bluetooth\mesh\sensor_client\build\sensor_client &amp;amp;&amp;amp; C:\ncs\toolchains\31f4403e35\opt\bin\cmake.exe --build .&amp;quot;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;ninja: build stopped: subcommand failed.&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(51, 153, 102, 1);"&gt;&lt;em&gt;&lt;strong&gt;FATAL ERROR: command exited with status 1: &amp;#39;C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE&amp;#39; --build C:/ncs/v2.4.0/nrf/samples/bluetooth/mesh/sensor_client/build&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Sorry for the format, for some reason I am not able to format this text better due to some technical issue.&lt;/p&gt;
&lt;p&gt;Maybe there are differences in your setup and my setup. But it seems like your main questions are below&lt;/p&gt;
[quote user="mash&amp;amp;hash"]Can I clarify my understand of the following with you&lt;br /&gt;1. can a node communicate using both connection-oriented communication and broadcast communication? (the multi-role example only demonstrates a node in connection-oriented communication playing both central and peripheral)&lt;br /&gt;2. may i know if&amp;nbsp;all broadcasted data are asynchronous[/quote]
&lt;p&gt;1) Mesh GATT proxy does something like this. But remember that mesh node in itself is very radio intensive, so the connection with the gatt proxy might be limited in throughput.&lt;/p&gt;
&lt;p&gt;2) Not sure what you mean by that, the packets are organized synchronously. It is synchronous transmission based flooding.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/438619?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 19:23:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4baeb0b-34ff-430c-a57b-42f93e906ab4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Priscilla,&lt;/p&gt;
&lt;p&gt;Terje is on vacation and I took over this thread. For me the most important thing to get a confirmation on is if it is possible to have both mesh node and BLE connection work at the same time. I assumed that the mesh node (not using LPN) would consume most of the radio time. I would have thought that if you need any other BLE feature parallel to Mesh you would have to use timeslots.&lt;/p&gt;
&lt;p&gt;Let me test your code early next week and come back to you with my observations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/437772?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2023 02:18:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f97b2d9-1feb-486c-94c0-fc1db22aa0f3</guid><dc:creator>mash&amp;amp;hash</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thank you for replying me despite summer vacations.&lt;br /&gt;Hope you are having a great summer in Norway.&lt;br /&gt;Unfortunately, I still have no luck figuring it out.&amp;nbsp;&lt;br /&gt;Oh yes !! Will try to give a sniffer trace a shot, thank you for the hyperlink.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Can I clarify my understand of the following with you&lt;br /&gt;1. can a node communicate using both connection-oriented communication and broadcast communication? (the multi-role example only demonstrates a node in connection-oriented communication playing both central and peripheral)&lt;br /&gt;2. may i know if&amp;nbsp;all broadcasted data are asynchronous?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Look forward to your reply.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;mash&amp;amp;hash&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/437342?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2023 15:51:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:750d7025-6b38-4837-9f68-1a1ad88db255</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you had any luck figuring out where the NUS communication fails? E.g. is the connection set up at all? Do you get communication one way (but not the other)? Have you tried doing a &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nrf-sniffer-for-bluetooth-le"&gt;sniffer trace&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;
&lt;p&gt;PS: Response times are long and we have limited capacity due to summer vacation season here in Norway. I am sorry for any inconvenience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/436147?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2023 07:20:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d830c5d-d10d-4037-8c0a-a33bd621c42e</guid><dc:creator>mash&amp;amp;hash</dc:creator><description>&lt;p&gt;Hi tesc, thank you for your reply. Following your advice, I managed to get the bluetooth mesh working but the bluetooth LE UART central and peripheral communication&amp;nbsp;isn&amp;#39;t operational.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;main.c&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/** @file
 *  @brief Nordic UART Service Client sample
 */

#include &amp;quot;model_handler.h&amp;quot;
#include &amp;lt;dk_buttons_and_leds.h&amp;gt;
#include &amp;lt;bluetooth/mesh/models.h&amp;gt;
#include &amp;lt;bluetooth/mesh/dk_prov.h&amp;gt;

#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/devicetree.h&amp;gt;
#include &amp;lt;zephyr/sys/byteorder.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;

#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/hci.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/conn.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/uuid.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/gatt.h&amp;gt;

#include &amp;lt;bluetooth/services/nus.h&amp;gt;
#include &amp;lt;bluetooth/services/nus_client.h&amp;gt;
#include &amp;lt;bluetooth/gatt_dm.h&amp;gt;
#include &amp;lt;bluetooth/scan.h&amp;gt;

#include &amp;lt;zephyr/settings/settings.h&amp;gt;

#include &amp;lt;zephyr/drivers/uart.h&amp;gt;

#include &amp;lt;zephyr/logging/log.h&amp;gt;

#define LOG_MODULE_NAME central_uart
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

/* UART payload buffer element size. */
#define UART_BUF_SIZE 20

#define KEY_PASSKEY_ACCEPT DK_BTN1_MSK
#define KEY_PASSKEY_REJECT DK_BTN2_MSK

#define NUS_WRITE_TIMEOUT K_MSEC(150)
#define UART_WAIT_FOR_BUF_DELAY K_MSEC(50)
#define UART_RX_TIMEOUT 50

static const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(uart0));
static struct k_work_delayable uart_work;

static void bt_ready(int err)
{
	if (err) {
		printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Bluetooth initialized\n&amp;quot;);

	dk_leds_init();
	dk_buttons_init(NULL);

	err = bt_mesh_init(bt_mesh_dk_prov_init(), model_handler_init());
	if (err) {
		printk(&amp;quot;Initializing mesh failed (err %d)\n&amp;quot;, err);
		return;
	}

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	/* This will be a no-op if settings_load() loaded provisioning info */
	bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);

	printk(&amp;quot;Mesh initialized\n&amp;quot;);
}


K_SEM_DEFINE(nus_write_sem, 0, 1);

struct uart_data_t {
	void *fifo_reserved;
	uint8_t  data[UART_BUF_SIZE];
	uint16_t len;
};

static K_FIFO_DEFINE(fifo_uart_tx_data);
static K_FIFO_DEFINE(fifo_uart_rx_data);

static struct bt_conn *default_conn;
static struct bt_nus_client nus_client;

static void ble_data_sent(struct bt_nus_client *nus, uint8_t err,
					const uint8_t *const data, uint16_t len)
{
	ARG_UNUSED(nus);

	struct uart_data_t *buf;

	/* Retrieve buffer context. */
	buf = CONTAINER_OF(data, struct uart_data_t, data);
	k_free(buf);

	k_sem_give(&amp;amp;nus_write_sem);

	if (err) {
		LOG_WRN(&amp;quot;ATT error code: 0x%02X&amp;quot;, err);
	}
}

static uint8_t ble_data_received(struct bt_nus_client *nus,
						const uint8_t *data, uint16_t len)
{
	ARG_UNUSED(nus);

	int err;

	for (uint16_t pos = 0; pos != len;) {
		struct uart_data_t *tx = k_malloc(sizeof(*tx));

		if (!tx) {
			LOG_WRN(&amp;quot;Not able to allocate UART send data buffer&amp;quot;);
			return BT_GATT_ITER_CONTINUE;
		}

		/* Keep the last byte of TX buffer for potential LF char. */
		size_t tx_data_size = sizeof(tx-&amp;gt;data) - 1;

		if ((len - pos) &amp;gt; tx_data_size) {
			tx-&amp;gt;len = tx_data_size;
		} else {
			tx-&amp;gt;len = (len - pos);
		}

		memcpy(tx-&amp;gt;data, &amp;amp;data[pos], tx-&amp;gt;len);

		pos += tx-&amp;gt;len;

		/* Append the LF character when the CR character triggered
		 * transmission from the peer.
		 */
		if ((pos == len) &amp;amp;&amp;amp; (data[len - 1] == &amp;#39;\r&amp;#39;)) {
			tx-&amp;gt;data[tx-&amp;gt;len] = &amp;#39;\n&amp;#39;;
			tx-&amp;gt;len++;
		}

		err = uart_tx(uart, tx-&amp;gt;data, tx-&amp;gt;len, SYS_FOREVER_MS);
		if (err) {
			k_fifo_put(&amp;amp;fifo_uart_tx_data, tx);
		}
	}

	return BT_GATT_ITER_CONTINUE;
}

static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data)
{
	ARG_UNUSED(dev);

	static size_t aborted_len;
	struct uart_data_t *buf;
	static uint8_t *aborted_buf;
	static bool disable_req;

	switch (evt-&amp;gt;type) {
	case UART_TX_DONE:
		LOG_DBG(&amp;quot;UART_TX_DONE&amp;quot;);
		if ((evt-&amp;gt;data.tx.len == 0) ||
		    (!evt-&amp;gt;data.tx.buf)) {
			return;
		}

		if (aborted_buf) {
			buf = CONTAINER_OF(aborted_buf, struct uart_data_t,
					   data);
			aborted_buf = NULL;
			aborted_len = 0;
		} else {
			buf = CONTAINER_OF(evt-&amp;gt;data.tx.buf,
					   struct uart_data_t,
					   data);
		}

		k_free(buf);

		buf = k_fifo_get(&amp;amp;fifo_uart_tx_data, K_NO_WAIT);
		if (!buf) {
			return;
		}

		if (uart_tx(uart, buf-&amp;gt;data, buf-&amp;gt;len, SYS_FOREVER_MS)) {
			LOG_WRN(&amp;quot;Failed to send data over UART&amp;quot;);
		}

		break;

	case UART_RX_RDY:
		LOG_DBG(&amp;quot;UART_RX_RDY&amp;quot;);
		buf = CONTAINER_OF(evt-&amp;gt;data.rx.buf, struct uart_data_t, data);
		buf-&amp;gt;len += evt-&amp;gt;data.rx.len;

		if (disable_req) {
			return;
		}

		if ((evt-&amp;gt;data.rx.buf[buf-&amp;gt;len - 1] == &amp;#39;\n&amp;#39;) ||
		    (evt-&amp;gt;data.rx.buf[buf-&amp;gt;len - 1] == &amp;#39;\r&amp;#39;)) {
			disable_req = true;
			uart_rx_disable(uart);
		}

		break;

	case UART_RX_DISABLED:
		LOG_DBG(&amp;quot;UART_RX_DISABLED&amp;quot;);
		disable_req = false;

		buf = k_malloc(sizeof(*buf));
		if (buf) {
			buf-&amp;gt;len = 0;
		} else {
			LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
			k_work_reschedule(&amp;amp;uart_work, UART_WAIT_FOR_BUF_DELAY);
			return;
		}

		uart_rx_enable(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data),
			       UART_RX_TIMEOUT);

		break;

	case UART_RX_BUF_REQUEST:
		LOG_DBG(&amp;quot;UART_RX_BUF_REQUEST&amp;quot;);
		buf = k_malloc(sizeof(*buf));
		if (buf) {
			buf-&amp;gt;len = 0;
			uart_rx_buf_rsp(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data));
		} else {
			LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
		}

		break;

	case UART_RX_BUF_RELEASED:
		LOG_DBG(&amp;quot;UART_RX_BUF_RELEASED&amp;quot;);
		buf = CONTAINER_OF(evt-&amp;gt;data.rx_buf.buf, struct uart_data_t,
				   data);

		if (buf-&amp;gt;len &amp;gt; 0) {
			k_fifo_put(&amp;amp;fifo_uart_rx_data, buf);
		} else {
			k_free(buf);
		}

		break;

	case UART_TX_ABORTED:
		LOG_DBG(&amp;quot;UART_TX_ABORTED&amp;quot;);
		if (!aborted_buf) {
			aborted_buf = (uint8_t *)evt-&amp;gt;data.tx.buf;
		}

		aborted_len += evt-&amp;gt;data.tx.len;
		buf = CONTAINER_OF(aborted_buf, struct uart_data_t,
				   data);

		uart_tx(uart, &amp;amp;buf-&amp;gt;data[aborted_len],
			buf-&amp;gt;len - aborted_len, SYS_FOREVER_MS);

		break;

	default:
		break;
	}
}

static void uart_work_handler(struct k_work *item)
{
	struct uart_data_t *buf;

	buf = k_malloc(sizeof(*buf));
	if (buf) {
		buf-&amp;gt;len = 0;
	} else {
		LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);
		k_work_reschedule(&amp;amp;uart_work, UART_WAIT_FOR_BUF_DELAY);
		return;
	}

	uart_rx_enable(uart, buf-&amp;gt;data, sizeof(buf-&amp;gt;data), UART_RX_TIMEOUT);
}

static int uart_init(void)
{
	int err;
	struct uart_data_t *rx;

	if (!device_is_ready(uart)) {
		LOG_ERR(&amp;quot;UART device not ready&amp;quot;);
		return -ENODEV;
	}

	rx = k_malloc(sizeof(*rx));
	if (rx) {
		rx-&amp;gt;len = 0;
	} else {
		return -ENOMEM;
	}

	k_work_init_delayable(&amp;amp;uart_work, uart_work_handler);

	err = uart_callback_set(uart, uart_cb, NULL);
	if (err) {
		return err;
	}

	return uart_rx_enable(uart, rx-&amp;gt;data, sizeof(rx-&amp;gt;data),
			      UART_RX_TIMEOUT);
}

static void discovery_complete(struct bt_gatt_dm *dm,
			       void *context)
{
	struct bt_nus_client *nus = context;
	LOG_INF(&amp;quot;Service discovery completed&amp;quot;);

	bt_gatt_dm_data_print(dm);

	bt_nus_handles_assign(dm, nus);
	bt_nus_subscribe_receive(nus);

	bt_gatt_dm_data_release(dm);
}

static void discovery_service_not_found(struct bt_conn *conn,
					void *context)
{
	LOG_INF(&amp;quot;Service not found&amp;quot;);
}

static void discovery_error(struct bt_conn *conn,
			    int err,
			    void *context)
{
	LOG_WRN(&amp;quot;Error while discovering GATT database: (%d)&amp;quot;, err);
}

struct bt_gatt_dm_cb discovery_cb = {
	.completed         = discovery_complete,
	.service_not_found = discovery_service_not_found,
	.error_found       = discovery_error,
};

static void gatt_discover(struct bt_conn *conn)
{
	int err;

	if (conn != default_conn) {
		return;
	}

	err = bt_gatt_dm_start(conn,
			       BT_UUID_NUS_SERVICE,
			       &amp;amp;discovery_cb,
			       &amp;amp;nus_client);
	if (err) {
		LOG_ERR(&amp;quot;could not start the discovery procedure, error &amp;quot;
			&amp;quot;code: %d&amp;quot;, err);
	}
}

static void exchange_func(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
{
	if (!err) {
		LOG_INF(&amp;quot;MTU exchange done&amp;quot;);
	} else {
		LOG_WRN(&amp;quot;MTU exchange failed (err %&amp;quot; PRIu8 &amp;quot;)&amp;quot;, err);
	}
}

static void connected(struct bt_conn *conn, uint8_t conn_err)
{
	char addr[BT_ADDR_LE_STR_LEN];
	int err;

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	if (conn_err) {
		LOG_INF(&amp;quot;Failed to connect to %s (%d)&amp;quot;, addr, conn_err);

		if (default_conn == conn) {
			bt_conn_unref(default_conn);
			default_conn = NULL;

			err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
			if (err) {
				LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;,
					err);
			}
		}

		return;
	}

	LOG_INF(&amp;quot;Connected: %s&amp;quot;, addr);

	static struct bt_gatt_exchange_params exchange_params;

	exchange_params.func = exchange_func;
	err = bt_gatt_exchange_mtu(conn, &amp;amp;exchange_params);
	if (err) {
		LOG_WRN(&amp;quot;MTU exchange failed (err %d)&amp;quot;, err);
	}

	err = bt_conn_set_security(conn, BT_SECURITY_L2);
	if (err) {
		LOG_WRN(&amp;quot;Failed to set security: %d&amp;quot;, err);

		gatt_discover(conn);
	}

	err = bt_scan_stop();
	if ((!err) &amp;amp;&amp;amp; (err != -EALREADY)) {
		LOG_ERR(&amp;quot;Stop LE scan failed (err %d)&amp;quot;, err);
	}
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	char addr[BT_ADDR_LE_STR_LEN];
	int err;

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Disconnected: %s (reason %u)&amp;quot;, addr, reason);

	if (default_conn != conn) {
		return;
	}

	bt_conn_unref(default_conn);
	default_conn = NULL;

	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;,
			err);
	}
}

static void security_changed(struct bt_conn *conn, bt_security_t level,
			     enum bt_security_err err)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	if (!err) {
		LOG_INF(&amp;quot;Security changed: %s level %u&amp;quot;, addr, level);
	} else {
		LOG_WRN(&amp;quot;Security failed: %s level %u err %d&amp;quot;, addr,
			level, err);
	}

	gatt_discover(conn);
}

BT_CONN_CB_DEFINE(conn_callbacks) = {
	.connected = connected,
	.disconnected = disconnected,
	.security_changed = security_changed
};

static void scan_filter_match(struct bt_scan_device_info *device_info,
			      struct bt_scan_filter_match *filter_match,
			      bool connectable)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(device_info-&amp;gt;recv_info-&amp;gt;addr, addr, sizeof(addr));

	LOG_INF(&amp;quot;Filters matched. Address: %s connectable: %d&amp;quot;,
		addr, connectable);
}

static void scan_connecting_error(struct bt_scan_device_info *device_info)
{
	LOG_WRN(&amp;quot;Connecting failed&amp;quot;);
}

static void scan_connecting(struct bt_scan_device_info *device_info,
			    struct bt_conn *conn)
{
	default_conn = bt_conn_ref(conn);
}

static int nus_client_init(void)
{
	int err;
	struct bt_nus_client_init_param init = {
		.cb = {
			.received = ble_data_received,
			.sent = ble_data_sent,
		}
	};

	err = bt_nus_client_init(&amp;amp;nus_client, &amp;amp;init);
	if (err) {
		LOG_ERR(&amp;quot;NUS Client initialization failed (err %d)&amp;quot;, err);
		return err;
	}

	LOG_INF(&amp;quot;NUS Client module initialized&amp;quot;);
	return err;
}

BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL,
		scan_connecting_error, scan_connecting);

static int scan_init(void)
{
	int err;
	struct bt_scan_init_param scan_init = {
		.connect_if_match = 1,
	};

	bt_scan_init(&amp;amp;scan_init);
	bt_scan_cb_register(&amp;amp;scan_cb);

	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_NUS_SERVICE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning filters cannot be set (err %d)&amp;quot;, err);
		return err;
	}

	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
	if (err) {
		LOG_ERR(&amp;quot;Filters cannot be turned on (err %d)&amp;quot;, err);
		return err;
	}

	LOG_INF(&amp;quot;Scan module initialized&amp;quot;);
	return err;
}


static void auth_cancel(struct bt_conn *conn)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Pairing cancelled: %s&amp;quot;, addr);
}


static void pairing_complete(struct bt_conn *conn, bool bonded)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_INF(&amp;quot;Pairing completed: %s, bonded: %d&amp;quot;, addr, bonded);
}


static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	LOG_WRN(&amp;quot;Pairing failed conn: %s, reason %d&amp;quot;, addr, reason);
}

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.cancel = auth_cancel,
};

static struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed
};

void main(void)
{
	int err;

	err = bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	if (err) {
		LOG_ERR(&amp;quot;Failed to register authorization callbacks.&amp;quot;);
		return;
	}

	err = bt_conn_auth_info_cb_register(&amp;amp;conn_auth_info_callbacks);
	if (err) {
		printk(&amp;quot;Failed to register authorization info callbacks.\n&amp;quot;);
		return;
	}

	err = bt_enable(bt_ready);
	if (err) {
		LOG_ERR(&amp;quot;Bluetooth init failed (err %d)&amp;quot;, err);
		return;
	}
	LOG_INF(&amp;quot;Bluetooth initialized&amp;quot;);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	int (*module_init[])(void) = {uart_init, scan_init, nus_client_init};
	for (size_t i = 0; i &amp;lt; ARRAY_SIZE(module_init); i++) {
		err = (*module_init[i])();
		if (err) {
			return;
		}
	}

	printk(&amp;quot;Starting Bluetooth Central UART example\n&amp;quot;);


	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;, err);
		return;
	}

	LOG_INF(&amp;quot;Scanning successfully started&amp;quot;);

	printk(&amp;quot;Initializing...\n&amp;quot;);

	err = bt_enable(bt_ready);
	if (err) {
		printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
	}

	return 0;

	for (;;) {
		/* Wait indefinitely for data to be sent over Bluetooth */
		struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data,
						     K_FOREVER);

		err = bt_nus_client_send(&amp;amp;nus_client, buf-&amp;gt;data, buf-&amp;gt;len);
		if (err) {
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;
				&amp;quot;(err %d)&amp;quot;, err);
		}

		err = k_sem_take(&amp;amp;nus_write_sem, NUS_WRITE_TIMEOUT);
		if (err) {
			LOG_WRN(&amp;quot;NUS send timeout&amp;quot;);
		}
	}
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;model_handler.c&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/mesh/models.h&amp;gt;
#include &amp;lt;dk_buttons_and_leds.h&amp;gt;
#include &amp;quot;model_handler.h&amp;quot;

#define GET_DATA_INTERVAL 3000

static void sensor_cli_data_cb(struct bt_mesh_sensor_cli *cli,
			       struct bt_mesh_msg_ctx *ctx,
			       const struct bt_mesh_sensor_type *sensor,
			       const struct sensor_value *value)
{
	if (sensor-&amp;gt;id == bt_mesh_sensor_present_dev_op_temp.id) {
		printk(&amp;quot;Chip temperature: %s\n&amp;quot;,
		       bt_mesh_sensor_ch_str(value));
	} else if (sensor-&amp;gt;id == bt_mesh_sensor_presence_detected.id) {
		if (value-&amp;gt;val1) {
			printk(&amp;quot;Presence detected\n&amp;quot;);
		} else {
			printk(&amp;quot;No presence detected\n&amp;quot;);
		}
	} else if (sensor-&amp;gt;id ==
		   bt_mesh_sensor_time_since_presence_detected.id) {
		if (!value-&amp;gt;val1) {
			printk(&amp;quot;Presence detected, or under 1 second since presence detected\n&amp;quot;);
		} else if (value-&amp;gt;val1 == 0xFFFF) {
			printk(&amp;quot;Unknown last presence detected\n&amp;quot;);
		} else {
			printk(&amp;quot;%s second(s) since last presence detected\n&amp;quot;,
			       bt_mesh_sensor_ch_str(value));
		}
	}
}

static void sensor_cli_series_entry_cb(
	struct bt_mesh_sensor_cli *cli, struct bt_mesh_msg_ctx *ctx,
	const struct bt_mesh_sensor_type *sensor, uint8_t index, uint8_t count,
	const struct bt_mesh_sensor_series_entry *entry)
{
	printk(&amp;quot;Relative runtime in %d to %d degrees: %s percent\n&amp;quot;,
		entry-&amp;gt;value[1].val1, entry-&amp;gt;value[2].val1,
		bt_mesh_sensor_ch_str(&amp;amp;entry-&amp;gt;value[0]));
}

static void sensor_cli_setting_status_cb(struct bt_mesh_sensor_cli *cli,
					 struct bt_mesh_msg_ctx *ctx,
					 const struct bt_mesh_sensor_type *sensor,
					 const struct bt_mesh_sensor_setting_status *setting)
{
	printk(&amp;quot;Sensor ID: 0x%04x, Setting ID: 0x%04x\n&amp;quot;, sensor-&amp;gt;id, setting-&amp;gt;type-&amp;gt;id);
	for (int chan = 0; chan &amp;lt; setting-&amp;gt;type-&amp;gt;channel_count; chan++) {
		printk(&amp;quot;\tChannel %d value: %s\n&amp;quot;, chan,
		       bt_mesh_sensor_ch_str(&amp;amp;(setting-&amp;gt;value[chan])));
	}
}

static void sensor_cli_desc_cb(struct bt_mesh_sensor_cli *cli, struct bt_mesh_msg_ctx *ctx,
			       const struct bt_mesh_sensor_info *sensor)
{
	printk(&amp;quot;Descriptor of sensor with ID 0x%04x:\n&amp;quot;, sensor-&amp;gt;id);
	printk(&amp;quot;\ttolerance: { positive: %s&amp;quot;,
	       bt_mesh_sensor_ch_str(&amp;amp;sensor-&amp;gt;descriptor.tolerance.positive));
	printk(&amp;quot; negative: %s }\n&amp;quot;, bt_mesh_sensor_ch_str(&amp;amp;sensor-&amp;gt;descriptor.tolerance.negative));
	printk(&amp;quot;\tsampling type: %d\n&amp;quot;, sensor-&amp;gt;descriptor.sampling_type);
}

static const struct bt_mesh_sensor_cli_handlers bt_mesh_sensor_cli_handlers = {
	.data = sensor_cli_data_cb,
	.series_entry = sensor_cli_series_entry_cb,
	.setting_status = sensor_cli_setting_status_cb,
	.sensor = sensor_cli_desc_cb,
};

static struct bt_mesh_sensor_cli sensor_cli =
	BT_MESH_SENSOR_CLI_INIT(&amp;amp;bt_mesh_sensor_cli_handlers);

static struct k_work_delayable get_data_work;

static void get_data(struct k_work *work)
{
	if (!bt_mesh_is_provisioned()) {
		k_work_schedule(&amp;amp;get_data_work, K_MSEC(GET_DATA_INTERVAL));
		return;
	}

	static uint32_t sensor_idx;
	int err;

	/* Only one message can be published at a time. Swap sensor after each timeout. */
	switch (sensor_idx++ % 3) {
	case (0): {
		err = bt_mesh_sensor_cli_get(&amp;amp;sensor_cli, NULL, &amp;amp;bt_mesh_sensor_present_dev_op_temp,
					     NULL);
		if (err) {
			printk(&amp;quot;Error getting chip temperature (%d)\n&amp;quot;, err);
		}
		break;
	}
	case (1): {
		err = bt_mesh_sensor_cli_series_entries_get(
			&amp;amp;sensor_cli, NULL,
			&amp;amp;bt_mesh_sensor_rel_runtime_in_a_dev_op_temp_range, NULL, NULL,
			NULL);
		if (err) {
			printk(&amp;quot;Error getting relative chip temperature data (%d)\n&amp;quot;,
			       err);
		}
		break;
	}
	case (2): {
		err = bt_mesh_sensor_cli_get(
			&amp;amp;sensor_cli, NULL, &amp;amp;bt_mesh_sensor_time_since_presence_detected,
			NULL);
		if (err) {
			printk(&amp;quot;Error getting time since presence detected (%d)\n&amp;quot;,
			       err);
		}
		break;
	}
	}
	k_work_schedule(&amp;amp;get_data_work, K_MSEC(GET_DATA_INTERVAL));
}

static const struct sensor_value temp_ranges[][2] = {
	{ { 0 }, { 100 } },
	{ { 10 }, { 20 } },
	{ { 22 }, { 30 } },
	{ { 40 }, { 50 } },
};

static const struct sensor_value presence_motion_threshold[] = {
	{   0 },
	{  25 },
	{  50 },
	{  75 },
	{ 100 },
};

static void button_handler_cb(uint32_t pressed, uint32_t changed)
{
	if (!bt_mesh_is_provisioned()) {
		return;
	}

	static uint32_t temp_idx;
	static uint32_t motion_threshold_idx;
	int err;

	if (pressed &amp;amp; changed &amp;amp; BIT(0)) {
		err = bt_mesh_sensor_cli_setting_get(&amp;amp;sensor_cli, NULL,
						     &amp;amp;bt_mesh_sensor_present_dev_op_temp,
						     &amp;amp;bt_mesh_sensor_dev_op_temp_range_spec, NULL);
		if (err) {
			printk(&amp;quot;Error getting range setting (%d)\n&amp;quot;, err);
		}
	}
	if (pressed &amp;amp; changed &amp;amp; BIT(1)) {
		err = bt_mesh_sensor_cli_setting_set(
			&amp;amp;sensor_cli, NULL, &amp;amp;bt_mesh_sensor_present_dev_op_temp,
			&amp;amp;bt_mesh_sensor_dev_op_temp_range_spec,
			&amp;amp;temp_ranges[temp_idx++][0], NULL);
		if (err) {
			printk(&amp;quot;Error setting range setting (%d)\n&amp;quot;, err);
		}
		temp_idx = temp_idx % ARRAY_SIZE(temp_ranges);
	}
	if (pressed &amp;amp; changed &amp;amp; BIT(2)) {
		err = bt_mesh_sensor_cli_desc_get(&amp;amp;sensor_cli, NULL,
						  &amp;amp;bt_mesh_sensor_present_dev_op_temp, NULL);
		if (err) {
			printk(&amp;quot;Error getting sensor descriptor (%d)\n&amp;quot;, err);
		}
	}
	if (pressed &amp;amp; changed &amp;amp; BIT(3)) {
		err = bt_mesh_sensor_cli_setting_set(
			&amp;amp;sensor_cli, NULL, &amp;amp;bt_mesh_sensor_presence_detected,
			&amp;amp;bt_mesh_sensor_motion_threshold,
			&amp;amp;presence_motion_threshold[motion_threshold_idx++], NULL);
		if (err) {
			printk(&amp;quot;Error setting motion threshold setting (%d)\n&amp;quot;, err);
		}
		motion_threshold_idx = motion_threshold_idx % ARRAY_SIZE(presence_motion_threshold);
	}
}

static struct button_handler button_handler = {
	.cb = button_handler_cb,
};

/* Set up a repeating delayed work to blink the DK&amp;#39;s LEDs when attention is
 * requested.
 */
static struct k_work_delayable attention_blink_work;
static bool attention;

static void attention_blink(struct k_work *work)
{
	static int idx;
	const uint8_t pattern[] = {
		BIT(0) | BIT(1),
		BIT(1) | BIT(2),
		BIT(2) | BIT(3),
		BIT(3) | BIT(0),
	};

	if (attention) {
		dk_set_leds(pattern[idx++ % ARRAY_SIZE(pattern)]);
		k_work_reschedule(&amp;amp;attention_blink_work, K_MSEC(30));
	} else {
		dk_set_leds(DK_NO_LEDS_MSK);
	}
}

static void attention_on(struct bt_mesh_model *mod)
{
	attention = true;
	k_work_reschedule(&amp;amp;attention_blink_work, K_NO_WAIT);
}

static void attention_off(struct bt_mesh_model *mod)
{
	/* Will stop rescheduling blink timer */
	attention = false;
}

static const struct bt_mesh_health_srv_cb health_srv_cb = {
	.attn_on = attention_on,
	.attn_off = attention_off,
};

static struct bt_mesh_health_srv health_srv = {
	.cb = &amp;amp;health_srv_cb,
};

BT_MESH_HEALTH_PUB_DEFINE(health_pub, 0);

static struct bt_mesh_elem elements[] = {
	BT_MESH_ELEM(1,
		     BT_MESH_MODEL_LIST(BT_MESH_MODEL_CFG_SRV,
					BT_MESH_MODEL_HEALTH_SRV(&amp;amp;health_srv,
								 &amp;amp;health_pub),
					BT_MESH_MODEL_SENSOR_CLI(&amp;amp;sensor_cli)),
		     BT_MESH_MODEL_NONE),
};

static const struct bt_mesh_comp comp = {
	.cid = CONFIG_BT_COMPANY_ID,
	.elem = elements,
	.elem_count = ARRAY_SIZE(elements),
};

const struct bt_mesh_comp *model_handler_init(void)
{
	k_work_init_delayable(&amp;amp;attention_blink_work, attention_blink);
	k_work_init_delayable(&amp;amp;get_data_work, get_data);

	dk_button_handler_add(&amp;amp;button_handler);
	k_work_schedule(&amp;amp;get_data_work, K_MSEC(GET_DATA_INTERVAL));

	return &amp;amp;comp;
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CMakeLists.txt&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(central_uart)

# NORDIC SDK APP START
target_sources(app PRIVATE
  src/main.c
  src/model_handler.c
)

target_include_directories(app PRIVATE include)
# NORDIC SDK APP END

zephyr_library_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;prj.conf&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Enable the BLE stack with GATT Client configuration
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y

# Enable the BLE modules from NCS
CONFIG_BT_NUS_CLIENT=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=2048

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n

CONFIG_ASSERT=y
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y

# Deffered logging helps improve LPN power consumption
# when friendship is established.
CONFIG_LOG_MODE_DEFERRED=y

# General configuration
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_NVS_LOOKUP_CACHE=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS_NAME_CACHE=y
CONFIG_HWINFO=y
CONFIG_DK_LIBRARY=y
CONFIG_PM_SINGLE_IMAGE=y
CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x8000
CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE=y

# Bluetooth configuration
CONFIG_BT=y
CONFIG_BT_COMPANY_ID=0x0059
CONFIG_BT_DEVICE_NAME=&amp;quot;Mesh Sensor Observer&amp;quot;
CONFIG_BT_L2CAP_TX_MTU=69
CONFIG_BT_L2CAP_TX_BUF_COUNT=32
CONFIG_BT_CTLR_DATA_LENGTH_MAX=37
CONFIG_BT_BUF_ACL_TX_SIZE=37
CONFIG_BT_OBSERVER=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SETTINGS=y
CONFIG_BT_RX_STACK_SIZE=2300

# Disable unused Bluetooth features
CONFIG_BT_CTLR_DUP_FILTER_LEN=0
CONFIG_BT_CTLR_LE_ENC=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_CHAN_SEL_2=n
CONFIG_BT_CTLR_MIN_USED_CHAN=n
CONFIG_BT_CTLR_PRIVACY=n

# Bluetooth mesh configuration
CONFIG_BT_MESH=y
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_FRIEND=y
CONFIG_BT_MESH_ADV_BUF_COUNT=64
CONFIG_BT_MESH_TX_SEG_MAX=24
CONFIG_BT_MESH_RX_SEG_MAX=16
CONFIG_BT_MESH_PB_GATT=y
CONFIG_BT_MESH_GATT_PROXY=y
CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME=y
CONFIG_BT_MESH_DK_PROV=y
CONFIG_BT_MESH_SUBNET_COUNT=2
CONFIG_BT_MESH_APP_KEY_COUNT=3
CONFIG_BT_MESH_CRPL=32
CONFIG_BT_MESH_MSG_CACHE_SIZE=64

# Bluetooth mesh models
CONFIG_BT_MESH_SENSOR_CLI=y
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrf52840dk_nrf52840.dts&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2017 Linaro Limited
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/dts-v1/;
#include &amp;lt;nordic/nrf52840_qiaa.dtsi&amp;gt;
#include &amp;quot;nrf52840dk_nrf52840-pinctrl.dtsi&amp;quot;

/ {
	model = &amp;quot;Nordic nRF52840 DK NRF52840&amp;quot;;
	compatible = &amp;quot;nordic,nrf52840-dk-nrf52840&amp;quot;;

	chosen {
		zephyr,console = &amp;amp;uart0;
		zephyr,shell-uart = &amp;amp;uart0;
		zephyr,uart-mcumgr = &amp;amp;uart0;
		zephyr,bt-mon-uart = &amp;amp;uart0;
		zephyr,bt-c2h-uart = &amp;amp;uart0;
		zephyr,sram = &amp;amp;sram0;
		zephyr,flash = &amp;amp;flash0;
		zephyr,code-partition = &amp;amp;slot0_partition;
		zephyr,ieee802154 = &amp;amp;ieee802154;
	};

	leds {
		compatible = &amp;quot;gpio-leds&amp;quot;;
		led0: led_0 {
			gpios = &amp;lt;&amp;amp;gpio0 13 GPIO_ACTIVE_LOW&amp;gt;;
			label = &amp;quot;Green LED 0&amp;quot;;
		};
		led1: led_1 {
			gpios = &amp;lt;&amp;amp;gpio0 14 GPIO_ACTIVE_LOW&amp;gt;;
			label = &amp;quot;Green LED 1&amp;quot;;
		};
		led2: led_2 {
			gpios = &amp;lt;&amp;amp;gpio0 15 GPIO_ACTIVE_LOW&amp;gt;;
			label = &amp;quot;Green LED 2&amp;quot;;
		};
		led3: led_3 {
			gpios = &amp;lt;&amp;amp;gpio0 16 GPIO_ACTIVE_LOW&amp;gt;;
			label = &amp;quot;Green LED 3&amp;quot;;
		};
	};

	pwmleds {
		compatible = &amp;quot;pwm-leds&amp;quot;;
		pwm_led0: pwm_led_0 {
			pwms = &amp;lt;&amp;amp;pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
		};
	};

	buttons {
		compatible = &amp;quot;gpio-keys&amp;quot;;
		button0: button_0 {
			gpios = &amp;lt;&amp;amp;gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
			label = &amp;quot;Push button switch 0&amp;quot;;
		};
		button1: button_1 {
			gpios = &amp;lt;&amp;amp;gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
			label = &amp;quot;Push button switch 1&amp;quot;;
		};
		button2: button_2 {
			gpios = &amp;lt;&amp;amp;gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
			label = &amp;quot;Push button switch 2&amp;quot;;
		};
		button3: button_3 {
			gpios = &amp;lt;&amp;amp;gpio0 25 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
			label = &amp;quot;Push button switch 3&amp;quot;;
		};
	};

	arduino_header: connector {
		compatible = &amp;quot;arduino-header-r3&amp;quot;;
		#gpio-cells = &amp;lt;2&amp;gt;;
		gpio-map-mask = &amp;lt;0xffffffff 0xffffffc0&amp;gt;;
		gpio-map-pass-thru = &amp;lt;0 0x3f&amp;gt;;
		gpio-map = &amp;lt;0 0 &amp;amp;gpio0 3 0&amp;gt;,	/* A0 */
			   &amp;lt;1 0 &amp;amp;gpio0 4 0&amp;gt;,	/* A1 */
			   &amp;lt;2 0 &amp;amp;gpio0 28 0&amp;gt;,	/* A2 */
			   &amp;lt;3 0 &amp;amp;gpio0 29 0&amp;gt;,	/* A3 */
			   &amp;lt;4 0 &amp;amp;gpio0 30 0&amp;gt;,	/* A4 */
			   &amp;lt;5 0 &amp;amp;gpio0 31 0&amp;gt;,	/* A5 */
			   &amp;lt;6 0 &amp;amp;gpio1 1 0&amp;gt;,	/* D0 */
			   &amp;lt;7 0 &amp;amp;gpio1 2 0&amp;gt;,	/* D1 */
			   &amp;lt;8 0 &amp;amp;gpio1 3 0&amp;gt;,	/* D2 */
			   &amp;lt;9 0 &amp;amp;gpio1 4 0&amp;gt;,	/* D3 */
			   &amp;lt;10 0 &amp;amp;gpio1 5 0&amp;gt;,	/* D4 */
			   &amp;lt;11 0 &amp;amp;gpio1 6 0&amp;gt;,	/* D5 */
			   &amp;lt;12 0 &amp;amp;gpio1 7 0&amp;gt;,	/* D6 */
			   &amp;lt;13 0 &amp;amp;gpio1 8 0&amp;gt;,	/* D7 */
			   &amp;lt;14 0 &amp;amp;gpio1 10 0&amp;gt;,	/* D8 */
			   &amp;lt;15 0 &amp;amp;gpio1 11 0&amp;gt;,	/* D9 */
			   &amp;lt;16 0 &amp;amp;gpio1 12 0&amp;gt;,	/* D10 */
			   &amp;lt;17 0 &amp;amp;gpio1 13 0&amp;gt;,	/* D11 */
			   &amp;lt;18 0 &amp;amp;gpio1 14 0&amp;gt;,	/* D12 */
			   &amp;lt;19 0 &amp;amp;gpio1 15 0&amp;gt;,	/* D13 */
			   &amp;lt;20 0 &amp;amp;gpio0 26 0&amp;gt;,	/* D14 */
			   &amp;lt;21 0 &amp;amp;gpio0 27 0&amp;gt;;	/* D15 */
	};

	arduino_adc: analog-connector {
		compatible = &amp;quot;arduino,uno-adc&amp;quot;;
		#io-channel-cells = &amp;lt;1&amp;gt;;
		io-channel-map = &amp;lt;0 &amp;amp;adc 1&amp;gt;,	/* A0 = P0.3 = AIN1 */
				 &amp;lt;1 &amp;amp;adc 2&amp;gt;,	/* A1 = P0.4 = AIN2 */
				 &amp;lt;2 &amp;amp;adc 4&amp;gt;,	/* A2 = P0.28 = AIN4 */
				 &amp;lt;3 &amp;amp;adc 5&amp;gt;,	/* A3 = P0.29 = AIN5 */
				 &amp;lt;4 &amp;amp;adc 6&amp;gt;,	/* A4 = P0.30 = AIN6 */
				 &amp;lt;5 &amp;amp;adc 7&amp;gt;;	/* A5 = P0.31 = AIN7 */
	};

	/* These aliases are provided for compatibility with samples */
	aliases {
		led0 = &amp;amp;led0;
		led1 = &amp;amp;led1;
		led2 = &amp;amp;led2;
		led3 = &amp;amp;led3;
		pwm-led0 = &amp;amp;pwm_led0;
		sw0 = &amp;amp;button0;
		sw1 = &amp;amp;button1;
		sw2 = &amp;amp;button2;
		sw3 = &amp;amp;button3;
		bootloader-led0 = &amp;amp;led0;
		mcuboot-button0 = &amp;amp;button0;
		mcuboot-led0 = &amp;amp;led0;
		watchdog0 = &amp;amp;wdt0;
		spi-flash0 = &amp;amp;mx25r64;
	};
};

&amp;amp;adc {
	status = &amp;quot;okay&amp;quot;;
};

&amp;amp;gpiote {
	status = &amp;quot;okay&amp;quot;;
};

&amp;amp;gpio0 {
	status = &amp;quot;okay&amp;quot;;
};

&amp;amp;gpio1 {
	status = &amp;quot;okay&amp;quot;;
};

&amp;amp;uart0 {
	compatible = &amp;quot;nordic,nrf-uarte&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	current-speed = &amp;lt;115200&amp;gt;;
	pinctrl-0 = &amp;lt;&amp;amp;uart0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;uart0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

arduino_serial: &amp;amp;uart1 {
	status = &amp;quot;okay&amp;quot;;
	current-speed = &amp;lt;115200&amp;gt;;
	pinctrl-0 = &amp;lt;&amp;amp;uart1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;uart1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

arduino_i2c: &amp;amp;i2c0 {
	compatible = &amp;quot;nordic,nrf-twi&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;i2c1 {
	compatible = &amp;quot;nordic,nrf-twi&amp;quot;;
	/* Cannot be used together with spi1. */
	/* status = &amp;quot;okay&amp;quot;; */
	pinctrl-0 = &amp;lt;&amp;amp;i2c1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;pwm0 {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;pwm0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;pwm0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;spi0 {
	compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
	/* Cannot be used together with i2c0. */
	/* status = &amp;quot;okay&amp;quot;; */
	pinctrl-0 = &amp;lt;&amp;amp;spi0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;spi2 {
	compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
	status = &amp;quot;disabled&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi2_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi2_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;qspi {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;qspi_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;qspi_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	mx25r64: mx25r6435f@0 {
		compatible = &amp;quot;nordic,qspi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		/* MX25R64 supports only pp and pp4io */
		writeoc = &amp;quot;pp4io&amp;quot;;
		/* MX25R64 supports all readoc options */
		readoc = &amp;quot;read4io&amp;quot;;
		sck-frequency = &amp;lt;8000000&amp;gt;;
		jedec-id = [c2 28 17];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		];
		size = &amp;lt;67108864&amp;gt;;
		has-dpd;
		t-enter-dpd = &amp;lt;10000&amp;gt;;
		t-exit-dpd = &amp;lt;35000&amp;gt;;
	};
};

arduino_spi: &amp;amp;spi3 {
	status = &amp;quot;okay&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;arduino_header 16 GPIO_ACTIVE_LOW&amp;gt;; /* D10 */
	pinctrl-0 = &amp;lt;&amp;amp;spi3_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi3_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;ieee802154 {
	status = &amp;quot;okay&amp;quot;;
};

&amp;amp;flash0 {

	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		boot_partition: partition@0 {
			label = &amp;quot;mcuboot&amp;quot;;
			reg = &amp;lt;0x00000000 0x0000C000&amp;gt;;
		};
		slot0_partition: partition@c000 {
			label = &amp;quot;image-0&amp;quot;;
			reg = &amp;lt;0x0000C000 0x00067000&amp;gt;;
		};
		slot1_partition: partition@73000 {
			label = &amp;quot;image-1&amp;quot;;
			reg = &amp;lt;0x00073000 0x00067000&amp;gt;;
		};
		scratch_partition: partition@da000 {
			label = &amp;quot;image-scratch&amp;quot;;
			reg = &amp;lt;0x000da000 0x0001e000&amp;gt;;
		};

		/*
		 * The flash starting at 0x000f8000 and ending at
		 * 0x000fffff is reserved for use by the application.
		 */

		/*
		 * Storage partition will be used by FCB/LittleFS/NVS
		 * if enabled.
		 */
		storage_partition: partition@f8000 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x000f8000 0x00008000&amp;gt;;
		};
	};
};

zephyr_udc0: &amp;amp;usbd {
	compatible = &amp;quot;nordic,nrf-usbd&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: exploring the possibility of combining/merging two sample codes</title><link>https://devzone.nordicsemi.com/thread/436044?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 15:28:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:375d7ac6-ac4d-4605-ac44-9bbaf67c5dc6</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The main resource constraint when combining BLE roles or BLE with other RF protocols, is radio usage time. It looks like you are combining BLE and Bluetooth mesh. The Bluetooth mesh stack wants to use the radio 100 % of the time, which means any additional BLE roles or other protocols may lead to reduced mesh performance, but all protocols should still work.&lt;/p&gt;
&lt;p&gt;The current code (that you attached in your opening post here) will never initialize Bluetooth mesh, because of the &amp;quot;&lt;code&gt;for (;;) {&lt;/code&gt; (...) &lt;code&gt;}&lt;/code&gt;&amp;quot; which is an infinite loop. No code after that &lt;code&gt;for&lt;/code&gt; loop will run. You should put all initialization before that infinite loop.&lt;/p&gt;
&lt;p&gt;Further, you should not call &lt;code&gt;bt_enable()&lt;/code&gt; multiple times. That function takes an optional callback function, which (if provided) is called when Bluetooth has been initialized. The mesh samples typically use this mechanism. Other samples may pass &lt;code&gt;NULL&lt;/code&gt; as the argument to &lt;code&gt;bt_enable()&lt;/code&gt;, and instead of relying on a callback they do initialization directly in main. Combining the two ways to do it, however, may lead to issues.&lt;/p&gt;
&lt;p&gt;In this particular example, the BLE operations are handled in the infinite for loop, while the Bluetooth mesh operations seems to be handled by other means. From what I can tell, it should be sufficient to replace &lt;code&gt;NULL&lt;/code&gt; with &lt;code&gt;bt_ready&lt;/code&gt; in the first call to &lt;code&gt;bt_enable()&lt;/code&gt;, as well as remove everything inside &lt;code&gt;main()&lt;/code&gt; below the infinite &lt;code&gt;for&lt;/code&gt; loop (since nothing below this for loop will run anyway.)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>