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

Regarding Python Scripts for nrf52840 to connect and transfer data.

Hi ,

What I am trying:- 

-connect the custom board with nrf52840 chip using nrf52 dongle on pc with python.

-Already set some commands on custom board so when my pc (via dongle) connects to custom board, I want to send some commands and accordingly receive the response.

For this I got my hands-on nrf dongle to give my laptop a BLE access.

And I am trying to access the board using dongle (using python script) and I am getting below error,


raise NordicSemiException('Failed to {}. Error code: {}'.format(wrapped.__name__, err_code))
pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13.

Would anyone able to tell me how do i resolve this. 

I want to have python code that can connect and do some data transfer over BLE using Dongle connected to my pc and I have tried with hart_rate_monitor unsuccessfully. 

EDIT 1:- I am able to scan and connect my board using the nRF Connect windows app. Same I wanted to implement over python.

Thanks,

Hinesh

  • Hi  

    Do you able to find out the error?

    Is there any other input require from my side?

    Thanks

  • Hi,

    Sorry for the delay, I have been out-of-office.

    It should work if you use the line:

    self.adapter.enable_notification(new_conn, DATA_CHAR_UUID)

    Regards,
    Terje

  • Hi

    I have tried the change you have suggested but still getting below error.

    ATT MTU exchange response: conn_handle=0
    Traceback (most recent call last):
      File "C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py", line 274, in <module>
        main(serial_port)
      File "C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py", line 255, in main
        conn_handle = collector.connect_and_discover()
      File "C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py", line 204, in connect_and_discover
        self.adapter.enable_notification(new_conn,  DATA_CHAR_UUID)
      File "C:\Python27\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 125, in wrapper
        err_code = wrapped(*args, **kwargs)
      File "C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py", line 254, in enable_notification
        raise NordicSemiException('CCCD not found')
    pc_ble_driver_py.exceptions.NordicSemiException: CCCD not found
    
    Process finished with exit code 1

  • Hi,

    I am sorry, but I cannot think of much more that might be the issue. Make sure that you have gotten the endianness correct (i.e. byte order in the UUIDs) and that you are using the correct UUIDs. Other than that, there is no reason left why it should not work...

    Regards,
    Terje

  • Hi ,

    I have took the endianness correctly that I have checked. But not able to success. If there is no other reason left then I have to take another approach here.

    I have took windows native ble libs for connecting to nrf board. As of now I am able to connect and explore services UUID's from board (pairing is also done). For this I am using the same UUID's as above for reading characteristics. ( If you have experience in that you can point to me correct way if I am wrong. I am coding in C# and open for java as well for example code).

    But While sending read command I am not able to receive data. To debug this issue,I request to point me for any example that utilizes the same libs(windows app for BLE libs) for communication. so that I can compare and make changes accordingly in my application.

    Thanks,

    Hinesh

Related