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

pc-ble-driver-py example of writing a characteristic.

I'm using the pc-ble-driver-py: Standard Heart Rate example to read a characteristic just fine.

My issue is i now need to write a to a characteristic.

How would I do that given the example above that reads great but can hypothetically write to the same characteristic read?

Link to HR example:

github.com/.../heart_rate_collector.py

Parents Reply Children
  • We don't have any examples for pc ble driver py for the ble_app_uart example. 

    I don't know if you are aware, but we have an SDK found here

    You can also use nRF Connect for Desktop or nRF Connect for iOS/android to connect to devices via BLE, to see what they look like before you start to write your pc-ble-driver-py application.

    The pc-ble-driver-py is a subset of pc-ble-driver, which is a C-based tool. I am not experienced with Python, and I don't know if you are.

    Do you intend to write a tool that is supposed to run on a PC? The reason I ask is that I am not sure whether you are using pc-ble-driver-py intentionally, or if this was the first thing you stumbled upon.

    The hex file for the ble_app_uart examples is found in the SDK from the link, which you have to unzip, and then find the example in SDK\examples\ble_peripheral\ble_app_uart. You can compile and download the hex file using SES (Segger Embedded Studio).

    BR,

    Edvin

  • I do write in python.  Its pretty obvious as my first post.  Your port of pc-ble-driver to pc-ble-driver-py is more or less there. 

    I do use the SDK and nRF Connect to send and write characteristics which works just fine.

    If you are implying that I need to look at examples in pc-ble-driver to help that's fine too.  I just wanted to know if you had an already working example in python that just demonstrated writing a characteristic.  But you do not.

    I already have a working example writing characteristic in python after some investigation and testing and I believe this ticket is closed.

  • I am in the position you were in: wanting to write a characteristic. Can you pass on any examples, tips, or links to information that helped you?

    Thanks,
    Chris

  • I figured it out. It's pretty simple, something like this for a custom service: (unverified after sanitizing)

    self.ourBaseUUID = BLEUUIDBase([0x5e, 0x0a, 0xc3, 0x95, 0x70, 0xb0, 0xab, 0xae,
                                    0xfd, 0x23, 0x6b, 0x79, 0x4a, 0x9b, 0x58, 0xda],
                                   2)  # base UUID type=2 (why?)
    self.ourCharUUID = BLEUUID(0x2001, self.ourBaseUUID)

    byte_array = [1, 2, 3, 4]
    self.adapter.write_req(conn_handle, self.ourCharUUID, byte_array)
  • Hi Chris,

    I am doing something like you but I am facing issue. Can you share your working example script?

    I use a nRF52840 Dongle to connect with my Bluetooth Device by modifying heart_rate_collector.py and it is successful. Now I would like to send some HEX code to the Bluetooth Device with python. The action should be similar with the nRF Connect Desktop at the 1401 below. I am sending the HEX command to the device.

Related