<?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>BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp;amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94782/bl653-crashes-when-working-with-config_mcumgr_smp_bt-config_esb</link><description>Hello everyone, 
 We&amp;#39;re trying to create an application that has 2 modes, one is running our regular application and upon a special command, it switches to a &amp;quot;DFU&amp;quot; (via device manager) mode. 
 In the DFU mode I&amp;#39;ve adapted the example here: https://github</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Dec 2022 14:59:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94782/bl653-crashes-when-working-with-config_mcumgr_smp_bt-config_esb" /><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/401313?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 14:59:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:228bf130-5ff1-4f82-8c35-6bf5de310a09</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Sigurd Hellesvik"]See &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/updating-to-the-mpsl-timeslot-interface"&gt;Updating to the MPSL Timeslot interface&lt;/a&gt; .[/quote]
&lt;p&gt;In case later customers see this: &lt;/p&gt;
&lt;p&gt;I found that in &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/releases/release-notes-2.2.0.html#bluetooth-le"&gt;nRF Connect SDK v2.2.0&lt;/a&gt; you no longer need to use MPSL to switch between Bluetooth Low Energy and ESB.&lt;br /&gt;Instead you can just disable Bluetooth Low Energy when using ESB and vise versa.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/401145?ContentTypeID=1</link><pubDate>Sun, 18 Dec 2022 09:21:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f26dda7d-3792-4f76-9452-1d7af10d4220</guid><dc:creator>Vagner Landskron</dc:creator><description>&lt;p&gt;Thanks Sigurd!&lt;br /&gt;Your links leaded me to the answer.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;smp_svr&lt;/strong&gt; is &amp;quot;erasing&amp;quot; (or marking it as not valid, magic number becomes invalid) the slot&amp;nbsp;once I upload a new image and switch it permanently.&lt;/p&gt;
&lt;p&gt;Solution for my problem is to not use this &amp;quot;smp_svr&amp;quot;, but something that doesn&amp;#39;t invalidate the&amp;nbsp;slot of the application that implements the DFU (i.e, the piece of code in my question).&lt;/p&gt;
&lt;p&gt;Sounds like a silly issue,&amp;nbsp;but I had a misunderstanding of the mechanism of &amp;quot;what happens behind the curtains&amp;quot;.&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;m able to upload my application and from my application to rollback to the DFU mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400795?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 10:18:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8401c726-8202-40d6-87a8-399aa9abb55a</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Vagner Landskron"]To be honest,&amp;nbsp;I feel like&amp;nbsp;I&amp;#39;m over-complicating this.&amp;nbsp;&lt;br /&gt;What I really need is a way to upload my application, over-the-air.[/quote]
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Good job on realizing what you really need! (See XY problem)-&lt;br /&gt;I agree that adding multi-protocol to your project might be too complicated, and probably should realized this in my last answer.&lt;/p&gt;
&lt;p&gt;Now to what you are asking: How to do over the air on an ESB application?&lt;/p&gt;
&lt;p&gt;MCUboot does not really care how the new firmware image is written to flash, as long as it is formatted correctly.&lt;br /&gt;Unfortunately we do not have any functionality for SMP over ESB. So you will have to add it yourself.&lt;/p&gt;
&lt;p&gt;We have some start points for this, which I will show you shortly.&lt;br /&gt;But first a downside with ESB Over-the-air DFU:&lt;br /&gt;Since mobile phones does not support ESB, you need a &amp;quot;DFU sender&amp;quot; to send the update as well.&lt;br /&gt;For example 2x nRF52833DK, one to send the update and one to receive it.&lt;/p&gt;
&lt;p&gt;So how would I suggest to solve this?&lt;br /&gt;MCUboot use the SMP protocol to do DFU.&lt;br /&gt;A SMP Client sends a firmware image to a SMP Server. Then the device with the SMP Server is updated.&lt;br /&gt;If you want to know more about how this works, see &lt;a href="https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples"&gt;some unofficial bootloader theory by me&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We have an SMP Server example for BLE as you know.&lt;br /&gt;This use the zephyr &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.2.99-ncs1/subsys/mgmt/mcumgr"&gt;mcumgr subsys&lt;/a&gt; to handle communication.&lt;br /&gt;As you see in this folder, there is &amp;quot;transport&amp;quot; folder.&lt;br /&gt;In theory, you should be able to add a new trasport here for ESB.&lt;/p&gt;
&lt;p&gt;We do not have an official SMP Client sample, and from when I said previously, you know that you need to have something to send as well.&lt;br /&gt;However, you can use this unofficial &lt;a href="https://github.com/simon-iversen/ncs_samples/tree/master/central_smp_client_dfu"&gt;Bluetooth: Central SMP Client DFU sample&lt;/a&gt;, and change it to use ESB as well.&lt;/p&gt;
&lt;p&gt;So in the end, you see that doing it this way requires you do add an ESB driver to the zephyr mcumgr subsys.&lt;br /&gt;I do not know if this will be more or less work than using MPSL.&lt;br /&gt;But it will be the &amp;quot;cleaner&amp;quot; solution, as your application do not need to switch between BLE and ESB.&lt;/p&gt;
&lt;p&gt;This was a long answer. Did it all make sense to you?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400773?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 09:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:965d70f0-afdb-47ee-a591-13b0c561331e</guid><dc:creator>Vagner Landskron</dc:creator><description>&lt;p&gt;I see, thanks for the reply Sigurd.&lt;/p&gt;
&lt;p&gt;To be honest,&amp;nbsp;I feel like&amp;nbsp;I&amp;#39;m over-complicating this.&amp;nbsp;&lt;br /&gt;What I really need is a way to upload my application, over-the-air.&lt;/p&gt;
&lt;p&gt;My original plan is to have Slot: 0 containing smp_svr (&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/mgmt/mcumgr/smp_svr"&gt;https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/mgmt/mcumgr/smp_svr&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Now we use &amp;quot;Device Manager&amp;quot; to upload our product&amp;#39;s image on Slot 1 - test and confirm.&lt;/p&gt;
&lt;p&gt;If any time in the future I want to upload a new image, then my application &amp;quot;swap&amp;quot; Slots again using&amp;nbsp;&lt;strong&gt;boot_request_upgrade()&amp;nbsp;&lt;/strong&gt;and I get &lt;strong&gt;smp_svr&lt;/strong&gt; running once again (and upload a new image instead of my previous one).&lt;/p&gt;
&lt;p&gt;But I couldn&amp;#39;t make it work so far.&lt;/p&gt;
&lt;p&gt;Is there an example of this simple DFU procedure?&lt;/p&gt;
&lt;p&gt;My setup: nRF52833, Zephyr OS, using &lt;strong&gt;ncs 1.9.1&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400591?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2022 11:39:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d9aadd0-2cf8-44aa-ae4f-e12bc2fec1da</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Vagner,&lt;/p&gt;
&lt;p&gt;From &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_MCUMGR_SMP_BT"&gt;CONFIG_MCUMGR_SMP_BT&lt;/a&gt;, we can see that it selects CONFIG_BT.&lt;/p&gt;
&lt;p&gt;I guess that the root issue here is that the nRF52 can not run ESB and Bluetooth Low Energy simultaneously.&lt;/p&gt;
&lt;p&gt;In that case you will need to use our Multiprotocol Service Layer to switch between these.&lt;/p&gt;
&lt;p&gt;See &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/updating-to-the-mpsl-timeslot-interface"&gt;Updating to the MPSL Timeslot interface&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400425?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 15:24:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c49bd53-34e6-48ce-a7da-ab42d1a5e5c0</guid><dc:creator>Vagner Landskron</dc:creator><description>&lt;p&gt;Hi Sigurd,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;just clarifying a bit this scenario. This BL653 (nRF52833) exchange data with another device BL654 (nRF52840).&lt;br /&gt;Periodically, BL654 broadcasts a packet (4-bytes length on RF channel 22) containing the operation for this cycle.&lt;/p&gt;
&lt;p&gt;My goal is to have the application on BL653 device working as usual, but if BL654 sends a special value to BL653 I must stop all ESB tasks (esb_stop_rx()) and immediately call this sequence of commands so I can interface using the iOS/Android app Device Manager (Nordic) using my phone in order to upload a new image, test or confirm:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    os_mgmt_register_group();
	img_mgmt_register_group();
	smp_bt_register();
	bt_conn_cb_register(&amp;amp;conn_callbacks);
	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
		bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	}

	err = bt_enable(NULL);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}
	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But what I&amp;#39;ve found out is that in case I compile my project using prj.conf&amp;nbsp;CONFIG_MCUMGR_SMP_BT=y, even if bt_enable() was never called, every ESB packet that I collect leads to a crash.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m open to an alternative solution for this issue as well...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400405?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 14:14:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0523432d-995a-4c81-b037-72e8f929704c</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Vagner,&lt;/p&gt;
