안녕하세요 😊😊😊
이번 시리즈는 간단하고도 어려운 Amazon IoT Core 시간입니다.
설명도 중간중간 진행하겠지만, 가장 기본적으로는 Step By Step으로 따라하면 무조건 성공할 수 있도록 단계별로 포스팅 할 예정입니다.
지금까지 영어로 된 자료, 조각화 된 자료로 고생하셨나요.
지금 이 포스팅을 쭉 따라하면서 개념을 이해해보시기를 바라겠습니다. 😘😘
[아키텍쳐]
[목차]
1. AWS IoT Core - Device 패키지 다운로드
2. Dummy Device, EC2에 설치 및 실행
3. Dummy Device 에서 생성된 데이터 IoT Core에서 확인하기
[실습시작]
1. AWS IoT Core - Device 패키지 다운로드
AWS IoT Core 서비스는 당연히 IoT Device가 있어야 합니다.
우리는 Device가 없죠.. 그래서 EC2로 가짜 Device를 생성하도록 하겠습니다.
AWS IoT 콘솔에 접속한 후 왼쪽 "Connect" > "Get Started"를 선택합니다.
아래와 같이 AWS IoT 디바이스 온보딩이 나오면, "시작하기" 버튼을 클릭합니다.
시작하기를 클릭합니다.
플랫폼(Linux), SDK(Python)을 선택하고 다음을 클릭합니다.
사물 이름을 작성합니다. 저는 my-IoT-Things 로 만들었습니다.
가장 중요한 부분입니다.
연결 키드를 다운로드 후 다음단계로 넘어갑니다.
키트 다운 후 어떻게 사용해야 하는지 명령어를 알려줍니다.
여기에서 완료를 누르거나, 참고용으로 페이지를 그냥 켜두셔도 됩니다.
2. Dummy Device, EC2에 설치 및 실행
패키지를 다운받았으니, 이제 EC2 인스턴스를 Dummy Device로 만들어보겠습니다.
먼저 EC2를 생성하고 1번 단계에서 다운받았던 패키지 파일을 EC2로 옮겨줍시다.
이 두가지는 별도로 설명하지 않겠습니다. (링크를 해놓겠습니다^^)
EC2에 접속해봅시다!
Desktop % ssh -i awskey/myEC2Key.pem ec2-user@13.125.171.126
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
3 package(s) needed for security, out of 15 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-172-31-9-184 ~]$
# root 유저로 변환
[ec2-user@ip-172-31-9-184 ~]$ sudo su
[root@ip-172-31-9-184 ec2-user]#
# iot-dummy 디렉토리 생성 및 zip파일 압축 해제
[root@ip-172-31-9-184 ec2-user]# mkdir /iot-dummy
[root@ip-172-31-9-184 ec2-user]# unzip connect_device_package.zip -d /iot-dummy/
# iot-dummy 디렉토리로 이동 후 파일 목록 확인
[root@ip-172-31-9-184 ec2-user]# cd /iot-dummy
[root@ip-172-31-9-184 iot-dummy]# ls -al
합계 16
drwxr-xr-x 2 root root 117 10월 12 08:24 .
dr-xr-xr-x 19 root root 274 10월 12 08:24 ..
-rw-r--r-- 1 root root 1224 10월 12 07:59 my-IoT-Things.cert.pem
-rw-r--r-- 1 root root 1679 10월 12 07:59 my-IoT-Things.private.key
-rw-r--r-- 1 root root 451 10월 12 07:59 my-IoT-Things.public.key
-rw-r--r-- 1 root root 1179 10월 12 07:59 start.sh
# git, pip 패키지 설치 및 iot Core Device SDK 실행
[root@ip-172-31-9-184 iot-dummy]# yum install git -y
[root@ip-172-31-9-184 iot-dummy]# yum install pip -y
[root@ip-172-31-9-184 iot-dummy]# sh start.sh
여기까지 했으면, MQTT 프로토콜로 IoT Core로 "{"message": "Hello World!", "sequence": 1} 메세지를 보내고 있을겁니다.
[root@ip-172-31-9-184 iot-dummy]# sh start.sh
콘솔 내용을 확인하려면 아래 더보기를 눌러주세요 :)
[root@ip-172-31-9-184 iot-dummy]# sh start.sh
Running pub/sub sample application...
2021-10-12 08:36:22,637 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Initializing MQTT layer...
2021-10-12 08:36:22,638 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Registering internal event callbacks to MQTT layer...
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - MqttCore initialized
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Client id: basicPubSub
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Protocol version: MQTTv3.1.1
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Authentication type: TLSv1.2 certificate based Mutual Auth.
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring endpoint...
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring certificates...
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring reconnect back off timing...
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Base quiet time: 1.000000 sec
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Max quiet time: 32.000000 sec
2021-10-12 08:36:22,639 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Stable connection time: 20.000000 sec
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queueing: max queue size: -1
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queue draining interval: 0.500000 sec
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring connect/disconnect time out: 10.000000 sec
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring MQTT operation time out: 5.000000 sec
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync connect...
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async connect...
2021-10-12 08:36:22,640 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Keep-alive: 600.000000 sec
2021-10-12 08:36:22,641 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread started
2021-10-12 08:36:22,641 - AWSIoTPythonSDK.core.protocol.mqtt_core - DEBUG - Passing in general notification callbacks to internal client...
2021-10-12 08:36:22,641 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in fixed event callbacks: CONNACK, DISCONNECT, MESSAGE
2021-10-12 08:36:22,652 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Starting network I/O thread...
2021-10-12 08:36:22,701 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [connack] event
2021-10-12 08:36:22,702 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [connack] event
2021-10-12 08:36:22,702 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - No need for recovery
2021-10-12 08:36:22,702 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:36:22,717 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync subscribe...
2021-10-12 08:36:22,717 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Adding a new subscription record: sdk/test/Python qos: 1
2021-10-12 08:36:22,718 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom suback event callback...
2021-10-12 08:36:22,759 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [suback] event
2021-10-12 08:36:22,761 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [suback] event
2021-10-12 08:36:22,761 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:36:22,761 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:36:24,784 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:36:24,784 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:36:24,794 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:36:24,797 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:36:24,797 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:36:24,798 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:36:24,820 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:36:24,821 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"message": "Hello World!", "sequence": 0}
from topic:
sdk/test/Python
--------------
2021-10-12 08:36:24,821 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:36:25,801 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:36:25,801 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:36:25,813 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:36:25,814 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:36:25,814 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:36:25,814 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:36:25,839 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:36:25,841 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"message": "Hello World!", "sequence": 1}
from topic:
sdk/test/Python
--------------
2021-10-12 08:36:25,842 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
하지만, 저는 이 데이터 형식이 마음이 들지 않습니다.
다른 서비스와 함께 사용해보기 위해, 조금더 재미있는 데이터 형식을 사용할겁니다 :)
먼저, /iot-dummy/aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py 파일을 수정해줍시다.
(AWS에서 제공하는 파이선 샘플을 조금 수정했습니다.!)
[root@ip-172-31-9-184 iot-dummy]# vim /iot-dummy/aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py
'''
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
'''
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
import logging
import time
import datetime
import argparse
import json
import random
import socket
AllowedActions = ['both', 'publish', 'subscribe']
# Custom MQTT message callback
def customCallback(client, userdata, message):
print("Received a new message: ")
print(message.payload)
print("from topic: ")
print(message.topic)
print("--------------\n\n")
# Read in command-line parameters
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--endpoint", action="store", required=True, dest="host", help="Your AWS IoT custom endpoint")
parser.add_argument("-r", "--rootCA", action="store", required=True, dest="rootCAPath", help="Root CA file path")
parser.add_argument("-c", "--cert", action="store", dest="certificatePath", help="Certificate file path")
parser.add_argument("-k", "--key", action="store", dest="privateKeyPath", help="Private key file path")
parser.add_argument("-p", "--port", action="store", dest="port", type=int, help="Port number override")
parser.add_argument("-w", "--websocket", action="store_true", dest="useWebsocket", default=False,
help="Use MQTT over WebSocket")
parser.add_argument("-id", "--clientId", action="store", dest="clientId", default="basicPubSub",
help="Targeted client id")
parser.add_argument("-t", "--topic", action="store", dest="topic", default="sdk/test/Python", help="Targeted topic")
parser.add_argument("-m", "--mode", action="store", dest="mode", default="both",
help="Operation modes: %s"%str(AllowedActions))
parser.add_argument("-M", "--message", action="store", dest="message", default="Hello World!",
help="Message to publish")
args = parser.parse_args()
host = args.host
rootCAPath = args.rootCAPath
certificatePath = args.certificatePath
privateKeyPath = args.privateKeyPath
port = args.port
useWebsocket = args.useWebsocket
clientId = args.clientId
topic = args.topic
if args.mode not in AllowedActions:
parser.error("Unknown --mode option %s. Must be one of %s" % (args.mode, str(AllowedActions)))
exit(2)
if args.useWebsocket and args.certificatePath and args.privateKeyPath:
parser.error("X.509 cert authentication and WebSocket are mutual exclusive. Please pick one.")
exit(2)
if not args.useWebsocket and (not args.certificatePath or not args.privateKeyPath):
parser.error("Missing credentials for authentication.")
exit(2)
# Port defaults
if args.useWebsocket and not args.port: # When no port override for WebSocket, default to 443
port = 443
if not args.useWebsocket and not args.port: # When no port override for non-WebSocket, default to 8883
port = 8883
# Configure logging
logger = logging.getLogger("AWSIoTPythonSDK.core")
logger.setLevel(logging.DEBUG)
streamHandler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)
# Init AWSIoTMQTTClient
myAWSIoTMQTTClient = None
if useWebsocket:
myAWSIoTMQTTClient = AWSIoTMQTTClient(clientId, useWebsocket=True)
myAWSIoTMQTTClient.configureEndpoint(host, port)
myAWSIoTMQTTClient.configureCredentials(rootCAPath)
else:
myAWSIoTMQTTClient = AWSIoTMQTTClient(clientId)
myAWSIoTMQTTClient.configureEndpoint(host, port)
myAWSIoTMQTTClient.configureCredentials(rootCAPath, privateKeyPath, certificatePath)
# AWSIoTMQTTClient connection configuration
myAWSIoTMQTTClient.configureAutoReconnectBackoffTime(1, 32, 20)
myAWSIoTMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueing
myAWSIoTMQTTClient.configureDrainingFrequency(2) # Draining: 2 Hlsz
myAWSIoTMQTTClient.configureConnectDisconnectTimeout(10) # 10 sec
myAWSIoTMQTTClient.configureMQTTOperationTimeout(5) # 5 sec
# Connect and subscribe to AWS IoT
myAWSIoTMQTTClient.connect()
if args.mode == 'both' or args.mode == 'subscribe':
myAWSIoTMQTTClient.subscribe(topic, 1, customCallback)
time.sleep(2)
# Publish to the same topic in a loop forever
loopCount = 0
while True:
if args.mode == 'both' or args.mode == 'publish':
message = {}
attri_device_id = "Device-0"+str(random.randrange(1,5))
attri_records_time = str(datetime.datetime.today())
attri_records_status = random.choice(["Up"])
attribute = {"device-id": attri_device_id, "records-time": attri_records_time, "status": attri_records_status}
values_flow = str(int(60 + int(random.randrange(1,32767)) % 40))
values_temp = str(int(15 + int(random.randrange(1,32767)) % 20))
values_humidity = str(int(50 + int(random.randrange(1,32767)) % 40))
values_vibration = str(int(100 + int(random.randrange(1,32767)) % 40))
values = []
values_list_flow = {"flow": values_flow}
values_list_temp = {"temperature": values_temp}
values_list_humidity = {"humidity": values_humidity}
values_list_vibration = {"vibration": values_vibration}
values.append(values_list_flow)
values.append(values_list_temp)
values.append(values_list_humidity)
values.append(values_list_vibration)
message['Unique_id'] = attribute
message['Measures_values'] = values
messageJson = json.dumps(message)
myAWSIoTMQTTClient.publish(topic, messageJson, 1)
if args.mode == 'publish':
print('Published topic %s: %s\n' % (topic, messageJson))
loopCount += 1
time.sleep(1)
완료 되었다면, 이제 다시 한번 start.sh 스크립트를 실행합니다.
[root@ip-172-31-9-184 iot-dummy]# sh start.sh
보내지는 데이터 형식은 아래와 같습니다.
{"Unique_id": {"records-time": "2021-10-12 08:48:46.221736", "device-id": "Device-03", "status": "Up"}, "Measures_values": [{"flow": "83"}, {"temperature": "29"}, {"humidity": "78"}, {"vibration": "133"}]}
결과 파일 샘플입니다. 정상적으로 운영된다면 이렇게 나와야 해요 ;)
2021-10-12 08:48:41,160 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:42,153 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:48:42,153 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:48:42,166 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:48:42,168 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:48:42,168 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:42,168 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:48:42,192 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:48:42,193 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"Unique_id": {"records-time": "2021-10-12 08:48:42.153412", "device-id": "Device-02", "status": "Up"}, "Measures_values": [{"flow": "85"}, {"temperature": "21"}, {"humidity": "87"}, {"vibration": "102"}]}
from topic:
sdk/test/Python
--------------
2021-10-12 08:48:42,193 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:43,170 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:48:43,171 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:48:43,182 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:48:43,186 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:48:43,186 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:43,186 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:48:43,209 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:48:43,210 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"Unique_id": {"records-time": "2021-10-12 08:48:43.170639", "device-id": "Device-03", "status": "Up"}, "Measures_values": [{"flow": "75"}, {"temperature": "30"}, {"humidity": "81"}, {"vibration": "118"}]}
from topic:
sdk/test/Python
--------------
2021-10-12 08:48:43,210 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:44,187 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:48:44,188 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:48:44,200 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:48:44,201 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:48:44,201 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:44,202 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:48:44,227 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:48:44,230 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"Unique_id": {"records-time": "2021-10-12 08:48:44.187602", "device-id": "Device-03", "status": "Up"}, "Measures_values": [{"flow": "96"}, {"temperature": "22"}, {"humidity": "81"}, {"vibration": "110"}]}
from topic:
sdk/test/Python
--------------
2021-10-12 08:48:44,230 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:45,204 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:48:45,205 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:48:45,216 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:48:45,217 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:48:45,217 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:45,218 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:48:45,242 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:48:45,245 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"Unique_id": {"records-time": "2021-10-12 08:48:45.204756", "device-id": "Device-01", "status": "Up"}, "Measures_values": [{"flow": "67"}, {"temperature": "27"}, {"humidity": "75"}, {"vibration": "100"}]}
from topic:
sdk/test/Python
--------------
2021-10-12 08:48:45,245 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:46,221 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...
2021-10-12 08:48:46,222 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2021-10-12 08:48:46,233 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2021-10-12 08:48:46,233 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2021-10-12 08:48:46,233 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2021-10-12 08:48:46,233 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
2021-10-12 08:48:46,260 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event
2021-10-12 08:48:46,261 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event
Received a new message:
{"Unique_id": {"records-time": "2021-10-12 08:48:46.221736", "device-id": "Device-03", "status": "Up"}, "Measures_values": [{"flow": "83"}, {"temperature": "29"}, {"humidity": "78"}, {"vibration": "133"}]}
from topic:
sdk/test/Python
--------------
이제, AWS IoT Core에 정상적으로 잘 보내지고 있는지 확인해봅시다.
3. Dummy Device 에서 생성된 데이터 IoT Core에서 확인하기
AWS IoT Core는 받는 데이터를 모니터링 할 수 있도록 MQTT Test Client를 제공합니다.
IoT Core 웹 콘솔의 왼쪽 네비게이션 바에서 "테스트" 클릭 후 모든 주제(#)를 구독합니다. 이렇게 하면 모든 토픽으로 들어오는 데이터를 모두 모니터링 할 수 있습니다.
정상적으로 데이터가 들어온다면, 데이터 형식은 아래와 같습니다.
이제 다음 단계에서 데이터를 활용하는 방법에 대해 알아보도록 합시다!!
고생하셨습니다!!~!!!🎉🎉🎉🎉