Hi Dears,
I am using the pc-ble-friver-py-0.1.0 for the nRF5840-Dongle development, I have an issue with the ble scan:
I used the function ble_gap_scan_start to aotu start the ble-scna, my scene is that if the ble-device advertised is not which I wanted, I will restart the scan instead of connecting it. To restart the scan, I use the ble_gap_scan_stop-->ble_gap_scan_start serials in order to get a new advertisement from different devices. But when I call the ble_gap_scan_start after called the ble_gap_scan_stop, I received the error:
File "/home/BleCollector.py", line 92, in connect_and_discover self.adapter.driver.ble_gap_scan_start() File "/usr/local/lib/python3.7/dist-packages/pc_ble_driver_py-0.12.0-py3.7-linux-x86_64.egg/pc_ble_driver_py/ble_driver.py", line 99, in wrapper error_code=err_code, pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gap_scan_start. Error code: 8
8 means NRF_ERROR_INVALID_STATE, I have checked the nRF SoftDevice API, it says:
NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: Scanning is already ongoing and p_scan_params was not NULL Scanning is not running and p_scan_params was NULL. The scanner has timed out when this function is called to continue scanning.
But from the python api in pc-ble-driver-py, it doesn't have these two parameters:
def ble_gap_scan_start(self, scan_params=None): if not scan_params: scan_params = self.scan_params_setup() assert isinstance(scan_params, BLEGapScanParams), "Invalid argument type" return driver.sd_ble_gap_scan_start(self.rpc_adapter, scan_params.to_c()
So I don't know how to afford it, or is there any other way to restart the scan to receive advertisement from other devices?
Thank you very much!