Improve ownship detection for EFBs that care

pull/794/head
William Castillo 2019-10-27 11:58:18 -05:00
rodzic eebe80d3c7
commit 1c92f75c4d
1 zmienionych plików z 13 dodań i 10 usunięć

Wyświetl plik

@ -295,21 +295,24 @@ func makeOwnshipReport() bool {
// See p.16.
msg[0] = 0x0A // Message type "Ownship".
// Ownship Target Identify (see 3.5.1.2 of GDL-90 Specifications)
// First half of byte is 0 for 'No Traffic Alert'
// Second half of byte is 0 for 'ADS-B with ICAO'
msg[1] = 0x00 // Alert status, address type.
// Retrieve ICAO code from settings
code, _ := hex.DecodeString(globalSettings.OwnshipModeS)
if len(code) != 3 {
// Ownship Target Identify (see 3.5.1.2 of GDL-90 Specifications)
// First half of byte is 0 for Alert type of 'No Traffic Alert'
// Second half of byte is 0 for traffic type 'ADS-B with ICAO'
// Send 0x01 by default, unless ICAO is set, send 0x00
if (len(code) == 3 && code[0] != 0xF0 && code[0] != 0x00) {
msg[1] = 0x00 // ADS-B Out with ICAO
msg[2] = code[0] // Mode S address.
msg[3] = code[1] // Mode S address.
msg[4] = code[2] // Mode S address.
} else {
msg[1] = 0x01 // ADS-B Out with self-assigned code
// Reserved dummy code.
msg[2] = 0xF0
msg[3] = 0x00
msg[4] = 0x00
} else {
msg[2] = code[0] // Mode S address.
msg[3] = code[1] // Mode S address.
msg[4] = code[2] // Mode S address.
}
var tmp []byte