Slide 1

Slide 1 text

Droidkaigi2018 Katsuya Kato

Slide 2

Slide 2 text

,1* ¢ %(!0Kato Katsuya ¢ Android / iOS ¢ 3"$ . ¢ +&2 # ¢ '/-) 2

Slide 3

Slide 3 text

#%/' ¢ Raspberry Pi-* Android Things&, ) "$!+. ( 3

Slide 4

Slide 4 text

"#%' 0>< ¢ E,67 ¢ :A.3 B;*=7 ¢ )1/8 D ¢ C@(HF, /295 ¢ C@(4?-+ ¢ IG ! $& 4

Slide 5

Slide 5 text

Android Things ¢ Google IoT ¢ ¢ : Raspberry Pi 3 5 // . / . /

Slide 6

Slide 6 text

Android Things ¢ Android,-1 ¢ #'$'( ¢ GPIO5/20 ¢ #'&Rainbow HAT1 ¢ LED4x14"%).4.3* ! &* etc ¢ GPIO1+ http://crossbridge- lab.hatenablog.com/entry/googlehome-androidthings- led

Slide 7

Slide 7 text

¢ ADK(Accessory Development Kit) ¢ Android ¢ https://developer.android.com/adk/index.html ¢ 2011/2012 Google I/O 7

Slide 8

Slide 8 text

" ¢ Android Things with Raspberry Pi ¢ Nature Remo ¢ ¢ Linking ¢ Bluetooth! ¢ Firebase ¢ Firebase Realtime Database ¢ Cloud Functions for Firebase ¢ Firebase Cloud Messaging ¢ Geofencing 8

Slide 9

Slide 9 text

9

Slide 10

Slide 10 text

35 ¢ 6'2/9"+&). *$!,1:@B04> 1. '2A#. (Linking%(")= Android Things'27: 2. 7: Firebase Realtime Database?<8 3. <8&-Cloud Functions for Firebase "+&).*$!,1:(FCM); 10

Slide 11

Slide 11 text

Linking*/#%)- ¢ NTT&.E37G>?5

Slide 12

Slide 12 text

1 12 1 2. E B Firebase Realtime Database Cloud Functions for Firebase 3.E B. 3. (FCM)

Slide 13

Slide 13 text

Linking(!# )* ¢ SDK$% ¢ https://linkingiot.com/developer/api.html ¢ + Jar,'&" 13

Slide 14

Slide 14 text

Linking$&!A/1 Android Things(,4K ¢ !*-3C 14 // BeaconScannerSDK?H+! val scanner = BeaconScanner(this) val filter = IntentFilter() // >;9 698$#FGD5 // =B98$#9 670 filter.addAction(Define.filterBeaconScanResult) // '-=B9 6BroadcastReceiver70 registerReceiver(receiver, filter) // '!ID!*-)%70!*-3C // 63N"- M:<[email protected])%3IJ scanner.startScan(intArrayOf(6), 0)

Slide 15

Slide 15 text

Linking Android Things ¢ 15 var receiver: BeaconReceiverBase = object : BeaconReceiverBase() { internal var receivedData: BeaconData? = null override fun onReceiveScanResult(beaconData: BeaconData?) receivedData = beaconData handler.postDelayed(updateTask, 0) } //

Slide 16

Slide 16 text

Linking/$& Android Things! (7 ¢ +*) 16 internal var updateTask: Runnable = Runnable { //rawData 838 06 val dataOpenCloseSensor = receivedData?.getOpenCloseSensor() if (dataOpenCloseSensor != null) { // 05 raw (12 '912"4 #- val binary = String.format("%12s", Integer.toBinaryString(dataOpenCloseSensor!!)) .replace(" ".toRegex(), "0") val binaryState = binary.substring(0, 1) // '912 val binaryCount = binary.substring(1) // '9%, // .

Slide 17

Slide 17 text

Linking Android Things ¢ 17 // Firebase Realtime Database val database = FirebaseDatabase.getInstance().reference.child("state") database.child("door1_state") .setValue(Integer.parseInt(binaryState)) database.child("door1_count") .setValue(Integer.parseInt(binaryCount,2)) } }

Slide 18

Slide 18 text

Cloud Functions for Firebase ¢ Firebase HTTPS ¢ Realtime Database ¢ Firebase Authentication ¢ Crashlytics ¢ Cloud Storage ¢ Realtime Database 18

Slide 19

Slide 19 text

Realtime Database Node.js 19 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.push = functions.database.ref("/state/door1_state/") .onWrite(event => { const item = event.data; const payload = { data: { title: "", message: "1 " + (item.val() === 0 ? " " : " "), } }; //

Slide 20

Slide 20 text

4 20 // . /

Slide 21

Slide 21 text

¢ 21

Slide 22

Slide 22 text

Geofencing ¢ 5;70:='ED& /" ?) # ¢ Google Play Service+9: $B A5;70,63@ 14( ¢ Google Play Service API> &TargetSDK26.!-/ !70C ¢ *< %82 ¢ https://github.com/googlesamples/android-play-location 22

Slide 23

Slide 23 text

('Geofencing4. ¢ Geofencing4Android!*+ $ 6#&:7/0- Database3/ ¢ Cloud Functions58, $61 " )9% 2 23

Slide 24

Slide 24 text

24

Slide 25

Slide 25 text

"( ¢ 745 !.,'$) ¢ Raspberry Pi2%/+1 2%/LED3* #6-&→)808 25

Slide 26

Slide 26 text

7 ¢ LinuxLIRC(Linux Infrared Remote Control) 164,- Android. ' $'(* ¢ Android Things035/8 +2"%#(&!)1 http://www.lirc.org/ 26

Slide 27

Slide 27 text

#&%)(!* Nature Remo ¢ #&%)(!* ¢ ;+ ;IRKit/KIRKit,L7 ¢ @:' !*J)(!*60 NH?A ¢ GC 4D2I)(!*.F ¢ -"$USBE9 ¢ API31 85 27 http://nature.global/

Slide 28

Slide 28 text

<: ¢ Nature Remo-6!$%( ) .* =3 84 ¢ Geofencing 502 " !#&ON0; OFF ¢ ()Geofencing 1' ¢ 07*()/ /9 ,+ 28

Slide 29

Slide 29 text

9? 1. '.*,$3"-/ @K6JHK6J! Firebase Database>7 2. Android ThingsFirebase DatabaseIG: AI!7 6JNature RemoAPI!L ¢ Nature RemoAPI1%0+)*2&#3( +)*;FCloud Functions!C →=8API!L54DE 29

Slide 30

Slide 30 text

Nature Remo)!API" ¢ API&% https://developer.nature.global/ ¢ ¢ '# $ ¢ '# $)! ¢ ¢ ()! etc 30

Slide 31

Slide 31 text

Nature Remo API 1. 2. API ID 3. API 31

Slide 32

Slide 32 text

Nature Remo API 32 $ curl -H ‘Authorization: Bearer {TOKEN}’ -H ‘accept: application/json’ -H ‘Content-Type: application/x-www-form-urlencoded’ -X POST ‘https://api.nature.global/1/signals/{ ID}/send’ ¢ https://api.nature.global/1/signals/{ ID}/send

Slide 33

Slide 33 text

33

Slide 34

Slide 34 text

"$ ¢ Android Things (% or #! *'&) 34

Slide 35

Slide 35 text

- 2 ¢ Android ThingsUSB*&Web' !# ¢ )%(" Linux ' ¢ Android Things+$, 35

Slide 36

Slide 36 text

2 36

Slide 37

Slide 37 text

.-), ¢ Android Things("* ¢ USB$ /!+%'& Web#( 37

Slide 38

Slide 38 text

38

Slide 39

Slide 39 text

"'=92. ¢ ;1 ,*6 ¢ Linking#%?7 ¢ (*A+),>#%( *5 0<7 ¢ &!$(* ¢ ,5 1834(-/34) @: 39

Slide 40

Slide 40 text

10#$&+FN@ Android Things,.%(',.%( ¢ ,.%( ¢ Android5=I -"*-.!> ¢ )%&. LBUSBJ<E/D6 )%&.Q4P!:A7 ¢ ',.%( ¢ K9C-"*-.Linux38!?5 ¢ Raspberry Pi 3&LinuxHGOM2; 40

Slide 41

Slide 41 text

¢ 4:,8:F T.+5&UC PIA ¢ Z$Q 'AndroidKR&N=W13)- &\IoT@ #S ¢ Y[Linux169/2# ¢ G? "]H# 'Android Things&X% ¢ Linking13)- 41

Slide 42

Slide 42 text

42