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

Related