This question devzone.nordicsemi.com/.../ reports the fact that the driver cannot be used twice without manually pin reseting teh BLE dongle.
But there is another problem (as I commented in this other post, but I prefer to pôst a new question as it's not exactly the same issue).
If trying to establish two COM connections in a row within the same process, pin reseting does not fix the problem.
Let's define a function that simply:
- Opens the port
- Plays with BTLE (start/stop device lookup for instance is enough)
- Closes the port
Now, create one program calling this function:
- Run the program
- Reset device using --pinreset
- Run the program again. It works
Now, create another program running this function, then doing the pinresets (system calls) and then calling the function again:
- Run the program. First function run works, second fails. It reports
Error: File: (null), Line: 0, Error code: 3
when sd_rpc_open() is invoked, and then sd_ble_gap_scan_start hangs for ever.
So, looks like the s120_nrf51_ble_driver.dll library itslef remains in an unstable state. Only having it be loaded from a brand new process makes it work again.
Looks like sd_rpc_open() is missing some resources cleanup.