This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pc-ble-driver-py missing high-rate notifications

Hello,

whilst implementing my embedded device software, I'm developing a tool running on a Windows laptop to validate my work.

The idea is to use pc-ble-driver-py python bindings to implement simple interactions with the device over BLE using the services exposed.

The current setup is:

  • pc-ble-driver-py 0.15.0 (latest)
  • nRF52840 Dongle (PCA10059) running connectivity FW 4.1.2 SD API v5 (latest supported)

Most of the functionalities seem to be working fine.

But when I try to collect notifications from a certain rate on, looks like the system is not able to "catch-up".

To give some context - from the embedded device, I'm polling data and queuing notifications on certain char every 10ms. The connection interval is set 15ms.

The moment I enable the notifications on this char from Client side(after the wanted connection intervals are updated), I start receiving as a return value from sd_ble_gatts_hvx the error code NRF_ERROR_RESOURCES on the server side - it's not always the case, but very often, at least 10/20 times per second.

The only explanation I can give to this is that the Central (i.e. the python script) is not meeting all the connection events at fixed interval (15ms), and this way the notification queue on the Server is increasing till its limit.

I tested this scenario with different platforms (Windows UWP, Android) and this is the only case I'm seeing this behaviour.

What I find rather odd is that using exactly the same dongle (with same FW), but from the nRF Connect Desktop App GUI this is NOT happening - I can subscribe to the notifications and getting them at the rate I expect.

Adding a couple of graph to make things clearer:

Notifications Intervals (ms) from nRF Connect Desktop:

Notifications Intervals (ms) from pc-ble-driver-py:

It's clear that in the first case, two notifications are sometimes very close as the queuing rate is higher than the connection interval (i.e you get more than one notification for conn interval).

Instead in the second case, interval is never below 15ms, meaning that for sure notifications are lost (I imagine due to missed connection events...).

I tried to do the same but changing the dongle with a nRF52-DK. The result is that in this case the system crashes and disconnects after a couple of seconds from the enabling of notifications with this log:

2020-10-20 15:17:21,194 [21092/LogThread] h5_decode error, code: 0x802c, H5 error count: 1. raw packet: c0 f0 0e 02 00 02 39 00 00 00 00 00 00 00 1c 00 01 12 00 f7 03 71 03 d0 02 de 02 fe 02 0e c0 

As a quick workaround, If I try to queue notifications every 20ms (or anything above the connection interval), I don't see any problem and the system works flawlessly.

Can you help me understanding what's going on?

I'm evaluating this python libraries for the system testing framework of our devices - and of course we'll need to evaluate also the high-rate notifications.

I think reproducing the issue would be quite trivial, but maybe there is something I'm missing that can solve this straightaway.

Thanks!

  • Hello,


    Sorry for my late reply.

    davege said:
    apparently we've been writing simultaneously

     Yes, it appears we did! Slight smile

    davege said:
    Exactly, that's the mystery to solve!

    Indeed it is, this is most strange. I would assume it might stem from the radio being busy with other tasks ( and thus not following up on the more data prompt ), but something seems amiss in this case.

    davege said:

    It is all very standard, as I just slightly modified the example code for the heart rate that I've found in the repository.

    At HW/FW level current setup is:

    • pc-ble-driver-py 0.15.0 (latest)
    • nRF52840 Dongle (PCA10059) running connectivity FW 4.1.2 SD API v5 (latest supported)

    The python script is just subscribing for notifications (on the selected custom service/char in my case, but I believe it could be whatever, even Nordic UART) and printing that line you've seen in the log with the data received.

    I believe there's no scanning active after the connection to the peripheral.

    Thank you for specifying! This is very helpful for me to know.

    davege said:
    Now wondering if this will keep scanning active even after I receive on_gap_evt_connected callback...
    davege said:
    I'm calling this API:

    What is the scan timeout parameter that you pass to your scan_start? Is it possible this set to indefinite?
    Looking through the unmodified example code it  seems that the scanning is not stopped on CONNECTED event, but is rather set to time out.

    I have reached out to the developers of the pc-ble-driver-py to ask if they have ever heard of similar behavior. I will get back to you as soon as they reply.
    I will create a small example to try and reproduce this on my end, using the connection parameters and setup you described.

    Best regards,
    Karl

  • Hi,

    great to know you are setting up something quick to reproduce the issue.

    What is the scan timeout parameter that you pass to your scan_start? Is it possible this set to indefinite?
         
    This is the full call with the params:
    scan_duration = 5
    params = BLEGapScanParams(interval_ms=200, window_ms=150, timeout_s=scan_duration)
    self.adapter.driver.ble_gap_scan_start(scan_params=params)
    I'm not aware about a way to scan forever, but usually with nRF5 SDK on the embedded side, this happens when setting the duration to 0.
    One of the problem I have with this python bindings is that they are not documented, so sometimes I'm just guessing I'm doing the right thing given the familiarity I have with the rest of the Nordic offering.
    Hopefully with your help I'll know if I'm doing something wrong Slight smile
    Thanks,
    D
  • Hi ,

    is there any progress on this?

    Let me know if I may help or if some reason it was not possible to reproduce the problem on your end.

    Thanks,

    D

  • Hello again Davege,

    I am terribly sorry for the very long delay in communications from my side on this.

    I have allocated time today to work through this issue. I will update you by the end of the day at the latest.
    I am again terribly sorry for the long delay on this issue.

    Best regards,
    Karl

  • Hello Davege,

    Thank you for your patience.
    I have today successfully replicated the issue with the setup you described on my end.
    I have allocated time tomorrow to keep working on resolving the issue.

    Best regards,
    Karl

Related