[quote user=""]&lt;p&gt;Application starts and automatically starts to listen for ESB packets(PRX).&lt;/p&gt;
&lt;p&gt;As soon as it gets a packet, &lt;/p&gt;[/quote]
&lt;p&gt;How do you send the SMP packets to the device?&lt;br /&gt;Aka: &amp;quot;What is the SMP Client?&amp;quot;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BL653 crashes when working with CONFIG_MCUMGR_SMP_BT &amp; CONFIG_ESB</title><link>https://devzone.nordicsemi.com/thread/400185?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2022 14:35:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1274e18-a22c-4f2f-91dc-52c6274d49f2</guid><dc:creator>Vagner Landskron</dc:creator><description>&lt;p&gt;Just adding some code to help.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main.c&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;sys/byteorder.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;soc.h&amp;gt;
#include &amp;lt;esb.h&amp;gt;
#include &amp;lt;sys_clock.h&amp;gt;
#include &amp;lt;drivers/clock_control.h&amp;gt;
#include &amp;lt;drivers/clock_control/nrf_clock_control.h&amp;gt;
#include &amp;lt;bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/hci.h&amp;gt;
#include &amp;lt;bluetooth/conn.h&amp;gt;
#include &amp;lt;bluetooth/uuid.h&amp;gt;
#include &amp;lt;bluetooth/gatt.h&amp;gt;

