Jump to content

[HOWTO] "Automated" Sensorly LTE data collection with Tasker


Recommended Posts

I decided to make this it's own thread, as I've gone and made it overly complicated.

 

Since we're letting our geek flags fly... Here is my Tasker setup that I created to aid me in tracking down LTE signal. I created this because if you're trying to be a "Sensorly Cartographer" like myself, it's annoying to have to keep your phone in front of your face all of the time, switching in and out of airplane mode, checking to see if the 3G now reads 4G. The most annoying thing for me is that if you lose your LTE signal, you'll have to 1) notice that it's gone, and 2) start cycling airplane mode again. This setup automates that, so if you're searching with Sensorly you just have to hit a button, and if there's LTE around you'll connect to it a lot faster. It's got a few moving parts to it, but so far it's worked out for me.

 

WARNING: be aware that this WILL increase your battery consumption if (for some reason) you leave it running when not activily mapping.

 

I highly recommend anyone who loves their Android phone to buy Tasker. I've had it for years, and am able to automate so many parts of my phone with it. I know I'm just scratching the surface with what I use it for too.

 

To fully utilize this you'll be creating 3 tasks, 2 profiles and a widget icon on your home screen.

 

Task 1: "Modified Airplane Mode Toggle" (Download here: Task-ModifiedAirplaneModeToggle.xml)

 

Modified Airplane Mode Toggle
A1: Flash [ Text:Airplane Toggle Long:Off ]
A2: Airplane Radios [ Bluetooth:Off Cell:On NFC:Off Wifi:Off Wimax:On ]
A3: Airplane Mode [ Set:On ]
A4: Wait [ MS:0 Seconds:20 Minutes:0 Hours:0 Days:0 ]
A5: Airplane Mode [ Set:Off ]

 

What it does: it turns a modified airplane mode on (modified because I kept getting annoyed at the regular airplane mode cutting off my bluetooth headphones), waits 20 seconds, and toggles the airplane mode back off. 20 seconds is long enough for radio to do an LTE scan when it comes back online.

 

On line A1, when things are set to "On" that means that they will be disabled by a Tasker Airplane Mode action, and "Off" means they won't be disabled by Tasker's Airplane Mode. I also set Wimax to "On" because, well, why not?

 

Task 2: "4G Scan Monitor" (Download here:Task-4GScanMonitor.xml)

 

