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

How to use PCA10040 as Dongle Scanner

Hi,

I'm trying to have a PCA10040 working as a scanner of BLE peripherals to be able to connect to my own BLE Nordic device, write a characteristic and close the connection. To do that I followed those steps:

  1. Flash `nRF5_SDK_14.1.0_1dda907/examples/ble_central/ble_app_uart_c on the PCA (Firmware + Soft device => make flash + make flash_softdevice)

  2. sudo pip install pygatt

  3. Clone the repo pc-ble-driver-py and type the command python2.7 heart_rate_collector.py NRF52 /dev/ttyACM0

This leads to an error : pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13 I precise that I changed l627 in main.c of ble_app_uart_c the baud_rate to UART_BAUDRATE_BAUDRATE_Baud1M and I changed the python script on function main to baud_rate=1000000

After that I decided to erase all on PCA10040 and used your application nrfconnect-2.2.1. So this application Bluetooth Low Energy reflashed the PCA10040 with a firmware and a SoftDevice. This application is working fine and scan my own device and its custom char and service. I'm able to write on this custom char without any problem.

After that I'm able to connect to the PCA with heart_rate_collector.py with all the self.adapter.enable_notification commented. The self.adapter.service_discovery(new_conn) seems to work. My custom service and charateristics have an UUID of 0x00 when I add some debug on service_discovery function (I do not know if it is normal ?).

So at the end when I try to call self.adapter.write_cmd after adding the CUSTOM SERVICE UUID and CHAR UUID as you explained on this post I still have the error pc_ble_driver_py.exceptions.NordicSemiException: Characteristic value handler not found

So my question is : where can I find a simple python script or a simple C program doing scan-discovery-connect-write_char-disconnect ? The same thing your nrfconnect-2.2.1 is doing but with a script.

Thanks for your response. Regards

Parents Reply
  • Hello Jörgen!

    I have a similar issue to this, but my error message looks something like this:

    robban@:pca20020_s132$ python2.7 nus_collector.py NRF52
    	0 : /dev/ttyACM0: 000682995637
     
    Enter your choice: 0
    Serial port used: /dev/ttyACM0
    Traceback (most recent call last):
      File "nus_collector.py", line 196, in <module>
        main(serial_port)
      File "nus_collector.py", line 158, in main
        collector.open()
      File "nus_collector.py", line 73, in open
        self.adapter.driver.open()
      File "/usr/local/lib/python2.7/dist-packages/pc_ble_driver_py/ble_driver.py", line 99, in wrapper
        error_code=err_code,
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13

    I have tried using the nrfjprog -f nrf52 -e command you recommended above, and my PATH includes the nrfjprog binaries. However I still cannot make it work, and the links to the wrong baudrate and similar issues above seem to be broken?

    Also I have tried figuring out where the script actually determines which HEX-files should be written with the nrfconnect to my device, I can't seem to find it.

    Would appreciate some help!

Children
Related