<?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>Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103782/restarting-high-duty-cycle-direct-advertising</link><description>I would like for the high duty cycle direct advertising to restart immediately after the ~1.2s timeout. 
 [I&amp;#39;m using Zephyr. I&amp;#39;m also really new to programming these devices] 
 I&amp;#39;ve tried to modify the direct_adv example (to use high duty cycle &amp;amp; restart</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Oct 2024 01:03:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103782/restarting-high-duty-cycle-direct-advertising" /><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/504599?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 01:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0a7f7f6-2ca0-4d6b-ade6-ba23039c6eec</guid><dc:creator>aacosta</dc:creator><description>&lt;p&gt;Actually, it&amp;#39;s racy. As I suspected the advertising work sometimes happens before the connection is deallocated.&lt;br /&gt;&lt;br /&gt;Using the `recycled` callback (which I just found about) is much nicer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/504381?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 13:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76236fda-4253-4cbf-958f-028c53b934f1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I don&amp;#39;t see any issue with adding the advertising start&amp;nbsp;work from the disconnected callback, if that&amp;#39;s what you&amp;#39;re asking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/504348?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 11:59:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c607807-a182-47b7-baac-6f1b73270d05</guid><dc:creator>aacosta</dc:creator><description>&lt;p&gt;Whenever there is a disconnection in the peripheral snd never prompted by me. I guess that online happens on connection errors?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/504317?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 09:21:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee5f2179-f758-42bf-8282-3219c9b2a97e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Are you attempting to start your directed advertiser when there is a connection error? In that case, the workqueue item&amp;nbsp;should be processed after the connection object has been released.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/504258?ContentTypeID=1</link><pubDate>Sun, 29 Sep 2024 10:56:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64b5ce2e-08ac-40b9-9aa9-8244cb4bb068</guid><dc:creator>aacosta</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&amp;nbsp;I run into the same problem and your work queue solution works great! Thanks!&lt;br /&gt;&lt;br /&gt;I have a question though. Are we sure that the advertising work will never run concurrently with the connection finalization? Wouldn&amp;#39;t this be a problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/446842?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2023 11:30:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3685b1c-bb88-45d8-a05c-8d0adedbf3a5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I&amp;#39;m Happy to help! I verified that it worked on my end by using the nRF connect app on Android with &amp;#39;autoconnect&amp;#39; enabled (Note: it won&amp;#39;t work on iOS as it doesn&amp;#39;t support directed advertisement). With&amp;nbsp;&amp;#39;autoconnect&amp;#39; enabled, the phone should try to re-connect when it receives directed advertisement packets from the device after the connection has been lost.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here are the steps I used to test this:&lt;/p&gt;
&lt;p&gt;1. Connect &amp;amp; bond with the device from the nRF connect&lt;/p&gt;
&lt;p&gt;2. Enable autoconnect by pressing the 3 dotted button in the top right corner and select &amp;quot;autoconnect&amp;quot;&lt;/p&gt;
&lt;p&gt;3. Reset the peripheral to force a disconnect&lt;/p&gt;
&lt;p&gt;4. Observe from the app that the connection state transitions from &amp;#39;connected&amp;#39; to &amp;#39;disconnected&amp;#39; and then back to &amp;#39;connected&amp;#39;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Debug log showing reconnect on the first advertisment after reset&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build 28a3fca7da5c ***
[00:00:00.006,561] &amp;lt;inf&amp;gt; fs_nvs: nvs_mount: 6 Sectors of 4096 bytes
[00:00:00.006,561] &amp;lt;inf&amp;gt; fs_nvs: nvs_mount: alloc wra: 0, fb8
[00:00:00.006,591] &amp;lt;inf&amp;gt; fs_nvs: nvs_mount: data wra: 0, b4
[00:00:00.006,713] &amp;lt;inf&amp;gt; bt_sdc_hci_driver: hci_driver_open: SoftDevice Controller build revision: 
                                            e0 7e 2e c1 5e 05 85 23  46 15 dc fa 8e 29 7d 70 |.~..^..# F....)}p
                                            10 93 a5 fc                                      |....             
[00:00:00.009,521] &amp;lt;inf&amp;gt; bt_hci_core: hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.009,552] &amp;lt;inf&amp;gt; bt_hci_core: hci_vs_init: HW Variant: nRF52x (0x0002)
[00:00:00.009,582] &amp;lt;inf&amp;gt; bt_hci_core: hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 224.11902 Build 2231721665
[00:00:00.009,979] &amp;lt;inf&amp;gt; bt_hci_core: bt_init: No ID address. App must call settings_load()
Bluetooth initialized
[00:00:00.010,803] &amp;lt;inf&amp;gt; bt_hci_core: bt_dev_show_info: Identity: D8:2A:C8:17:11:5C (random)
[00:00:00.010,833] &amp;lt;inf&amp;gt; bt_hci_core: bt_dev_show_info: HCI: version 5.4 (0x0d) revision 0x1077, manufacturer 0x0059
[00:00:00.010,894] &amp;lt;inf&amp;gt; bt_hci_core: bt_dev_show_info: LMP: version 5.4 (0x0d) subver 0x1077
Direct advertising to 6C:DD:BC:29:D8:8E (public)
Advertising successfully started
Connected&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1695209280455v3.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1695209313368v5.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I should also&amp;nbsp;add that directed advertisements will not be &amp;quot;Scanner&amp;quot; view when scanning for new devices.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/446822?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2023 10:11:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19241bdf-cacf-4e09-b0cf-89c7783fa50b</guid><dc:creator>lionfish</dc:creator><description>&lt;p&gt;Thank you for writing all that code for me. It&amp;#39;s really appreciated. That appears to be working I guess... but I can&amp;#39;t actually tell. I&amp;#39;ve tried bonding with it via the Nordic nRF connect app, but never see high-duty packets? I also tried looking for them via a separate system running the DA14531 SoC, but I couldn&amp;#39;t see them there either (I also tried manually setting the target address equal to my phone and the DA14531&amp;#39;s address).&lt;/p&gt;
&lt;p&gt;Is there a way of detecting these packets? I assume I can&amp;#39;t see them as I&amp;#39;ve some how messed up the address or something, and direct adv packets that aren&amp;#39;t addressed to a device get ignored?&lt;/p&gt;
&lt;p&gt;Thanks again for your help.&lt;/p&gt;
&lt;p&gt;E.g. Modifying the target address...&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#9cdcfe;"&gt;err&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;bt_addr_le_from_str&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;C0:56:78:9A:BC:DE&amp;quot;&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;, &lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;random&amp;quot;&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;, &lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;bond_addr&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#c586c0;"&gt;if&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; (&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;err&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;printk&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;Setting address failed (err &lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;%d&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;)&lt;/span&gt;&lt;span style="color:#d7ba7d;"&gt;\n&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;, &lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;err&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;"&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting High Duty Cycle Direct Advertising</title><link>https://devzone.nordicsemi.com/thread/446210?ContentTypeID=1</link><pubDate>Fri, 15 Sep 2023 09:19:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e24e9342-cc3a-489b-a444-09c9cabe176c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The program needs to exit the connection callback before attempting to re-start the advertisement. I think the easiest way to do this is to create a workqueue item to start advertising, then offload this task to the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.2/zephyr/kernel/services/threads/workqueue.html#workqueue-threads"&gt;workqueue&lt;/a&gt;&amp;nbsp;thread from the connected callback.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Define&amp;nbsp;workqueue item&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void advertising_start(struct k_work *work);
static K_WORK_DEFINE(start_advertising_worker, advertising_start);&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;advertising_start() implementation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void advertising_start(struct k_work *work)
{
	int err;
	char addr[BT_ADDR_LE_STR_LEN];
	
	bt_addr_le_copy(&amp;amp;bond_addr, BT_ADDR_LE_NONE);
	bt_foreach_bond(BT_ID_DEFAULT, copy_last_bonded_addr, NULL);

	/* Address is equal to BT_ADDR_LE_NONE if compare returns 0.
	 * This means there is no bond yet.
	 */
	if (bt_addr_le_cmp(&amp;amp;bond_addr, BT_ADDR_LE_NONE) != 0) {
		bt_addr_le_to_str(&amp;amp;bond_addr, addr, sizeof(addr));
		printk(&amp;quot;Direct advertising to %s\n&amp;quot;, addr);

		//adv_param = *BT_LE_ADV_CONN_DIR_LOW_DUTY(&amp;amp;bond_addr);
		adv_param = *BT_LE_ADV_CONN_DIR(&amp;amp;bond_addr);
		adv_param.options |= BT_LE_ADV_OPT_DIR_ADDR_RPA;
		err = bt_le_adv_start(&amp;amp;adv_param, NULL, 0, NULL, 0);
	} else {
		err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);
	}

	if (err) {
		printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;Advertising successfully started\n&amp;quot;);
	}	
}&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Submit &amp;quot;advertising start task&amp;quot; to the workqueue from the connected callback&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void connected(struct bt_conn *conn, uint8_t err)
{
	if (err == BT_HCI_ERR_ADV_TIMEOUT) {
		printk(&amp;quot;Trying to re-start directed adv.\n&amp;quot;);
		k_work_submit(&amp;amp;start_advertising_worker);
	}
	else if (err) {
		printk(&amp;quot;Connection failed (err 0x%02x)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;Connected\n&amp;quot;);
	}
}&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I tried this with the&amp;nbsp;&lt;span&gt;direct_adv example, and it seemed to work as expected. Here&amp;#39;s the&amp;nbsp;full main.c with at the changes I made:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2022 Michal Morsisko
 * Copyright (c) 2015-2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#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;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/sys/byteorder.h&amp;gt;
