This commit is contained in:
vshcherb 2014-05-19 01:50:17 +03:00
parent d13d59c445
commit 2d548eec46
3 changed files with 12 additions and 3 deletions

View file

@ -31,6 +31,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
public OsMoPlugin(final OsmandApplication app) {
service = new OsMoService(app);
tracker = new OsMoTracker(service);
tracker.enableTracker();
groups = new OsMoGroups(service, tracker, app.getSettings());
this.app = app;
}

View file

@ -239,6 +239,7 @@ public class OsMoThread {
private void processReadMessages() {
while(!queueOfMessages.isEmpty()){
String cmd = queueOfMessages.poll();
log.info("OSMO get:"+cmd);
int k = cmd.indexOf('|');
String header = cmd;
String data = "";
@ -258,7 +259,7 @@ public class OsMoThread {
if(obj != null && obj.has("error")) {
error = true;
try {
service.showErrorMessage(obj.getString("description"));
service.showErrorMessage(obj.getString("error"));
} catch (JSONException e) {
e.printStackTrace();
}
@ -297,10 +298,14 @@ public class OsMoThread {
}
}
}
private ByteBuffer getNewPendingSendCommand() throws UnsupportedEncodingException {
if(authorized == 0) {
String auth = "TOKEN|"+ token.token;
log.info("OSMO send:" + auth);
authorized = 1;
return ByteBuffer.wrap(prepareCommand(auth).toString().getBytes("UTF-8"));
}
if(authorized == 1) {
@ -310,6 +315,7 @@ public class OsMoThread {
String l = s.nextSendCommand(this);
if (l != null) {
StringBuilder res = prepareCommand(l);
log.info("OSMO send " + res);
return ByteBuffer.wrap(res.toString().getBytes("UTF-8"));
}
}

View file

@ -68,7 +68,7 @@ public class OsMoTracker implements OsMoSender, OsMoReactor {
if(loc.hasBearing()) {
cmd.append("C").append((float)loc.getBearing());
}
if((System.currentTimeMillis() - loc.getTime()) > 30000) {
if((System.currentTimeMillis() - loc.getTime()) > 30000 && loc.getTime() != 0) {
cmd.append("T").append(loc.getTime());
}
return cmd.toString();
@ -77,7 +77,9 @@ public class OsMoTracker implements OsMoSender, OsMoReactor {
}
public void sendCoordinate(Location location) {
bufferOfLocations.add(location);
if(startSendingLocations) {
bufferOfLocations.add(location);
}
}
public void sendCoordinate(double lat, double lon) {