diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/MainActivity.java b/codec2talkie/src/main/java/com/radio/codec2talkie/MainActivity.java
index d5b079e..e40611d 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/MainActivity.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/MainActivity.java
@@ -307,6 +307,10 @@ public class MainActivity extends AppCompatActivity {
Toast.makeText(getBaseContext(), "Not implemented", Toast.LENGTH_SHORT).show();
return true;
}
+ else if (itemId == R.id.aprs_log) {
+ Toast.makeText(getBaseContext(), "Not implemented", Toast.LENGTH_SHORT).show();
+ return true;
+ }
return super.onOptionsItemSelected(item);
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/audio/AudioProcessor.java b/codec2talkie/src/main/java/com/radio/codec2talkie/audio/AudioProcessor.java
index 89030e8..82fd614 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/audio/AudioProcessor.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/audio/AudioProcessor.java
@@ -21,6 +21,7 @@ import java.util.TimerTask;
import com.radio.codec2talkie.protocol.Callback;
import com.radio.codec2talkie.protocol.Protocol;
import com.radio.codec2talkie.protocol.ProtocolFactory;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.tools.AudioTools;
import com.radio.codec2talkie.transport.Transport;
@@ -207,7 +208,7 @@ public class AudioProcessor extends Thread {
private final Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Aprs.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Aprs.java
index 2cdcefe..8c11a8e 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Aprs.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Aprs.java
@@ -2,25 +2,38 @@ package com.radio.codec2talkie.protocol;
import android.content.Context;
import android.content.SharedPreferences;
+import android.util.Log;
import androidx.preference.PreferenceManager;
+import com.radio.codec2talkie.audio.AudioProcessor;
import com.radio.codec2talkie.protocol.aprs.AprsCallsign;
+import com.radio.codec2talkie.protocol.aprs.AprsData;
+import com.radio.codec2talkie.protocol.aprs.AprsDataFactory;
+import com.radio.codec2talkie.protocol.aprs.AprsDataType;
+import com.radio.codec2talkie.protocol.position.Position;
+import com.radio.codec2talkie.protocol.ax25.AX25Callsign;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.transport.Transport;
import java.io.IOException;
public class Aprs implements Protocol {
+ private static final String TAG = Aprs.class.getSimpleName();
private final Protocol _childProtocol;
- private String _srcCallsign;
- private String _dstCallsign;
-
private Callback _parentCallback;
- boolean _isVoax25Enabled;
+ private String _srcCallsign;
+ private String _dstCallsign;
+ private String _symbolCode;
+ private String _status;
+ private String _comment;
+ private boolean _isVoax25Enabled;
+ private boolean _isCompressed;
+
+ private AprsDataType _positionDataType;
public Aprs(Protocol childProtocol) {
_childProtocol = childProtocol;
@@ -33,9 +46,21 @@ public class Aprs implements Protocol {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
_isVoax25Enabled = sharedPreferences.getBoolean(PreferenceKeys.APRS_VOAX25_ENABLE, false);
- _srcCallsign = sharedPreferences.getString(PreferenceKeys.APRS_CALLSIGN, "NOCALL") + "-" +
- sharedPreferences.getString(PreferenceKeys.APRS_SSID, "0");
+
+ _srcCallsign = AX25Callsign.formatCallsign(
+ sharedPreferences.getString(PreferenceKeys.APRS_CALLSIGN, "NOCALL"),
+ sharedPreferences.getString(PreferenceKeys.APRS_SSID, "0"));
_dstCallsign = "APZMDM";
+
+ _symbolCode = sharedPreferences.getString(PreferenceKeys.APRS_SYMBOL, "/[");
+ String packetFormat = sharedPreferences.getString(PreferenceKeys.APRS_LOCATION_PACKET_FORMAT, "uncompressed");
+ _status = sharedPreferences.getString(PreferenceKeys.APRS_LOCATION_MIC_E_MESSAGE_TYPE, "off_duty");
+ _comment = sharedPreferences.getString(PreferenceKeys.APRS_COMMENT, "off_duty");
+ _isCompressed = packetFormat.equals("compressed");
+
+ AprsDataType.DataType dataType = packetFormat.equals("mic_e") ?
+ AprsDataType.DataType.MIC_E : AprsDataType.DataType.POSITION_WITHOUT_TIMESTAMP_MSG;
+ _positionDataType = new AprsDataType(dataType);
}
@Override
@@ -70,7 +95,7 @@ public class Aprs implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -134,8 +159,22 @@ public class Aprs implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
- // TODO, implement
+ public void sendPosition(Position position) throws IOException {
+ position.dstCallsign = _dstCallsign;
+ position.srcCallsign = _srcCallsign;
+ position.symbolCode = _symbolCode;
+ position.comment = _comment;
+ position.status = _status;
+ position.isCompressed = _isCompressed;
+ AprsData aprsData = AprsDataFactory.create(_positionDataType);
+ if (aprsData != null) {
+ aprsData.fromPosition(position);
+ if (aprsData.isValid()) {
+ sendData(position.srcCallsign, position.dstCallsign, aprsData.toBinary());
+ } else {
+ Log.e(TAG, "Send position protocol error");
+ }
+ }
}
@Override
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioCodec2.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioCodec2.java
index cdf198f..335f97f 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioCodec2.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioCodec2.java
@@ -2,6 +2,7 @@ package com.radio.codec2talkie.protocol;
import android.content.Context;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.transport.Transport;
import com.ustadmobile.codec2.Codec2;
@@ -68,7 +69,7 @@ public class AudioCodec2 implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -130,7 +131,7 @@ public class AudioCodec2 implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioFrameAggregator.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioFrameAggregator.java
index 3a1fb40..e641ccd 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioFrameAggregator.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/AudioFrameAggregator.java
@@ -6,6 +6,7 @@ import android.util.Log;
import androidx.preference.PreferenceManager;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.transport.Transport;
import com.ustadmobile.codec2.Codec2;
@@ -90,7 +91,7 @@ public class AudioFrameAggregator implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -163,7 +164,7 @@ public class AudioFrameAggregator implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Ax25.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Ax25.java
index aad2938..cea5bea 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Ax25.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Ax25.java
@@ -7,6 +7,7 @@ import android.util.Log;
import androidx.preference.PreferenceManager;
import com.radio.codec2talkie.protocol.ax25.AX25Packet;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.transport.Transport;
@@ -92,7 +93,7 @@ public class Ax25 implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -164,7 +165,7 @@ public class Ax25 implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Callback.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Callback.java
index 3e11c6c..1db96b3 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Callback.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Callback.java
@@ -1,8 +1,10 @@
package com.radio.codec2talkie.protocol;
+import com.radio.codec2talkie.protocol.position.Position;
+
public abstract class Callback {
// receive
- abstract protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment);
+ abstract protected void onReceivePosition(Position position);
abstract protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame);
abstract protected void onReceiveCompressedAudio(String src, String dst, int codec, byte[] frame);
abstract protected void onReceiveData(String src, String dst, byte[] data);
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Kiss.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Kiss.java
index b2fb264..c6a1a2e 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Kiss.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Kiss.java
@@ -11,6 +11,7 @@ import android.widget.Toast;
import androidx.preference.PreferenceManager;
import com.radio.codec2talkie.R;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.transport.Transport;
@@ -228,7 +229,7 @@ public class Kiss implements Protocol {
}
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Protocol.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Protocol.java
index ab6239e..74b4b46 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Protocol.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Protocol.java
@@ -2,6 +2,7 @@ package com.radio.codec2talkie.protocol;
import android.content.Context;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.transport.Transport;
import java.io.IOException;
@@ -18,7 +19,7 @@ public interface Protocol {
// callback
boolean receive() throws IOException;
// gps
- void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment);
+ void sendPosition(Position position) throws IOException;
// control
void flush() throws IOException;
void close();
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Raw.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Raw.java
index d8a6a58..279b995 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Raw.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Raw.java
@@ -2,6 +2,7 @@ package com.radio.codec2talkie.protocol;
import android.content.Context;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.transport.Transport;
import java.io.IOException;
@@ -57,7 +58,7 @@ public class Raw implements Protocol {
}
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Recorder.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Recorder.java
index eb2ae46..0a970f1 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Recorder.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Recorder.java
@@ -5,6 +5,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.radio.codec2talkie.MainActivity;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.tools.StorageTools;
import com.radio.codec2talkie.transport.Transport;
@@ -80,7 +81,7 @@ public class Recorder implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -143,7 +144,7 @@ public class Recorder implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Scrambler.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Scrambler.java
index 036a720..a17e76f 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Scrambler.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Scrambler.java
@@ -6,6 +6,7 @@ import android.util.Log;
import androidx.preference.PreferenceManager;
+import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.tools.ScramblingTools;
import com.radio.codec2talkie.transport.Transport;
@@ -80,7 +81,7 @@ public class Scrambler implements Protocol {
Callback _protocolCallback = new Callback() {
@Override
- protected void onReceivePosition(String src, double latitude, double longitude, double altitude, float bearing, String comment) {
+ protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
}
@@ -152,7 +153,7 @@ public class Scrambler implements Protocol {
};
@Override
- public void sendPosition(double latitude, double longitude, double altitude, float bearing, String comment) {
+ public void sendPosition(Position position) {
throw new UnsupportedOperationException();
}
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsData.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsData.java
index 5723ea4..230c708 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsData.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsData.java
@@ -1,7 +1,10 @@
package com.radio.codec2talkie.protocol.aprs;
+import com.radio.codec2talkie.protocol.position.Position;
+
public interface AprsData {
- void fromPosition(AprsPosition position);
+ void fromPosition(Position position);
+ Position toPosition();
void fromBinary(byte[] infoData);
byte[] toBinary();
boolean isValid();
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataFactory.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataFactory.java
index 1b84e2d..de10692 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataFactory.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataFactory.java
@@ -7,12 +7,12 @@ public class AprsDataFactory {
switch (aprsDataType.getDataType()) {
case UNKNOWN:
case MESSAGE:
- break;
case MIC_E:
case POSITION_WITH_TIMESTAMP_MSG:
case POSITION_WITH_TIMESTAMP_NO_MSG:
- case POSITION_WITHOUT_TIMESTAMP_MSG:
case POSITION_WITHOUT_TIMESTAMP_NO_MSG:
+ break;
+ case POSITION_WITHOUT_TIMESTAMP_MSG:
return new AprsDataPositionReport();
}
return null;
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataPositionReport.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataPositionReport.java
index dff63dd..0b50f37 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataPositionReport.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsDataPositionReport.java
@@ -1,8 +1,16 @@
package com.radio.codec2talkie.protocol.aprs;
+import com.radio.codec2talkie.protocol.position.Position;
+
public class AprsDataPositionReport implements AprsData {
+
@Override
- public void fromPosition(AprsPosition position) {
+ public void fromPosition(Position position) {
+ }
+
+ @Override
+ public Position toPosition() {
+ return null;
}
@Override
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/ax25/AX25Callsign.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/ax25/AX25Callsign.java
index 5ad7786..df087e1 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/ax25/AX25Callsign.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/ax25/AX25Callsign.java
@@ -12,6 +12,10 @@ public class AX25Callsign {
public boolean isValid;
public boolean isLast = false;
+ public static String formatCallsign(String callsign, String ssid) {
+ return String.format("%s-%s", callsign, ssid);
+ }
+
public void fromString(String callsignWithSsid) {
isValid = false;
// ABCDEF-XX
diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsPosition.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/position/Position.java
similarity index 51%
rename from codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsPosition.java
rename to codec2talkie/src/main/java/com/radio/codec2talkie/protocol/position/Position.java
index 7824eb4..96e655a 100644
--- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/aprs/AprsPosition.java
+++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/position/Position.java
@@ -1,11 +1,15 @@
-package com.radio.codec2talkie.protocol.aprs;
+package com.radio.codec2talkie.protocol.position;
-public class AprsPosition {
+public class Position {
+ public String timestamp;
+ public String srcCallsign;
+ public String dstCallsign;
public double latitude;
public double longitude;
public double altitude;
public float bearing;
+ public String status;
public String comment;
- public String timestamp;
+ public String symbolCode;
public boolean isCompressed;
}
diff --git a/codec2talkie/src/main/res/menu/main_menu.xml b/codec2talkie/src/main/res/menu/main_menu.xml
index e4fe0a7..7a46715 100644
--- a/codec2talkie/src/main/res/menu/main_menu.xml
+++ b/codec2talkie/src/main/res/menu/main_menu.xml
@@ -10,6 +10,9 @@
+
- Start tracking
Send position
☎
+ View log
\ No newline at end of file