#include &amp;lt;zephyr/sys/reboot.h&amp;gt;
#include &amp;lt;zephyr/settings/settings.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;



/* Custom Service Variables */
#define BT_UUID_CUSTOM_SERVICE_VAL \
	BT_UUID_128_ENCODE(0x12345678, 0x1234, 0x5678, 0x1234, 0x56789abcdef0)

static struct bt_uuid_128 primary_service_uuid = BT_UUID_INIT_128(
	BT_UUID_CUSTOM_SERVICE_VAL);

static struct bt_uuid_128 read_characteristic_uuid = BT_UUID_INIT_128(
	BT_UUID_128_ENCODE(0x12345678, 0x1234, 0x5678, 0x1234, 0x56789abcdef1));

static struct bt_uuid_128 write_characteristic_uuid = BT_UUID_INIT_128(
	BT_UUID_128_ENCODE(0x12345678, 0x1234, 0x5678, 0x1234, 0x56789abcdef2));

static int signed_value;
static struct bt_le_adv_param adv_param;
static bt_addr_le_t bond_addr;


static void advertising_start(struct k_work *work);

static K_WORK_DEFINE(start_advertising_worker, advertising_start);

static ssize_t read_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr,
			   void *buf, uint16_t len, uint16_t offset)
{
	int *value = &amp;amp;signed_value;

	return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
				 sizeof(signed_value));
}

