Compare commits

..

No commits in common. "main" and "v1.0.1" have entirely different histories.
main ... v1.0.1

2 changed files with 6 additions and 86408 deletions

File diff suppressed because it is too large Load Diff

12
main.py
View File

@ -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:
@ -17,7 +17,7 @@ def extract_data(json_item):
return None return None
def main(): def main():
file_path = './cnt_data.json' file_path = '../cnt_data.json'
items = read_json_file(file_path) items = read_json_file(file_path)
total_count = len(items) total_count = len(items)
index = 0 index = 0
@ -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.")