Compare commits
No commits in common. "main" and "v1.0.4" have entirely different histories.
10
main.py
10
main.py
|
@ -3,8 +3,8 @@ import uuid
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
|
||||||
sdtcloudMqttClient = sdtcloudpubsub.sdtcloudpubsub()
|
sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
|
||||||
sdtcloudMqttClient.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
mqttClient = sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
||||||
|
|
||||||
def read_json_file(file_path):
|
def read_json_file(file_path):
|
||||||
with open(file_path, 'r', encoding='utf-8') as f:
|
with open(file_path, 'r', encoding='utf-8') as f:
|
||||||
|
@ -25,9 +25,9 @@ def main():
|
||||||
while True:
|
while True:
|
||||||
data = extract_data(items[index])
|
data = extract_data(items[index])
|
||||||
if data:
|
if data:
|
||||||
# msg = json.dumps(data, ensure_ascii=False, default=str)
|
msg = json.dumps(data, ensure_ascii=False, default=str)
|
||||||
sdtcloudMqttClient.pubMessage(data)
|
sdtcloud.pubMessage(mqttClient, msg)
|
||||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S')} Extracted data:{data}")
|
print(f"{time.strftime('%Y-%m-%d %H:%M:%S')} Extracted data:{msg}")
|
||||||
else:
|
else:
|
||||||
print("No 'data' key found in the JSON item.")
|
print("No 'data' key found in the JSON item.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue