44
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution Builder [1-H1-3-17/1-P3-2-19] AWS IoT

AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Takashi Koyanagawa

SA: IoT/AI Solution Builder

[1-H1-3-17/1-P3-2-19]

AWS IoT ����������������

Page 2: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

S A Q c F ba RW

d

������%�&�������3F$( #!�����')����"��������� �*����

Page 3: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

����

�cp mnADI C

��o a S K MT

geW L b idh ,

���������/ )

, (

Page 4: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Agenda• ,������43�%9$���• MQTT�������

• MQTT�<!*'�(�;�• device SDK� ���MQTT�������*.

• IoT Core-7�/1• shadow���� �• � ������6�:�=)/topic�+#"1*.

• 2017&summit�28��� ��� ��update• ���50

• client temporally token

Page 5: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

@�!�(,�JI

AWS.�IoT *'-�(,�BR���97��)��,";O�Y��MQTT%+�)&,��>E�AWS IoT Core�DM�6G������)��,"/�)�#�;O�C����5<���U?���@�!�(,�=VL����2/��

• IoT�%*�-�(,�SQ/XHL• AWS IoT Core�DM�FP����>

@�!�(,=V:�0A

• 8@I AWS IoT�-$�YW��K1/3�>• Greengrass4N�Y��T

Page 6: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

MQTT�������

Page 7: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

MQTT�%�"

Publisher

BrokerTopic:sensor/temp

Subscriber

Subscriber

publish

subscribe

Broker publisher�������������topic���%��$���!#topic������Subscriber �����������

IoT rule

�����

thing

Subscribe�������������� ��������

Page 8: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

MQTT�����

Publisher

BrokerTopic:sensor1/temp

Subscriber

Subscriber

Subscriber

Topic:update/sensor1Publisher

����

����

IoT rule

�����thing�����������������

thing

thing

Page 9: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK���pub/sub�������AWS IoT Device SDK python���

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <� �������������>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

Page 10: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK$.�pub/sub���-*��1AWS IoT Device SDK python���

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <���� ����'" &�+>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

ClicentID�endpoint���0/���� ��0/�#!�)%�(,�clinetID������

Page 11: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK�&�pub/sub���%"� �)AWS IoT Device SDK python��

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <������� ����#>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

������($'��($�MQTTLib.py��!

MQTTLib.py �����

Page 12: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK���pub/sub�������AWS IoT Device SDK python���

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <� �������������>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

keepalive packet����(sec)default 600(s)

Page 13: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK.7pub/sub���63���:AWS IoT Device SDK python�"

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <� �!�����0,'/%4>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

def callback_function(client, userdata, message):message.topic : 8#$topic)message.payload : ���!�palyload

subscribe��topic ���!����callback91�+���message object topic)/8#�!��*����topic�payload��%4&-�����2���(5

Page 14: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

SDK�(�pub/sub��'$���)AWS IoT Device SDK python���

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID) myMQTTClient.configureEndpoint(YOUR.ENDPOINT, 8883) myMQTTClient.configureCredentials( root_ca, private_key, certificate_key)myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueingmyMQTTClient.configureDrainingFrequency(2) # Draining: 2 HzmyMQTTClient.configureConnectDisconnectTimeout(10) # 10 secmyMQTTClient.configureMQTTOperationTimeout(5) # 5 sec

myMQTTClient.connect(KeepAliveTime)

#subscribemyMQTTClient.subscribe(subscribe_topic, qos, callback_function)While True:

payload = <����� � ����%>#publishmyMQTTClient.publish(publish_topic, payload(string), qos)time.sleep(wait_time)

https://github.com/aws/aws-iot-device-sdk-python

json�string��"

IoTGateway�AWS IoT�thing�����gateway�&%����� ������json��payload�#����%�!�

Page 15: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Broker

AWS IoT Core�����QoSIoT Core����QoS� “0”�”1”�QoS=2������

QoS=0At most once

QoS=1at least once

PUBACK

PUBLISHPUBLISH

Broker

Page 16: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Broker

AWS IoT Core�����QoSIoT Core������QoS� “0”�”1”�QoS=2�������

QoS=0At most once

QoS=1at least once

PUBACK

PUBLISHPUBLISH

Broker

PUBACK������Publisher� ��

Page 17: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

sample �����IoT Device SDK �sample �������������������������

Page 18: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

���MQTT �������

g y s p T /, m y T 0, pil T )4,

m 0244 $.441$ 8 9

.441 .441

)/, c s pWS)$ s p

