Hi Simon, Thanks for the heads up; this is definitely an omission. You should be able to cancel a scan in progress.
Barring any unforeseen complications, the cancel functionality should be implemented in the develop branch tomorrow. This will allow the app cancel the scan and initiate a connect procedure from within the advertising event callback. Chris On Sat, Jun 18, 2016 at 7:38 PM, Simon Ratner <si...@proxy.co> wrote: > Hi devs, > > Having initiated an undirected scan with ble_gap_disc(), I would like to > connect to my peripheral as soon as I spot it in the scan callback. > However, calling ble_gap_conn_initiate() at this point fails with > BLE_HS_EALREADY, as ble_gap_master is still in discovery mode. I need to > stash the discovered peripheral, wait for the scan to finish, and then try > to connect, which is unnecessary state management. Additionally, there > doesn't seem to be a way to cancel the scan, so this becomes especially > problematic if the scan is long-running. > > For comparison, while advertising, an incoming connection automatically > drops the slave out of advertising mode (which can be resumed immediately > if you have enough connection resources). > > Is this an omission, or by design? > > Cheers, > simon >