<?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>Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117029/achieving-stable-ble-notifications-with-nrf52833</link><description>Hi, 
 I’m currently developing an application for the nRF52833 that collects sensor data via SPI and sends it out over BLE using notifications. My primary goal is to achieve a stable, periodic notification interval. Specifically, I want the time between</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Dec 2024 09:52:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117029/achieving-stable-ble-notifications-with-nrf52833" /><item><title>RE: Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/thread/514452?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2024 09:52:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c14556ae-2546-4129-88cf-254e0e341632</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t prevent packet loss, as that will happen, and you will have retransmissions. Also, from the Bluetooth Low Energy specification, once a packet is sent, but not Acked, it shall be retransmitted until it is acked *&lt;/p&gt;
&lt;p&gt;*There is one exception, which is a fairly new feature were you can use isochrounous channels, where you can set a given amount of retransmissions. This is&amp;nbsp;typically&amp;nbsp;intended for Bluetooth LE Audio, but I guess it is possible to use it to discard packets that are not acked in a non-audio application as well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Another option is to use something called periodic advertising and scanning. Here, the devices will not be connected, but one will advertise periodically (without the added 0-10ms of random delay), and the scanner can use this to sync up with the advertiser. Here you will not have a two way communication channel, though.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you want to investigate any of these two, you can check out:&lt;/p&gt;
&lt;p&gt;ncs\zephyr\samples\bluetooth\&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/bluetooth/iso_peripheral/README.html#ble_peripheral_iso"&gt;iso_peripheral &lt;/a&gt;and &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/bluetooth/iso_central/README.html#ble_central_iso"&gt;iso_central &lt;/a&gt;(or iso_broadcast and iso_receive. I haven&amp;#39;t tried these, but I guess this is how they work).&lt;/p&gt;
&lt;p&gt;ncs\zephyr\samples\bluetooth\&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/bluetooth/periodic_adv/README.html#ble_periodic_adv"&gt;periodic_adv&lt;/a&gt; and &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/bluetooth/periodic_sync/README.html#ble_periodic_adv_sync"&gt;periodic_sync&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But with a standard BLE link, what you have now is as good as it gets.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/thread/514165?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2024 08:16:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:202a744e-784e-4a20-8fe9-7fe905715f64</guid><dc:creator>Floppey</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I implemented an example application for testing using the radio notifications. It looks a lot better now although there is still one problem remaining.&amp;nbsp;In the appended image i set the connection interval to 11ms. The packets on average also arrive at that time however there a still a few exceptions. The spikes can be explained by one connection interval being missed and then in the next one two packets are sent in one connection interval. Do you have any suggestions on how i could fix that. I already tried increasing the preparation time in the radio notification.&amp;nbsp; I appended the code and the image:&lt;br /&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/3884.timings.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;zephyr/kernel.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;zephyr/bluetooth/hci_vs.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/controller.h&amp;gt;
#include &amp;lt;zephyr/sys_clock.h&amp;gt;
#include &amp;lt;bluetooth/radio_notification_cb.h&amp;gt;




static void radio_notification_conn_prepare_cb(struct bt_conn *conn)
{
    int test_val = 10;
    bt_gatt_notify(NULL, &amp;amp;ess.attrs[1], &amp;amp;test_val, sizeof(test_val));
}

void main(void)
{
    bleSetup();
    // Setup radio notification callback
    static const struct bt_radio_notification_conn_cb radio_callbacks = {
        .prepare = radio_notification_conn_prepare_cb,
    };

    int err = bt_radio_notification_conn_cb_register(
        &amp;amp;radio_callbacks,
        BT_RADIO_NOTIFICATION_CONN_CB_PREPARE_DISTANCE_US_RECOMMENDED
    );
    if (err) {
        printk(&amp;quot;Failed registering radio notification callback (err %d)\n&amp;quot;, err);
        return;
    }

    while (true) {
        if (isConnected()) {
            printk(&amp;quot;Connection established.\n&amp;quot;);
            break;
        }
        k_sleep(K_MSEC(100));
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/thread/514042?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 13:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bce80679-283d-404b-b861-5f6dba1af155</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry, I meant to link to the radio notification in the previous link, but I forgot. The radio notification is found under ncs\nrf\samples\bluetooth\&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/bluetooth/radio_notification_cb/README.html"&gt;radio_notification&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I am not sure about the sample that you linked to. On one hand, it looks like you can separate on multiple links, which you can&amp;#39;t do in the radio_notification sample. However, I am not sure whether the events in the Event Trigger are triggered before or after the actual connection event, and whether you can control how long before/after it will trigger.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the radio_notification sample you can adjust the time between your upcoming event and the connection event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/thread/513913?ContentTypeID=1</link><pubDate>Sat, 07 Dec 2024 09:15:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dc79939-2b0b-40c8-bc7a-04daac4279a3</guid><dc:creator>Floppey</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply!&lt;/p&gt;
&lt;p&gt;The Graph also makes sense to me. The questions is more how to get a stable frequency. I will take a look at the radio notifications. I guess i would then set the connection interval time to my desired&amp;nbsp;frequency and then i will get some sort of callback in the radio notifications at every connection event where i can then queue it up inside? Do you have any examples for getting started (I&amp;#39;m using the nrF connect SDK).&amp;nbsp; Also does anything change for the central device when using radio notifications?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also found this Event Trigger example Do you think this would be an option in my case or would the radio&amp;nbsp;notifications suit better here?&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/bluetooth/event_trigger/README.html"&gt;docs.nordicsemi.com/.../README.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Best&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Achieving Stable BLE Notifications with nRF52833</title><link>https://devzone.nordicsemi.com/thread/513864?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2024 14:41:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebb31703-aa94-4ae4-b0ee-e38686f74fbe</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your connection interval?&lt;/p&gt;
&lt;p&gt;What I see from your graph can probably be explained. Most of the time it is either 14 or 22ms. Probably depending on how long the actual transmission took. I guess that some times the packet (the notification) was queued directly before the connection event (the event that occurs every connection interval), so just a bit too late to be added to the upcoming transmission. In those cases, you will probably get two packets queued for the next connection event. This will result in that the next transmission will spend a bit more time on air, which is probably why you see some increased time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also see that many of your samples (about every other one) is very close to 0. This probably means that these are two notifications sent on the same connection event. (The previous notification and the current notification). Since you will receive them in your app chronologically, the time between the previous and the current will be very short. Almost directly after.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I guess we need some more details. How long is the packet that you are usually sending? How often do you send it? And what is your connection interval?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;There is something called &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.4.2/page/nrfxlib/mpsl/doc/radio_notification.html"&gt;radio notifications&lt;/a&gt;. Using this, you will be notified a given amount of time before the radio will be used. You can use this to sample your data, and queue it up directly before the connection event. You probably need to play around with the timing to find the sweetspot so that you will have time to sample and queue the packet long enough before the connection event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>