diff --git a/phoneClients/javaMe/build/JavaMEPhone1/.timestamp b/phoneClients/javaMe/build/JavaMEPhone1/.timestamp new file mode 100644 index 0000000..999b584 --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/.timestamp @@ -0,0 +1 @@ +ignore me \ No newline at end of file diff --git a/phoneClients/javaMe/build/JavaMEPhone1/manifest.mf b/phoneClients/javaMe/build/JavaMEPhone1/manifest.mf new file mode 100644 index 0000000..bd06b7b --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/manifest.mf @@ -0,0 +1,6 @@ +MIDlet-1: GpsTracker, , com.websmithing.gpstracker.GpsTracker +MIDlet-Vendor: Vendor +MIDlet-Name: GpsTracker +MIDlet-Version: 1.0 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.1 diff --git a/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsHelper.java b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsHelper.java new file mode 100644 index 0000000..1b85587 --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsHelper.java @@ -0,0 +1,170 @@ +// +// GpsHelper.java +// GpsTracker +// +// Created by Nick Fox on 11/7/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +package com.websmithing.gpstracker; + +import javax.microedition.location.*; +import java.util.Calendar; +import java.util.Date; + +public class GpsHelper implements LocationListener { + + private LocationProvider locationProvider = null; + private Coordinates oldCoordinates = null, currentCoordinates = null; + private float distance = 0; + private int azimuth = 0; + private String uploadWebsite; + private GpsTracker midlet; + private int interval; + protected long sessionID; + + public GpsHelper(GpsTracker Midlet, int Interval, String UploadWebsite){ + sessionID = System.currentTimeMillis(); + this.midlet = Midlet; + this.interval = Interval; + this.uploadWebsite = UploadWebsite; + } + + // getting the gps location is based on an interval in seconds. for instance, + // the location is gotten once a minute, sent to the website to be stored in + // the DB (and then viewed on Google map) and used to retrieve a map tile (image) + // to be diplayed on the phone + + public void startGPS() { + if (locationProvider == null) { + createLocationProvider(); + + Thread locationThread = new Thread() { + public void run(){ + createLocationListener(); + } + }; + locationThread.start(); + } + } + + // this allows us to change how often the gps location is gotten + public void changeInterval(int Interval) { + if (locationProvider != null) { + locationProvider.setLocationListener(this, Interval, -1, -1); + } + } + + private void createLocationProvider() { + Criteria cr = new Criteria(); + + try { + locationProvider = LocationProvider.getInstance(cr); + } catch (Exception e) { + midlet.log("GPS.createLocationProvider: " + e); + } + } + + private void createLocationListener(){ + // 2cd value is interval in seconds + try { + locationProvider.setLocationListener(this, interval, -1, -1); + } catch (Exception e) { + midlet.log("GPS.createLocationListener: " + e); + } + } + + public void locationUpdated(LocationProvider provider, final Location location) { + // get new location from locationProvider + + try { + Thread getLocationThread = new Thread(){ + public void run(){ + sendLocationToWebsite(location); + } + }; + + getLocationThread.start(); + } catch (Exception e) { + midlet.log("GPS.locationUpdated: " + e); + } + } + + public void providerStateChanged(LocationProvider provider, int newState) {} + + private void sendLocationToWebsite(Location location){ + float speed = 0; + + try { + QualifiedCoordinates qualifiedCoordinates = location.getQualifiedCoordinates(); + + qualifiedCoordinates.getLatitude(); + + if (oldCoordinates == null){ + oldCoordinates = new Coordinates(qualifiedCoordinates.getLatitude(), + qualifiedCoordinates.getLongitude(), + qualifiedCoordinates.getAltitude()); + } else { + if (!Float.isNaN( qualifiedCoordinates.distance(oldCoordinates))) { + distance += qualifiedCoordinates.distance(oldCoordinates); + } + + currentCoordinates = new Coordinates(qualifiedCoordinates.getLatitude(), + qualifiedCoordinates.getLongitude(), + qualifiedCoordinates.getAltitude()); + azimuth = (int)oldCoordinates.azimuthTo(currentCoordinates); + oldCoordinates.setAltitude(qualifiedCoordinates.getAltitude()); + oldCoordinates.setLatitude(qualifiedCoordinates.getLatitude()); + oldCoordinates.setLongitude(qualifiedCoordinates.getLongitude()); + + } + + if (qualifiedCoordinates != null){ + // we are trying to get mySql datetime in the following format with a space (%20) + // 2008-04-17%2012:07:02 + + Calendar currentTime = Calendar.getInstance(); + StringBuffer mySqlDateTimeString = new StringBuffer(); + mySqlDateTimeString.append(currentTime.get(Calendar.YEAR)).append("-"); + mySqlDateTimeString.append(currentTime.get(Calendar.DATE)).append("-"); + mySqlDateTimeString.append(currentTime.get(Calendar.MONTH)+1).append("%20"); + mySqlDateTimeString.append(currentTime.get(Calendar.HOUR_OF_DAY)).append(':'); + mySqlDateTimeString.append(currentTime.get(Calendar.MINUTE)).append(':'); + mySqlDateTimeString.append(currentTime.get(Calendar.SECOND)); + + if (!Float.isNaN(location.getSpeed())) { + speed = location.getSpeed(); + } + + /* example url + http://www.websmithing.com/gpstracker2/getgooglemap3.php?lat=47.473349&lng=-122.025035&mph=137&dir=0&mi=0& + dt=2008-04-17%2012:07:02&lm=0&h=291&w=240&zm=12&dis=25&pn=momosity&sid=11137&acc=95&iv=yes&info=momostuff + */ + + String gpsData = "lat=" + String.valueOf(qualifiedCoordinates.getLatitude()) + + "&lng=" + String.valueOf(qualifiedCoordinates.getLongitude()) + + "&mph=" + String.valueOf((int)(speed/1609*3600)) // in miles per hour + + "&dir=" + String.valueOf(azimuth) + + "&dt=" + mySqlDateTimeString + + "&lm=" + location.getLocationMethod() + + "&dis=" + String.valueOf((int)(distance/1609)) // in miles + + "&pn=" + midlet.phoneNumber + + "&sid=" + String.valueOf(sessionID) // guid? + + "&acc=" + String.valueOf((int)(qualifiedCoordinates.getHorizontalAccuracy()*3.28)) // in feet + + "&iv=yes" + + "&info=javaMe-" + location.getExtraInfo("text/plain"); + + // with our query string built, we create a networker object to send the + // gps data to our website and update the DB + NetWorker netWorker = new NetWorker(midlet, uploadWebsite); + netWorker.postGpsData(gpsData); + } + + } catch (Exception e) { + midlet.log("GPS.getLocation: " + e); + } + } +} + + + diff --git a/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsTracker.java b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsTracker.java new file mode 100644 index 0000000..a40f1c2 --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/GpsTracker.java @@ -0,0 +1,225 @@ +// +// GpsTracker.java +// GpsTracker +// +// Created by Nick Fox on 11/7/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +package com.websmithing.gpstracker; + +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; +import java.util.Calendar; + +public class GpsTracker extends MIDlet implements CommandListener { + private Display display; + private Form form; + private Form settingsScreen; + private Command exitCmd; + private Command saveCmd; + private Command zoomCmd; + private Command settingsCmd; + private Command backCmd; + private TextField phoneNumberTextField; + private TextField uploadWebsiteTextField; + private ChoiceGroup updateIntervalCG; + private String updateInterval; + private int[] iTimes = {60, 300, 900}; + + private RmsHelper rms; + private GpsHelper gps; + + private String uploadWebsite; + private String defaultUploadWebsite = "http://www.websmithing.com/gpstracker2/getgooglemap3.php"; + + protected String phoneNumber; + protected String zoomLevel; + protected int height, width; + protected Calendar currentTime; + protected long sessionID; + + public GpsTracker(){ + form = new Form("GpsTracker"); + display = Display.getDisplay(this); + exitCmd = new Command("Exit", Command.EXIT, 1); + settingsCmd = new Command("Settings", Command.SCREEN, 2); + + form.addCommand(exitCmd); + form.addCommand(settingsCmd); + form.setCommandListener(this); + + display.setCurrent(form); + currentTime = Calendar.getInstance(); + sessionID = System.currentTimeMillis(); + height = form.getHeight(); + width = form.getWidth(); + + // RMS is the phone's built in storage, kind of like a database, but + // it only stores name-value pairs (like an associative array or hashtable). + // eveything is stored as a string. + getSettingsFromRMS(); + + // the phone number field is the only empty field when the application is + // first loaded. it does not have to be a phone number, it can be any string, + // but for uniqueness, it's best to use a phone number. this only has to be + // done once. + if (hasPhoneNumber()) { + startGPS(); + displayInterval(); + } + } + + public void startApp() { + if ( form != null ) { + display.setCurrent(form); + } + } + + // let the user know how often map will be updated + private void displayInterval() { + int tempTime = iTimes[Integer.parseInt(updateInterval)]/60; + + display.setCurrent(form); + form.deleteAll(); + + if (tempTime == 1) { + log("Getting map once a minute..."); + } + else { + log("Getting map every " + String.valueOf(tempTime) + " minutes..."); + } + } + + private void loadSettingsScreen() { + settingsScreen = new Form("Settings"); + + phoneNumberTextField = new TextField("Phone number or user name", phoneNumber, 20, TextField.ANY); + uploadWebsiteTextField = new TextField("Upload website", uploadWebsite, 100, TextField.ANY); + settingsScreen.append(phoneNumberTextField); + settingsScreen.append(uploadWebsiteTextField); + + String[] times = { "1 minute", "5 minutes", "15 minutes"}; + updateIntervalCG = new ChoiceGroup("Update map how often?", ChoiceGroup.EXCLUSIVE, times, null); + updateIntervalCG.setSelectedIndex(Integer.parseInt(updateInterval), true); + settingsScreen.append(updateIntervalCG); + + saveCmd = new Command("Save", Command.SCREEN, 1); + settingsScreen.addCommand(saveCmd); + + settingsScreen.setCommandListener(this); + display.setCurrent(settingsScreen); + } + + // get the settings from the phone's storage and load 4 global variables + public void getSettingsFromRMS() { + try { + rms = new RmsHelper(this, "GPSTracker"); + + phoneNumber = rms.get("phoneNumber"); + uploadWebsite = rms.get("uploadWebsite"); + zoomLevel = rms.get("zoomLevel"); + updateInterval = rms.get("updateInterval"); + } + catch (Exception e) { + log("GPSTracker.getSettingsFromRMS: " + e); + } + + if ((uploadWebsite == null) || (uploadWebsite.trim().length() == 0)) { + uploadWebsite = defaultUploadWebsite; + } + + if ((zoomLevel == null) || (zoomLevel.trim().length() == 0)) { + zoomLevel = "12"; + } + if ((updateInterval == null) || (updateInterval.trim().length() == 0)) { + updateInterval = "1"; + } + } + + private boolean hasPhoneNumber() { + if ((phoneNumber == null) || (phoneNumber.trim().length() == 0)) { + log("Phone number required. Please go to settings."); + return false; + } + else { + return true; + } + } + + // gps is started with the update interval. the interval is the time in between + // map updates + private void startGPS() { + if (gps == null) { + gps = new GpsHelper(this, iTimes[Integer.parseInt(updateInterval)], uploadWebsite); + gps.startGPS(); + } + } + + // this is called when the user changes the interval in the settings screen + private void changeInterval() { + if (gps == null) { + startGPS(); + } + else { + gps.changeInterval(iTimes[Integer.parseInt(updateInterval)]); + } + } + + // save settings back to phone memory + private void saveSettingsToRMS() { + try { + phoneNumber = phoneNumberTextField.getString(); + uploadWebsite = uploadWebsiteTextField.getString(); + updateInterval = String.valueOf(updateIntervalCG.getSelectedIndex()); + + rms.put("phoneNumber", phoneNumber); + rms.put("uploadWebsite", uploadWebsite); + rms.put("updateInterval", updateInterval); + + rms.save(); + } + catch (Exception e) { + log("GPSTracker.saveSettings: " + e); + } + display.setCurrent(form); + } + + public void log(String text) { + StringItem si = new StringItem(null, text); + si.setLayout(Item.LAYOUT_NEWLINE_AFTER); + form.append(si); + } + + public void commandAction(Command cmd, Displayable screen) { + if (cmd == exitCmd) { + shutDownApp(); + } + else if (cmd == saveCmd) { + saveSettingsToRMS(); + + if (hasPhoneNumber()) { + changeInterval(); + displayInterval(); + } + } + else if (cmd == settingsCmd) { + loadSettingsScreen(); + } + else if (cmd == backCmd) { + displayInterval(); + } + } + + public void pauseApp() {} + + public void destroyApp(boolean unconditional) {} + + protected void shutDownApp() { + destroyApp(true); + notifyDestroyed(); + } +} + + + diff --git a/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/NetWorker.java b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/NetWorker.java new file mode 100644 index 0000000..26e8b8a --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/NetWorker.java @@ -0,0 +1,86 @@ +// +// NetWorker.java +// GpsTracker +// +// Created by Nick Fox on 11/7/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +package com.websmithing.gpstracker; + +import javax.microedition.io.*; +import java.io.*; + +public class NetWorker { + private GpsTracker midlet; + private String uploadWebsite; + int i = 1; + + public NetWorker(GpsTracker lbsMidlet, String UploadWebsite){ + this.midlet = lbsMidlet; + this.uploadWebsite = UploadWebsite; + } + + public void postGpsData(String queryString) { + queryString = urlEncodeString(queryString); + HttpConnection httpConnection = null; + DataOutputStream dataOutputStream = null; + + try{ + httpConnection = (HttpConnection)Connector.open(uploadWebsite); + httpConnection.setRequestMethod(HttpConnection.POST); + httpConnection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); + httpConnection.setRequestProperty("Content-Language", "en-US"); + httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + httpConnection.setRequestProperty("Content-Length", String.valueOf(queryString.length())); + + dataOutputStream = new DataOutputStream(httpConnection.openOutputStream()); + dataOutputStream.write(queryString.getBytes()); + + // some mobile devices have unexpected behavior with flush(), test before using + //dataOutputStream.flush(); + + if(httpConnection.getResponseCode() != HttpConnection.HTTP_OK){ + midlet.log("NetWorker.postGpsData responseCode: " + httpConnection.getResponseCode()); + } + } catch (Exception e) { + midlet.log("NetWorker.postGpsData error: " + e); + } + finally{ // clean up + try{ + if(httpConnection != null) + httpConnection.close(); + if(dataOutputStream != null) + dataOutputStream.close(); + } + catch(Exception e){} + } + } + + private String urlEncodeString(String s) + { + if (s != null) { + StringBuffer tmp = new StringBuffer(); + int i = 0; + try { + while (true) { + int b = (int)s.charAt(i++); + + if (b != 0x20) { + tmp.append((char)b); + } + else { + tmp.append("%"); + if (b <= 0xf) { + tmp.append("0"); + } + tmp.append(Integer.toHexString(b)); + } + } + } + catch (Exception e) {} + return tmp.toString(); + } + return null; + } +} diff --git a/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/RmsHelper.java b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/RmsHelper.java new file mode 100644 index 0000000..6a904c6 --- /dev/null +++ b/phoneClients/javaMe/build/JavaMEPhone1/preprocessed/com/websmithing/gpstracker/RmsHelper.java @@ -0,0 +1,88 @@ +// +// RmsHelper.java +// GpsTracker +// +// Created by Nick Fox on 11/7/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +package com.websmithing.gpstracker; + +import java.util.*; +import javax.microedition.rms.*; + +public class RmsHelper { + private GpsTracker midlet; + private String mRecordStoreName; + private Hashtable mHashtable; + + public RmsHelper(GpsTracker Midlet, String recordStoreName) throws RecordStoreException { + this.midlet = Midlet; + this.mRecordStoreName = recordStoreName; + this.mHashtable = new Hashtable(); + load(); + } + + public String get(String key) { + return (String)mHashtable.get(key); + } + + public void put(String key, String value) { + if (value == null) value = ""; + mHashtable.put(key, value); + } + + private void load() throws RecordStoreException { + RecordStore rs = null; + RecordEnumeration re = null; + + try { + rs = RecordStore.openRecordStore(mRecordStoreName, true); + re = rs.enumerateRecords(null, null, false); + while (re.hasNextElement()) { + byte[] raw = re.nextRecord(); + String pref = new String(raw); + // Parse out the name. + int index = pref.indexOf('|'); + String name = pref.substring(0, index); + String value = pref.substring(index + 1); + put(name, value); + } + } + finally { + if (re != null) re.destroy(); + if (rs != null) rs.closeRecordStore(); + } + } + + public void save() throws RecordStoreException { + RecordStore rs = null; + RecordEnumeration re = null; + try { + rs = RecordStore.openRecordStore(mRecordStoreName, true); + re = rs.enumerateRecords(null, null, false); + + // First remove all records, a little clumsy. + while (re.hasNextElement()) { + int id = re.nextRecordId(); + rs.deleteRecord(id); + } + + // Now save the preferences records. + Enumeration keys = mHashtable.keys(); + while (keys.hasMoreElements()) { + String key = (String)keys.nextElement(); + String value = get(key); + String pref = key + "|" + value; + byte[] raw = pref.getBytes(); + rs.addRecord(raw, 0, raw.length); + } + } + finally { + if (re != null) re.destroy(); + if (rs != null) rs.closeRecordStore(); + } + } + +} + diff --git a/phoneClients/javaMe/dist/nbrun3788515748598082110/GpsTracker.jad b/phoneClients/javaMe/dist/nbrun3788515748598082110/GpsTracker.jad deleted file mode 100644 index 5753ada..0000000 --- a/phoneClients/javaMe/dist/nbrun3788515748598082110/GpsTracker.jad +++ /dev/null @@ -1,8 +0,0 @@ -MIDlet-1: GpsTracker, , com.websmithing.gpstracker.GpsTracker -MIDlet-Jar-Size: 11834 -MIDlet-Jar-URL: GpsTracker.jar -MIDlet-Name: GpsTracker -MIDlet-Vendor: Vendor -MIDlet-Version: 1.0 -MicroEdition-Configuration: CLDC-1.1 -MicroEdition-Profile: MIDP-2.1 diff --git a/phoneClients/javaMe/nbproject/private/private.properties b/phoneClients/javaMe/nbproject/private/private.properties index 2be98fe..3a8312e 100644 --- a/phoneClients/javaMe/nbproject/private/private.properties +++ b/phoneClients/javaMe/nbproject/private/private.properties @@ -1,5 +1,6 @@ app-version.autoincrement=false -config.active= +config.active=JavaMEPhone1 +configs.JavaMEPhone1.platform.apis.defaults=JSR179-1.0,JSR256-1.2 deployment.counter=3 deployment.number=3.0.0 javadoc.preview=true diff --git a/phoneClients/javaMe/nbproject/private/private.xml b/phoneClients/javaMe/nbproject/private/private.xml index 79ec6ce..362428f 100644 --- a/phoneClients/javaMe/nbproject/private/private.xml +++ b/phoneClients/javaMe/nbproject/private/private.xml @@ -3,10 +3,9 @@ - file:/C:/Users/Nick/Documents/Visual%20Studio%202012/Projects/GpsTracker/src/com/websmithing/gpstracker/NetWorker.java - file:/C:/Users/Nick/Documents/Visual%20Studio%202012/Projects/GpsTracker/src/com/websmithing/gpstracker/GpsTracker.java - file:/C:/Users/Nick/Documents/Visual%20Studio%202012/Projects/GpsTracker/src/com/websmithing/gpstracker/GpsHelper.java - file:/C:/Users/Nick/Documents/Visual%20Studio%202012/Projects/GpsTracker/src/com/websmithing/gpstracker/RmsHelper.java + file:/C:/Users/Nick/Documents/GpsTracker/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsHelper.java + file:/C:/Users/Nick/Documents/GpsTracker/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsTracker.java + file:/C:/Users/Nick/Documents/GpsTracker/phoneClients/javaMe/src/com/websmithing/gpstracker/NetWorker.java diff --git a/phoneClients/javaMe/nbproject/project.properties b/phoneClients/javaMe/nbproject/project.properties index 0be96a8..996d601 100644 --- a/phoneClients/javaMe/nbproject/project.properties +++ b/phoneClients/javaMe/nbproject/project.properties @@ -10,12 +10,15 @@ build.dir=build/${config.active} build.root.dir=build configs.JavaMEPhone1.abilities=MMAPI=1.2,JSR82=1.1,JSR280=1.0,JSR226=1.0,MIDP=2.1,SATSA=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0,J2MEWS=1.0,WMA=2.0,JSR172=1.0,JSR257=1.0,JSR256=1.2,OBEX=1.0,ColorScreen,JSR239=1.0,TouchScreen,JSR211=1.0,JSR234=1.0,ScreenWidth=240,JSR75=1.0,JSR184=1.1,ScreenHeight=320,ScreenColorDepth=16, +configs.JavaMEPhone1.javac.source=1.3 +configs.JavaMEPhone1.javac.target=1.3 configs.JavaMEPhone1.platform.active=Oracle_Java_TM__Platform_Micro_Edition_SDK_3_4 configs.JavaMEPhone1.platform.active.description=Oracle Java(TM) Platform Micro Edition SDK 3.4 -configs.JavaMEPhone1.platform.apis=JSR239-1.0,SATSA-1.0,WMA-2.0,JSR82-1.1,JSR184-1.1,JSR280-1.0,JSR172-1.0,JSR234-1.0,OBEX-1.0,JSR179-1.0,JSR75-1.0,JSR226-1.0,JSR211-1.0,JSR257-1.0,JSR177-1.0,J2ME-WS-1.0,MMAPI-1.2,JSR256-1.2 -configs.JavaMEPhone1.platform.bootclasspath=${platform.home}/lib/jsr172_1.0.jar:${platform.home}/lib/jsr234_1.0.jar:${platform.home}/lib/jsr135_1.2.jar:${platform.home}/lib/jsr239_1.0.jar:${platform.home}/lib/jsr75_1.0.jar:${platform.home}/lib/jsr211_1.0.jar:${platform.home}/lib/jsr177_1.0.jar:${platform.home}/lib/jsr257_1.0.jar:${platform.home}/lib/jsr184_1.1.jar:${platform.home}/lib/jsr226_1.0.jar:${platform.home}/lib/jsr205_2.0.jar:${platform.home}/lib/jsr082_1.1.jar:${platform.home}/lib/jsr179_1.0.jar:${platform.home}/lib/jsr256_1.2.jar:${platform.home}/lib/jsr280_1.0.jar:${platform.home}/lib/midp_2.1.jar:${platform.home}/lib/cldc_1.1.jar +configs.JavaMEPhone1.platform.apis=JSR179-1.0,JSR256-1.2 +configs.JavaMEPhone1.platform.bootclasspath=${platform.home}/lib/jsr179_1.0.jar:${platform.home}/lib/jsr256_1.2.jar:${platform.home}/lib/midp_2.1.jar:${platform.home}/lib/cldc_1.1.jar configs.JavaMEPhone1.platform.configuration=CLDC-1.1 configs.JavaMEPhone1.platform.device=JavaMEPhone1 +configs.JavaMEPhone1.platform.fat.jar=true configs.JavaMEPhone1.platform.profile=MIDP-2.1 configs.JavaMEPhone1.platform.trigger=CLDC configs.JavaMEPhone1.platform.type=UEI-1.0.1 diff --git a/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsHelper.java b/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsHelper.java index c8e8be8..1b85587 100644 --- a/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsHelper.java +++ b/phoneClients/javaMe/src/com/websmithing/gpstracker/GpsHelper.java @@ -8,7 +8,6 @@ package com.websmithing.gpstracker; - import javax.microedition.location.*; import java.util.Calendar; import java.util.Date; @@ -21,13 +20,10 @@ private int azimuth = 0; private String uploadWebsite; private GpsTracker midlet; - private int interval; - protected Calendar currentTime; + private int interval; protected long sessionID; - - + public GpsHelper(GpsTracker Midlet, int Interval, String UploadWebsite){ - currentTime = Calendar.getInstance(); sessionID = System.currentTimeMillis(); this.midlet = Midlet; this.interval = Interval; @@ -84,7 +80,7 @@ try { Thread getLocationThread = new Thread(){ public void run(){ - getLocation(location); + sendLocationToWebsite(location); } }; @@ -96,7 +92,7 @@ public void providerStateChanged(LocationProvider provider, int newState) {} - private void getLocation(Location location){ + private void sendLocationToWebsite(Location location){ float speed = 0; try { @@ -124,8 +120,18 @@ } if (qualifiedCoordinates != null){ - Date d = new Date(); - + // we are trying to get mySql datetime in the following format with a space (%20) + // 2008-04-17%2012:07:02 + + Calendar currentTime = Calendar.getInstance(); + StringBuffer mySqlDateTimeString = new StringBuffer(); + mySqlDateTimeString.append(currentTime.get(Calendar.YEAR)).append("-"); + mySqlDateTimeString.append(currentTime.get(Calendar.DATE)).append("-"); + mySqlDateTimeString.append(currentTime.get(Calendar.MONTH)+1).append("%20"); + mySqlDateTimeString.append(currentTime.get(Calendar.HOUR_OF_DAY)).append(':'); + mySqlDateTimeString.append(currentTime.get(Calendar.MINUTE)).append(':'); + mySqlDateTimeString.append(currentTime.get(Calendar.SECOND)); + if (!Float.isNaN(location.getSpeed())) { speed = location.getSpeed(); } @@ -139,7 +145,7 @@ + "&lng=" + String.valueOf(qualifiedCoordinates.getLongitude()) + "&mph=" + String.valueOf((int)(speed/1609*3600)) // in miles per hour + "&dir=" + String.valueOf(azimuth) - + "&dt=2008-04-17%2012:07:02" // + d.toString() + + "&dt=" + mySqlDateTimeString + "&lm=" + location.getLocationMethod() + "&dis=" + String.valueOf((int)(distance/1609)) // in miles + "&pn=" + midlet.phoneNumber diff --git a/phoneClients/javaMe/src/com/websmithing/gpstracker/NetWorker.java b/phoneClients/javaMe/src/com/websmithing/gpstracker/NetWorker.java index 23d1353..26e8b8a 100644 --- a/phoneClients/javaMe/src/com/websmithing/gpstracker/NetWorker.java +++ b/phoneClients/javaMe/src/com/websmithing/gpstracker/NetWorker.java @@ -57,7 +57,6 @@ } } - private String urlEncodeString(String s) { if (s != null) {