Discussion of various aspects of developing mobile apps that utilize location-based services, including best practices for saving battery life and data transfer.
10. 10
Last Known Network Location
Per Call Measurement Data (PCMD)
Provided though the Sprint Services Framework
• Location Recorded with
each network connection
• On the order of AFLT quality
• Network initiated location
• Very Low Latency
• Partnering with AirSage
Fast, Inexpensive Network Location
11. 11
Smart Phones & Connection Cards
PDE access is limited because we have no SW control
Legacy Device Use MS-Based Location
• GPS Quality Location
• PDE is accessed every few hours
• Device launched in the last year …
> Maintain initial or pre-fix fix until GPS is available
> The Pre-Fix is a terrestrial quality fix
> Uncertainty will give an indication of the quality
Coming Devices will use gpsOneXTRA
• Also Android 2.2 upgrades
• GPS Quality Location
• No Indoor Capability
Device Based GPS or “Outdoor” Location Only
12. 12
gpsOneXTRA
All new Smart Devices and later, Connection Cards will
take advantage of this predictive ephemeris technology
• No PDE Access
• Ephemeris download good for up to 7 days
• Accuracy Degrades over time
> Sprint will update every 48 hours
• If Device has strong signal it will go into an Autonomous
mode with no degraded accuracy
• Each download is approximately 38.5 Kbytes
• Autonomous GPS functionality when out of coverage
• Application can request refresh of assistance data
> LocationProvider.sendExtraCommand()
Device Based A-GPS Solution
13. 13
Android Location
GPS Provider
• Legacy Devices
– MS-Based with pre-fix capability
• New devices use gpsOneXTRA
– Starting with LG LS670 launching 31 October
Network Provider
• Google / OEM prerogative
– Sprint Cell Tower Location
– Google WiFi Location
– Google Network Data
GPS and Network Capabilities
14. 14
Cell Tower to Cell Sector conversion
Sprint broadcast CLM (Course Location Message)
• Current Broadcast
> Longitude / Latitude of the cell tower
• Next year’s Broadcast
> Longitude / Latitude the Cell Sector Centroid
• Accessible on Android and Blackberry devices
More accurate and always available
12.56 Square Miles 3.14 Square Miles
2 Miles
1 Mile
A = π R2
15. 15
Carrier Network is Import for CLM
Some Carriers broadcast are suspect
•Latitude / Longitude all zeros
•A group all the same
•Reversed Polarity
Sprint maintains accurate CLM on Cell Tower Broadcast
•Sample Code
TelephonyManager tm = (TelephonyManager)
this.getSystemService(Context.TELEPHONY_SERVICE);
if(tm.getNetworkOperatorName().equalsIgnoreCase("SPRINT"))
{
//you are on the Sprint network
}
16. 16
Femto Cell Location
Same as CLM from the tower only more accurate
• User Network Provider/CLM (Course Location
Message/Cell Tower Broadcast)
• 50 meters accurate
• Femto Cells NID 501, 502 and 503
• Sample Code
Available on Device Based and Network Based Location
TelephonyManager tm = (TelephonyManager)
getSystemService(Service.TELEPHONY_SERVICE);
// Call below requires permission ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION
CellLocation cl = tm.getCellLocation();
// check to see if the instance is CDMA
if (cl instanceof CdmaCellLocation) {
// yes – proceed to read CDMA specific values
CdmaCellLocation cdmaCl = (CdmaCellLocation) cl;
int baseStationId = cdmaCl.getBaseStationId();
int nid = cdmaCl.getNetworkId();
int sid = cdmaCl.getSystemId();
18. University of South Florida
Research
• Improve efficiency of location-based services through intelligent
software
• Create innovative location-aware applications
Education
• Train future workforce in mobile information systems software
development through:
> Research assistantships
> Classroom education
Commercialization
• Indentify commercial partners
• License relevant technology
• Ongoing partnership for research and career track for students
18
Location-Aware Information Systems Lab
19. University of South Florida
• First navigation app for public
transportation using GPS-enabled
mobile phones
• Alert user when to get off the bus with
audio, visual, and tactile prompts
> “Get Ready…”
> “Pull Cord Now!”
• Target simplicity, with cognitively disabled
in mind
• Successful field testing at five Florida
transit agencies
19
Working with Industry for Real-world Solutions
Dajuta has partnered with USF to launch the
“Travel Assistance Device (TAD)”
20. GPS Data Characteristics Can Vary
20
Two major influences
1. Mobile Device Hardware & Software
> GPS hardware sensitivity
> Antenna quality and device integration
> Assisted vs. Unassisted GPS
> MS-based vs. gpsOneXTRA
> Firmware/software filters
2. Environment
> Indoor / Outdoor
> “Urban Canyons”
> Building materials
> Shielding by enclosure (e.g., purse, car)
21. Benchmarking GPS accuracy is useful
21
Environment: Indoor, 2nd floor, on desk near window, Tampa, Fl
Samsung Moment HTC EVO 4G172 meters
95th percentile: 550m
68th percentile: 398m
50th percentile: 335m
Categorize devices for similar LBS app performance
172 meters
22. 22
29.7 meters HTC EVO 4GHTC Hero
Environment: Indoor, 2nd floor, on desk near window
29.7 meters
23. Android LocationListener
23
Allows app to request position updates
LocationListener has three primary settings:
• “provider” – positioning technology (e.g. GPS, NETWORK)
• “minTime” – requested time (milliseconds) between location updates
• “minDistance” – requested distance (m) that triggers updates
Behavior of devices can vary
• Phone may not always follow given “minTime” between updates
> If phone can’t get a GPS fix, it may not update for a long period of
time
> Some platforms ignore “minTime” setting and frequently update
even if “minTime” is a large value
– Can have a significant impact on battery life!
Don’t make time assumptions based on number of updates
• E.g., I’ve set minTime = 4 sec., I’ve gotten 5 updates, so 20 seconds
have passed
• Instead, check the system and/or location timestamps
24. Android LocationListener
24
“minTime” behavior for GPS
Setting “minTime”, “minDistance” = 0 provides updates as
frequently as possible
On some Android devices, extensive background tracking
may require registering/canceling LocationListener, or
filtering data from API, to achieve desired behavior
Device Obeys “minTime”? Requires extra code
Motorola i1 Yes No
HTC Hero Yes* Optional*
HTC EVO 4G Yes* Optional*
Samsung Moment Yes* Optional*
Samsung Epic 4G Yes* Optional*
* Has unexpected behavior – see next slide
25. Android LocationListener
• Samsung Epic/Moment, HTC Hero/EVO update every
second for ~9-11 GPS fixes, then sleep for “minTime”
Ex. Using “minTime = 60 seconds”:
25
“minTime” behavior for GPS
0
10
20
30
40
50
60
70
80
90
1 12 23 34 45 56 67 78 89 100 111 122 133 144 155 166 177 188 199 210 221 232
GPS Fix ID
TimeBetweenFixes(seconds)
26. Android LocationListener
26
Useful Apps for Development and Testing
“MyTracks”:
• Open-source Android GPS tracking app with many features
> Can record GPS and export to GPX, KML, CSV, TCX
> See how LBS features are implemented in code
> http://code.google.com/p/mytracks/
“OldTracks”:
• Implements a “Mock” LocationProvider by loading GPX file
> Your app registers for LocationListener updates (i.e., GPX
file) played back by “OldTracks” provider
> http://www.cl.cam.ac.uk/~acr31/android
List of available
LocationProviders
on device
27. Use GPS Sparingly to Save Battery Life
27
0
5
10
15
20
25
30
35
40
45
4 15 30 60 150 300
BatteryLife(hours)
Interval Between GPS Fixes (sec)
Impact of Interval Between GPS Fixes on Battery Life
Sanyo Pro 200
Sprint CDMA
EV-DO Rev. A
network
28. Pseudo-code for “GPS Auto-Sleep”
if (Moving){
-Decrease LocationListener “minTime”
} else{
if(Stopped for a reasonable amount of time){
-Increase LocationListener “minTime”
}
}
• Useful for background tracking applications
• Determining whether you’re moving or not can be difficult
• Alternate approach for Android v2.2 and higher:
> Use “PASSIVE” LocationProvider (instead of “GPS”)
– Only updates your app if another app or service requests a
location
– “Scavenges” locations off other apps
– But, no guaranteed updates
28
30. 30
It is Possible to Remove GPS Outliers
•Beware – you will get outliers, more common on first
few fixes as number of satellites in view changes
•The Kalman Filter functions in a recursive fashion that
works well online with real-time GPS data
•Open-source Kalman Filters on the web:
•http://tinyurl.com/27c86v3
•http://tinyurl.com/33ydrxm
Modified
Kalman
Filter
-82.5
-82.45
-82.4
-82.35
-82.3
1
15
29
43
57
71
85
99
113
127
141
155
169
183
197
211
Noisy Data
-82.5
-82.45
-82.4
-82.35
-82.3
1
15
29
43
57
71
85
99
113
127
141
155
169
183
197
211
Less Noisy Data
Outliers No Outliers!
31. 31
Lightweight RESTful web services are preferred to XML-
based SOAP implementations
POST /busstoparrival/busstopws.asmx HTTP/1.1
Host: 73.205.128.123
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetNextNVehicleArrivals"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetNextNVehicleArrivals xmlns="http://tempuri.org/">
<n>int</n>
<RouteID>int</RouteID>
<DirectionCodeID>int</DirectionCodeID>
<BusStopID>int</BusStopID>
<TripID_External>string</TripID_External>
</GetNextNVehicleArrivals>
</soap:Body>
</soap:Envelope>
SOAP Request via HTTP
GET /busstoparrival/busstopws.asmx/GetNextNVehicleArrivals?
n=string&RouteID=string&DirectionCodeID=string
&BusStopID=string&
TripID_External=string HTTP/1.1 Host: 73.205.128.123
RESTful HTTP Request
•3.7 times more characters
using SOAP!
•Plus, many mobile platforms
don’t natively support SOAP
• Java ME
• Android
•If you have a choice, use
RESTful web services
Accessing Web Services from Phones
32. 0
5
10
15
20
25
30
4 15 30 60
BatteryLife(hours)
Interval Between Wireless Transmissions (s)
JAX-RPC HTTP-POST
REST-ful Web Services Save Energy
32 32
Motorola i580 - iDEN network
Impact of JAX-RPC and HTTP-Post Operations on Device Battery Life
33. http://code.google.com/apis/protocolbuffers/docs/javatutorial.html
33
Creating your own remote procedure
calls (RPC)?
Consider going really light-weight with Protocol Buffers
•Are 3 to 10 times smaller, 20 to 100 times faster than XML
•You implement a simple .proto file:
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2;}
}
•Java library handles serializing data into binary format
for transmission, de-serializing when receiving data
34. If you don’t need 100% delivery,
consider User Datagram Protocol (UDP)
34
Impact of Transmission Protocols on Battery Life
UDP does not provide handshake with server for packet
“reliability”, but occasional loss of location data may be
reasonable (< 3% fixes lost in tests)
35. Receiving is cheaper than Transmitting
If you’re exchanging information with a server, try to push
it to the device, rather than have the device pull it
35
Device Transmitting vs. Receiving
Receive
Motorola i877 Java ME using UDP
Transmit
36. Critical Point Algorithm
36 36
All GPS Points Critical Points Only
Try to send only necessary data from a device to a server
37. Completely open-source
trip planning solution
• From map tiling to
routing software
• in Java/Javascript
Uses OpenStreetMap data
• Wikipedia for
geographic
information
• Free data
Can be integrated with
device location to
create new products
37
opentripplanner.org
OpenStreetMap
http://www.openstreetmap.org/
38. Questions?
Sean J. Barbeau, M.S. Comp.Sci.
Research Associate
Center for Urban Transportation Research
University of South Florida
813.974.7208
barbeau@cutr.usf.edu
USF Location-Aware Information Systems Lab
http://www.locationaware.usf.edu/
38
Sprint has partnered with many industry leading Solution Enablers. Along with having access to Sprint services directly, Solution Enablers provide many value added services to help a customer deliver an optimized solution that meets their needs. Some of these value added services include: Custom Development Capabilities (mobile, server) and ongoing development support, System Integration (abilty to integrate with existing back-end systems, Hosting/Monitoring of the solution, User privacy opt-in/opt-out management (being compliant with Sprint and Legal mandates), Customer Care support, and other Web Services and web 2.0 capabilities.