kopia lustrzana https://github.com/sh123/codec2_talkie
Refactor date interface to include path
rodzic
5789bf40a3
commit
c4be79d6aa
|
@ -294,7 +294,7 @@ public class AppWorker extends Thread {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
String note = (src == null ? "UNK" : src) + "→" + (dst == null ? "UNK" : dst);
|
||||
sendStatusUpdate(AppMessage.EV_DATA_RECEIVED, note);
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ public class AppWorker extends Thread {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
String note = (src == null ? "UNK" : src) + "→" + (dst == null ? "UNK" : dst);
|
||||
sendStatusUpdate(AppMessage.EV_TRANSMITTED_VOICE, note);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.radio.codec2talkie.protocol;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
@ -91,7 +90,7 @@ public class Aprs implements Protocol {
|
|||
aprsData.fromTextMessage(textMessage);
|
||||
if (aprsData.isValid()) {
|
||||
textMessage.src = _srcCallsign;
|
||||
sendData(_srcCallsign, _dstCallsign, aprsData.toBinary());
|
||||
sendData(_srcCallsign, _dstCallsign, null, aprsData.toBinary());
|
||||
_parentProtocolCallback.onTransmitTextMessage(textMessage);
|
||||
} else {
|
||||
Log.e(TAG, "Invalid APRS message");
|
||||
|
@ -109,8 +108,8 @@ public class Aprs implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src == null ? _srcCallsign : src, dst == null ? _dstCallsign : dst, dataPacket);
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src == null ? _srcCallsign : src, dst == null ? _dstCallsign : dst, path, dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +140,7 @@ public class Aprs implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
if (data.length == 0) return;
|
||||
AprsDataType dataType = new AprsDataType((char)data[0]);
|
||||
AprsData aprsData = AprsDataFactory.fromBinary(src, dst, data);
|
||||
|
@ -158,7 +157,7 @@ public class Aprs implements Protocol {
|
|||
}
|
||||
}
|
||||
}
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,8 +192,8 @@ public class Aprs implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -235,7 +234,7 @@ public class Aprs implements Protocol {
|
|||
return;
|
||||
}
|
||||
if (aprsData.isValid()) {
|
||||
sendData(position.srcCallsign, position.dstCallsign, aprsData.toBinary());
|
||||
sendData(position.srcCallsign, position.dstCallsign, null, aprsData.toBinary());
|
||||
_parentProtocolCallback.onTransmitPosition(position);
|
||||
} else {
|
||||
Log.e(TAG, "Invalid APRS data");
|
||||
|
|
|
@ -63,8 +63,8 @@ public class AudioCodec2 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, dataPacket);
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, path, dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,8 +95,8 @@ public class AudioCodec2 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,8 +130,8 @@ public class AudioCodec2 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,8 +86,8 @@ public class AudioFrameAggregator implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, dataPacket);
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, path, dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,8 +129,8 @@ public class AudioFrameAggregator implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,8 +164,8 @@ public class AudioFrameAggregator implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -85,8 +85,8 @@ public class Ax25 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, dataPacket);
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, _digipath, dataPacket);
|
||||
AX25Packet ax25Packet = new AX25Packet();
|
||||
ax25Packet.src = src;
|
||||
ax25Packet.dst = dst;
|
||||
|
@ -98,7 +98,7 @@ public class Ax25 implements Protocol {
|
|||
Log.e(TAG, "Cannot convert AX.25 data packet to binary");
|
||||
_parentProtocolCallback.onProtocolTxError();
|
||||
} else {
|
||||
_childProtocol.sendData(src, dst, ax25Frame);
|
||||
_childProtocol.sendData(src, dst, _digipath, ax25Frame);
|
||||
_parentProtocolCallback.onTransmitLog(ax25Packet.toString());
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class Ax25 implements Protocol {
|
|||
if (ax25Data.isAudio) {
|
||||
_parentProtocolCallback.onReceiveCompressedAudio(ax25Data.src, ax25Data.dst, ax25Data.codec2Mode, ax25Data.rawData);
|
||||
} else {
|
||||
_parentProtocolCallback.onReceiveData(ax25Data.src, ax25Data.dst, ax25Data.rawData);
|
||||
_parentProtocolCallback.onReceiveData(ax25Data.src, ax25Data.dst, ax25Data.digipath, ax25Data.rawData);
|
||||
_parentProtocolCallback.onReceiveLog(ax25Data.toString());
|
||||
if (_isDigiRepeaterEnabled) digiRepeat(ax25Data);
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ public class Ax25 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,8 +178,8 @@ public class Ax25 implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -222,7 +222,7 @@ public class Ax25 implements Protocol {
|
|||
_parentProtocolCallback.onProtocolTxError();
|
||||
} else {
|
||||
try {
|
||||
_childProtocol.sendData(ax25Packet.src, ax25Packet.dst, ax25Frame);
|
||||
_childProtocol.sendData(ax25Packet.src, ax25Packet.dst, ax25Packet.digipath, ax25Frame);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Cannot send AX.25 digi repeated packet");
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -88,7 +88,7 @@ public class Freedv implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
if (dataPacket.length > _dataBuffer.length - 2) {
|
||||
Log.e(TAG, "Too large packet " + dataPacket.length + " > " + _dataBuffer.length);
|
||||
return;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class Hdlc implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_transport.write(hdlcEncode(dataPacket));
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ public class Kiss implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
// NOTE, KISS does not distinguish between audio and data packet, upper layer should decide
|
||||
send(dataPacket);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface Protocol {
|
|||
// messaging
|
||||
void sendTextMessage(TextMessage textMessage) throws IOException;
|
||||
// data
|
||||
void sendData(String src, String dst, byte[] dataPacket) throws IOException;
|
||||
void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException;
|
||||
// callback
|
||||
boolean receive() throws IOException;
|
||||
// gps
|
||||
|
|
|
@ -9,7 +9,7 @@ public abstract class ProtocolCallback {
|
|||
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 onReceiveTextMessage(TextMessage textMessage);
|
||||
abstract protected void onReceiveData(String src, String dst, byte[] data);
|
||||
abstract protected void onReceiveData(String src, String dst, String path, byte[] data);
|
||||
abstract protected void onReceiveSignalLevel(short rssi, short snr);
|
||||
abstract protected void onReceiveLog(String logData);
|
||||
|
||||
|
@ -18,7 +18,7 @@ public abstract class ProtocolCallback {
|
|||
abstract protected void onTransmitCompressedAudio(String src, String dst, int codec, byte[] frame);
|
||||
abstract protected void onTransmitTextMessage(TextMessage textMessage);
|
||||
abstract protected void onTransmitPosition(Position position);
|
||||
abstract protected void onTransmitData(String src, String dst, byte[] data);
|
||||
abstract protected void onTransmitData(String src, String dst, String path, byte[] data);
|
||||
abstract protected void onTransmitLog(String logData);
|
||||
|
||||
// errors
|
||||
|
|
|
@ -52,7 +52,7 @@ public class Raw implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_transport.write(Arrays.copyOf(dataPacket, dataPacket.length));
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ public class Recorder implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, dataPacket);
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
_childProtocol.sendData(src, dst, path, dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,8 +109,8 @@ public class Recorder implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,8 +144,8 @@ public class Recorder implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class Scrambler implements Protocol {
|
|||
if (result == null) {
|
||||
_parentProtocolCallback.onProtocolTxError();
|
||||
} else {
|
||||
_childProtocol.sendData(src, dst, result);
|
||||
_childProtocol.sendData(src, dst, null, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,12 @@ public class Scrambler implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
|
||||
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
|
||||
byte[] result = scramble(dataPacket);
|
||||
if (result == null) {
|
||||
_parentProtocolCallback.onProtocolTxError();
|
||||
} else {
|
||||
_childProtocol.sendData(src, dst, result);
|
||||
_childProtocol.sendData(src, dst, path, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,12 +113,12 @@ public class Scrambler implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveData(String src, String dst, byte[] scrambledData) {
|
||||
protected void onReceiveData(String src, String dst, String path, byte[] scrambledData) {
|
||||
byte[] data = unscramble(scrambledData);
|
||||
if (data == null) {
|
||||
_parentProtocolCallback.onProtocolRxError();
|
||||
} else {
|
||||
_parentProtocolCallback.onReceiveData(src, dst, data);
|
||||
_parentProtocolCallback.onReceiveData(src, dst, path, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,8 +153,8 @@ public class Scrambler implements Protocol {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onTransmitData(String src, String dst, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, data);
|
||||
protected void onTransmitData(String src, String dst, String path, byte[] data) {
|
||||
_parentProtocolCallback.onTransmitData(src, dst, path, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Ładowanie…
Reference in New Issue