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?

Parents Reply
  • I tried setting user_desc to a list but the error is still there. The char_md.char_user_desc_size  seems to be correct in both cases

    Edit: Aha! I found one issue. It is missing char_user_desc_max_size. Adding it gets rid of the NRF_ERROR_DATA_SIZE error:

        char_md.char_user_desc_size = len(self.user_desc)
        char_md.char_user_desc_max_size = len(self.user_desc)

    I can now connect to the peripheral but the user description contains all 0x00 (len(self.user_desc)  number of 0x00 bytes)

Children
No Data
Related