<?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>Way to enumerate advertisements</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119289/way-to-enumerate-advertisements</link><description>Hello, Our peripheral device (52840) broadcasts BLE extended advertisements with 1 Hz frequency. Each advertisement has a &amp;quot;manufacturer data&amp;quot; with sensor readings. To estimate data loss I&amp;#39;d like to attach to each advertisement a sequential ID - to see</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Feb 2025 13:26:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119289/way-to-enumerate-advertisements" /><item><title>RE: Way to enumerate advertisements</title><link>https://devzone.nordicsemi.com/thread/524609?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2025 13:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a706b4d-37e1-4b7d-bfe6-7ebb5d4b9305</guid><dc:creator>Jakob Ruhe</dc:creator><description>&lt;p&gt;I guess you should be able to use the Bluetooth Event Trigger API for this. The example&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.9.0/page/nrf/samples/bluetooth/event_trigger/README.html"&gt;Bluetooth: Event Trigger&lt;/a&gt;&amp;nbsp;is setting up triggers on Connection Events. If you change the function `setup_connection_event_trigger()` to something like the following code snippet, you should be able to trigger at Advertising Events instead.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int setup_advertisement_event_trigger(struct bt_le_ext_adv *adv_set, bool enable)
{
	int err;
	sdc_hci_cmd_vs_set_event_start_task_t cmd_params = {};
	uint8_t adv_handle;

	err = bt_hci_get_adv_handle(adv_set, &amp;amp;adv_handle);
	if (err) {
		printk(&amp;quot;Failed obtaining handle: %s (%d)\n&amp;quot;, strerror(-err), err);
		return err;
	}

	cmd_params.handle_type = SDC_HCI_VS_SET_EVENT_START_TASK_HANDLE_TYPE_ADV;
	cmd_params.handle = adv_handle;

	if (enable) {
		cmd_params.task_address = nrf_egu_task_address_get(NRF_EGU, NRF_EGU_TASK_TRIGGER0);

		IRQ_DIRECT_CONNECT(DT_IRQN(EGU_NODE), 5, egu_handler, 0);
		nrf_egu_int_enable(NRF_EGU, NRF_EGU_INT_TRIGGERED0);
		NVIC_EnableIRQ(DT_IRQN(EGU_NODE));
	} else {
		cmd_params.task_address = 0;
		nrf_egu_int_disable(NRF_EGU, NRF_EGU_INT_TRIGGERED0);
		NVIC_DisableIRQ(DT_IRQN(EGU_NODE));
	}

	err = hci_vs_sdc_set_event_start_task(&amp;amp;cmd_params);
	if (err) {
		printk(&amp;quot;Error for command hci_vs_sdc_set_event_start_task(): %s (%d)\n&amp;quot;,
		       strerror(-err), err);
		return err;
	}

	printk(&amp;quot;Successfully configured event trigger\n&amp;quot;);

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Call that function after you have created your Extended Adverisement Set. Create a worker callback function that updates your Advertisement Data by using the function `bt_le_ext_adv_set_data()` every time the event is triggered.&lt;/p&gt;
&lt;p&gt;Note that Extended Advertisements are&amp;nbsp;sent out with a small random delay added to your chosen interval (1 second). If that is a problem you may want to have a look at Periodic Advertising (Bluetooth 5.0). Also Periodic Advertising with Responses (PAwR, Bluetooth 5.4) is a very powerful feature for connecting multiple sensors to one access point.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>