summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2026-09-27 10:24:48 +0100
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2026-09-27 10:24:48 +0100
commitfa8b756462fec42b23acbf253313c9292e43afed (patch)
tree81b153638b18226feb254f44d0e8a7efababe69a
parent40038b02ce651958ae703c8ecfe5f5578e1f7f09 (diff)
downloadADSBDecoder-fa8b756462fec42b23acbf253313c9292e43afed.tar.gz
ADSBDecoder-fa8b756462fec42b23acbf253313c9292e43afed.zip
remove from files multiple clases and put them in separate filesmain
-rw-r--r--ADSBDecoder.xcodeproj/project.pbxproj34
-rw-r--r--ADSBDecoderFramework.xctestplan26
-rw-r--r--ADSBDecoderFramework/ADSBDecoderFramework.docc/ADSBDecoderFramework.md4
-rw-r--r--ADSBDecoderFramework/ADSBTypeCodeAirbonePositon.swift49
-rw-r--r--ADSBDecoderFramework/ADSBTypeCodeIndentification.swift34
-rw-r--r--ADSBDecoderFramework/AirplaneTracker.swift1
-rw-r--r--ADSBDecoderFramework/DataFormat17.swift100
-rw-r--r--ADSBDecoderFramework/Decoder.swift159
-rw-r--r--ADSBDecoderFrameworkTests/ADSBMessage.swift13
-rw-r--r--ADSBDecoderFrameworkTests/IcaoAlfabet.swift32
-rw-r--r--ADSBDecoer.xctestplan19
11 files changed, 308 insertions, 163 deletions
diff --git a/ADSBDecoder.xcodeproj/project.pbxproj b/ADSBDecoder.xcodeproj/project.pbxproj
index ee775e0..81f745a 100644
--- a/ADSBDecoder.xcodeproj/project.pbxproj
+++ b/ADSBDecoder.xcodeproj/project.pbxproj
@@ -29,6 +29,7 @@
8DCF557F3068673400C724BA /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 8DCF557E3068673400C724BA /* ArgumentParser */; };
8DCF55813068678500C724BA /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 8DCF55803068678500C724BA /* ArgumentParser */; };
8DCF55833068678900C724BA /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = 8DCF55823068678900C724BA /* Collections */; };
+ 8DCF558E306914F700C724BA /* ADSBDecoer.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 8DCF558D306914F700C724BA /* ADSBDecoer.xctestplan */; };
8DEC6F2E2C2E9C3000AC6209 /* ADSBFileRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DEC6F2D2C2E9C3000AC6209 /* ADSBFileRunner.swift */; };
8DEC6F302C2E9F0E00AC6209 /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = 8DEC6F2F2C2E9F0E00AC6209 /* Collections */; };
8DEC6F322C31530C00AC6209 /* FlighState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DEC6F312C31530C00AC6209 /* FlighState.swift */; };
@@ -150,6 +151,8 @@
8DCF5553306864B700C724BA /* ADSBDecoder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ADSBDecoder.app; sourceTree = BUILT_PRODUCTS_DIR; };
8DCF5561306864B800C724BA /* ADSBDecoderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ADSBDecoderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8DCF556B306864B800C724BA /* ADSBDecoderUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ADSBDecoderUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DCF558D306914F700C724BA /* ADSBDecoer.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = ADSBDecoer.xctestplan; sourceTree = "<group>"; };
+ 8DCF558F3069161900C724BA /* ADSBDecoderFramework.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = ADSBDecoderFramework.xctestplan; sourceTree = "<group>"; };
8DEC6F2D2C2E9C3000AC6209 /* ADSBFileRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADSBFileRunner.swift; sourceTree = "<group>"; };
8DEC6F312C31530C00AC6209 /* FlighState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlighState.swift; sourceTree = "<group>"; };
8DF756732C059969008E8DFF /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
@@ -329,6 +332,8 @@
8DF756562C0595AA008E8DFF = {
isa = PBXGroup;
children = (
+ 8DCF558F3069161900C724BA /* ADSBDecoderFramework.xctestplan */,
+ 8DCF558D306914F700C724BA /* ADSBDecoer.xctestplan */,
8D4F384D3065289B00EA3890 /* Utils */,
8DF756692C0595BB008E8DFF /* Data */,
8DF756722C059969008E8DFF /* Test */,
@@ -688,7 +693,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 2700;
- LastUpgradeCheck = 1530;
+ LastUpgradeCheck = 2700;
TargetAttributes = {
8D4F382E3065267E00EA3890 = {
CreatedOnToolsVersion = 27.0;
@@ -768,6 +773,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 8DCF558E306914F700C724BA /* ADSBDecoer.xctestplan in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -965,6 +971,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -1004,6 +1011,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -1041,6 +1049,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1060,6 +1069,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1078,6 +1088,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.5;
@@ -1090,6 +1101,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.5;
@@ -1103,6 +1115,7 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.5;
@@ -1116,6 +1129,7 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.5;
@@ -1128,6 +1142,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
@@ -1140,6 +1155,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
@@ -1156,6 +1172,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
ENABLE_APP_SANDBOX = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
@@ -1187,6 +1204,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
ENABLE_APP_SANDBOX = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
@@ -1216,6 +1234,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1236,6 +1255,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1255,6 +1275,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1274,6 +1295,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.6;
MARKETING_VERSION = 1.0;
@@ -1322,6 +1344,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
+ DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -1346,6 +1369,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
+ STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
@@ -1385,6 +1409,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
+ DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -1402,6 +1427,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
+ STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
@@ -1415,6 +1441,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"LearnMapKit/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
@@ -1442,6 +1469,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"LearnMapKit/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
@@ -1466,6 +1494,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.4;
MARKETING_VERSION = 1.0;
@@ -1483,6 +1512,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.4;
MARKETING_VERSION = 1.0;
@@ -1499,6 +1529,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = RadioTeam.LearnMapKitUITests;
@@ -1514,6 +1545,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
+ DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = RadioTeam.LearnMapKitUITests;
diff --git a/ADSBDecoderFramework.xctestplan b/ADSBDecoderFramework.xctestplan
new file mode 100644
index 0000000..631268e
--- /dev/null
+++ b/ADSBDecoderFramework.xctestplan
@@ -0,0 +1,26 @@
+{
+ "configurations" : [
+ {
+ "id" : "17C09187-53AD-4DA4-8B38-6BE1A2A4483E",
+ "name" : "Test Scheme Action",
+ "options" : {
+
+ }
+ }
+ ],
+ "defaultOptions" : {
+ "codeCoverage" : false,
+ "performanceAntipatternCheckerEnabled" : true,
+ "testInteropMode" : "complete"
+ },
+ "testTargets" : [
+ {
+ "target" : {
+ "containerPath" : "container:ADSBDecoder.xcodeproj",
+ "identifier" : "8D4F38383065267F00EA3890",
+ "name" : "ADSBDecoderFrameworkTests"
+ }
+ }
+ ],
+ "version" : 1
+}
diff --git a/ADSBDecoderFramework/ADSBDecoderFramework.docc/ADSBDecoderFramework.md b/ADSBDecoderFramework/ADSBDecoderFramework.docc/ADSBDecoderFramework.md
index 588e73d..6a75e2c 100644
--- a/ADSBDecoderFramework/ADSBDecoderFramework.docc/ADSBDecoderFramework.md
+++ b/ADSBDecoderFramework/ADSBDecoderFramework.docc/ADSBDecoderFramework.md
@@ -1,6 +1,6 @@
# ``ADSBDecoderFramework``
-<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@-->
+List of functions to decode ADSB ASCII hex messages.
## Overview
@@ -10,4 +10,4 @@
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->
-- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@--> \ No newline at end of file
+- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->
diff --git a/ADSBDecoderFramework/ADSBTypeCodeAirbonePositon.swift b/ADSBDecoderFramework/ADSBTypeCodeAirbonePositon.swift
new file mode 100644
index 0000000..b6a302a
--- /dev/null
+++ b/ADSBDecoderFramework/ADSBTypeCodeAirbonePositon.swift
@@ -0,0 +1,49 @@
+//
+// ADSBTypeCodeAirbonePositon.swift
+// ADSBDecoder
+//
+// Created by Jacky Jack on 27/09/2026.
+//
+
+//DF17 message types codes 8 to 18
+public class ADSBTypeCodeAirbonePositon:CustomStringConvertible {
+ var TypeCode:Int = 11
+ var SurveillanceStatus: Int = 0
+ var SingleAntennaFlag: Int = 0
+ public var Altitude: Int = 0
+ var Time: Int = 0
+ public var CPRFormat: Int = 0
+ public var Latitude: Int = 0
+ public var Longitude: Int = 0
+
+ public init(_ bindata:ArraySlice<UInt8>) {
+ let ss = (bindata[4]>>1)&(0x3)
+ SurveillanceStatus = Int(ss)
+ let saf = bindata[5]&0x1
+ SingleAntennaFlag = Int(saf)
+ let altitude = UInt16(bindata[5])<<4 + (UInt16(bindata[6])>>4)&0xf
+ //print(altitude)
+ Altitude = BarometricAltitudeFeat(altitude)
+ let time = (bindata[6]>>3)&0x1
+ Time = Int(time)
+ let cpr = (bindata[6]>>2)&0x1
+ CPRFormat = Int(cpr)
+ let lat:UInt32 = UInt32(bindata[6]&0x3)<<15 + UInt32(bindata[7])<<7 + UInt32(bindata[8]>>1)
+ Latitude = Int(lat)
+ let lon:UInt32 = UInt32(bindata[8]&0x1)<<16 + UInt32(bindata[9])<<8 + UInt32(bindata[10])
+ Longitude = Int(lon)
+ }
+
+ public var description: String {
+ var description = "SS \(SurveillanceStatus) SAF \(SingleAntennaFlag) Altitude \(Altitude)ft \n"
+ description += "Time \(Time) CPR \(CPRFormat)"
+ if (CPRFormat == 0) {
+ description += "even"
+ } else {
+ description += "odd"
+ }
+ description += "\n"
+ description += "Lat \(Latitude) Long \(Longitude)"
+ return description
+ }
+}
diff --git a/ADSBDecoderFramework/ADSBTypeCodeIndentification.swift b/ADSBDecoderFramework/ADSBTypeCodeIndentification.swift
new file mode 100644
index 0000000..ad66378
--- /dev/null
+++ b/ADSBDecoderFramework/ADSBTypeCodeIndentification.swift
@@ -0,0 +1,34 @@
+//
+// ADSBTypeCodeIndentification.swift
+// ADSBDecoder
+//
+// Created by Jacky Jack on 27/09/2026.
+//
+
+public class ADSBTypeCodeIndentification: CustomStringConvertible {
+ var TypeCode:Int = 4
+ var Category:Int = 0
+ public var ICAOName:String
+
+ public init(_ bindata:ArraySlice<UInt8>) {
+ let cat = bindata[4]&0x7
+ Category = Int(cat)
+ let char_0 = bindata[5]>>2
+ let char_1 = (bindata[5]&0x3)<<4 + bindata[6]>>4
+ let char_2 = (bindata[6]&0xf)<<2 + (bindata[7]>>6)&0x3
+ let char_3 = (bindata[7])&0x3f
+ let char_4 = bindata[8]>>2
+ let char_5 = (bindata[8]&0x3)<<4 + bindata[9]>>4
+ 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)
+ ICAOName = ICAO2String(char_0, char_1, char_2, char_3, char_4, char_5, char_6, char_7)
+ //print("ICAO name \(ICAOName)")
+ }
+
+ public var description: String {
+ let description = "TypeCode \(TypeCode) Cat \(Category) Flight name \(ICAOName)"
+ return description
+ }
+}
diff --git a/ADSBDecoderFramework/AirplaneTracker.swift b/ADSBDecoderFramework/AirplaneTracker.swift
index 6c09953..d32e33c 100644
--- a/ADSBDecoderFramework/AirplaneTracker.swift
+++ b/ADSBDecoderFramework/AirplaneTracker.swift
@@ -116,5 +116,4 @@ public class AirPlaneTracker {
}
}
}
-
}
diff --git a/ADSBDecoderFramework/DataFormat17.swift b/ADSBDecoderFramework/DataFormat17.swift
new file mode 100644
index 0000000..e1ea428
--- /dev/null
+++ b/ADSBDecoderFramework/DataFormat17.swift
@@ -0,0 +1,100 @@
+//
+// DataFormat17.swift
+// ADSBDecoder
+//
+// Created by Jacky Jack on 27/09/2026.
+//
+
+import Foundation
+
+public class DataFormat17 {
+
+ let DataFormat=17 //0:5
+ var Capability=0 //5:7
+ public var AddressAnnounced=0 //8:31
+ public var TypeCode=0 //32:36
+ var MovementField=0//37:43
+ var HeadingBit=0//44
+ var HeadingField=0//45:51
+ //var CPROddEven=0//53
+ //var CPRlat=0//54:70
+ //var CPRlon=0//71:87
+ var ParityIntegrity=0//88-111
+
+ //all avaliable message types
+ public var messageIdentification:ADSBTypeCodeIndentification? = nil
+ public var messageAirbornPositon:ADSBTypeCodeAirbonePositon? = nil
+
+ public init(_ adsb_data: String) {
+ //print("Dataformat: 17!")
+ //print(adsb_data)
+
+ var bindata:[UInt8] = []
+
+ var startN = adsb_data.startIndex
+ var endN = adsb_data.index(startN, offsetBy: 1)
+ var count=0//start index value
+ while (count<adsb_data.count) {
+ let u8 = UInt8(adsb_data[startN...endN], radix: 16)!
+ //print(adsb_data[startN...endN])
+ bindata.append(u8)
+ count += 2
+ if (count<adsb_data.count) {
+ startN = adsb_data.index(startN, offsetBy: 2)
+ endN = adsb_data.index(startN, offsetBy: 1)
+ }
+ }
+ //print(bindata)
+
+ //Decode Capability
+ let cap = (bindata[0]>>1)&0x7
+ //print(String(format: "cap %02x", cap))
+ Capability = Int(cap)
+
+ //Decode Address Announcement
+ let address_ann = UInt32(bindata[1])<<16 + UInt32(bindata[2])<<8 + UInt32(bindata[3])
+ //print(String(format: "address %06x", address_ann))
+
+ AddressAnnounced = Int(address_ann)
+
+ //Decode Type Code
+ let tc_byte = bindata[4] >> 3
+ //print(String(format: "tc %02d", tc_byte))
+
+ TypeCode = Int(tc_byte)
+
+ //aircraft indentification and category
+ if (tc_byte == 4) {
+ let msg = ADSBTypeCodeIndentification(bindata[4...10])
+ 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])
+ 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) {
+ if decoder_debug_mode {
+ print("=====ADSB MESSSGE 19 =======")
+ print("=====VELOCITY =======")
+ }
+ } else {
+ if decoder_debug_mode {
+ print("=====ADSB MESSSGE UNKNOWN =======")
+ }
+ }
+ }
+}
+
+
diff --git a/ADSBDecoderFramework/Decoder.swift b/ADSBDecoderFramework/Decoder.swift
index 17fce52..1296b40 100644
--- a/ADSBDecoderFramework/Decoder.swift
+++ b/ADSBDecoderFramework/Decoder.swift
@@ -50,9 +50,6 @@ public class Decoder {
//let endI = adsb_data.index(adsb_data.endIndex, offsetBy: -1)
//let adsbData = adsb_data[startI...endI]
let ret:DataFormat17 = DataFormat17(adsb_data)
-
-
-
return ret;
}
@@ -77,166 +74,10 @@ func ICAO2String(_ b1: UInt8, _ b2: UInt8, _ b3: UInt8, _ b4: UInt8, _ b5: UInt8
return ICAOAlphabet(b1)+ICAOAlphabet(b2)+ICAOAlphabet(b3)+ICAOAlphabet(b4)+ICAOAlphabet(b5)+ICAOAlphabet(b6)+ICAOAlphabet(b7)+ICAOAlphabet(b8)
}
-public class DataFormat17 {
- let DataFormat=17 //0:5
- var Capability=0 //5:7
- public var AddressAnnounced=0 //8:31
- public var TypeCode=0 //32:36
- var MovementField=0//37:43
- var HeadingBit=0//44
- var HeadingField=0//45:51
- //var CPROddEven=0//53
- //var CPRlat=0//54:70
- //var CPRlon=0//71:87
- var ParityIntegrity=0//88-111
-
- //all avaliable message types
- public var messageIdentification:ADSBTypeCodeIndentification? = nil
- public var messageAirbornPositon:ADSBTypeCodeAirbonePositon? = nil
- public init(_ adsb_data: String) {
- //print("Dataformat: 17!")
- //print(adsb_data)
-
- var bindata:[UInt8] = []
-
- var startN = adsb_data.startIndex
- var endN = adsb_data.index(startN, offsetBy: 1)
- var count=0//start index value
- while (count<adsb_data.count) {
- let u8 = UInt8(adsb_data[startN...endN], radix: 16)!
- //print(adsb_data[startN...endN])
- bindata.append(u8)
- count += 2
- if (count<adsb_data.count) {
- startN = adsb_data.index(startN, offsetBy: 2)
- endN = adsb_data.index(startN, offsetBy: 1)
- }
- }
- //print(bindata)
-
- //Decode Capability
- let cap = (bindata[0]>>1)&0x7
- //print(String(format: "cap %02x", cap))
- Capability = Int(cap)
-
- //Decode Address Announcement
- let address_ann = UInt32(bindata[1])<<16 + UInt32(bindata[2])<<8 + UInt32(bindata[3])
- //print(String(format: "address %06x", address_ann))
-
- AddressAnnounced = Int(address_ann)
-
- //Decode Type Code
- let tc_byte = bindata[4] >> 3
- //print(String(format: "tc %02d", tc_byte))
-
- TypeCode = Int(tc_byte)
-
- //aircraft indentification and category
- if (tc_byte == 4) {
- let msg = ADSBTypeCodeIndentification(bindata[4...10])
- 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])
- 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) {
- if decoder_debug_mode {
- print("=====ADSB MESSSGE 19 =======")
- print("=====VELOCITY =======")
- }
- } else {
- if decoder_debug_mode {
- print("=====ADSB MESSSGE UNKNOWN =======")
- }
- }
- }
-}
-
-public class ADSBTypeCodeIndentification: CustomStringConvertible {
- var TypeCode:Int = 4
- var Category:Int = 0
- public var ICAOName:String
-
- public init(_ bindata:ArraySlice<UInt8>) {
- let cat = bindata[4]&0x7
- Category = Int(cat)
- let char_0 = bindata[5]>>2
- let char_1 = (bindata[5]&0x3)<<4 + bindata[6]>>4
- let char_2 = (bindata[6]&0xf)<<2 + (bindata[7]>>6)&0x3
- let char_3 = (bindata[7])&0x3f
- let char_4 = bindata[8]>>2
- let char_5 = (bindata[8]&0x3)<<4 + bindata[9]>>4
- 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)
- ICAOName = ICAO2String(char_0, char_1, char_2, char_3, char_4, char_5, char_6, char_7)
- //print("ICAO name \(ICAOName)")
- }
-
- public var description: String {
- let description = "TypeCode \(TypeCode) Cat \(Category) Flight name \(ICAOName)"
- return description
- }
-}
-//DF17 message types codes 8 to 18
-public class ADSBTypeCodeAirbonePositon:CustomStringConvertible {
- var TypeCode:Int = 11
- var SurveillanceStatus: Int = 0
- var SingleAntennaFlag: Int = 0
- public var Altitude: Int = 0
- var Time: Int = 0
- public var CPRFormat: Int = 0
- public var Latitude: Int = 0
- public var Longitude: Int = 0
- public init(_ bindata:ArraySlice<UInt8>) {
- let ss = (bindata[4]>>1)&(0x3)
- SurveillanceStatus = Int(ss)
- let saf = bindata[5]&0x1
- SingleAntennaFlag = Int(saf)
- let altitude = UInt16(bindata[5])<<4 + (UInt16(bindata[6])>>4)&0xf
- //print(altitude)
- Altitude = BarometricAltitudeFeat(altitude)
- let time = (bindata[6]>>3)&0x1
- Time = Int(time)
- let cpr = (bindata[6]>>2)&0x1
- CPRFormat = Int(cpr)
- let lat:UInt32 = UInt32(bindata[6]&0x3)<<15 + UInt32(bindata[7])<<7 + UInt32(bindata[8]>>1)
- Latitude = Int(lat)
- let lon:UInt32 = UInt32(bindata[8]&0x1)<<16 + UInt32(bindata[9])<<8 + UInt32(bindata[10])
- Longitude = Int(lon)
- }
-
- public var description: String {
- var description = "SS \(SurveillanceStatus) SAF \(SingleAntennaFlag) Altitude \(Altitude)ft \n"
- description += "Time \(Time) CPR \(CPRFormat)"
- if (CPRFormat == 0) {
- description += "even"
- } else {
- description += "odd"
- }
- description += "\n"
- description += "Lat \(Latitude) Long \(Longitude)"
- return description
- }
-}
class DataFormat19:CustomStringConvertible {
init(_ bindata:ArraySlice<UInt8>) {
diff --git a/ADSBDecoderFrameworkTests/ADSBMessage.swift b/ADSBDecoderFrameworkTests/ADSBMessage.swift
new file mode 100644
index 0000000..9c9f7d2
--- /dev/null
+++ b/ADSBDecoderFrameworkTests/ADSBMessage.swift
@@ -0,0 +1,13 @@
+//
+// ADSBMessage.swift
+// ADSBDecoder
+//
+// Created by Jacky Jack on 27/09/2026.
+//
+
+import Testing
+@testable import ADSBDecoderFramework
+
+struct ADSBMessage {
+
+}
diff --git a/ADSBDecoderFrameworkTests/IcaoAlfabet.swift b/ADSBDecoderFrameworkTests/IcaoAlfabet.swift
new file mode 100644
index 0000000..35fb2d3
--- /dev/null
+++ b/ADSBDecoderFrameworkTests/IcaoAlfabet.swift
@@ -0,0 +1,32 @@
+//
+// IcaoAlfabet.swift
+// ADSBDecoder
+//
+// Created by Jacky Jack on 27/09/2026.
+//
+
+import Testing
+@testable import ADSBDecoderFramework
+
+struct IcaoAlfabet {
+
+ @Test("Letter A") func TestLetterA() async throws {
+
+ }
+
+ @Test("Letter Z") func TestLetterZ() async throws {
+
+ }
+
+ @Test("Numbers") func TestNumbers() async throws {
+
+ }
+ @Test("White space") func TestWhitespace() async throws {
+
+ }
+
+ @Test("Out of range") func TestOutOfRange() async throws {
+
+ }
+
+}
diff --git a/ADSBDecoer.xctestplan b/ADSBDecoer.xctestplan
new file mode 100644
index 0000000..f81f349
--- /dev/null
+++ b/ADSBDecoer.xctestplan
@@ -0,0 +1,19 @@
+{
+ "configurations" : [
+ {
+ "id" : "DE93ADEB-A7E0-430D-B8B0-7092083AFAA2",
+ "name" : "Configuration 1",
+ "options" : {
+
+ }
+ }
+ ],
+ "defaultOptions" : {
+ "testInteropMode" : "complete",
+ "testTimeoutsEnabled" : true
+ },
+ "testTargets" : [
+
+ ],
+ "version" : 1
+}