I'm playing with some more advanced things in Tasker, and I've set up an NFC tag to do various things when I return home from work each day. One of these is to connect to wifi and run an SSH command to wake up my computer.

I'm in a dorm at a university, so all of the wifi SSIDs are the same. Because of this, my phone (a Nexus 5 on stock/rooted 5.1) will latch onto one AP and hold on as long as possible, and eventually switch as I move further away. This means that when I arrive at my room and tap the tag, my phone is almost always in the process of reconnecting to the nearest/correct AP and my SSH command fails. Sometimes it's connected immediately, sometimes it doesn't connect for a few minutes, so a simple "wait 10 seconds" in Tasker doesn't cut it.

Is there a way to simply break the existing connection and reconnect to the same SSID (just reconnecting in general is fine, there's only one SSID)? I know that disabling wifi altogether, waiting a few seconds for the phone to do it, enabling it again, and waiting a few more seconds will do this, but it takes longer and I imagine there's a better solution.

TL;DR: How can I break a wifi connection then reconnect in Android 5.1 (stock/rooted) without actually disabling wifi? Terminal commands are fine.


Checking the Tasker manual for the "WiFi Net" action shows:

WiFi Net

Change the wifi network connection status.

Reassociate: reconnect even if already connected.

(emphasis mine)

That should be exactly what you're looking for – playing with Tasker anyway :)

  • Dang, I didn't even see that in the manual! Perfect, thank you!
    – vaindil
    Mar 17 '15 at 21:41
  • Great! And yes, that manual could use a better index (it has not even anchors to the segments, so it's hard to reference). Easy to overlook the "small print" :) Btw: For more Tasker tipps, see here. And scroll down to the function graphs to see what's available :)
    – Izzy
    Mar 17 '15 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.