Skip to content

Commit 822aeb5

Browse files
committed
Add BDS21 Registration & Airline
1 parent 1fd5a06 commit 822aeb5

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ We hope with more BDS implemented the guessing accuracy will improve.
112112
| 1,E | Mode S services GICB capability report ||
113113
| 1,F | Mode S services GICB capability report ||
114114
| 2,0 | Aircraft Identification ||
115-
| 2,1 | Aircraft and Airline registration marking | |
115+
| 2,1 | Aircraft and Airline registration marking | ⚠️ | Experimental
116116
| 2,2 | Antenna positions ||
117117
| 2,5 | Antenna type ||
118118
| 3,0 | ACAS Active resolution advisory | ❌ | Detection implemented, decoding missing
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package aero.t2s.modes.decoder.df.bds;
2+
3+
import aero.t2s.modes.Track;
4+
import aero.t2s.modes.decoder.Common;
5+
6+
public class Bds21 extends Bds {
7+
@Override
8+
public boolean attemptDecode(Track track, short[] data) {
9+
if (track.getCapabilityReport().isAvailable() && !track.getCapabilityReport().isBds21()) {
10+
return false;
11+
}
12+
13+
boolean aircraftRegistrationStatus = (data[4] & 0b10000000) != 0;
14+
boolean airlineRegistrationStatus = (data[9] & 0b00010000) != 0;
15+
16+
if (!aircraftRegistrationStatus && (data[4] | data[5] | data[6] | data[7] | data[8] | data[9] >>> 5) != 0) {
17+
return false;
18+
}
19+
20+
if (!airlineRegistrationStatus && ((data[9] & 0b00001111) | data[10]) != 0) {
21+
return false;
22+
}
23+
24+
if (aircraftRegistrationStatus) {
25+
String registration = Common.charToString((data[4] & 0b01111110) >>> 1) // Char 1
26+
+ Common.charToString(((data[4] & 0b00000001) << 5) | (data[5] >>> 3)) // Char 2
27+
+ Common.charToString(((data[5] & 0b00000111) << 3) | (data[6] >>> 5)) // Char 3
28+
+ Common.charToString(((data[6] & 0b00011111) << 1) | (data[7] >>> 7)) // Char 4
29+
+ Common.charToString((data[7] & 0b01111110) >>> 1) // Char 5
30+
+ Common.charToString(((data[7] & 0b00000001) << 5) | (data[8] >>> 3)) // Char 6
31+
+ Common.charToString(((data[8] & 0b00000111) << 3) | (data[9] >>> 3)) // Char 7
32+
;
33+
34+
35+
if (registration.contains("#")) {
36+
return false;
37+
}
38+
39+
track.setRegistration(registration.replace("_", ""));
40+
}
41+
42+
if (airlineRegistrationStatus) {
43+
String airline = Common.charToString(((data[9] & 0b00001111) << 2 | (data[10] >>> 6)))
44+
+ Common.charToString(data[10] & 0b00111111);
45+
46+
if (airline.contains("_") || airline.contains("#")) {
47+
return false;
48+
}
49+
50+
track.setOperator(airline);
51+
}
52+
53+
return true;
54+
}
55+
}

mode-s/src/main/java/aero/t2s/modes/decoder/df/bds/BdsDecoder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public BdsDecoder() {
2020
bdsDecoder.add(new Bds50());
2121
bdsDecoder.add(new Bds53());
2222
bdsDecoder.add(new Bds60());
23+
bdsDecoder.add(new Bds21());
2324
}
2425

2526
public boolean decode(Track track, short[] data) {
@@ -30,8 +31,6 @@ public boolean decode(Track track, short[] data) {
3031

3132
for (Bds bds : bdsDecoder) {
3233
if (bds.attemptDecode(track, data)) {
33-
LoggerFactory.getLogger(getClass()).debug("Matched {}", bds.getClass().getSimpleName());
34-
3534
return true;
3635
}
3736
}

0 commit comments

Comments
 (0)