Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,785,512 Members 42,696 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
mpetruzz
Old
#1  
mpetruzz's Avatar
Senior Member - OP
Thanks Meter 105
Posts: 1,533
Join Date: Nov 2010
Default Tasker question - how can I turn on Bluetooth when WiFi goes off

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
 
UncleMike
Old
#2  
Senior Member
Thanks Meter 30
Posts: 178
Join Date: 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.
 
titanshadow
Old
#3  
titanshadow's Avatar
Senior Member
Thanks Meter 93
Posts: 609
Join Date: Feb 2012
Location: Lexington, KY

 
DONATE TO ME
Quote:
Originally Posted by UncleMike View Post
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.
Cyanogenmod is to the average user as caviar is to the general.

https://plus.google.com/+DavidHagar/
 
chrisbass
Old
#4  
chrisbass's Avatar
Senior Member
Thanks Meter 100
Posts: 404
Join Date: Jun 2011
Location: Norwich
Quote:
Originally Posted by titanshadow View Post
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
 
titanshadow
Old
(Last edited by titanshadow; 26th January 2014 at 03:35 AM.) Reason: Added a note about Secure Settings
#5  
titanshadow's Avatar
Senior Member
Thanks Meter 93
Posts: 609
Join Date: Feb 2012
Location: Lexington, KY

 
DONATE TO ME
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.
Cyanogenmod is to the average user as caviar is to the general.

https://plus.google.com/+DavidHagar/
The Following User Says Thank You to titanshadow For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes