From ce5e351b48a0a8bb666a579324586caeba8eba8a Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期五, 15 十一月 2024 13:18:01 +0800
Subject: [PATCH] 合拼电压电量和透析机数据一起上传到阿里云

---
 upgrade/pyamp.zip    |    0 
 src/app_aliyunIot.py |    4 ++--
 src/tool.py          |    7 +++++++
 src/app_uart485.py   |   29 +++++++++++++++++++++++++----
 4 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/app_aliyunIot.py b/src/app_aliyunIot.py
index 2e77b9c..0a9e39a 100644
--- a/src/app_aliyunIot.py
+++ b/src/app_aliyunIot.py
@@ -237,9 +237,9 @@
 def get_mqtt_connect_flag():
     global iot_connected
     return iot_connected
-def masgDefault_ver(id):
+def masgDefault_ver(id): 
     while True:
         print('当前App版本号:' + default_ver)
         print('等待Ota升级包.....')
         print('--------------------------------------------------------------------')
-        time.sleep(5)
\ No newline at end of file
+        time.sleep(30)
\ No newline at end of file
diff --git a/src/app_uart485.py b/src/app_uart485.py
index abb60f6..f94a1a7 100644
--- a/src/app_uart485.py
+++ b/src/app_uart485.py
@@ -6,6 +6,13 @@
 import utime   # 延时函数在utime库中
 uart = UART()
 
+
+
+#电量
+g_dianlaing = 0
+g_dianya=0
+g_dianlaingbaojing=0
+
 #打开串口通讯
 def uart_init():
     uart.open("serial3")
@@ -41,6 +48,7 @@
     
 #发送指令到串口
 def sundSos(hex_data,type):
+    global g_dianlaing,g_dianya,g_dianlaingbaojing
     # 将16进制数据列表转换为字节串
     byte_data = bytes(hex_data)
     uart.write(byte_data)
@@ -69,18 +77,28 @@
         print("CRC 校验正确")
         if type=='sos':
             print("输出计算得到的电量: {}".format(readBuf[4]))
-            app_aliyunIot.sudDataPostProps({"Dsos":readBuf[4]}) 
+            # app_aliyunIot.sudDataPostProps({"Dsos":readBuf[4]}) 
+            g_dianlaing=readBuf[4]
         elif type=='alert':
             print("输出计算得到的电池报警: {}".format(readBuf[4]))
-            app_aliyunIot.sudDataPostProps({"Dalert":readBuf[4]}) 
+            g_dianlaingbaojing=readBuf[4]
+            # app_aliyunIot.sudDataPostProps({"Dalert":readBuf[4]}) 
         elif type=='dianya':
             print(readBuf[3],readBuf[4])
             dianyasun=hex_to_decimal_divide(readBuf[3],readBuf[4])
             print("输出计算得到的电压: {}".format(dianyasun))
-            app_aliyunIot.sudDataPostProps({"Dv":dianyasun}) 
+            g_dianya=dianyasun
+            # app_aliyunIot.sudDataPostProps({"Dv":dianyasun}) 
             
     else:
         print("CRC 校验不正确")
+        if type=='sos':
+            g_dianlaing=0
+        elif type=='alert':
+            g_dianlaingbaojing=0
+        elif type=='dianya':
+            g_dianya=0
+            # app_aliyunIot.sudDataPostProps({"Dv":dianyasun}) 
 
 def hex_to_decimal_divide(dec1, dec2):
     hex1 = '{:02X}'.format(dec1)
@@ -89,4 +107,7 @@
     decimal_value = int(hex1 + hex2, 16)
     # 除以 100 并保留一位小数
     result = round(decimal_value / 100, 1)
-    return result
\ No newline at end of file
+    return result
+def getG_dian():
+    global g_dianlaing,g_dianya,g_dianlaingbaojing
+    return  [g_dianlaing,g_dianya,g_dianlaingbaojing]        
\ No newline at end of file
diff --git a/src/tool.py b/src/tool.py
index 83be88c..89cef42 100644
--- a/src/tool.py
+++ b/src/tool.py
@@ -1,6 +1,7 @@
 import http
 import ujson
 from modem import info 
+import app_uart485
 import kv
 isDevice=False
 #通过imei接口获取三元组信息
@@ -57,6 +58,8 @@
     return  isDevice 
 #转成json格式
 def toParams(strData):
+    #获取485的数据
+    datas=app_uart485.getG_dian()
     print('------data-TO--Params-----------')
     jsonData={
         "A":strData[6:11],
@@ -114,6 +117,10 @@
         "C53": strData[257: 258],
         "C54": strData[259: 264],
         "C55": strData[265: 266],
+        "Dsos":datas[0],
+        "Dv":datas[1],
+        "Dalert":datas[2],
+
         "suedtime": '',
         "deviceType": '东丽'
 
diff --git a/upgrade/pyamp.zip b/upgrade/pyamp.zip
index 23263ad..8af9fe0 100644
--- a/upgrade/pyamp.zip
+++ b/upgrade/pyamp.zip
Binary files differ

--
Gitblit v1.8.0