Upgrade to Pro — share decks privately, control downloads, hide ads and more …

日曜HackでHomeKitと戯れた話

 日曜HackでHomeKitと戯れた話

API非公開の学習リモコンをHomeKit対応させた話と、HomeKitについて。

@iOS_LT #23

Tatsuya Tanaka

October 30, 2016
Tweet

More Decks by Tatsuya Tanaka

Other Decks in Technology

Transcript

  1. γεςϜߏ੒ • RM mini 3 (ࠇ౾) • Node.js • homebridge

    • iPhone 6s (iOS10) ࠇ౾ HomeKit API UDP ੺֎ઢ TV
  2. Primary Homeͷऔಘ // 管理クラスの取得 let homeManager = HMHomeManager() homeManager.delegate =

    self // MARK: - HMHomeManagerDelegate func homeManagerDidUpdateHomes(_ manager: HMHomeManager) { // Primary Homeの取得 let home = manager.primaryHome } ↓͜ΕΛऔಘ
  3. Room / Accessoryͷऔಘ let home = manager.primaryHome let room =

    home?.rooms[0] let accessory = room?.accessories[0] // これでも可 let accessory = home?.accessories[0]
  4. Characteristicͷऔಘ for service in accessory.services { switch service.serviceType { case

    HMServiceTypeSwitch: for chara in service.characteristics { switch chara.characteristicType { case HMCharacteristicTypePowerState: // 電源スイッチの取得 chara default: () } } default: () } } Accessory Service • TV • Ϙλϯ Characteristic • ిݯ • ϛϡʔτ • …
  5. ஋ͷऔಘ Accessory Service • TV • Ϙλϯ Characteristic switch chara.characteristicType

    { case HMCharacteristicTypePowerState: // 値の取得 chara.readValue { error in let isOn = chara.value as? Bool } // 値の設定 chara.writeValue(true) { error in print(error) } default: () } • ిݯ • ϛϡʔτ • …