|
| 1 | +/* |
| 2 | + * ***************************************************************************** |
| 3 | + * Copyright (C) 2014-2024 Dennis Sheirer |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
| 17 | + * **************************************************************************** |
| 18 | + */ |
| 19 | + |
| 20 | +package io.github.dsheirer.module.decode.p25.phase2.message.mac.structure.motorola; |
| 21 | + |
| 22 | +import io.github.dsheirer.bits.CorrectedBinaryMessage; |
| 23 | +import io.github.dsheirer.bits.IntField; |
| 24 | +import io.github.dsheirer.identifier.Identifier; |
| 25 | +import io.github.dsheirer.identifier.radio.RadioIdentifier; |
| 26 | +import io.github.dsheirer.module.decode.p25.identifier.radio.APCO25RadioIdentifier; |
| 27 | +import io.github.dsheirer.module.decode.p25.phase2.message.mac.structure.MacStructureVendor; |
| 28 | +import java.util.Collections; |
| 29 | +import java.util.List; |
| 30 | + |
| 31 | +/** |
| 32 | + * Motorola Group Radios Active Feature. Observed on NM-DTRS Phase 2 network. My theory is that this lists the |
| 33 | + * subset of talkgroup member radios that are currently active on the traffic channel. |
| 34 | + * |
| 35 | + * Opcodes 130 and 143 are almost the same, except 143 is mostly transmitted during an ACTIVE call state and 130 is |
| 36 | + * mostly transmitted during the HANGTIME state. I say mostly, because there are examples where both opcodes are seen |
| 37 | + * in both channel states. |
| 38 | + * |
| 39 | + * Curiously: opcode 130 is in the middle of the message number sequence where GROUP REGROUP messages are allocated. |
| 40 | + * |
| 41 | + * Opcode 143 includes an additional 1-byte status field that seems to contain a 2-bit sequence counter that mostly |
| 42 | + * cycles through all values, but sometimes it skips values or just toggles between two of the observed values. |
| 43 | + * Examples: 0x00, 0x40, 0x80, 0xC0 |
| 44 | + * There doesn't seem to be any correlation between the value of this nibble and the radio IDs being transmitted. |
| 45 | + * |
| 46 | + * The lower nibble of this 1-byte field seems to have an additional flag bit that is sometimes transmitted: |
| 47 | + * Examples: 0x08, 0x88 |
| 48 | + * |
| 49 | + * Both opcode 130 and 143 employ up to 2x 1-byte fields that always transmit a 0x09 value. The second field is only |
| 50 | + * present when the message is sending 3 or 4 radio IDs. |
| 51 | + * |
| 52 | + * It seems that the complete list of active member radios is transmitted in a fixed sequence with zero to four of those |
| 53 | + * radios transmitted per message. The messages are transmitted when the talkgroup is first allocated to the channel |
| 54 | + * and eventually the 130/143 messages stop listing radios and the empty 143 and the 191 messages are intermittently |
| 55 | + * sent. Occasionally there are radios listed in the message with all zeros values. |
| 56 | + * |
| 57 | + * Opcode 143 is transmitted with just the status byte and no radio IDs after the full sequence of radios has been |
| 58 | + * sent and are no longer being sent. |
| 59 | + * |
| 60 | + * I'm not sure what Opcode 191 indicates. It's always the same (3-bytes) value: BF9003. It may be some kind of |
| 61 | + * feature marker to let the listening radios/devices know that the feature is active on that traffic channel. |
| 62 | + * |
| 63 | + * These three opcodes seem to be used for this feature. |
| 64 | + * Opcode 130/x82 - talkgroup member radios currently active - mostly transmitted during HANGTIME |
| 65 | + * Opcode 143/x8F - talkgroup member radios currently active - mostly transmitted during ACTIVE call state |
| 66 | + * Opcode 191/xBF - transmitted continuously while channel is allocated to a talkgroup - fixed value: 0xBF9003 |
| 67 | + */ |
| 68 | +public class MotorolaActiveGroupRadiosOpcode130_x82 extends MacStructureVendor |
| 69 | +{ |
| 70 | + private static final IntField SEPARATOR_1 = IntField.length8(OCTET_4_BIT_24); //Value is always 0x09 |
| 71 | + private static final IntField RADIO_1 = IntField.length24(OCTET_5_BIT_32); |
| 72 | + private static final IntField RADIO_2 = IntField.length24(OCTET_8_BIT_56); |
| 73 | + private static final IntField SEPARATOR_2 = IntField.length8(OCTET_11_BIT_80); //Value is always 0x09 |
| 74 | + private static final IntField RADIO_3 = IntField.length24(OCTET_12_BIT_88); |
| 75 | + private static final IntField RADIO_4 = IntField.length24(OCTET_15_BIT_112); |
| 76 | + private RadioIdentifier mRadio1; |
| 77 | + private RadioIdentifier mRadio2; |
| 78 | + private RadioIdentifier mRadio3; |
| 79 | + private RadioIdentifier mRadio4; |
| 80 | + |
| 81 | + /** |
| 82 | + * Constructs the message |
| 83 | + * |
| 84 | + * @param message containing the message bits |
| 85 | + * @param offset into the message for this structure |
| 86 | + */ |
| 87 | + public MotorolaActiveGroupRadiosOpcode130_x82(CorrectedBinaryMessage message, int offset) |
| 88 | + { |
| 89 | + super(message, offset); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Textual representation of this message |
| 94 | + */ |
| 95 | + public String toString() |
| 96 | + { |
| 97 | + StringBuilder sb = new StringBuilder(); |
| 98 | + sb.append("MOTOROLA 130 ACTIVE GROUP RADIOS: "); |
| 99 | + sb.append(getRadio1()); |
| 100 | + |
| 101 | + if(hasRadio2()) |
| 102 | + { |
| 103 | + sb.append(", ").append(getRadio2()); |
| 104 | + |
| 105 | + if(hasRadio3()) |
| 106 | + { |
| 107 | + sb.append(", ").append(getRadio3()); |
| 108 | + |
| 109 | + if(hasRadio4()) |
| 110 | + { |
| 111 | + sb.append(", ").append(getRadio4()); |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + CorrectedBinaryMessage cbm = getMessage().getSubMessage(getOffset(), getOffset() + (getLength() * 8)); |
| 117 | + sb.append(" MSG:").append(cbm.toHexString()); |
| 118 | + |
| 119 | + return sb.toString(); |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * Radio identifier or null if the message doesn't contain the value. |
| 124 | + */ |
| 125 | + public RadioIdentifier getRadio1() |
| 126 | + { |
| 127 | + if(mRadio1 == null && hasRadio1()) |
| 128 | + { |
| 129 | + mRadio1 = APCO25RadioIdentifier.createAny(getInt(RADIO_1)); |
| 130 | + } |
| 131 | + |
| 132 | + return mRadio1; |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Radio identifier or null if the message doesn't contain the value. |
| 137 | + */ |
| 138 | + public RadioIdentifier getRadio2() |
| 139 | + { |
| 140 | + if(mRadio2 == null && hasRadio2()) |
| 141 | + { |
| 142 | + mRadio2 = APCO25RadioIdentifier.createAny(getInt(RADIO_2)); |
| 143 | + } |
| 144 | + |
| 145 | + return mRadio2; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Radio identifier or null if the message doesn't contain the value. |
| 150 | + */ |
| 151 | + public RadioIdentifier getRadio3() |
| 152 | + { |
| 153 | + if(mRadio3 == null && hasRadio3()) |
| 154 | + { |
| 155 | + mRadio3 = APCO25RadioIdentifier.createAny(getInt(RADIO_3)); |
| 156 | + } |
| 157 | + |
| 158 | + return mRadio3; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * Radio identifier or null if the message doesn't contain the value. |
| 163 | + */ |
| 164 | + public RadioIdentifier getRadio4() |
| 165 | + { |
| 166 | + if(mRadio4 == null && hasRadio4()) |
| 167 | + { |
| 168 | + mRadio4 = APCO25RadioIdentifier.createAny(getInt(RADIO_4)); |
| 169 | + } |
| 170 | + |
| 171 | + return mRadio4; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Indicates if this message contains the radio value. |
| 176 | + */ |
| 177 | + public boolean hasRadio1() |
| 178 | + { |
| 179 | + return getLength() > 4; |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Indicates if this message contains the radio value. |
| 184 | + */ |
| 185 | + public boolean hasRadio2() |
| 186 | + { |
| 187 | + return getLength() > 8; |
| 188 | + } |
| 189 | + |
| 190 | + /** |
| 191 | + * Indicates if this message contains the radio value. |
| 192 | + */ |
| 193 | + public boolean hasRadio3() |
| 194 | + { |
| 195 | + return getLength() > 11; |
| 196 | + } |
| 197 | + |
| 198 | + /** |
| 199 | + * Indicates if this message contains the radio value. |
| 200 | + */ |
| 201 | + public boolean hasRadio4() |
| 202 | + { |
| 203 | + return getLength() > 15; |
| 204 | + } |
| 205 | + |
| 206 | + @Override |
| 207 | + public List<Identifier> getIdentifiers() |
| 208 | + { |
| 209 | + return Collections.emptyList(); |
| 210 | + } |
| 211 | +} |
0 commit comments