4G Scan Monitor
A1: If [ %4GSCAN Is Set ]
A2: If [ %HAVE4G ! Set ]
A3: Perform Task [ Name:Modified Airplane Mode Toggle Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
A4: Wait [ MS:0 Seconds:45 Minutes:0 Hours:0 Days:0 ]
A5: Goto [ Type:Action Number Number:1 Label: ]
A6: End If
A7: End If

 

This simulates a while loop, checking to see two things: if you have turned on your "scanning" widget to scan (more on that in a bit), and if you currently do not have 4G coverage (keep reading!). It then runs the "Modified Airplane Mode Toggle", waits 45 seconds, and goes back to the first line.

 

Task 3: "Airplane Toggle Widget" (Download: SEE BELOW)

 

Airplane Toggle Widget
A1: If [ %4GSCAN Is Set ]
A2: Variable Clear [ Name:%4GSCAN Pattern Matching:Off ]
A3: Set Widget Icon [ Name:Airplane Toggle Widget Icon:<icon> ]
A4: Else
A5: Variable Set [ Name:%4GSCAN To:1 Do Maths:Off Append:Off ]
A6: Set Widget Icon [ Name:Airplane Toggle Widget Icon:<icon> ]

 

This is the logic behind the widget button you'll create later. It just sets/unsets the variable that controls whether or not you will be popping into/out of airplane mode.

 

Profile 1: "In LTE" (Download here: Profile-InLTE.xml)

 

Profile: In LTE
State: Mobile Network [ 2G:Off 3G:Off 3G - HSPA:Off 4G:On ]
Enter: Anon
A1: Variable Set [ Name:%HAVE4G To:1 Do Maths:Off Append:Off ]
Exit: Anon
A1: Variable Clear [ Name:%HAVE4G Pattern Matching:Off ]
A2: If [ %4GSCAN Is Set ]
A3: Perform Task [ Name:4G Scan Monitor Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]

 

This profile sets a variable when you enter into 4G coverage. When you leave/lose 4G, it will check to see if you're currently in "scanning mode". If you are, it will start the scan over again.

 

Profile 2: "Run 4G Scan" (Download here: Profile-Run4GScan.xml)

 

Profile: Run 4G Scan
State: Variable Value [ Name:%4GSCAN Op:Is Set Value:* ]
Enter: 4G Scan Monitor

 

This simply monitors the variable set by your widget toggle, and runs the "4G Scan Monitor" task.

 

To add the widget:

 

Long press on your launcher home screen: select Widget. Scroll down to "Tasker" and select "Task". From the list that pops up select "Airplane Toggle Widget".

 

How to use:

  1. Start Sensorly
  2. Get a GPS lock
  3. Click the Start button on the Map Trip screen
  4. Hit your Home button to return to your launcher
  5. Tap the "Airplane Toggle Widget" you added earlier
  6. ...
  7. Profit!

This will keep Sensorly running in the background. If/when your phone latches on to 4G, Sensorly will immediately start recording your 4G points.

 

Hints:

 

Recommended reading: http://forum.xda-dev...d.php?t=1110775

 

I have also attached the two Profile XML files you can import directly into Tasker to make setting all of this easier. The should set up Profiles 1 and 2, as well as Tasks 1 and 2.

 

For some reason the forum won't let me upload the XML file for the Airplane Toggle Widget. Just copy and paste the following into an XML file named "AirplaneToggleWidget.xml", and import it that way.

 

<TaskerData sr="" dvi="1" tv="1.3.3u2m">
<Task sr="task89">
<cdate>1354205330359</cdate>
<edate>1354207750344</edate>
<id>89</id>
<nme>Airplane Toggle Widget</nme>
<Action sr="act0" ve="3">
<code>37</code>
<lhs>%4GSCAN</lhs>
<op>9</op>
<rhs></rhs>
</Action>
<Action sr="act1" ve="3">
<code>549</code>
<Str sr="arg0" ve="3">%4GSCAN</Str>
<Int sr="arg1" val="0"/>
</Action>
<Action sr="act2" ve="3">
<code>152</code>
<Str sr="arg0" ve="3">Airplane Toggle Widget</Str>
<Img sr="arg1" ve="2">
<icn>2130837588</icn>
</Img>
</Action>
<Action sr="act3" ve="3">
<code>43</code>
</Action>
<Action sr="act4" ve="3">
<code>547</code>
<Str sr="arg0" ve="3">%4GSCAN</Str>
<Str sr="arg1" ve="3">1</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act5" ve="3">
<code>152</code>
<Str sr="arg0" ve="3">Airplane Toggle Widget</Str>
<Img sr="arg1" ve="2">
<icn>2130837617</icn>
</Img>
</Action>
<Img sr="icn" ve="2">
<icn>2130837588</icn>
</Img>
</Task>
</TaskerData>

 

To import the Tasks and Profiles

 

First download the XML files to your phone. In certain browsers they will ask you if you want to open the file with Tasker. If your browser just offers to save the file, use a file explorer to move it to /sdcard/Tasker/tasks (for Tasks) or /sdcard/Tasker/profiles (for Profiles). Then go into Tasker and do a long-tap on the Profiles tab header. To import Tasks do the same on the Tasks tab header.

 

Please let me know if you find any errors in my logic, as I'm sure there are a few.

 

Happy hunting!

  • Like 3
Link to comment
Share on other sites

I was able to create the task, but I cant import the profiles on tasker.

Did you get any errors? What process did you use? Did you download it using your phone?

 

Try this: On your phone, open this page in the browser. When you click on the xml file, it should ask you if you want to open it with Tasker. Once you've done that, go back into Tasker and try the import again.

Link to comment
Share on other sites

To open the files in Tasker directly, they need the correct file extensions; the Task files need to have the extension .tsk.xml and the Profile files need the extension .prf.xml

Thanks for pointing this out. I'm trying to edit my post, but it's not showing me the option right now.

Link to comment
Share on other sites

Nice, anyone find a way to do this with llama?

I just downloaded llama and unfortunately it doesn't look like it supports the cell state conditions to make this usable.

 

Sent from my SPH-L900 using Tapatalk 2

 

 

Link to comment
Share on other sites

How often do our phones natively look for 4g? I mean, they must check every now and then right?

 

They do, however, some phones just refuse to connect properly, and some with ease.

Link to comment
Share on other sites

Nice, anyone find a way to do this with llama?

 

Tina?

 

http://www.youtube.com/watch?v=c2glOppqBRg

 

I have to be honest. The Android developer community is probably a little bit too active and chooses some of the most ridiculous names.

 

AJ

  • Like 1
Link to comment
Share on other sites

Whats the news on the Galaxy Nexus? Is it playing nice with LTE? (though I suppose I am running ROMs so that could effect that)

 

I don't know. I just got mine on Black Friday & haven't been to any LTE areas yet. There are a few others that have been having an easy time with LTE on theirs.

Link to comment
Share on other sites

Is airplane mode really necessary? I see everyone else doing it, but for me, switching between LTE/CDMA and CDMA/EvDo works really well. Usually I'm connected to LTE within 1-2 seconds of hitting LTE/CDMA (If I'm in reach of an LTE tower of course.)

 

