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

pc-ble-driver connection problem

Hello, I am developing with pc-ble-driver using python. I noticed that the Bluetooth connection becomes disconnected when I alt tab out of the gui I made. Is there a solution for this and why is this happening. When this happens nothing appears on the command prompt like ble_disconnect message. When I try to reuse the bluetooth feature like to advertise I get Error code: 12289 from the driver.

I think the the nrf52 board I am using as a central device is not working correctly? Is the softdevice provided for these not enough in order to make a project? and if not how do I need to modify the code.

I am using nrf52 chip and I tested for both 115K and 1M softdevice. I using a pyqt as my gui api.

Thank you ahead,

  • It sounds like there is an issue with your GUI. Have you tried running the command line examples? The error code you get (12289 - 0x3001) is BLE_ERROR_NOT_ENABLED, which means that sd_ble_enable has not been called.

  • Thank you for looking into my problem. I would say that something is wrong with my gui if I get this problem right away but this problem also happens for long runs. So I would get the same symptoms when I run the driver for a long time ( so i will get disconnected with all my connected peripheral ble devices ~40 minutes into running my program). Do you have any comments on this?

  • Are you using the nRF52 DK with the pc-ble-driver or another board? Have you tried doing some debugging to see where in your program the error occurs? Can you try the example provided with the pc-ble-driver-py to see if this has similar problems?

  • Hello, I did some test with the examples given(heart_rate_collector.py) as you suggested. I changed the CONNECTIONS to 5 and ran it over night with a youtube video on. There wasn't any connection problems at all Hoverever I found some bugs? that happened with the example.First, my application needs to have 8 ble connected concurrently but the example given only always up to 5 connections and if I try any number higher than 5, it would give this error

    C:\Python27\Lib\site-packages\pc_ble_driver_py\examples>python heart_rate_collector.py NRF52
            0 : COM3: 682160565
    
    Enter your choice: 0
    Serial port used: COM3
    Enabling larger ATT MTUs
    Traceback (most recent call last):
      File "heart_rate_collector.py", line 189, in <module>
        main(serial_port)
      File "heart_rate_collector.py", line 149, in main
        collector.open()
      File "heart_rate_collector.py", line 78, in open
        self.adapter.driver.ble_enable(ble_enable_params)
      File "C:\Python27\lib\site-packages\wrapt\wrappers.py", line 561, in __call__
        args, kwargs)
      File "C:\Python27\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 126, in wrapper
        raise NordicSemiException('Failed to {}. Error code: {}'.format(wrapped.__name__, err_code))
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_enable. Error code: 4
    
  • Also, When the central device is advertising and trying to connect with the perperial device, it would give me these errors sometime. What does these error mean and what do I need to do to fix them

    New connection: 0
    Disconnected: 0 BLEHci.conn_failed_to_be_established
    Traceback (most recent call last):
      File "heart_rate_collector.py", line 187, in <module>
        main(serial_port)
      File "heart_rate_collector.py", line 151, in main
        conn_handle = collector.connect_and_discover()
      File "heart_rate_collector.py", line 90, in connect_and_discover
        att_mtu = self.adapter.att_mtu_exchange(new_conn)
      File "C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py", line 166, in att_mtu_exchange
        return self.db_conns[conn_handle].att_mtu
    KeyError: 0L
    
    
    -------------------------------------------------------------------------------------------------------------
    
    Connection: 1, 0x2A37 (Standard.heart_rate) = [22L, 220L, 121L, 1L, 120L, 1L, 119L, 1L, 118L, 1L, 117L, 1L, 116L, 1L]
    Received advertisment report, address: 0xDC6CA5B384C1, device_name: Nordic_HRM
    Connection: 0, 0x2A37 (Standard.heart_rate) = [21L, 14L, 1L, 175L, 1L, 174L, 1L, 173L, 1L, 172L, 1L, 171L, 1L, 170L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [5L, 24L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [5L, 34L, 1L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [6L, 230L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [6L, 240L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [22L, 250L, 115L, 1L, 114L, 1L, 113L, 1L, 112L, 1L, 111L, 1L, 110L, 1L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [7L, 4L, 1L]
    Connection: 0, 0x2A19 (Standard.battery_level) = [88L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [21L, 44L, 1L, 169L, 1L, 168L, 1L, 167L, 1L, 166L, 1L, 165L, 1L, 164L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [5L, 34L, 1L]
    New connection: 2
    Connection: 1, 0x2A37 (Standard.heart_rate) = [7L, 14L, 1L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [23L, 24L, 1L, 109L, 1L, 108L, 1L, 107L, 1L, 106L, 1L, 105L, 1L, 104L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [5L, 24L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [21L, 14L, 1L, 163L, 1L, 162L, 1L, 161L, 1L, 160L, 1L, 159L, 1L, 158L, 1L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [7L, 34L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [5L, 4L, 1L]
    Disconnected: 2 BLEHci.conn_failed_to_be_established
    Connection: 1, 0x2A37 (Standard.heart_rate) = [7L, 44L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [4L, 250L]
    Connection: 1, 0x2A37 (Standard.heart_rate) = [23L, 34L, 1L, 103L, 1L, 102L, 1L, 101L, 1L, 100L, 1L, 99L, 1L, 98L, 1L]
    Connection: 0, 0x2A37 (Standard.heart_rate) = [20L, 240L, 157L, 1L, 156L, 1L, 155L, 1L, 154L, 1L, 153L, 1L, 152L, 1L]
    
    Traceback (most recent call last):
      File "heart_rate_collector.py", line 189, in <module>
        main(serial_port)
      File "heart_rate_collector.py", line 151, in main
        conn_handle = collector.connect_and_discover()
      File "heart_rate_collector.py", line 90, in connect_and_discover
        att_mtu = self.adapter.att_mtu_exchange(new_conn)
      File "C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py", line 166, in att_mtu_exchange
        return self.db_conns[conn_handle].att_mtu
    KeyError: 2L
    
Related