9 9 s pM

o y )$g y c )/,W

S )$ g y B

)$ , ) 4,

l ge5(

5( 5(

K Qb g y PKH g Wl y

Ksk v c a

g y PGK

e t grK G g Vtc

Page 19: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

J,#)!�(�K<�D7• @G9-HA

• "�'�(��%�0?4J, : MQTT• *�I,��� : MQTT or HTTP

• ��!HA• J,�58E(or>L) .B1G: MQTT or HTTP• J,�SIM�/=�F����

• &��*�I,N:�O�PMQTT• &��*�N:�+�PMQTT or HTTP

(*) MQTT�port443 .B ���������https://aws.amazon.com/jp/blogs/news/mqtt-with-tls-client-authentication-on-port-443-why-it-is-useful-and-how-it-works/https://aws.amazon.com/jp/blogs/news/how-to-implement-mqtt-with-tls-client-authentication-on-port-443-from-client-devices-python/

HTTP�handshake�header�J,��!�;M���63���

AWS IoT Core��$*!�#)!�(/$*!C2

Page 20: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

MQTT+2#/,3#����• publish�return�:QLD�6���• :QLDH��87��"/ *5��response�6>�� ��

subscriber�TN

• HTTP�subscribeK=�GO�:J�����polling.(1�+2#/,3#�?R����

• AWS IoT���MQTT <CBM $0.063/year per device,HTTP0"!&)�AWS IoT��1msg�Amazon API Gateway��V

request�%&)���• HTTP�0�1'�-@�I����U%&)���

HTTP lib/client��A���;F��MQTT�ES� ���P�$4&�9��

Page 21: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Core���- Shadow�������

Page 22: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

MQTT�3#����shadow-"�(.MQTT�%,����pub/sub����request/response�)1����� ��thing�shadow0+�&*�����!�5�topic�$2���- $aws/things/thing_name/shadow/get

: shadow�get����������topic- $aws/things/thing_name/shadow/get/accepted

:get ������'� �4�shadow�0+����/��topic

1) get/accepted�subscribe

IoTshadow

{“state”:

“reportede”:{“polling_time” :10

}}

2) /get�publish

3) get/accepted�publish

Page 23: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

