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

nRF Dongle as UART client python

Hi, I'm trying to write a simple python application on Windows 7 that communicates with a BLE peripheral running Nordic UART Service. I'm using the nRF dongle and pyserial and can get prints from the dongle when it is connecting to the peripheral (e.g. The device has the Nordic UART Service) but I can't send any data. I can't find any information about the python api regarding Nordic UART.

The nRF Dongle has been flashed with "ble_app_uart_c_pca10031_s130.hex"

What do I need to be able to send/receive data from a pyhton app to a BLE peripheral?

Parents
  • Hi,

    You can use pc-ble-driver-py to communicate with peripherals from your python program. See the examples in python/pc_ble_driver_py/examples for help getting started.

    [EDIT:]

    To use the Nordic UART service to read and write data, you have to add the UUIDs to your driver. An example of how this is done can be seen in the source of the BLE transport layer for the DFU service in nrfutil.

    Based on the HRS example code, adding the corresponding UUIDs for NUS will then be as follows.

    Define the UUIDs inside the HRCollector class:

        BASE_UUID     = BLEUUIDBase([0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93, 
                                     0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E])
    	NUS_TX_UUID   = BLEUUID(0x0003, BASE_UUID)
    

    Add your BASE_UUID to the driver (in HRCollector.open()):

    self.adapter.driver.ble_vs_uuid_add(HRCollector.BASE_UUID)
    

    Enable notification (in HRCollector.connect_and_discover()):

    self.adapter.enable_notification(conn_handle=new_conn, uuid=HRCollector.NUS_TX_UUID)
    

    Best regards,

    Jørgen

  • Hi. So gannerud do you succeded to do what you want on your original POST ? I want to do exactly the same thing and I follow the advices of Jorgen but I still have the error pc_ble_driver_py.exceptions.NordicSemiException: Characteristic value handler not found

    Should I add my BLE BASE_UUID or should I add the one you write on the post Jorgen ? I'm a bit confused ...

    Could you give me some help ?

    Thanks

Reply Children
No Data
Related