Project Report - GPS Tracker
Project Report - GPS Tracker
Pascal Bruegger
Msc Course - Ubiquitous Computing
University of Fribourg, Switzerland
March 9, 2006
1
Contents
1 Backgrounds 4
1.1 Motivations and Goals . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 State of the art . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Functional Description 6
2.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Operational Instructions 9
3.1 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.1 Components . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.2 Software Modules . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.3 EJB container: description of Entity Bean and the Session 11
3.4.4 WEB container: description of the JSPs and Servlets . . . 11
3.4.5 Database: description of the tables and relations . . . . . 16
3.4.6 Midlet: description of the Java mobile application . . . . 18
3.4.7 Implementation status . . . . . . . . . . . . . . . . . . . . 19
3.4.8 Communication between modules . . . . . . . . . . . . . . 19
3.4.9 Package’s structure . . . . . . . . . . . . . . . . . . . . . . 20
4 User’s guide 21
4.1 Installation procedures . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Download and files locations . . . . . . . . . . . . . . . . . . . . . 22
4.3 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 Web Client . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.2 Midlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5 Evaluation 25
5.1 Adherence with the specification . . . . . . . . . . . . . . . . . . 25
5.2 Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.3 Known Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6 Future Works 27
6.1 To do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2 Possible extensions . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7 Project Management 30
7.1 Team composition . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.2 Individual job description . . . . . . . . . . . . . . . . . . . . . . 30
7.3 Effective individual contributions . . . . . . . . . . . . . . . . . 31
2
List of Figures
1 GPS traker: General schema . . . . . . . . . . . . . . . . . . . . 4
2 Use case of the application . . . . . . . . . . . . . . . . . . . . . . 5
3 General Architecture of GPS Tracker application . . . . . . . . . 10
4 Entity Bean: Class diagram . . . . . . . . . . . . . . . . . . . . . 12
5 Session Bean and Service Locator: Class diagram . . . . . . . . . 13
6 EJB Container - Complete schema of classes with associations . . 14
7 Web Container - Schema of JSPs and Servlets with associations
for web browser access . . . . . . . . . . . . . . . . . . . . . . . . 15
8 Servlets - Access from a mobile device to the EJB using the servlets 16
9 Midlets - complete architecture of the mobile application . . . . . 18
10 Midlets - architecture of the mobile application using the Position
list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
11 Communication between the different modules of the application 20
12 User navigation : site map . . . . . . . . . . . . . . . . . . . . . . 23
13 Web Client: registration . . . . . . . . . . . . . . . . . . . . . . . 24
14 Web Client: login . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
15 Web Client: Navigation page . . . . . . . . . . . . . . . . . . . . 26
16 Web Client: Drawing the track on the Swiss Topo map . . . . . . 27
17 Midlet: Main menu . . . . . . . . . . . . . . . . . . . . . . . . . . 28
18 Midlet: Create a track . . . . . . . . . . . . . . . . . . . . . . . . 29
19 Midlet: Send position and server response . . . . . . . . . . . . . 30
3
Note of the author: Before starting the study of this report the reader must
have a good understanding of the J2EE and EJB technologies. The concept of
the project is presented without explicit specifications of EJB 2.1. If any doubt
on J2EE technology, refer to [9, 2].
1 Backgrounds
1.1 Motivations and Goals
Security is very important in some activities. Freeride, mountain walking or
climbing, paragliding are those where accidents can be serious or fatal. Having
the possibility to follow physically the position of a person on regular basis can
be comfortable for family, relatives or others.
The project is meant to propose a simple and portable solution for people to get
traced during a trip. The application is web based and should be available for
every people who have the possibility to
1. Run a small Java application on its mobile phone.
4
1.2 State of the art
As mentioned above, there are already a lot of applications which use the geo-
positioning. Garmin, one of the famous GPS manufacturer, proposes maps of
almost every countries in the world ready to be download into their panel of
GPS devices. Different kind of applications for different kind of public: road
maps and tracking, topologic maps for technical job like geologist (for instance),
flight’s map for pilots, etc.
Also it exist, for mountain activities like freeride, hicking, those automatic sig-
nalling systems which switch on as soon as the rider get cought by an avalanche
for example. It transmits a radio signal to the closest relay and indicate the
exact position of the victim. It helps for the search and often save lives. The
portable TomTom GPS proposes a full navigation system with vocal indication.
The list of geo-positioning applications is huge and a simple search on the In-
ternet gives hundred web sites talking about the topic.
The diagram (figure 2) shows the use cases for the application. There are
3 actors, 10 use cases which represent for different action what actors can do
with the system. The use case Start a track is in fact 2 use cases. A track
can be started from the web client or from the mobile application (cell phone
application). The use case Send a position is only available from the mobile
5
application. We will see in the architecture what is done where (mobile vs
server application).
2 Functional Description
2.1 Requirements
The application will follow the use cases described in figure 2. All use cases are
now described formally.
Within the 3 actors, the manager has a special role and is automatically created
with the user Id 1. It can do exactly what a standard user can do but has special
rights that the others don’t have.
The application will allow to do:
1. First Name
2. Last Name
3. Street
4. Zip code
5. City
6. Phone
7. Password
Then the user receives a user Id (integer) and is recorded in the database.
This part is done on the web client side. The password must be more than 4
characters long. Any fields must be empty otherwise the user is not register.
Modification of the user profile. Once logged, the user can modify its
profile using the same data as above and same constraints.
User login This web page is the first one in the system. The user must be
identify in order to access any options. The web page contains two fields:
1. User Id
2. Password
This page proposes the link to the registration web page in case the user is not
yet register.
6
Creation of a track for a given user. The user, once registered, can log in
the system and create a track. There is two possibilities to do it:
1. From the web client application.
2. From the mobile application (mobile phone).
If a new track is started from the mobile application, the user must provide:
1. User Id
2. Password
Then the server will create a new track and be ready to store the future positions
in under this track’s id.
For a track started from the web client, the user can (but it is not mandatory)
give:
1. North coordinates
2. East coordinates
This will represent the first point of the track. The track has a unique identifier
within the system. The time and date when the track is created is taken from
the server’s clock.
Follow a user in real time mode on the Internet. Any person having
the right to watch a user’s track must log in the system under the user’s ID
and password. Then he/she can choose the track to be drawn. A list of the
user’s tracks is available. This is done through the web page. The drawings of
the track are done in two different manners: Swiss Topo 2D maps and Google
Earth. If the track chosen is the current one and drawn in 2D mode, it is
refreshed periodically using a ”refresh time” parameter.
7
Delete a track. The user can delete tracks from a list of tracks. If the track
deleted is the current one then the previous one become again the current track
and all the future positions sent to the server will be save under this track id.
Manager - Delete users. The web page allow the manager to delete users
from a list of register one. This list shows all the available users.
8
3 Operational Instructions
The architecture of project is based on Entreprise JavaBeans technology. The
mobile application is developed in Java 2 Micro Edition.
3.2 Software
The OS where all the following were installed is Windows XP sp2:
1. J2EE Application Server: Sun Java System Application Server Platform
Edition 8.1 2005Q1
2. Entreprise Java Beans 2.1
3. Java Midlet : SUN J2ME Wireless Tool Kit 2.2
4. PointBase free Version: 5.2 ECF build 294
3.3 Hardware
Only two devices where needed and provided by the PAI group:
1. Mobile Phone Nokia
2. GPS EMTAC Bluetooth - GPS Trine
These two hardware were used by Otto Poveda for his part of the development
(communication between GPS and mobile Phone).
9
3.4 Architecture
The technologies used for the project are client-server and web based. The main
platform of development is J2EE. The full description of the language, server
version is describe above. We will not explain in detail how J2EE works and
assume that the reader knows this technology and how the modules are defined.
The general structure of the application is shown in the figure 3.
The application is based on 3-tiers architecture:
3. Database
3.4.1 Components
As shown in the figure 3, there are 3 main components. The client side which
contains an Java Midlet application (loaded in the mobile phone) and the
browsers. The application server which contains the Web container (JSPs and
servlets) and the EJB container where the business logic (Session beans and
Entity beans) stands. The third tier is the database managing the tables where
the entity beans store their values.
10
1. EJB container: description of the Session and Entity Bean
2. WEB container: description of the JSPs and Servlets
3. Database: description of the tables and relations
Note: The definition of the bean classes includes implicitly the different in-
terfaces needed in the J2EE specifications. Also in a class, the standard ejbCre-
ate(), ejbActivate() methods, etc. are underlying (ref [9, 2]).
The application uses the pattern SessionFacade [1]. The client does not
access the entity bean directly but the session bean which provide methods.
Two session beans are described in the figure 5. The pattern Service Locator
has also been implemented in order to separate the search of the entity bean
instance each time the session bean needs it. Finally, the figure 6 describe the
complete component (with associations) of the EJB container:
11
Figure 4: Entity Bean: Class diagram
Servlets. Four servlets are used specifically to interface the EJB container.
1. StartNewTrack.class
2. PostNewPosition.class
3. DrawTrack.class
4. GetPointList.class
The StartATrack servlet receives HTTP requests from the Midlet and calls
the method startRemoteTrack(userId) in the TrackManagementSessionBean. If
the operation is done it sends the a string ”track X has started” (Figure 8).
Same principle is used to send a new position from the mobile device. The servlet
PostNewPosition receives HTTP request and sends HTTP response using the
methods addRemotePosition() in TrackManagementSessionBean. Example of
the doGet in the StartNewTrack is shown under. Here we see the power of the
Session facade. Once the client method is identified, it is very simple to interface
with the entity beans.
12
Figure 5: Session Bean and Service Locator: Class diagram
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
res = data;
}
out.print(res);
try {
trackManagement.remove();
} catch (RemoteException e) {
e.printStackTrace();
} catch (RemoveException e) {
e.printStackTrace();
}
}
13
Figure 6: EJB Container - Complete schema of classes with associations
on the Swiss topo map. The position are saved in this format in the table
tracker position.
Google Earth is using the system WGS84 (deg, min, sec.).
14
Figure 7: Web Container - Schema of JSPs and Servlets with associations for
web browser access
into KML format (Figure 7). The response is in the form of:
response.setContentType("application/keyhole");
and using the MIME type to launch Goople Earth. The KML format is a
XML based format used by Google Earth to describe a track (for instance).
The complete syntax is explain in [4]. Before drawing the track on Google
Earth, we have to translate the Swiss grid format into WGS84 format. This is
done by getListOfPositionByTrackInKMLFormat(track). This method calls the
private method convertSwissGridToWGS84(String[] coordinates) which convert
each points into WGS84 format.
15
Figure 8: Servlets - Access from a mobile device to the EJB using the servlets
16
TABLE TRACKER_ADDRESS (
ID INTEGER NOT NULL CONSTRAINT ADDRESS_PK PRIMARY KEY,
STREET VARCHAR(24) NOT NULL,
ZIP INTEGER NOT NULL,
CITY VARCHAR(24) NOT NULL,
PHONE VARCHAR(12) NOT NULL);
TABLE TRACKER_TRACK (
ID INTEGER CONSTRAINT TRACKER_PK PRIMARY KEY,
DATE DATE NOT NULL,
START_TIME TIME NOT NULL,
END_TIME TIME ,
PERSON_ID INTEGER NOT NULL);
TABLE TRACKER_POSITION (
ID INTEGER CONSTRAINT POSITION_PK PRIMARY KEY,
EAST VARCHAR(8) NOT NULL,
NORTH VARCHAR(8) NOT NULL,
ALTITUDE INTEGER NOT NULL,
TIME TIME NOT NULL,
TRACK_ID INTEGER NOT NULL);
TABLE TRACKER_PRIMEKEY (
ID INTEGER CONSTRAINT PRIMEKEY_PK PRIMARY KEY,
PERSON_ID INTEGER NOT NULL,
ADDRESS_ID INTEGER NOT NULL,
TRACK_ID INTEGER NOT NULL,
POSITION_ID INTEGER NOT NULL);
TABLE TRACKER_LOGIN (
USERID INTEGER CONSTRAINT USERID_PK PRIMARY KEY,
PASSWORD VARCHAR(15) NOT NULL,
PERSON_ID INTEGER NOT NULL);
17
FOREIGN KEY (USER_ID) REFERENCES TRACKER_LOGIN(USERID);
Note: It is supposed that the reader has the necessary knowledge in Java Mi-
dlet application. Otherwise refer to [5, 6, 7, 8].
18
3.4.7 Implementation status
Every module which have been described above are implemented. The only
part of the project not fully implemented is the Midlets and especially the
communication with the GPS device. The communication Bluetooth between
the GPS and the mobile phone has been developed partly (Otto Poveda) but not
integrate into the present implementation. The actual situation is that a class
PositionList is simulating the GPS class and a pre-defined list of gps coordinates
is used to simulate the positions (Figure 10). It is important to realise that the
actual project is only a prototype of what could be the application. A lot of
implementation details and choices (name of methods, security roles, etc) are
not satisfactory or not implemented.
Figure 10: Midlets - architecture of the mobile application using the Position
list
19
Figure 11: Communication between the different modules of the application
20
– ServiceLocatorException.java
– ServiceLocatorSUNRemote.java
• tracker.ejb.webapp.applets
– TrackDrawing.java
– TrackDrawingClient.java
• tracker.ejb.webapp.servlets
– DrawTrack.java
– GetPointsList.java
– PostNewPosition.java
– StartNewTrack.java
The servlets and JSPs are saved in the standard (J2EE structure) src/web/
directory.
Mobile application. The source file of the Midlets are saved in the CD-ROM
under ../java Sources eclipse-Project/WTK2.2-Apps and the mobilTracker.jad
is under /WTK2.2-apps/MobilTracker.
4 User’s guide
The application can run on a local machine very easily. The machine must have
the Java SDK 1.5, SUN application server with PointBase, Java Wireless Tool
Kit 2.2 installed.
21
Usually the default domain used is Domain1 and all the files extracted from .ear
will be saved under ../domain1/...
4.3 Tutorial
The application is very simple to use and very intuitive. The user interfaces are:
1. Web client
2. Midlet
22
4.3.1 Web Client
The web client can allow 2 types of users to be log in the system: 1) the manager
2) the user. The manager is a special user and is identified in the system by the
user Id number ”1”. It is in fact the first user to be register.
The figure 12 shows the web site map for a normal user. We will see what are
the additional rights that the manager has later.
To access the application from the web the URL
23
Figure 13: Web Client: registration
• Delete : Delete a selected track from a list. If the track is the current one,
the previous track become the current one.
• View Track: The user can view the list of track and select one from a list.
Once the track selected, click Get List of points and then only the track
can drawn on maps. Two options are available:
1. Draw on a Swiss topo Map
2. Draw the track using Google Earth application (which must be in-
stalled!)
The manager has the same Profile setup and Logout as the standard user.
The differences are:
24
Figure 14: Web Client: login
4.3.2 Midlet
At that level of development, the midlets are available only with the Java Sim-
ulator. KtoolBar of the WTK must be launched. You must open the project
MobilTracker and run it.
The Mobile Application offers two menus which allow the user to:
1. Create a new track
2. Send a position to the server
The option create a track will send a request to server after the user provides
its Id as shown in the Figure 18. When a track has started, you begin to send
your positions (GPS points). The option Start Position Tracking propose the
same interface than the Start new Track but when the user Id as been sent, the
tracking starts and every 5 seconds a new point is sent to server (Figure 19).
5 Evaluation
5.1 Adherence with the specification
Most of the part where developed following the specifications fixed at the be-
ginning of this document. The server side is based on a simple but robust
architecture. It offers already a relatively stable structure and the entity man-
aged by the EJB container are what we need at that stage of the project.
The Web client side is 50 per cent sufficient. It is enough for a proof of concept
but that’s all.
The Midlet is enough for a proof of concept as well but need a serious work on
it.
5.2 Tests
The test of user and tracks creation, delete, sending positions, drawing tracks
were done several times and in very bad conditions: low memory capacity,
25
Figure 15: Web Client: Navigation page
machine unstable with to many open applications, server unstable, and so on.
Basically, the tests were done in a pure messy developer environment without
any proper setup. The tests on the application itself were quite successful. The
major problems came from the SUN application server.
26
Figure 16: Web Client: Drawing the track on the Swiss Topo map
indicating to the user that the session is over and he must authenticate
himself again.
6 Future Works
6.1 To do
First of all, the project at that stage is only a prototype. There is a long list
of possible extensions of such project. But the development of a real program
usable on the Internet should be built with professional tools like JBoss Appli-
cation server, Studio Creator for the interfaces, Pointbase or Oracle full licence,
etc.
Now coming back to this version of the project, the part which has not been
developed as wanted is the communication between GPS and Mobile phone.
That is the main remaining work for this prototype. We have to create a class
27
Figure 17: Midlet: Main menu
GPS which open a Bluetooth session with the GPS and collect the positions and
send it to the class Position in an appropriate format. The class Position must
also be able in case of no communication with the server to store the positions
in a list and then when possible send them all. The communication using SMS
should be develop and an automatic switch between GPRS and SMS must be
implemented.
28
Figure 18: Midlet: Create a track
29
Figure 19: Midlet: Send position and server response
7 Project Management
The project was supposed to be developed in a team of 2 students.
2. Otto Poveda:
(a) Analysis and implementation of the Bluetooth communication be-
tween the GPS device and the mobile phone.
(b) Analysis and implementation of the Midlet requesting positions to
the GPS.
30
(c) Implementation of the Midlet starting a track and sending formatted
position to server (using the servlets).
The work done for the project presented in this document and in the class room
represent about 250 to 300 hours of work for the author. This part of the project
has been entirely developed by Pascal Bruegger and the part including the GPS
communication with the mobile phone will be delivered by Otto Poveda (source
and documentation) separately.
31
References
[1] John Crupi Deepak Alur and Malks. Core J2EE Patterns - 2nd Edition.
SUN microsystem, 2004.
[2] J. Ball E. Armstrong and S. Bodoff. The J2EE 1.4 Tutorial. www.sun.com,
2005.
[3] Crawford Farley and Flanagan. Java Enterprise, 2nd Edition. O’Reilly,
2003.
[4] Google. Google Earth KML 2.0
. http://www.keyhole.com/kml/docs/Google Earth KML.pdf, 2004.
[5] Qusay H. Mahmoud. MIDP Event Handling
. http://developers.sun.com/techtopics/mobility/midp/articles/event/,
2004.
[6] Qusay H. Mahmoud. MIDP Inter-Communication with CGI and Servlets
. http://developers.sun.com/techtopics/mobility/midp/articles/event/,
2004.
32