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

how to use sd_ble_uuid_vs_add in python

Hello,

I am programing a central role device in Python, with nRF51-BLE-Driver for windows. I want to discover custom 128 UUID services. For that i need to call the sd_ble_uuid_vs_add function ( base on this topic devzone.nordicsemi.com/.../ ) But how should I use it?

If I try this

uuid_list = [213, 127, 254, 99, 205, 147, 235, 163, 14, 74, 172, 83, 1, 0, 162, 186]
uuid_pointer = 0
ble_driver.sd_ble_uuid_vs_add(uuid_array, uuid_pointer)

I get: TypeError: in method 'sd_ble_uuid_vs_add', argument 1 of type 'ble_uuid128_t const *'

If I try to create ble_uuid128_t const *

srvc_uuid128 = ble_driver.ble_uuid128_t()
srvc_uuid128.uuid128 = util.list_to_uint8_array(uuid_list)

I get: TypeError: in method 'ble_uuid128_t_uuid128_set', argument 2 of type 'unsigned char [16]'

What is the correct way to use sd_ble_uuid_vs_add function in python?

Parents
  • Hi!

    Calling sd_ble_uuid_vs_add() can be done like this:

    uuid_list = [213, 127, 254, 99, 205, 147, 235, 163, 14, 74, 172, 83, 1, 0, 162, 186]
    uuid_array = util.list_to_uint8_array(uuid_list)
    
    srvc_uuid128 = ble_driver.ble_uuid128_t()
    srvc_uuid128.uuid128 = uuid_array.cast()
    
    uuid_type_pointer = ble_driver.new_uint8()
    
    ble_driver.sd_ble_uuid_vs_add(srvc_uuid128, uuid_type_pointer)
    
    uuid_type = ble_driver.uint8_value(uuid_type_pointer)
    

    Converting to the correct argument types might be a somewhat tricky. The examples in the release are for now the best source for information regarding how to pass different argument types.

Reply
  • Hi!

    Calling sd_ble_uuid_vs_add() can be done like this:

    uuid_list = [213, 127, 254, 99, 205, 147, 235, 163, 14, 74, 172, 83, 1, 0, 162, 186]
    uuid_array = util.list_to_uint8_array(uuid_list)
    
    srvc_uuid128 = ble_driver.ble_uuid128_t()
    srvc_uuid128.uuid128 = uuid_array.cast()
    
    uuid_type_pointer = ble_driver.new_uint8()
    
    ble_driver.sd_ble_uuid_vs_add(srvc_uuid128, uuid_type_pointer)
    
    uuid_type = ble_driver.uint8_value(uuid_type_pointer)
    

    Converting to the correct argument types might be a somewhat tricky. The examples in the release are for now the best source for information regarding how to pass different argument types.

Children
No Data
Related