I was facing a very strange issue in my phone (Galaxy Ace – Running Android v2.2 FroYo). Wifi network was scanned properly but it did not connect all the time. Sometime or the other, it just keeps on trying to obtain the IP address, and it never connected. I also tried one free android application – fixmywifi. It is available on android market for free, I used it once, but it asked me to restart the phone, I did not like that idea. Because restarting the phone anyways solves the issue.
So, I found another way (ofcourse from doing some googling) that if you dial *#*#526#*#*, the phone will actually initiate the wifi driver loading/unloading process. And once it is successful (as displayed on the phone screen) you can connect to your wifi network. It worked like a charm for me.
Glad to know that!!