-
Notifications
You must be signed in to change notification settings - Fork 240
/
LDUMessage.java
101 lines (91 loc) · 3.76 KB
/
LDUMessage.java
1
2
3
4
5
6
7
8
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
/*
* *****************************************************************************
* Copyright (C) 2014-2024 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.module.decode.p25.phase1.message.ldu;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.P25Message;
import java.util.ArrayList;
import java.util.List;
/**
* LDU voice frame
*/
public abstract class LDUMessage extends P25Message
{
public static final int IMBE_FRAME_1 = 0;
public static final int IMBE_FRAME_2 = 144;
public static final int IMBE_FRAME_3 = 328;
public static final int IMBE_FRAME_4 = 512;
public static final int IMBE_FRAME_5 = 696;
public static final int IMBE_FRAME_6 = 880;
public static final int IMBE_FRAME_7 = 1064;
public static final int IMBE_FRAME_8 = 1248;
public static final int IMBE_FRAME_9 = 1424;
public static final int[] LOW_SPEED_DATA = {1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1408, 1409, 1410, 1411,
1412, 1413, 1414, 1415};
private List<byte[]> mIMBIFrames;
/**
* Constructs an instance
* @param message with data
* @param nac code
* @param timestamp for the message
*/
public LDUMessage(CorrectedBinaryMessage message, int nac, long timestamp)
{
super(message, nac, timestamp);
}
/**
* Low speed data field contents.
*/
public String getLowSpeedData()
{
return getMessage().getHex(LOW_SPEED_DATA, 4);
}
/**
* Base message used by subclass implementations.
* @return base message
*/
public String getMessageStub()
{
StringBuilder sb = new StringBuilder();
sb.append(super.getMessageStub());
sb.append(" VOICE LSD:");
sb.append(getLowSpeedData());
return sb.toString();
}
/**
* Returns a 162 byte array containing 9 IMBE voice frames of 18-bytes* (144-bits) each. Each frame is intact as
* transmitted and requires deinterleaving, error correction, derandomizing, etc.
*/
public synchronized List<byte[]> getIMBEFrames()
{
if(mIMBIFrames == null)
{
mIMBIFrames = new ArrayList<>();
mIMBIFrames.add(getMessage().get(IMBE_FRAME_1, IMBE_FRAME_1 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_2, IMBE_FRAME_2 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_3, IMBE_FRAME_3 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_4, IMBE_FRAME_4 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_5, IMBE_FRAME_5 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_6, IMBE_FRAME_6 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_7, IMBE_FRAME_7 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_8, IMBE_FRAME_8 + 144).toByteArray());
mIMBIFrames.add(getMessage().get(IMBE_FRAME_9, IMBE_FRAME_9 + 144).toByteArray());
}
return mIMBIFrames;
}
}