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
  • Hi Jorgen !!!

    Thank you for this pretty cool answer. I tried your script after flashing my PCA10040 with example/ble_central_ble_app_uart_c on SDK 14.1.0 without any changement. I used the command

    $ python2.7 nus_collector.py NRF52 /dev/ttyACM0 
    

    An this is the log :

    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 126, in 
    wrapper
        raise NordicSemiException('Failed to {}. Error code: {}'.format(wrapped.__name__, err_code))
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13
    

    So I still have the problem. Do you have any idea ?

  • Did you flash the connectivity firmware manually? If you have the firmware flashed, but it is using the wrong baudrate, you might get this error. Please try erasing the board using nrfjprog -f nrf52 -e command and let pc-ble-driver-py do the firmware flashing for you. You can also try disabling the MSD when using Linux, some users have experienced similar issues when this is enabled.

  • Hi Jorgen.

    I have tried to change the baudrate put 115200 and put 1M on the ble_central_ble_app_uart_c example.

    When I change the auto_flash to True on the python script l155 I got this error : pc_ble_driver_py.exceptions.NordicSemiException: nrfjprog not installed

    I think I need to change some path somewhere ...

    Thanks

Reply Children
No Data
Related