kopia lustrzana https://github.com/sh123/codec2_talkie
Mic-E decoder bug fixes
rodzic
667b1edc23
commit
1c76993cc7
|
@ -232,9 +232,10 @@ public class AppWorker extends Thread {
|
|||
private final ProtocolCallback _protocolCallback = new ProtocolCallback() {
|
||||
@Override
|
||||
protected void onReceivePosition(Position position) {
|
||||
Log.i(TAG, String.format("Position received: %f %f %f %f %f",
|
||||
Log.i(TAG, String.format("Position received: %f %f %f %f %f %s %s %s",
|
||||
position.latitude, position.longitude,
|
||||
position.bearingDegrees, position.speedMetersPerSecond, position.altitudeMeters));
|
||||
position.bearingDegrees, position.speedMetersPerSecond, position.altitudeMeters,
|
||||
position.symbolCode, position.status, position.comment));
|
||||
// TODO, store to database
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
public void fromBinary(String srcCallsign, String dstCallsign, byte[] infoData) {
|
||||
_isValid = false;
|
||||
_position = new Position();
|
||||
_dstCallsign = dstCallsign;
|
||||
_position.srcCallsign = srcCallsign;
|
||||
_position.dstCallsign = dstCallsign;
|
||||
|
||||
|
@ -147,8 +148,8 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
}
|
||||
c = (c == 'Z') ? ' ' : (char) (c - 32);
|
||||
}
|
||||
messageId <<= 1;
|
||||
if (i == 3) latitude.append('.');
|
||||
if (i < 2) messageId <<= 1;
|
||||
if (i == 4) latitude.append('.');
|
||||
latitude.append(c);
|
||||
}
|
||||
|
||||
|
@ -158,23 +159,23 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
: _miceMessageReverseTypeMapStd.get(messageId);
|
||||
|
||||
// read longitude
|
||||
int d = (infoData[0] - 28) + longOffset;
|
||||
int d = ((int)infoData[0] - 28) + longOffset;
|
||||
if (d >= 180 && d <= 189) d -= 80;
|
||||
else if (d >= 190 && d <= 199) d -= 190;
|
||||
else if (d >= 190) d -= 190;
|
||||
|
||||
int m = (infoData[1] - 28);
|
||||
if (m >= 6) m -= 60;
|
||||
int m = ((int)infoData[1] - 28);
|
||||
if (m >= 60) m -= 60;
|
||||
|
||||
int h = (infoData[2] - 28);
|
||||
int h = ((int)infoData[2] - 28);
|
||||
|
||||
String longitude = String.format(Locale.US, "%03d%d.%d", d, m, h);
|
||||
_position.longitude = UnitTools.nmeaToDecimal(longitude, Character.toString(we));
|
||||
|
||||
// read course/speed
|
||||
int sp = 10 * (infoData[3] - 28);
|
||||
int dcSp = (infoData[4] - 28) / 10;
|
||||
int dcSe =(infoData[4] - 28) % 10;
|
||||
int se = infoData[5] - 28;
|
||||
int sp = 10 * ((int)infoData[3] - 28);
|
||||
int dcSp = ((int)infoData[4] - 28) / 10;
|
||||
int dcSe = (((int)infoData[4] - 28) % 10) * 100;
|
||||
int se = (int)infoData[5] - 28;
|
||||
|
||||
int speed = sp + dcSp;
|
||||
if (speed >= 800) speed -= 800;
|
||||
|
@ -192,7 +193,7 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
_position.symbolCode = String.format(Locale.US, "%c%c", infoData[7], infoData[6]);
|
||||
|
||||
// read comment until the end
|
||||
_position.comment = new String(Arrays.copyOfRange(infoData, 8, infoData.length - 1));
|
||||
_position.comment = new String(Arrays.copyOfRange(infoData, 8, infoData.length));
|
||||
|
||||
_isValid = true;
|
||||
}
|
||||
|
@ -289,7 +290,7 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
lonMinHun += 28;
|
||||
buffer.put(lonMinHun);
|
||||
|
||||
// encode speed/cou8rse
|
||||
// encode speed/course
|
||||
long speed = UnitTools.metersPerSecondToKnots(position.speedMetersPerSecond);
|
||||
byte speedHun = (byte)((speed / 10) + 28);
|
||||
buffer.put(speedHun);
|
||||
|
|
|
@ -9,8 +9,8 @@ public class Position {
|
|||
public double latitude;
|
||||
public double longitude;
|
||||
public double altitudeMeters;
|
||||
public float bearingDegrees;
|
||||
public float speedMetersPerSecond;
|
||||
public double bearingDegrees;
|
||||
public double speedMetersPerSecond;
|
||||
public String status;
|
||||
public String comment;
|
||||
public String symbolCode;
|
||||
|
|
|
@ -9,7 +9,7 @@ public class UnitTools {
|
|||
double degreesIntegral = Math.abs(degrees) - degreesFractional;
|
||||
degreesFractional *= 60;
|
||||
degreesIntegral *= 100;
|
||||
long nmeaDouble = (long)Math.round((degreesIntegral + degreesFractional) * 100.0);
|
||||
long nmeaDouble = Math.round((degreesIntegral + degreesFractional) * 100.0);
|
||||
return String.format(
|
||||
Locale.US,
|
||||
isLatitude ? "%06d%c" : "%07d%c",
|
||||
|
@ -44,15 +44,15 @@ public class UnitTools {
|
|||
return feet * 0.3048;
|
||||
}
|
||||
|
||||
public static long metersPerSecondToKnots(float metersPerSecond) {
|
||||
public static long metersPerSecondToKnots(double metersPerSecond) {
|
||||
return (long)(metersPerSecond / 0.514444);
|
||||
}
|
||||
|
||||
public static float knotsToMetersPerSecond(long knots) {
|
||||
return (float) (knots * 0.5144444);
|
||||
public static double knotsToMetersPerSecond(long knots) {
|
||||
return knots * 0.5144444;
|
||||
}
|
||||
|
||||
public static double metersPerSecondToMilesPerHour(float metersPerSecond) {
|
||||
public static double metersPerSecondToMilesPerHour(double metersPerSecond) {
|
||||
return metersPerSecond * 2.23693629;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class Smart implements Tracker {
|
|||
private boolean isCornerPeggingTriggered(Position newPosition, Position oldPosition) {
|
||||
long timeDifferenceSeconds = UnitTools.millisToSeconds(newPosition.timestampEpochMs - oldPosition.timestampEpochMs);
|
||||
|
||||
float turnAngleDegrees = Math.abs(newPosition.bearingDegrees - oldPosition.bearingDegrees) % 360;
|
||||
double turnAngleDegrees = Math.abs(newPosition.bearingDegrees - oldPosition.bearingDegrees) % 360;
|
||||
turnAngleDegrees = turnAngleDegrees <= 180 ? turnAngleDegrees : 360 - turnAngleDegrees;
|
||||
|
||||
if (!newPosition.hasBearing || newPosition.speedMetersPerSecond == 0)
|
||||
|
|
Ładowanie…
Reference in New Issue