From b32ecfab276fb8e1dff0e1d72ed819b548323328 Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Tue, 16 Jul 2024 06:45:43 +0100 Subject: Working implementation of ADSB loaded from file. Net1090 can read from dump1090 socket --- ADSBDecoder/Decoder.swift | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'ADSBDecoder/Decoder.swift') diff --git a/ADSBDecoder/Decoder.swift b/ADSBDecoder/Decoder.swift index 65a9ddd..a9724b6 100644 --- a/ADSBDecoder/Decoder.swift +++ b/ADSBDecoder/Decoder.swift @@ -25,7 +25,7 @@ class Decoder { var DataFormat: UInt32 = 0; init (_ adsb_data: String) { - print(adsb_data) + //print(adsb_data) self.adsb_data = adsb_data //get the first 8 bits as integer let startI = adsb_data.startIndex @@ -38,7 +38,7 @@ class Decoder { DataFormat = CM_DataFormat //let CM_TranspoderCapability = ControlMsg&(0x7) } - print("Data Format \(DataFormat)") + //print("Data Format \(DataFormat)") } func getDataFormat17() -> DataFormat17? { @@ -114,7 +114,7 @@ class DataFormat17 { endN = adsb_data.index(startN, offsetBy: 1) } } - print(bindata) + //print(bindata) //Decode Capability let cap = (bindata[0]>>1)&0x7 @@ -136,25 +136,33 @@ class DataFormat17 { //aircraft indentification and category if (tc_byte == 4) { let msg = ADSBTypeCodeIndentification(bindata[4...10]) - print("=====ADSB MESSSGE 04 =======") - print(msg) - print("============================") + if decoder_debug_mode { + print("=====ADSB MESSSGE 04 =======") + print(msg) + print("============================") + } messageIdentification = msg //airborn position } else if ((tc_byte >= 8) && (tc_byte <= 18)) { let msg = ADSBTypeCodeAirbonePositon(bindata[4...10]) - print(String(format:"=====ADSB MESSSGE %02d ======= AA:%04d", tc_byte, AddressAnnounced)) - print(msg) - print("============================") + if decoder_debug_mode { + print(String(format:"=====ADSB MESSSGE %02d ======= AA:%04d", tc_byte, AddressAnnounced)) + print(msg) + print("============================") + } messageAirbornPositon = msg //airborn velocity } else if (tc_byte == 19) { - print("=====ADSB MESSSGE 19 =======") - print("=====VELOCITY =======") + if decoder_debug_mode { + print("=====ADSB MESSSGE 19 =======") + print("=====VELOCITY =======") + } } else { - print("=====ADSB MESSSGE UNKNOWN =======") + if decoder_debug_mode { + print("=====ADSB MESSSGE UNKNOWN =======") + } } } } @@ -176,7 +184,7 @@ class ADSBTypeCodeIndentification: CustomStringConvertible { let char_6 = (bindata[9]&0xf)<<2 + (bindata[10]>>6) let char_7 = bindata[10]&0x3f - print(char_0, char_1, char_2,char_3,char_4,char_5,char_6,char_7) + //print(char_0, char_1, char_2,char_3,char_4,char_5,char_6,char_7) ICAOName = ICAO2String(char_0, char_1, char_2, char_3, char_4, char_5, char_6, char_7) //print("ICAO name \(ICAOName)") } -- cgit v1.2.3