Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
HomeKit 2020
Search
tokorom
September 19, 2020
Programming
7
2.4k
HomeKit 2020
iOSDC Japan 2020 9/19 TrackA のセッション
tokorom
September 19, 2020
Tweet
Share
More Decks by tokorom
See All by tokorom
続・SharePlayの歴史と進化 iOS18とApple Vision Proにおける新展開
tokorom
3
240
SharePlayの歴史と進化 そしてvisionOSへ (iOSDC 2023)
tokorom
2
830
5分でSharePlay入門
tokorom
2
1.4k
Advanced Segue 2019年のSegue事情
tokorom
9
5.7k
tvOSアプリUIの勘所
tokorom
1
1.9k
カッコ悪くリアクティブじゃダメですか?
tokorom
7
12k
古き良きsendAction (in potatotips #26)
tokorom
1
3.5k
画面遷移と私(iOS)
tokorom
4
3.7k
長生きするために心臓に悪いリリースはもうやめよう
tokorom
21
33k
Other Decks in Programming
See All in Programming
プログラマのための音楽入門
cheebow
5
560
開発を加速する共有Swift Package実践
elmetal
PRO
0
370
Swift Concurrencyとレースコンディション
objectiveaudio
1
400
XStateでReactに秩序を与えたい
gizm000
0
520
Core_Audio徹底解剖.pdf
entaku
3
100
現代のVueとTypeScript - 型安全の活用術
minako__ph
4
3.2k
Amebaチョイス立ち上げの裏側 ~依存システムとの闘い~
daichi_igarashi
0
220
GraphQL あるいは React における自律的なデータ取得について
quramy
9
2.5k
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
2
530
状態管理ライブラリZustandの導入から運用まで
k1tikurisu
2
320
null or undefined
susisu
22
6k
全力の跳躍を捉える計測アプリを作る
ogijun2018
1
1.3k
Featured
See All Featured
Embracing the Ebb and Flow
colly
83
4.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
248
20k
Fontdeck: Realign not Redesign
paulrobertlloyd
80
5.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
28
1.6k
The Cult of Friendly URLs
andyhume
76
5.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
45
4.8k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Rails Girls Zürich Keynote
gr2m
93
13k
Intergalactic Javascript Robots from Outer Space
tanoku
268
26k
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
Creatively Recalculating Your Daily Design Routine
revolveconf
215
12k
Transcript
ॴ༑ଠ:VUB5PLPSP J04UW04"QQ1SPHSBNNFS )PNF,JU J04%$+BQBO
@tokorom tokorom Spinners Inc. ॴ ༑ଠ / Yuta Tokoro
)PNF,JU֓ཁ )PNF,JUͱ
)PNF,JU֓ཁ )PNF,JUશମ૾ w J1IPOFͳͲͷ"QQMF͔Β༷ʑͳσόΠε Λཧɾίϯτϩʔϧ͢ΔͨΊͷΈ )PNF,JU
)PNF,JU֓ཁ )PNF,JU'SBNFXPSL w αʔυύʔςΟΞϓϦ͕ରԠΛίϯτ ϩʔϧ͢ΔͨΊͷ'SBNFXPSL )PNF,JU 'SBNFXPSL
)PNF,JU֓ཁ )PNF,JU"%, w )PNF,JUʹରԠσόΠεΛ։ൃ͢ΔͨΊͷΩ οτ )PNF,JU "%,
)PNF,JU֓ཁ )"1 w "QQMFͱ)PNF,JUରԠσόΠε͕૬ޓʹ ௨৴͢ΔͨΊͷϓϩτίϧ )PNF,JU "DDFTTPSZ 1SPUPDPM )"1
"HFOEB w )PNF,JU'SBNFXPSLͬ͘͟Γೖ w )PNF,JUͷ#SJEHFʹ͍ͭͯ w )PNFCSJEHFͰ)PNF,JUະରԠΛ)PNF,JUରԠ w )PNF,JU"%,Ͱ࡞Δࣗ࡞ΞΫηαϦ
"HFOEB w )PNF,JU'SBNFXPSLͬ͘͟Γೖ w )PNF,JUͷ#SJEHFʹ͍ͭͯ w )PNFCSJEHFͰ)PNF,JUະରԠΛ)PNF,JUରԠ w )PNF,JU"%,Ͱ࡞Δࣗ࡞ΞΫηαϦ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ )PNF,JU'SBNFXPSLͰͰ͖Δ͜ͱ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ )PNF,JU'SBNFXPSLͰͰ͖Δ͜ͱ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ )PNF,JU'SBNFXPSLͰͰ͖Δ͜ͱ w ϗʔϜϧʔϜͳͲͷάϧʔϐϯάͷཧ w σόΠεͷཧͱૢ࡞ w σόΠεΛҰʹૢ࡞͢Δγʔϯͷཧ w ΦʔτϝʔγϣϯͷͨΊͷτϦΨʔͷཧ
w ϗʔϜʹΞΫηεͰ͖ΔϢʔβʔͷཧ w ϗʔϜσόΠεͷมߋݕ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ ཧཁૉͷߏ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ )PNF,JUͷߏ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ ిٿΛ౮ͤ͞Δίʔυ let power = home .servicesWithTypes([HMServiceTypeLightbulb])? .first? .characteristics .filter
{ $0.characteristicType == HMCharacteristicTypePowerState } .first power.writeValue(true) { error in }
)PNF,JU'SBNFXPSLͬ͘͟Γೖ αϙʔτ͍ͯ͠ΔΩϟϥΫλʔ let power = home .servicesWithTypes([HMServiceTypeLightbulb])? .first? .characteristics .filter
{ $0.characteristicType == HMCharacteristicTypePowerState } .first power.writeValue(true) { error in }
)PNF,JU'SBNFXPSLͬ͘͟Γೖ αϙʔτ͍ͯ͠ΔΩϟϥΫλʔ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ Ӆ͠ΩϟϥΫλʔΛࢀর͢Δ &MHBUP&WF8FBUIFS8JSFMFTT0VUEPPS4FOTPS
)PNF,JU'SBNFXPSLͬ͘͟Γೖ Ӆ͠ΩϟϥΫλʔΛࢀর͢Δ w ؾԹ w ࣪ w ؾѹ)PNF,JUະαϙʔτͷΩϟϥΫλʔʂ
)PNF,JU'SBNFXPSLͬ͘͟Γೖ Ӆ͠ΩϟϥΫλʔΛࢀর͢Δ let power = home .servicesWithTypes([HMServiceTypeLightbulb])? .first? .characteristics .filter
{ $0.characteristicType == HMCharacteristicTypePowerState } .first power.writeValue(true) { error in }
)PNF,JU'SBNFXPSLͬ͘͟Γೖ Ӆ͠ΩϟϥΫλʔΛࢀর͢Δ let airPressure = home .servicesWithTypes(["E863F00A-079E-48FF-8F27-9C2605A29F52"])? .first? .characteristics .filter
{ $0.characteristicType == "E863F10F-079E-48FF-8F27-9C2605A29F52" } .first airPressure.readValue { error in let value = airPressure.value as? Float }
)PNF,JU'SBNFXPSLͬ͘͟Γೖ Ӆ͠ΩϟϥΫλʔΛࢀর͢Δ for characteristic in service.characteristics { print("ID: \(characteristic.characteristicType)”) print("આ໌:
\(characteristic.metadata?.manufacturerDescription ?? "")") }
)PNF,JU'SBNFXPSLͬ͘͟Γೖ ).$BNFSB7JFX
)PNF,JUͰͰ͖Δ͜ͱ۩ମྫ ଞϓϥοτϑΥʔϜΑΓࡉ͔ͳઃఆ w ΫϦεϚεϥΠτΛʮͷೖʯʹ౮͢Δ w Ոʹ୭͍ͳ͘ͳͬͨΒશͯͷిؾΛফ౮ͯ͠ώʔλʔΛࢭΊΔ w ࣗಈ౮ͨ͠ϥΠτΛඵޙʹফ౮͢Δ w தͰτΠϨ͕े໌Δ͚Εࣗಈ౮͠ͳ͍
"HFOEB w )PNF,JU'SBNFXPSLͬ͘͟Γೖ w )PNF,JUͷ#SJEHFʹ͍ͭͯ w )PNFCSJEHFͰ)PNF,JUະରԠΛ)PNF,JUରԠ w )PNF,JU"%,Ͱ࡞Δࣗ࡞ΞΫηαϦ
)PNF,JUͷ#SJEHFʹ͍ͭͯ )VFͷྫ
)PNF,JUͷ#SJEHFʹ͍ͭͯ )VFͷྫ )PNF,JUະରԠʂʁ
)PNF,JUͷ#SJEHFʹ͍ͭͯ )VFͷྫ )VF#SJEHF
)PNF,JUͷ#SJEHFʹ͍ͭͯ )VFͷྫ )VF#SJEHF
)PNF,JUͷ#SJEHFʹ͍ͭͯ )PNFCSJEHF IUUQTIPNFCSJEHFJP
)PNF,JUͷ#SJEHFʹ͍ͭͯ )VFͷྫ )PNFCSJEHF " # $ %
"HFOEB w )PNF,JU'SBNFXPSLͬ͘͟Γೖ w )PNF,JUͷ#SJEHFʹ͍ͭͯ w )PNFCSJEHFͰ)PNF,JUະରԠΛ)PNF,JUରԠ w )PNF,JU"%,Ͱ࡞Δࣗ࡞ΞΫηαϦ
)PNFCSJEHF ରԠσόΠεͷ۩ମྫ ϧϯό #SPBEMJOL3.NJOJ ʢ֎ઢϦϞίϯʣ 4&4".& ʢεϚʔτϩοΫʣ Χϝϥ
)PNFCSJEHF ࣗͰ)PNFCSJEHFΛ͏ʹ " # $ %
)PNFCSJEHF ࣗͰ)PNFCSJEHFΛ͏ʹ " # $ % IUUQTIPNFCSJEHFJP
)PNFCSJEHF )PNFCSJEHFΛ)PNFʹՃ
)PNFCSJEHF ϓϥάΠϯΛࣗ࡞ IUUQTHJUIVCDPNIPNFCSJEHFIPNFCSJEHFQMVHJOUFNQMBUF
"HFOEB w )PNF,JU'SBNFXPSLͬ͘͟Γೖ w )PNF,JUͷ#SJEHFʹ͍ͭͯ w )PNFCSJEHFͰ)PNF,JUະରԠΛ)PNF,JUରԠ w )PNF,JU"%,Ͱ࡞Δࣗ࡞ΞΫηαϦ
)PNF,JU"%, ֓ཁ w )PNF,JU"DDFTTPSZ%FWFMPQNFOU,JU w ΞΫηαϦʔϝʔΧʔ͕)PNF,JUରԠσόΠεΛ։ൃ͢ΔͨΊͷΩοτ w ݄ʹΦʔϓϯιʔε൛͕ϦϦʔε w झຯͰͳΒࣗ༝ʹ։ൃͯ͠0,
)PNF,JU"%, )PNFCSJEHFͱͷҧ͍ )PNFCSJEHF # $ % "
)PNF,JU"%, )PNFCSJEHFͱͷҧ͍ "%, # $ % " "%, "%, "%,
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ IUUQTHJUIVCDPNBQQMF)PNF,JU"%,
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ $ brew install [υΩϡϝϯτʹॻ͔Ε͍ͯΔͷ͍͔ͭ͘] $ make all $
./Output/লུ/Debug/IP/Applications/Lightbulb.OpenSSL
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ Info [com.apple.mfi.HomeKit.Core:AccessoryServer] Accessory server starting.
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ Info HandleLightBulbOnWrite: true ... Info HandleLightBulbOnWrite: false
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ lightbulb_slack/Applications/Lightbulb/App.c #include <stdlib.h> HAPError HandleLightBulbOnWrite( // ... if
(value) { system("./handleLightBulbOn"); } // ... }
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ #!/usr/bin/swift import Foundation let slackURL = URL(string: "Incoming
Webhook URL") var request = URLRequest(url: slackURL!) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-type") let message = "ϥΠτ͕౮" let postData = "{\"text\": \"\(message)\"}".data(using: .utf8) request.httpBody = postData let semaphore = DispatchSemaphore(value: 0) let session = URLSession(configuration: URLSessionConfiguration.default) let task = session.dataTask(with: request) { _, _, _ in semaphore.signal() } task.resume() semaphore.wait()
)PNF,JU"%, ࣗͰΞΫηαϦʔΛ࡞Δ
.PSF*OGPSNBUJPO w J041SPHSBNNJOH w Ξοϓϧͷ)PNF1PEͱ)PNF,JUٕज़ຊ IUUQTQFBLTDDCPPLTJ04 IUUQTCPPUIQNKBJUFNT