1
1
package com .radio .codec2talkie .protocol .aprs ;
2
2
3
+ import android .icu .number .FormattedNumber ;
4
+ import android .util .Log ;
5
+
3
6
import com .radio .codec2talkie .protocol .aprs .tools .AprsTools ;
4
7
import com .radio .codec2talkie .protocol .message .TextMessage ;
5
8
import com .radio .codec2talkie .protocol .position .Position ;
9
+ import com .radio .codec2talkie .tools .DeviceIdTools ;
6
10
import com .radio .codec2talkie .tools .TextTools ;
7
11
import com .radio .codec2talkie .tools .UnitTools ;
8
12
@@ -191,7 +195,12 @@ public void fromBinary(String srcCallsign, String dstCallsign, String digipath,
191
195
latitude .append (c );
192
196
}
193
197
194
- _position .latitude = UnitTools .nmeaToDecimal (latitude .toString (), Character .toString (ns ));
198
+ try {
199
+ _position .latitude = UnitTools .nmeaToDecimal (latitude .toString (), Character .toString (ns ));
200
+ } catch (NumberFormatException e ) {
201
+ e .printStackTrace ();
202
+ return ;
203
+ }
195
204
_position .status = isCustom
196
205
? _miceMessageReverseTypeMapCustom .get (messageId )
197
206
: _miceMessageReverseTypeMapStd .get (messageId );
@@ -207,7 +216,12 @@ public void fromBinary(String srcCallsign, String dstCallsign, String digipath,
207
216
int h = ((int )infoData [2 ] - 28 );
208
217
209
218
String longitude = String .format (Locale .US , "%03d%02d.%02d" , d , m , h );
210
- _position .longitude = UnitTools .nmeaToDecimal (longitude , Character .toString (we ));
219
+ try {
220
+ _position .longitude = UnitTools .nmeaToDecimal (longitude , Character .toString (we ));
221
+ } catch (NumberFormatException e ) {
222
+ e .printStackTrace ();
223
+ return ;
224
+ }
211
225
212
226
// read course/speed
213
227
int sp = 10 * ((int )infoData [3 ] - 28 );
@@ -244,7 +258,16 @@ public void fromBinary(String srcCallsign, String dstCallsign, String digipath,
244
258
} else {
245
259
i --;
246
260
}
247
- _position .comment = TextTools .stripNulls (new String (Arrays .copyOfRange (infoData , i + 1 , infoData .length ), StandardCharsets .UTF_8 ));
261
+ String comment = new String (Arrays .copyOfRange (infoData , i + 1 , infoData .length ), StandardCharsets .UTF_8 ).strip ();
262
+ if (comment .length () >= 2 ) {
263
+ String deviceId = comment .substring (comment .length () - 2 );
264
+ String deviceIdDescription = DeviceIdTools .getMiceDeviceDescription (deviceId );
265
+ if (deviceIdDescription != null ) {
266
+ _position .deviceIdDescription = deviceIdDescription ;
267
+ comment = comment .substring (0 , comment .length () - 2 );
268
+ }
269
+ }
270
+ _position .comment = TextTools .stripNulls (comment );
248
271
}
249
272
250
273
_position .maidenHead = UnitTools .decimalToMaidenhead (_position .latitude , _position .longitude );
0 commit comments