As far as I know, wfmSetAirplaneMode just sets weather the Wifi is active or not. It doesn't necessarily connect to a network.
You'll want to use wfmConnectWireless or wfmConnectWirelessSilently to connect to a network.
Regarding timeout, only a single timeout is supported. It might be getting confused with two.
EDIT: hang on, just re-read your script... hmm
|