You could simply check if wpa_supplicant managed to associate with an AP via wpa_cli, that should work just as well, will only block as long as necessary, and doesn't require actual WAN connectivity.
c.f.,
https://github.com/koreader/koreader...sync.sh#L8-L20
Or, in a similar fashion, poke sysfs until the network IF is up:
c.f.,
https://github.com/koreader/koreader...ce.lua#L15-L27
(Except don't hardcode the IF name, use the ${INTERFACE} env var).