Whats the news on the Galaxy Nexus? Is it playing nice with LTE? (though I suppose I am running ROMs so that could effect that)

It does, but I've also experienced a bit of hanging on to 3G in an obviously-4G area. I think it just varies. Plus, it doesn't help that I'm usually in a moving car.

Link to comment
Share on other sites

  • 4 weeks later...

I'm having problems with my Mobile Networks -> Connections Optimizer locking up and getting com.android.phone has stopped error. I'm posting this here because I think it has some relationship to what we're doing here...especially since I found the fix was posted on another forum by enormous!

http://forum.xda-developers.com/showthread.php?t=1957107

 

Have others had this problem when trying to go in and change your Mobile Network?

 

Also, enormous... How do you restore it and its data? I'm not sure what to do to fix the issue. I do not have a backup, if that's necessary.

 

A related issue (I think), is that my Tasker toggle scripts are not working currently while this is an issue. I'm guessing its related, but it says its running the 4G LTE Scan, but it won't go in and out from Airplane mode. So I'm guessing this is the reason.

Link to comment
Share on other sites

Did you remove Connection Optimizer with anything? I had used Titanium Backup (TiB) to remove it, and once I had restored the app and it's data I stopped getting the phone stopped error.

 

If you don't have a backup, I could PM you a copy of mine. This might work. But you'd still need TiB to restore it. Let me know if you'd like to try that.

 

Now I just have the Connection Optimizer frozen through TiB and all is well.

 

I would also guess that the issue with Connection Optimizer is why the toggle scripts aren't working.

Link to comment
Share on other sites

No, I didn't remove it. I had this problem with the stock rom, and then installed blaze rom (or something) and it was fine for a while. Not sure if it started when I started using the Tasker script.

 

But yeah if you could send that over, I'll give it a try. I really appreciate it.

 

Sent from my SPH-L710 using Tapatalk 2

 

 

Link to comment
Share on other sites

After reinstalling/reflashing my ROM I continued to have problems.

 

After trying to figure out how the Tasker script worked (I've never played with it, but I am a programmer), I realized that the problem was with a variable %HAVE4G. For whatever reason my phone had %HAVE4G set to 1 all the time. So I added a 'Variable Clear' as step 3 in the Airplane Toggle Widget, right after it clears the %4GSCAN variable.

 

This seems to have the script working properly now on my phone. You can correct me and tell me if this will have any ill effects when I actually do go into 4g coverage or at other times with the script, but as far as I can tell, it may need to clear that variable in new script installs.

 

My guess is that I went into 4G at some point and that variable got stuck in memory. Perhaps I killed the script before leaving 4G and it prevented the script for working correctly thereafter???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...