Index by title

Developers tutorial. 15 minutes start guide.

There are several steps you should do.

Part I. Installing and configuring necessary software.

1. You need a working Bazaar client - a distributed version control system.

You can download and find instructions how to install it here:
http://bazaar-vcs.org/Download

After you get a working Bazaar initialize the directory where you will branch the wannatrak project. Here is the instruction:
http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html#branching-a-project.

(Optional) Read Bazaar docs to ensure you understand how it works.
http://bazaar-vcs.org/Documentation

2. From your local repository execute Bazaar branch command to get wannatrak project:
bzr branch http://bzr.wannatrak.org/main

3. Configure Maven - a project management tool that builds and deploys Wannatrak application.

Using link below you can find detailed instructions on how to install it: http://maven.apache.org/download.html

To make maven work and to ease its usage create M2_HOME and M2 environment variables. Also add maven dir to PATH. You can read how to do it at the bottom of the page: http://maven.apache.org/download.html

4. Install DBMS PostgreSQL 8.3. Here are the instructions:
http://www.postgresql.org/download/

5. You need JBoss 4.2.3 Application Server. You can download it from developers site: http://jboss.org/jbossas/downloads/
or right away from SourceForge: http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/

To install unzip it, for example to the c:\JBosses\JBoss-4.2.3.GA

Add new environment variable WT_JBOSS_HOME with the JBoss installation path value. As in the example above it can be c:\JBosses\JBoss-4.2.3.GA

6. (Optional) In order to develop mobile Java application you need to install WTK 2.5.2. All necessary information you can find here:
http://www.j2ee.me/products/sjwtoolkit/download.html

Add new environment variable WTK_HOME with the WTK installation path value.

Part II. Deploying Wannatrak using Maven.

If you have installed and configured programs described in part I, you can deploy Wannatrak project with maven.

1. First of all you need to initialize PostgreSQL database, load demonstration data if need and init JBoss (copy libs).

Execute this command from the root of the project to initialize wannatrak:
mvn install -P InitDB,LoadDemo,InitJBoss

It has default properties:
    <properties>
        <db.url>jdbc:postgresql://127.0.0.1</db.url>
        <db.driver>org.postgresql.Driver</db.driver>
        <db.type>PostgreSQL 8.3</db.type>
        <db.username>postgres</db.username>
        <db.password>postgres</db.password>
        <db.name>wannatrak</db.name>

        ...
    </properties>

If you wish to change any of them, use -D key as shown below (keep in mind they are case sensitive):
mvn install -Ddb.username=myname -Ddb.password=1234

You can combine keys to load demonstration data and change default parameters simultaneously:
mvn install -P InitDB,LoadDemo,InitJBoss -Ddb.username=myname -Ddb.password=1234

The process of demonstration data loading takes some time, be patient.

2. Build the Wannatrak.

Execute mvn install command that builds project - middleware and device. If you want to rebuild project:
    mvn clean install
There are some profiles for building wannatrak project:

WithClient - web interface based on GWT.

WithClientAndJ2ME - includes client and mobile modules.

Deploy2JBoss - copies middleware, device and client to JBoss

UpdateJ2MEInClient - copies last mobile Jar and Jad files to client/war/download.

You can combine any of these profiles according to what you need, for example to update mobile client and deploy to JBoss, use this command:
    mvn clean install -P UpdateJ2MEInClient,Deploy2JBoss

3. It's time to run the project.

Check whether PostgreSQL service started.

Launch JBoss.

