From 1c92f75c4d1fbebb3ccca329346af76a0db977e7 Mon Sep 17 00:00:00 2001 From: William Castillo Date: Sun, 27 Oct 2019 11:58:18 -0500 Subject: [PATCH] Improve ownship detection for EFBs that care --- main/gen_gdl90.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index fd4c0bc9..837e2535 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -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