├── .gitignore ├── BLETemperatureReaderSwift ├── BLETemperatureReaderSwift.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── BLETemperatureReaderSwift │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-29@2x.png │ │ │ ├── Icon-29@3x.png │ │ │ ├── Icon-40@2x.png │ │ │ ├── Icon-40@3x.png │ │ │ ├── Icon-60@2x.png │ │ │ └── Icon-60@3x.png │ │ ├── Contents.json │ │ ├── temp-10.imageset │ │ │ ├── 10s.png │ │ │ ├── 10s@2x.png │ │ │ ├── 10s@3x.png │ │ │ └── Contents.json │ │ ├── temp-100.imageset │ │ │ ├── 100s.png │ │ │ ├── 100s@2x.png │ │ │ ├── 100s@3x.png │ │ │ └── Contents.json │ │ ├── temp-20.imageset │ │ │ ├── 20s.png │ │ │ ├── 20s@2x.png │ │ │ ├── 20s@3x.png │ │ │ └── Contents.json │ │ ├── temp-30.imageset │ │ │ ├── 30s.png │ │ │ ├── 30s@2x.png │ │ │ ├── 30s@3x.png │ │ │ └── Contents.json │ │ ├── temp-40.imageset │ │ │ ├── 40s.png │ │ │ ├── 40s@2x.png │ │ │ ├── 40s@3x.png │ │ │ └── Contents.json │ │ ├── temp-50.imageset │ │ │ ├── 50s.png │ │ │ ├── 50s@2x.png │ │ │ ├── 50s@3x.png │ │ │ └── Contents.json │ │ ├── temp-60.imageset │ │ │ ├── 60s.png │ │ │ ├── 60s@2x.png │ │ │ ├── 60s@3x.png │ │ │ └── Contents.json │ │ ├── temp-70.imageset │ │ │ ├── 70s.png │ │ │ ├── 70s@2x.png │ │ │ ├── 70s@3x.png │ │ │ └── Contents.json │ │ ├── temp-80.imageset │ │ │ ├── 80s.png │ │ │ ├── 80s@2x.png │ │ │ ├── 80s@3x.png │ │ │ └── Contents.json │ │ └── temp-90.imageset │ │ │ ├── 90s.png │ │ │ ├── 90s@2x.png │ │ │ ├── 90s@3x.png │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Device.swift │ ├── Info.plist │ └── TemperatureViewController.swift └── README.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | *.DS_Store 3 | 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | DerivedData/ 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xcuserstate 26 | *.xcworkspace 27 | !default.xcworkspace 28 | 29 | ## Obj-C/Swift specific 30 | *.hmap 31 | *.ipa 32 | *.dSYM.zip 33 | *.dSYM 34 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C80679C01CB9B7ED009BCB93 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C80679BF1CB9B7ED009BCB93 /* AppDelegate.swift */; }; 11 | C80679C51CB9B7ED009BCB93 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C80679C31CB9B7ED009BCB93 /* Main.storyboard */; }; 12 | C80679C71CB9B7ED009BCB93 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C80679C61CB9B7ED009BCB93 /* Assets.xcassets */; }; 13 | C80679CA1CB9B7ED009BCB93 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C80679C81CB9B7ED009BCB93 /* LaunchScreen.storyboard */; }; 14 | C80679D41CB9BF83009BCB93 /* TemperatureViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C80679D31CB9BF83009BCB93 /* TemperatureViewController.swift */; }; 15 | C80679D61CB9C03A009BCB93 /* Device.swift in Sources */ = {isa = PBXBuildFile; fileRef = C80679D51CB9C03A009BCB93 /* Device.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | C80679BC1CB9B7ED009BCB93 /* BLETemperatureReaderSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BLETemperatureReaderSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | C80679BF1CB9B7ED009BCB93 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | C80679C41CB9B7ED009BCB93 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 22 | C80679C61CB9B7ED009BCB93 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | C80679C91CB9B7ED009BCB93 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | C80679CB1CB9B7ED009BCB93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | C80679D31CB9BF83009BCB93 /* TemperatureViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TemperatureViewController.swift; sourceTree = ""; }; 26 | C80679D51CB9C03A009BCB93 /* Device.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Device.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | C80679B91CB9B7ED009BCB93 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | C80679B31CB9B7ED009BCB93 = { 41 | isa = PBXGroup; 42 | children = ( 43 | C80679BE1CB9B7ED009BCB93 /* BLETemperatureReaderSwift */, 44 | C80679BD1CB9B7ED009BCB93 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | C80679BD1CB9B7ED009BCB93 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | C80679BC1CB9B7ED009BCB93 /* BLETemperatureReaderSwift.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | C80679BE1CB9B7ED009BCB93 /* BLETemperatureReaderSwift */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | C80679D51CB9C03A009BCB93 /* Device.swift */, 60 | C80679BF1CB9B7ED009BCB93 /* AppDelegate.swift */, 61 | C80679D31CB9BF83009BCB93 /* TemperatureViewController.swift */, 62 | C80679C31CB9B7ED009BCB93 /* Main.storyboard */, 63 | C80679C61CB9B7ED009BCB93 /* Assets.xcassets */, 64 | C80679C81CB9B7ED009BCB93 /* LaunchScreen.storyboard */, 65 | C80679CB1CB9B7ED009BCB93 /* Info.plist */, 66 | ); 67 | path = BLETemperatureReaderSwift; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | C80679BB1CB9B7ED009BCB93 /* BLETemperatureReaderSwift */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = C80679CE1CB9B7ED009BCB93 /* Build configuration list for PBXNativeTarget "BLETemperatureReaderSwift" */; 76 | buildPhases = ( 77 | C8005C8A1D39920B0000F8BA /* ShellScript */, 78 | C80679B81CB9B7ED009BCB93 /* Sources */, 79 | C80679B91CB9B7ED009BCB93 /* Frameworks */, 80 | C80679BA1CB9B7ED009BCB93 /* Resources */, 81 | ); 82 | buildRules = ( 83 | ); 84 | dependencies = ( 85 | ); 86 | name = BLETemperatureReaderSwift; 87 | productName = iOSRemoteConfBLEDemo; 88 | productReference = C80679BC1CB9B7ED009BCB93 /* BLETemperatureReaderSwift.app */; 89 | productType = "com.apple.product-type.application"; 90 | }; 91 | /* End PBXNativeTarget section */ 92 | 93 | /* Begin PBXProject section */ 94 | C80679B41CB9B7ED009BCB93 /* Project object */ = { 95 | isa = PBXProject; 96 | attributes = { 97 | LastSwiftUpdateCheck = 0730; 98 | LastUpgradeCheck = 0730; 99 | ORGANIZATIONNAME = "Cloud City"; 100 | TargetAttributes = { 101 | C80679BB1CB9B7ED009BCB93 = { 102 | CreatedOnToolsVersion = 7.3; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = C80679B71CB9B7ED009BCB93 /* Build configuration list for PBXProject "BLETemperatureReaderSwift" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = English; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = C80679B31CB9B7ED009BCB93; 115 | productRefGroup = C80679BD1CB9B7ED009BCB93 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | C80679BB1CB9B7ED009BCB93 /* BLETemperatureReaderSwift */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | C80679BA1CB9B7ED009BCB93 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | C80679CA1CB9B7ED009BCB93 /* LaunchScreen.storyboard in Resources */, 130 | C80679C71CB9B7ED009BCB93 /* Assets.xcassets in Resources */, 131 | C80679C51CB9B7ED009BCB93 /* Main.storyboard in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXShellScriptBuildPhase section */ 138 | C8005C8A1D39920B0000F8BA /* ShellScript */ = { 139 | isa = PBXShellScriptBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | ); 143 | inputPaths = ( 144 | ); 145 | outputPaths = ( 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | shellPath = /bin/sh; 149 | shellScript = "if [ $CONFIGURATION == Release ]; then\necho \"Bumping build number...\"\nplist=${PROJECT_DIR}/${INFOPLIST_FILE}\n\n# increment the build number (ie 115 to 116)\nbuildnum=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${plist}\")\nif [[ \"${buildnum}\" == \"\" ]]; then\necho \"No build number in $plist\"\nexit 2\nfi\n\nbuildnum=$(expr $buildnum + 1)\n/usr/libexec/Plistbuddy -c \"Set CFBundleVersion $buildnum\" \"${plist}\"\necho \"Bumped build number to $buildnum\"\n\nelse\necho $CONFIGURATION \" build - Not bumping build number.\"\nfi"; 150 | }; 151 | /* End PBXShellScriptBuildPhase section */ 152 | 153 | /* Begin PBXSourcesBuildPhase section */ 154 | C80679B81CB9B7ED009BCB93 /* Sources */ = { 155 | isa = PBXSourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | C80679D61CB9C03A009BCB93 /* Device.swift in Sources */, 159 | C80679C01CB9B7ED009BCB93 /* AppDelegate.swift in Sources */, 160 | C80679D41CB9BF83009BCB93 /* TemperatureViewController.swift in Sources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXSourcesBuildPhase section */ 165 | 166 | /* Begin PBXVariantGroup section */ 167 | C80679C31CB9B7ED009BCB93 /* Main.storyboard */ = { 168 | isa = PBXVariantGroup; 169 | children = ( 170 | C80679C41CB9B7ED009BCB93 /* Base */, 171 | ); 172 | name = Main.storyboard; 173 | sourceTree = ""; 174 | }; 175 | C80679C81CB9B7ED009BCB93 /* LaunchScreen.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | C80679C91CB9B7ED009BCB93 /* Base */, 179 | ); 180 | name = LaunchScreen.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | C80679CC1CB9B7ED009BCB93 /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_NONNULL = YES; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_WARN_BOOL_CONVERSION = YES; 196 | CLANG_WARN_CONSTANT_CONVERSION = YES; 197 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INT_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_UNREACHABLE_CODE = YES; 203 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 204 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 224 | MTL_ENABLE_DEBUG_INFO = YES; 225 | ONLY_ACTIVE_ARCH = YES; 226 | SDKROOT = iphoneos; 227 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 228 | }; 229 | name = Debug; 230 | }; 231 | C80679CD1CB9B7ED009BCB93 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | CLANG_ANALYZER_NONNULL = YES; 236 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 237 | CLANG_CXX_LIBRARY = "libc++"; 238 | CLANG_ENABLE_MODULES = YES; 239 | CLANG_ENABLE_OBJC_ARC = YES; 240 | CLANG_WARN_BOOL_CONVERSION = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INT_CONVERSION = YES; 246 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 247 | CLANG_WARN_UNREACHABLE_CODE = YES; 248 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 249 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 250 | COPY_PHASE_STRIP = NO; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu99; 255 | GCC_NO_COMMON_BLOCKS = YES; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | SDKROOT = iphoneos; 265 | VALIDATE_PRODUCT = YES; 266 | }; 267 | name = Release; 268 | }; 269 | C80679CF1CB9B7ED009BCB93 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | INFOPLIST_FILE = BLETemperatureReaderSwift/Info.plist; 274 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 275 | PRODUCT_BUNDLE_IDENTIFIER = io.cloudcity.BLETemperatureReaderSwift; 276 | PRODUCT_NAME = BLETemperatureReaderSwift; 277 | }; 278 | name = Debug; 279 | }; 280 | C80679D01CB9B7ED009BCB93 /* Release */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 284 | INFOPLIST_FILE = BLETemperatureReaderSwift/Info.plist; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = io.cloudcity.BLETemperatureReaderSwift; 287 | PRODUCT_NAME = BLETemperatureReaderSwift; 288 | }; 289 | name = Release; 290 | }; 291 | /* End XCBuildConfiguration section */ 292 | 293 | /* Begin XCConfigurationList section */ 294 | C80679B71CB9B7ED009BCB93 /* Build configuration list for PBXProject "BLETemperatureReaderSwift" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | C80679CC1CB9B7ED009BCB93 /* Debug */, 298 | C80679CD1CB9B7ED009BCB93 /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | C80679CE1CB9B7ED009BCB93 /* Build configuration list for PBXNativeTarget "BLETemperatureReaderSwift" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | C80679CF1CB9B7ED009BCB93 /* Debug */, 307 | C80679D01CB9B7ED009BCB93 /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | /* End XCConfigurationList section */ 313 | }; 314 | rootObject = C80679B41CB9B7ED009BCB93 /* Project object */; 315 | } 316 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // iOSRemoteConfBLEDemo 4 | // 5 | // Created by Evan Stone on 4/9/16. 6 | // Copyright © 2016 Cloud City. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | func applicationWillResignActive(application: UIApplication) { 22 | // 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. 23 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 24 | } 25 | 26 | func applicationDidEnterBackground(application: UIApplication) { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | func applicationWillEnterForeground(application: UIApplication) { 32 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 33 | } 34 | 35 | func applicationDidBecomeActive(application: UIApplication) { 36 | // 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. 37 | } 38 | 39 | func applicationWillTerminate(application: UIApplication) { 40 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 41 | } 42 | 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-29@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/10s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-10.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "10s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "10s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "10s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/100s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-100.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "100s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "100s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "100s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/20s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-20.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "20s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "20s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "20s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/30s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-30.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "30s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "30s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "30s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/40s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-40.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "40s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "40s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "40s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/50s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-50.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "50s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "50s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "50s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/60s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-60.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "60s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "60s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "60s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/70s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-70.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "70s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "70s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "70s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/80s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-80.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "80s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "80s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "80s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s@2x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudcity/ZeroToBLE-Part2-Swift/27e076f898997ba9d3685e8d65c9717a62faaea4/BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/90s@3x.png -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Assets.xcassets/temp-90.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "90s.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "90s@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "90s@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/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 | 47 | 56 | 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 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Device.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BLEConstants.swift 3 | // iOSRemoteConfBLEDemo 4 | // 5 | // Created by Evan Stone on 4/9/16. 6 | // Copyright © 2016 Cloud City. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | //------------------------------------------------------------------------ 13 | // Information about Texas Instruments SensorTag UUIDs can be found at: 14 | // http://processors.wiki.ti.com/index.php/SensorTag_User_Guide#Sensors 15 | //------------------------------------------------------------------------ 16 | // From the TI documentation: 17 | // The TI Base 128-bit UUID is: F0000000-0451-4000-B000-000000000000. 18 | // 19 | // All sensor services use 128-bit UUIDs, but for practical reasons only 20 | // the 16-bit part is listed in this document. 21 | // 22 | // It is embedded in the 128-bit UUID as shown by example below. 23 | // 24 | // Base 128-bit UUID: F0000000-0451-4000-B000-000000000000 25 | // "0xAA01" maps as: F000AA01-0451-4000-B000-000000000000 26 | // ^--^ 27 | //------------------------------------------------------------------------ 28 | 29 | struct Device { 30 | 31 | static let SensorTagAdvertisingUUID = "AA10" 32 | 33 | static let TemperatureServiceUUID = "F000AA00-0451-4000-B000-000000000000" 34 | static let TemperatureDataUUID = "F000AA01-0451-4000-B000-000000000000" 35 | static let TemperatureConfig = "F000AA02-0451-4000-B000-000000000000" 36 | 37 | static let HumidityServiceUUID = "F000AA20-0451-4000-B000-000000000000" 38 | static let HumidityDataUUID = "F000AA21-0451-4000-B000-000000000000" 39 | static let HumidityConfig = "F000AA22-0451-4000-B000-000000000000" 40 | 41 | static let SensorDataIndexTempInfrared = 0 42 | static let SensorDataIndexTempAmbient = 1 43 | static let SensorDataIndexHumidityTemp = 0 44 | static let SensorDataIndexHumidity = 1 45 | } 46 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | BLE Swift 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/BLETemperatureReaderSwift/TemperatureViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TemperatureViewController.swift 3 | // iOSRemoteConfBLEDemo 4 | // 5 | // Created by Evan Stone on 4/9/16. 6 | // Copyright © 2016 Cloud City. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | // Conform to CBCentralManagerDelegate, CBPeripheralDelegate protocols 13 | class TemperatureViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate { 14 | 15 | @IBOutlet weak var backgroundImageView1: UIImageView! 16 | @IBOutlet weak var backgroundImageView2: UIImageView! 17 | @IBOutlet weak var controlContainerView: UIView! 18 | @IBOutlet weak var circleView: UIView! 19 | @IBOutlet weak var temperatureLabel: UILabel! 20 | @IBOutlet weak var humidityLabel: UILabel! 21 | @IBOutlet weak var disconnectButton: UIButton! 22 | 23 | // define our scanning interval times 24 | let timerPauseInterval:NSTimeInterval = 10.0 25 | let timerScanInterval:NSTimeInterval = 2.0 26 | 27 | // UI-related 28 | let temperatureLabelFontName = "HelveticaNeue-Thin" 29 | let temperatureLabelFontSizeMessage:CGFloat = 56.0 30 | let temperatureLabelFontSizeTemp:CGFloat = 81.0 31 | 32 | var backgroundImageViews: [UIImageView]! 33 | var visibleBackgroundIndex = 0 34 | var invisibleBackgroundIndex = 1 35 | var lastTemperatureTens = 0 36 | let defaultInitialTemperature = -9999 37 | var lastTemperature:Int! 38 | var lastHumidity:Double = -9999 39 | var circleDrawn = false 40 | var keepScanning = false 41 | //var isScanning = false 42 | 43 | // Core Bluetooth properties 44 | var centralManager:CBCentralManager! 45 | var sensorTag:CBPeripheral? 46 | var temperatureCharacteristic:CBCharacteristic? 47 | var humidityCharacteristic:CBCharacteristic? 48 | 49 | // This could be simplified to "SensorTag" and check if it's a substring. 50 | // (Probably a good idea to do that if you're using a different model of 51 | // the SensorTag, or if you don't know what model it is...) 52 | let sensorTagName = "CC2650 SensorTag" 53 | 54 | override func viewDidLoad() { 55 | super.viewDidLoad() 56 | 57 | lastTemperature = defaultInitialTemperature 58 | 59 | // Create our CBCentral Manager 60 | // delegate: The delegate that will receive central role events. Typically self. 61 | // queue: The dispatch queue to use to dispatch the central role events. 62 | // If the value is nil, the central manager dispatches central role events using the main queue. 63 | centralManager = CBCentralManager(delegate: self, queue: nil) 64 | 65 | // Central Manager Initialization Options (Apple Developer Docs): http://tinyurl.com/zzvsgjh 66 | // CBCentralManagerOptionShowPowerAlertKey 67 | // CBCentralManagerOptionRestoreIdentifierKey 68 | // To opt in to state preservation and restoration in an app that uses only one instance of a 69 | // CBCentralManager object to implement the central role, specify this initialization option and provide 70 | // a restoration identifier for the central manager when you allocate and initialize it. 71 | //centralManager = CBCentralManager(delegate: self, queue: nil, options: nil) 72 | 73 | // configure initial UI 74 | temperatureLabel.font = UIFont(name: temperatureLabelFontName, size: temperatureLabelFontSizeMessage) 75 | temperatureLabel.text = "Searching" 76 | humidityLabel.text = "" 77 | humidityLabel.hidden = true 78 | circleView.hidden = true 79 | backgroundImageViews = [backgroundImageView1, backgroundImageView2] 80 | view.bringSubviewToFront(backgroundImageViews[0]) 81 | backgroundImageViews[0].alpha = 1 82 | backgroundImageViews[1].alpha = 0 83 | view.bringSubviewToFront(controlContainerView) 84 | } 85 | 86 | override func viewWillAppear(animated: Bool) { 87 | if lastTemperature != defaultInitialTemperature { 88 | updateTemperatureDisplay() 89 | } 90 | } 91 | 92 | 93 | // MARK: - Handling User Interaction 94 | 95 | @IBAction func handleDisconnectButtonTapped(sender: AnyObject) { 96 | // if we don't have a sensor tag, start scanning for one... 97 | if sensorTag == nil { 98 | keepScanning = true 99 | resumeScan() 100 | return 101 | } else { 102 | disconnect() 103 | } 104 | } 105 | 106 | func disconnect() { 107 | if let sensorTag = self.sensorTag { 108 | if let tc = self.temperatureCharacteristic { 109 | sensorTag.setNotifyValue(false, forCharacteristic: tc) 110 | } 111 | if let hc = self.humidityCharacteristic { 112 | sensorTag.setNotifyValue(false, forCharacteristic: hc) 113 | } 114 | 115 | /* 116 | NOTE: The cancelPeripheralConnection: method is nonblocking, and any CBPeripheral class commands 117 | that are still pending to the peripheral you’re trying to disconnect may or may not finish executing. 118 | Because other apps may still have a connection to the peripheral, canceling a local connection 119 | does not guarantee that the underlying physical link is immediately disconnected. 120 | 121 | From your app’s perspective, however, the peripheral is considered disconnected, and the central manager 122 | object calls the centralManager:didDisconnectPeripheral:error: method of its delegate object. 123 | */ 124 | centralManager.cancelPeripheralConnection(sensorTag) 125 | } 126 | temperatureCharacteristic = nil 127 | humidityCharacteristic = nil 128 | } 129 | 130 | 131 | // MARK: - Bluetooth scanning 132 | 133 | func pauseScan() { 134 | // Scanning uses up battery on phone, so pause the scan process for the designated interval. 135 | print("*** PAUSING SCAN...") 136 | _ = NSTimer(timeInterval: timerPauseInterval, target: self, selector: #selector(resumeScan), userInfo: nil, repeats: false) 137 | centralManager.stopScan() 138 | disconnectButton.enabled = true 139 | } 140 | 141 | func resumeScan() { 142 | if keepScanning { 143 | // Start scanning again... 144 | print("*** RESUMING SCAN!") 145 | disconnectButton.enabled = false 146 | temperatureLabel.font = UIFont(name: temperatureLabelFontName, size: temperatureLabelFontSizeMessage) 147 | temperatureLabel.text = "Searching" 148 | _ = NSTimer(timeInterval: timerScanInterval, target: self, selector: #selector(pauseScan), userInfo: nil, repeats: false) 149 | centralManager.scanForPeripheralsWithServices(nil, options: nil) 150 | } else { 151 | disconnectButton.enabled = true 152 | } 153 | } 154 | 155 | 156 | // MARK: - Updating UI 157 | 158 | func updateTemperatureDisplay() { 159 | if !circleDrawn { 160 | drawCircle() 161 | } else { 162 | circleView.hidden = false 163 | } 164 | 165 | updateBackgroundImageForTemperature(lastTemperature) 166 | temperatureLabel.font = UIFont(name: temperatureLabelFontName, size: temperatureLabelFontSizeTemp) 167 | temperatureLabel.text = " \(lastTemperature)°" 168 | } 169 | 170 | func drawCircle() { 171 | circleView.hidden = false 172 | let circleLayer = CAShapeLayer() 173 | circleLayer.path = UIBezierPath(ovalInRect: CGRectMake(0, 0, circleView.frame.width, circleView.frame.height)).CGPath 174 | circleView.layer.addSublayer(circleLayer) 175 | circleLayer.lineWidth = 2 176 | circleLayer.strokeColor = UIColor.whiteColor().CGColor 177 | circleLayer.fillColor = UIColor.clearColor().CGColor 178 | circleDrawn = true 179 | } 180 | 181 | func tensValue(temperature:Int) -> Int { 182 | var temperatureTens = 10; 183 | if (temperature > 19) { 184 | if (temperature > 99) { 185 | temperatureTens = 100; 186 | } else { 187 | temperatureTens = 10 * Int(floor( Double(temperature / 10) + 0.5 )) 188 | } 189 | } 190 | return temperatureTens 191 | } 192 | 193 | func updateBackgroundImageForTemperature(temperature:Int) { 194 | let temperatureTens = tensValue(temperature) 195 | if temperatureTens != lastTemperatureTens { 196 | // generate file name of new background to show 197 | let temperatureFilename = "temp-\(temperatureTens)" 198 | print("*** BACKGROUND FILENAME: \(temperatureFilename)") 199 | 200 | // fade out old background, fade in new. 201 | let visibleBackground = backgroundImageViews[visibleBackgroundIndex] 202 | let invisibleBackground = backgroundImageViews[invisibleBackgroundIndex] 203 | invisibleBackground.image = UIImage(named: temperatureFilename) 204 | invisibleBackground.alpha = 0 205 | view.bringSubviewToFront(invisibleBackground) 206 | view.bringSubviewToFront(controlContainerView) 207 | UIView.animateWithDuration(0.5, animations: { 208 | invisibleBackground.alpha = 1; 209 | }, completion: { (finished) in 210 | visibleBackground.alpha = 0 211 | let indexTemp = self.visibleBackgroundIndex 212 | self.visibleBackgroundIndex = self.invisibleBackgroundIndex 213 | self.invisibleBackgroundIndex = indexTemp 214 | print("**** NEW INDICES - visible: \(self.visibleBackgroundIndex) - invisible: \(self.invisibleBackgroundIndex)") 215 | }) 216 | } 217 | } 218 | 219 | func displayTemperature(data:NSData) { 220 | // We'll get four bytes of data back, so we divide the byte count by two 221 | // because we're creating an array that holds two 16-bit (two-byte) values 222 | let dataLength = data.length / sizeof(UInt16) 223 | var dataArray = [UInt16](count:dataLength, repeatedValue: 0) 224 | data.getBytes(&dataArray, length: dataLength * sizeof(Int16)) 225 | 226 | // // output values for debugging/diagnostic purposes 227 | // for i in 0 ..< dataLength { 228 | // let nextInt:UInt16 = dataArray[i] 229 | // print("next int: \(nextInt)") 230 | // } 231 | 232 | let rawAmbientTemp:UInt16 = dataArray[Device.SensorDataIndexTempAmbient] 233 | let ambientTempC = Double(rawAmbientTemp) / 128.0 234 | let ambientTempF = convertCelciusToFahrenheit(ambientTempC) 235 | print("*** AMBIENT TEMPERATURE SENSOR (C/F): \(ambientTempC), \(ambientTempF)"); 236 | 237 | // Device also retrieves an infrared temperature sensor value, which we don't use in this demo. 238 | // However, for instructional purposes, here's how to get at it to compare to the ambient temperature: 239 | let rawInfraredTemp:UInt16 = dataArray[Device.SensorDataIndexTempInfrared] 240 | let infraredTempC = Double(rawInfraredTemp) / 128.0 241 | let infraredTempF = convertCelciusToFahrenheit(infraredTempC) 242 | print("*** INFRARED TEMPERATURE SENSOR (C/F): \(infraredTempC), \(infraredTempF)"); 243 | 244 | let temp = Int(ambientTempF) 245 | lastTemperature = temp 246 | print("*** LAST TEMPERATURE CAPTURED: \(lastTemperature)° F") 247 | 248 | if UIApplication.sharedApplication().applicationState == .Active { 249 | updateTemperatureDisplay() 250 | } 251 | } 252 | 253 | func displayHumidity(data:NSData) { 254 | let dataLength = data.length / sizeof(UInt16) 255 | var dataArray = [UInt16](count:dataLength, repeatedValue: 0) 256 | data.getBytes(&dataArray, length: dataLength * sizeof(Int16)) 257 | 258 | for i in 0 ..< dataLength { 259 | let nextInt:UInt16 = dataArray[i] 260 | print("next int: \(nextInt)") 261 | } 262 | 263 | let rawHumidity:UInt16 = dataArray[Device.SensorDataIndexHumidity] 264 | let calculatedHumidity = calculateRelativeHumidity(rawHumidity) 265 | print("*** HUMIDITY: \(calculatedHumidity)"); 266 | humidityLabel.text = String(format: "Humidity: %.01f%%", calculatedHumidity) 267 | humidityLabel.hidden = false 268 | 269 | // Humidity sensor also retrieves a temperature, which we don't use. 270 | // However, for instructional purposes, here's how to get at it to compare to the ambient sensor: 271 | let rawHumidityTemp:UInt16 = dataArray[Device.SensorDataIndexHumidityTemp] 272 | let calculatedTemperatureC = calculateHumidityTemperature(rawHumidityTemp) 273 | let calculatedTemperatureF = convertCelciusToFahrenheit(calculatedTemperatureC) 274 | print("*** HUMIDITY TEMP C: \(calculatedTemperatureC) F: \(calculatedTemperatureF)") 275 | 276 | } 277 | 278 | // MARK: - CBCentralManagerDelegate methods 279 | 280 | // Invoked when the central manager’s state is updated. 281 | func centralManagerDidUpdateState(central: CBCentralManager) { 282 | var showAlert = true 283 | var message = "" 284 | 285 | switch central.state { 286 | case .PoweredOff: 287 | message = "Bluetooth on this device is currently powered off." 288 | case .Unsupported: 289 | message = "This device does not support Bluetooth Low Energy." 290 | case .Unauthorized: 291 | message = "This app is not authorized to use Bluetooth Low Energy." 292 | case .Resetting: 293 | message = "The BLE Manager is resetting; a state update is pending." 294 | case .Unknown: 295 | message = "The state of the BLE Manager is unknown." 296 | case .PoweredOn: 297 | showAlert = false 298 | message = "Bluetooth LE is turned on and ready for communication." 299 | 300 | print(message) 301 | keepScanning = true 302 | _ = NSTimer(timeInterval: timerScanInterval, target: self, selector: #selector(pauseScan), userInfo: nil, repeats: false) 303 | 304 | // Initiate Scan for Peripherals 305 | //Option 1: Scan for all devices 306 | centralManager.scanForPeripheralsWithServices(nil, options: nil) 307 | 308 | // Option 2: Scan for devices that have the service you're interested in... 309 | //let sensorTagAdvertisingUUID = CBUUID(string: Device.SensorTagAdvertisingUUID) 310 | //print("Scanning for SensorTag adverstising with UUID: \(sensorTagAdvertisingUUID)") 311 | //centralManager.scanForPeripheralsWithServices([sensorTagAdvertisingUUID], options: nil) 312 | 313 | } 314 | 315 | if showAlert { 316 | let alertController = UIAlertController(title: "Central Manager State", message: message, preferredStyle: UIAlertControllerStyle.Alert) 317 | let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil) 318 | alertController.addAction(okAction) 319 | self.showViewController(alertController, sender: self) 320 | } 321 | } 322 | 323 | 324 | /* 325 | Invoked when the central manager discovers a peripheral while scanning. 326 | 327 | The advertisement data can be accessed through the keys listed in Advertisement Data Retrieval Keys. 328 | You must retain a local copy of the peripheral if any command is to be performed on it. 329 | In use cases where it makes sense for your app to automatically connect to a peripheral that is 330 | located within a certain range, you can use RSSI data to determine the proximity of a discovered 331 | peripheral device. 332 | 333 | central - The central manager providing the update. 334 | peripheral - The discovered peripheral. 335 | advertisementData - A dictionary containing any advertisement data. 336 | RSSI - The current received signal strength indicator (RSSI) of the peripheral, in decibels. 337 | 338 | */ 339 | func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) { 340 | print("centralManager didDiscoverPeripheral - CBAdvertisementDataLocalNameKey is \"\(CBAdvertisementDataLocalNameKey)\"") 341 | 342 | // Retrieve the peripheral name from the advertisement data using the "kCBAdvDataLocalName" key 343 | if let peripheralName = advertisementData[CBAdvertisementDataLocalNameKey] as? String { 344 | print("NEXT PERIPHERAL NAME: \(peripheralName)") 345 | print("NEXT PERIPHERAL UUID: \(peripheral.identifier.UUIDString)") 346 | 347 | if peripheralName == sensorTagName { 348 | print("SENSOR TAG FOUND! ADDING NOW!!!") 349 | // to save power, stop scanning for other devices 350 | keepScanning = false 351 | disconnectButton.enabled = true 352 | 353 | // save a reference to the sensor tag 354 | sensorTag = peripheral 355 | sensorTag!.delegate = self 356 | 357 | // Request a connection to the peripheral 358 | centralManager.connectPeripheral(sensorTag!, options: nil) 359 | } 360 | } 361 | } 362 | 363 | 364 | /* 365 | Invoked when a connection is successfully created with a peripheral. 366 | 367 | This method is invoked when a call to connectPeripheral:options: is successful. 368 | You typically implement this method to set the peripheral’s delegate and to discover its services. 369 | */ 370 | func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) { 371 | print("**** SUCCESSFULLY CONNECTED TO SENSOR TAG!!!") 372 | 373 | temperatureLabel.font = UIFont(name: temperatureLabelFontName, size: temperatureLabelFontSizeMessage) 374 | temperatureLabel.text = "Connected" 375 | 376 | // Now that we've successfully connected to the SensorTag, let's discover the services. 377 | // - NOTE: we pass nil here to request ALL services be discovered. 378 | // If there was a subset of services we were interested in, we could pass the UUIDs here. 379 | // Doing so saves battery life and saves time. 380 | peripheral.discoverServices(nil) 381 | } 382 | 383 | 384 | /* 385 | Invoked when the central manager fails to create a connection with a peripheral. 386 | 387 | This method is invoked when a connection initiated via the connectPeripheral:options: method fails to complete. 388 | Because connection attempts do not time out, a failed connection usually indicates a transient issue, 389 | in which case you may attempt to connect to the peripheral again. 390 | */ 391 | func centralManager(central: CBCentralManager, didFailToConnectPeripheral peripheral: CBPeripheral, error: NSError?) { 392 | print("**** CONNECTION TO SENSOR TAG FAILED!!!") 393 | } 394 | 395 | 396 | /* 397 | Invoked when an existing connection with a peripheral is torn down. 398 | 399 | This method is invoked when a peripheral connected via the connectPeripheral:options: method is disconnected. 400 | If the disconnection was not initiated by cancelPeripheralConnection:, the cause is detailed in error. 401 | After this method is called, no more methods are invoked on the peripheral device’s CBPeripheralDelegate object. 402 | 403 | Note that when a peripheral is disconnected, all of its services, characteristics, and characteristic descriptors are invalidated. 404 | */ 405 | func centralManager(central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: NSError?) { 406 | print("**** DISCONNECTED FROM SENSOR TAG!!!") 407 | lastTemperature = 0 408 | updateBackgroundImageForTemperature(lastTemperature) 409 | circleView.hidden = true 410 | temperatureLabel.font = UIFont(name: temperatureLabelFontName, size: temperatureLabelFontSizeMessage) 411 | temperatureLabel.text = "Tap to search" 412 | humidityLabel.text = "" 413 | humidityLabel.hidden = true 414 | if error != nil { 415 | print("****** DISCONNECTION DETAILS: \(error!.localizedDescription)") 416 | } 417 | sensorTag = nil 418 | } 419 | 420 | 421 | //MARK: - CBPeripheralDelegate methods 422 | 423 | /* 424 | Invoked when you discover the peripheral’s available services. 425 | 426 | This method is invoked when your app calls the discoverServices: method. 427 | If the services of the peripheral are successfully discovered, you can access them 428 | through the peripheral’s services property. 429 | 430 | If successful, the error parameter is nil. 431 | If unsuccessful, the error parameter returns the cause of the failure. 432 | */ 433 | // When the specified services are discovered, the peripheral calls the peripheral:didDiscoverServices: method of its delegate object. 434 | func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) { 435 | if error != nil { 436 | print("ERROR DISCOVERING SERVICES: \(error?.localizedDescription)") 437 | return 438 | } 439 | 440 | // Core Bluetooth creates an array of CBService objects —- one for each service that is discovered on the peripheral. 441 | if let services = peripheral.services { 442 | for service in services { 443 | print("Discovered service \(service)") 444 | // If we found either the temperature or the humidity service, discover the characteristics for those services. 445 | if (service.UUID == CBUUID(string: Device.TemperatureServiceUUID)) || 446 | (service.UUID == CBUUID(string: Device.HumidityServiceUUID)) { 447 | peripheral.discoverCharacteristics(nil, forService: service) 448 | } 449 | } 450 | } 451 | } 452 | 453 | 454 | /* 455 | Invoked when you discover the characteristics of a specified service. 456 | 457 | If the characteristics of the specified service are successfully discovered, you can access 458 | them through the service's characteristics property. 459 | 460 | If successful, the error parameter is nil. 461 | If unsuccessful, the error parameter returns the cause of the failure. 462 | */ 463 | func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) { 464 | if error != nil { 465 | print("ERROR DISCOVERING CHARACTERISTICS: \(error?.localizedDescription)") 466 | return 467 | } 468 | 469 | if let characteristics = service.characteristics { 470 | var enableValue:UInt8 = 1 471 | let enableBytes = NSData(bytes: &enableValue, length: sizeof(UInt8)) 472 | 473 | for characteristic in characteristics { 474 | // Temperature Data Characteristic 475 | if characteristic.UUID == CBUUID(string: Device.TemperatureDataUUID) { 476 | // Enable the IR Temperature Sensor notifications 477 | temperatureCharacteristic = characteristic 478 | sensorTag?.setNotifyValue(true, forCharacteristic: characteristic) 479 | } 480 | 481 | // Temperature Configuration Characteristic 482 | if characteristic.UUID == CBUUID(string: Device.TemperatureConfig) { 483 | // Enable IR Temperature Sensor 484 | sensorTag?.writeValue(enableBytes, forCharacteristic: characteristic, type: .WithResponse) 485 | } 486 | 487 | if characteristic.UUID == CBUUID(string: Device.HumidityDataUUID) { 488 | // Enable Humidity Sensor notifications 489 | humidityCharacteristic = characteristic 490 | sensorTag?.setNotifyValue(true, forCharacteristic: characteristic) 491 | } 492 | 493 | if characteristic.UUID == CBUUID(string: Device.HumidityConfig) { 494 | // Enable Humidity Temperature Sensor 495 | sensorTag?.writeValue(enableBytes, forCharacteristic: characteristic, type: .WithResponse) 496 | } 497 | } 498 | } 499 | } 500 | 501 | 502 | /* 503 | Invoked when you retrieve a specified characteristic’s value, 504 | or when the peripheral device notifies your app that the characteristic’s value has changed. 505 | 506 | This method is invoked when your app calls the readValueForCharacteristic: method, 507 | or when the peripheral notifies your app that the value of the characteristic for 508 | which notifications and indications are enabled has changed. 509 | 510 | If successful, the error parameter is nil. 511 | If unsuccessful, the error parameter returns the cause of the failure. 512 | */ 513 | func peripheral(peripheral: CBPeripheral, didUpdateValueForCharacteristic characteristic: CBCharacteristic, error: NSError?) { 514 | if error != nil { 515 | print("ERROR ON UPDATING VALUE FOR CHARACTERISTIC: \(characteristic) - \(error?.localizedDescription)") 516 | return 517 | } 518 | 519 | // extract the data from the characteristic's value property and display the value based on the characteristic type 520 | if let dataBytes = characteristic.value { 521 | if characteristic.UUID == CBUUID(string: Device.TemperatureDataUUID) { 522 | displayTemperature(dataBytes) 523 | } else if characteristic.UUID == CBUUID(string: Device.HumidityDataUUID) { 524 | displayHumidity(dataBytes) 525 | } 526 | } 527 | } 528 | 529 | 530 | // MARK: - TI Sensor Tag Utility Methods 531 | 532 | func convertCelciusToFahrenheit(celcius:Double) -> Double { 533 | let fahrenheit = (celcius * 1.8) + Double(32) 534 | return fahrenheit 535 | } 536 | 537 | func calculateRelativeHumidity(rawH:UInt16) -> Double { 538 | // clear status bits [1..0] 539 | let clearedH = rawH & ~0x003 540 | 541 | //-- calculate relative humidity [%RH] -- 542 | // RH= -6 + 125 * SRH/2^16 543 | let relativeHumidity:Double = -6.0 + 125.0/65536 * Double(clearedH) 544 | return relativeHumidity 545 | } 546 | 547 | func calculateHumidityTemperature(rawT:UInt16) -> Double { 548 | //-- calculate temperature [deg C] -- 549 | let temp = -46.85 + 175.72/65536 * Double(rawT); 550 | return temp; 551 | } 552 | 553 | } 554 | -------------------------------------------------------------------------------- /BLETemperatureReaderSwift/README.md: -------------------------------------------------------------------------------- 1 | # BLECoffeeTemperatureSwift 2 | Bluetooth Low Energy Coffee Surface Temperature Reader in Swift! 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZeroToBLE-Part2 2 | Demonstration iOS project to accompany [Part Two](http://blog.cloudcity.io/2015/06/11/zero-to-ble-on-ios-part-two/) of the Cloud City Development Blog series, *Zero to BLE*. 3 | --------------------------------------------------------------------------------