can tasker detect if I have mobile data ?

1,816 views
Skip to first unread message

Mike Kramer

unread,
Jan 6, 2015, 7:35:20 AM1/6/15
to tas...@googlegroups.com
I have a app which sends commands via mobile data. When I am logged into wifi, tasker turns my mobile data off. In that short period of switching from 3G to wifi, I get error messages that the command could not be sent as there is no mobile data. If I could detect if there is mobile data I could delay that action until I have mobile data again, either via 3G or wifi. I had a look and cant see anything like that

Pent

unread,
Jan 6, 2015, 7:52:38 AM1/6/15
to tas...@googlegroups.com
There's an action to test if Mobile Data is enabled (Net / Test Net) and a state context Mobile Data too to see if it's connected
at a given moment.

Pent

Pent

unread,
Jan 6, 2015, 7:53:22 AM1/6/15
to tas...@googlegroups.com
p.s. Menu / Search Tasker for 'mobile' would have shown you both of those.

Pent

Mike Kramer

unread,
Jan 6, 2015, 8:14:31 AM1/6/15
to tas...@googlegroups.com
I know why I didn't see it... I was looking in task actions rather than Profile state. Ok so I use a profile to set a variable to 1 when I have data, and change the variable to 0 when I haven't, and in the task do a wait until my variable is 1... that should do it. Perfect. Thanks

Mike Kramer

unread,
Jan 6, 2015, 8:27:29 AM1/6/15
to tas...@googlegroups.com
actually, test net is a action. But looking at it, how do I use it in my case ? I have tried
 
Action - test net - type - mobile data enabled and then set a variable %Mobdata, but when I check the variable in Vars it is not there, so think it is not set. And I wanted to test for any data connection and not sure which wifi option to use if I have to have 2 separate actions for 3G data and wifi data
Message has been deleted

Peter Kammerl

unread,
Jan 6, 2015, 8:23:11 PM1/6/15
to tas...@googlegroups.com
try this as shell:

dumpsys telephony.registry | grep mDataConnectionState  | awk '{print $1}'

as root

Pent

unread,
Jan 7, 2015, 2:34:43 AM1/7/15
to tas...@googlegroups.com
For your case you should use the Mobile Data state and set a variable with it on enter and exit. To test wifi you can use Wifi Connected state and similarly set/clear a variable.

Pent

Mike Kramer

unread,
Jan 7, 2015, 2:47:29 AM1/7/15
to tas...@googlegroups.com
I have seen my Action - test net - type - mobile data enabled and then set a variable %Mobdata, returns mobile when I am on 3G, and wifi when I am on wifi. So I could use that to set a variable, which in turn tells me if I am on mobile or wifi, and then proceeds with the authomation command. Or as pent said, I could use the wifi connected, which I use in another profile anyway to set that variable. The only downside I could possibly see, when connecting to wifi, it takes a little while to connect and get an ip. I do not know when wifi connected reports as connected, or when the test net - mobile data reports wifi. Ideally I would use the one which reports when I am properly connected. Which one is better in that case, wifi connected or test net ?

Mike Kramer

unread,
Jan 7, 2015, 3:56:50 AM1/7/15
to tas...@googlegroups.com
I am also trying a profile, state - mobile network, I ticked 3g and 3g hspa, and that sets my mobile data variable to 1, question is is that true when its either 3g or 3g hspa or both ?

Pent

unread,
Jan 7, 2015, 9:15:42 AM1/7/15
to tas...@googlegroups.com

I am also trying a profile, state - mobile network, I ticked 3g and 3g hspa, and that sets my mobile data variable to 1, question is is that true when its either 3g or 3g hspa or both ?

Read the help text, I think it's pretty clear on that.

Pent

Mike Kramer

unread,
Jan 7, 2015, 11:20:14 AM1/7/15
to tas...@googlegroups.com
Yes ok its as I thought, true when its either 3g or 3g hspa or both, so that should work fine for what I want to do. Should have looked at the manual first...
Reply all
Reply to author
Forward
0 new messages