shadow�65����+-0A��!4�2(����!42(� A_common���thing shadow�/*�"1���device� &��shadow�subscribe��

IoTshadow

�����

3# ��thing�!4shadow�',�%�$�.�A_common�shadow /get/accepted�)�subscribe

A_1

A_2

A_3

�����

update thing shadow�publish(polling time�15�',)

shadow update

$aws/things/a_common/shadow/get

Page 24: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

shadow�JI��,�;=BA��/H�E8����/HE8��A_common���thing shadow�?9�0D��device�.4��shadow�subscribe����%'�* ��thing�G2�shadow�7<����AF�>�/get�publish����35=B.��H@�������

IoTshadow

�&)+!

A_1

A_2

A_3

�+'$("��:-�K�/� #61�C��

Page 25: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

shadow/topicRQ��+#&",+<T�thing�V��shadow/topic�7G�����RQ�UB=�shadow������1��thing�shadow�KH�

���2�0��get/accepted�0J��$aws/things/thing_name/shadow/update/accepted�3I����� +$*,)����shadow�-Ltopic�A:�HP�����SO

shadow�/��D5��,!WNEC8@�9R>�� �F�pub/sub�/��D5��,!W6M�%�(�)"�'�4?;.

https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/using-device-shadows.html

Page 26: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Core ����- �������������/topic������

Page 27: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

thing������1) payload�json���thing���2) MQTT�#�&����clientID������������3) MQTT topic�!�� (�����"�)

�������� SQL$%��SELECT * as payload, clientid() as thing_name FROM 'data/#'

�������� ����� {

"thing_name": ”client_name","payload": {

…}

}

# Import SDK packagesfrom AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient(myClientID)

Page 28: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Topic#!�)+���message payload�0���MQTT topic,���������������

topic����data/place(' /-"%)/thing_name(' �)

��������SQL.1&(SELECT * as payload, topic(2) as place, topic(3) as thing_nameFROM ‘data/#'

�������*$�� ���{

”place": ”Tokyo”,"thing_name": ”test-thing","payload": {

…}

}

-

Page 29: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Shadow���������������

��� ���SQL���SELECT * FROM ‘data/#’ WHEREget_thing_shadow(“thingname”, “roleARN”).state.reported.door_status = “open”

thing��������Rule��(DB update)�shadowupdate����������

Page 30: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

)�&��rule engine�(�+�,$��'

��topic����kinesis data stream�partition key�topic()�!����shard�#������newuuid()�timestamp()� �#�%�������*������"�

( // ()

/ ( ( ( /)

( // ()

/ ( ( ( //

A = A

Page 31: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

�'��*,�B�H�I:�E�

newuuid() : 16byte�uuid>7timestamp() : unixtime65 "$A.) ���#��% parse_time() : <(�65��&!��19lower(value), upper(value): ;3+�4;3/2;3-principal(): 8C�thing�,?����F=F���%�& $%�����thing0

���,?/D�I:�SQL version��@G�����

https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/iot-sql-functions.html

Page 32: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

"$"�#�#/topic�� �

"$"�#�#�topic�.(/2��� ��+5�Lambda�%1�=0��� � $��payload�=0�topic/payload�?8�'A��� �)6�2,�����4�>�@-�3<��� ��topic ��#�7&�!$��$��*���;:��� �?9

Page 33: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

2017�������� �� �update

AWS Summit Tokyo 2017�� IoT ���� -AWS IoT�AWS Greengrass�������� -

Page 34: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

sST A T dT A lo

18 dAbihpS

) / 2 5

� ���� ������

42 a T d K SW Ae B

513 Sn IBSn D w (-2 m

18ty Su

Page 35: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Device Management

($ (https://aws.amazon.com/jp/iot-device-management/)

• #3�����%�thing"/shadowstatus�Lucene like�Index�� &-!/

• �������������,)�� ����'/

• �����2��Greengrass/FreeRTOSFirm update*1+��� job'/4job.0 � )

I AA J

Continuous Snapshot

G

Page 36: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Device Management: Group*0

Thing�/,%!��Group6,3+������Group%!��Policy5'�&0- #��Thing%!�Policy�5'����2�

�� �54�")�� => ��� => 7(�����.$� �8)54� 1-�5'&0

Page 37: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Device Management: Index

�������!�! ���#%"$�������������� �������������� ��������������������������#%��������

CLI aws iot search-index --index-name "AWS_Things" --query-string "shadow.reported.firmware:1.1.0"

Page 38: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

IoT Device Management : Jobs-3%8 device�Group*&�����)7(�������$9� snapshot+�/job,9��5 ��thing�#��'���������60�"����� /.�2!�14�������-3�+�

Page 39: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

1. Index��/thing group�����2. update Group� 3. job�

IoT Device Management��������

Page 40: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

- e

reu

hu h I

t

SW ibl M

k M T scA M n

po

Page 41: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

) I A 2

)1 3

3 H)3 31 H

))

1

e.g) wget�tempolay������ wget--private-key= private.pem.key--certificate= certificate.pem.crt--ca-directory= AmazonRootCA1.pemhttps://<your_info>.credentials.iot.us-west-2.amazonaws.com:443/role-aliases/<2�����alias>/credentials

https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/authorizing-direct-aws.html

����� ���������������������

�)Credential������ 2)�CreateRoleAlias API����(900-3600�)

Page 42: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

���

• MQTT8��%$�#3%$�,5��76/ (#3�&=�01

• IoT Core , IoT Device Management�)2�'"!-���*>�<.�9��

• "+/����:� �topic�����;4• re:Invent 2017������ “One Message to Million Things Done

in 60 seconds with AWS IoT”�����������

Page 43: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

S A Q c F ba RW

d

������%�&�������3F$( #!�����')����"��������� �*����

Page 44: AWS IoT の賢い利用の仕方とプログラミングの勘所 · © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takashi Koyanagawa SA: IoT/AI Solution

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Thank you