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.5k
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
610
SharePlayの歴史と進化 そしてvisionOSへ (iOSDC 2023)
tokorom
3
900
5分でSharePlay入門
tokorom
3
1.4k
Advanced Segue 2019年のSegue事情
tokorom
9
5.8k
tvOSアプリUIの勘所
tokorom
1
2k
カッコ悪くリアクティブじゃダメですか?
tokorom
7
12k
古き良きsendAction (in potatotips #26)
tokorom
1
3.6k
画面遷移と私(iOS)
tokorom
4
3.7k
長生きするために心臓に悪いリリースはもうやめよう
tokorom
21
33k
Other Decks in Programming
See All in Programming
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
500
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
480
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
160
Jakarta EE meets AI
ivargrimstad
0
260
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
190
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
300
Featured
See All Featured
Become a Pro
speakerdeck
PRO
26
5k
Code Reviewing Like a Champion
maltzj
520
39k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Writing Fast Ruby
sferik
628
61k
Why Our Code Smells
bkeepers
PRO
335
57k
Automating Front-end Workflow
addyosmani
1366
200k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
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