#include &amp;lt;bluetooth/services/lbs.h&amp;gt;

#include &amp;lt;settings/settings.h&amp;gt;

//#include &amp;lt;dk_buttons_and_leds.h&amp;gt;

//LOG_MODULE_REGISTER(esb_ptx, CONFIG_ESB_PTX_APP_LOG_LEVEL);

// ***************** //
// Time measurements //
// ***************** //
#if !defined(NRF_RTC1) &amp;amp;&amp;amp; defined(CONFIG_SOC_FAMILY_NRF)
#include &amp;lt;soc.h&amp;gt;
#endif
static double timestamp_get(void)
{
#ifdef CONFIG_SOC_FAMILY_NRF
	return NRF_RTC1-&amp;gt;COUNTER / 32768.0;
#else
	return k_cycle_get_32() / 32768.0;
#endif
}

static long long Timestamp_us(void)
{
#ifdef CONFIG_SOC_FAMILY_NRF
	return timestamp_get() * 1000000ll;
#else
	return timestamp_get() * 1000000ll;
#endif
}
// ***************** //

struct esb_config config = ESB_DEFAULT_CONFIG;
static struct esb_payload rx_payload;
static struct esb_payload tx_payload = ESB_CREATE_PAYLOAD(0,
	0x01, 0x00, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08);

#define _RADIO_SHORTS_COMMON                                                   \
	(RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk |         \
	 RADIO_SHORTS_ADDRESS_RSSISTART_Msk |                                  \
	 RADIO_SHORTS_DISABLED_RSSISTOP_Msk)


#define DEVICE_NAME             CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN         (sizeof(DEVICE_NAME) - 1)


#define RUN_STATUS_LED          DK_LED1
#define CON_STATUS_LED          DK_LED2
#define RUN_LED_BLINK_INTERVAL  1000

#define USER_LED                DK_LED3

//#define USER_BUTTON             DK_BTN1_MSK

static bool app_button_state;

static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};