Open link below in your browser (be sure firewall doesn't block 8080 port): http://localhost:8080


How to ease mobile app start on Simbian v6.2


Web RESTful API Reference

Login
Logout
Post track
Create new track
Get list of existing tracks
Continue existing track
Get track info
Get track settings
Update track settings
Get track
Remove track

Briefly

Login to post GPS data to Wannatrak server.

You'll receive the DEVICE_KEY on successful login.

You'll use this DEVICE_KEY for further interactions with server as your unique identifier.

If you login for the first time and you don't have previous tracks on the server there will be created a new one with your login name.

If you already have tracks then you will be linked to the last used track. Your GPS data will be attached to it.

To find out a name of your current track call Get track info.

To see your existing tracks use Get list of existing tracks.

If you want to post data to a new track, first of all, Create new track.

To switch to one of existing tracks use Continue existing track.

Login

Correct case

Request:

POST /device/api/login HTTP/1.1
Content-Type: text/json

{"login":"LOGIN","password":"PASSWORD"}

Response:

HTTP/1.1 200 OK
Content-Type: */*

%DEVICE_KEY%

Incorrect case

Request:

POST /device/api/login HTTP/1.1
Content-Type: text/json

{"login":"WRONG LOGIN","password":"WRONG PASSWORD"}

Response:

HTTP/1.1 403 Forbidden

top

Logout

Correct case

Request:

POST /device/api/logout HTTP/1.1
Content-Type: text/json

%DEVICE_KEY%

Response:

HTTP/1.1 204 No Content

Incorrect case

Request:

POST /device/api/logout HTTP/1.1
Content-Type: text/json

%WRONG_DEVICE_KEY%

Response:

HTTP/1.1 400 Bad Request

top

Post track

Correct case

Request:

POST /device/api/trak/%DEVICE_KEY% HTTP/1.1
Content-Type: text/json

[[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]

Timestamp - integer number of millis since 1/1/1970

Longitude, Latitude and Course - float degrees

Speed - float number of kilometers per hour

Altitude - float number of meters above sea level

Example on js:
 1 var http = new XMLHttpRequest();
 2 http.open("POST", "http://www.wannatrak.com/device/api/trak/%DEVICE_KEY%", true);
 3 var params = '[[127000000,2.5,3.4,4,5,6],[127000001,2.4,3.5,4,5,6]]';
 4 http.setRequestHeader("Content-type", "text/json");
 5 http.setRequestHeader("Content-length", params.length);
 6 http.setRequestHeader("Connection", "close");
 7 http.onreadystatechange = function() {
 8     if(http.readyState == 4 && http.status == 200) {
 9         alert(http.responseText);
10     }
11 }
12 http.send(params);

Response:

HTTP/1.1 204 No Content

Incorrect case

Response:

HTTP/1.1 400 Bad Request

Warning! If you try to send track before sendPeriod elapsed server will reject your track.

Response:

HTTP/1.1 409 Conflict

Read more about sendPeriod here.

top

Create new track

Correct case

Request:

GET /device/api/trak/create/%DEVICE_KEY%/%TRACK_NAME% HTTP/1.1 
Accept: text/json

Response:

HTTP/1.1 200 OK 
Content-Type: text/json

{"id":"%TRACK_ID%","name":"Track name"}

Incorrect case

Response:

HTTP/1.1 400 Bad Request

top

Get list of existing tracks

Correct case

Request:

GET /device/api/trak/list/%DEVICE_KEY% HTTP/1.1 
Accept: text/json

Response:

HTTP/1.1 200 OK 
Content-Type: text/json

[{"id":"%TRACK_ID%","name":"Track name"}, {"id":"%TRACK_ID_2%","name":"Track name 2"}, ...]

Incorrect case

Response:

HTTP/1.1 400 Bad Request

top

Continue existing track

Correct case

Request:

GET /device/api/trak/continue/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1
Accept: text/json 

Response:

HTTP/1.1 200 OK 
Content-Type: */*

%NEW_DEVICE_KEY%

Incorrect case

Response:

HTTP/1.1 400 Bad Request

top

Get track info

Correct case

Request:

GET /device/api/trak/get/%DEVICE_KEY% HTTP/1.1 
Accept: text/json

Response:

HTTP/1.1 200 OK 
Content-Type: text/json

{"id":"%TRACK_ID%","name":"Track name"}

Incorrect case

Response:

HTTP/1.1 400 Bad Request

top

Get track settings

Correct case

Request:

GET /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1 
Accept: text/json

Response:

HTTP/1.1 200 OK 
Content-Type: text/json

{"savePeriod":5,"sendPeriod":5,"name":"Track name"} 

savePeriod - seconds between points in track

sendPeriod - minutes between sending part of track to server

Warning! If you try to send track before sendPeriod elapsed server will reject your track.

Incorrect case

Response:

HTTP/1.1 400 Bad Request

top

Update track settings

Correct case

Request:

POST /device/api/trak/settings/%DEVICE_KEY% HTTP/1.1
Content-Type: text/json

{"savePeriod":1,"sendPeriod":2,"name":"New track"} 

savePeriod - seconds between points in track

sendPeriod - minutes between sending part of track to server

Warning! If you try to send track before sendPeriod elapsed server will reject your track.

Response:

HTTP/1.1 204 No Content

Incorrect case

Response:

HTTP/1.1 400 Bad Request

Track with such name already exists case

Response:

HTTP/1.1 409 Conflict

top

Get track

Correct case

Request:

GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%FROM%/%TO%/%WITH_NOISE% HTTP/1.1
Accept: text/json

FROM - start time in milliseconds since Jan 1 1970

TO - end time in milliseconds since Jan 1 1970

WITH_NOISE - include noise movements in track (true/false)

Number of returned points is limited to 4000.

Short version:

GET /device/api/trak/%DEVICE_KEY%/%TRACK_ID%/%WITH_NOISE% HTTP/1.1
Accept: text/json

From Jan 1 1970 to now

Response:

HTTP/1.1 200 OK 
Content-Type: text/json

[[Timestamp,Longitude,Latitude,Speed,Course,Altitude],[Timestamp,Longitude,Latitude,Speed,Course,Altitude], ...]

top

Remove track

Correct case

Request:

DELETE /device/api/trak/remove/%DEVICE_KEY%/%TRACK_ID% HTTP/1.1
Accept: text/json

Response:

HTTP/1.1 204 No Content

Incorrect case

Request:

DELETE /device/api/trak/remove/%WRONG_DEVICE_KEY%/%TRACK_ID% HTTP/1.1
Accept: text/json

Response:

HTTP/1.1 400 Bad Request

top


Wiki

Developers tutorial. 15 minutes start guide.

Web RESTful API. Reference

How to ease mobile app start on Simbian v6.2 (S60 3rd Edition with Feature Pack 1)