Setting interval less than a scan window does not make much sense and is not allowed in the spec. Yes, you can modify
before initiating any scan or any connection. You should probably stop scan before attempting connection. If your device spends all time scanning it does not have time to do anything else. Please note that time to create connection will depend on how often your peripheral sends advertisements. Even if you are listening all the time and peer sends advertisements once per 2 seconds, it still will take you up to 2 seconds to see the advertisement.
Is it safe to do stop scan command from within the ad received callback?
I'm worried about doing commands to start actions from within callback functions (start/stop scan, start/stop connUp/connDown). Is this safe?
It should be ok.
The problem was me lowering interval size below window size, because I didn't understand the two.
Interval is how many slots WITHIN window to be listening (scanning).
are there advantages and risks to other configurations, like:
interval=10 and window = 20
or: interval = 1 and windows = 2
Interval is how often to start scan of window duration. If interval is 100 and window is 10 the device will be listening for 10 slots and go to sleep for 90 slots. Then listen for 10 slots then go to sleep for 90... Its all depends on your latency requirements and power consumption requirements.