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!

  • Hi ,

    thanks for this.

    Unfortunately neither myself or my team at the moment has the capacity to move the testing framework implementation to pc-ble-driver, which I used in the past and I can confirm it works great.

    So hopefully I'll just wait here to understand if there's any movement.

    Do you believe that marking this ticket as private can be useful to push things a little bit?

    My company is using Nordic chips for different products, so we are already in contact.

    Thanks,

    D

  • Hello again Davege,

    davege said:

    Unfortunately neither myself or my team at the moment has the capacity to move the testing framework implementation to pc-ble-driver, which I used in the past and I can confirm it works great.

    So hopefully I'll just wait here to understand if there's any movement.

    I totally understand, no worries at all. We will get to the bottom of this.

    This might seem trivial, but could you add the following modification to your code, to see if it allows you to receive multiple notification packets per connection event?
    If you are using the heart_rate_collector example, this code block should be inserted in the collector class's open function, in the NRF52 section.
    It should look like this:

        def open(self):
            self.adapter.driver.open()
            if config.__conn_ic_id__.upper() == "NRF51":
                self.adapter.driver.ble_enable(
                    BLEEnableParams(
                        vs_uuid_count=1,
                        service_changed=0,
                        periph_conn_count=0,
                        central_conn_count=1,
                        central_sec_count=0,
                    )
                )
            elif config.__conn_ic_id__.upper() == "NRF52":
                gatt_cfg = BLEConfigConnGatt()
                gatt_cfg.att_mtu = self.adapter.default_mtu
                gatt_cfg.tag = CFG_TAG
                self.adapter.driver.ble_cfg_set(BLEConfig.conn_gatt, gatt_cfg)
    
                conn_cfg = BLEConfigConnGap()
                conn_cfg.conn_count = 1
                conn_cfg.event_length = 320
                self.adapter.driver.ble_cfg_set(BLEConfig.conn_gap, conn_cfg)
    
                self.adapter.driver.ble_enable()

    You will also need to add the BLEConfigConnGap method to the list of globals, imported from driver, which should then look like this:
        global config, BLEDriver, BLEAdvData, BLEEvtID, BLEAdapter, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID, BLEConfigCommon, BLEConfig, BLEConfigConnGatt, BLEConfigConnGap, BLEGapScanParams
        from pc_ble_driver_py import config
    
        config.__conn_ic_id__ = conn_ic_id
        # noinspection PyUnresolvedReferences
        from pc_ble_driver_py.ble_driver import (
            BLEDriver,
            BLEAdvData,
            BLEEvtID,
            BLEEnableParams,
            BLEGapTimeoutSrc,
            BLEUUID,
            BLEGapScanParams,
            BLEConfigCommon,
            BLEConfig,
            BLEConfigConnGatt,
            BLEConfigConnGap,
        )



    The only difference here is that the default event_length parameter is not used, instead, the maximum event_length for the given connection interval is set explicitly.
    If you could test this with your own test-script and let me know if you succeed in getting multiple packets per event, that would be great.

    If it does not enable you to send multiple notifications per connection event, could you provide a trace of the test, with the code above added?

    I will continue to look into this to find the required event_length analytically - instead of just setting it to the maximum value.

    davege said:
    Do you believe that marking this ticket as private can be useful to push things a little bit?

    No, this will not affect the internal requests priority - since the only difference between private tickets and public ones is who may view it.
    Private tickets is of course only viewable by the tickets creator and the Technical Support staff here at Nordic.

    Looking forward to hearing the results of your test!

    Best regards,
    Karl

  • Hi ,

    I tried adding your changes but see no effects whatsoever.

    Did something change with the setup you have?

    I believe that if you find any kind of solution, that will work also on your end (using Nordic UART characteristic or similar).

    I'm a bit frustrated as now I'm at the point where it would be extremely useful to get the notifications running.

    Do you know if nRF Connect Desktop is using pc-ble-driver dll underneath for the connection to the dongle?
    If this is the case, it may be easy to spot the change in the way the API are invoked on two sides.

    Thanks,

    D

  • Hello Davege,

    davege said:
    I'm a bit frustrated as now I'm at the point where it would be extremely useful to get the notifications running.

    Yes, for course. I am sorry to hear that.

    davege said:

    I tried adding your changes but see no effects whatsoever.

    Did something change with the setup you have?

    Could you send a trace of the communication when you test it with the changes?
    With the changes mentioned in my last comment I am seeing multiple notifications per connection event.

    davege said:
    I believe that if you find any kind of solution, that will work also on your end (using Nordic UART characteristic or similar).

    Using the code from my last comment I am seeing multiple notification per connection event on my end.
    If it would be easier for you, I could send you the .py file and .hex file for the peripheral, for you to test this?
    If you are not seeing multiple notifications per event it would be really useful to see a sniffer trace.

    Best regards,
    Karl

  • Hi,

    it would be great to have those, if I can just use a nRF52-DK as a peripheral it is even better.

    I can first test and then providing a sniffing trace to you.

    Thanks

    D

Related