Set BLE connect timeout

Hi guys…
Is it possible to set a connect timeout when trying to use device as a central?
I have NRF52840 Dev kit and mbed-os-5.15.2 with "target.features_add": ["BLE"].

The issue that I am currently experiencing is that when there is no device in proximity the connect attempt never times out or at least i am not notified about it. So i tried to use cancelConnect() to stop the connection but instead after it when i turn on the device it connects without me wanting it to.

Is it possible to set connect timeout to 10s?
What do you suggest for alternative solution?

Thanks

Hi Stjepan,

I think you need to set scan_duration.

I can’t find the duration field in connection parameters.

The duration is passed in startScan()

Thanks for your replay.
I connect directly using connect method which for argument takes mac address without scanning although i think that connect internally uses scan to find the device.

What would i gain if i would scan first?