kopia lustrzana https://github.com/sh123/codec2_talkie
Update fromBinary interface to include destination callsign
rodzic
c2c48ae279
commit
62e2f6b75d
|
@ -145,7 +145,7 @@ public class Aprs implements Protocol {
|
|||
protected void onReceiveData(String src, String dst, byte[] data) {
|
||||
if (data.length == 0) return;
|
||||
AprsDataType dataType = new AprsDataType((char)data[0]);
|
||||
AprsData aprsData = AprsDataFactory.fromBinary(data);
|
||||
AprsData aprsData = AprsDataFactory.fromBinary(dst, data);
|
||||
if (aprsData != null && aprsData.isValid()) {
|
||||
if (dataType.isTextMessage()) {
|
||||
TextMessage textMessage = aprsData.toTextMessage();
|
||||
|
|
|
@ -8,7 +8,7 @@ public interface AprsData {
|
|||
void fromTextMessage(TextMessage textMessage);
|
||||
Position toPosition();
|
||||
TextMessage toTextMessage();
|
||||
void fromBinary(byte[] infoData);
|
||||
void fromBinary(String dstCallsign, byte[] infoData);
|
||||
byte[] toBinary();
|
||||
boolean isValid();
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ public class AprsDataFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static AprsData fromBinary(byte[] infoData) {
|
||||
public static AprsData fromBinary(String dstCallsign, byte[] infoData) {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(infoData);
|
||||
AprsDataType dataType = new AprsDataType((char)buffer.get());
|
||||
AprsData aprsData = create(dataType);
|
||||
if (aprsData == null) return null;
|
||||
byte[] data = new byte[buffer.remaining()];
|
||||
buffer.get(data);
|
||||
aprsData.fromBinary(data);
|
||||
aprsData.fromBinary(dstCallsign, data);
|
||||
return aprsData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class AprsDataPositionReport implements AprsData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromBinary(byte[] infoData) {
|
||||
public void fromBinary(String dstCallsign, byte[] infoData) {
|
||||
_isValid = false;
|
||||
_position = new Position();
|
||||
if ((infoData[0] == '/' || infoData[0] == '\\') && fromCompressedBinary(infoData)) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class AprsDataPositionReportMicE implements AprsData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromBinary(byte[] infoData) {
|
||||
public void fromBinary(String dstCallsign, byte[] infoData) {
|
||||
_isValid = false;
|
||||
// TODO, implement fromBinary, needs dst callsign
|
||||
// ByteBuffer buffer = ByteBuffer.wrap(infoData);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class AprsDataTextMessage implements AprsData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromBinary(byte[] infoData) {
|
||||
public void fromBinary(String dstCallsign, byte[] infoData) {
|
||||
_isValid = false;
|
||||
if (infoData.length < 10) return;
|
||||
ByteBuffer buffer = ByteBuffer.wrap(infoData);
|
||||
|
|
Ładowanie…
Reference in New Issue