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

User description in pc-ble-driver-py

When trying to add a user description to the BLEGattsCharMD() I get this error:

TypeError: in method 'ble_gatts_char_md_t_p_char_user_desc_set', argument 2 of type 'uint8_t const *'

This is a code snippet causing this error:

props = BLEGattCharProps(notify=True, read=True, write=True)
desc_md = BLEGattCharProps(read=True)
user_desc = bytearray([1,2,3])
char_md = BLEGattsCharMD(char_props=props, desc_md=desc_md, user_desc=user_desc)

The error is on this line in ble_driver.py:

char_md.p_char_user_desc = util.list_to_char_array(self.user_desc)

(See https://github.com/NordicSemiconductor/pc-ble-driver-py/blob/v0.15.0/pc_ble_driver_py/ble_driver.py#L1267)

Any ideas?

  • Which Python and OS versions are you running this on? I'm getting an error after a few seconds:

    Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads
    Python runtime state: finalizing (tstate=010BEDC0)
    
    Thread 0x000052b8 (most recent call first):
      File "C:\Python\Python38-32\lib\threading.py", line 306 in wait
      File "C:\Python\Python38-32\lib\queue.py", line 179 in get
      File "C:\Python\Python38-32\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 2336 in ble_event_handler_thread
      File "C:\Python\Python38-32\lib\threading.py", line 870 in run
      File "C:\Python\Python38-32\lib\threading.py", line 932 in _bootstrap_inner
      File "C:\Python\Python38-32\lib\threading.py", line 890 in _bootstrap
    
    Thread 0x0000314c (most recent call first):
      File "C:\Python\Python38-32\lib\threading.py", line 306 in wait
      File "C:\Python\Python38-32\lib\queue.py", line 179 in get
      File "C:\Python\Python38-32\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 2287 in status_handler_thread
      File "C:\Python\Python38-32\lib\threading.py", line 870 in run
      File "C:\Python\Python38-32\lib\threading.py", line 932 in _bootstrap_inner
      File "C:\Python\Python38-32\lib\threading.py", line 890 in _bootstrap
    
    Thread 0x00004f80 (most recent call first):
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 1084 in emit
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 950 in handle
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 1649 in callHandlers
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 1587 in handle
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 1577 in _log
      File "C:\Python\Python38-32\lib\logging\__init__.py", line 1500 in log
      File "C:\Python\Python38-32\lib\site-packages\pc_ble_driver_py\ble_adapter.py", line 786 in on_rpc_log_entry
      File "C:\Python\Python38-32\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 2321 in log_message_handler_sync
      File "C:\Python\Python38-32\lib\site-packages\wrapt\decorators.py", line 445 in _synchronized
      File "C:\Python\Python38-32\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 2327 in log_message_handler_thread
      File "C:\Python\Python38-32\lib\threading.py", line 870 in run
      File "C:\Python\Python38-32\lib\threading.py", line 932 in _bootstrap_inner
      File "C:\Python\Python38-32\lib\threading.py", line 890 in _bootstrap
    
    Current thread 0x00002bb4 (most recent call first):
    <no Python frame>

  • Oh, that didn't look too good. I am running Ubuntu 20.04.2 LTS, Python 3.8.5.

    Edit: And just to be clear, the version of pc-ble-driver-py is 0.15.0

  • In my other issue there is also garbage showing up. Maybe these two issues are related: devzone.nordicsemi.com/.../device-name-shows-garbage-using-pc_ble_driver_py

Related