mqtt-s3-sdt-sdk-template/main.py

31 lines
723 B
Python

import sdtcloudpubsub
import sdtclouds3
import time
import uuid
# call sdtcloudpubsub
sdtcloudMqttClient = sdtcloudpubsub.sdtcloudpubsub()
sdtcloudMqttClient.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
# call sdtclouds3
S3Id = "" # your S3 AWS Access Key
S3Key = "" # your S3 AWS Access Sercet Key
sdtcloudS3Client = sdtclouds3.sdtclouds3(S3Id, S3Key)
def runAction():
while True:
uploadFile = "./text.txt"
result = sdtcloudS3Client.uploadData(uploadFile, "")
msg = {
"message": "Hello World",
"uploadFile": result
}
sdtcloudMqttClient.pubMessage(msg)
time.sleep(10)
if __name__ == "__main__":
runAction()