static const struct bt_data sd[] = {
	//BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_LBS_VAL),
	// this string is the same as defined in the mcumgr default key (check it from the end to the start)
	// https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/blob/main/mcumgr-ble/src/main/java/io/runtime/mcumgr/ble/DefaultMcuMgrUuidConfig.java
	// 	public final static UUID SMP_SERVICE_UUID = UUID.fromString(&amp;quot;8D53DC1D-1DB7-4CD3-868B-8A527460AA84&amp;quot;);
	BT_DATA_BYTES(BT_DATA_UUID128_ALL,
		      0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
		      0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
};

static void connected(struct bt_conn *conn, uint8_t err)
{
	if (err) {
		printk(&amp;quot;Connection failed (err %u)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Connected\n&amp;quot;);

	//dk_set_led_on(CON_STATUS_LED);
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	printk(&amp;quot;Disconnected (reason %u)\n&amp;quot;, reason);

	//dk_set_led_off(CON_STATUS_LED);
}

#ifdef CONFIG_BT_LBS_SECURITY_ENABLED
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) {
		printk(&amp;quot;Security changed: %s level %u\n&amp;quot;, addr, level);
	} else {
		printk(&amp;quot;Security failed: %s level %u err %d\n&amp;quot;, addr, level,
			err);
	}
}
#endif

static struct bt_conn_cb conn_callbacks = {
	.connected        = connected,
	.disconnected     = disconnected,
#ifdef CONFIG_BT_LBS_SECURITY_ENABLED
	.security_changed = security_changed,
#endif
};

#if defined(CONFIG_BT_LBS_SECURITY_ENABLED)
static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	printk(&amp;quot;Passkey for %s: %06u\n&amp;quot;, addr, passkey);
}

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));

	printk(&amp;quot;Pairing cancelled: %s\n&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));

	printk(&amp;quot;Pairing completed: %s, bonded: %d\n&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));

	printk(&amp;quot;Pairing failed conn: %s, reason %d\n&amp;quot;, addr, reason);
}

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.passkey_display = auth_passkey_display,
	.cancel = auth_cancel,
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed
};
#else
static struct bt_conn_auth_cb conn_auth_callbacks;
#endif

static void app_led_cb(bool led_state)
{
	//dk_set_led(USER_LED, led_state);
}

static bool app_button_cb(void)
{
	return app_button_state;
}

static struct bt_lbs_cb lbs_callbacs = {
	.led_cb    = app_led_cb,
	.button_cb = app_button_cb,
};

// static void button_changed(uint32_t button_state, uint32_t has_changed)
// {
// 	if (has_changed &amp;amp; USER_BUTTON) {
// 		uint32_t user_button_state = button_state &amp;amp; USER_BUTTON;

// 		bt_lbs_send_button_state(user_button_state);
// 		app_button_state = user_button_state ? true : false;
// 	}
// }

static int init_button(void)
{
	int err = 0;

	//err = dk_buttons_init(button_changed);
	if (err) {
		printk(&amp;quot;Cannot init buttons (err: %d)\n&amp;quot;, err);
	}

	return err;
}

void event_handler(struct esb_evt const *event)
{
	printk(&amp;quot;packet\n\r&amp;quot;);
	switch (event-&amp;gt;evt_id) {
	case ESB_EVENT_TX_SUCCESS:
		break;
	case ESB_EVENT_TX_FAILED:
		break;
	case ESB_EVENT_RX_RECEIVED:
		while (esb_read_rx_payload(&amp;amp;rx_payload) == 0) 
		{			
			printk(&amp;quot;Got pkt %d %d\n\r&amp;quot;, (uint8_t)rx_payload.data[2], rx_payload.length);
		}
		break;
	}
}

int clocks_start(void)
{
	int err;
	int res;
	struct onoff_manager *clk_mgr;
	struct onoff_client clk_cli;

	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
	if (!clk_mgr) {
		//LOG_ERR(&amp;quot;Unable to get the Clock manager&amp;quot;);
		return -ENXIO;
	}

	sys_notify_init_spinwait(&amp;amp;clk_cli.notify);

	err = onoff_request(clk_mgr, &amp;amp;clk_cli);
	if (err &amp;lt; 0) {
		//LOG_ERR(&amp;quot;Clock request failed: %d&amp;quot;, err);
		return err;
	}

	do {
		err = sys_notify_fetch_result(&amp;amp;clk_cli.notify, &amp;amp;res);
		if (!err &amp;amp;&amp;amp; res) {
			//LOG_ERR(&amp;quot;Clock could not be started: %d&amp;quot;, res);
			return res;
		}
	} while (err);

	//LOG_DBG(&amp;quot;HF clock started&amp;quot;);
	return 0;
}


