Post Reply

Tasker question - how can I turn on Bluetooth when WiFi goes off

25th January 2014, 08:37 PM   |  #1  
mpetruzz's Avatar
OP Senior Member
Thanks Meter: 105
 
1,543 posts
Join Date:Joined: Nov 2010
So I've been trying to set tasker to turn on my Bluetooth when I get out of range from my homes WiFi signal.

Problem is I have no idea how to set tasked to do that.

Has anyone done this and possibly shoot me some info.

Sent from my XT1060 using xda app-developers app
25th January 2014, 09:44 PM   |  #2  
Senior Member
Thanks Meter: 30
 
180 posts
Join Date:Joined: Nov 2010
I would do something like this:

Profile: BT Off at Home
Context: Wifi Connected [SSID:<YourSSID>]
Enter:
Bluetooth Off
Exit:
Bluetooth On

The exit task isn't really necessary if the Bluetooth was on before you connected to your home Wifi, but it ensures that you get the results you're looking for regardless of the Bluetooth state before the profile activates.
25th January 2014, 10:06 PM   |  #3  
titanshadow's Avatar
Senior Member
Flag Lexington, KY
Thanks Meter: 93
 
610 posts
Join Date:Joined: Feb 2012
Donate to Me
More
Quote:
Originally Posted by UncleMike

I would do something like this:

Profile: BT Off at Home
Context: Wifi Connected [SSID:<YourSSID>]
Enter:
Bluetooth Off
Exit:
Bluetooth On

The exit task isn't really necessary if the Bluetooth was on before you connected to your home Wifi, but it ensures that you get the results you're looking for regardless of the Bluetooth state before the profile activates.

I have a similar tasker situation setup on mine where if I'm not on WiFi my phone turned BT on and enables BT tethering. It is a bit more complicated than that though. Let me know if you'd like me to post it.
26th January 2014, 02:59 AM   |  #4  
chrisbass's Avatar
Senior Member
Flag Norwich
Thanks Meter: 100
 
407 posts
Join Date:Joined: Jun 2011
More
Quote:
Originally Posted by titanshadow

I have a similar tasker situation setup on mine where if I'm not on WiFi my phone turned BT on and enables BT tethering. It is a bit more complicated than that though. Let me know if you'd like me to post it.


I would definitely appreciate if you posted it


Sent from my iPad using Tapatalk
26th January 2014, 03:31 AM   |  #5  
titanshadow's Avatar
Senior Member
Flag Lexington, KY
Thanks Meter: 93
 
610 posts
Join Date:Joined: Feb 2012
Donate to Me
More
I use 2 profiles.

Enable BT Tether 1 is triggered when not connected to WiFi and executes "Enable Bluetooth Tethering" on entry and "Disable Bluetooth Tethering" on exit.
Enable BT Tether 2 is triggered when BT is turned when Bluetooth is on and does the same as above.

I use 2 profiles so that if Bluetooth is turned off when WiFi is also off, tethering enables itself again once BT comes back on. This also requites the use of an app called "Secure Settings" which can turn tethering on and off. When you turn tethering on if you're running a stock OS for your device it will check with your carrier (the OS does it, not Secure Settings) to see if you have that feature. This does not work if you use a 3rd party app to do tethering outside of the native OS method. If you are on CyanogenMod it does not check.

Enable Bluetooth Tether:
Code:
Profile Status BT Tether 1 ON
Profile Status BT Tether 2 ON
Secure Settings BT Tether Enabled if %WIFII !~ *CONNECTION*
Disable Bluetooth Tether:
Code:
Profile Status BT Tether 2 OFF
Secure Settings BT Tether Disabled
Now, I also have a much more complicated tasker series set up on my tablet to make sure my tablet always connects when wifi fails, but it took a lot more work to not waste battery power.

Auto Tether is triggered when not connected to WiFi and executes "Tether to Phone" on entry and "Disconnect from Phone" on exit.

Please note that where it says "Secure Settings Connect to Phone" the Secure Settings action used is "BT Connection" and you select your already paired device from the dropdown list. You can also set Secure Settings to toggle Bluetooth to ON if it is off, I don't have it say that way but it could be handy. I also found myself getting a lot of errors popping up as Toast notifications, but they were meaningless as the connection was established. Thus, I didn't worry about them and ended up disabling all notifications from Secure Settings.

Tether to Phone:
Code:
If %PhoneConnected = 0
Profile Status Monitoring Phone Connection ON
Secure Settings Connect to Phone
Profile Status Tether Search ON
Else
Profile Status Tether Search OFF
End If
Monitoring Phone Connection is triggered when the phone is connected via Bluetooth and executes "Phone Connected" on entry and "Phone Disconnected" on Exit.

Phone Connected:
Code:
Wait 1 Second
HTTP Get www.google.com:80
If %HTTPR=200
Variable Set %PhoneFailed to 0
Variable Set %PhoneConnected to 1
Profile Tether Search OFF
Else
Variable Set %PhoneFailed to 1
Variable Set %PhoneConnected to 0
End If
PhoneDisconnected:
Code:
Variable Set %PhoneConnected to 0
If %WIFII !~ *connection*
Profile Status Tether Search ON
Perform Task Tether to Phone if %PhoneFailed=0
End If
Tether Search is triggered every 5 minutes and executes Tether to Phone and has no exit.

I basically had to set it up this way because there is no way to have the tablet aware that it is connected to the phone at any given time, it'll execute an event but unlike WiFi there is no tasker variable for what devices are connected via Bluetooth using %PhoneConnected to manage this works very well. Using %PhoneFailed allows the script to be able to tell that a connection was attempted but unsuccessful, without this the tablet gets stuck in a loop always trying to reconnect once the phone goes out of range. I found this happening a lot when I would go to the grocery store and leave the tablet in the car after school. The battery drain wasn't extreme but it was there.

It is a little complicated, which kind of annoys me. One of these days I may get into Android programming and just make an app. But for now, this works. If the phone or tablet disconnect and are out of range, every 5 minutes a connection is attempted. If the connection drops, it does try once right away to reconnect, but then trips the Failed variable which prevents the tablet from going hardcore at trying to reconnect.
Last edited by titanshadow; 26th January 2014 at 03:35 AM. Reason: Added a note about Secure Settings
The Following User Says Thank You to titanshadow For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Moto X Q&A by ThreadRank