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

Python Bindings for an Advertising device

Hi all,

 I am using the python bindings in recent weeks to development a BLE scanning device and have found the python bindings very useful for getting the kit up and running.  I now need to use the pc_ble_driver_py to create an BLE advertiser. I have had success in running the advertising.py example, I can see the advertising device in the nRF connect app with the service uuids 0x1800 (Generic Access) and 0x1801 (Generic Attribute). What I need to do is add additional services and data to this advertising.py example. Im struggling to find how to do this.

the advertising.py example uses:

adv_data = BLEAdvData(complete_local_name="My_Advertiser")

to create the advertising data, then uses the adv_data in a data_set method to create the basic advertising data.

driver.ble_gap_adv_data_set(adv_data)

The full main() function in the example is:

def main(serial_port):
    print("Serial port used: {}".format(serial_port))
    driver = BLEDriver(serial_port=serial_port, baud_rate=1000000)
    observer = TimeoutObserver()
    adv_data = BLEAdvData(complete_local_name="my_Advertiser")
    driver.observer_register(observer)
    driver.open()
    if config.__conn_ic_id__.upper() == "NRF51":
        driver.ble_enable(
            BLEEnableParams(
                vs_uuid_count=0, 
                service_changed=0,
                periph_conn_count=1,
                central_conn_count=0,
                central_sec_count=0,
            )
        )
    elif config.__conn_ic_id__.upper() == "NRF52":
        driver.ble_enable()
    driver.ble_gap_adv_data_set(adv_data)
    driver.ble_gap_adv_start()
    observer.wait_for_timeout()
    print("Closing")
    driver.close()

My question is how can I find documentation or any other examples on how I can create additional advertising data from the device. For example if I wanted to create an additional 16bit uuid for the advertising device I guessed I should change the adv_data variable to something like:

adv_data = BLEAdvData(complete_local_name="my_Advertiser",service_16bit_uuid_complete = [0x11AA, 0x22AA, 0x33AA])

I've tried a few variations of the above, I'm sure I'm missing some significant steps in the procedure for adding additional advertising services and data.

Any help or advice is appreciated, hopefully the above is explained clearly enough, let me know if anything obvious is missing.

 I am new to Nordic dev kits and software in past few months, so this is my first post to the group. Thanks everyone for reading.

Haydn

Parents
  • Thanks for the reply,

    I had no error messages, my script was executing ok, I think possibly the data was there but stupidly I was thrown off by the combination of forgetting the data should be in reverse order and it shown in dec at the scanner side Face palm. With your suggestion and one further modication I got transmitting the data I needed.

    set up the adv_data as below, that gave me uuid 0x8FE1 with the data following that:

        adv_data = BLEAdvData(complete_local_name="Wake_Transmitter",
                              service_data = [0xE1, 0x8F, 0xAA, 0xBB, 0xCC, 0xDD],
                              appearance = [0xc3, 0x03] #0x03c3 is joystick
                             )

    So I used service_data, rather that service_16bit_uuid_complete.

     Thanks again for the pointer. Really appreciate the help.

    Kind Regards,

    Haydn

Reply
  • Thanks for the reply,

    I had no error messages, my script was executing ok, I think possibly the data was there but stupidly I was thrown off by the combination of forgetting the data should be in reverse order and it shown in dec at the scanner side Face palm. With your suggestion and one further modication I got transmitting the data I needed.

    set up the adv_data as below, that gave me uuid 0x8FE1 with the data following that:

        adv_data = BLEAdvData(complete_local_name="Wake_Transmitter",
                              service_data = [0xE1, 0x8F, 0xAA, 0xBB, 0xCC, 0xDD],
                              appearance = [0xc3, 0x03] #0x03c3 is joystick
                             )

    So I used service_data, rather that service_16bit_uuid_complete.

     Thanks again for the pointer. Really appreciate the help.

    Kind Regards,

    Haydn

Children
No Data
Related