Newer
Older
public class AX25Frame {
public static final byte AX25 = 0;
public static final byte TXDELAY = 1;
public static final byte P = 2;
public static final byte SlotTime = 3;
public static final byte TXtail = 4;
public static final byte Fullduplex = 5;
public static final byte SetHardware = 6;
public static final byte Exit1 = (byte) 255;
public static final byte unknow = -1;
byte[] rawData=null;
Callsign from;
Callsign to;
Callsign [] repeater = new Callsign[8];
char[] data;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public void decodeAX25Frame (byte[] frame , int lenght)
{
int offset = 0;
rawData=frame;
to = decodeCalsign( frame,offset);
offset=offset+7;
from = decodeCalsign( frame,offset);
offset=offset+7;
int i=0;
boolean valid=true;
while (valid)
{
if (frame[offset] !=0x03)
{
repeater[i]=decodeCalsign( frame,offset);
offset=offset+7;
i++;
}
else
{
valid=false;
}
if (i==8)
{
valid=false;
System.out.println("erreur de decodage");
}
}
controlID= frame[offset++];
protocolID= frame[offset++];
int datalengt = lenght-offset;
data = new char[datalengt];
int j=0;
for ( j =0; j<datalengt;j++)
{
data[j]=(char) frame[offset++];
}
}
public Callsign decodeCalsign(byte[] arg0,int offset) {
Callsign calsign = new Callsign();
for (int i=0;i<6;i++)
{
char c= (char) ((arg0[i+offset] & 0xFF) >>1 & 0x7F);
val[i] = c;
}
calsign.setCallsign(val);
calsign.setSsid((char)((arg0[6+offset]>>1) & 0xFF));
return calsign;
}
public String getData()
{
return String.valueOf(data);
}
public String toString()
{
return "from : "+ from.toString()+" to : "+to.toString() +" data :"+ String.valueOf(data);
}
public String toStringHexa() {
// TODO Auto-generated method stub
return "string Hexa";
}
public String toStringHeader() {
// TODO Auto-generated method stub
return "string Header";
}