nRF52 DK + NUS (BLE UART) app + Python

I'm running the NUS demo on my nRF52 DK board and I can connect and send/receive data using the nRF Toolbox app on Android.

Now I'd like to use Python from my (Windows 11) laptop. I installed the Python Bleak library and from Python and I can find the Nordic_UART_Service device and connect to it. But I am not able to write to the gatt characteristic (UUID 6e400002-b5a3-f393-e0a9-e50e24dcca9e ).

I'm getting a "characteristic not found" error from the Bleak Client.

Does anyone have some Python example code that successfully does I/O to the NUS app?

Regards,

Bret

Parents
  • Hi Bret, 
    I'm not very familiar with the PythonBleak library but as with any BLE central, you would need to perform a service discover to be able to get the handle ID of the characteristic. 
    In other words you can not directly write to a characteristic with just the UUID. You need to discover the attribute table to get the handle ID of the characteristic that matches the UUID you are looking for. 
    Please double check if the UUID of the characteristic you are planning to write to match with what on the peripheral. 


    I would suggest to get familiar with the library by testing with some standard BLE service before you move to NUS, for example heart rate service. 

  • After I connect, I see the DK connect light turn on, so I know I'm connecting. But the Bleak Client services list is empty. Is it possible that the NUS demo does not have services discovery enabled?
    I'll try the same code with the HRS demo and see if any services are discovered.

  • Hi Bret, 
    All BLE server would support service discovery procedure. If you can use a phone and connect to the device and can get the services& characteristic that mean the service discovery has been performed. 
    I would suggest to use nRF Sniffer to track what happen over the air. 

Reply Children
No Data
Related