int esb_initialize(void)
{
	int err;
	/* These are arbitrary default addresses. In end user products
	 * different addresses should be used for each set of devices.
	 */
	uint8_t base_addr_0[4] = {0xE7, 0xE7, 0xE7, 0xE7};
	uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2};
	uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8};	

	config.protocol = ESB_PROTOCOL_ESB_DPL;
	config.retransmit_delay = 300;
	config.tx_output_power = ESB_TX_POWER_4DBM;
	config.retransmit_count = 0;
	config.bitrate = ESB_BITRATE_2MBPS_BLE;
	config.crc = ESB_CRC_16BIT;
	config.event_handler = event_handler;
	config.mode = ESB_MODE_PRX;
	config.selective_auto_ack = false;

	err = esb_init(&amp;amp;config);

	if (err) {
		return err;
	}

	err = esb_set_base_address_0(base_addr_0);
	if (err) {
		return err;
	}

	err = esb_set_base_address_1(base_addr_1);
	if (err) {
		return err;
	}

	err = esb_set_prefixes(addr_prefix, ARRAY_SIZE(addr_prefix));
	if (err) {
		return err;
	}

	err = esb_set_rf_channel(22);
	if (err) {
		return err;
	}

	esb_start_rx();

	return 0;
}


void main(void)
{
	int blink_status = 0;
	int err = 0;

	err = clocks_start();
	if (err) {
		return;
	}

	err = esb_initialize();
	if (err) {
		return;
	}
	for (;;) {
		//dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
	}

	printk(&amp;quot; Starting Bluetooth Peripheral LBS example\n&amp;quot;);

	//err = dk_leds_init();
	if (err) {
		printk(&amp;quot;LEDs init failed (err %d)\n&amp;quot;, err);
		return;
	}

	err = init_button();
	if (err) {
		printk(&amp;quot;Button init failed (err %d)\n&amp;quot;, err);
		return;
	}
	printk(&amp;quot;build time: &amp;quot; __DATE__ &amp;quot; &amp;quot; __TIME__ &amp;quot;\n&amp;quot;);
	os_mgmt_register_group();
	img_mgmt_register_group();
	smp_bt_register();
	bt_conn_cb_register(&amp;amp;conn_callbacks);
	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
		bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	}

	err = bt_enable(NULL);
	if (err) {
		printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Bluetooth initialized\n&amp;quot;);

	printk(&amp;quot;\n\rVagner was here\n\r&amp;quot;);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	//err = bt_lbs_init(&amp;amp;lbs_callbacs);
	if (err) {
		printk(&amp;quot;Failed to init LBS (err:%d)\n&amp;quot;, err);
		return;
	}

	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) {
		printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Advertising successfully started\n&amp;quot;);

	for (;;) {
		//dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;prj.conf&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_ESB=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_LOG=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;Zephyr CDC ACM sample&amp;quot;
CONFIG_MCUBOOT_SIGNATURE_KEY_FILE=&amp;quot;root-rsa-2048.pem&amp;quot;
CONFIG_BOOTLOADER_MCUBOOT=y
# Enable mcumgr.
CONFIG_MCUMGR=y
# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y

# Allow for large Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=252
CONFIG_BT_BUF_ACL_RX_SIZE=256

# Enable the Bluetooth (unauthenticated) and shell mcumgr transports.
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n

# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

CONFIG_MCUBOOT_IMAGE_VERSION=&amp;quot;0.0.1&amp;quot;
CONFIG_ESB=y
# 32kHz clock source 
#CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y 
#CONFIG_CLOCK_CONTROL_NRF_K32SRC_20PPM=y 
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you have another application that sends a packet on channel 22, this application will crash with the following error message:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
E: MPSL ASSERT: 112, 2236
E: ***** HARD FAULT *****
E:   Fault escalation (see below)
E: ARCH_EXCEPT with reason 3

E: r0/a1:  0x00000003  r1/a2:  0x0000000a  r2/a3:  0x00000000
E: r3/a4:  0x2000645e r12/ip:  0x00000000 r14/lr:  0x00028597
E:  xpsr:  0x61000011
E: Faulting instruction address (r15/pc): 0x000285a2
E: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Fault during interrupt handling

E: Current thread: 0x20001d58 (idle 00)
E: Resetting system&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>