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

29 lines
659 B
Python
Raw Permalink Normal View History

2024-03-05 08:44:46 +00:00
import sdtcloudpubsub
import sdtclouds3
import time
import uuid
# call sdtcloudpubsub
sdtcloudMqttClient = sdtcloudpubsub.sdtcloudpubsub()
mqttClient = sdtcloudMqttClient.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
# call sdtclouds3
sdtcloudS3Client = sdtclouds3.sdtclouds3()
def runAction():
while True:
uploadFile = "./text.txt"
result = sdtcloudS3Client.uploadData(uploadFile, "")
msg = {
"message": "Hello World",
"uploadFile": result
}
sdtcloudMqttClient.pubMessage(mqttClient, msg)
time.sleep(10)
if __name__ == "__main__":
runAction()