Newer
Older
package org.josast.AX25;
import java.util.logging.Level;
import java.util.logging.Logger;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
public static final int AX25 = 0;
public static final int TXDELAY = 1;
public static final int P = 2;
public static final int SlotTime = 3;
public static final int TXtail = 4;
public static final int Fullduplex = 5;
public static final int SetHardware = 6;
public static final int Exit = 255;
public static final int unknow = -1;
public int cptcontents = 0;
private Logger log = Logger.getLogger("AmsatLogger");
private byte type;
private byte[] contents = new byte[1050];
@Deprecated
public void setType(byte ax252) {
type = ax252;
}
@Deprecated
public byte DecodeKissType(final byte val) {
switch (val) {
case 0x00:
type = AX25;
log.log(Level.INFO, "AX25 type");
break;
case 0x01:
type = TXDELAY;
break;
case 0x02:
type = P;
break;
case 0x03:
type = SlotTime;
break;
case 0x04:
type = TXtail;
break;
case 0x05:
type = Fullduplex;
break;
case 0x07:
type = SetHardware;
break;
case (byte) 0xFF:
type = (byte) Exit;
break;
default:
type = unknow;
log.log(Level.INFO, "unknow type");
}
return type;
}
@Deprecated
public KissData extactMessage(byte[] frame, int nb) {
KissData kissData;
type = unknow;
boolean startFrame = false;
boolean endFrame = false;
int cpt = 0;
cptcontents = 0;
// detect start frame
while (!startFrame) {
if (((byte) frame[cpt++] & 0xFF) == 0xC0) {
startFrame = true;
}
if (cpt == nb) {
startFrame = true;
endFrame = true;
}
}
// identify frame
type = DecodeKissType((byte) (frame[cpt++] & 0xFF));
// Extract data
while (!endFrame) {
if (((int) frame[cpt] & 0xFF) == 0xDB) {
cpt++;
}
if (((int) frame[cpt] & 0xFF) == 0xDD) {
cpt++;
}
if (((int) frame[cpt] & 0xFF) == 0xC0) {
endFrame = true;
}
contents[cptcontents++] = (byte) (frame[cpt++] & 0xFF);
if (cpt >= nb) {
endFrame = true;
}
}
kissData = new KissData(contents, cptcontents);
return kissData;
}