2016-06-22 6 views
0

aws iotで作業していて、シェルスクリプトを使用してシャドウ状態を端末で更新できるようになっていますが、 root @ raspberrypi:〜#。 /aws_subscribe.py 結果コード0に接続しました aws iotホームで同期エラーが発生しています 以下に添付されています。 I followed the following linkシャドウステータスがawsで同期していないiot解決方法

+0

可能な複製(http://stackoverflow.com/questions/37984677/on-message-is-not-working-in-python) –

答えて

0

これは私が得る限りです。これは私がラズベリーパイで動いているので、私は証明書が必要です。ラムダに証明書が必要かどうかわからないシャドウ状態は、カスタムコールバックで返されます。これは彼らがそれをすることを決めた方法です。私はまだコールバックの外でシャドウ状態を取得する方法を理解することはできませんので、実際に印刷以外のもので有用なことを実際に行うことができます。

from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTShadowClient 
    import logging 
    import json 


def get(payload, responseStatus, token): 
    dict = json.loads(payload) 
    print(str(dict["state"]["desired"]["State"])) #make sure this matches your shadow names 



# Read in command-line parameters 
useWebsocket = False 
host = "XXXXXYourINFO HEREXXXXXX.iot.us-east-1.amazonaws.com" 
rootCAPath = "XXXXXYourINFO HEREXXXXXX" 
certificatePath = "XXXXXYourINFO HEREXXXXXX" 
privateKeyPath = "XXXXXYourINFO HEREXXXXXX" 


# 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 AWSIoTMQTTShadowClient 

myAWSIoTMQTTShadowClient = AWSIoTMQTTShadowClient("basicShadowUpdater") 
myAWSIoTMQTTShadowClient.configureEndpoint(host, 8883) 
myAWSIoTMQTTShadowClient.configureCredentials(rootCAPath, privateKeyPath, certificatePath) 

# AWSIoTMQTTShadowClient configuration 
myAWSIoTMQTTShadowClient.configureAutoReconnectBackoffTime(1, 32, 20) 
myAWSIoTMQTTShadowClient.configureConnectDisconnectTimeout(10) # 10 sec 
myAWSIoTMQTTShadowClient.configureMQTTOperationTimeout(5) # 5 sec 

# Connect to AWS IoT 
myAWSIoTMQTTShadowClient.connect() 

# Create a deviceShadow with persistent subscription 
Bot = myAWSIoTMQTTShadowClient.createShadowHandlerWithName("GarageRBP", True) 

#get the shadow here and the state is included in the custom callback 
Bot.shadowGet(get, 5) 
[\の_messageにpythonで動作していない]の
関連する問題