├── .gitignore ├── 4-1_Scan └── BLEScanExample │ ├── BLEScanExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEScanExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 4-2_Connect └── BLEConnectExample │ ├── BLEConnectExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEConnectExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 4-3_DiscoverServices └── BLEDiscoverServicesExample │ ├── BLEDiscoverServicesExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEDiscoverServicesExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 4-4_Read └── BLEReadExample │ ├── BLEReadExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEReadExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 4-5_Write └── BLEWriteExample │ ├── BLEWriteExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEWriteExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 4-6_Notify └── BLENotifyExample │ ├── BLENotifyExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLENotifyExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-1_Advertise └── BLEAdvertiseExample │ ├── BLEAdvertiseExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEAdvertiseExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-2_AddService └── BLEAddServiceExample │ ├── BLEAddServiceExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEAddServiceExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-3_AdvertiseService └── BLEAdvertiseServiceExample │ ├── BLEAdvertiseServiceExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEAdvertiseServiceExample │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-4_ReadRequest ├── BLEReadErrorExamplePeripheral │ ├── BLEReadExamplePeripheral.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ ├── BLEReadExamplePeripheral.xccheckout │ │ │ └── IDEWorkspaceChecks.plist │ └── BLEReadExamplePeripheral │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m ├── BLEReadExampleCentral │ ├── BLEReadExampleCentral.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ ├── BLEReadExampleCentral.xccheckout │ │ │ └── IDEWorkspaceChecks.plist │ └── BLEReadExampleCentral │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m └── BLEReadExamplePeripheral │ ├── BLEReadExamplePeripheral.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEReadExamplePeripheral │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-5_WriteRequest ├── BLEWriteExampleCentral │ ├── BLEWriteExampleCentral.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ ├── BLEWriteExampleCentral.xccheckout │ │ │ └── IDEWorkspaceChecks.plist │ └── BLEWriteExampleCentral │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m └── BLEWriteExamplePeripheral │ ├── BLEWriteExamplePeripheral.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLEWriteExamplePeripheral │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── 5-6_Notify ├── BLENotifyExampleCentral │ ├── BLENotifyExampleCentral.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ ├── BLENotifyExampleCentral.xccheckout │ │ │ └── IDEWorkspaceChecks.plist │ └── BLENotifyExampleCentral │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m └── BLENotifyExamplePeripheral │ ├── BLENotifyExamplePeripheral.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── BLENotifyExamplePeripheral │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── Common ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ └── Icon.png │ ├── Contents.json │ └── bluetooth_book.imageset │ │ ├── Contents.json │ │ └── bluetooth_book.pdf ├── BLEAppearance.h ├── BLECommonButton.h └── BLECommonButton.m ├── 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 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEScanExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEScanExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /4-1_Scan/BLEScanExample/BLEScanExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEScanExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class ViewController: UIViewController { 13 | 14 | var isScanning = false 15 | var centralManager: CBCentralManager! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // セントラルマネージャ初期化 21 | centralManager = CBCentralManager(delegate: self, queue: nil) 22 | } 23 | 24 | // MARK: - Actions 25 | 26 | @IBAction func scanButtonTapped(_ sender: UIButton) { 27 | if !isScanning { 28 | isScanning = true 29 | sender.setTitle("STOP SCAN", for: .normal) 30 | 31 | centralManager.scanForPeripherals(withServices: nil) 32 | } else { 33 | centralManager.stopScan() 34 | 35 | sender.setTitle("START SCAN", for: .normal) 36 | isScanning = false 37 | } 38 | } 39 | } 40 | 41 | extension ViewController: CBCentralManagerDelegate { 42 | 43 | // セントラルマネージャの状態が変化すると呼ばれる 44 | func centralManagerDidUpdateState(_ central: CBCentralManager) { 45 | print("state: \(central.state)") 46 | } 47 | 48 | // 周辺にあるデバイスを発見すると呼ばれる 49 | func centralManager(_ central: CBCentralManager, 50 | didDiscover peripheral: CBPeripheral, 51 | advertisementData: [String : Any], 52 | rssi RSSI: NSNumber) 53 | { 54 | print("発見したBLEデバイス: \(peripheral)") 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEConnectExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/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 | 43 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEConnectExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /4-2_Connect/BLEConnectExample/BLEConnectExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEScanExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class ViewController: UIViewController { 13 | 14 | var isScanning = false 15 | var centralManager: CBCentralManager! 16 | var peripheral: CBPeripheral! 17 | var peripherals: [CBPeripheral] = [] 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | // セントラルマネージャ初期化 23 | centralManager = CBCentralManager(delegate: self, queue: nil) 24 | } 25 | 26 | // MARK: - Actions 27 | 28 | @IBAction func scanButtonTapped(_ sender: UIButton) { 29 | if !isScanning { 30 | isScanning = true 31 | sender.setTitle("STOP SCAN", for: .normal) 32 | 33 | centralManager.scanForPeripherals(withServices: nil) 34 | } else { 35 | centralManager.stopScan() 36 | 37 | sender.setTitle("START SCAN", for: .normal) 38 | isScanning = false 39 | } 40 | } 41 | } 42 | 43 | extension ViewController: CBCentralManagerDelegate { 44 | 45 | // セントラルマネージャの状態が変化すると呼ばれる 46 | func centralManagerDidUpdateState(_ central: CBCentralManager) { 47 | print("state: \(central.state)") 48 | } 49 | 50 | // 周辺にあるデバイスを発見すると呼ばれる 51 | func centralManager(_ central: CBCentralManager, 52 | didDiscover peripheral: CBPeripheral, 53 | advertisementData: [String : Any], 54 | rssi RSSI: NSNumber) 55 | { 56 | print("発見したBLEデバイス: \(peripheral)") 57 | 58 | self.peripheral = peripheral 59 | peripherals.append(peripheral) 60 | 61 | centralManager.connect(peripheral) 62 | } 63 | 64 | // ペリフェラルへの接続が成功すると呼ばれる 65 | func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { 66 | print("接続成功!") 67 | } 68 | 69 | // ペリフェラルへの接続が失敗すると呼ばれる 70 | func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) { 71 | print("接続失敗・・・") 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEDiscoverServicesExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEDiscoverServicesExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /4-3_DiscoverServices/BLEDiscoverServicesExample/BLEDiscoverServicesExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEScanExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class ViewController: UIViewController { 13 | var isScanning = false 14 | var centralManager: CBCentralManager! 15 | var peripheral: CBPeripheral! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // セントラルマネージャ初期化 21 | centralManager = CBCentralManager(delegate: self, queue: nil) 22 | } 23 | 24 | // MARK: - Actions 25 | 26 | @IBAction func scanButtonTapped(_ sender: UIButton) { 27 | 28 | if !isScanning { 29 | isScanning = true 30 | sender.setTitle("STOP SCAN", for: .normal) 31 | 32 | centralManager.scanForPeripherals(withServices: nil) 33 | } else { 34 | centralManager.stopScan() 35 | 36 | sender.setTitle("START SCAN", for: .normal) 37 | isScanning = false 38 | } 39 | } 40 | } 41 | 42 | extension ViewController: CBCentralManagerDelegate { 43 | // セントラルマネージャの状態が変化すると呼ばれる 44 | func centralManagerDidUpdateState(_ central: CBCentralManager) { 45 | print("state: \(central.state)") 46 | } 47 | 48 | // 周辺にあるデバイスを発見すると呼ばれる 49 | func centralManager(_ central: CBCentralManager, 50 | didDiscover peripheral: CBPeripheral, 51 | advertisementData: [String : Any], 52 | rssi RSSI: NSNumber) 53 | { 54 | print("発見したBLEデバイス: \(peripheral)") 55 | 56 | if let name = peripheral.name, name.hasPrefix("konashi") { 57 | self.peripheral = peripheral 58 | 59 | centralManager.connect(peripheral) 60 | centralManager.stopScan() 61 | } 62 | } 63 | 64 | // ペリフェラルへの接続が成功すると呼ばれる 65 | func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { 66 | print("接続成功!") 67 | 68 | // サービス探索結果を受け取るためにデリゲートをセット 69 | peripheral.delegate = self 70 | 71 | // サービス探索開始 72 | peripheral.discoverServices(nil) 73 | } 74 | 75 | // ペリフェラルへの接続が失敗すると呼ばれる 76 | func centralManager(_ central: CBCentralManager, 77 | didFailToConnect peripheral: CBPeripheral, 78 | error: Error?) 79 | { 80 | print("接続失敗・・・") 81 | } 82 | } 83 | 84 | extension ViewController: CBPeripheralDelegate { 85 | // サービス発見時に呼ばれる 86 | func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { 87 | if let error = error { 88 | print("エラー: \(error)") 89 | return 90 | } 91 | 92 | guard let services = peripheral.services, services.count > 0 else { 93 | print("no services") 94 | return 95 | } 96 | print("\(services.count) 個のサービスを発見! \(services)") 97 | 98 | for service in services { 99 | // キャラクタリスティック探索開始 100 | peripheral.discoverCharacteristics(nil, for: service) 101 | } 102 | } 103 | 104 | // キャラクタリスティック発見時に呼ばれる 105 | func peripheral(_ peripheral: CBPeripheral, 106 | didDiscoverCharacteristicsFor service: CBService, 107 | error: Error?) 108 | { 109 | if let error = error { 110 | print("エラー: \(error)") 111 | return 112 | } 113 | 114 | if let characteristics = service.characteristics { 115 | print("\(characteristics.count) 個のキャラクタリスティックを発見! \(characteristics)") 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEReadExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-4_Read/BLEReadExample/BLEReadExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEReadExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEWriteExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-5_Write/BLEWriteExample/BLEWriteExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEWriteExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLENotifyExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4-6_Notify/BLENotifyExample/BLENotifyExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLENotifyExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEAdvertiseExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEAdvertiseExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-1_Advertise/BLEAdvertiseExample/BLEAdvertiseExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEAdvertiseExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet var advertiseBtn: UIButton! 15 | private var peripheralManager: CBPeripheralManager! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // ペリフェラルマネージャ初期化 21 | peripheralManager = CBPeripheralManager( 22 | delegate: self, 23 | queue: nil, 24 | options: nil) 25 | } 26 | 27 | // MARK: - Private 28 | 29 | private func startAdvertise() { 30 | // アドバタイズメントデータを作成する 31 | let advertisementData = [CBAdvertisementDataLocalNameKey: "Test Device"] 32 | 33 | // アドバタイズ開始 34 | peripheralManager.startAdvertising(advertisementData) 35 | 36 | advertiseBtn.setTitle("STOP ADVERTISING", for: .normal) 37 | } 38 | 39 | private func stopAdvertise () { 40 | // アドバタイズ停止 41 | peripheralManager.stopAdvertising() 42 | 43 | advertiseBtn.setTitle("START ADVERTISING", for: .normal) 44 | } 45 | 46 | // MARK: - Action 47 | 48 | @IBAction func advertiseButtonTapped(_ sender: UIButton) { 49 | if !peripheralManager.isAdvertising { 50 | startAdvertise() 51 | } else { 52 | stopAdvertise() 53 | } 54 | } 55 | } 56 | 57 | extension ViewController: CBPeripheralManagerDelegate { 58 | 59 | // ペリフェラルマネージャの状態が変化すると呼ばれる 60 | func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { 61 | print("state: \(peripheral.state)") 62 | 63 | switch peripheral.state { 64 | case .poweredOn: 65 | // アドバタイズ開始 66 | startAdvertise() 67 | default: 68 | break 69 | } 70 | } 71 | 72 | // アドバタイズ開始処理が完了すると呼ばれる 73 | func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { 74 | if let error = error { 75 | print("アドバタイズ開始失敗! error: \(error)") 76 | return 77 | } 78 | print("アドバタイズ開始成功!") 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEAddServiceExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEAddServiceExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-2_AddService/BLEAddServiceExample/BLEAddServiceExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEAdvertiseExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet var advertiseBtn: UIButton! 15 | private var peripheralManager: CBPeripheralManager! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // ペリフェラルマネージャ初期化 21 | peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) 22 | } 23 | 24 | // MARK: - Private 25 | 26 | private func publishservice () { 27 | 28 | // サービスを作成 29 | let serviceUUID = CBUUID(string: "0000") 30 | let service = CBMutableService(type: serviceUUID, primary: true) 31 | 32 | // キャラクタリスティックを作成 33 | let characteristicUUID = CBUUID(string: "0001") 34 | let characteristic = CBMutableCharacteristic( 35 | type: characteristicUUID, 36 | properties: .read, 37 | value: nil, 38 | permissions: .readable) 39 | 40 | // キャラクタリスティックをサービスにセット 41 | service.characteristics = [characteristic] 42 | 43 | // サービスを追加 44 | peripheralManager.add(service) 45 | } 46 | 47 | private func startAdvertise() { 48 | // アドバタイズメントデータを作成する 49 | let advertisementData = [CBAdvertisementDataLocalNameKey: "Test Device"] 50 | 51 | // アドバタイズ開始 52 | peripheralManager.startAdvertising(advertisementData) 53 | 54 | advertiseBtn.setTitle("STOP ADVERTISING", for: .normal) 55 | } 56 | 57 | func stopAdvertise () { 58 | // アドバタイズ停止 59 | peripheralManager.stopAdvertising() 60 | 61 | advertiseBtn.setTitle("START ADVERTISING", for: .normal) 62 | } 63 | 64 | // MARK: - Action 65 | 66 | @IBAction func advertiseButtonTapped(_ sender: UIButton) { 67 | 68 | if !peripheralManager.isAdvertising { 69 | startAdvertise() 70 | } else { 71 | stopAdvertise() 72 | } 73 | } 74 | } 75 | 76 | extension ViewController: CBPeripheralManagerDelegate { 77 | 78 | // ペリフェラルマネージャの状態が変化すると呼ばれる 79 | func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { 80 | print("state: \(peripheral.state)") 81 | 82 | switch peripheral.state { 83 | case .poweredOn: 84 | // サービス登録開始 85 | publishservice() 86 | default: 87 | break 88 | } 89 | } 90 | 91 | // サービス追加処理が完了すると呼ばれる 92 | func peripheralManager(_ peripheral: CBPeripheralManager, 93 | didAdd service: CBService, 94 | error: Error?) 95 | { 96 | if let error = error { 97 | print("サービス追加失敗! error: \(error)") 98 | return 99 | } 100 | print("サービス追加成功!") 101 | 102 | // アドバタイズ開始 103 | startAdvertise() 104 | } 105 | 106 | // アドバタイズ開始処理が完了すると呼ばれる 107 | func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, 108 | error: Error?) 109 | { 110 | if let error = error { 111 | print("アドバタイズ開始失敗! error: \(error)") 112 | return 113 | } 114 | print("アドバタイズ開始成功!") 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEAdvertiseServiceExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/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 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEAdvertiseServiceExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-3_AdvertiseService/BLEAdvertiseServiceExample/BLEAdvertiseServiceExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BLEAdvertiseExample 4 | // 5 | // Created by Shuichi Tsutsumi on 2014/12/12. 6 | // Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreBluetooth 11 | 12 | 13 | class ViewController: UIViewController { 14 | 15 | @IBOutlet var advertiseBtn: UIButton! 16 | private var peripheralManager: CBPeripheralManager! 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | // ペリフェラルマネージャ初期化 22 | peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) 23 | } 24 | 25 | // MARK: - Private 26 | 27 | private func publishservice () { 28 | 29 | // サービスを作成 30 | let serviceUUID = CBUUID(string: "0000") 31 | let service = CBMutableService(type: serviceUUID, primary: true) 32 | 33 | // キャラクタリスティックを作成 34 | let characteristicUUID = CBUUID(string: "0001") 35 | let properties: CBCharacteristicProperties = [.notify, .read, .read] 36 | let permissions: CBAttributePermissions = [.readable, .writeable] 37 | let characteristic = CBMutableCharacteristic(type: characteristicUUID, properties: properties, value: nil, permissions: permissions) 38 | 39 | // キャラクタリスティックをサービスにセット 40 | service.characteristics = [characteristic] 41 | 42 | // サービスを Peripheral Manager にセット 43 | peripheralManager.add(service) 44 | } 45 | 46 | private func startAdvertise() { 47 | 48 | // アドバタイズしたいサービスのUUIDのリスト 49 | let serviceUUIDs = [CBUUID(string: "0000")] 50 | 51 | // アドバタイズメントデータを作成する 52 | let advertisementData: [String: Any] = [ 53 | CBAdvertisementDataLocalNameKey: "Test Device", 54 | CBAdvertisementDataServiceUUIDsKey: serviceUUIDs 55 | ] 56 | 57 | // アドバタイズ開始 58 | peripheralManager.startAdvertising(advertisementData) 59 | 60 | advertiseBtn.setTitle("STOP ADVERTISING", for: .normal) 61 | } 62 | 63 | private func stopAdvertise () { 64 | // アドバタイズ停止 65 | peripheralManager.stopAdvertising() 66 | 67 | advertiseBtn.setTitle("START ADVERTISING", for: .normal) 68 | } 69 | 70 | // MARK: - Action 71 | 72 | @IBAction func advertiseButtonTapped(_ sender: UIButton) { 73 | if (!peripheralManager.isAdvertising) { 74 | startAdvertise() 75 | } else { 76 | stopAdvertise() 77 | } 78 | } 79 | } 80 | 81 | extension ViewController: CBPeripheralManagerDelegate { 82 | // ペリフェラルマネージャの状態が変化すると呼ばれる 83 | func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { 84 | print("state: \(peripheral.state)") 85 | 86 | switch peripheral.state { 87 | case .poweredOn: 88 | // サービス登録開始 89 | publishservice() 90 | default: 91 | break 92 | } 93 | } 94 | 95 | // サービス追加処理が完了すると呼ばれる 96 | func peripheralManager(_ peripheral: CBPeripheralManager, 97 | didAdd service: CBService, 98 | error: Error?) 99 | { 100 | if let error = error { 101 | print("サービス追加失敗! error: \(error)") 102 | return 103 | } 104 | print("サービス追加成功!") 105 | 106 | // アドバタイズ開始 107 | startAdvertise() 108 | } 109 | 110 | // アドバタイズ開始処理が完了すると呼ばれる 111 | func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { 112 | if let error = error { 113 | print("アドバタイズ開始失敗! error: \(error)") 114 | return 115 | } 116 | print("アドバタイズ開始成功!") 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral.xcodeproj/project.xcworkspace/xcshareddata/BLEReadExamplePeripheral.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 7A4F9378-6E6E-4446-B8EF-7534784C573A 9 | IDESourceControlProjectName 10 | BLEReadExamplePeripheral 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 14 | github.com:shu223/BLEBook.git 15 | 16 | IDESourceControlProjectPath 17 | Sample/Part2/5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 21 | ../../../../../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:shu223/BLEBook.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 36 | IDESourceControlWCCName 37 | BLEBook 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSBluetoothAlwaysUsageDescription 26 | {Bluetoothの利用許可を求める文言} 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarStyle 36 | UIStatusBarStyleLightContent 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadErrorExamplePeripheral/BLEReadExamplePeripheral/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/BLEReadExampleCentral.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 9501B1B7-D5C0-4AE3-9EE1-0C1FD0946F3B 9 | IDESourceControlProjectName 10 | BLEReadExampleCentral 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 14 | github.com:shu223/BLEBook.git 15 | 16 | IDESourceControlProjectPath 17 | Sample/Part2/5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 21 | ../../../../../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:shu223/BLEBook.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 36 | IDESourceControlWCCName 37 | BLEBook 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSBluetoothAlwaysUsageDescription 26 | {Bluetoothの利用許可を求める文言} 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarStyle 36 | UIStatusBarStyleLightContent 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExampleCentral/BLEReadExampleCentral/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEReadExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral/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 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-4_ReadRequest/BLEReadExamplePeripheral/BLEReadExamplePeripheral/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEReadExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/BLEWriteExampleCentral.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | D547A400-44C3-4424-9732-CE038957CBA2 9 | IDESourceControlProjectName 10 | BLEWriteExampleCentral 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 14 | github.com:shu223/BLEBook.git 15 | 16 | IDESourceControlProjectPath 17 | Sample/Part2/5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 21 | ../../../../../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:shu223/BLEBook.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 36 | IDESourceControlWCCName 37 | BLEBook 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSBluetoothAlwaysUsageDescription 26 | {Bluetoothの利用許可を求める文言} 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarStyle 36 | UIStatusBarStyleLightContent 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExampleCentral/BLEWriteExampleCentral/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLEWriteExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-5_WriteRequest/BLEWriteExamplePeripheral/BLEWriteExamplePeripheral/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLEWriteExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/BLENotifyExampleCentral.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | A1B8D09D-C1F3-410B-B702-6010F44C5829 9 | IDESourceControlProjectName 10 | BLENotifyExampleCentral 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 14 | github.com:shu223/BLEBook.git 15 | 16 | IDESourceControlProjectPath 17 | Sample/Part2/5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 21 | ../../../../../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:shu223/BLEBook.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 996D8ED54A06D2612FCDCD9182B0F0B291CCBC66 36 | IDESourceControlWCCName 37 | BLEBook 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSBluetoothAlwaysUsageDescription 26 | {Bluetoothの利用許可を求める文言} 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarStyle 36 | UIStatusBarStyleLightContent 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExampleCentral/BLENotifyExampleCentral/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BLESample 4 | // 5 | // Created by Shuichi Tsutsumi on 10/9/14. 6 | // Copyright (c) 2014 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BLENotifyExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral/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 | 43 | 44 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /5-6_Notify/BLENotifyExamplePeripheral/BLENotifyExamplePeripheral/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // BLENotifyExamplePeripheral 4 | // 5 | // Created by Shuichi Tsutsumi on 2023/06/02. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Common/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "193", 9 | "green" : "116", 10 | "red" : "0" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Common/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "Icon.png", 5 | "idiom" : "universal", 6 | "platform" : "ios", 7 | "size" : "1024x1024" 8 | } 9 | ], 10 | "info" : { 11 | "author" : "xcode", 12 | "version" : 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Common/Assets.xcassets/AppIcon.appiconset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shu223/iOS-BLE-Tutorials/ca72a09e05bb18dda1c96200ee70ad3c28c5b210/Common/Assets.xcassets/AppIcon.appiconset/Icon.png -------------------------------------------------------------------------------- /Common/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Common/Assets.xcassets/bluetooth_book.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "bluetooth_book.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Common/Assets.xcassets/bluetooth_book.imageset/bluetooth_book.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shu223/iOS-BLE-Tutorials/ca72a09e05bb18dda1c96200ee70ad3c28c5b210/Common/Assets.xcassets/bluetooth_book.imageset/bluetooth_book.pdf -------------------------------------------------------------------------------- /Common/BLEAppearance.h: -------------------------------------------------------------------------------- 1 | // 2 | // BLEAppearance.h 3 | // 4 | // Created by Shuichi Tsutsumi on 2015/01/25. 5 | // Copyright (c) 2015年 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | #define BLE_MAIN_COLOR [UIColor colorWithRed:5./255. green:111./255. blue:184./255. alpha:1.] 9 | #define BLE_HIGHLIGHTED_COLOR [UIColor colorWithRed:5./255. green:111./255. blue:255./255. alpha:1.] 10 | -------------------------------------------------------------------------------- /Common/BLECommonButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // BLECommonButton.h 3 | // 4 | // Created by Shuichi Tsutsumi on 2015/01/25. 5 | // Copyright (c) 2015 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BLECommonButton : UIButton 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Common/BLECommonButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // BLECommonButton.m 3 | // 4 | // Created by Shuichi Tsutsumi on 2015/01/25. 5 | // Copyright (c) 2015 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | #import "BLECommonButton.h" 9 | #import "BLEAppearance.h" 10 | 11 | 12 | @interface UIImage (TTMExtentions) 13 | 14 | + (UIImage *)imageOfSize:(CGSize)size color:(UIColor *)color; 15 | 16 | @end 17 | 18 | 19 | @implementation UIImage (TTMExtentions) 20 | 21 | + (UIImage *)imageOfSize:(CGSize)size color:(UIColor *)color { 22 | 23 | UIGraphicsBeginImageContext(size); 24 | CGContextRef currentContext = UIGraphicsGetCurrentContext(); 25 | CGRect fillRect = CGRectMake(0,0,size.width,size.height); 26 | CGContextSetFillColorWithColor(currentContext, color.CGColor); 27 | CGContextFillRect(currentContext, fillRect); 28 | 29 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 30 | UIGraphicsEndImageContext(); 31 | 32 | return image; 33 | } 34 | 35 | @end 36 | 37 | 38 | @implementation BLECommonButton 39 | 40 | - (void)awakeFromNib { 41 | 42 | [super awakeFromNib]; 43 | 44 | self.backgroundColor = BLE_MAIN_COLOR; 45 | self.layer.borderColor = [UIColor whiteColor].CGColor; 46 | self.layer.borderWidth = 0.5; 47 | self.layer.cornerRadius = 4.0; 48 | self.layer.masksToBounds = YES; 49 | 50 | UIImage *bgImage1 = [UIImage imageOfSize:CGSizeMake(1, 1) color:BLE_MAIN_COLOR]; 51 | UIImage *bgImage2 = [UIImage imageOfSize:CGSizeMake(1, 1) color:[UIColor whiteColor]]; 52 | 53 | [self setBackgroundImage:bgImage1 forState:UIControlStateNormal]; 54 | [self setBackgroundImage:bgImage2 forState:UIControlStateHighlighted]; 55 | 56 | [self setTitleColor:BLE_HIGHLIGHTED_COLOR forState:UIControlStateHighlighted]; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 shu223 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 | # iOS-BLE-Tutorials 2 | 3 | Step-by-step examples of Core Bluetooth written in Swift. 4 | 5 | These are basically the sample codes for a book below, 6 | 7 |
iOS×BLE Core Bluetooth Programming
Shuichi Tsutsumi, Reo Matsumura
8 | 9 | however, they also provide excellent step-by-step tutorials for Core Bluetooth **even WITHOUT** owning the book. 10 | 11 | ## How to use 12 | 13 | ### If you have the book 14 | 15 | 詳細については書籍の該当する節(フォルダ名の先頭についている数字が書籍内の節番号に相当します)をご参照ください。 16 | 17 | ### If you don't have the book 18 | 19 | Please follow along with the example projects and the comments in the code. They will help you understand the basics of Core Bluetooth. 20 | 21 | なお、書籍の発行は2015年ですが、BLEの基礎概念は変わらないので、現在でも大いに参考になると思います。電子書籍版は[こちら](https://tatsu-zine.com/books/ios-ble-core-bluetooth-programming)で購入可能です。 22 | 23 | ### [note] 24 | 25 | Please do not move the `Common` folder as it is referenced in all projects. 26 | 27 | --------------------------------------------------------------------------------