Lab : Network Security
Development & Deployment of Local-Based Service Application on Mobile Devices
Telecommunications Program
Part I: Objective
The goal of this lab is to introduce the student to a development of a local-based service application for wireless devices such as mobile phone and the personal digital assistants (PDAs). Student will learn the capabilities of JSR 179 Locating API and how to use it in an application. Student should also be capable of acquiring location information and performing calculations with this data, much as one would with any standard GPS device.
Part II: Equipment List
1. A personal computer with Windows OS
2. Eclipse 3.2 SDK with Java 2 Standard Edition Development Kit (JDK) Version 1.5.0 or higher installed and EclipseME plug-in
3. Java 2 Micro Edition Wireless Toolkit Version 2.5 for CLDC or higher
Part III: Introduction
Location-based services (LBS) provide users of mobile devices personalized services tailored to their current location. They open a new market for developers, cellular network operators, and service providers to develop and deploy value-added services: advising users of current traffic conditions, supplying routing information, helping them find nearby restaurants, and many more.
Location API for J2ME (JSR 179) is a J2ME Optional Package that enables mobile location-based applications for resource limited devices (referred to as ’terminals’ in the following). The API is designed to be a compact and generic API that produces information about the present geographic location of the terminal to Java applications. This API covers obtaining information about the present geographic location and orientation of the terminal and accessing a database of known landmarks stored in the terminal.
The Location API for J2ME is designed as an Optional Package that can be used with many J2ME Profiles. The minimum platform required by this API is the J2ME Connected, Limited Device Configuration (CLDC) v1.1. The API can also be used with the J2ME Connected Device Configuration (CDC). (Note that due to using the floating point datatypes in this API, it can’t be used with CLDC v1.0.)
Location-based services answer three questions: Where am I? What's around me? How do I get there? They determine the location of the user by using one of several technologies for determining position, then use the location and other information to provide personalized applications and services. As an example, consider a wireless 911 emergency service that determines the caller's location automatically. Such a service would be extremely useful, especially to users who are far from home and don't know local landmarks. Traffic advisories, navigation help including maps and directions, and roadside assistance are natural location-based services. Other services can combine present location with information about personal preferences to help users find food, lodging, and entertainment to fit their tastes and pocketbooks.
There are two basic approaches to implementing location-based services:
1. Process location data in a server and deliver results to the device.
2. Obtain location data for a device-based application that uses it directly.
To discover the location of the device, LBS must use real-time positioning methods. Accuracy depends on the method used.
Locations can be expressed in spatial terms or as text descriptions. A spatial location can be expressed in the widely used latitude-longitude-altitude coordinate system. Latitude is expressed as 0-90 degrees north or south of the equator, and longitude as 0-180 degrees east or west of the prime meridian, which passes through Greenwich, England. Altitude is expressed in meters above sea level. A text description is usually expressed as a street address, including city, postal code, and so on.
Applications can call on any of several types of positioning methods.
• Using the mobile phone network: The current cell ID can be used to identify the Base Transceiver Station (BTS) that the device is communicating with and the location of that BTS. Clearly, the accuracy of this method depends on the size of the cell, and can be quite inaccurate. A GSM cell may be anywhere from 2 to 20 kilometers in diameter. Other techniques used along with cell ID can achieve accuracy within 150 meters.
• Using satellites: The Global Positioning System (GPS), controlled by the US Department of Defense, uses a constellation of 24 satellites orbiting the earth. GPS determines the device's position by calculating differences in the times signals from different satellites take to reach the receiver. GPS signals are encoded, so the mobile device must be equipped with a GPS receiver. GPS is potentially the most accurate method (between 4 and 40 meters if the GPS receiver has a clear view of the sky), but it has some drawbacks: The extra hardware can be costly, consumes battery while in use, and requires some warm-up after a cold start to get an initial fix on visible satellites. It also suffers from "canyon effects" in cities, where satellite visibility is intermittent.
• Using short-range positioning beacons: In relatively small areas, such as a single building, a local area network can provide locations along with other services. For example, appropriately equipped devices can use Bluetooth for short-range positioning.
In addition, location methods can connect to a mobile position center that provides an interface to query for the position of the mobile subscriber. The API to the mobile position center is XML-based. While applications can be fully self-contained on the device, it's clear that a wider array of services is possible when a server-side application is part of the overall service.
Some applications don't need high accuracy, but others will be useless if the location isn't accurate enough. It is okay for the location of a tourist walking around town to be off by 30 meters, but other applications and services may demand higher accuracy.
The Location API for J2ME specification defines an optional package, javax.microedition.location, that enables developers to write wireless location-based applications and services for resource-limited devices like mobile phones, and can be implemented with any common location method. The compact and generic J2ME location APIs provide mobile applications with information about the device's present physical location and orientation (compass direction), and support the creation and use of databases of known landmarks, stored in the device.
JSR 179 requires the Connected Device Configuration (CDC) or version 1.1 of the Connected Limited Device Configuration (CLDC). CLDC 1.0 isn't adequate because it doesn't support floating-point numbers, which the API uses to represent coordinates and other measurements. The Location API doesn't depend on any particular profile -- it can be used with MIDP or the Personal Profile.
The hardware platform determines which location methods are supported. If it doesn't support at least one location provider, LBS won't be possible. Applications can request providers with particular characteristics, such as a minimum degree of accuracy. Some location methods may be free; others may entail service fees. The application should warn the user before any charges are incurred.
It is up to the application to determine the criteria for selecting the location method. Criteria fields include: accuracy, response time, need for altitude, and speed. Once the application obtains a LocationProvider instance that meets the criteria, it can use that object to obtain the location, in either of two ways:
• Invoke a method synchronously to get a single location.
• Register a listener and get periodic updates at application-defined intervals.
The Location class abstracts the location results. Its object contains coordinates, speed if available, textual address if available, and a time stamp that indicates when the location measurements were made.
Coordinates are represented by either of two classes:
• A Coordinates object represents a point's latitude and longitude in degrees, and altitude in meters.
• A QualifiedCoordinates object contains latitude, longitude, and altitude, and also an indication of their accuracy, represented as the radius of an area.
A landmark is a location associated with a name and a description. Landmarks can be stored in a device-based database, where they can be shared among all J2ME applications. Landmarks can store frequently used locations: home, office, favorite restaurants, and so on. Each is represented by a Landmark instance, and the database by a LandmarkStore. You can create multiple named LandmarkStores to group locations into categories such as cinemas, museums, or customer sites.
If the device includes a compass, the application may be able to determine not only its location but its orientation, which is useful in navigational applications. The Orientation class represents the device's azimuth as an angle from due north, which the application can easily convert to a compass direction.
Part IV: Software Preparation (Optional)
1. Download and install the Eclipse SDK 3.2 from the Eclipse homepage (). After it's downloaded, extract the contents into a directory of your choice.
2. Download and install the Sun Java Wireless Toolkit from the Sun Java Wireless Toolkit homepage ().
3. Install the EclipseME plug-in. EclipseME is an Eclipse plug-in that connects wireless toolkits to the Eclipse SDK. Integrating the Sun Java Wireless Toolkit with Eclipse is much easier with the EclipseME plug-in installed. The steps to install the plug-in and add it to your Eclipse IDE are:
1. Open the Eclipse IDE from the location you extracted its files to. You can specify your own workspace location; I used e:\LBSSample:
Figure 1. Select a workspace
[pic]
2. In Eclipse, navigate to Help > Software Updates > Find and Install.
3. From the Install/Update window, select the Search for new features to install radio button and click Next.
Figure 2. Search for features to install
[pic]
4. Click New Remote Site on the Installation screen. You'll see two fields, one for the name of the feature or plug-in you want to install, and one for its URL:
Figure 3. Select the update site
[pic]
5. Enter EclipseME for the name and for the URL and click OK.
Figure 4. Enter the feature name and URL
[pic]
6. Ensure the check box for "EclipseME" is selected and click Finish to search the EclipseME update site for the EclipseME plug-in.
Figure 5. Search for the EclipseME plug-in
[pic]
7. The search results return the EclipseME plug-in. Select the EclipseME 1.5.5 checkbox and click Next.
Figure 6. Select the EclipseME plug-in from the search results
[pic]
8. Read and accept the EclipseME license agreement and click Next.
Figure 7. Accept the EclipseME license agreement
[pic]
9. By default the EclipseME feature is installed in the Eclipse SDK root. Click
Finish to complete the installation.
Figure 8. Complete the installation
[pic]
9. You might get an unsigned warning about the EclipseME feature. Go ahead and click Install if your screen matches the one shown in Figure 9.
Figure 9. An unsigned warning -- click Install
[pic]
11. Installation of the EclipseME plug-in is complete. It is recommended that you click Yes to restart Eclipse.
Figure 10. Restart Eclipse
[pic]
4. Configure the EclipseME feature and Eclipse SDK
Next, you will configure the EclipseME plug-in and Eclipse SDK for J2ME development. If you haven't already started Eclipse do so now. Then select Preferences from the Eclipse Window menu.
1. In the Eclipse Preferences window, expand J2ME and select Device Management, as shown in Figure 11. Click the Import button on the right side of the window.
Figure 11. The Eclipse Preferences window
[pic]
2. Import the WTK devices:
1. Enter the root directory of the WTK 2.5 install. (I installed my WTK 2.5 into c:\WTK25).
2. Click Refresh. • Your result should look like what you see in Figure 12.
3. Click Finish to import the WTK devices. You don't need all these devices, but it doesn't hurt to have them.
Figure 12. J2ME device import list
[pic]
3. Configure the default device and apply the changes as follows:
1. Select the DefaultColorPhone default check box as shown in Figure 13 below.
2. Click Apply in the Device Management window to complete the WTK 2.5 device import.
Figure 13. Specify the devices to be used
[pic]
3. Expand the "Java" item in the left pane and select Debug:
1. Uncheck the Suspend execution on uncaught exceptions and Suspend execution on compilation errors options.
2. Increase the "Debugger timeout (ms)" field to 15000.
3. Click OK to save your changes and close the window.
Figure 14. Configure Java debugging
[pic]
Part V: Location API (JSR 179)
Using the Location API to determine the geographical location of a device is straightforward:
1. Verify that your target platform has the optional Location API installed.
2. Establish a LocationProvider instance.
3. Capture location information.
In addition, there are two optional steps:
1. Create a LocationListener to listen for location update events.
2. Create a ProximityListener to notify the application when the device is within a defined range of a specific location.
Step 1: Verify the Location API package
To use the Location API to acquire location coordinates, you must verify that a device has the optional Location API installed. Check the system property microedition.location.version as shown in Listing 1.
Listing 1. Location package discovery
[pic]
Step 2: Establish a LocationProvider instance
To retrieve coordinates you must first establish a LocationProvider instance specifying a Criteria object. As the name implies, the Criteria object contains the specific criteria you have determined the LocationProvider must match. Listing 2 shows how to establish a LocationProvider instance. The default settings for the Criteria object are shown in Table 1.
Listing 2. Establishing a LocationProvider instance
[pic]
Table 1. Default values for the Criteria class
[pic]
Step 3: Capture location information
[pic]
Next, you'll use the Location.getQualifiedCoordinates() method to retrieve a QualifedCoordinates object from your target device. With the QualifedCoordinates object, you can retrieve the longitude, latitude, and altitude in WGS84 datum using the methods QualifiedCoordinates.getLongitude(), QualifiedCoordinates.getLatitude(), and QualifiedCoordinates.getAltitude().
After you have a target device's coordinates, you can use future coordinate-capture events to calculate its heading/azimuth (in degrees) and distance (in meters) using
Coordinates.azimuthTo(Coordinates to) and Coordinates.distance(Coordinates to). You can also retrieve a device's speed in meters-per-second (m/s) by using the method Location.getSpeed().
In summary, you can now capture the location and speed of a target device. Using this acquired data, you can calculate the device's distance and heading. Listing 3 shows the acquisition of a device's location and speed along with the calculation of its directional heading/azimuth and distance traveled.
Listing 3. Location and speed acquisition with distance and heading calculation
[pic]
The following optional steps can enhance or enable the functions of certain types of applications.
Optional step 1: Setting the LocationListener
[pic]
Tracing routes and displaying live information to a device end-user requires capturing or updating location details at timed intervals. The Location API provides a LocationListener interface for this purpose. The LocationListener is registered with a LocationProvider, with a defined interval at which it attempts to capture location details.
To register a LocationListener, use the method LocationProvider.setLocationListener (LocationListener listener, int interval, int timeout, int maxAge).
LocationListener methods
The LocationListener has two methods:
1. locationUpdated(LocationProvider provider, Location location)
2. providerStateChanged(LocationProvider provider, int state)
The locationUpdated(LocationProvider provider, Location location) method is called by the LocationProvider at the defined interval for the registered LocationListener providing the updated location.
The providerStateChanged(LocationProvider provider, int state) method is called on state changes in the LocationProvider. The states include: AVAILABLE, TEMPORARILY_UNAVAILABLE, and OUT_OF_SERVICE.
Optional step 2: Setting the ProximityListener
The ProximityListener interface provides the necessary functions to listen and notify your application if the device enters a defined proximity. The proximity is defined as a location Coordinates and a radius (positive value of type float).
To register a ProximityListener, use the LocationProvider.addProximityListener (ProximityListener listener, Coordinates Coordinates, float proximityRadius) method.
ProximityListener methods
The ProximityListener has two methods:
1. monitoringStateChanged(boolean isMonitoringActive)
2. proximityEvent(Coordinates coordinates, Location location)
The monitoringStateChanged(boolean isMonitoringActive) method is called by the listener to notify the application of a change in state. The change in state is a boolean meaning that the ProximityListener has either become active or inactive. In the inactive state, the listener is still registered but is inactive for some reason determined by the provider.
The proximityEvent(Coordinates coordinates, Location location) method is called by the listener, notifying the application that the device has entered the defined proximity boundary. With this notification, the coordinates of the defined proximity are given along with the current coordinates of the device.
Part VI: Develop a location-based application
Create the J2ME project
Create a Java ME project for building the example application as follows:
1. From the Eclipse File menu, select New > Project...
• Expand the J2ME item in the list, select J2ME Midlet Suite, and click Next.
Figure 15. Select the J2ME MIDlet suite
[pic]
2. Enter LBSSample in the project wizard's Project Name field and click Next.
• You can either leave the "Use default location" box checked or uncheck the selection and define your own project-location path.
Figure 16. Name the project
[pic]
3. No further configuration is required, click Finish to complete the process of creating the new project.
Figure 17. Click Finish to complete the process
[pic]
Create a source folder
Next, you'll create a source folder in the J2ME LBSSample project:
1. Right-click on the LBSSample project and select New > Source Folder
2. Enter src in the Folder Name field.
3. Click Finish.
Figure 18. Create a source folder
[pic]
Import the LBS MIDlet class
To run an application on a Java embedded device, you must write a MIDlet. For the purpose of this tutorial, you will simply import the tutorial MIDlet class LBSMIDlet into the LBSSample project. After you have imported the LBSMIDlet, I will walk you through its implementation of the JSR 179 Location API. Import the base LBSSample MIDlet class as follows:
1. Right-click on the LBSSample project and select Import.
1. From the "Select an import source" list, expand General and select Archive File.
2. Click Next.
Figure 19. Select the Import source
[pic]
4. Import the source folder from the archive:
• Enter the path where you unzipped the tutorial zip file and PositionTestApp.jar.
• Expand the archive tree and de-select the "com" and "META_INF" checkboxes as shown in Figure 20.
• Click Finish to import the LBSMIDlet.
Figure 20. Import the LBSMIDlet
[pic]
The LBSSample MIDlet
The LBSSample MIDlet is programmed to do the following:
• Verify that the target device supports the Location API.
• Create a LocationProvider instance with default Criteria for the target device.
• Set a LocationListener and ProximityListener for the device.
• Capture location information and calculate the results.
In the next sections you'll see how each of these functions is implemented in the MIDlet.
Verify Location API support
The LBSSample MIDlet uses the system property microedition.location.version to discover if a target device supports the Location API, as shown in Listing 4.
Listing 4. Check for Location API support
[pic]
Create a LocationProvider instance
For devices supporting the Location API, the LBSSample app then creates a LocationProvider instance with default Criteria, as shown in Listing 5.
Listing 5. Create a LocationProvider instance
[pic]
Set the LocationListener and ProximityListener
The application sets the LocationListener and ProximityListener when a device end-user elects to start the application or create a waypoint. Code for this is displayed in bold in Listing 6.
Listing 6. Setting the LocationListener and ProximityListener
[pic]
[pic]
LocationListener settings
The LocationListener is set with a listening interval of two seconds. The timeout and maxage parameters are set to the provider defaults. You can see the LocationListener settings in Listing 7.
Listing 7. The setListener method
[pic]
ProximityListener settings
The waypoint and radius are specified by the end-user, then passed to the setProximity method to enable the ProximityListener. In Listing 8 the ProximityListener is added to the provider.
Listing 8. The setProximity method
[pic]
Receiving location events
The LocationListener provides location updates using its locationUpdated method, as shown in Listing 9.
Listing 9. The locationUpdated method
[pic]
Receiving proximity events
The ProximityListener provides an event using the proximityEvent method in Listing 10. Note that proximityEvent uses a separate thread to avoid any future thread blocking.
Listing 10. The proximityEvent method
[pic]
Location coordinates and calculations
The getLocation method, shown in Listing 11 is used to get location coordinates and calculate a device's distance and azimuth. All details are then updated on the J2ME device screen.
Listing 11. The getLocation method
[pic]
Part VII: Test the application
Finally, you're ready to test the application. In this section you will learn how to do that using the Sun Java Wireless Toolkit with a preset device route.
Configure the run settings
First, you'll configure the run settings for both the MIDlet and the emulator.
1. Select Run from the Eclipse Run menu.
2. Enter LBSSample config in the Name field.
3. Choose the MIDlet radio in the Executable section and enter com.myfistlbsapp.LBSMIDlet in the textbox. (See Figure 21 below.)
4. Switch to the Emulation tab. (See Figure 22.)
5. From the "Security Domain" drop-down list, select manufacturer. (See Figure 21.)
6. Click Apply.
7. When you click Run, your MIDlet and emulator windows should look as shown in Figure 21 and Figure 22.
Figure 21. Run configuration for the MIDlet
[pic]
Figure 22. Run configuration for the emulator
[pic]
Create a waypoint and set the ProximityListener
Next, you set a waypoint and radius for the ProximityListener. The ProximityListener notifies you when the device has entered the defined area.
1. Click the Menu button on the phone emulator and select New Waypoint. The resulting screen is shown in Figure 23.
2. Enter the following values in the Create Waypoint Screen:
• Latitude: 14.398338
• Longitude: 50.100303
• Altitude: 310
• Radius: 100
3. Click the corresponding button for Create on the emulator.
4. Click the corresponding button for Location on the emulator.
Figure 23. Create a waypoint and Figure 24. The phone emulator's MIDlet menu
[pic] [pic]
Load the preset route
A preset route makes it possible to test your application's responses to listener events. Your next step is to load the preset route.
1. From the phone emulator's MIDlet menu, choose External Events, as shown in Figure 24:
2. Enter the following value in location blocks as the origin
• Latitude: 14.398338
• Longitude: 50.100303
• Altitude: 310
3. Load the citywalk.xml sample route:
1. In the External Events window click Browse, as shown in Figure 25
Figure 25. Browse the External Events window
[pic]
1. In the Browsing window, browse to C:\WTK2.5.2\apps\CityGuide\citywalk.xml and click Open, as shown in Figure 26:
Figure 26. Select a route
[pic]
2. Back in the External Events window, click Start at the bottom.
Run the example
Everything is set up. Now all you need to do is run the application in the emulator and listen for location updates or proximity events.
1. Click the button corresponding with the menu option on the display of the phone emulator.
2. Select Start.
3. You should now see the target device's location coordinates with speed, heading, and direction details similar to those in Figure 27.
Figure 27. Running the LBSSample application
[pic]
Part VIII: An LBS Demo.
1. Open Sun Java Wireless Toolkit
2. Click Open Project to open an example project that comes with the toolkit
3. Select CityGuide from the list and click Open Project
4. Click Run
5. Press launch button and Next to execute the application
[pic]
6. Open external events and preset route: citywalk.xml (the same as that in the last part) and then click play to run the script
7. Watch the device’s screen. The man icon indicates where the device is on the map. Interesting places will flash when the device is near the places.
8. You can pause the walk (by clicking pause button on the external events window) and see the information of the places by pressing menu button and choosing detail.
Part IX: Assignments
Use the first application to answer the following.
1. How far is it between SIS building and Hillman Library?
_________________0.6km______________________________________________
2. If a SIS student needs to go to Hillman Library to look for a book, meet a friend at Katz School of Business, buy a book at PITT book store and then come back to SIS for another class, how far does he need to walk?
_____________________2.1km_______________________________________
Note:
Addresses:
• School of Information Science: 135 N Bellefield Ave Pittsburgh, PA 15213
• Hillman Library: 3960 Forbes Ave # 271 Pittsburgh, PA 15260
• Katz School of Business: Roberto Clemente Dr Pittsburgh, PA 15260
• PITT book store: 4000 5th Ave Pittsburgh, PA 15213
You can find the specific coordinates of places from
Questions
1. What is a waypoint?
_______A waypoint is a reference point with specific latitude, longitude and altitude coordinates______________________________________________________________
2. What is the street address and phone number of National Theater in the LBS Demo?
________702 Singers Str. Real City 16001 Phone Number 60406322______________
3. How would the answer be different if we were to hold an actual device and really walk to the places to measure the distance in the assignment?
_______The distance would be longer because the distance we got in the assignment is the direct distance between the places calculated from the coordinates. But if we used the actual device and walked from a place to another the distance would be the walking distance which would be longer.______________________________________________
4. Which method do we need to modify in order to make the man icon in the demo move smoother?
________ The LocationListener is registered with a LocationProvider, with a defined___ interval at which it attempts to capture location details.____________________________
References:
Qusay H. Mahmoud, J2ME and Location-Based Services, March 2004. Available Online at
1. JSR 179 Expert Group, Location API for JAVA 2 Micro Edition, February 2006.
2. Kevin L Sally, Develop a location-based service application using JSR 179, October 2006
3. Martin Brehovsky and Brian Leonard, NetBeans Location Based Services Mobility Demo, January 2006.
-----------------------
Student Name: _______________________
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- disable windows security network credentials
- windows security enter network credentials 10
- windows security enter network password
- windows security network credentials password
- network security engineer certifications
- network security certification jobs
- network security engineer certification
- windows 10 windows security enter network credentials
- change windows security network credentials
- windows security network credential
- windows 10 security network credentials
- windows 10 security enter network credentials