static ssize_t write_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr,
			    const void *buf, uint16_t len, uint16_t offset,
			    uint8_t flags)
{
	int *value = &amp;amp;signed_value;

	if (offset + len &amp;gt; sizeof(signed_value)) {
		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
	}

	memcpy(value + offset, buf, len);

	return len;
}

/* Vendor Primary Service Declaration */
BT_GATT_SERVICE_DEFINE(primary_service,
	BT_GATT_PRIMARY_SERVICE(&amp;amp;primary_service_uuid),
	BT_GATT_CHARACTERISTIC(&amp;amp;read_characteristic_uuid.uuid,
			       BT_GATT_CHRC_READ,
			       BT_GATT_PERM_READ,
			       read_signed, NULL, NULL),
	BT_GATT_CHARACTERISTIC(&amp;amp;write_characteristic_uuid.uuid,
			       BT_GATT_CHRC_WRITE,
			       BT_GATT_PERM_WRITE_ENCRYPT,
			       NULL, write_signed, NULL),
);

static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_CUSTOM_SERVICE_VAL),
};

static void connected(struct bt_conn *conn, uint8_t err)
{
	if (err == BT_HCI_ERR_ADV_TIMEOUT) {
		printk(&amp;quot;Trying to re-start directed adv.\n&amp;quot;);
		k_work_submit(&amp;amp;start_advertising_worker);
	}
	else if (err) {
		printk(&amp;quot;Connection failed (err 0x%02x)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;Connected\n&amp;quot;);
	}
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	printk(&amp;quot;Disconnected (reason 0x%02x)\n&amp;quot;, reason);
}

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

static void copy_last_bonded_addr(const struct bt_bond_info *info, void *data)
{
	bt_addr_le_copy(&amp;amp;bond_addr, &amp;amp;info-&amp;gt;addr);
}

static void advertising_start(struct k_work *work)
{
	int err;
	char addr[BT_ADDR_LE_STR_LEN];
	
	bt_addr_le_copy(&amp;amp;bond_addr, BT_ADDR_LE_NONE);
	bt_foreach_bond(BT_ID_DEFAULT, copy_last_bonded_addr, NULL);

	/* Address is equal to BT_ADDR_LE_NONE if compare returns 0.
	 * This means there is no bond yet.
	 */
	if (bt_addr_le_cmp(&amp;amp;bond_addr, BT_ADDR_LE_NONE) != 0) {
		bt_addr_le_to_str(&amp;amp;bond_addr, addr, sizeof(addr));
		printk(&amp;quot;Direct advertising to %s\n&amp;quot;, addr);

		//adv_param = *BT_LE_ADV_CONN_DIR_LOW_DUTY(&amp;amp;bond_addr);
		adv_param = *BT_LE_ADV_CONN_DIR(&amp;amp;bond_addr);
		adv_param.options |= BT_LE_ADV_OPT_DIR_ADDR_RPA;
		err = bt_le_adv_start(&amp;amp;adv_param, NULL, 0, NULL, 0);
	} else {
		err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);
	}

	if (err) {
		printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;Advertising successfully started\n&amp;quot;);
	}	
}

static void bt_ready(void)
{

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

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

void pairing_complete(struct bt_conn *conn, bool bonded)
{
	printk(&amp;quot;Pairing completed. Rebooting in 5 seconds...\n&amp;quot;);

	k_sleep(K_SECONDS(5));
	sys_reboot(SYS_REBOOT_WARM);
}

static struct bt_conn_auth_info_cb bt_conn_auth_info = {
	.pairing_complete = pairing_complete
};

int main(void)
{
	int err;

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

	bt_ready();
	bt_conn_auth_info_cb_register(&amp;amp;bt_conn_auth_info);

	k_work_submit(&amp;amp;start_advertising_worker);

	while (1) {
		k_sleep(K_FOREVER);
	}
	return 0;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In my code, I didn&amp;#39;t implement this, but you would probably want to limit the number of times you restart the advertisement to prevent battery drainage. Additionally, as you might be aware, the high-duty directed advertisement should only run for 1.28 seconds according to the spec.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>