├── .gitignore ├── L2CapDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── paulw.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── L2CapDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── first.imageset │ │ ├── Contents.json │ │ └── first.pdf │ └── second.imageset │ │ ├── Contents.json │ │ └── second.pdf ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CentralViewController.swift ├── Constants.swift ├── DataExtensions.swift ├── Info.plist ├── L2CapDemo.entitlements └── PeripheralViewController.swift ├── L2CapDemoMac ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── CentralViewController.swift ├── Info.plist └── PeripheralViewController.swift ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | # 51 | # Add this line if you want to avoid checking in source code from the Xcode workspace 52 | # *.xcworkspace 53 | 54 | # Carthage 55 | # 56 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 57 | # Carthage/Checkouts 58 | 59 | Carthage/Build 60 | 61 | # fastlane 62 | # 63 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 64 | # screenshots whenever they are needed. 65 | # For more information about the recommended setup visit: 66 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 67 | 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots/**/*.png 71 | fastlane/test_output 72 | 73 | # Code Injection 74 | # 75 | # After new code Injection tools there's a generated folder /iOSInjectionProject 76 | # https://github.com/johnno1962/injectionforxcode 77 | 78 | iOSInjectionProject/ 79 | -------------------------------------------------------------------------------- /L2CapDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BB3A7DEB23A3411E0086C9ED /* L2Cap in Frameworks */ = {isa = PBXBuildFile; productRef = BB3A7DEA23A3411E0086C9ED /* L2Cap */; }; 11 | BB43BB5823A9CE7D005F67A4 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = BB43BB5723A9CE7D005F67A4 /* README.md */; }; 12 | BB696ECD21F016D100116608 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB696ECC21F016D100116608 /* AppDelegate.swift */; }; 13 | BB696ECF21F016D100116608 /* CentralViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB696ECE21F016D100116608 /* CentralViewController.swift */; }; 14 | BB696ED121F016D100116608 /* PeripheralViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB696ED021F016D100116608 /* PeripheralViewController.swift */; }; 15 | BB696ED421F016D100116608 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB696ED221F016D100116608 /* Main.storyboard */; }; 16 | BB696ED621F016D200116608 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BB696ED521F016D200116608 /* Assets.xcassets */; }; 17 | BB696ED921F016D200116608 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB696ED721F016D200116608 /* LaunchScreen.storyboard */; }; 18 | BB696EE121F0180700116608 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB696EE021F0180700116608 /* Constants.swift */; }; 19 | BB696EE321F035E400116608 /* DataExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB696EE221F035E400116608 /* DataExtensions.swift */; }; 20 | BBDFB3A023AC4EA300D93C0F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDFB39F23AC4EA300D93C0F /* AppDelegate.swift */; }; 21 | BBDFB3A223AC4EA300D93C0F /* CentralViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDFB3A123AC4EA300D93C0F /* CentralViewController.swift */; }; 22 | BBDFB3A423AC4EA600D93C0F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BBDFB3A323AC4EA600D93C0F /* Assets.xcassets */; }; 23 | BBDFB3A723AC4EA600D93C0F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BBDFB3A523AC4EA600D93C0F /* Main.storyboard */; }; 24 | BBDFB3AF23AC6D4900D93C0F /* L2Cap in Frameworks */ = {isa = PBXBuildFile; productRef = BBDFB3AE23AC6D4900D93C0F /* L2Cap */; }; 25 | BBDFB3B223ACC81900D93C0F /* PeripheralViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDFB3B123ACC81900D93C0F /* PeripheralViewController.swift */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | BB43BB5723A9CE7D005F67A4 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 30 | BB696EC921F016D100116608 /* L2CapDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = L2CapDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | BB696ECC21F016D100116608 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | BB696ECE21F016D100116608 /* CentralViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CentralViewController.swift; sourceTree = ""; }; 33 | BB696ED021F016D100116608 /* PeripheralViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeripheralViewController.swift; sourceTree = ""; }; 34 | BB696ED321F016D100116608 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | BB696ED521F016D200116608 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 36 | BB696ED821F016D200116608 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 37 | BB696EDA21F016D200116608 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | BB696EE021F0180700116608 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 39 | BB696EE221F035E400116608 /* DataExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtensions.swift; sourceTree = ""; }; 40 | BBDFB39D23AC4EA300D93C0F /* L2CapDemoMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = L2CapDemoMac.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | BBDFB39F23AC4EA300D93C0F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 42 | BBDFB3A123AC4EA300D93C0F /* CentralViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CentralViewController.swift; sourceTree = ""; }; 43 | BBDFB3A323AC4EA600D93C0F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 44 | BBDFB3A623AC4EA600D93C0F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | BBDFB3A823AC4EA600D93C0F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | BBDFB3B023ACC78800D93C0F /* L2CapDemo.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = L2CapDemo.entitlements; sourceTree = ""; }; 47 | BBDFB3B123ACC81900D93C0F /* PeripheralViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeripheralViewController.swift; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | BB696EC621F016D100116608 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | BB3A7DEB23A3411E0086C9ED /* L2Cap in Frameworks */, 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | BBDFB39A23AC4EA300D93C0F /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | BBDFB3AF23AC6D4900D93C0F /* L2Cap in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | BB696EC021F016D100116608 = { 71 | isa = PBXGroup; 72 | children = ( 73 | BB43BB5723A9CE7D005F67A4 /* README.md */, 74 | BB696ECB21F016D100116608 /* L2CapDemo */, 75 | BBDFB39E23AC4EA300D93C0F /* L2CapDemoMac */, 76 | BB696ECA21F016D100116608 /* Products */, 77 | BBDFB3AD23AC6D4900D93C0F /* Frameworks */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | BB696ECA21F016D100116608 /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | BB696EC921F016D100116608 /* L2CapDemo.app */, 85 | BBDFB39D23AC4EA300D93C0F /* L2CapDemoMac.app */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | BB696ECB21F016D100116608 /* L2CapDemo */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | BBDFB3B023ACC78800D93C0F /* L2CapDemo.entitlements */, 94 | BB696ECC21F016D100116608 /* AppDelegate.swift */, 95 | BB696ECE21F016D100116608 /* CentralViewController.swift */, 96 | BB696ED021F016D100116608 /* PeripheralViewController.swift */, 97 | BB696EE221F035E400116608 /* DataExtensions.swift */, 98 | BB696ED221F016D100116608 /* Main.storyboard */, 99 | BB696ED521F016D200116608 /* Assets.xcassets */, 100 | BB696ED721F016D200116608 /* LaunchScreen.storyboard */, 101 | BB696EDA21F016D200116608 /* Info.plist */, 102 | BB696EE021F0180700116608 /* Constants.swift */, 103 | ); 104 | path = L2CapDemo; 105 | sourceTree = ""; 106 | }; 107 | BBDFB39E23AC4EA300D93C0F /* L2CapDemoMac */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | BBDFB39F23AC4EA300D93C0F /* AppDelegate.swift */, 111 | BBDFB3A123AC4EA300D93C0F /* CentralViewController.swift */, 112 | BBDFB3B123ACC81900D93C0F /* PeripheralViewController.swift */, 113 | BBDFB3A323AC4EA600D93C0F /* Assets.xcassets */, 114 | BBDFB3A523AC4EA600D93C0F /* Main.storyboard */, 115 | BBDFB3A823AC4EA600D93C0F /* Info.plist */, 116 | ); 117 | path = L2CapDemoMac; 118 | sourceTree = ""; 119 | }; 120 | BBDFB3AD23AC6D4900D93C0F /* Frameworks */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | ); 124 | name = Frameworks; 125 | sourceTree = ""; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | BB696EC821F016D100116608 /* L2CapDemo */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = BB696EDD21F016D200116608 /* Build configuration list for PBXNativeTarget "L2CapDemo" */; 133 | buildPhases = ( 134 | BB696EC521F016D100116608 /* Sources */, 135 | BB696EC621F016D100116608 /* Frameworks */, 136 | BB696EC721F016D100116608 /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = L2CapDemo; 143 | packageProductDependencies = ( 144 | BB3A7DEA23A3411E0086C9ED /* L2Cap */, 145 | ); 146 | productName = L2CapDemo; 147 | productReference = BB696EC921F016D100116608 /* L2CapDemo.app */; 148 | productType = "com.apple.product-type.application"; 149 | }; 150 | BBDFB39C23AC4EA300D93C0F /* L2CapDemoMac */ = { 151 | isa = PBXNativeTarget; 152 | buildConfigurationList = BBDFB3AC23AC4EA600D93C0F /* Build configuration list for PBXNativeTarget "L2CapDemoMac" */; 153 | buildPhases = ( 154 | BBDFB39923AC4EA300D93C0F /* Sources */, 155 | BBDFB39A23AC4EA300D93C0F /* Frameworks */, 156 | BBDFB39B23AC4EA300D93C0F /* Resources */, 157 | ); 158 | buildRules = ( 159 | ); 160 | dependencies = ( 161 | ); 162 | name = L2CapDemoMac; 163 | packageProductDependencies = ( 164 | BBDFB3AE23AC6D4900D93C0F /* L2Cap */, 165 | ); 166 | productName = L2CapDemoMac; 167 | productReference = BBDFB39D23AC4EA300D93C0F /* L2CapDemoMac.app */; 168 | productType = "com.apple.product-type.application"; 169 | }; 170 | /* End PBXNativeTarget section */ 171 | 172 | /* Begin PBXProject section */ 173 | BB696EC121F016D100116608 /* Project object */ = { 174 | isa = PBXProject; 175 | attributes = { 176 | LastSwiftUpdateCheck = 1130; 177 | LastUpgradeCheck = 1010; 178 | ORGANIZATIONNAME = "Paul Wilkinson"; 179 | TargetAttributes = { 180 | BB696EC821F016D100116608 = { 181 | CreatedOnToolsVersion = 10.1; 182 | LastSwiftMigration = 1130; 183 | }; 184 | BBDFB39C23AC4EA300D93C0F = { 185 | CreatedOnToolsVersion = 11.3; 186 | }; 187 | }; 188 | }; 189 | buildConfigurationList = BB696EC421F016D100116608 /* Build configuration list for PBXProject "L2CapDemo" */; 190 | compatibilityVersion = "Xcode 9.3"; 191 | developmentRegion = en; 192 | hasScannedForEncodings = 0; 193 | knownRegions = ( 194 | en, 195 | Base, 196 | ); 197 | mainGroup = BB696EC021F016D100116608; 198 | packageReferences = ( 199 | BB3A7DE923A3411E0086C9ED /* XCRemoteSwiftPackageReference "L2Cap" */, 200 | ); 201 | productRefGroup = BB696ECA21F016D100116608 /* Products */; 202 | projectDirPath = ""; 203 | projectRoot = ""; 204 | targets = ( 205 | BB696EC821F016D100116608 /* L2CapDemo */, 206 | BBDFB39C23AC4EA300D93C0F /* L2CapDemoMac */, 207 | ); 208 | }; 209 | /* End PBXProject section */ 210 | 211 | /* Begin PBXResourcesBuildPhase section */ 212 | BB696EC721F016D100116608 /* Resources */ = { 213 | isa = PBXResourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | BB696ED921F016D200116608 /* LaunchScreen.storyboard in Resources */, 217 | BB696ED621F016D200116608 /* Assets.xcassets in Resources */, 218 | BB43BB5823A9CE7D005F67A4 /* README.md in Resources */, 219 | BB696ED421F016D100116608 /* Main.storyboard in Resources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | BBDFB39B23AC4EA300D93C0F /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | BBDFB3A423AC4EA600D93C0F /* Assets.xcassets in Resources */, 228 | BBDFB3A723AC4EA600D93C0F /* Main.storyboard in Resources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXResourcesBuildPhase section */ 233 | 234 | /* Begin PBXSourcesBuildPhase section */ 235 | BB696EC521F016D100116608 /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | BB696ED121F016D100116608 /* PeripheralViewController.swift in Sources */, 240 | BB696ECD21F016D100116608 /* AppDelegate.swift in Sources */, 241 | BB696ECF21F016D100116608 /* CentralViewController.swift in Sources */, 242 | BB696EE321F035E400116608 /* DataExtensions.swift in Sources */, 243 | BB696EE121F0180700116608 /* Constants.swift in Sources */, 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | }; 247 | BBDFB39923AC4EA300D93C0F /* Sources */ = { 248 | isa = PBXSourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | BBDFB3A223AC4EA300D93C0F /* CentralViewController.swift in Sources */, 252 | BBDFB3B223ACC81900D93C0F /* PeripheralViewController.swift in Sources */, 253 | BBDFB3A023AC4EA300D93C0F /* AppDelegate.swift in Sources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | /* End PBXSourcesBuildPhase section */ 258 | 259 | /* Begin PBXVariantGroup section */ 260 | BB696ED221F016D100116608 /* Main.storyboard */ = { 261 | isa = PBXVariantGroup; 262 | children = ( 263 | BB696ED321F016D100116608 /* Base */, 264 | ); 265 | name = Main.storyboard; 266 | sourceTree = ""; 267 | }; 268 | BB696ED721F016D200116608 /* LaunchScreen.storyboard */ = { 269 | isa = PBXVariantGroup; 270 | children = ( 271 | BB696ED821F016D200116608 /* Base */, 272 | ); 273 | name = LaunchScreen.storyboard; 274 | sourceTree = ""; 275 | }; 276 | BBDFB3A523AC4EA600D93C0F /* Main.storyboard */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | BBDFB3A623AC4EA600D93C0F /* Base */, 280 | ); 281 | name = Main.storyboard; 282 | sourceTree = ""; 283 | }; 284 | /* End PBXVariantGroup section */ 285 | 286 | /* Begin XCBuildConfiguration section */ 287 | BB696EDB21F016D200116608 /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ALWAYS_SEARCH_USER_PATHS = NO; 291 | CLANG_ANALYZER_NONNULL = YES; 292 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 293 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 294 | CLANG_CXX_LIBRARY = "libc++"; 295 | CLANG_ENABLE_MODULES = YES; 296 | CLANG_ENABLE_OBJC_ARC = YES; 297 | CLANG_ENABLE_OBJC_WEAK = YES; 298 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 299 | CLANG_WARN_BOOL_CONVERSION = YES; 300 | CLANG_WARN_COMMA = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 305 | CLANG_WARN_EMPTY_BODY = YES; 306 | CLANG_WARN_ENUM_CONVERSION = YES; 307 | CLANG_WARN_INFINITE_RECURSION = YES; 308 | CLANG_WARN_INT_CONVERSION = YES; 309 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 310 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 311 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 314 | CLANG_WARN_STRICT_PROTOTYPES = YES; 315 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 316 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | CODE_SIGN_IDENTITY = "iPhone Developer"; 320 | COPY_PHASE_STRIP = NO; 321 | DEBUG_INFORMATION_FORMAT = dwarf; 322 | ENABLE_STRICT_OBJC_MSGSEND = YES; 323 | ENABLE_TESTABILITY = YES; 324 | GCC_C_LANGUAGE_STANDARD = gnu11; 325 | GCC_DYNAMIC_NO_PIC = NO; 326 | GCC_NO_COMMON_BLOCKS = YES; 327 | GCC_OPTIMIZATION_LEVEL = 0; 328 | GCC_PREPROCESSOR_DEFINITIONS = ( 329 | "DEBUG=1", 330 | "$(inherited)", 331 | ); 332 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 333 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 334 | GCC_WARN_UNDECLARED_SELECTOR = YES; 335 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 336 | GCC_WARN_UNUSED_FUNCTION = YES; 337 | GCC_WARN_UNUSED_VARIABLE = YES; 338 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 339 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 340 | MTL_FAST_MATH = YES; 341 | ONLY_ACTIVE_ARCH = YES; 342 | SDKROOT = iphoneos; 343 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 344 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 345 | }; 346 | name = Debug; 347 | }; 348 | BB696EDC21F016D200116608 /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_ANALYZER_NONNULL = YES; 353 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 354 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 355 | CLANG_CXX_LIBRARY = "libc++"; 356 | CLANG_ENABLE_MODULES = YES; 357 | CLANG_ENABLE_OBJC_ARC = YES; 358 | CLANG_ENABLE_OBJC_WEAK = YES; 359 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 360 | CLANG_WARN_BOOL_CONVERSION = YES; 361 | CLANG_WARN_COMMA = YES; 362 | CLANG_WARN_CONSTANT_CONVERSION = YES; 363 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 364 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 365 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 366 | CLANG_WARN_EMPTY_BODY = YES; 367 | CLANG_WARN_ENUM_CONVERSION = YES; 368 | CLANG_WARN_INFINITE_RECURSION = YES; 369 | CLANG_WARN_INT_CONVERSION = YES; 370 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 371 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 372 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 375 | CLANG_WARN_STRICT_PROTOTYPES = YES; 376 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 377 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 378 | CLANG_WARN_UNREACHABLE_CODE = YES; 379 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 380 | CODE_SIGN_IDENTITY = "iPhone Developer"; 381 | COPY_PHASE_STRIP = NO; 382 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 383 | ENABLE_NS_ASSERTIONS = NO; 384 | ENABLE_STRICT_OBJC_MSGSEND = YES; 385 | GCC_C_LANGUAGE_STANDARD = gnu11; 386 | GCC_NO_COMMON_BLOCKS = YES; 387 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 388 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 389 | GCC_WARN_UNDECLARED_SELECTOR = YES; 390 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 391 | GCC_WARN_UNUSED_FUNCTION = YES; 392 | GCC_WARN_UNUSED_VARIABLE = YES; 393 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 394 | MTL_ENABLE_DEBUG_INFO = NO; 395 | MTL_FAST_MATH = YES; 396 | SDKROOT = iphoneos; 397 | SWIFT_COMPILATION_MODE = wholemodule; 398 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 399 | VALIDATE_PRODUCT = YES; 400 | }; 401 | name = Release; 402 | }; 403 | BB696EDE21F016D200116608 /* Debug */ = { 404 | isa = XCBuildConfiguration; 405 | buildSettings = { 406 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 407 | CODE_SIGN_ENTITLEMENTS = L2CapDemo/L2CapDemo.entitlements; 408 | CODE_SIGN_STYLE = Automatic; 409 | DEVELOPMENT_TEAM = UPP93EJ3U2; 410 | INFOPLIST_FILE = L2CapDemo/Info.plist; 411 | LD_RUNPATH_SEARCH_PATHS = ( 412 | "$(inherited)", 413 | "@executable_path/Frameworks", 414 | ); 415 | PRODUCT_BUNDLE_IDENTIFIER = me.wilko.L2CapDemo3; 416 | PRODUCT_NAME = "$(TARGET_NAME)"; 417 | SWIFT_VERSION = 5.0; 418 | TARGETED_DEVICE_FAMILY = "1,2"; 419 | }; 420 | name = Debug; 421 | }; 422 | BB696EDF21F016D200116608 /* Release */ = { 423 | isa = XCBuildConfiguration; 424 | buildSettings = { 425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 426 | CODE_SIGN_ENTITLEMENTS = L2CapDemo/L2CapDemo.entitlements; 427 | CODE_SIGN_STYLE = Automatic; 428 | DEVELOPMENT_TEAM = UPP93EJ3U2; 429 | INFOPLIST_FILE = L2CapDemo/Info.plist; 430 | LD_RUNPATH_SEARCH_PATHS = ( 431 | "$(inherited)", 432 | "@executable_path/Frameworks", 433 | ); 434 | PRODUCT_BUNDLE_IDENTIFIER = me.wilko.L2CapDemo3; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | SWIFT_VERSION = 5.0; 437 | TARGETED_DEVICE_FAMILY = "1,2"; 438 | }; 439 | name = Release; 440 | }; 441 | BBDFB3AA23AC4EA600D93C0F /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | CODE_SIGN_ENTITLEMENTS = L2CapDemoMac/L2CapDemoMac.entitlements; 446 | CODE_SIGN_IDENTITY = "Apple Development"; 447 | CODE_SIGN_STYLE = Automatic; 448 | COMBINE_HIDPI_IMAGES = YES; 449 | DEVELOPMENT_TEAM = UPP93EJ3U2; 450 | ENABLE_HARDENED_RUNTIME = YES; 451 | INFOPLIST_FILE = L2CapDemoMac/Info.plist; 452 | LD_RUNPATH_SEARCH_PATHS = ( 453 | "$(inherited)", 454 | "@executable_path/../Frameworks", 455 | ); 456 | MACOSX_DEPLOYMENT_TARGET = 10.15; 457 | PRODUCT_BUNDLE_IDENTIFIER = me.wilko.L2CapDemoMac; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | SDKROOT = macosx; 460 | SWIFT_VERSION = 5.0; 461 | }; 462 | name = Debug; 463 | }; 464 | BBDFB3AB23AC4EA600D93C0F /* Release */ = { 465 | isa = XCBuildConfiguration; 466 | buildSettings = { 467 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 468 | CODE_SIGN_ENTITLEMENTS = L2CapDemoMac/L2CapDemoMac.entitlements; 469 | CODE_SIGN_IDENTITY = "Apple Development"; 470 | CODE_SIGN_STYLE = Automatic; 471 | COMBINE_HIDPI_IMAGES = YES; 472 | DEVELOPMENT_TEAM = UPP93EJ3U2; 473 | ENABLE_HARDENED_RUNTIME = YES; 474 | INFOPLIST_FILE = L2CapDemoMac/Info.plist; 475 | LD_RUNPATH_SEARCH_PATHS = ( 476 | "$(inherited)", 477 | "@executable_path/../Frameworks", 478 | ); 479 | MACOSX_DEPLOYMENT_TARGET = 10.15; 480 | PRODUCT_BUNDLE_IDENTIFIER = me.wilko.L2CapDemoMac; 481 | PRODUCT_NAME = "$(TARGET_NAME)"; 482 | SDKROOT = macosx; 483 | SWIFT_VERSION = 5.0; 484 | }; 485 | name = Release; 486 | }; 487 | /* End XCBuildConfiguration section */ 488 | 489 | /* Begin XCConfigurationList section */ 490 | BB696EC421F016D100116608 /* Build configuration list for PBXProject "L2CapDemo" */ = { 491 | isa = XCConfigurationList; 492 | buildConfigurations = ( 493 | BB696EDB21F016D200116608 /* Debug */, 494 | BB696EDC21F016D200116608 /* Release */, 495 | ); 496 | defaultConfigurationIsVisible = 0; 497 | defaultConfigurationName = Release; 498 | }; 499 | BB696EDD21F016D200116608 /* Build configuration list for PBXNativeTarget "L2CapDemo" */ = { 500 | isa = XCConfigurationList; 501 | buildConfigurations = ( 502 | BB696EDE21F016D200116608 /* Debug */, 503 | BB696EDF21F016D200116608 /* Release */, 504 | ); 505 | defaultConfigurationIsVisible = 0; 506 | defaultConfigurationName = Release; 507 | }; 508 | BBDFB3AC23AC4EA600D93C0F /* Build configuration list for PBXNativeTarget "L2CapDemoMac" */ = { 509 | isa = XCConfigurationList; 510 | buildConfigurations = ( 511 | BBDFB3AA23AC4EA600D93C0F /* Debug */, 512 | BBDFB3AB23AC4EA600D93C0F /* Release */, 513 | ); 514 | defaultConfigurationIsVisible = 0; 515 | defaultConfigurationName = Release; 516 | }; 517 | /* End XCConfigurationList section */ 518 | 519 | /* Begin XCRemoteSwiftPackageReference section */ 520 | BB3A7DE923A3411E0086C9ED /* XCRemoteSwiftPackageReference "L2Cap" */ = { 521 | isa = XCRemoteSwiftPackageReference; 522 | repositoryURL = "https://github.com/paulw11/L2Cap.git"; 523 | requirement = { 524 | branch = master; 525 | kind = branch; 526 | }; 527 | }; 528 | /* End XCRemoteSwiftPackageReference section */ 529 | 530 | /* Begin XCSwiftPackageProductDependency section */ 531 | BB3A7DEA23A3411E0086C9ED /* L2Cap */ = { 532 | isa = XCSwiftPackageProductDependency; 533 | package = BB3A7DE923A3411E0086C9ED /* XCRemoteSwiftPackageReference "L2Cap" */; 534 | productName = L2Cap; 535 | }; 536 | BBDFB3AE23AC6D4900D93C0F /* L2Cap */ = { 537 | isa = XCSwiftPackageProductDependency; 538 | package = BB3A7DE923A3411E0086C9ED /* XCRemoteSwiftPackageReference "L2Cap" */; 539 | productName = L2Cap; 540 | }; 541 | /* End XCSwiftPackageProductDependency section */ 542 | }; 543 | rootObject = BB696EC121F016D100116608 /* Project object */; 544 | } 545 | -------------------------------------------------------------------------------- /L2CapDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /L2CapDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /L2CapDemo.xcodeproj/xcuserdata/paulw.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | L2CapDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | L2CapDemoMac.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /L2CapDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // L2CapDemo 4 | // 5 | // Created by Paul Wilkinson on 17/1/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "first.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/first.imageset/first.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulw11/L2CapDemo/bafee16f418e0b7028e5e5df7686dab06dc9340b/L2CapDemo/Assets.xcassets/first.imageset/first.pdf -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "second.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /L2CapDemo/Assets.xcassets/second.imageset/second.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulw11/L2CapDemo/bafee16f418e0b7028e5e5df7686dab06dc9340b/L2CapDemo/Assets.xcassets/second.imageset/second.pdf -------------------------------------------------------------------------------- /L2CapDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /L2CapDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 58 | 59 | 60 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /L2CapDemo/CentralViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.swift 3 | // L2CapDemo 4 | // 5 | // Created by Paul Wilkinson on 17/1/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | import ExternalAccessory 12 | import L2Cap 13 | 14 | class CentralViewController: UIViewController { 15 | 16 | @IBOutlet weak var scanSwitch: UISwitch! 17 | @IBOutlet weak var inputText: UITextField! 18 | @IBOutlet weak var byteLabel: UILabel! 19 | @IBOutlet weak var sendButton: UIButton! 20 | @IBOutlet weak var stateLabel: UILabel! 21 | 22 | private var peripheral: CBPeripheral? 23 | private var connection: L2CapConnection? 24 | private var characteristic: CBCharacteristic? 25 | 26 | private var l2capCentral: L2CapCentral! 27 | 28 | private var bytesSent = 0 { 29 | didSet { 30 | self.byteLabel.text = "Bytes sent = \(self.bytesSent)" 31 | } 32 | } 33 | 34 | private var queueQueue = DispatchQueue(label: "queue queue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem, target: nil) 35 | 36 | private var outputData = Data() 37 | 38 | override func viewDidLoad() { 39 | super.viewDidLoad() 40 | // Do any additional setup after loading the view, typically from a nib. 41 | self.bytesSent = 0 42 | self.l2capCentral = L2CapCentral() 43 | self.l2capCentral.discoveredPeripheralCallback = { peripheral in 44 | print("Discovered peripheral \(peripheral)") 45 | self.peripheral = peripheral 46 | self.connect(peripheral: peripheral) 47 | } 48 | 49 | self.l2capCentral.disconnectedPeripheralCallBack = { (connection,error) in 50 | print("\(connection) disconnected") 51 | if let error = error { 52 | print("\(error)") 53 | } 54 | self.connection = nil 55 | if let peripheral = self.peripheral { 56 | print("Reconnecting to \(peripheral)...") 57 | self.connect(peripheral: peripheral) 58 | } 59 | } 60 | } 61 | 62 | private func connect(peripheral: CBPeripheral) { 63 | self.l2capCentral.connect(peripheral: peripheral) { connection in 64 | self.connection = connection 65 | self.connection?.receiveCallback = { (connection,data) in 66 | print("Received data") 67 | } 68 | self.connection?.sentDataCallback = { (connection, count) in 69 | self.bytesSent += count 70 | } 71 | DispatchQueue.main.async { 72 | self.sendButton.isEnabled = true 73 | } 74 | self.connection?.stateChangeCallback = { (connection, eventCode) in 75 | switch eventCode { 76 | case Stream.Event.openCompleted: 77 | self.stateLabel.text = "Stream is open" 78 | case Stream.Event.endEncountered: 79 | self.stateLabel.text = "End encountered" 80 | self.connection?.close() 81 | self.connection = nil 82 | break 83 | case Stream.Event.hasBytesAvailable: 84 | break 85 | case Stream.Event.hasSpaceAvailable: 86 | break 87 | case Stream.Event.errorOccurred: 88 | self.stateLabel.text = "Stream error" 89 | self.connection?.close() 90 | self.connection = nil 91 | default: 92 | self.stateLabel.text = "Unknown stream event" 93 | } 94 | } 95 | } 96 | } 97 | 98 | @IBAction func scanSwitched(_ sender: UISwitch) { 99 | self.l2capCentral.scan = sender.isOn 100 | } 101 | 102 | @IBAction func sendTextTapped(_ sender: UIButton) { 103 | guard let connection = self.connection else { 104 | return 105 | } 106 | if let text = self.inputText.text, let data = text.data(using: .utf8) { 107 | connection.send(data: data) 108 | } 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /L2CapDemo/Constants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.swift 3 | // L2CapDemo 4 | // 5 | // Created by Paul Wilkinson on 17/1/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreBluetooth 11 | 12 | struct Constants { 13 | static let serviceID = CBUUID(string:"12E61727-B41A-436F-B64D-4777B35F2294") 14 | static let PSMID = CBUUID(string:CBUUIDL2CAPPSMCharacteristicString) 15 | } 16 | -------------------------------------------------------------------------------- /L2CapDemo/DataExtensions.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation 3 | 4 | extension Data { 5 | 6 | init(from value: T) { 7 | self = Swift.withUnsafeBytes(of: value) { Data($0) } 8 | } 9 | 10 | func to(type: T.Type) -> T { 11 | return self.withUnsafeBytes { $0.pointee } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /L2CapDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSBluetoothAlwaysUsageDescription 24 | L2CapDemo will use Bluetooth to demonstrate L2CAP channels with Core Bluetooth 25 | UIBackgroundModes 26 | 27 | remote-notification 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UIStatusBarTintParameters 38 | 39 | UINavigationBar 40 | 41 | Style 42 | UIBarStyleDefault 43 | Translucent 44 | 45 | 46 | 47 | UISupportedInterfaceOrientations 48 | 49 | UIInterfaceOrientationPortrait 50 | UIInterfaceOrientationLandscapeLeft 51 | UIInterfaceOrientationLandscapeRight 52 | 53 | UISupportedInterfaceOrientations~ipad 54 | 55 | UIInterfaceOrientationPortrait 56 | UIInterfaceOrientationPortraitUpsideDown 57 | UIInterfaceOrientationLandscapeLeft 58 | UIInterfaceOrientationLandscapeRight 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /L2CapDemo/L2CapDemo.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /L2CapDemo/PeripheralViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.swift 3 | // L2CapDemo 4 | // 5 | // Created by Paul Wilkinson on 17/1/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | import L2Cap 12 | 13 | class PeripheralViewController: UIViewController { 14 | 15 | @IBOutlet weak var advertiseSwitch: UISwitch! 16 | @IBOutlet weak var publishSwitch: UISwitch! 17 | @IBOutlet weak var outputLabel: UILabel! 18 | 19 | private var peripheral: L2CapPeripheral! 20 | private var connection: L2CapConnection? 21 | 22 | private var bytesReceived = 0 { 23 | didSet { 24 | DispatchQueue.main.async { 25 | self.outputLabel.text = "Bytes received = \(self.bytesReceived)" 26 | } 27 | } 28 | } 29 | 30 | override func viewDidLoad() { 31 | super.viewDidLoad() 32 | // Do any additional setup after loading the view, typically from a nib. 33 | self.peripheral = L2CapPeripheral(connectionHandler: { (connection) in 34 | self.connection = connection 35 | self.connection?.receiveCallback = { (connection, data) in 36 | DispatchQueue.main.async { 37 | self.bytesReceived += data.count 38 | if let str = String(data: data, encoding: .utf8) { 39 | self.outputLabel.text = str 40 | } 41 | } 42 | } 43 | }) 44 | self.bytesReceived = 0 45 | } 46 | 47 | @IBAction func advertiseSwitched(_ sender: UISwitch) { 48 | self.peripheral.publish = sender.isOn 49 | self.publishSwitch.isOn = sender.isOn 50 | } 51 | 52 | @IBAction func publishSwitched(_ sender: UISwitch) { 53 | self.peripheral.publishChannel = sender.isOn 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /L2CapDemoMac/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // L2CapDemoMac 4 | // 5 | // Created by Paul Wilkinson on 20/12/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /L2CapDemoMac/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /L2CapDemoMac/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /L2CapDemoMac/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | Default 530 | 531 | 532 | 533 | 534 | 535 | 536 | Left to Right 537 | 538 | 539 | 540 | 541 | 542 | 543 | Right to Left 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | Default 555 | 556 | 557 | 558 | 559 | 560 | 561 | Left to Right 562 | 563 | 564 | 565 | 566 | 567 | 568 | Right to Left 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | -------------------------------------------------------------------------------- /L2CapDemoMac/CentralViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // L2CapDemoMac 4 | // 5 | // Created by Paul Wilkinson on 20/12/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import CoreBluetooth 11 | import L2Cap 12 | 13 | class CentralViewController: NSViewController { 14 | 15 | @IBOutlet weak var scanSwitch: NSSwitch! 16 | @IBOutlet weak var inputText: NSTextField! 17 | @IBOutlet weak var byteLabel: NSTextField! 18 | @IBOutlet weak var sendButton: NSButton! 19 | 20 | private var peripheral: CBPeripheral? 21 | private var connection: L2CapConnection? 22 | private var characteristic: CBCharacteristic? 23 | 24 | private var l2capCentral: L2CapCentral! 25 | 26 | private var queueQueue = DispatchQueue(label: "queue queue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem, target: nil) 27 | 28 | private var outputData = Data() 29 | 30 | 31 | private var bytesSent = 0 { 32 | didSet { 33 | self.byteLabel.stringValue = "Bytes sent = \(self.bytesSent)" 34 | } 35 | } 36 | 37 | override func viewDidLoad() { 38 | super.viewDidLoad() 39 | 40 | // Do any additional setup after loading the view. 41 | 42 | self.bytesSent = 0 43 | self.l2capCentral = L2CapCentral() 44 | self.l2capCentral.discoveredPeripheralCallback = { peripheral in 45 | self.peripheral = peripheral 46 | self.l2capCentral.connect(peripheral: peripheral) { connection in 47 | self.connection = connection 48 | self.connection?.receiveCallback = { (connection,data) in 49 | print("Received data") 50 | } 51 | self.connection?.sentDataCallback = { (connection, count) in 52 | self.bytesSent += count 53 | } 54 | DispatchQueue.main.async { 55 | self.sendButton.isEnabled = true 56 | } 57 | } 58 | } 59 | self.l2capCentral.disconnectedPeripheralCallBack = { (connection, error) in 60 | print("Disconnected \(connection)") 61 | if let err = error { 62 | print("With error \(err)") 63 | } 64 | } 65 | } 66 | 67 | override var representedObject: Any? { 68 | didSet { 69 | // Update the view, if already loaded. 70 | } 71 | } 72 | 73 | @IBAction func scanSwitched(_ sender: NSSwitch) { 74 | self.l2capCentral.scan = sender.state == .on 75 | } 76 | 77 | @IBAction func sendTextTapped(_ sender: NSButton) { 78 | guard let connection = self.connection else { 79 | return 80 | } 81 | let text = self.inputText.stringValue 82 | if let data = text.data(using: .utf8) { 83 | connection.send(data: data) 84 | } 85 | } 86 | 87 | 88 | } 89 | 90 | -------------------------------------------------------------------------------- /L2CapDemoMac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2019 Paul Wilkinson. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | NSSupportsAutomaticTermination 32 | 33 | NSSupportsSuddenTermination 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /L2CapDemoMac/PeripheralViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeripheralViewController.swift 3 | // L2CapDemoMac 4 | // 5 | // Created by Paul Wilkinson on 20/12/19. 6 | // Copyright © 2019 Paul Wilkinson. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import CoreBluetooth 11 | import L2Cap 12 | 13 | class PeripheralViewController: NSViewController { 14 | 15 | @IBOutlet weak var advertiseSwitch: NSSwitch! 16 | @IBOutlet weak var outputLabel: NSTextField! 17 | 18 | private var peripheral: L2CapPeripheral! 19 | private var connection: L2CapConnection? 20 | 21 | private var bytesReceived = 0 { 22 | didSet { 23 | DispatchQueue.main.async { 24 | self.outputLabel.stringValue = "Bytes received = \(self.bytesReceived)" 25 | } 26 | } 27 | } 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | // Do any additional setup after loading the view, typically from a nib. 32 | self.peripheral = L2CapPeripheral(connectionHandler: { (connection) in 33 | self.connection = connection 34 | self.connection?.receiveCallback = { (connection, data) in 35 | DispatchQueue.main.async { 36 | self.bytesReceived += data.count 37 | if let str = String(data: data, encoding: .utf8) { 38 | self.outputLabel.stringValue = str 39 | } 40 | } 41 | } 42 | }) 43 | self.bytesReceived = 0 44 | } 45 | 46 | @IBAction func advertiseSwitched(_ sender: NSSwitch) { 47 | self.peripheral.publish = sender.state == .on 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Paul Wilkinson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # L2CapDemo 2 | Demonstration of using Core Bluetooth L2CAP channels in Swift on iOS. Use the [L2Cap swift module](https://github.com/paulw11/L2Cap) 3 | 4 | You will need two iOS devices to run this demo. Bluetooth is not supported in the simulator. 5 | 6 | On one device, turn on the *Scan* switch - this device is the central that will look for a peripheral 7 | On the other device, turn on tyhe *Advertise* switch - This device is the peripheral. 8 | 9 | Once a connection is made, text entered into the text field on the central will be displayed on the peripheral when you tap *Send* 10 | 11 | --------------------------------------------------------------------------------