G10去掉log
authorp15692025051 <846603105@qq.com>
Mon, 27 Nov 2023 01:32:06 +0000 (09:32 +0800)
committerp15692025051 <846603105@qq.com>
Mon, 27 Nov 2023 01:32:06 +0000 (09:32 +0800)
13 files changed:
2.sdk/project/D10/merge_bin.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/EventMesh.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/appWechat.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/led.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/location.py [deleted file]
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_1.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/sleep_test.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/ui.py

index ed21894..37e4cee 100644 (file)
@@ -12,7 +12,7 @@ output_list = []
 # 文件名--》下标
 def text_to_hash(filename: str) -> str:
     output_list.append(filename.split("\\")[-1][:-4])
-    print(str(len(output_list)-1) + filename[-4:])
+    EventMesh.debug_log(str(len(output_list)-1) + filename[-4:])
     return str(len(output_list)-1) + filename[-4:]
 
 
@@ -30,17 +30,17 @@ def merge_bin(res='res.bin', *args):
     fileheader = bytes("montage", 'utf-8') + bytes(1) + bytes.fromhex('%08X' % len(file_list))[::-1]
     filebyte, bytesize, filebody = b'', 0, b''
     for i in file_list:
-        print(i)
+        EventMesh.debug_log(i)
         filename_byte = bytes(text_to_hash(i), 'utf-8')
         filebyte += (filename_byte + bytes(128-len(filename_byte)) + bytes.fromhex('%08X' % (len(file_list)*136 + 12 + bytesize))[::-1] + bytes.fromhex('%08X' % os.path.getsize(i))[::-1])
         bytesize += os.path.getsize(i)
         filebody += open(i, 'rb').read()
     f.write(fileheader + filebyte + filebody)
     f.close()
-    print(output_list)
+    EventMesh.debug_log(output_list)
     with open('list.json', 'w') as f:
         f.write(str(output_list))
-    print("----MERGE SUCCESS----")
+    EventMesh.debug_log("----MERGE SUCCESS----")
     return output_list
 
 output_list = merge_bin("D:\\1.workspace\\3.ASR\\2.G5\\1.Code\\ASR1603_G5\\2.sdk\\project\\D10\\audio.bin", "D:\\1.workspace\\3.ASR\\2.G5\\1.Code\\ASR1603_G5\\2.sdk\\project\\D10\\audio\\")
\ No newline at end of file
index 960db2b..a2c05dd 100644 (file)
@@ -92,12 +92,22 @@ def callback_wrapper(callback):#按键回调
 
 
 import utime
-Txt_Log = 1
+import uos
+debug_Log = 0
+def debug_log(*data):
+    if debug_Log != 0 :
+        print(data)
+Txt_Log = 0
 def txt_log(data):
-    pass
-    # if Txt_Log != 0 :
-    #     with open("/usr/log.txt","a",encoding="utf-8") as fd:
-    #         d_time = utime.localtime()
-    #         data_tmp = "%02d-%02d %02d:%02d:%02d :"%(d_time[1],d_time[2],d_time[3],d_time[4],d_time[5])
-    #         fd.write(data_tmp+data+"\n")
-
+    if Txt_Log != 0 :
+        print(data)
+        try:
+            f_stat = uos.stat("ext/log.txt")
+            if f_stat[6] >50*1024:
+                uos.remove("ext/log.txt") 
+        except Exception as e:
+            usys.print_exception(e)
+        with open("/ext/log.txt","a",encoding="utf-8") as fd:
+            d_time = utime.localtime()
+            data_tmp = "%02d-%02d %02d:%02d:%02d :"%(d_time[1],d_time[2],d_time[3],d_time[4],d_time[5])
+            fd.write(data_tmp+data+"\n")
index 44ce391..405f372 100644 (file)
@@ -67,7 +67,7 @@ style_alarm_screen_default.set_pad_bottom(0)
 
 # -------------------------------------------clk_list screen----------------------------------------------------------
 clk_list_screen = lv.obj()
-print("clk_list_screen")
+EventMesh.debug_log("clk_list_screen")
 clk_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_list_title_bg= lv.btn(clk_list_screen)
@@ -121,7 +121,7 @@ no_add_alarm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
 # -------------------------------------------clk_edit screen----------------------------------------------------------
 
 clk_edit_screen = lv.obj()
-print("clk_edit_screen")
+EventMesh.debug_log("clk_edit_screen")
 clk_edit_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_edit_title = lv.label(clk_edit_screen)
@@ -170,7 +170,7 @@ clk_delete_alarm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.
 
 # -------------------------------------------clk_repeat screen----------------------------------------------------------
 clk_repeat_screen = lv.obj()
-print("clk_repeat_screen")
+EventMesh.debug_log("clk_repeat_screen")
 clk_repeat_screen.set_scrollbar_mode(0)
 clk_repeat_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
 
@@ -339,7 +339,7 @@ clk_repeat_switch6.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.IN
 
 # -------------------------------------------clk_repeat screen----------------------------------------------------------
 clk_time_screen = lv.obj()
-print("clk_time_screen")
+EventMesh.debug_log("clk_time_screen")
 clk_time_screen.set_scrollbar_mode(0)
 clk_time_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
 
@@ -442,9 +442,9 @@ class ClockManager(Abstract):
 
     def set(self, event, msg):
         global alarm_list
-        print("msg = {}".format(msg))
+        EventMesh.debug_log("msg = {}".format(msg))
         idx = msg.get("idx")
-        print("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
+        EventMesh.debug_log("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
         alarm_list[idx]["hour"] = msg["hour"]
         alarm_list[idx]["minute"] = msg["minute"]
         alarm_list[idx]["days"] = msg["days"]
@@ -456,7 +456,7 @@ class ClockManager(Abstract):
     def read_alarminjson(self, event, msg):
         IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") 
         global alarm_list     
-        print("IFEXIST:{}".format(IFEXIST))
+        EventMesh.debug_log("IFEXIST:{}".format(IFEXIST))
         if IFEXIST == True:
             with open("/usr/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
                 alarm_list = ujson.load(fd)
@@ -472,7 +472,7 @@ class ClockManager(Abstract):
         count = 1
         new = 0
         num = 0
-        print("msg:{}".format(msg))
+        EventMesh.debug_log("msg:{}".format(msg))
         # if msg[0] == 1:
         # msg_new = msg[1]
         for i in range(0,2):#开关机固定是 idx 0 1
@@ -484,7 +484,7 @@ class ClockManager(Abstract):
             EventMesh.publish("set_boot_off_time",[msg[0],msg[1],msg[2]])
             if alarm_list and new == 0 :
                 for x in range(0,5):
-                    # print("count :{} self.alarm_list:111111{} len(self.alarm_list):{}".format(count,alarm_list,len(alarm_list)))
+                    # EventMesh.debug_log("count :{} self.alarm_list:111111{} len(self.alarm_list):{}".format(count,alarm_list,len(alarm_list)))
                     if new == 1 and count > len(alarm_list):
                         break
                     tmp = alarm_list[count-1]['idx']
@@ -493,37 +493,37 @@ class ClockManager(Abstract):
                         count+=1
                         if count > len(alarm_list):
                             new = 1
-                        # print("self.alarm_list:5555 {}".format(alarm_list))
+                        # EventMesh.debug_log("self.alarm_list:5555 {}".format(alarm_list))
                         break
                     else:#添加最新的
                         count+=1
                         if tmp == 2 or tmp == 3 or tmp == 4:#添加最新的
                             msg_tmp = EventMesh.publish("get_boot_off_time")
-                            # print("msg_tmp all_data {}".format(msg_tmp))
+                            # EventMesh.debug_log("msg_tmp all_data {}".format(msg_tmp))
                             if msg_tmp != None: 
                                 if len(msg_tmp[0]) > 0:#只有关机时间长度为0时才添加新元素 不是就覆盖原来旧的数据
-                                    # print("self.alarm_list:444444 {}".format(alarm_list))
+                                    # EventMesh.debug_log("self.alarm_list:444444 {}".format(alarm_list))
                                     if count > len(alarm_list):
                                         new = 1
                                     continue
                                 else:
                                     alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10}) 
-                                    # print("self.alarm_list:7777777 {}".format(alarm_list))
+                                    # EventMesh.debug_log("self.alarm_list:7777777 {}".format(alarm_list))
                                     if count > len(alarm_list):
                                         new = 1
                                     break
                     count+=1
-                    # print("self.alarm_list:111111 {}".format(alarm_list))
+                    # EventMesh.debug_log("self.alarm_list:111111 {}".format(alarm_list))
                     
             else:#添加最新的
                 alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10})
                 new = 1
             num+=1
-            # print("add_here-----idx:{} msg:{} alarm_list:{}".format(idx,msg,alarm_list))
+            # EventMesh.debug_log("add_here-----idx:{} msg:{} alarm_list:{}".format(idx,msg,alarm_list))
             
         # else:
         #     msg_tmp = msg[1]
-        #     # print("alarm_list:{} alarm_new_old:{} msg_tmp:{}",alarm_new,alarm_new_old,msg_tmp)
+        #     # EventMesh.debug_log("alarm_list:{} alarm_new_old:{} msg_tmp:{}",alarm_new,alarm_new_old,msg_tmp)
         #     num = 2
         #     count = 1
         #     j=0
@@ -555,7 +555,7 @@ class ClockManager(Abstract):
         #             if alarm_list and new == 0 :
         #                 for x in range(0,5):
                         
-        #                     print("count :{} self.alarm_new:111111{} len(self.alarm_new):{} ".format(count,alarm_list,len(alarm_list)))
+        #                     EventMesh.debug_log("count :{} self.alarm_new:111111{} len(self.alarm_new):{} ".format(count,alarm_list,len(alarm_list)))
                             
         #                     tmp = alarm_list[count-1]['idx']
         #                     if tmp == 2 or tmp == 3 or tmp == 4 :#覆盖旧的
@@ -563,33 +563,33 @@ class ClockManager(Abstract):
         #                         count+=1
         #                         if count > len(alarm_list):
         #                             new = 1
-        #                         print("self.alarm_list:5555 {}".format(alarm_list))
+        #                         EventMesh.debug_log("self.alarm_list:5555 {}".format(alarm_list))
         #                         break
         #                     else:#添加最新的
         #                         count+=1
         #                         if tmp == 0 or tmp == 1:#添加最新的
         #                             msg_data = EventMesh.publish("get_boot_off_time")
-        #                             print("msg_data all_data {}".format(msg_data))
+        #                             EventMesh.debug_log("msg_data all_data {}".format(msg_data))
         #                             if msg_data != None: 
         #                                 if msg_data[1] > 0:#只有关机时间长度为0时才添加新元素 不是就覆盖原来旧的数据
-        #                                     print("self.alarm_list:444444 {}".format(alarm_list))
+        #                                     EventMesh.debug_log("self.alarm_list:444444 {}".format(alarm_list))
         #                                     if count > len(alarm_list):
         #                                         new = 1
         #                                     continue
         #                                 else:
         #                                     alarm_list.append({"idx": num, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num}) 
-        #                                     print("self.alarm_list:7777777 {}".format(alarm_list))
+        #                                     EventMesh.debug_log("self.alarm_list:7777777 {}".format(alarm_list))
         #                                     if count > len(alarm_list):
         #                                         new = 1
         #                                     break
         #                     count+=1
-        #                     print("self.alarm_list:111111 {}".format(alarm_list))
+        #                     EventMesh.debug_log("self.alarm_list:111111 {}".format(alarm_list))
         #             else:#添加最新的
         #                 alarm_list.append({"idx": num, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
         #                 new = 1
         #         num+=1
         
-        print("alarm_list----len- :{}".format(len(alarm_list)))
+        EventMesh.debug_log("alarm_list----len- :{}".format(len(alarm_list)))
         with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
         EventMesh.publish("push_update_alarm_show")
@@ -601,22 +601,22 @@ class ClockManager(Abstract):
 
     def remove_alarm(self, event, msg):
         global alarm_list
-        print("ddddddddddddddddddd:",msg)
+        EventMesh.debug_log("ddddddddddddddddddd:",msg)
         idx = msg.get("idx")
-        print("delete_here1-----{},{}:".format(idx,msg))
+        EventMesh.debug_log("delete_here1-----{},{}:".format(idx,msg))
 
         for i, alarm in enumerate(alarm_list):
-            print("delete_here2-----{},{}:".format(i,alarm))
+            EventMesh.debug_log("delete_here2-----{},{}:".format(i,alarm))
 
             if alarm["idx"] == idx:
                 del alarm_list[i]
-                print("delete_here3-----",alarm_list)
+                EventMesh.debug_log("delete_here3-----",alarm_list)
 
                 #删除闹钟后,对idx重新排序
                 if alarm_list:
                     for j in range(i,len(alarm_list)):
                         alarm_list[j]["idx"] -= 1
-                        print("delete_here4-----",alarm_list)
+                        EventMesh.debug_log("delete_here4-----",alarm_list)
 
         with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
@@ -626,18 +626,18 @@ class ClockManager(Abstract):
         return self.idx
 
     def _rtc_callback(self,args):
-        print("---!!!!!!alarm_ring!!!!!!!---,idx:",args)
+        EventMesh.debug_log("---!!!!!!alarm_ring!!!!!!!---,idx:",args)
         global alarm_list
         EventMesh.publish("read_alarminjson")
         idx = self.idx
-        print("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
+        EventMesh.debug_log("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
         #判断是否是单次闹钟,如果是,则将开关状态设置为关闭
         # for i in range(len(alarm_list)):
         #     if alarm_list[i]["idx"] == self.idx:
         #         idx = i
         if not alarm_list[idx]["days"] :
-            print("关闭1:",alarm_list[idx]["days"])
-            print("关闭2:",alarm_list [idx]["days"])
+            EventMesh.debug_log("关闭1:",alarm_list[idx]["days"])
+            EventMesh.debug_log("关闭2:",alarm_list [idx]["days"])
             alarm_list[idx]["enabled"] = False
             with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
                 ujson.dump(alarm_list,fd)
@@ -645,7 +645,7 @@ class ClockManager(Abstract):
         #设置下一个闹钟,定时开关机功能
         if 0 :
             msg_data = EventMesh.publish("get_boot_off_time")
-            print("msg_tmp:{}".format(msg_data))
+            EventMesh.debug_log("msg_tmp:{}".format(msg_data))
             
             off_on = msg_data[0]
             off_tmp2  = msg_data[2]
@@ -655,7 +655,7 @@ class ClockManager(Abstract):
             rtc_now_time = self.rtc.datetime()
             current = rtc_now_time[4]*60+rtc_now_time[5]
             
-            print("end_min:{} current:{} off_tmp2:{}".format(end_min,current,off_tmp2))
+            EventMesh.debug_log("end_min:{} current:{} off_tmp2:{}".format(end_min,current,off_tmp2))
             if off_on != None:
                 if off_on == 1:#开关使能打开
                     if end_min == current:#结束的时间分钟等于关机时间分钟数则关机
@@ -671,24 +671,24 @@ class ClockManager(Abstract):
         # EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃
                 # EventMesh.publish("load_screen", {"screen": "popup_alarm"})
     # def _reset_rtc_alarm_time(self, args):
-    #     print("---alarm_ring---")
+    #     EventMesh.debug_log("---alarm_ring---")
 
     def set_rtc_alarm(self,event,msg):
         global alarm_list
         EventMesh.publish("read_alarminjson")
         rtc_now_time = self.rtc.datetime()
 
-       # print("00获取所有闹钟信息:{}".format(alarm_list))
+       # EventMesh.debug_log("00获取所有闹钟信息:{}".format(alarm_list))
         new_alarm_list = [(alarm['hour'], alarm['minute'], alarm['days'],alarm["idx"]) for alarm in alarm_list if alarm['enabled']]
 
-        print("01获取开启的闹钟:{}".format(new_alarm_list))
+        EventMesh.debug_log("01获取开启的闹钟:{}".format(new_alarm_list))
         start_day = 0 # 周日
         start_minute = 0 # 0点
         end_minute = 60*24*7
         minute_list = []
 
         if not new_alarm_list:
-            print("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
+            EventMesh.debug_log("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
             self.rtc.enable_alarm(0)
             return
         
@@ -703,25 +703,25 @@ class ClockManager(Abstract):
                 #如果当前时间没超过闹钟设置时间,则设置为今天,否则设置为明天
                 if (hour*60 + minute) > (rtc_now_time[4]*60 + rtc_now_time[5]):
                     minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day)*24*60)
-                    print("设置单次闹钟:{}".format(new_alarm_list))
+                    EventMesh.debug_log("设置单次闹钟:{}".format(new_alarm_list))
 
                 else:
                     minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day+1)*24*60)
         
         total_minutes = sorted(minute_list)
-        print("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
+        EventMesh.debug_log("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
 
         #获取当前时间  (2020, 9, 11, 5, 15, 43, 23, 0)
         # rtc_now_time = (2020, 9, 11, 6, 11, 43, 23, 0)
         # rtc_now_time = self.rtc.datetime()
 
-        print("03当前的rtc时间:{}".format(rtc_now_time))  
+        EventMesh.debug_log("03当前的rtc时间:{}".format(rtc_now_time))  
 
         current_minute = rtc_now_time[4]*60 + rtc_now_time[5] + (rtc_now_time[3]-start_day)*24*60
-        print("04当前的rtc_total_minutes:{}".format(current_minute))  
+        EventMesh.debug_log("04当前的rtc_total_minutes:{}".format(current_minute))  
 
         if current_minute in minute_list:
-            print("当前时间和闹钟列表时间重复,删除重复的时间")
+            EventMesh.debug_log("当前时间和闹钟列表时间重复,删除重复的时间")
             minute_list.remove(current_minute)
 
         minute_list.append(current_minute)
@@ -730,37 +730,37 @@ class ClockManager(Abstract):
         minute_list = sorted(minute_list)
         current_index = minute_list.index(current_minute)
 
-        print("05将当前时间插入min_list后的min_list:{}".format(minute_list))  
-        print("06当前时间所在位置:{}".format(current_index))  
+        EventMesh.debug_log("05将当前时间插入min_list后的min_list:{}".format(minute_list))  
+        EventMesh.debug_log("06当前时间所在位置:{}".format(current_index))  
 
         next_index = current_index + 1
         if next_index >= len(minute_list):
             next_minute = minute_list[0]
-            print("07下一个闹钟的分钟数:", next_minute)
+            EventMesh.debug_log("07下一个闹钟的分钟数:", next_minute)
         else:
             next_minute = minute_list[next_index]
-            print("07下一个闹钟的分钟数:", next_minute)
+            EventMesh.debug_log("07下一个闹钟的分钟数:", next_minute)
 
         if next_minute >= current_minute:
             interval_minute = next_minute - current_minute
-            print("08距离下一次响铃的的分钟数:", interval_minute)
+            EventMesh.debug_log("08距离下一次响铃的的分钟数:", interval_minute)
         else:
             interval_minute = end_minute - current_minute + next_minute
-            print("08距离下一次响铃的的分钟数:", interval_minute)
+            EventMesh.debug_log("08距离下一次响铃的的分钟数:", interval_minute)
 
         #反向获取时间戳
         time = utime.localtime()
-        print("09获取utime的时间戳:", time)
+        EventMesh.debug_log("09获取utime的时间戳:", time)
         rtc_mktime = utime.mktime(time)
-        print("10反向获取utime的mktime:", rtc_mktime)
+        EventMesh.debug_log("10反向获取utime的mktime:", rtc_mktime)
 
         #加上下一次响铃需要的时间
         next_alarm_mktime = rtc_mktime + interval_minute*60
-        print("11下一次响铃的mktime:", next_alarm_mktime)
+        EventMesh.debug_log("11下一次响铃的mktime:", next_alarm_mktime)
 
         #格式化时间戳,得到下一次闹钟的时间
         next_alarm_time = utime.localtime(next_alarm_mktime)
-        print("12下一次响铃的准确时间:", next_alarm_time)
+        EventMesh.debug_log("12下一次响铃的准确时间:", next_alarm_time)
         #将时间转换为rtc的格式
         data_l = [2021, 7, 9, 5, 12, 30, 0, 0]
         #给rtc时间赋值
@@ -771,11 +771,11 @@ class ClockManager(Abstract):
         data_l[5] = next_alarm_time[4] #minute               
         #转换为元组       
         data_e=tuple(data_l)
-        print("13将该时间转换为RTC元组:", data_e)
+        EventMesh.debug_log("13将该时间转换为RTC元组:", data_e)
        
         for alarm in alarm_list:
             if not alarm["days"] and alarm["enabled"]:
-                print("关闭666:",alarm["idx"])
+                EventMesh.debug_log("关闭666:",alarm["idx"])
                 if alarm["hour"] == data_l[4] and alarm["minute"]==data_l[5]:
                     self.idx = alarm["idx"]
         #设置rtc闹钟时间
@@ -783,15 +783,15 @@ class ClockManager(Abstract):
 
         FLAG = self.rtc.set_alarm(data_e)
         if FLAG == 0:
-            print("14成功设置rtc的到期时间:", data_e)
+            EventMesh.debug_log("14成功设置rtc的到期时间:", data_e)
         else:
-            print("14设置rtc的到期时间失败:", data_e)
+            EventMesh.debug_log("14设置rtc的到期时间失败:", data_e)
         
         self.rtc.enable_alarm(1)
            
 #闹钟弹窗
 popup_alarm_screen = lv.obj()
-print("popup_alarm_screen")
+EventMesh.debug_log("popup_alarm_screen")
 popup_alarm_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 
@@ -895,7 +895,7 @@ class ClkListScreen(Screen):
     def initialization(self): 
         EventMesh.publish("read_alarminjson")
         EventMesh.publish("set_rtc_alarm")
-        print("n闹钟列表初始化!!")
+        EventMesh.debug_log("n闹钟列表初始化!!")
         self.alarm_draw_btn()
         
     def update_show_info(self,event,msg):
@@ -912,7 +912,7 @@ class ClkListScreen(Screen):
         IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json")    
         if IFEXIST == True:
             if self.clock_list:
-                # print("nalarm_list:{}".format(alarm_list))
+                # EventMesh.debug_log("nalarm_list:{}".format(alarm_list))
                 no_add_alarm_img.add_flag(lv.obj.FLAG.HIDDEN)
                 no_add_alarm.add_flag(lv.obj.FLAG.HIDDEN)
                 self.alarm_show_list.delete()#先删除一次控件
@@ -921,7 +921,7 @@ class ClkListScreen(Screen):
                 self.alarm_show_list.set_size(240, 255)
                 self.alarm_show_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
                 self.alarm_show_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-                #print("菜单的孩子个数:",clk_list_screen1.get_child_cnt())
+                #EventMesh.debug_log("菜单的孩子个数:",clk_list_screen1.get_child_cnt())
                 num = 0
                 count = 0
                 for i ,each in enumerate(self.clock_list):
@@ -939,7 +939,7 @@ class ClkListScreen(Screen):
                                             lv.EVENT.CLICKED, None)
 
                     
-                    # print("------刷新闹钟列表噢:{} num:{}",each,num)
+                    # EventMesh.debug_log("------刷新闹钟列表噢:{} num:{}",each,num)
                     _btn_label1 = lv.label(_btn)
                     _btn_label1.set_pos(50, 0)
                     _btn_label1.set_size(0, 0)
@@ -961,7 +961,7 @@ class ClkListScreen(Screen):
                     _btn_label3 = lv.label(_btn)
                     _btn_label3.set_pos(5, 44)
                     _btn_label3.set_size(200, 40)
-                    print("_new_list:{} repeart:{}".format(_new_list,repeart))
+                    EventMesh.debug_log("_new_list:{} repeart:{}".format(_new_list,repeart))
                     if repeart == 1:
                         _btn_label3.set_text("一次")
                     elif repeart == 2:
@@ -1007,7 +1007,7 @@ class ClkListScreen(Screen):
     def edit_alarm(self, e):#暂时屏蔽
         return
         idx = int(e.get_target().get_child(0).get_text())
-        print("edit!!!!!!!!!!!!:",idx)
+        EventMesh.debug_log("edit!!!!!!!!!!!!:",idx)
         clock_info = self.clock_list[idx]
         clock_info["idx"] = idx
 
@@ -1017,7 +1017,7 @@ class ClkListScreen(Screen):
 
         if len(self.clock_list) >= 3:
             return
-        print("!!!!!!!!!!!!!!!!!------")
+        EventMesh.debug_log("!!!!!!!!!!!!!!!!!------")
         EventMesh.publish("add_alarm")
         self.alarm_draw_btn()
 
@@ -1025,18 +1025,18 @@ class ClkListScreen(Screen):
     #     obj = e.get_target()
     #     idx = int(e.get_target().get_parent().get_child(0).get_text())
     #     clock_info = self.clock_list[idx]
-    #     print("修改闹钟开关:",self.clock_list[idx])
+    #     EventMesh.debug_log("修改闹钟开关:",self.clock_list[idx])
     #     clock_info["idx"] = idx
     #     if obj.has_state(lv.STATE.CHECKED):
-    #         print("ON ~~~")
+    #         EventMesh.debug_log("ON ~~~")
     #         clock_info["enabled"] = True
     #     else:
-    #         print("OFF ~~~")
+    #         EventMesh.debug_log("OFF ~~~")
     #         clock_info["enabled"] = False
     #     EventMesh.publish("push_clock_info", clock_info)
     #     EventMesh.publish("set_rtc_alarm")
 
-    #     print("sw_event_cb ~~~")
+    #     EventMesh.debug_log("sw_event_cb ~~~")
 
     def done_return(self):
         EventMesh.publish("load_screen", {"screen": "toolbox"})
@@ -1059,7 +1059,7 @@ class NewEditClk(Screen):
         clk_delete_alarm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.delete_alarm(e)), lv.EVENT.CLICKED, None)
 
     def initialization(self):  
-        print("hahahahh",self.meta_info["idx"])
+        EventMesh.debug_log("hahahahh",self.meta_info["idx"])
 
     def delete_alarm(self, e):
         EventMesh.publish("remove_alarm",self.meta_info)
@@ -1106,7 +1106,7 @@ class CLKTimeScreen(Screen):
         clk_time_roller_1.get_selected_str(option_1, len(option_1))
         option_1_strip = option_1.strip()[:2]
         option_2_strip = option_2.strip()[:2]
-        print("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip))
+        EventMesh.debug_log("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip))
         self.meta_info["hour"] = int(option_1_strip)
         self.meta_info["minute"] = int(option_2_strip)
         EventMesh.publish("push_clock_info", self.meta_info)
@@ -1152,7 +1152,7 @@ class ClkPeriod(Screen):
     def initialization(self):
         self.choice_list = self.meta_info["days"]
         self.alarm_info = self.meta_info
-        print("初始化:{},{}".format(self.alarm_info,self.choice_list))
+        EventMesh.debug_log("初始化:{},{}".format(self.alarm_info,self.choice_list))
 
 
         for i in range(0,6):
@@ -1167,17 +1167,17 @@ class ClkPeriod(Screen):
         if i in self.choice_list:
             self.clk_switch_list[i].clear_state(lv.STATE.CHECKED)
             self.choice_list.remove(i)
-            print("here1-----",self.choice_list,i)
+            EventMesh.debug_log("here1-----",self.choice_list,i)
 
         else:
             self.clk_switch_list[i].add_state(lv.STATE.CHECKED)
             self.choice_list.append(i)
-            print("here2-----",self.choice_list,i)
+            EventMesh.debug_log("here2-----",self.choice_list,i)
 
-        print("here-----",self.choice_list)
+        EventMesh.debug_log("here-----",self.choice_list)
         self.alarm_info["days"] = self.choice_list
 
-        print("编辑星期:{}".format(self.alarm_info))
+        EventMesh.debug_log("编辑星期:{}".format(self.alarm_info))
         if self.alarm_info["days"] == []:
             self.alarm_info["repeart"] = 1
         else:
index 58c3e1b..5bab8ba 100644 (file)
@@ -50,7 +50,7 @@ style_wechat_btn.set_shadow_opa(0)
 
 # -------------------------------------------wechat screen----------------------------------------------------------
 wechat_screen = lv.obj()
-print("wechat_screen")
+EventMesh.debug_log("wechat_screen")
 wechat_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
 wechat_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
 
@@ -608,7 +608,7 @@ class WechatScreen(Screen):
 #微聊弹窗
 
 wechat_popup_screen = lv.obj()
-print("wechat_popup_screen")
+EventMesh.debug_log("wechat_popup_screen")
 wechat_popup_screen.center()
 wechat_popup_screen.set_size(240, 320)
 wechat_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
index 2781fd1..6cbd554 100644 (file)
@@ -211,24 +211,24 @@ class intervManager(Abstract):
     def audio_event_queue_thread(self):
         while True:
             data = self.audio_event_queue.get()
-            #print("audio_event_queue:data = {}".format(data))
+            #EventMesh.debug_log("audio_event_queue:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
-                    print("audio_event_queue:ERROR:{}".format(e))
+                    EventMesh.debug_log("audio_event_queue:ERROR:{}".format(e))
                     usys.print_exception(e)
     def publish_message_event_audio(self,event,msg):
         self.audio_event_queue.put(msg)
 
     def play_audio_file(self, *args, **kwargs):#拨打电话
-        # print("args",args)
+        # EventMesh.debug_log("args",args)
         EventMesh.publish("publish_message_event_audio",{"func":self.play_audio_file_do,"data":args[1]})  
 
     def play_audio_file_do(self,data):#msg 拼接的路径文件
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         power_off = EventMesh.publish("get_power_off_state")#获取开机标识
-        # print("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断
+        # EventMesh.debug_log("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断
         if open_power != None:
             if open_power == 0:
                 return
@@ -236,19 +236,19 @@ class intervManager(Abstract):
             if power_off == 1:
                 return
         self.aud.montage_play('U:/static/audio.bin',1,data[1],data[0])
-        # print("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断
+        # EventMesh.debug_log("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断
         
 
 
     def interInfo_queue_thread(self):
         while True:
             data = self.interInfo_queue.get()
-            #print("interInfo_queue_thread:data = {}".format(data))
+            #EventMesh.debug_log("interInfo_queue_thread:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
-                    print("interInfo_queue_thread:ERROR:{}".format(e))
+                    EventMesh.debug_log("interInfo_queue_thread:ERROR:{}".format(e))
                     usys.print_exception(e)
 
     def publish_message_event_interInfo(self,event,msg):
@@ -295,7 +295,7 @@ class intervManager(Abstract):
 
 
     def close_timer_all(self, event, msg): 
-        # print("close_timer_all!!!!!!!!!!!!!!!!!!!")
+        # EventMesh.debug_log("close_timer_all!!!!!!!!!!!!!!!!!!!")
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         power_off = EventMesh.publish("get_power_off_state")#获取开机标识
         if open_power != None:
@@ -362,7 +362,7 @@ class intervManager(Abstract):
         if power_off != None:
             if power_off == 1:
                 return
-        # print("dial_out_call_center_cb",msg)
+        # EventMesh.debug_log("dial_out_call_center_cb",msg)
         if self.call_state == 0:
             self.phone_num = ''
             EventMesh.publish("close_timer_all")#
@@ -390,7 +390,7 @@ class intervManager(Abstract):
             if power_off == 1:
                 return
         self.sos_phone_num = ''
-        # print("sos_out_call_center_cb",msg)
+        # EventMesh.debug_log("sos_out_call_center_cb",msg)
         if self.call_state == 0:
             EventMesh.publish("close_timer_all")#
             if msg == None:
@@ -437,7 +437,7 @@ class intervManager(Abstract):
         if flag != 2:#电话通话中 或者呼叫中挂断中断
             EventMesh.publish("close_timer_all")#
             step = EventMesh.publish("get_old_step_value")
-            print("step",step)
+            EventMesh.debug_log("step",step)
             self.setp_old = step
             if step <= 10:#
                 if step == 10:#十步
@@ -693,7 +693,7 @@ class intervManager(Abstract):
                 self.aud.play(1,1,'U:/static/R_CHARGE_IN.mp3')
                 # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN"))
                 # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-            print("charge R_CHARGE_IN")
+            EventMesh.debug_log("charge R_CHARGE_IN")
             
             
         elif msg == 2:
@@ -701,7 +701,7 @@ class intervManager(Abstract):
             EventMesh.publish("stop_led_timer")#设置参数
             # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
             EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
-            print("charge R_CHARGE_OUT")
+            EventMesh.debug_log("charge R_CHARGE_OUT")
             if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断
                 EventMesh.publish("close_timer_all")#
                 self.aud.stop()
@@ -713,7 +713,7 @@ class intervManager(Abstract):
 
         elif msg == 3:
             self.usbState = msg
-            print("charge full")
+            EventMesh.debug_log("charge full")
             str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
             EventMesh.publish("set_led_time_arg",str_buf)#
             if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断
@@ -799,7 +799,7 @@ class intervManager(Abstract):
     
     def power_on_audio_cb(self, msg):
         self.power_on_flag = 1
-        # print("power_on_audio_cb")
+        # EventMesh.debug_log("power_on_audio_cb")
         self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
         # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
         # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
@@ -812,7 +812,7 @@ class intervManager(Abstract):
         return self.power_on_flag
     
     def power_off_audio_cb(self, msg):
-        # print("power_off_audio_cb")
+        # EventMesh.debug_log("power_off_audio_cb")
         self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
         # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
         # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
@@ -822,7 +822,7 @@ class intervManager(Abstract):
         self.pwk_timer2.start(7000,0,self.publish_power_down_event_cb)
     
     def power_off_no_audio_cb(self, msg):
-        print("power_off_no_audio_cb")
+        EventMesh.debug_log("power_off_no_audio_cb")
         EventMesh.publish("set_led_time_arg",[1,2,6*8,led_mode.FLASH_LIGHT_RED,6,3,led_mode.POWER_OFF_MODE])#
         
         self.pwk_timer1.start(2000,0,self.set_power_off_cb)
@@ -841,14 +841,14 @@ class intervManager(Abstract):
         if get_hr_state != None or get_spo2_state != None or get_temp_state != None:
             if get_hr_state != 0:
                 EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
-                print("sstop hr")
+                EventMesh.debug_log("sstop hr")
                 EventMesh.publish(constants.EVENT.STOP_HEART) 
             elif get_spo2_state != 0:
-                print("stop spo2")
+                EventMesh.debug_log("stop spo2")
                 EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
             if get_temp_state != 0:
-                print("stop temp")
+                EventMesh.debug_log("stop temp")
                 EventMesh.publish("set_temp_state",0)
                 EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
 
@@ -858,7 +858,7 @@ class intervManager(Abstract):
         get_temp_state = EventMesh.publish("get_temp_state")
         if msg == 1:
             if get_hr_state != 1:#不是手动测试直接打断
-                print("set_manual_measure_mode",msg)
+                EventMesh.debug_log("set_manual_measure_mode",msg)
                 EventMesh.publish("set_hr_state",1)
                 EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
@@ -866,13 +866,13 @@ class intervManager(Abstract):
         elif msg == 2:
             if get_hr_state == 0:
                 if get_spo2_state != 1:
-                    print("set_manual_measure_mode",msg)
+                    EventMesh.debug_log("set_manual_measure_mode",msg)
                     EventMesh.publish("set_spo2_state",1)
                     EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
                     EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
         elif msg == 3:
             if get_temp_state != 1:
-                print("set_manual_measure_mode",msg)
+                EventMesh.debug_log("set_manual_measure_mode",msg)
                 EventMesh.publish("set_temp_state",1)
                 EventMesh.publish("set_start_temp_measure_time")#设置开始测量的时间戳时间
                 EventMesh.publish(constants.EVENT.START_TEMP)#手动体温测试
@@ -1169,7 +1169,7 @@ class intervManager(Abstract):
 
     def FIND_timer_cb(self, data):
         if self.find_state == 1:
-            # print("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+            # EventMesh.debug_log("self.FIND_timer_count:{}".format(self.FIND_timer_count))
             str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_find_haixiu"))
             EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             self.FIND_timer_count += 1
@@ -1210,7 +1210,7 @@ class intervManager(Abstract):
 
     def Alarm_timer_cb(self, data):
         if self.alarm_state == 1:
-            # print("self.alarm_timer_count:{}".format(self.alarm_timer_count))
+            # EventMesh.debug_log("self.alarm_timer_count:{}".format(self.alarm_timer_count))
             str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
             EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             self.alarm_timer_count += 1
@@ -1226,7 +1226,7 @@ class intervManager(Abstract):
             data = RTC().datetime()
             hour = data[4]
             min = data[5]
-            # print("hour",hour,min)
+            # EventMesh.debug_log("hour",hour,min)
             self.old_hour = hour
             self.old_min = min
             if self.old_hour == 0:
@@ -1414,7 +1414,7 @@ class intervManager(Abstract):
                     str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
                     EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             else:#未设置号码
-                # print("play_center_phone")
+                # EventMesh.debug_log("play_center_phone")
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
                 pass
@@ -1425,7 +1425,7 @@ class intervManager(Abstract):
         if flag != 2:#电话通话中 或者呼叫中挂断中断
             EventMesh.publish("close_timer_all")#
             imei = EventMesh.publish(constants.EVENT.GET_IMEI)
-            print(imei)
+            EventMesh.debug_log(imei)
             str_data = 'mp3files={}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(imei[0]))\
             ,audio_buf.index("R_READ_TIME_{}".format(imei[1])),audio_buf.index("R_READ_TIME_{}".format(imei[2])),audio_buf.index("R_READ_TIME_{}".format(imei[3])),\
             audio_buf.index("R_READ_TIME_{}".format(imei[4])),audio_buf.index("R_READ_TIME_{}".format(imei[5])),audio_buf.index("R_READ_TIME_{}".format(imei[6])),audio_buf.index("R_READ_TIME_{}".format(imei[7])),\
@@ -1446,14 +1446,14 @@ class intervManager(Abstract):
         return [self.MXA_MSG ,self.wechat_recode_list]
     
     def set_wechat_data(self, event, msg): 
-        # print("set_wechat_data1 ",msg,self.wechat_num)
+        # EventMesh.debug_log("set_wechat_data1 ",msg,self.wechat_num)
         self.MXA_MSG = msg[0]
         self.wechat_recode_list = msg[1]
         self.wechat_num = self.wechat_recode_list["num"]
         with open("/usr/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
             ujson.dump(self.wechat_recode_list,fd)
             #写编号
-        # print("set_wechat_data2:{} ".format(self.wechat_num))
+        # EventMesh.debug_log("set_wechat_data2:{} ".format(self.wechat_num))
        
 
     def get_wechat_time(self, event, msg):
@@ -1475,7 +1475,7 @@ class intervManager(Abstract):
                     self.timeSecond = time_tmp#保存按下的时间长s
                     self.aud.setVolume(11)#设置音量最大
                     
-                    print("talking1.0")
+                    EventMesh.debug_log("talking1.0")
                     if self.wechat_num >= self.MXA_MSG:
                         self.wechat_num = 0 
                     self.wechat_num += 1
@@ -1508,13 +1508,13 @@ class intervManager(Abstract):
             else:
                 self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:0"
                 self.wechat_recode_list["num"] = self.wechat_show
-                print("self.wechat_recode_list :{}".format(self.wechat_recode_list))
+                EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list))
 
 
 
                 with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
                     ujson.dump(self.wechat_recode_list,fd)
-                # print("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+                # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
 
                 check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
                 if check_txt == True :
@@ -1550,7 +1550,7 @@ class intervManager(Abstract):
                 play_state = 0
                 if len(self.wechat_recode_list) > 1:
                     num = int(self.wechat_recode_list["num"])
-                    #print("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
+                    #EventMesh.debug_log("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
                     if num != 0:
                         last_num = str("%02d"%(num))
                         last_tmp = self.wechat_recode_list[last_num]
@@ -1563,11 +1563,11 @@ class intervManager(Abstract):
                         else:
                             sotr_new = {}
                             sotr_new = sorted(self.wechat_recode_list.keys(), reverse=True)#降序排序
-                            # print("sotr_new:{}".format(sotr_new))
+                            # EventMesh.debug_log("sotr_new:{}".format(sotr_new))
                             for i in range(len(self.wechat_recode_list)-1):#1 01 02 
                                 key = sotr_new[i+1]
                                 num_id = int(key)
-                                #print("key:{} num_id:{}".format(key,num_id))
+                                #EventMesh.debug_log("key:{} num_id:{}".format(key,num_id))
                                 if key in self.wechat_recode_list:#
                                     str_tmp = self.wechat_recode_list[key]
                                     read = int(str_tmp.split(":")[1])
@@ -1576,7 +1576,7 @@ class intervManager(Abstract):
                                         if check_amr == True:
                                             self.wechat_recode_list[key] = "read:0"
                                             self.wechat_recode_list["num"] = num 
-                                            print("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
+                                            EventMesh.debug_log("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
                                             # self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num))  #文件名前面要加上路径
                                             play_state = 1
                                             with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
@@ -1588,7 +1588,7 @@ class intervManager(Abstract):
                                         continue
                                 else:
                                     continue
-                        #print("play_state:{}".format(play_state))
+                        #EventMesh.debug_log("play_state:{}".format(play_state))
                         # if play_state == 0:#
                         check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
                         if check_amr == True:
@@ -1698,12 +1698,12 @@ class BtnDevice(Abstract):
     def btnInfo_queue_thread(self):
         while True:
             data = self.btnInfo_queue.get()
-            #print("Info_queue:data = {}".format(data))
+            #EventMesh.debug_log("Info_queue:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
-                    print("btnInfo_queue:ERROR:{}".format(e))
+                    EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
                     usys.print_exception(e)
     def publish_message_event_btnInfo(self,event,msg):
         self.btnInfo_queue.put(msg)
@@ -1739,7 +1739,7 @@ class BtnDevice(Abstract):
 
     def pwk_extint_cb(self,args):#侧边按键
         self.GPIO26_status = self.extint.read_level()
-        # print('### key20_extint_cb  {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+        # EventMesh.debug_log('### key20_extint_cb  {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
         power_off = EventMesh.publish("get_power_off_state")#获取关机标识
         if power_off != None:
             if power_off == 1:
@@ -1762,7 +1762,7 @@ class BtnDevice(Abstract):
                     self.pwkey_count = 0
                     self.led_state = 0
                     self.pwkey_timer.start(100, 1, self.publish_pwkKey_btn_event_cb)
-                    # print("key22_extint_cb:self.key22_timer.start!!!!\n")
+                    # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
 
     def pwKey_press_cb(self, data):
         '''KEY2:联动屏幕右下角或返回键长按关机'''
@@ -1787,7 +1787,7 @@ class BtnDevice(Abstract):
             
             if self.GPIO26_status == 1:#松开
                 if self.pwkey_count >= 1: #防抖100ms
-                    # print("self.GPIO26_status == 1")
+                    # EventMesh.debug_log("self.GPIO26_status == 1")
                     self.pwkey_timer.stop()
                     self.pwkey_count = 0
                     self.pwkey_press = 0
@@ -1798,7 +1798,7 @@ class BtnDevice(Abstract):
     def  hsensorTest_timer_cb(self,e):
         EventMesh.publish("system_sleep_rest")#防止黑屏 
         w_data = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
-        #print("FactoryModeHsensorTest{}".format(data))
+        #EventMesh.debug_log("FactoryModeHsensorTest{}".format(data))
     
         c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
         # text_data = "   佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}".format(
@@ -1808,7 +1808,7 @@ class BtnDevice(Abstract):
         if(self.hsensorTest_timer_count != 0):
                 self.hsensorTest_timer_count -= 1
                 if self.hsensorTest_timer_count%5 == 0:
-                    print("c_data:{} {} {} {}".format(c_data[11],c_data[12],c_data[13],c_data[14]))
+                    EventMesh.debug_log("c_data:{} {} {} {}".format(c_data[11],c_data[12],c_data[13],c_data[14]))
                     if c_data[11] != 0 and c_data[13] != 0: #校准成功
                         str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
                         EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
@@ -1830,11 +1830,11 @@ class BtnDevice(Abstract):
         boot_count = EventMesh.publish("get_boot_time_count")
         try :
             if boot_count < 50 :#开机50秒内按键次数大于10就校准
-                #print("boot_count:{}".format(boot_count))
+                #EventMesh.debug_log("boot_count:{}".format(boot_count))
                 if self.pwKey_press_count >= 10:
                     self.Hsensor =  EventMesh.publish("get_Hsensor")
                     self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb) 
-                    print("打开校准模式")
+                    EventMesh.debug_log("打开校准模式")
                     self.Hsensor.set_sar(1)
                     self.Hsensor.open_test(255) #打开校准模式
                     utime.sleep_ms(500)
@@ -1849,7 +1849,7 @@ class BtnDevice(Abstract):
         except Exception as e:
             usys.print_exception(e)
         if self.pwKey_press_count >= 1:
-            # print("pwKey_timeout_cb:self.pwKey_press_count >= 1")
+            # EventMesh.debug_log("pwKey_timeout_cb:self.pwKey_press_count >= 1")
             EventMesh.publish("stop_led_timer")#设置参数
             EventMesh.publish("dialing_out_event")#电话呼叫中voiceCall.callEnd()
             
@@ -1873,7 +1873,7 @@ class BtnDevice(Abstract):
             if power_off == 1:
                 return
         self.sosKey_status = self.sosKey.read_level()
-        # print('### key22_extint_cb  {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+        # EventMesh.debug_log('### key22_extint_cb  {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
         if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
             if self.sosKey_status == 0:#按下
                 if self.sosKey_press == 0 :
@@ -1891,7 +1891,7 @@ class BtnDevice(Abstract):
                     self.sosKey_long_press = 0
                     self.sosKey_count = 0
                     self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
-        # print("key22_extint_cb:self.key22_timer.start!!!!\n")
+        # EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
 
     def sosKey_press_cb(self, data):
         '''KEY2:联动屏幕右下角或返回键长按关机'''
@@ -1910,7 +1910,7 @@ class BtnDevice(Abstract):
                 EventMesh.publish_async("dial_sos_phone")#拨打sos号码
                 return
 
-            # print("self.sosKey_count {}",self.sosKey_count)
+            # EventMesh.debug_log("self.sosKey_count {}",self.sosKey_count)
             if self.sosKey_status == 1:#松开
                 if self.sosKey_count >= 1: #防抖100ms
                     self.sosKey_timer.stop()
@@ -1921,7 +1921,7 @@ class BtnDevice(Abstract):
     def publish_sosKey_timeout_cb_do(self, *args, **kwargs):
         EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_timeout_cb,"data":0})  
     def sosKey_timeout_cb(self, data):#
-        # print("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
+        # EventMesh.debug_log("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
         if self.sosKey_press_count == 10:#
             self.sosKey_press_count = 0
             # EventMesh.publish("reset_factor_setiing")#
@@ -1983,7 +1983,7 @@ class BtnDevice(Abstract):
             if power_off == 1:
                 return
         self.WeChatKey_status = self.wechatKey.read_level()
-        # print('### wechatKey_extint_cb  {} self.WeChatKey_status:{}'.format(args,self.WeChatKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+        # EventMesh.debug_log('### wechatKey_extint_cb  {} self.WeChatKey_status:{}'.format(args,self.WeChatKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
         if self.sosKey_status != 0 and self.GPIO26_status != 0:
             if self.WeChatKey_status == 0:#按下
                 if self.wechatKey_press == 0:
@@ -2018,7 +2018,7 @@ class BtnDevice(Abstract):
                 time_tmp = utime.mktime(date_tmp)
                 time_sec = tmp[1]
                 wechat_time = time_tmp - time_sec
-                # print("close_btn_timer",time_tmp,time_sec,wechat_time)
+                # EventMesh.debug_log("close_btn_timer",time_tmp,time_sec,wechat_time)
                 if wechat_time >= 15:
                     wechat_time = 15
                 if wechat_time <= 0:
@@ -2075,7 +2075,7 @@ class BtnDevice(Abstract):
                                 if tmp[0] != 0:
                                     time_sec = tmp[1]
                                     wechat_time = time_tmp - time_sec
-                                # print("WECHAT TIEM",time_tmp,time_sec,wechat_time)
+                                # EventMesh.debug_log("WECHAT TIEM",time_tmp,time_sec,wechat_time)
                                 if wechat_time >= 15:
                                     wechat_time = 15
                             
@@ -2089,7 +2089,7 @@ class BtnDevice(Abstract):
 
             if self.WeChatKey_status == 1:#松开
                 if self.wechatKey_count >= 1: #防抖100ms
-                    # print("WeChat time!!!!!!!!!!!!!!")
+                    # EventMesh.debug_log("WeChat time!!!!!!!!!!!!!!")
                     self.wechatKey_timer.stop()
                     self.wechatKey_count = 0
                     self.wechatKey_press = 0
@@ -2100,7 +2100,7 @@ class BtnDevice(Abstract):
         EventMesh.publish("publish_message_event_btnInfo",{"func":self.wechatKey_timeout_cb,"data":0})  
 
     def wechatKey_timeout_cb(self,data):#微聊键
-        # print("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
+        # EventMesh.debug_log("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
         if self.wechatKey_press_count == 10:#短按十次解绑app
             self.wechatKey_press_count = 0
             EventMesh.publish("stop_led_timer")#设置参数
@@ -2144,49 +2144,49 @@ class BtnDevice(Abstract):
         if self.pwk_press == 1 :
             
             self.pwk_count += 1
-            print("self.pwk_count {}",self.pwk_count)
+            EventMesh.debug_log("self.pwk_count {}",self.pwk_count)
             if self.GPIO26_status == 1:#松开
                 if self.pwk_count >= 1: #防抖100ms
                     self.__pwk_timer.stop()
                     self.pwk_count = 0
                     self.pwk_press = 0
-                    print("self.GPIO22_status")
+                    EventMesh.debug_log("self.GPIO22_status")
 
             if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
                 self.__pwk_timer.stop()
                 self.pwk_count = 0
                 self.pwk_press = 0
-                print("btn8_long_press")
+                EventMesh.debug_log("btn8_long_press")
 
     def __ui_callback(self, para):
-       # print("para = {}".format(para))
+       # EventMesh.debug_log("para = {}".format(para))
         if para == 0:
             EventMesh.publish("done_left_to_right")
-            #print("<-")
+            #EventMesh.debug_log("<-")
         elif para == 1:
             EventMesh.publish("done_right_to_left")
-            #print("->")
+            #EventMesh.debug_log("->")
         elif para == 2:
             EventMesh.publish("done_bottom_to_top")
-            #print("^")
+            #EventMesh.debug_log("^")
         elif para == 3:
             EventMesh.publish("done_top_to_bottom")
-            #print("V")
+            #EventMesh.debug_log("V")
         elif para == 4:
             EventMesh.publish("done_return")
-            #print("return")
+            #EventMesh.debug_log("return")
         elif para == 5:
             EventMesh.publish("done_click")
-            #print("CLICK")
+            #EventMesh.debug_log("CLICK")
         elif para == 6:
             EventMesh.publish("done_press")
-            #print("press")
+            #EventMesh.debug_log("press")
         elif (para == 6):
             EventMesh.publish("done_error")
-            #print("error")
+            #EventMesh.debug_log("error")
 
     def key_callback(self, l_list):
-        print("key_callback:",str(l_list))
+        EventMesh.debug_log("key_callback:",str(l_list))
         if l_list[0] == 1:
             # 马达震动预留
             pass
@@ -2202,7 +2202,7 @@ class BtnDevice(Abstract):
 
 
     def powerKey_callback(self, status):
-        print('==pwr:', status)# 0 1 0
+        EventMesh.debug_log('==pwr:', status)# 0 1 0
         self.powerKey_status = status
         if self.pwk_press == 1: #按按钮时不处理
             return
index dca8c00..1262403 100644 (file)
@@ -155,12 +155,12 @@ class ledEventManager(Abstract):#灯事件
     def ledInfo_queue_thread(self):
         while True:
             data = self.ledInfo_queue.get()
-            #print("ledInfo_queue:data = {}".format(data))
+            #EventMesh.debug_log("ledInfo_queue:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
-                    print("ledInfo_queue:ERROR:{}".format(e))
+                    EventMesh.debug_log("ledInfo_queue:ERROR:{}".format(e))
                     usys.print_exception(e)
     def publish_message_event_ledInfo(self,event,msg):
         self.ledInfo_queue.put(msg)
@@ -181,7 +181,7 @@ class ledEventManager(Abstract):#灯事件
         return white_level
 
     def set_hr_blood_led(self, event, msg): #
-        print("set_hr_blood_led :{}".format(msg))
+        EventMesh.debug_log("set_hr_blood_led :{}".format(msg))
         if msg != None:
             if msg == 1:
                 EventMesh.publish("set_led_time_arg",[1,2,10*70*2,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE])#測量成功
@@ -207,7 +207,7 @@ class ledEventManager(Abstract):#灯事件
         if msg != None:
             if len(msg) != 0:
                 self.led_total_time = msg[2]#
-                # print("open_timer:{}".format(msg))
+                # EventMesh.debug_log("open_timer:{}".format(msg))
                 if self.led_total_time != None:
 
                     if self.led_total_time > 0:
@@ -233,7 +233,7 @@ class ledEventManager(Abstract):#灯事件
         
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         power_off = EventMesh.publish("get_power_off_state")#获取开机标识
-        # print("set_led_time_arg",msg,open_power,power_off)
+        # EventMesh.debug_log("set_led_time_arg",msg,open_power,power_off)
         if open_power != None:
             if open_power == 0:
                 return
@@ -243,7 +243,7 @@ class ledEventManager(Abstract):#灯事件
         usb_in = EventMesh.publish("get_usb")#
         if msg != None:
             if msg[6] != led_mode.POWER_OFF_MODE:#插入usb关机以防不亮红绿灯
-                # print("usb_in",usb_in)
+                # EventMesh.debug_log("usb_in",usb_in)
                 if usb_in != None:
                     if usb_in == 1 or usb_in == 3:#正在充电或者充电已满都不要被打断
                         if self.timer_state == 1:
@@ -271,7 +271,7 @@ class ledEventManager(Abstract):#灯事件
                         
                         wechat_state = EventMesh.publish("get_wechat_state")
                         temp_state = EventMesh.publish("get_temp_state")
-                        print("get_hr_state",get_hr_state,get_spo2_state,temp_state,wechat_state,self.working_led_mode)
+                        EventMesh.debug_log("get_hr_state",get_hr_state,get_spo2_state,temp_state,wechat_state,self.working_led_mode)
                         if wechat_state != None: #获取微聊状态
                             if wechat_state == 1:
                                 if self.working_led_mode != led_mode.WECHAT_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
@@ -288,7 +288,7 @@ class ledEventManager(Abstract):#灯事件
                                 self.wechat_btn = 0
                                 if get_hr_state != 0 or get_spo2_state != 0 or temp_state != 0 :#心率血氧优先级高
                                     if self.working_led_mode != led_mode.HEALTH_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
-                                        # print("set_hr_blood_led!!!!!!!!!!")
+                                        # EventMesh.debug_log("set_hr_blood_led!!!!!!!!!!")
                                         str_buf = [1,2,10*70*2,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE]#測量成功
                                         self.timer_state = 0
                                         self.timer.stop()
@@ -296,7 +296,7 @@ class ledEventManager(Abstract):#灯事件
                                         self.working_led_mode = led_mode.HEALTH_LED_MODE
                                         return
                                     else:
-                                        # print("set_hr_blood_led stop!!!!!!!!!!")
+                                        # EventMesh.debug_log("set_hr_blood_led stop!!!!!!!!!!")
                                         return
                                 if  get_hr_state == 0 and get_spo2_state == 0 and temp_state == 0:
                                     self.working_led_mode = led_mode.OTHER_MEASURE_MODE
@@ -324,7 +324,7 @@ class ledEventManager(Abstract):#灯事件
                             EventMesh.publish("close_hr_sop2")
                             EventMesh.publish("close_led_pin")
                             return
-        # print("self.long_count",self.long_count)
+        # EventMesh.debug_log("self.long_count",self.long_count)
         if self.led_total_time != 0:
             #红灯闪烁
             if self.long_light_mode == led_mode.FLASH_LIGHT_RED :#
@@ -338,7 +338,7 @@ class ledEventManager(Abstract):#灯事件
                         else:
                             EventMesh.publish("stop_led_timer")#关闭所有的灯
                 elif self.led_mode == 2:
-                    # print("led red!!!!!!!")
+                    # EventMesh.debug_log("led red!!!!!!!")
                     
                     if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                         close_led_green()
@@ -509,7 +509,7 @@ class ledEventManager(Abstract):#灯事件
                 self.long_count = 0
     
     def close_led_pin(self, event, msg):
-        print("close_led_pin!!!")
+        EventMesh.debug_log("close_led_pin!!!")
 
         self.timer.stop()
         self.timer_state = 0
@@ -530,7 +530,7 @@ class ledEventManager(Abstract):#灯事件
     
     def close_all_led(self, event, msg):
         self.close_all_led_do(0)
-        # print("close_all_led!!2222222!!")
+        # EventMesh.debug_log("close_all_led!!2222222!!")
         # EventMesh.publish("publish_message_event_ledInfo",{"func":self.close_all_led_do,"data":0})  
     def close_all_led_do(self,data):   
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
@@ -553,7 +553,7 @@ class ledEventManager(Abstract):#灯事件
                         
                         wechat_state = EventMesh.publish("get_wechat_state")
                         temp_state = EventMesh.publish("get_temp_state")
-                        # print("get_hr_state",get_hr_state,get_spo2_state,wechat_state,self.working_led_mode)
+                        # EventMesh.debug_log("get_hr_state",get_hr_state,get_spo2_state,wechat_state,self.working_led_mode)
                         if wechat_state != None: #获取微聊状态
                             if wechat_state == 1 or get_spo2_state != 0 or get_hr_state != 0 or temp_state != 0:
                                 return
@@ -571,7 +571,7 @@ class ledEventManager(Abstract):#灯事件
         close_led_red()
         close_led_green()
         close_led_white()
-        # print("close led!!!")
+        # EventMesh.debug_log("close led!!!")
 
     def led_test_fun_cb(self, data):
         return
diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/location.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/location.py
deleted file mode 100644 (file)
index b546faf..0000000
+++ /dev/null
@@ -1,1024 +0,0 @@
-# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import ure
-import net
-import math
-import utime
-import osTimer
-import _thread
-import wifiScan
-import cellLocator
-
-from queue import Queue
-from machine import UART, Pin
-
-try:
-    from wifilocator import wifilocator
-except:
-    wifilocator = None
-
-from log import getLogger
-
-try:
-    import quecgnss
-except ImportError:
-    quecgnss = None
-
-log = getLogger(__name__)
-
-_gps_read_lock = _thread.allocate_lock()
-_gps_data_set_lock = _thread.allocate_lock()
-
-EE = 0.00669342162296594323
-EARTH_RADIUS = 6378.137  # Approximate Earth Radius(km)
-M_PI = math.pi
-
-
-class _loc_method(object):
-    gps = 0x1
-    cell = 0x2
-    wifi = 0x4
-
-
-class _gps_mode(object):
-    none = 0x0
-    internal = 0x1
-    external = 0x2
-
-
-def transformLat(x, y):
-    ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt(math.fabs(x))
-    ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0
-    ret += (20.0 * math.sin(y * M_PI) + 40.0 * math.sin(y / 3.0 * M_PI)) * 2.0 / 3.0
-    ret += (160.0 * math.sin(y / 12.0 * M_PI) + 320 * math.sin(y * M_PI / 30.0)) * 2.0 / 3.0
-    return ret
-
-
-def transformLon(x, y):
-    ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqrt(math.fabs(x))
-    ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0
-    ret += (20.0 * math.sin(x * M_PI) + 40.0 * math.sin(x / 3.0 * M_PI)) * 2.0 / 3.0
-    ret += (150.0 * math.sin(x / 12.0 * M_PI) + 300.0 * math.sin(x / 30.0 * M_PI)) * 2.0 / 3.0
-    return ret
-
-
-def WGS84ToGCJ02(lon, lat):
-    dLat = transformLat(lon - 105.0, lat - 35.0)
-    dLon = transformLon(lon - 105.0, lat - 35.0)
-    radLat = lat / 180.0 * M_PI
-    magic = math.sin(radLat)
-    magic = 1 - magic * magic * EE
-    sqrtMagic = math.sqrt(magic)
-
-    dLat = (dLat * 180.0) / ((EARTH_RADIUS * 1000 * (1 - EE)) / (magic * sqrtMagic) * M_PI)
-    dLon = (dLon * 180.0) / (EARTH_RADIUS * 1000 / sqrtMagic * math.cos(radLat) * M_PI)
-    lon02 = lon + dLon
-    lat02 = lat + dLat
-
-    return lon02, lat02
-
-
-class GPSMatch(object):
-    """This class is match gps NEMA 0183"""
-
-    def GxRMC(self, gps_data):
-        """Match Recommended Minimum Specific GPS/TRANSIT Data(RMC)
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: RMC NMEA string.
-        """
-        if gps_data:
-            rmc_re = ure.search(
-                r"\$G[NP]RMC,\d*\.*\d*,*[AV],*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*\d*\.*\d*,*\d*\.*\d*,*\d*,*\d*\.*\d*,*[EW]*,*[ADEN]*,*[SCUV]*\**(\d|\w)*",
-                gps_data)
-            if rmc_re:
-                return rmc_re.group(0)
-        return ""
-
-    def GxGGA(self, gps_data):
-        """Match Global Positioning System Fix Data(GGA)
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: GGA NMEA string.
-        """
-        if gps_data:
-            gga_re = ure.search(
-                r"\$G[BLPN]GGA,\d*\.*\d*,*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*[0126],*\d*,*\d*\.*\d*,*-*\d*\.*\d*,*M,*-*\d*\.*\d*,*M,*\d*,*\**(\d|\w)*",
-                gps_data)
-            if gga_re:
-                return gga_re.group(0)
-        return ""
-
-    def GxVTG(self, gps_data):
-        """Match Track Made Good and Ground Speed(VTG)
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: VTG NMEA string.
-        """
-        if gps_data:
-            vtg_re = ure.search(r"\$G[NP]VTG,\d*\.*\d*,*T,*\d*\.*\d*,*M,*\d*\.*\d*,*N,*\d*\.*\d*,*K,*[ADEN]*\*(\d|\w)*",
-                                gps_data)
-            if vtg_re:
-                return vtg_re.group(0)
-        return ""
-
-    def GxGSV(self, gps_data):
-        """Mactch GPS Satellites in View(GSV)
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: GSV NMEA string.
-        """
-        if gps_data:
-            gsv_re = ure.search(
-                r"\$G[NP]GSV,\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\**(\d|\w)*",
-                gps_data)
-            if gsv_re:
-                return gsv_re.group(0)
-        return ""
-
-    def GxGLL(self, gps_data):
-        """Geographic Position
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: GLL NMEA string.
-        """
-        if gps_data:
-            gll_re = ure.search(r"\$G[NP]GLL,\d*\.*\d*,*[NS]*,*\d*\.*\d*,*[EW]*,*\d*\.*\d*,*[AV]*,*[ADEN]*\**(\d|\w)*",
-                                gps_data)
-            if gll_re:
-                return gll_re.group(0)
-
-    def GxGSA(self, gps_data):
-        """GNSS DOP and Active Satellites
-
-        Args:
-            gps_data(str): GPS NMEA string.
-
-        Returns:
-            str: GSA NMEA string.
-        """
-        if gps_data:
-            gsa_re = ure.search(
-                r"\$G[NP]GSA,[MA]*,*[123]*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\.*\d*,*\d*\.*\d*,*\d*\.*\d*,*(\d|\w)*\**(\d|\w)*",
-                gps_data)
-            if gsa_re:
-                return gsa_re.group(0)
-
-
-class GPSParse(object):
-    """Parse details from gps data"""
-
-    def GxGGA_satellite_num(self, gga_data):
-        """Parse satellite num from GGA"""
-        if gga_data:
-            satellite_num_re = ure.search(r",[EW],[0126],\d+,", gga_data)
-            if satellite_num_re:
-                return satellite_num_re.group(0).split(",")[-2]
-        return ""
-
-    def GxGGA_latitude(self, gga_data):
-        """Parse latitude from GGA"""
-        if gga_data:
-            latitude_re = ure.search(r",[0-9]+\.[0-9]+,[NS],", gga_data)
-            if latitude_re:
-                latitude = latitude_re.group(0)[1:-3]
-                return str(float(latitude[:2]) + float(latitude[2:]) / 60)
-        return ""
-
-    def GxGGA_longitude(self, gga_data):
-        """Parse longitude from GGA"""
-        if gga_data:
-            longitude_re = ure.search(r",[0-9]+\.[0-9]+,[EW],", gga_data)
-            if longitude_re:
-                longitude = longitude_re.group(0)[1:-3]
-                return str(float(longitude[:3]) + float(longitude[3:]) / 60)
-        return ""
-
-    def GxGGA_altitude(self, gga_data):
-        """Parse altitude from GGA"""
-        if gga_data:
-            altitude_re = ure.search(r",-*[0-9]+\.[0-9]+,M,", gga_data)
-            if altitude_re:
-                return altitude_re.group(0)[1:-3]
-        return ""
-
-    def GxVTG_speed(self, vtg_data):
-        """Parse speed from VTG"""
-        if vtg_data:
-            speed_re = ure.search(r",N,\d+\.\d+,K,", vtg_data)
-            if speed_re:
-                return speed_re.group(0)[3:-3]
-        return ""
-
-    def GxGSV_satellite_num(self, gsv_data):
-        """Parse satellite num from GSV"""
-        if gsv_data:
-            satellite_num_re = ure.search(r"\$G[NP]GSV,\d+,\d+,\d+,", gsv_data)
-            if satellite_num_re:
-                return satellite_num_re.group(0).split(",")[-2]
-        return ""
-
-    def GxRMC_loc_status(self, rmc_data):
-        if rmc_data:
-            loc_status_re = ure.search(r"\$G[NP]RMC,\d*\.*\d*,[AV],", rmc_data)
-            if loc_status_re:
-                loc_status = loc_status_re.group(0).split(",")[-2]
-                return True if loc_status == "A" else False
-        return False
-
-    def __nmea_parse(self, nmea):
-        return tuple(nmea[1:].split("*")[0].split(",")) if nmea else ()
-
-    def GxRMC(self, rmc_data):
-        return self.__nmea_parse(rmc_data)
-
-    def GxGGA(self, gga_data):
-        return self.__nmea_parse(gga_data)
-
-    def GxGSV(self, gsv_data):
-        return self.__nmea_parse(gsv_data)
-
-    def GxGSA(self, gsa_data):
-        return self.__nmea_parse(gsa_data)
-
-    def GxVTG(self, vtg_data):
-        return self.__nmea_parse(vtg_data)
-
-    def GxGLL(self, gll_data):
-        return self.__nmea_parse(gll_data)
-
-
-class GPS(object):
-    """This class if for reading gps data.
-
-    Now support external gps and internal gps.
-
-    Sleep power consumption:
-        power off < backup < standby
-    """
-
-    __RMC = 0
-    __GGA = 1
-    __GSV = 2
-    __GSA = 3
-    __VTG = 4
-    __GLL = 5
-    __NMEA = 0b010111
-
-    def __init__(self, UARTn, buadrate, databits, parity, stopbits, flowctl, PowerPin, StandbyPin, BackupPin, gps_mode):
-        """Init GPS module
-
-        [description]
-
-        Args:
-            UARTn(int): UART No.
-            buadrate(int): baud rate
-            databits(int): data bits (5 ~ 8)
-            parity(int): parity (0 – NONE,1 – EVEN,2 - ODD)
-            stopbits(int): stop bit
-            flowctl(int): hardware control flow (0 – FC_NONE, 1 – FC_HW)
-            PowerPin(int): Power GIPO Pin
-            StandbyPin(int): Standby GPIO Pin
-            BackupPin(int): Back GPIO Pin
-            gps_mode(int): GPS mode
-                0 - None
-                1 - internal GPS
-                2 - external GPS
-        """
-        self.__UARTn = UARTn
-        self.__buadrate = buadrate
-        self.__databits = databits
-        self.__parity = parity
-        self.__stopbits = stopbits
-        self.__flowctl = flowctl
-        self.__PowerPin = PowerPin
-        self.__StandbyPin = StandbyPin
-        self.__BackupPin = BackupPin
-        self.__gps_mode = gps_mode
-
-        self.__external_obj = None
-        self.__internal_obj = quecgnss
-        self.__gps_match = GPSMatch()
-        self.__gps_parse = GPSParse()
-        self.__gps_power_gpio = None
-        self.__gps_standby_gpio = None
-        self.__gps_backup_gpio = None
-
-        self.__external_retrieve_queue = None
-        self.__queue_size = 2
-        self.__first_break = 0
-        self.__break = 0
-        self.__gps_data = ""
-        self.__rmc_data = ""
-        self.__gga_data = ""
-        self.__vtg_data = ""
-        self.__gsv_data = ""
-        self.__gps_timer = osTimer()
-        self.__gps_data_check_timer = osTimer()
-
-        if self.__gps_mode & _gps_mode.external:
-            self.__external_init()
-        elif self.__gps_mode & _gps_mode.internal:
-            self.__internal_init()
-        #print("GPS:__init__%d",self.__gps_mode)
-    def __gps_power_control(self, GPIOn, onoff, method):
-        if method == "power_switch":
-            if self.__gps_power_gpio is None:
-                self.__gps_power_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
-            gpio_obj = self.__gps_power_gpio
-        elif method == "standby":
-            if self.__gps_standby_gpio is None:
-                self.__gps_standby_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
-            gpio_obj = self.__gps_standby_gpio
-        elif method == "backup":
-            if self.__gps_backup_gpio is None:
-                self.__gps_backup_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
-            gpio_obj = self.__gps_backup_gpio
-        else:
-            raise TypeError("Param method %s is not compare." % method)
-
-        if gpio_obj.read() != onoff:
-            gpio_obj.write(onoff)
-            if gpio_obj.read() != onoff:
-                return False
-        return True
-
-    def __reverse_gps_data(self, this_gps_data):
-        """Reverse GPS data for regular match get the latest data"""
-        log.debug("this_gps_data: \n%s" % this_gps_data)
-        delimiter = "\r\n"
-        if this_gps_data:
-            _gps_data = self.__get_gps_data()
-            if _gps_data:
-                _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1])
-            _gps_data += this_gps_data.strip().replace("\r", "").replace("\n", "").replace("$", delimiter + "$")
-            _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1])
-            self.__set_gps_data(_gps_data)
-
-    def __read_latitude(self, gps_data):
-        """Read latitude from gps data"""
-        return self.__gps_parse.GxGGA_latitude(self.__gps_match.GxGGA(gps_data))
-
-    def __read_longitude(self, gps_data):
-        """Read longitude from gps data"""
-        return self.__gps_parse.GxGGA_longitude(self.__gps_match.GxGGA(gps_data))
-
-    def __read_altitude(self, gps_data):
-        """Read altitude from gps data"""
-        return self.__gps_parse.GxGGA_altitude(self.__gps_match.GxGGA(gps_data))
-
-    def __set_gps_data(self, gps_data):
-        self.__gps_data = gps_data
-
-    def __get_gps_data(self):
-        return self.__gps_data
-
-    def __gps_timer_callback(self, args):
-        """GPS read timer callback
-        When over time to get uart data, break queue wait
-        """
-        self.__break = 1
-        if self.__external_retrieve_queue is not None:
-            self.__external_retrieve_queue.put(False)
-
-    def __gps_data_check_callback(self, args):
-        """GPS read old data clean timer callback
-        When GPS read over time, clean old gps data, wait to read new gps data.
-        """
-        clean = False
-        if "" in (self.__rmc_data, self.__gga_data, self.__gsv_data):
-            clean = True
-        else:
-            if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
-                clean = True
-            elif self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
-                clean = True
-            elif self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
-                clean = True
-
-        if clean:
-            self.__gps_nmea_data_clean()
-
-    def __external_init(self):
-        """External GPS init"""
-        self.__external_retrieve_queue = Queue(maxsize=self.__queue_size)
-
-    def __external_open(self):
-        """External GPS start, UART init"""
-        self.power_switch(1)
-        self.__external_obj = UART(
-            self.__UARTn,
-            self.__buadrate,
-            self.__databits,
-            self.__parity,
-            self.__stopbits,
-            self.__flowctl
-        )
-        self.__external_obj.set_callback(self.__external_retrieve_cb)
-
-    def __external_close(self):
-        """External GPS close, UART close, NOT GPS stop"""
-        self.__external_obj.close()
-
-    def __external_retrieve_cb(self, args):
-        """
-        GPS data retrieve callback from UART
-        When data comes, send a message to queue of data length
-        """
-        # log.debug("GPS __external_retrieve_cb args: %s" % str(args))
-        if self.__external_retrieve_queue.size() >= self.__queue_size:
-            self.__external_retrieve_queue.get()
-        self.__external_retrieve_queue.put(True)
-
-    def __internal_init(self):
-        """Internal GPS init"""
-        if self.__internal_obj:
-            if self.__internal_obj.init() != 0:
-                self.__internal_open()
-                log.error("GNSS INIT Failed.")
-            else:
-                log.debug("GNSS INIT Success.")
-        else:
-            log.error("Module quecgnss Import Error.")
-
-    def __internal_open(self):
-        """Internal GPS enable"""
-        if self.__internal_obj.get_state() == 0:
-            return True if self.__internal_obj.gnssEnable(1) == 0 else False
-        else:
-            return True
-
-    def __internal_close(self):
-        """Internal GPS close"""
-        return True if self.__internal_obj.gnssEnable(0) == 0 else False
-
-    def __nmea_statement_exist(self, nmea_item):
-        return (self.__NMEA & (0b1 << nmea_item)) >> nmea_item
-
-    def __gps_nmea_data_clean(self):
-        self.__set_gps_data("")
-        self.__rmc_data = ""
-        self.__gga_data = ""
-        self.__gsv_data = ""
-        self.__gsa_data = ""
-        self.__vtg_data = ""
-        self.__gll_data = ""
-
-    def __check_gps_valid(self, gps_data):
-        self.__reverse_gps_data(gps_data)
-
-        if not self.__rmc_data:
-            self.__rmc_data = self.__gps_match.GxRMC(self.__get_gps_data())
-        loc_status = self.__gps_parse.GxRMC_loc_status(self.__rmc_data)
-
-        if self.__rmc_data and loc_status:
-            if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data:
-                self.__gga_data = self.__gps_match.GxGGA(self.__get_gps_data())
-            if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data:
-                self.__gsv_data = self.__gps_match.GxGSV(self.__get_gps_data())
-            if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
-                self.__gsa_data = self.__gps_match.GxGSA(self.__get_gps_data())
-            if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
-                self.__vtg_data = self.__gps_match.GxVTG(self.__get_gps_data())
-            if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
-                self.__gll_data = self.__gps_match.GxGLL(self.__get_gps_data())
-
-            if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data:
-                return False
-            if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data:
-                return False
-            if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
-                return False
-            if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
-                return False
-            if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
-                return False
-            return True
-
-        return False
-
-    def __external_read(self):
-        """Read external GPS data
-
-        Return:
-            $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
-            $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
-            $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
-            $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
-            $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
-            $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
-            $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
-            $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
-            $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
-            $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
-            $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
-            $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
-            $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
-            $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
-            $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
-        """
-        self.__external_open()
-        log.debug("__external_read start")
-
-        while self.__break == 0:
-            self.__gps_timer.start(50, 0, self.__gps_timer_callback)
-            signal = self.__external_retrieve_queue.get()
-            log.debug("[first] signal: %s" % signal)
-            if signal:
-                to_read = self.__external_obj.any()
-                log.debug("[first] to_read: %s" % to_read)
-                if to_read > 0:
-                    self.__set_gps_data(self.__external_obj.read(to_read).decode())
-            self.__gps_timer.stop()
-        self.__break = 0
-
-        self.__gps_nmea_data_clean()
-        self.__gps_data_check_timer.start(2000, 1, self.__gps_data_check_callback)
-        cycle = 0
-        while self.__break == 0:
-            self.__gps_timer.start(1500, 0, self.__gps_timer_callback)
-            signal = self.__external_retrieve_queue.get()
-            log.debug("[second] signal: %s" % signal)
-            if signal:
-                to_read = self.__external_obj.any()
-                log.debug("[second] to_read: %s" % to_read)
-                if to_read > 0:
-                    if self.__check_gps_valid(self.__external_obj.read(to_read).decode()):
-                        self.__break = 1
-
-            self.__gps_timer.stop()
-            cycle += 1
-            if cycle >= self.__retry:
-                self.__break = 1
-            if self.__break != 1:
-                utime.sleep(1)
-        self.__gps_data_check_timer.stop()
-        self.__break = 0
-
-        # To check GPS data is usable or not.
-        self.__gps_data_check_callback(None)
-        self.__external_close()
-        log.debug("__external_read data: %s" % self.__get_gps_data())
-        return self.__get_gps_data()
-
-    def __internal_read(self):
-        import EventMesh
-        log.debug("__internal_read start.")
-        """Read internal GPS data
-
-        Return:
-            $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
-            $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
-            $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
-            $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
-            $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
-            $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
-            $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
-            $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
-            $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
-            $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
-            $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
-            $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
-            $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
-            $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
-            $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
-        """
-
-        #self.__gps_nmea_data_clean()
-
-        cycle = 0
-        #while self.__break == 0:
-        gnss_data = quecgnss.read(1024*3)
-        #print("__internal_read")
-        #print(gnss_data)
-        if gnss_data and gnss_data[1]:
-            this_gps_data = gnss_data[1].decode() if len(gnss_data) > 1 and gnss_data[1] else ""
-            _gps_valid = self.__check_gps_valid(this_gps_data)
-            log.debug("_gps_valid: %s" % _gps_valid)
-            
-            #print("_gps_valid:",_gps_valid)
-            #print(str(_gps_valid),self.__get_gps_data())
-            if _gps_valid == True :
-                #EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"])
-                return self.__get_gps_data()
-            else :
-                EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"])
-                return ""
-        
-    def read(self, retry=30):
-        """For user to read gps data
-
-        Return: (res_code, gps_data)
-            res_code:
-                -  0: Success
-                - -1: Failed
-            gps_data:
-                $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
-                $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
-                $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
-                $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
-                $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
-                $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
-                $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
-                $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
-                $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
-                $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
-                $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
-                $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
-                $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
-                $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
-                $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
-        """
-        self.__retry = retry
-        gps_data = ""
-        if self.__gps_mode & _gps_mode.external:
-            gps_data = self.__external_read()
-        elif self.__gps_mode & _gps_mode.internal:
-            gps_data = self.__internal_read()
-
-        res = 0 if gps_data else -1
-        return (res, gps_data)
-
-    def read_coordinates(self, gps_data):
-        """Read positioning coordinates.
-
-        Params:
-            gps_data: read gps data.
-            map_coordinate_system: `WGS84` or GCJ02
-
-        Return:
-            (longitude, latitude, altitude)
-        """
-        latitude = self.__read_latitude(gps_data)
-        latitude = float(latitude) if latitude else latitude
-        longitude = self.__read_longitude(gps_data)
-        longitude = float(longitude) if longitude else longitude
-        altitude = self.__read_altitude(gps_data)
-        altitude = float(altitude) if altitude else altitude
-        return (longitude, latitude, altitude)
-
-    def power_switch(self, onoff):
-        """GPS module power switch
-
-        Params:
-            onoff: 0 -- off, 1 -- on
-        """
-        if self.__gps_mode & _gps_mode.external:
-            if self.__PowerPin is not None:
-                return self.__gps_power_control(self.__PowerPin, onoff, "power_switch")
-            else:
-                return False
-        elif self.__gps_mode & _gps_mode.internal:
-            # TODO: Interal GNSS power down will not be used this api.
-            if onoff == 0:
-                return self.__internal_close()
-            else:
-                return self.__internal_open()
-
-    def backup(self, onoff):
-        """GPS module low enery mode backup
-
-        Params:
-            onoff: 0 -- off, 1 -- on
-        """
-        if self.__BackupPin is not None:
-            return self.__gps_power_control(self.__BackupPin, onoff, "backup")
-        else:
-            return False
-
-    def standby(self, onoff):
-        """GPS module low enery mode standby
-
-        Params:
-            onoff: 0 -- off, 1 -- on
-        """
-        if self.__StandbyPin is not None:
-            return self.__gps_power_control(self.__StandbyPin, onoff, "standby")
-        else:
-            return False
-
-    def set_nmea_statement(self, nmea_statement):
-        """Set NMEA statement to check gps info valid
-
-        RMC, GGA, GSV must be required.
-
-        Args:
-            nmea_statement(int):
-                RMC - 0b1 << 0 (bit0), 0 - off, 1 - on
-                GGA - 0b1 << 1 (bit1), 0 - off, 1 - on
-                GSV - 0b1 << 2 (bit2), 0 - off, 1 - on
-                GSA - 0b1 << 3 (bit3), 0 - off, 1 - on
-                VTG - 0b1 << 4 (bit4), 0 - off, 1 - on
-                GLL - 0b1 << 5 (bit5), 0 - off, 1 - on
-
-        Returns:
-            bool: True - success, False - falied.
-        """
-        if nmea_statement >= 0b111:
-            self.__NMEA = nmea_statement
-            return True
-        return False
-
-
-class CellLocator(object):
-    """This class is for reading cell location data"""
-
-    def __init__(self, serverAddr, port, token, timeout, profileIdx):
-        self.__serverAddr = serverAddr
-        self.__port = port
-        self.__token = token
-        self.__timeout = timeout
-        self.__profileIdx = profileIdx
-
-    def read(self):
-        read_loc_res = self.__read_loc()
-        read_cell_res = self.__read_cell()
-        res = 0 if read_loc_res[0] == 0 or read_cell_res[0] == 0 else -1
-        return (res, read_loc_res[1], read_cell_res[1])
-
-    def __read_loc(self):
-        """Read cell location data.
-
-        Return: (res_code, loc_data)
-            res_code:
-                -  0: Success
-                - -1: Initialization failed
-                - -2: The server address is too long (more than 255 bytes)
-                - -3: Wrong key length, must be 16 bytes
-                - -4: The timeout period is out of range, the supported range is (1 ~ 300) s
-                - -5: The specified PDP network is not connected, please confirm whether the PDP is correct
-                - -6: Error getting coordinates
-            loc_data:
-                (117.1138, 31.82279, 550)
-        """
-        res = -1
-        loc_data = cellLocator.getLocation(
-            self.__serverAddr,
-            self.__port,
-            self.__token,
-            self.__timeout,
-            self.__profileIdx
-        )
-        if isinstance(loc_data, tuple) and len(loc_data) == 3:
-            res = 0
-        else:
-            res = loc_data
-            loc_data = ()
-
-        return (res, loc_data)
-
-    def __read_cell(self):
-        res = -1
-        near_cell = []
-        server_cell = []
-
-        near_cells = net.getCi()
-        if near_cells != -1 and isinstance(near_cells, list):
-            near_cell = list(map(str, near_cells))
-
-        server_cells = net.getCellInfo()
-        if server_cells != -1 and isinstance(server_cells, tuple):
-            server_cell = server_cells
-
-        res = 0 if near_cell or server_cell else -1
-        return (res, {"near_cell": near_cell, "server_cell": server_cell})
-
-
-class WiFiLocator(object):
-    """This class is for reading wifi location data"""
-
-    def __init__(self, token):
-        self.__wifilocator_obj = wifilocator(token)
-
-    def read(self):
-        read_loc_res = self.__read_loc()
-        read_mac_res = self.__read_mac()
-        res = 0 if read_loc_res[0] == 0 or read_mac_res[0] == 0 else -1
-        return (res, read_loc_res[1], read_mac_res[1])
-
-    def __read_loc(self):
-        """Read wifi location data.
-
-        Return: (res_code, loc_data)
-            res_code:
-                -  0: Success
-                - -1: The current network is abnormal, please confirm whether the dial-up is normal
-                - -2: Wrong key length, must be 16 bytes
-                - -3: Error getting coordinates
-            loc_data:
-                (117.1138, 31.82279, 550)
-        """
-        res = -1
-        loc_data = self.__wifilocator_obj.getwifilocator()
-        if isinstance(loc_data, tuple) and len(loc_data) == 3:
-            res = 0
-        else:
-            res = loc_data
-            loc_data = ()
-
-        return (res, loc_data)
-
-    def __read_mac(self):
-        res = -1
-        macs = []
-        if wifiScan.support():
-            if wifiScan.control(1) == 0:
-                if wifiScan.getState():
-                    wifisacn_start = wifiScan.start()
-                    if wifisacn_start != -1 and wifisacn_start[0] > 0:
-                        macs = [i[0] for i in wifisacn_start[1]]
-                        res = 0
-            wifiScan.control(0)
-        return (res, macs)
-
-
-class Location(object):
-    """This class is for reading location data from gps, cell, wifi"""
-    gps = None
-    cellLoc = None
-    wifiLoc = None
-
-    def __init__(self, loc_method, locator_init_params):
-        """Init Location module
-
-        1. If loc_method include gps then init gps module;
-        2. If loc_method inculde cell then init cell module;
-        3. If loc_method Include wifi then init wifi module;
-
-        Args:
-            loc_method(int):
-                1 - gps
-                2 - cell
-                3 - cell & gps
-                4 - wifi
-                5 - wifi & gps
-                6 - wifi & cell
-                7 - wifi & cell & gps
-            locator_init_params(dict):
-                gps_cfg(dict):GPS module init args
-                cell_cfg(dict):CELL module init args
-                wifi_cfg(dict):WIFI module init args
-        """
-        self.__loc_method = loc_method
-        self.__locator_init_params = locator_init_params
-        self.__locater_init()
-
-    def __locater_init(self):
-        """Init gps, cell, wifi by loc_method"""
-
-        if self.__loc_method & _loc_method.gps:
-            if self.gps is None:
-                _gps_cfg = self.__locator_init_params.get("gps_cfg", {})
-                if _gps_cfg:
-                    self.gps = GPS(**_gps_cfg)
-                    if _gps_cfg.get("nmea_cfg") is not None:
-                        self.gps.set_nmea_statement(_gps_cfg.get("nmea_cfg"))
-                else:
-                    raise ValueError("Invalid gps init parameters.")
-        else:
-            self.gps = None
-
-        if self.__loc_method & _loc_method.cell:
-            if self.cellLoc is None:
-                _cell_cfg = self.__locator_init_params.get("cell_cfg")
-                if _cell_cfg:
-                    self.cellLoc = CellLocator(**_cell_cfg)
-                else:
-                    raise ValueError("Invalid cell-locator init parameters.")
-        else:
-            self.cellLoc = None
-
-        if self.__loc_method & _loc_method.wifi:
-            if self.wifiLoc is None:
-                _wifi_cfg = self.__locator_init_params.get("wifi_cfg")
-                if _wifi_cfg:
-                    self.wifiLoc = WiFiLocator(**_wifi_cfg)
-                else:
-                    raise ValueError("Invalid wifi-locator init parameters.")
-        else:
-            self.wifiLoc = None
-
-    def __read_gps(self, retry):
-        """Read loction data from gps module
-
-        Return:
-            $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
-            $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
-            $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
-            $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
-            $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
-            $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
-            $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
-            $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
-            $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
-            $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
-            $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
-            $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
-            $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
-            $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
-            $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
-        """
-        if self.gps:
-            return self.gps.read(retry)[1]
-        return ""
-
-    def __read_cell(self):
-        """Read loction data from cell module
-
-        Return:
-            (117.1138, 31.82279, 550) or ()
-        """
-        if self.cellLoc:
-            cell_loc_data = self.cellLoc.read()
-            return (cell_loc_data[1], cell_loc_data[2])
-        return ()
-
-    def __read_wifi(self):
-        """Read loction data from wifi module
-
-        Return:
-            (117.1138, 31.82279, 550) or ()
-        """
-        if self.wifiLoc:
-            wifi_loc_data = self.wifiLoc.read()
-            return (wifi_loc_data[1], wifi_loc_data[2])
-        return ()
-
-    def read(self, retry=30):
-        """Read location data
-
-        args:
-            retry(int): gps read uart data retry count.
-
-        Returns:
-            dict:
-                key:
-                    1 - GPS data
-                    2 - CELL data
-                    4 - WIFI data
-            .e.g:
-            {
-                1: "$GPGGA,XXX",
-                2: (0.00, 0.00, 0.00),
-                4: (0.00, 0.00, 0.00),
-            }
-        """
-        loc_data = {}
-
-        if self.__loc_method & _loc_method.gps:
-            loc_data[_loc_method.gps] = self.__read_gps(retry)
-
-        if self.__loc_method & _loc_method.cell:
-            loc_data[_loc_method.cell] = self.__read_cell()
-
-        if self.__loc_method & _loc_method.wifi:
-            loc_data[_loc_method.wifi] = self.__read_wifi()
-
-        return loc_data
-
-    def wgs84togcj02(self, Longitude, Latitude):
-        return WGS84ToGCJ02(Longitude, Latitude)
-
-
-if __name__ == '__main__':
-    _gps_cfg = {
-        "UARTn": UART.UART1,
-        "buadrate": 115200,
-        "databits": 8,
-        "parity": 0,
-        "stopbits": 1,
-        "flowctl": 0,
-        "PowerPin": Pin.GPIO2,
-        "StandbyPin": Pin.GPIO3,
-        "BackupPin": None,
-        "gps_mode": 0x01,
-    }
-    gps = GPS(**_gps_cfg)
-    print("read {}".format(gps.read(300)))
index 972f1a2..829f270 100644 (file)
@@ -41,13 +41,13 @@ if __name__ == '__main__':
         uos.mount(ldev,'/ext')
     res = uos.statvfs("/ext")
     res = list(res)
-    print('总ext空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
-    print("init1:{}".format(utime.localtime()))
+    EventMesh.debug_log('总ext空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
+    EventMesh.debug_log("init1:{}".format(utime.localtime()))
     import EventMesh
     from common import Abstract
-    print("init2:{}".format(utime.localtime()))
+    EventMesh.debug_log("init2:{}".format(utime.localtime()))
     from lcd import tp_cst816
-    print("init3:{}".format(utime.localtime()))
+    EventMesh.debug_log("init3:{}".format(utime.localtime()))
 
     from usr.ui_main_menu import MainMenuScreen
     # from ui_WatchFaceScreen import WatchFaceScreen
@@ -55,12 +55,12 @@ if __name__ == '__main__':
     from appFactoryMode import  FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeAlipayInitScreen
     import ui as _ui
     # import ui as _ui
-    print("init4:{}".format(utime.localtime()))
+    EventMesh.debug_log("init4:{}".format(utime.localtime()))
     ui = _ui.UI()
     ui.post_processor_after_instantiation()
     ui.add_screen(MainMenuScreen()) 
     EventMesh.publish("load_screen", {"screen": "main_menu"})
-    print("init5:{}".format(utime.localtime()))
+    EventMesh.debug_log("init5:{}".format(utime.localtime()))
     
     ui.add_screen(_ui.PopupScreen()) 
     ui.add_screen(_ui.PhoneScreen()) 
@@ -129,18 +129,18 @@ if __name__ == '__main__':
     ui.add_screen(NewWechatPopupScreen())
     ui.add_screen(HealthScreen())
     # ui.add_screen(_ui.Setting3Screen())  
-    print("init6:{}".format(utime.localtime()))
+    EventMesh.debug_log("init6:{}".format(utime.localtime()))
     
 
     from protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
         TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,\
             ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager
     import mgr as mgr
-    print("init7:{}".format(utime.localtime()))
+    EventMesh.debug_log("init7:{}".format(utime.localtime()))
     
     from mgr import ConfigStoreManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
     AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
-    print("init8:{}".format(utime.localtime()))
+    EventMesh.debug_log("init8:{}".format(utime.localtime()))
     
     
     #from ui_WatchFaceScreen import WatchFaceScreen 
@@ -148,10 +148,10 @@ if __name__ == '__main__':
     
     # from usr.test_sms import HRSTART_ProtoCol,getHrTimeManager,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,getBrightnessManager,\
     # getStorageDataManager
-    print("init9:{}".format(utime.localtime()))
+    EventMesh.debug_log("init9:{}".format(utime.localtime()))
    #from usr.ui_wechat import WechatScreen,TK_ProtoCol
 
-    print("init10:{}".format(utime.localtime()))
+    EventMesh.debug_log("init10:{}".format(utime.localtime()))
     
 
     app = watchApp()
@@ -190,9 +190,9 @@ if __name__ == '__main__':
     app.append_manager(getSosFlagManager())
     app.append_manager(CountdownManager())
 
-    print("init21:{}".format(utime.localtime()))    
+    EventMesh.debug_log("init21:{}".format(utime.localtime()))    
     
-    print("init11:{}".format(utime.localtime()))    
+    EventMesh.debug_log("init11:{}".format(utime.localtime()))    
     pcr = ProtoColResolver()
     pcr.add_support(LK_ProtoCol())
     pcr.add_support(PING_ProtoCol())
@@ -224,16 +224,16 @@ if __name__ == '__main__':
     sm = SockManager()
     sm.add_support_resolver(pcr)
     app.append_manager(sm)
-    print("init11.0:{}".format(utime.localtime()))   
+    EventMesh.debug_log("init11.0:{}".format(utime.localtime()))   
     app.start()
     sms_data = sms.getSaveLoc()
     sms_lacv = sms_data[0][0]
     if sms_lacv != 'SM':#每次开机设置一下短信的存储位置
         sms.setSaveLoc('SM', 'SM', 'SM')
-    print("init12:{}".format(utime.localtime()))
+    EventMesh.debug_log("init12:{}".format(utime.localtime()))
     import atcmd
     resp=bytearray(50)
     atcmd.sendSync('AT+log=52,1\r\n',resp,'',20)
-    print("AT+log=52,1:{}".format(resp))
+    EventMesh.debug_log("AT+log=52,1:{}".format(resp))
 
 
index 66d1086..2bc2b79 100644 (file)
@@ -5,7 +5,7 @@ import machine
 from led import ledEventManager,led_mode
 resp=bytearray(50)
 # atcmd.sendSync('AT+log=52,1\r\n',resp,'',200)
-# print("AT+log=52,1:{}".format(resp))
+# EventMesh.debug_log("AT+log=52,1:{}".format(resp))
 from common import Abstract
 class App(object):
     def __init__(self):
@@ -44,17 +44,18 @@ def main_init():
     import uos
     import ql_fs
     import utime
+    import EventMesh
     # if ql_fs.path_exists("/ext") == False:
     #     ldev = uos.VfsLfs1(32, 32, 32, "ext_fs",0,3)
     #     uos.mount(ldev,'/ext')
     res = uos.statvfs("/usr")
     res = list(res)
-    print('总usr空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
-    print("init1:{}".format(utime.localtime()))
-    import EventMesh
+    EventMesh.debug_log('总usr空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
+    EventMesh.debug_log("init1:{}".format(utime.localtime()))
+    
     
-    print("init2:{}".format(utime.localtime()))
-    print("init3:{}".format(utime.localtime()))
+    EventMesh.debug_log("init2:{}".format(utime.localtime()))
+    EventMesh.debug_log("init3:{}".format(utime.localtime()))
     from btn_device_ec800m import BtnDevice,intervManager
 
     btn_device = BtnDevice()
@@ -62,14 +63,14 @@ def main_init():
     
     import ui as _ui
     # import ui as _ui
-    print("init4:{}".format(utime.localtime()))
+    EventMesh.debug_log("init4:{}".format(utime.localtime()))
     ui = _ui.UI()
     ui.post_processor_after_instantiation()
 
-    print("init5:{}".format(utime.localtime()))
+    EventMesh.debug_log("init5:{}".format(utime.localtime()))
     
     # ui.add_screen(_ui.UIFINDScreen())  
-    print("init6:{}".format(utime.localtime()))
+    EventMesh.debug_log("init6:{}".format(utime.localtime()))
     
 
     from protocol import MESSAGE_ProtoCol,TK_ProtoCol,LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
@@ -77,20 +78,20 @@ def main_init():
             ProtoColResolver,SILENCETIME2_ProtoCol,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager
         
     import mgr as mgr
-    print("init7:{}".format(utime.localtime()))
+    EventMesh.debug_log("init7:{}".format(utime.localtime()))
     
     from mgr import ClockManager,deleteSmsManager,testSmsSetIPManager,ConfigStoreManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
     AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
-    print("init8:{}".format(utime.localtime()))
+    EventMesh.debug_log("init8:{}".format(utime.localtime()))
     
     # from appWechat import TK_ProtoCol,MESSAGE_ProtoCol
     
     
     # from usr.test_sms import HRSTART_ProtoCol,getHrTimeManager,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,getBrightnessManager,\
     # getStorageDataManager
-    print("init9:{}".format(utime.localtime()))
+    EventMesh.debug_log("init9:{}".format(utime.localtime()))
 
-    print("init10:{}".format(utime.localtime()))
+    EventMesh.debug_log("init10:{}".format(utime.localtime()))
     
 
     app = watchApp()
@@ -143,9 +144,9 @@ def main_init():
     app.append_manager(deleteSmsManager())
     app.append_manager(ClockManager())
 
-    print("init21:{}".format(utime.localtime()))    
+    EventMesh.debug_log("init21:{}".format(utime.localtime()))    
     
-    print("init11:{}".format(utime.localtime()))    
+    EventMesh.debug_log("init11:{}".format(utime.localtime()))    
     pcr = ProtoColResolver()
     pcr.add_support(LK_ProtoCol())
     pcr.add_support(PING_ProtoCol())
@@ -179,16 +180,16 @@ def main_init():
     sm = SockManager()
     sm.add_support_resolver(pcr)
     app.append_manager(sm)
-    print("init11.0:{}".format(utime.localtime()))   
+    EventMesh.debug_log("init11.0:{}".format(utime.localtime()))   
     app.start()
     sms_data = sms.getSaveLoc()
     if(sms_data != -1):
         sms_lacv = sms_data[0][0]
         if sms_lacv != 'SM':#每次开机设置一下短信的存储位置
             sms.setSaveLoc('SM', 'SM', 'SM')
-    print("init12:{}".format(utime.localtime()))
+    EventMesh.debug_log("init12:{}".format(utime.localtime()))
     timer_t = net.nitzTime()
-    print("timer_t:{}".format(timer_t))
+    EventMesh.debug_log("timer_t:{}".format(timer_t))
     if(timer_t != -1):
         timeSecond = int(timer_t[1])
         if timeSecond != 0:
index 4854e03..7505f86 100644 (file)
@@ -28,12 +28,12 @@ import urandom
 try :
     from Hsensor import GH3018
 except Exception as e:
-    print("Hsensor none GH3018:{}".format(e))   
+    EventMesh.debug_log("Hsensor none GH3018:{}".format(e))   
 #
 try :
     from Hsensor import HX3918
 except Exception as e:
-    print("Hsensor none HX3918:{}".format(e))    
+    EventMesh.debug_log("Hsensor none HX3918:{}".format(e))    
 from machine import RTC
 import quecgnss
 import wifiScan
@@ -187,7 +187,7 @@ class CountdownManager(Abstract):
     def set_countdown_all_time(self, event, msg):
         self.total = msg[0]
         self.total_sec = msg[1]
-        # print("self.total:{} self.total_sec:{}".format(self.total,self.total_sec))
+        # EventMesh.debug_log("self.total:{} self.total_sec:{}".format(self.total,self.total_sec))
 
 
     def get_countdown_all_time(self, event, msg):
@@ -197,7 +197,7 @@ class CountdownManager(Abstract):
 
         self.time_cb = msg[0]
         self.time_play = msg[1]
-        # print("self.time_cb:{} self.total_sec:{}".format(self.time_cb,self.time_play))
+        # EventMesh.debug_log("self.time_cb:{} self.total_sec:{}".format(self.time_cb,self.time_play))
 
 
     def get_countdown_off_state(self, event, msg):
@@ -209,7 +209,7 @@ class CountdownManager(Abstract):
             date_tmp = utime.localtime()
             time_tmp = utime.mktime(date_tmp) 
             reduce = time_tmp- self.total_sec
-            print("self.time_cb:{} self.time_play:{} self.total:{} self.total_sec:{}".format(self.time_cb,self.time_play, self.total,self.total_sec))
+            EventMesh.debug_log("self.time_cb:{} self.time_play:{} self.total:{} self.total_sec:{}".format(self.time_cb,self.time_play, self.total,self.total_sec))
             self.total = self.total - reduce
             if self.total <= 0:
                 self.total = 0
@@ -370,7 +370,7 @@ class Battery(object):
                     break
                 else:
                     pre_volt = volt
-            # print("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt)))
+            # EventMesh.debug_log("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt)))
             if pre_volt == 0:  # Input Voltarg > Highest Voltarg
                 return soc1
             elif volt_not_under == 0:
@@ -424,7 +424,7 @@ class Battery(object):
         if( volt_arg == None) :
             volt_arg = self.get_voltage()
         self.__energy = self.__get_soc(self.__temp, volt_arg)
-        # print("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy))
+        # EventMesh.debug_log("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy))
         return self.__energy
 
     def set_charge_callback(self, charge_callback):
@@ -498,9 +498,9 @@ class sosInfoCallManager(Abstract):
             EventMesh.publish("set_sos_flag",0)
             EventMesh.publish("set_sos_num",0)
             EventMesh.publish("set_hangup_mode",0)
-        print('hangup_mode disconnect',hangup_mode)
+        EventMesh.debug_log('hangup_mode disconnect',hangup_mode)
         sos_flag = EventMesh.publish("get_sos_flag")
-        print('voicecall sos_flag',sos_flag)
+        EventMesh.debug_log('voicecall sos_flag',sos_flag)
         if sos_flag == 0 :
             EventMesh.publish("set_sos_num",0)
         else:
@@ -519,7 +519,7 @@ class sosInfoCallManager(Abstract):
                         num_len = len(number)+1
                     elif len(number) == 3:
                         num_len = len(number)+2  
-                    # print("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len))
+                    # EventMesh.debug_log("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len))
                     if num > num_len :
                         if len(number) == 1:
                             number1 = str(number[0])
@@ -540,37 +540,37 @@ class sosInfoCallManager(Abstract):
                         EventMesh.publish("set_sos_flag",0)
                         EventMesh.publish("set_sos_num",0)
                     else:
-                    # print("number:{} number_len :{}".format(number,len(number)))
+                    # EventMesh.debug_log("number:{} number_len :{}".format(number,len(number)))
                         EventMesh.publish("set_sos_num",num)
                         if len(number) == 1:
                             EventMesh.publish("set_callnumer_cb",number[0])
-                            print("phone 1")
+                            EventMesh.debug_log("phone 1")
                         elif len(number) == 2:
                             if num == 1 or num == 3:
-                                print("phone 2")
+                                EventMesh.debug_log("phone 2")
                                 EventMesh.publish("set_callnumer_cb",number[1])
                             elif num == 2:
-                                print("phone 3")
+                                EventMesh.debug_log("phone 3")
                                 EventMesh.publish("set_callnumer_cb",number[0])
                         elif len(number) == 3:
                             if num == 1 or num == 4:
                                 EventMesh.publish("set_callnumer_cb",number[1])
-                                print("phone 4")
+                                EventMesh.debug_log("phone 4")
                             elif num == 2 or num == 5:
-                                print("phone 5")
+                                EventMesh.debug_log("phone 5")
                                 EventMesh.publish("set_callnumer_cb",number[2])
                             elif num == 3:
-                                print("phone 6")
+                                EventMesh.debug_log("phone 6")
                                 EventMesh.publish("set_callnumer_cb",number[0])   
         
 def voice_callback(args):
-   print('voicecall iinfo:{}'.format(args))
+   EventMesh.debug_log('voicecall iinfo:{}'.format(args))
    if args[0] == 10:
         get_UI_high_priority = EventMesh.publish("get_UI_high_priority")#如果在拨出去或者通话中屏蔽来电
         if get_UI_high_priority == 1:
             EventMesh.publish("set_interrup_incall",1)
             return
-        print('voicecall incoming call, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall incoming call, PhoneNO.: ', args[6])
         size_len = len(str(args[6]))
         tmp = []
         tmp = args[6]
@@ -590,7 +590,7 @@ def voice_callback(args):
             sos_flag = 0
             EventMesh.publish("set_sos_flag",0)
 
-        print('voicecall connected, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall connected, PhoneNO.: ', args[6])
         size_len = len(str(args[6]))
         tmp = []
         tmp = args[6]
@@ -618,25 +618,25 @@ def voice_callback(args):
         if flag == 2:
             EventMesh.publish("close_timer_all")#
         EventMesh.publish("set_call_state",0) 
-        print('voicecall disconnect end')
+        EventMesh.debug_log('voicecall disconnect end')
         
 
    elif args[0] == 13:
-        print('voicecall is waiting, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall is waiting, PhoneNO.: ', args[6])
    elif args[0] == 14:
 
-        print('voicecall dialing, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall dialing, PhoneNO.: ', args[6])
         EventMesh.publish("set_UI_high_priority",0)
         EventMesh.publish("set_call_state",1) 
         # EventMesh.publish("load_screen", {"screen": "dialing"})
 
         
    elif args[0] == 15:
-        print('voicecall alerting, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall alerting, PhoneNO.: ', args[6])
         EventMesh.publish("set_call_state",1) 
         
    elif args[0] == 16:
-        print('voicecall holding, PhoneNO.: ', args[6])
+        EventMesh.debug_log('voicecall holding, PhoneNO.: ', args[6])
 
 class DeviceInfoManager(Abstract):
     
@@ -715,23 +715,23 @@ class DeviceInfoManager(Abstract):
         self.log = LogAdapter(self.__class__.__name__)
         self.rtc = RTC()
         self.aud = audio.Audio(0)
-        print("DeviceInfoManager:1")
+        EventMesh.debug_log("DeviceInfoManager:1")
         self.gsensor = SC7A20()
-        print("DeviceInfoManager:1.0")
+        EventMesh.debug_log("DeviceInfoManager:1.0")
         self.gsensor.activate()
-        print("DeviceInfoManager:1.1")
+        EventMesh.debug_log("DeviceInfoManager:1.1")
         self.gsensor.init()
-        print("DeviceInfoManager:2")
+        EventMesh.debug_log("DeviceInfoManager:2")
         self.gsensor.set_callback(self.gsensor_cb)
         try :
             self.hsensor = HX3918()
             
         except Exception as e:
-            print("Hsensor none HX3918:{}".format(e))   
+            EventMesh.debug_log("Hsensor none HX3918:{}".format(e))   
         try :
             self.hsensor = GH3018()
         except Exception as e:
-            print("Hsensor none GH3018:{}".format(e))   
+            EventMesh.debug_log("Hsensor none GH3018:{}".format(e))   
         #
         self.hsensor.activate()
         self.hsensor.init()
@@ -739,15 +739,15 @@ class DeviceInfoManager(Abstract):
         try :
             self.hsensor.set_sar(1)
         except Exception as e:
-            print("Hsensor none set_sar:{}".format(e)) 
+            EventMesh.debug_log("Hsensor none set_sar:{}".format(e)) 
         self.old_temp_time = 0
-        # #print("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart()))
-        print("DeviceInfoManager:3")
+        # #EventMesh.debug_log("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart()))
+        EventMesh.debug_log("DeviceInfoManager:3")
         self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE)
         self.stop_temp( None, None)
         
     def post_processor_after_instantiation(self):
-        print("post_processor_after_instantiation:1")
+        EventMesh.debug_log("post_processor_after_instantiation:1")
         """订阅此类所有的事件到 EventMesh中"""
         voiceCall.setCallback(voice_callback)
         EventMesh.subscribe("screen_get_ope", self.get_device_ope)
@@ -793,7 +793,7 @@ class DeviceInfoManager(Abstract):
         EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp)
         EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp)
         EventMesh.subscribe("get_boot_time_count", self.get_boot_time_count)
-        print("post_processor_after_instantiation:2")
+        EventMesh.debug_log("post_processor_after_instantiation:2")
         self.timer_push_schedule.start(10000, 1, self.publish_event_cb)
         # self.timer_pusht_test.start(2000, 1, self.publish_test)
         # self.battery_push_schedule.start(3000, 1, self.__check_battery)
@@ -802,7 +802,7 @@ class DeviceInfoManager(Abstract):
         # 设备开机立刻更新一次参数
         self.publish_event_cb()
         
-        print("post_processor_after_instantiation:3")
+        EventMesh.debug_log("post_processor_after_instantiation:3")
 
     def publish_message_event_DeviceInfo(self,event,msg):
         self.DeviceInfo_queue.put(msg)
@@ -811,17 +811,17 @@ class DeviceInfoManager(Abstract):
     def DeviceInfo_queue_thread(self):
         while True:
             data = self.DeviceInfo_queue.get()
-            #print("DeviceInfo_queue_thread:data = {}".format(data))
+            #EventMesh.debug_log("DeviceInfo_queue_thread:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
-                    print("DeviceInfo_queue_thread:ERROR:{}".format(e))
+                    EventMesh.debug_log("DeviceInfo_queue_thread:ERROR:{}".format(e))
                     usys.print_exception(e)
 
 
     def gsensor_cb(self, para):
-        print("gsensor_cb:{}".format(para))
+        EventMesh.debug_log("gsensor_cb:{}".format(para))
         flip_sw = EventMesh.publish("get_storage_config","flip_sw")
         
         if para == 0: #跌倒报警
@@ -841,18 +841,18 @@ class DeviceInfoManager(Abstract):
     def publish_event_cb(self, *args, **kwargs):
         if self.boot_time_count < 50000000:
             self.boot_time_count += 10
-            #print("boot_time_count:{}".format(self.boot_time_count))
+            #EventMesh.debug_log("boot_time_count:{}".format(self.boot_time_count))
         EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0})  
     def optimize_temp(self,temp):
         temp += 0.5
         get_temp_time  = EventMesh.publish("get_temp_time")
-        print("temp:{}".format(temp))
+        EventMesh.debug_log("temp:{}".format(temp))
         if temp < 36 :#or temp > 37.5:
             temp = 36+urandom.random()
         if temp > 37.5:
             
             self.temp_warning += 1
-            print("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time))
+            EventMesh.debug_log("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time))
             
             if self.temp_warning*get_temp_time < 3:#高温没连续超过3次,和谐成37.5度以下
                 temp = 37+(urandom.randint(1, 4)/10)
@@ -880,7 +880,7 @@ class DeviceInfoManager(Abstract):
         self.timer_push = 0
         date_tmp = utime.localtime()
         time_tmp = utime.mktime(date_tmp)
-        # print("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp))
+        # EventMesh.debug_log("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp))
         
 
         EventMesh.publish("countdown_end_cb")
@@ -901,7 +901,7 @@ class DeviceInfoManager(Abstract):
         """定时定位"""
         #EventMesh.publish("set_upload_data",3*60)
         self.upload_time = EventMesh.publish("get_upload_data")
-        #print("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time)))
+        #EventMesh.debug_log("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time)))
         if self.upload_time != None :
             if  math.fabs(time_tmp - self.UD_time) > self.upload_time: #30分钟一次定位
                 self.UD_time = time_tmp
@@ -913,7 +913,7 @@ class DeviceInfoManager(Abstract):
                     self.gsensor.clean_status()#清除运动次数
                 else : #关闭定位
                     #EventMesh.txt_log("NO status")
-                    print("NO status")
+                    EventMesh.debug_log("NO status")
                     EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 
         EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count())
 
@@ -932,7 +932,7 @@ class DeviceInfoManager(Abstract):
             bat_total_value += self.vbat_buf[i]
         bat_total_value = bat_total_value//curr_count#一分钟更新一次电量 10个平均值
         EventMesh.publish("set_curr_battery_level",bat_total_value)
-        # print("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp))
+        # EventMesh.debug_log("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp))
         bat_tmp = EventMesh.publish("screen_get_battery")
         self.vbat_count+=10
         if self.vbat_count >= 60:
@@ -950,13 +950,13 @@ class DeviceInfoManager(Abstract):
         hour = date_tmp[3]
         min = date_tmp[4]
         old_Timesec = EventMesh.publish("get_old_time_data")
-        # print("old_Timesec",old_Timesec)
+        # EventMesh.debug_log("old_Timesec",old_Timesec)
         if old_Timesec != None:
             data = RTC().datetime()
             hour = data[4]
             min = data[5]
             next_alarm_time = utime.localtime(int(old_Timesec))
-            # print("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
+            # EventMesh.debug_log("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
             month = next_alarm_time[1]
             day = next_alarm_time[2]
             if month != data[1] or day != data[2]:
@@ -999,11 +999,11 @@ class DeviceInfoManager(Abstract):
         """电量小于20% 5分钟提醒一次"""
         get_low_btn = EventMesh.publish("get_low_bat_btn")#
         battery = EventMesh.publish("screen_get_battery")
-        # print("get_low_btn:{} self.bat_time:{}".format(get_low_btn,self.bat_time))
+        # EventMesh.debug_log("get_low_btn:{} self.bat_time:{}".format(get_low_btn,self.bat_time))
         if get_low_btn != None:#低电使能开关
             if get_low_btn == 1:
                 self.bat_time+=10
-                # print("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time))
+                # EventMesh.debug_log("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time))
                 if self.bat_time > 5*60:
                     self.bat_time = 0
                     if battery[1] <= 20 and battery[1] > 0:
@@ -1014,11 +1014,11 @@ class DeviceInfoManager(Abstract):
         
         """未联网提示关机"""
         ble=EventMesh.publish(constants.EVENT.GET_CONNECT)
-        # print("ble",ble)
+        # EventMesh.debug_log("ble",ble)
         if ble == 0:#未联网提示关机
             if battery[0] != '1':
                 self.no_smi_count+=10
-                # print("self.no_smi_count",self.no_smi_count)
+                # EventMesh.debug_log("self.no_smi_count",self.no_smi_count)
                 if self.no_smi_count >= (15*60):
                     self.no_smi_count = 0
                     EventMesh.publish("open_power_on", 2)#  #未检测到sim卡15分钟后关机
@@ -1032,7 +1032,7 @@ class DeviceInfoManager(Abstract):
             self.no_smi_count = 0
 
         msg_nums = sms.getMsgNums() #获取短信条数
-        # print("msg_nums",msg_nums)
+        # EventMesh.debug_log("msg_nums",msg_nums)
         if(msg_nums != -1):
             sms_data = sms.getSaveLoc()
             sms_max = sms_data[0][2]
@@ -1067,7 +1067,7 @@ class DeviceInfoManager(Abstract):
         if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
         # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1 and call_state == 0:
 
-            # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
+            # EventMesh.debug_log("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
             if get_temp_time != None:#定时测量体温
                 if get_temp_time > 0:
                     if get_temp_state != None:
@@ -1087,7 +1087,7 @@ class DeviceInfoManager(Abstract):
                                 self.temp_state = 1
                                 self.temp_one_state = 0
                                 EventMesh.publish("set_temp_state",2)
-                                print("AUTO temp:") 
+                                EventMesh.debug_log("AUTO temp:") 
                                 EventMesh.publish(constants.EVENT.START_TEMP)
 
                             elif (time_tmp-self.temp_time) >= 30 and self.temp_state == 1:
@@ -1116,7 +1116,7 @@ class DeviceInfoManager(Abstract):
                                         EventMesh.publish("set_history_temp_value",0)
                                         # EventMesh.publish("play_temp_value",0)#播放体温数值
                                 EventMesh.publish(constants.EVENT.STOP_TEMP)
-                                print("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
+                                EventMesh.debug_log("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                                 
                                 
 
@@ -1125,7 +1125,7 @@ class DeviceInfoManager(Abstract):
                                     self.temp_one_state+=1
                                     if self.temp_one_state == 1:
                                         EventMesh.publish("set_temp_state",3)
-                                        print("AUTO one temp:1") 
+                                        EventMesh.debug_log("AUTO one temp:1") 
                                         EventMesh.publish(constants.EVENT.START_TEMP)   
                                     elif self.temp_one_state > 3:
                                         self.temp_one_state = 0
@@ -1153,7 +1153,7 @@ class DeviceInfoManager(Abstract):
                                                 EventMesh.publish("set_history_temp_value",0)
                                                 # EventMesh.publish("play_temp_value",0)#播放体温数值
                                         EventMesh.publish(constants.EVENT.STOP_TEMP)
-                                        print("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
+                                        EventMesh.debug_log("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                                         
                         else:
                            self.temp_one_state = 0 
@@ -1173,7 +1173,7 @@ class DeviceInfoManager(Abstract):
                     if get_temp_end_state == 3:#单次测量
                         self.temp_one_state+=1
                         if self.temp_one_state == 1:
-                            print("AUTO one temp:2") 
+                            EventMesh.debug_log("AUTO one temp:2") 
                             EventMesh.publish("set_temp_state",3)
                             EventMesh.publish(constants.EVENT.START_TEMP)   
                         elif self.temp_one_state > 3:
@@ -1202,16 +1202,16 @@ class DeviceInfoManager(Abstract):
                                     EventMesh.publish("set_history_temp_value",0)
                                     # EventMesh.publish("play_temp_value",0)#播放体温数值
                             EventMesh.publish(constants.EVENT.STOP_TEMP)
-                            print("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
+                            EventMesh.debug_log("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp)) 
                             
             if hr_time[0] !=  None:
                 self.mearsure_btn = int(hr_time[0])
                 self.mearsure_timer = int(hr_time[1])
                 if self.mearsure_btn != None and self.mearsure_timer != None:
-                    # print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1]))
+                    # EventMesh.debug_log("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1]))
                     if self.mearsure_btn > 0:
                         if self.mearsure_timer > 0:
-                            #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer))
+                            #EventMesh.debug_log("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer))
                             if self.get_hr_state != 1 and self.get_spo2_state != 1:
                                 if self.get_hr_state == 0 and self.get_spo2_state == 0:
                                     if self.HR_state == 0 or self.HR_state == 3:
@@ -1229,7 +1229,7 @@ class DeviceInfoManager(Abstract):
                                         else:
                                             pass
                                             # EventMesh.publish("play_hr_value",0)#测量失败
-                                        print("stop debug1")
+                                        EventMesh.debug_log("stop debug1")
                                         EventMesh.publish(constants.EVENT.STOP_HEART)
                                         self.HR_state = 0
                                     elif self.get_spo2_state == 2 and self.HR_state == 2:
@@ -1249,7 +1249,7 @@ class DeviceInfoManager(Abstract):
                                     if (time_tmp - self.SENSOR_time) >= self.mearsure_timer:
                                         if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的
                                             if self.get_hr_state == 3:
-                                                print("stop debug2")
+                                                EventMesh.debug_log("stop debug2")
                                                 EventMesh.publish(constants.EVENT.STOP_HEART)
                                                 heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                                                 if heart_value > 50 and heart_value != None:
@@ -1278,9 +1278,9 @@ class DeviceInfoManager(Abstract):
                                         self.SENSOR_time = time_tmp
                                         self.HR_state = 0
                                     
-                                #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state))
+                                #EventMesh.debug_log("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state))
                                 if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0:
-                                    print("START_HEART:1")
+                                    EventMesh.debug_log("START_HEART:1")
                                     EventMesh.publish("set_hr_state",2)#2代表后台进入测试
                                     EventMesh.publish(constants.EVENT.START_HEART)
                                     self.HR_state = 1
@@ -1288,10 +1288,10 @@ class DeviceInfoManager(Abstract):
                                     self.HR_OneTime = 0
                                 elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1:
                                     EventMesh.publish("set_hr_state",0)#2代表后台进入测试
-                                    print("stop debug3")
+                                    EventMesh.debug_log("stop debug3")
                                     EventMesh.publish(constants.EVENT.STOP_HEART)
                                     heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                    print("heart_value:{}".format(heart_value))
+                                    EventMesh.debug_log("heart_value:{}".format(heart_value))
                                     if heart_value > 50 and heart_value != None:
                                         # EventMesh.publish("play_hr_value",heart_value)
                                         EventMesh.publish("set_history_hr_value",heart_value)
@@ -1300,18 +1300,18 @@ class DeviceInfoManager(Abstract):
                                         pass
                                         # EventMesh.publish("play_hr_value",0)
                                     #获取心率数据上传数据app
-                                    print("STOP_HEART:")
+                                    EventMesh.debug_log("STOP_HEART:")
                                 
                                     self.HR_state = 3
                                     # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试
                                     # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                    # print("START_BLOOD_OXYGEN:")
+                                    # EventMesh.debug_log("START_BLOOD_OXYGEN:")
                                 # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开
-                                #     print("STOP_BLOOD_OXYGEN:")
+                                #     EventMesh.debug_log("STOP_BLOOD_OXYGEN:")
                                 #     EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
                                 #     EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
                                 #     spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                #     print("spo2_value:{}".format(spo2_value))
+                                #     EventMesh.debug_log("spo2_value:{}".format(spo2_value))
                                 #     if spo2_value > 85 and spo2_value != None:
                                 #         EventMesh.publish("set_old_spo2_data",spo2_value)
                                 #         EventMesh.publish("set_history_spo2_value",spo2_value)
@@ -1326,7 +1326,7 @@ class DeviceInfoManager(Abstract):
                                     self.HR_state = 0
                                     self.HR_OneTime+=1
                                     if self.HR_OneTime == 1 and self.HR_Onestate == 0:
-                                        print("hr..........\r\n")
+                                        EventMesh.debug_log("hr..........\r\n")
                                         if self.get_hr_state == 3:
                                             self.Hr_Need_Open = 1
                                             EventMesh.publish("set_hr_state",3)#2代表后台进入测试
@@ -1341,11 +1341,11 @@ class DeviceInfoManager(Abstract):
                                         else:
                                             self.Spo2_Need_Open = 0
                                         self.HR_Onestate = 1
-                                        # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+                                        # EventMesh.debug_log("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
                                     elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
-                                        # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+                                        # EventMesh.debug_log("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
                                         if self.Hr_Need_Open == 1:#需要关闭心率测量
-                                            print("stop debug4")
+                                            EventMesh.debug_log("stop debug4")
                                             EventMesh.publish(constants.EVENT.STOP_HEART)
                                             heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                                             if heart_value > 50 and heart_value != None:
@@ -1395,7 +1395,7 @@ class DeviceInfoManager(Abstract):
                                                 
                                                 
                                     elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
-                                        print("HR_OneTime:....05")
+                                        EventMesh.debug_log("HR_OneTime:....05")
                                         if self.set_hsenor_crt == 2:
                                             EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
                                             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
@@ -1411,7 +1411,7 @@ class DeviceInfoManager(Abstract):
 
                                         elif self.set_hsenor_crt == 1:
                                             EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                            print("stop debug5")
+                                            EventMesh.debug_log("stop debug5")
                                             EventMesh.publish(constants.EVENT.STOP_HEART)
                                             heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                                             if heart_value > 50 and heart_value != None:
@@ -1435,7 +1435,7 @@ class DeviceInfoManager(Abstract):
                                     self.HR_OneTime = 0
                                     self.set_hsenor_crt = 0
                     else:
-                        #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate))
+                        #EventMesh.debug_log("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate))
                         self.SENSOR_time = time_tmp#进入最后一次的时间戳
                         self.old_time = 0
 
@@ -1461,12 +1461,12 @@ class DeviceInfoManager(Abstract):
                                     self.HR_Onestate = 1
                             
                                 elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
-                                    print("stop_heart Onec ")
+                                    EventMesh.debug_log("stop_heart Onec ")
                                     if self.Hr_Need_Open == 1:#需要关闭心率测量
-                                        print("stop debug6")
+                                        EventMesh.debug_log("stop debug6")
                                         EventMesh.publish(constants.EVENT.STOP_HEART)
                                         heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                        print("stop_heart heart_value:{}".format(heart_value))
+                                        EventMesh.debug_log("stop_heart heart_value:{}".format(heart_value))
                                         if heart_value > 50 and heart_value != None:
                                             # EventMesh.publish("play_hr_value",heart_value)
                                             EventMesh.publish("set_history_hr_value",heart_value)
@@ -1490,7 +1490,7 @@ class DeviceInfoManager(Abstract):
                                             EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
                                             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
                                             spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                            print("spo2_value:{}.......01..".format(spo2_value))
+                                            EventMesh.debug_log("spo2_value:{}.......01..".format(spo2_value))
                                             if spo2_value > 85 and spo2_value != None:
                                                 # EventMesh.publish("play_spo2_value",spo2_value)
                                                 EventMesh.publish("set_history_spo2_value",spo2_value)
@@ -1508,7 +1508,7 @@ class DeviceInfoManager(Abstract):
                                                 self.HR_Onestate = 0
                                                 self.HR_OneTime = 0
                                                 self.set_hsenor_crt = 2#血氧关闭
-                                            print("STOP_BLOOD_OXYGEN:....06.....")
+                                            EventMesh.debug_log("STOP_BLOOD_OXYGEN:....06.....")
                                             
                                 elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
                                     if self.set_hsenor_crt == 2:
@@ -1524,7 +1524,7 @@ class DeviceInfoManager(Abstract):
                                             # EventMesh.publish("play_spo2_value",0)
                                     elif self.set_hsenor_crt == 1:
                                         EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                        print("stop debug7")
+                                        EventMesh.debug_log("stop debug7")
                                         EventMesh.publish(constants.EVENT.STOP_HEART)
                                         heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                                         if heart_value > 50 and heart_value != None:
@@ -1556,7 +1556,7 @@ class DeviceInfoManager(Abstract):
                 if get_hr_state != None and get_spo2_state != None:
                     if get_hr_state == 2 or get_hr_state == 3:
                         EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
-                        print("stop debug8")
+                        EventMesh.debug_log("stop debug8")
                         EventMesh.publish(constants.EVENT.STOP_HEART) 
                     elif get_spo2_state == 2 or get_spo2_state == 3:
                         EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
@@ -1609,7 +1609,7 @@ class DeviceInfoManager(Abstract):
                     if time_s != 0:
                         if (time_tmp - time_s) >= 60:#大于60s关闭测试
                             EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                            print("stop debug7")
+                            EventMesh.debug_log("stop debug7")
                             EventMesh.publish(constants.EVENT.STOP_HEART)
                             heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                             if heart_value > 50 and heart_value != None:
@@ -1621,7 +1621,7 @@ class DeviceInfoManager(Abstract):
                         else :
                             if WEAR  != 1:
                                 EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                print("stop debug7")
+                                EventMesh.debug_log("stop debug7")
                                 EventMesh.publish(constants.EVENT.STOP_HEART)                               
                                 EventMesh.publish("play_hr_value",0) 
                 pass
@@ -1631,7 +1631,7 @@ class DeviceInfoManager(Abstract):
                     if time_s != 0:
                         if (time_tmp - time_s) >= 60:#大于60s关闭测试
                             EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
-                            print("stop spo2 debug7")
+                            EventMesh.debug_log("stop spo2 debug7")
                             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
                             spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
                             if spo2_value > 85 and spo2_value != None:
@@ -1643,7 +1643,7 @@ class DeviceInfoManager(Abstract):
                         else :
                             if WEAR  != 1:
                                 EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
-                                print("stop debug8")
+                                EventMesh.debug_log("stop debug8")
                                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)                               
                                 EventMesh.publish("play_spo2_value",0) 
                 pass
@@ -1653,10 +1653,10 @@ class DeviceInfoManager(Abstract):
                 if time_s != None:
                     if time_s != 0:
                         if (time_tmp - time_s) >= 30:#大于60s关闭测试
-                            print("体温测量结束")
+                            EventMesh.debug_log("体温测量结束")
                             temp = EventMesh.publish(constants.EVENT.GET_TEMP)       
                             temp = self.optimize_temp(temp)
-                            print("temp",temp)
+                            EventMesh.debug_log("temp",temp)
                             EventMesh.publish("set_temp_state",0)
                             tmp_f_tmp = 0
                             tmp_d_tmp = 0
@@ -1682,7 +1682,7 @@ class DeviceInfoManager(Abstract):
                         else :
                             if WEAR  != 1:
                                 EventMesh.publish("set_temp_state",0)#0代表g关闭测试
-                                print("stop debug9")
+                                EventMesh.debug_log("stop debug9")
                                 EventMesh.publish(constants.EVENT.STOP_TEMP)                               
                                 EventMesh.publish("play_temp_value",0) 
 
@@ -1692,7 +1692,7 @@ class DeviceInfoManager(Abstract):
         
 
         if battery[0] == '1':
-            # print("battery[1]",battery[1])
+            # EventMesh.debug_log("battery[1]",battery[1])
             if self.vbat_full_flag <= 120:
                 self.vbat_full_flag+=10
                 if self.vbat_full_flag == 60:#开机检测一次如果是充电标识为1就不再提示
@@ -1702,7 +1702,7 @@ class DeviceInfoManager(Abstract):
                 if battery[1] >= 100:
                     if self.charge_full_count == 0:#充电已满
                         EventMesh.publish("set_usb",3)#
-                        print("charge R_CHARGE_full")
+                        EventMesh.debug_log("charge R_CHARGE_full")
                         self.charge_full_count = 1
                 
         else:
@@ -1793,7 +1793,7 @@ class DeviceInfoManager(Abstract):
         tmp = 0
        
         tmp =  self.gsensor.get_step() 
-        # print("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp)
+        # EventMesh.debug_log("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp)
         self.step[0]= tmp 
         self.step[1] = XYZ[0]
         self.step[2] = XYZ[1]
@@ -1838,7 +1838,7 @@ class DeviceInfoManager(Abstract):
         vbat = EventMesh.publish("get_battery",temp)
         if vbat == None:
             vbat = 100
-        # print("vbat",vbat)
+        # EventMesh.debug_log("vbat",vbat)
         # if temp != None :
         #     if temp <= 3505:
         #         vbat = 0 
@@ -1926,25 +1926,25 @@ class DeviceInfoManager(Abstract):
         return self.PING
 
     def set_connect(self, topic, msg):
-        #print("set_connect:{}".format(msg))
+        #EventMesh.debug_log("set_connect:{}".format(msg))
         self.connect = msg
     def get_connect(self, topic, msg):
         return self.connect
 
     def start_blood_oxygen(self, topic, msg):
-        print("start_blood_oxygen!!!")
+        EventMesh.debug_log("start_blood_oxygen!!!")
         self.hsensor.open_blood_oxygen()
 
     def start_heart(self, topic, msg):
-        print("start_heart!!!")
+        EventMesh.debug_log("start_heart!!!")
         self.hsensor.open_heart()
 
     def stop_blood_oxygen(self, topic, msg):
-        print("stop_blood_oxygen!!!")
+        EventMesh.debug_log("stop_blood_oxygen!!!")
         self.hsensor.close()
 
     def stop_heart(self, topic, msg):
-        print("stop_heart!!!")
+        EventMesh.debug_log("stop_heart!!!")
         self.hsensor.close()
 
     def get_blood_oxygen(self, topic, msg):
@@ -1965,7 +1965,7 @@ class DeviceInfoManager(Abstract):
         self.hsensor.set_sleep()
 
     def start_temp(self, topic, msg):
-        print("start_temp!!!!!!!")
+        EventMesh.debug_log("start_temp!!!!!!!")
         WHO_AM_I = bytearray([0x01, 0])
         I2C_SLAVE_ADDR = 0x49
         #I2C_SLAVE_ADDR = 0x48
@@ -1973,7 +1973,7 @@ class DeviceInfoManager(Abstract):
         data = bytearray([0x61A0, 0])   # 唤醒
         return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
     def stop_temp(self, topic, msg):
-        print("stop_temp!!!!!!!")
+        EventMesh.debug_log("stop_temp!!!!!!!")
         WHO_AM_I = bytearray([0x01, 0])
         I2C_SLAVE_ADDR = 0x49
         #I2C_SLAVE_ADDR = 0x48
@@ -1987,11 +1987,11 @@ class DeviceInfoManager(Abstract):
         #I2C_SLAVE_ADDR = 0x48
         r_data = bytearray(2)
         self.i2c0.read(I2C_SLAVE_ADDR, WHO_AM_I, 1, r_data, 2, 0)
-        #print("temp_data:{}".format(r_data))
+        #EventMesh.debug_log("temp_data:{}".format(r_data))
         temp_s = ((r_data[0]<<8) | (r_data[1]))>>4
-        #print("temp_s:{}".format(temp_s))
+        #EventMesh.debug_log("temp_s:{}".format(temp_s))
         temp_data = temp_s * 0.0625
-        print("temp_data:{}".format(temp_data))
+        EventMesh.debug_log("temp_data:{}".format(temp_data))
         return temp_data
  
             
@@ -2015,12 +2015,12 @@ class DeviceInfoManager(Abstract):
         status = state
 
         if status == 1:#插入USB
-            print("charge R_CHARGE_in")
+            EventMesh.debug_log("charge R_CHARGE_in")
             EventMesh.publish("set_usb", 1)#
             pass
         elif status == 0:#拨出usbs
             EventMesh.publish("set_usb", 2)#
-            print("charge R_CHARGE_out")
+            EventMesh.debug_log("charge R_CHARGE_out")
             
             
 
@@ -2057,8 +2057,15 @@ class LocationManager(Abstract):
         self.location_queue = Queue(100)
         self.lpm_fd = None
         self.start_agps = 0
-        quecgnss.init()
-        quecgnss.gnssEnable(0)
+        read_data = EventMesh.publish("get_storage_config","isOpenGNSS")#获取是否打开GNSS
+        if read_data != None:
+            self.isOpenGNSS = read_data
+        else:#默认关闭GNSS
+            self.isOpenGNSS = "0"
+            EventMesh.publish("set_storage_config",["isOpenGNSS",self.isOpenGNSS])
+        if self.isOpenGNSS == "1":
+            quecgnss.init()
+            quecgnss.gnssEnable(0)
     @staticmethod
     def get_date():
         return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
@@ -2101,7 +2108,7 @@ class LocationManager(Abstract):
         self.cell_data = []
         self.location_timer_count = 0
         self.GSV_sig_ok_count = 0
-        print("start_location:{}".format(msg))
+        EventMesh.debug_log("start_location:{}".format(msg))
         if( self.location_flag == 1):
             return
         _thread.stack_size((9+5)*1024)
@@ -2114,7 +2121,7 @@ class LocationManager(Abstract):
 
 
     def start_location_test(self, event, msg):
-        print("start_location_test")
+        EventMesh.debug_log("start_location_test")
         
         self.location_type = 1
         if( self.location_flag == 1):
@@ -2139,11 +2146,11 @@ class LocationManager(Abstract):
 
     def WIFI_INFO(self, event, msg):
         self.wifi_data = msg
-        # print("WIFI_INFO:")
-        # print([msg[0],msg])
+        # EventMesh.debug_log("WIFI_INFO:")
+        # EventMesh.debug_log([msg[0],msg])
 
     def WIFI_scan_open(self, event, msg):
-        #print("WIFI_scan_open")
+        #EventMesh.debug_log("WIFI_scan_open")
         
 
         if wifiScan.getState() == False :
@@ -2152,23 +2159,25 @@ class LocationManager(Abstract):
             wifiScan.setCfgParam(6, 2, 5,  0)  #设置WiFi参数,10秒上层,两轮,最多6个,6秒底层,PS优先
             wifiScan.setCallback(wifiScan_cb) #注册回调函数
             wifiScan.asyncStart()
-            #print("wifiScan.asyncStart")
+            #EventMesh.debug_log("wifiScan.asyncStart")
         else :
-            print("WIFI_scan_open:error1") 
+            EventMesh.debug_log("WIFI_scan_open:error1") 
     def gps_open(self, event, msg):
-        #print("publish:gps_open")
-        #quecgnss.init()
-        quecgnss.gnssEnable(2)
-        #self.gps.__gps_nmea_data_clean()
+        if self.isOpenGNSS == "1":
+            #EventMesh.debug_log("publish:gps_open")
+            #quecgnss.init()
+            quecgnss.gnssEnable(2)
+            #self.gps.__gps_nmea_data_clean()
     def gps_close(self, event, msg):
-        quecgnss.gnssEnable(0)
+        if self.isOpenGNSS == "1":
+            quecgnss.gnssEnable(0)
     def location_timer(self, *args, **kwargs):
         
         self.location_timer_count = self.location_timer_count +1
         self.location_check_data_timer_count = self.location_check_data_timer_count+1
 
     def Location_send(self, msg) :
-        #print("Location_send1")
+        #EventMesh.debug_log("Location_send1")
         if self.location_queue.empty() == True:
             return
         date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
@@ -2264,11 +2273,11 @@ class LocationManager(Abstract):
         send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
         send_data += ",%d,%s"%(WIFI_num,WIFI_data)
         send_data+=",%s"%(precision)
-        #print("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
+        #EventMesh.debug_log("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
         while True:
             if self.location_queue.empty() == False:
                 TYPE = self.location_queue.get()
-                #print("Location_send3:{}".format(TYPE))
+                #EventMesh.debug_log("Location_send3:{}".format(TYPE))
                 EventMesh.publish(TYPE,send_data)
             else :
                 break
@@ -2313,11 +2322,11 @@ class LocationManager(Abstract):
         if self.lpm_fd == None:
             self.lpm_fd = pm.create_wakelock("test_lock", len("test_lock"))
         pm.wakelock_lock(self.lpm_fd)
-        print("location_thread:1")
+        EventMesh.debug_log("location_thread:1")
         EventMesh.publish(constants.EVENT.GPSOPEN)
-        print("location_thread:2")
+        EventMesh.debug_log("location_thread:2")
         #self.timer_read_GPS_info.start(1000, 1, self.location_timer)
-        print("location_thread:3")
+        EventMesh.debug_log("location_thread:3")
         #utime.sleep_ms(1000)
         self.location_timer_count = 0
         #quecgnss.read(4096)#去掉第一次错误数据
@@ -2336,92 +2345,92 @@ class LocationManager(Abstract):
                 #     pm.sclkEx_set(0, 1, 5)
                 if self.location_check_data_timer_count >= 1 :#3秒查一次基站数据和wifi数据
                     self.location_check_data_timer_count = 0
-                    #print(self.location_timer_count)
+                    #EventMesh.debug_log(self.location_timer_count)
                     GSV_dict= {}
-                    
-                    #检查GNSS数据
-                    if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
+                    if self.isOpenGNSS == "1":                    
+                        #检查GNSS数据
+                        if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
 
-                        pass
-                        tmp_ok_count = 0
-                        tmp_very_ok_count = 0
-                        gsv_data = quecgnss.get_gsv()
-                        rmc_data = quecgnss.get_rmc()
-                        gga_data = quecgnss.get_gga()
-                        vtg_data = quecgnss.get_vtg()
-                        # print("gsv:{}".format(quecgnss.get_gsv()))
-                        # print("gga:{}".format(quecgnss.get_gga()))
-                        # print("rmc:{}".format(quecgnss.get_rmc()))
-                        # print("vtg:{}".format(quecgnss.get_vtg())) 
-                        for i in range(len(gsv_data)) :
-                            
-                            if i % 2 == 0:
-                                if i+1 >= len(gsv_data) :
-                                    # print("gsv_data num error!!")
-                                    break
-                                GSV_dict[gsv_data[i]] = gsv_data[i+1]
-                                #print("type:gsv_data{}".format(type(gsv_data[i+1])))
-                                try:
-                                    #print("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
-                                    if gsv_data[i+1] :
-                                        if (gsv_data[i+1])>=20:
-                                            tmp_ok_count +=1   
-                                        if (gsv_data[i+1])>=30:
-                                            tmp_very_ok_count +=1  
-                                            
-                                except Exception as e:
-                                    usys.print_exception(e)
+                            pass
+                            tmp_ok_count = 0
+                            tmp_very_ok_count = 0
+                            gsv_data = quecgnss.get_gsv()
+                            rmc_data = quecgnss.get_rmc()
+                            gga_data = quecgnss.get_gga()
+                            vtg_data = quecgnss.get_vtg()
+                            # EventMesh.debug_log("gsv:{}".format(quecgnss.get_gsv()))
+                            # EventMesh.debug_log("gga:{}".format(quecgnss.get_gga()))
+                            # EventMesh.debug_log("rmc:{}".format(quecgnss.get_rmc()))
+                            # EventMesh.debug_log("vtg:{}".format(quecgnss.get_vtg())) 
+                            for i in range(len(gsv_data)) :
                                 
-                        if(tmp_ok_count > self.GSV_sig_ok_count ):
-                            self.GSV_sig_ok_count = tmp_ok_count
-                        if(tmp_very_ok_count > self.GSV_sig_very_ok_count ):
-                            self.GSV_sig_very_ok_count = tmp_very_ok_count
-                        match_rmc_data = rmc_data.split(",")
-                        if len (match_rmc_data)>3: #有rmc数据
-                                 if match_rmc_data[2] == 'A':    
-                                    match_gga_data = gga_data.split(",")
-                                    if len(match_gga_data) >4: #数据全
-                                        match_vtg_data = vtg_data.split(",")
-                                        gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期
-                                        #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1])
-                                        latitude = "0,N" #纬度
-                                        latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".")
-                                        if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
-                                            latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6])
-                                            latitude = "%s,%s"%(latitude,match_rmc_data[4] )
-
-                                        longitude = "0,E"#经度
-                                        longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".")
-                                        if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5:
-                                            longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6])
-                                            longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1])
-                                        
-                                        high = "0"#高度
-                                        high = str(self.GxGGA_altitude(gga_data))
-                                        number = "0"#可用卫星
-                                        precision = "5.8"#精度
-                                        if len(match_gga_data)>5 :
-                                            if match_gga_data[7]:
-                                                number = match_gga_data[7]
-                                            if match_gga_data[8]:
-                                                precision = match_gga_data[8]
-                                        direction = "249.5" #方向
-                                        speed = '0.00'    #速度    
-                                        if(len(match_vtg_data)>5 ):
-                                            if match_vtg_data[1]:
-                                                direction =  match_vtg_data[1]
-                                            if match_vtg_data[7]:    
-                                                speed =  match_vtg_data[7]
-                                        self.gps_data = {
-                                            "latitude": latitude,
-                                            "longitude": longitude,
-                                            "high": high,
-                                            "direction": direction,
-                                            "speed": speed,
-                                            "number": number, 
-                                            "date":  gps_date,
-                                            "precision":  precision
-                                        }
+                                if i % 2 == 0:
+                                    if i+1 >= len(gsv_data) :
+                                        # EventMesh.debug_log("gsv_data num error!!")
+                                        break
+                                    GSV_dict[gsv_data[i]] = gsv_data[i+1]
+                                    #EventMesh.debug_log("type:gsv_data{}".format(type(gsv_data[i+1])))
+                                    try:
+                                        #EventMesh.debug_log("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
+                                        if gsv_data[i+1] :
+                                            if (gsv_data[i+1])>=20:
+                                                tmp_ok_count +=1   
+                                            if (gsv_data[i+1])>=30:
+                                                tmp_very_ok_count +=1  
+                                                
+                                    except Exception as e:
+                                        usys.print_exception(e)
+                                    
+                            if(tmp_ok_count > self.GSV_sig_ok_count ):
+                                self.GSV_sig_ok_count = tmp_ok_count
+                            if(tmp_very_ok_count > self.GSV_sig_very_ok_count ):
+                                self.GSV_sig_very_ok_count = tmp_very_ok_count
+                            match_rmc_data = rmc_data.split(",")
+                            if len (match_rmc_data)>3: #有rmc数据
+                                    if match_rmc_data[2] == 'A':    
+                                        match_gga_data = gga_data.split(",")
+                                        if len(match_gga_data) >4: #数据全
+                                            match_vtg_data = vtg_data.split(",")
+                                            gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期
+                                            #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1])
+                                            latitude = "0,N" #纬度
+                                            latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".")
+                                            if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
+                                                latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6])
+                                                latitude = "%s,%s"%(latitude,match_rmc_data[4] )
+
+                                            longitude = "0,E"#经度
+                                            longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".")
+                                            if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5:
+                                                longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6])
+                                                longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1])
+                                            
+                                            high = "0"#高度
+                                            high = str(self.GxGGA_altitude(gga_data))
+                                            number = "0"#可用卫星
+                                            precision = "5.8"#精度
+                                            if len(match_gga_data)>5 :
+                                                if match_gga_data[7]:
+                                                    number = match_gga_data[7]
+                                                if match_gga_data[8]:
+                                                    precision = match_gga_data[8]
+                                            direction = "249.5" #方向
+                                            speed = '0.00'    #速度    
+                                            if(len(match_vtg_data)>5 ):
+                                                if match_vtg_data[1]:
+                                                    direction =  match_vtg_data[1]
+                                                if match_vtg_data[7]:    
+                                                    speed =  match_vtg_data[7]
+                                            self.gps_data = {
+                                                "latitude": latitude,
+                                                "longitude": longitude,
+                                                "high": high,
+                                                "direction": direction,
+                                                "speed": speed,
+                                                "number": number, 
+                                                "date":  gps_date,
+                                                "precision":  precision
+                                            }
 # ***********************************************************************************
 
 
@@ -2472,7 +2481,7 @@ class LocationManager(Abstract):
                     #     EventMesh.txt_log("GGA_count<3:timer:{} ok_count:{} count:{}".format(self.location_timer_count,self.GSV_sig_ok_count,self.GGA_count))
                     #     self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
                         
-                    if self.GSV_sig_ok_count <= 1 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个
+                    if (self.isOpenGNSS == "1" or self.GSV_sig_ok_count <= 1) and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个
                         EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位   
                         #EventMesh.txt_log("GSV_sig_ok_count<3:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count))
                         self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
@@ -2483,13 +2492,13 @@ class LocationManager(Abstract):
                 #EventMesh.txt_log("self.GSV_sig_ok_count :{}".format(self.GSV_sig_ok_count))
                 #EventMesh.publish("set_old_step_value",self.location_timer_count)
                 
-                #print("location_timer_count:{}".format(self.location_timer_count))
+                #EventMesh.debug_log("location_timer_count:{}".format(self.location_timer_count))
                 
             except Exception as e:
                 usys.print_exception(e)
                 EventMesh.txt_log("location_thread:ERROR:".format(e))
-                #print("location_thread:ERROR:{}".format(usys.print_exception(e)))
-                print("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data))
+                #EventMesh.debug_log("location_thread:ERROR:{}".format(usys.print_exception(e)))
+                EventMesh.debug_log("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data))
                 #self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
                 EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 
             utime.sleep_ms(500)
@@ -2504,7 +2513,7 @@ class LocationManager(Abstract):
         if self.lpm_fd != None:
             pm.wakelock_unlock(self.lpm_fd)
         #pm.delete_wakelock(lpm_fd)
-        print("CLOSE_LOCATION")
+        EventMesh.debug_log("CLOSE_LOCATION")
         #EventMesh.txt_log("CLOSE_LOCATION")
 
                 
@@ -2519,7 +2528,7 @@ class AddrBookManager(Abstract):
         if self.check_json == True:
             with open("/usr/static/storage_file/phonebook.json","r",encoding="utf-8") as fd:
                 self.read_phonebook = ujson.load(fd)
-                print("读取电话本")
+                EventMesh.debug_log("读取电话本")
 
     def post_processor_after_instantiation(self):
         EventMesh.subscribe("get_phonebook_list", self.get)
@@ -2550,7 +2559,7 @@ class AddrBookManager(Abstract):
                 EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
         else:
             EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
-        print("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook)))
+        EventMesh.debug_log("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook)))
 
     def call_phonebook_two_call(self, event, msg):
         name = ''
@@ -2572,7 +2581,7 @@ class AddrBookManager(Abstract):
                 EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
         else:
             EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
-            print("call_phonebook_two_call name:{} key_tmp:{}".format(name,key_tmp))
+            EventMesh.debug_log("call_phonebook_two_call name:{} key_tmp:{}".format(name,key_tmp))
     
     def call_phonebook_three_call(self, event, msg):
         name = ''
@@ -2594,7 +2603,7 @@ class AddrBookManager(Abstract):
                 EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
         else:
             EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
-        print("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp))
+        EventMesh.debug_log("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp))
 
     def set(self, event, msg):
         self.check_json = msg[0]
@@ -2615,13 +2624,13 @@ class MsgManager(Abstract):
     def get_msg_nums(self, event, msg):
 
         self.msg_nums = sms.getMsgNums() 
-        print("self.msg_nums {}:".format(self.msg_nums))
+        EventMesh.debug_log("self.msg_nums {}:".format(self.msg_nums))
         return self.msg_nums
     
     def get_msg_detail(self, event, msg):
         
         # self.msg_detail = sms.searchTextMsg(self.msg_nums)
-        # print("self.msg_detai {}:".format(self.msg_detai))
+        # EventMesh.debug_log("self.msg_detai {}:".format(self.msg_detai))
         return{
             "小明":"有内鬼,停止交易",
             "小红":"今晚十点一起吃饭"
@@ -2641,11 +2650,11 @@ class MsgdetailManager(Abstract):
 
     def save_msg_name(self, event, msg): 
         self.msg_name = str(msg)
-        print("save_msg_name:msg".format(msg))
+        EventMesh.debug_log("save_msg_name:msg".format(msg))
     
     def save_msg_content(self, event, msg):
         self.msg_content = str(msg)
-        print("save_msg_content:msg".format(msg))
+        EventMesh.debug_log("save_msg_content:msg".format(msg))
     
     def get_msg_content(self, event, msg):
         return self.msg_content
@@ -2662,7 +2671,7 @@ class CallLogManager(Abstract):
         if self.check_json == True:
             with open("/usr/static/storage_file/Call_log.json","r",encoding="utf-8") as fd:
                 self.read_call_log = ujson.load(fd)
-                print("读取通话记录")
+                EventMesh.debug_log("读取通话记录")
 
     def post_processor_after_instantiation(self):
         EventMesh.subscribe("get_call_log_list", self.get)
@@ -2789,7 +2798,7 @@ class gethistoryDataManager(Abstract):
             # if len(self.read_histroy_temp_data) >= 7:
             #     sort_new = {}
             #     sort_new = sorted(self.read_histroy_temp_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-            #     print(sort_new)
+            #     EventMesh.debug_log(sort_new)
             #     for i in range(len(self.read_histroy_temp_data)-1):
             #         sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
             #         self.read_histroy_temp_data[i] = sort_new[i]
@@ -2800,7 +2809,7 @@ class gethistoryDataManager(Abstract):
 
             # with open("/usr/static/storage_file/history_temp.json","w",encoding="utf-8") as fd:
             #     ujson.dump(self.read_histroy_temp_data,fd)
-            #print(self.read_histroy_temp_data)
+            #EventMesh.debug_log(self.read_histroy_temp_data)
             pass
         else:
             pass
@@ -2824,7 +2833,7 @@ class gethistoryDataManager(Abstract):
             if len(self.read_histroy_hr_data) >= 7:
                 sort_new = {}
                 sort_new = sorted(self.read_histroy_hr_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-                print(sort_new)
+                EventMesh.debug_log(sort_new)
                 for i in range(len(self.read_histroy_hr_data)-1):
                     sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
                     self.read_histroy_hr_data[i] = sort_new[i]
@@ -2855,7 +2864,7 @@ class gethistoryDataManager(Abstract):
             # if len(self.read_histroy_spo2_data) >= 7:
             #     sort_new = {}
             #     sort_new = sorted(self.read_histroy_spo2_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-            #     print(sort_new)
+            #     EventMesh.debug_log(sort_new)
             #     for i in range(len(self.read_histroy_spo2_data)-1):
             #         sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
             #         self.read_histroy_spo2_data[i] = sort_new[i]
@@ -2866,7 +2875,7 @@ class gethistoryDataManager(Abstract):
 
             # with open("/usr/static/storage_file/history_spo2.json","w",encoding="utf-8") as fd:
             #     ujson.dump(self.read_histroy_spo2_data,fd)
-            # #print(self.read_histroy_spo2_data)
+            # #EventMesh.debug_log(self.read_histroy_spo2_data)
             #播放语音
             # EventMesh.publish("set_hr_blood_led",2)#测量成功
             pass
@@ -3106,7 +3115,7 @@ class getStorageDataManager(Abstract):#获取内存数据
         EventMesh.subscribe("get_storage_config", self.get_storage_config)
 
     def set_storage_data(self, event, msg): 
-        # print("set_storage_data:{}".format(msg))
+        # EventMesh.debug_log("set_storage_data:{}".format(msg))
         if msg != None:
             self.config_data = msg
             with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
@@ -3114,29 +3123,29 @@ class getStorageDataManager(Abstract):#获取内存数据
     
 
     def set_storage_config(self,event,msg): 
-        # print("set_storage_key_data1:{}".format(msg))
+        # EventMesh.debug_log("set_storage_key_data1:{}".format(msg))
         if len(msg) >= 2:
             self.config_data[msg[0]]=msg[1]
-            # print("set_storage_key_data2:{}".format(self.config_data[msg[0]]))
+            # EventMesh.debug_log("set_storage_key_data2:{}".format(self.config_data[msg[0]]))
             EventMesh.publish("publish_message_event_ui",{"func":self.set_storage_save,"data":0})
     def set_storage_save(self, data): 
             with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
                 ujson.dump(self.config_data,fd)
     def get_storage_data(self, event, msg): 
-        # print("get_storage_data:{}".format(self.config_data))
+        # EventMesh.debug_log("get_storage_data:{}".format(self.config_data))
         return self.config_data 
     def get_storage_config(self,event,msg):
-        # print("get_storage_key_data1:{}".format(msg))
+        # EventMesh.debug_log("get_storage_key_data1:{}".format(msg))
         b = msg in self.config_data.keys()
         if b == True:
-            # print("get_storage_key_data2:{}".format(self.config_data[msg]))
+            # EventMesh.debug_log("get_storage_key_data2:{}".format(self.config_data[msg]))
             return self.config_data[msg]
         else :
             return None
         # try:
         #     return self.config_data[msg]
         # except:
-        #     print("get_storage_key_data:none key:{}",msg)
+        #     EventMesh.debug_log("get_storage_key_data:none key:{}",msg)
         #     return None
 #定位频率
 class getUpLoadDataManager(Abstract):#
@@ -3483,9 +3492,9 @@ class ClockManager(Abstract):
 
     def set(self, event, msg):
         global alarm_list
-        print("msg = {}".format(msg))
+        EventMesh.debug_log("msg = {}".format(msg))
         idx = msg.get("idx")
-        print("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
+        EventMesh.debug_log("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
         alarm_list[idx]["hour"] = msg["hour"]
         alarm_list[idx]["minute"] = msg["minute"]
         alarm_list[idx]["days"] = msg["days"]
@@ -3497,7 +3506,7 @@ class ClockManager(Abstract):
     def read_alarminjson(self, event, msg):
         IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") 
         global alarm_list     
-        print("IFEXIST:{}".format(IFEXIST))
+        EventMesh.debug_log("IFEXIST:{}".format(IFEXIST))
         if IFEXIST == True:
             with open("/usr/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
                 alarm_list = ujson.load(fd)
@@ -3507,14 +3516,14 @@ class ClockManager(Abstract):
 
         global alarm_list
         EventMesh.publish("read_alarminjson")
-        print("msg:{}".format(msg))
+        EventMesh.debug_log("msg:{}".format(msg))
         for i in range(0,2):#开关机固定是 idx 0 1
             off_msg1 = msg[i+1]
             msg_tmp1 = off_msg1.split(':')
             start_hour = int(msg_tmp1[0])
             start_min = int(msg_tmp1[1])
             enable = int(msg[0])
-            print("start_hour:{} start_min:{} enable:{}",start_hour,start_min,enable)
+            EventMesh.debug_log("start_hour:{} start_min:{} enable:{}",start_hour,start_min,enable)
             EventMesh.publish("set_boot_off_time",[msg[0],msg[1],msg[2]])
 
             alarm_list[i]["idx"]=i
@@ -3528,7 +3537,7 @@ class ClockManager(Abstract):
             # alarm_list.append({"idx": i, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10})
 
         
-        # print("alarm_list----len- :{} alarm_list:{}".format(len(alarm_list),alarm_list))
+        # EventMesh.debug_log("alarm_list----len- :{} alarm_list:{}".format(len(alarm_list),alarm_list))
         with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
         EventMesh.publish("push_update_alarm_show")
@@ -3540,22 +3549,22 @@ class ClockManager(Abstract):
 
     def remove_alarm(self, event, msg):
         global alarm_list
-        print("ddddddddddddddddddd:",msg)
+        EventMesh.debug_log("ddddddddddddddddddd:",msg)
         idx = msg.get("idx")
-        print("delete_here1-----{},{}:".format(idx,msg))
+        EventMesh.debug_log("delete_here1-----{},{}:".format(idx,msg))
 
         for i, alarm in enumerate(alarm_list):
-            print("delete_here2-----{},{}:".format(i,alarm))
+            EventMesh.debug_log("delete_here2-----{},{}:".format(i,alarm))
 
             if alarm["idx"] == idx:
                 del alarm_list[i]
-                print("delete_here3-----",alarm_list)
+                EventMesh.debug_log("delete_here3-----",alarm_list)
 
                 #删除闹钟后,对idx重新排序
                 if alarm_list:
                     for j in range(i,len(alarm_list)):
                         alarm_list[j]["idx"] -= 1
-                        print("delete_here4-----",alarm_list)
+                        EventMesh.debug_log("delete_here4-----",alarm_list)
 
         with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
@@ -3565,25 +3574,25 @@ class ClockManager(Abstract):
         return self.idx
 
     def _rtc_callback(self,args):
-        print("---!!!!!!pfff neew alarm_ring!!!!!!!---,idx:",args)
+        EventMesh.debug_log("---!!!!!!pfff neew alarm_ring!!!!!!!---,idx:",args)
         global alarm_list
         EventMesh.publish("read_alarminjson")
         idx = self.idx
-        print("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
+        EventMesh.debug_log("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
         #判断是否是单次闹钟,如果是,则将开关状态设置为关闭
         # for i in range(len(alarm_list)):
         #     if alarm_list[i]["idx"] == self.idx:
         #         idx = i
         if not alarm_list[idx]["days"] :
-            print("关闭1:",alarm_list[idx]["days"])
-            print("关闭2:",alarm_list [idx]["days"])
+            EventMesh.debug_log("关闭1:",alarm_list[idx]["days"])
+            EventMesh.debug_log("关闭2:",alarm_list [idx]["days"])
             alarm_list[idx]["enabled"] = False
             with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
                 ujson.dump(alarm_list,fd)
         
         #设置下一个闹钟,定时开关机功能
         msg_data = EventMesh.publish("get_boot_off_time")
-        print("msg_tmp:{}".format(msg_data))
+        EventMesh.debug_log("msg_tmp:{}".format(msg_data))
         off_on = 1
         off_start = "06:00"
         off_end = "23:00"
@@ -3605,7 +3614,7 @@ class ClockManager(Abstract):
         current = rtc_now_time[4]*60+rtc_now_time[5]
         cur_day = rtc_now_time[3]
         
-        print("off_on:{} current:{} start_min:{} end_min:{}".format(off_on,current,start_min,end_min))
+        EventMesh.debug_log("off_on:{} current:{} start_min:{} end_min:{}".format(off_on,current,start_min,end_min))
         if off_on != None:
             if off_on == 1:
                 if end_min == current:#结束的时间分钟等于关机时间分钟数则关机
@@ -3618,25 +3627,25 @@ class ClockManager(Abstract):
                     if next_minute >= current_minute:#开机时间大于当前时间 9:00 > = 8:00
                         interval_minute = next_minute - current_minute
                         
-                        print("关机距离下一次响铃的的分钟数:", interval_minute,next_minute)
+                        EventMesh.debug_log("关机距离下一次响铃的的分钟数:", interval_minute,next_minute)
                     else:#8:00 9:00
                         #7*60*24 7天一个周期 7*60*24 - 
                         interval_minute = next_minute + 24*60
-                        print("关机08888距离下一次响铃的的分钟数:", interval_minute,next_minute)
+                        EventMesh.debug_log("关机08888距离下一次响铃的的分钟数:", interval_minute,next_minute)
 
                     #反向获取时间戳
                     time = utime.localtime()
-                    print("关机09获取utime的时间戳:", time)
+                    EventMesh.debug_log("关机09获取utime的时间戳:", time)
                     rtc_mktime = utime.mktime(time)
-                    print("关机10反向获取utime的mktime:", rtc_mktime)
+                    EventMesh.debug_log("关机10反向获取utime的mktime:", rtc_mktime)
 
                     #加上下一次响铃需要的时间
                     next_alarm_mktime = rtc_mktime + interval_minute*60 #转换成s单位 时间戳
-                    print("关机11下一次响铃的mktime:", next_alarm_mktime)
+                    EventMesh.debug_log("关机11下一次响铃的mktime:", next_alarm_mktime)
 
                     #格式化时间戳,得到下一次闹钟的时间
                     next_alarm_time = utime.localtime(next_alarm_mktime)
-                    print("关机12下一次响铃的准确时间:", next_alarm_time)
+                    EventMesh.debug_log("关机12下一次响铃的准确时间:", next_alarm_time)
                     #将时间转换为rtc的格式
                     data_l = [2021, 7, 9, 5, 12, 30, 0, 0]
                     #给rtc时间赋值
@@ -3646,22 +3655,22 @@ class ClockManager(Abstract):
                     data_l[4] = next_alarm_time[3] #hour               
                     data_l[5] = next_alarm_time[4] #minute   
                     data_e=tuple(data_l)
-                    print("关机13将该时间转换为RTC元组:", data_e)
+                    EventMesh.debug_log("关机13将该时间转换为RTC元组:", data_e)
                     
                     self.rtc.register_callback(self._rtc_callback)
 
                     FLAG = self.rtc.set_alarm(data_e)
                     if FLAG == 0:
-                        print("开机11成功设置rtc的到期时间:", data_e)
+                        EventMesh.debug_log("开机11成功设置rtc的到期时间:", data_e)
                     else:
-                        print("开机时设置rtc的到期时间失败:", data_e)
+                        EventMesh.debug_log("开机时设置rtc的到期时间失败:", data_e)
                     self.rtc.enable_alarm(1)
                     if ubs_state == 2 or ubs_state == 0:
-                        print("结束时设置rtc的到期时间失败:", data_e)
+                        EventMesh.debug_log("结束时设置rtc的到期时间失败:", data_e)
                         EventMesh.publish("open_power_on", 5)#静音关机
                         return
                     else:
-                        print("结束111开机时设置rtc的到期时间失败:", data_e)
+                        EventMesh.debug_log("结束111开机时设置rtc的到期时间失败:", data_e)
                         return
         
         EventMesh.publish("set_rtc_alarm")
@@ -3671,7 +3680,7 @@ class ClockManager(Abstract):
         total_min = 0
         if off_on != None:
             if off_on == 1:
-                # print("alarm_list:{}".format(alarm_list))
+                # EventMesh.debug_log("alarm_list:{}".format(alarm_list))
                 for idx in range(0,len(alarm_list)):
                     hour = int(alarm_list[idx]["hour"])
                     min = int(alarm_list[idx]["minute"])
@@ -3679,7 +3688,7 @@ class ClockManager(Abstract):
                     enable = int(alarm_list[idx]["enabled"])
                     repeart = int(alarm_list[idx]["repeart"])
                     total_min = hour*60+min
-                    # print("hour",hour,min,day,enable,repeart,total_min,start_min)
+                    # EventMesh.debug_log("hour",hour,min,day,enable,repeart,total_min,start_min)
                     if enable == 1:
                         if repeart != 10:
                             if len(day) == 0 and enable == 1:#单次闹钟
@@ -3692,7 +3701,7 @@ class ClockManager(Abstract):
                             else:
                                 if (cur_day in day)  and enable == 1:
                                     if total_min == start_min and enable == 1:#如果闹钟时间和开机时间一致啧响铃否则不响铃
-                                        # print("alarm_ring22222")
+                                        # EventMesh.debug_log("alarm_ring22222")
                                         EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃
                                         alarm_flag = 1
                                         break
@@ -3702,7 +3711,7 @@ class ClockManager(Abstract):
                             continue
             else:
                 alarm_flag = 0
-        # print("start_min",start_min,current,alarm_flag)
+        # EventMesh.debug_log("start_min",start_min,current,alarm_flag)
         if (start_min != current and alarm_flag == 0) or off_on == 0:
             EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃
 
@@ -3712,17 +3721,17 @@ class ClockManager(Abstract):
         EventMesh.publish("read_alarminjson")
         rtc_now_time = self.rtc.datetime()
 
-       # print("00获取所有闹钟信息:{}".format(alarm_list))
+       # EventMesh.debug_log("00获取所有闹钟信息:{}".format(alarm_list))
         new_alarm_list = [(alarm['hour'], alarm['minute'], alarm['days'],alarm["idx"]) for alarm in alarm_list if alarm['enabled']]
 
-        print("01获取开启的闹钟:{}".format(new_alarm_list))
+        EventMesh.debug_log("01获取开启的闹钟:{}".format(new_alarm_list))
         start_day = 0 # 周日
         start_minute = 0 # 0点
         end_minute = 60*24*7
         minute_list = []
 
         if not new_alarm_list:
-            print("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
+            EventMesh.debug_log("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
             self.rtc.enable_alarm(0)
             return
         
@@ -3737,25 +3746,25 @@ class ClockManager(Abstract):
                 #如果当前时间没超过闹钟设置时间,则设置为今天,否则设置为明天
                 if (hour*60 + minute) > (rtc_now_time[4]*60 + rtc_now_time[5]):
                     minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day)*24*60)
-                    print("设置单次闹钟:{}".format(new_alarm_list))
+                    EventMesh.debug_log("设置单次闹钟:{}".format(new_alarm_list))
 
                 else:
                     minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day+1)*24*60)
         
         total_minutes = sorted(minute_list)
-        print("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
+        EventMesh.debug_log("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
 
         #获取当前时间  (2020, 9, 11, 5, 15, 43, 23, 0)
         # rtc_now_time = (2020, 9, 11, 6, 11, 43, 23, 0)
         # rtc_now_time = self.rtc.datetime()
 
-        print("03当前的rtc时间:{}".format(rtc_now_time))  
+        EventMesh.debug_log("03当前的rtc时间:{}".format(rtc_now_time))  
 
         current_minute = rtc_now_time[4]*60 + rtc_now_time[5] + (rtc_now_time[3]-start_day)*24*60
-        print("04当前的rtc_total_minutes:{}".format(current_minute))  
+        EventMesh.debug_log("04当前的rtc_total_minutes:{}".format(current_minute))  
 
         if current_minute in minute_list:
-            print("当前时间和闹钟列表时间重复,删除重复的时间")
+            EventMesh.debug_log("当前时间和闹钟列表时间重复,删除重复的时间")
             minute_list.remove(current_minute)
 
         minute_list.append(current_minute)
@@ -3764,38 +3773,38 @@ class ClockManager(Abstract):
         minute_list = sorted(minute_list)
         current_index = minute_list.index(current_minute)
 
-        print("05将当前时间插入min_list后的min_list:{}".format(minute_list))  
-        print("06当前时间所在位置:{}".format(current_index))  
+        EventMesh.debug_log("05将当前时间插入min_list后的min_list:{}".format(minute_list))  
+        EventMesh.debug_log("06当前时间所在位置:{}".format(current_index))  
 
         next_index = current_index + 1
         if next_index >= len(minute_list):
             next_minute = minute_list[0]
-            print("0744下一个闹钟的分钟数:", next_minute)
+            EventMesh.debug_log("0744下一个闹钟的分钟数:", next_minute)
         else:
             next_minute = minute_list[next_index]
-            print("0744下一个闹钟的分钟数:", next_minute)
+            EventMesh.debug_log("0744下一个闹钟的分钟数:", next_minute)
 
         if next_minute >= current_minute:
             interval_minute = next_minute - current_minute
-            print("08666距离下一次响铃的的分钟数:", interval_minute)
+            EventMesh.debug_log("08666距离下一次响铃的的分钟数:", interval_minute)
         else:
             #7*60*24 7天一个周期 7*60*24 - 
             interval_minute = end_minute - current_minute + next_minute
-            print("08888距离下一次响铃的的分钟数:", interval_minute)
+            EventMesh.debug_log("08888距离下一次响铃的的分钟数:", interval_minute)
 
         #反向获取时间戳
         time = utime.localtime()
-        print("09获取utime的时间戳:", time)
+        EventMesh.debug_log("09获取utime的时间戳:", time)
         rtc_mktime = utime.mktime(time)
-        print("10反向获取utime的mktime:", rtc_mktime)
+        EventMesh.debug_log("10反向获取utime的mktime:", rtc_mktime)
 
         #加上下一次响铃需要的时间
         next_alarm_mktime = rtc_mktime + interval_minute*60
-        print("11下一次响铃的mktime:", next_alarm_mktime)
+        EventMesh.debug_log("11下一次响铃的mktime:", next_alarm_mktime)
 
         #格式化时间戳,得到下一次闹钟的时间
         next_alarm_time = utime.localtime(next_alarm_mktime)
-        print("12下一次响铃的准确时间:", next_alarm_time)
+        EventMesh.debug_log("12下一次响铃的准确时间:", next_alarm_time)
         #将时间转换为rtc的格式
         data_l = [2021, 7, 9, 5, 12, 30, 0, 0]
         #给rtc时间赋值
@@ -3806,11 +3815,11 @@ class ClockManager(Abstract):
         data_l[5] = next_alarm_time[4] #minute               
         #转换为元组       
         data_e=tuple(data_l)
-        print("13将该时间转换为RTC元组:", data_e)
+        EventMesh.debug_log("13将该时间转换为RTC元组:", data_e)
        
         for alarm in alarm_list:
             if not alarm["days"] and alarm["enabled"]:
-                print("关闭666:",alarm["idx"])
+                EventMesh.debug_log("关闭666:",alarm["idx"])
                 if alarm["hour"] == data_l[4] and alarm["minute"]==data_l[5]:
                     self.idx = alarm["idx"]
         #设置rtc闹钟时间
@@ -3818,9 +3827,9 @@ class ClockManager(Abstract):
 
         FLAG = self.rtc.set_alarm(data_e)
         if FLAG == 0:
-            print("14成功设置rtc的到期时间:", data_e)
+            EventMesh.debug_log("14成功设置rtc的到期时间:", data_e)
         else:
-            print("14设置rtc的到期时间失败:", data_e)
+            EventMesh.debug_log("14设置rtc的到期时间失败:", data_e)
         
         self.rtc.enable_alarm(1)
          
index 92cfc21..8efcbdf 100644 (file)
@@ -26,7 +26,7 @@ def server_init(server_type = None):
     #服务器选择1,防走丢,2大锤,3三基同创,4童信,5云米,6荣为
     if server_type == None:
         server_type = 1
-    #print("server_init:server_type:{}".format(server_type))
+    #EventMesh.debug_log("server_init:server_type:{}".format(server_type))
    
     d_server_addr = "api.xcloudtech.com"
     d_server_port = 9000
@@ -110,14 +110,14 @@ def UnicodeHexStr_To_Utf8Str(str):
             odata = odata << 4
             odata += tmp - ord('A') + 10
         if(i%4==3): #每2字节获取一个int,拿到转换后的unicode int
-            #print(odata.to_bytes(2, 'big'))
+            #EventMesh.debug_log(odata.to_bytes(2, 'big'))
             #result.append(odata)
             if odata > 255:
                 tmp = unicode_to_utf8(odata)#拿到转换后的utf8 int
                 tmp2 = tmp.to_bytes(3, 'big') #转bytes
             else :
                 tmp2 = odata.to_bytes(1, 'big') 
-            #print("tmp2:{}".format(tmp2))
+            #EventMesh.debug_log("tmp2:{}".format(tmp2))
             result = result + tmp2
             odata = 0 
         i+=1
@@ -135,17 +135,17 @@ class SockManager(Abstract):
         self.reconnect_flag = 0
         self.connect_tmp = 0
         server_data = server_init()
-        print("SockManager:server_data:{}".format(server_data))
+        EventMesh.debug_log("SockManager:server_data:{}".format(server_data))
         self.server_addr = server_data[0]
         self.server_port = server_data[1]
         ip_infor = {}
         ip_infor = EventMesh.publish("get_new_ip")
-        print("ip_infor1:{} \n\n\n".format(ip_infor))
+        EventMesh.debug_log("ip_infor1:{} \n\n\n".format(ip_infor))
         
         if ip_infor != None: #已经改过服务器
             self.server_addr = ip_infor[0]
             self.server_port = ip_infor[1]
-        print("server_addr:{} server_port:{}".format(self.server_addr,self.server_port))
+        EventMesh.debug_log("server_addr:{} server_port:{}".format(self.server_addr,self.server_port))
         _thread.stack_size((9+3)*1024)
         _thread.start_new_thread(self.connect, ())
         _thread.stack_size(8*1024)
@@ -170,7 +170,7 @@ class SockManager(Abstract):
     
 
     def connect(self):
-        print("connect1{}:{}".format(self.server_addr, self.server_port))
+        EventMesh.debug_log("connect1{}:{}".format(self.server_addr, self.server_port))
         if EventMesh.publish("get_sim_Status") != 1: #没sim
             return
         try:
@@ -189,14 +189,14 @@ class SockManager(Abstract):
             self.run_flag = False
         else:
             self.run_flag = True
-        print("connect2{}:{}".format(self.server_addr, self.server_port))
+        EventMesh.debug_log("connect2{}:{}".format(self.server_addr, self.server_port))
         self.reconnect_flag = 0
     def publish_timer_cb(self, *args):
         EventMesh.publish(constants.PROTOCOL.LK_SEND)
         
     def check(self, *args):
         if (not self.run_flag) or (self.connect_tmp == 0) : #7分钟无数据读取,则认为是掉线了
-            print("tcp reconnect!!!!!!!!!!!!!!!!!!")
+            EventMesh.debug_log("tcp reconnect!!!!!!!!!!!!!!!!!!")
             EventMesh.publish(constants.EVENT.SET_CONNECT,0) #标记断网
             self.reconnect()
         self.connect_tmp = 0
@@ -217,9 +217,9 @@ class SockManager(Abstract):
     def socket_send_queue_thread(self):
          while True:
             data = self.socket_send_queue.get()
-            print("TCP:send data1 len:{}".format(len(data)))
+            EventMesh.debug_log("TCP:send data1 len:{}".format(len(data)))
 
-            #print("ui_queue_thread:data = {}".format(data))
+            #EventMesh.debug_log("ui_queue_thread:data = {}".format(data))
             socketsta = self.sock.getsocketsta() 
             if(socketsta == -1): #给释放了或者出错了
                 continue
@@ -227,11 +227,11 @@ class SockManager(Abstract):
                 if data != None:
                     try:
                         self.sock.send(data)
-                        print("TCP:send data2 len:{}".format(len(data)))    
+                        EventMesh.debug_log("TCP:send data2 len:{}".format(len(data)))    
                     except Exception as e:
                         self.reconnect()
                         self.socket_send_queue.put(data)#重新把数据加回队列
-                        #print("socket_send_queue_thread1:ERROR:")
+                        #EventMesh.debug_log("socket_send_queue_thread1:ERROR:")
                         #usys.print_exception(e)
             elif socketsta < 4:#正在连接,等待连接成功重新发送
                 count = 0
@@ -242,29 +242,29 @@ class SockManager(Abstract):
                     if(self.sock.getsocketsta() == 4):#
                         try:
                             self.sock.send(data)
-                            print("TCP:send data3 len:{}".format(len(data)))    
+                            EventMesh.debug_log("TCP:send data3 len:{}".format(len(data)))    
                         except Exception as e:
                             self.reconnect()
                             self.socket_send_queue.put(data)#重新把数据加回队列
-                            #print("socket_send_queue_thread2:ERROR:")
+                            #EventMesh.debug_log("socket_send_queue_thread2:ERROR:")
                             #usys.print_exception(e)
                         break
             else :#连接错误
-                print("socket_send_queue_thread:ERROR:reconnect")
+                EventMesh.debug_log("socket_send_queue_thread:ERROR:reconnect")
                 self.reconnect()
             utime.sleep(1)
 
     def send(self, topic, msg):
-       # print("TCP:send data:{}".format(msg))
+       # EventMesh.debug_log("TCP:send data:{}".format(msg))
         if EventMesh.publish("get_sim_Status") != 1: #没sim,则不发送
             EventMesh.publish(constants.EVENT.SET_CONNECT, 0)#标记断网
-            print("dataCall not connect")
+            EventMesh.debug_log("dataCall not connect")
             return
         else :
             try:
                 self.socket_send_queue.put(msg)
             except Exception as e:   
-                print("self.socket_send_queue.put:ERROR:")
+                EventMesh.debug_log("self.socket_send_queue.put:ERROR:")
                 usys.print_exception(e) 
                 # self.run_flag = False
 
@@ -280,9 +280,9 @@ class SockManager(Abstract):
                     self.reconnect()
    
                 data = data + r
-                print("TCP recv: data:len:{}".format(len(data)))
+                EventMesh.debug_log("TCP recv: data:len:{}".format(len(data)))
                 
-                print("TCP recv: data:{}".format(data))
+                EventMesh.debug_log("TCP recv: data:{}".format(data))
                 if data[-1] != 0x5d and len(data)<20*1024: #']':
                     continue
                 self.connect_tmp = 1 #有数据,就认为是连接状态
@@ -298,7 +298,7 @@ class SockManager(Abstract):
                 
                 data = b''
             except Exception as e:
-                #print("TCP:ERROR:recv:")
+                #EventMesh.debug_log("TCP:ERROR:recv:")
                 #usys.print_exception(e)
                 self.run_flag = False
                 self.reconnect()
@@ -325,7 +325,7 @@ class NetManager(Abstract):
             if count > 5 :
                 return
             data = dataCall.getInfo(1, 0)
-            print("data call INFO {}".format(data))
+            EventMesh.debug_log("data call INFO {}".format(data))
             if data[2][0]:
                 self.network_state = 1
                 break
@@ -338,11 +338,11 @@ class NetManager(Abstract):
         nw_sta = args[1]
         if nw_sta == 1:
             self.network_state = 1
-            print("*** network %d connected! ***" % pdp)
+            EventMesh.debug_log("*** network %d connected! ***" % pdp)
 
         else:
             self.network_state = 0
-            print("*** network %d not connected! ***" % pdp)
+            EventMesh.debug_log("*** network %d not connected! ***" % pdp)
            
     def get_network_state(self, topic, msg):
         return self.network_state 
@@ -374,7 +374,7 @@ class ProtoCol(Abstract):
         # ip_infor = EventMesh.publish("get_new_ip")
         # if ip_infor != None:
         #     self.md5_key = ip_infor[2]
-        # print("md5_key",self.md5_key)
+        # EventMesh.debug_log("md5_key",self.md5_key)
 
     def initialization(self, *args, **kwargs):
         EventMesh.subscribe(self.TYPE + "_SEND", self.handler)
@@ -429,9 +429,9 @@ class ProtoCol(Abstract):
         # 转成十六进制表示
         MD5_head = ubinascii.hexlify(res)
         MD5_head = MD5_head.decode('ascii')
-        #print("data+self.md5_key:{}".format(data+self.md5_key))
-        #print(res)
-        #print(MD5_head)
+        #EventMesh.debug_log("data+self.md5_key:{}".format(data+self.md5_key))
+        #EventMesh.debug_log(res)
+        #EventMesh.debug_log(MD5_head)
         return MD5_head
 
 class LK_ProtoCol(ProtoCol):
@@ -440,11 +440,11 @@ class LK_ProtoCol(ProtoCol):
 
     def send(self, event, msg):
         #[SZKW*334588000000156*0002*LK]
-        #print('self.imei:%s'%(self.imei))
+        #EventMesh.debug_log('self.imei:%s'%(self.imei))
         send_data = self.PID+"*%s*0002*LK"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("LK_ProtoCol:send:%s"%(data))
+        # EventMesh.debug_log("LK_ProtoCol:send:%s"%(data))
 
         
         # 通过socket发送到服务器端
@@ -456,7 +456,7 @@ class LK_ProtoCol(ProtoCol):
         @param event: LK成功
         @param msg: 接收到的下行数据
         """
-        print("LK_ProtoCol:recv:%s"%(msg))
+        EventMesh.debug_log("LK_ProtoCol:recv:%s"%(msg))
         EventMesh.publish(constants.PROTOCOL.PING_SEND)
         EventMesh.publish(constants.PROTOCOL.KA_SEND)
         EventMesh.publish(constants.PROTOCOL.TIME_SEND)
@@ -472,7 +472,7 @@ class PING_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0004*PING"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("PING_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("PING_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -482,7 +482,7 @@ class PING_ProtoCol(ProtoCol):
         @param event: PING
         @param msg: 接收到的下行数据
         """
-        #print("PING_ProtoCol:recv:%s"%(msg))   
+        #EventMesh.debug_log("PING_ProtoCol:recv:%s"%(msg))   
         data_tmp =  msg.decode('ascii')   
         data_tmp = data_tmp.split(']')[0] #去掉]    
         EventMesh.publish(constants.EVENT.SET_PING, data_tmp.split(',')[1])
@@ -496,7 +496,7 @@ class KA_ProtoCol(ProtoCol):
         #[XT*YYYYYYYYYYYYYYY*LEN*KA,日期,步数,翻滚次数,电量百分数,车载里程数(km)] 实例:[XT*334588000000156*0014*KA,120414,50,100,100,100.12]
         date = "{:04d}{:02d}{:02d}".format(*utime.localtime()[0:3])
         date = date[2:]
-        #print("date:",date)
+        #EventMesh.debug_log("date:",date)
         #步数
         old_step = 0
         step = 0
@@ -508,7 +508,7 @@ class KA_ProtoCol(ProtoCol):
                     old_step = read_data
                 
                 if old_step !=  step:
-                    # print("old_step:send:%d %d"%(old_step,step))
+                    # EventMesh.debug_log("old_step:send:%d %d"%(old_step,step))
                     EventMesh.publish("set_storage_config",["old_step_new",step+10])
                     EventMesh.publish("set_storage_config",["old_step_new",step])
 
@@ -525,7 +525,7 @@ class KA_ProtoCol(ProtoCol):
 
         MD5_SIGN = self.pack_MD5_head(MD5_head_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("KA_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("KA_ProtoCol:send:%s"%(data))
 
         
         # 通过socket发送到服务器端
@@ -537,7 +537,7 @@ class KA_ProtoCol(ProtoCol):
         @param event: PING
         @param msg: 接收到的下行数据
         """
-        #print("KA_ProtoCol:recv:%s"%(msg))   
+        #EventMesh.debug_log("KA_ProtoCol:recv:%s"%(msg))   
         
 class UD_ProtoCol(ProtoCol):
     """位置信息"""
@@ -573,7 +573,7 @@ class UD_ProtoCol(ProtoCol):
 
     def recv(self, event, msg):
         pass
-        # print("UD_ProtoCol:recv:%s"%(msg))  
+        # EventMesh.debug_log("UD_ProtoCol:recv:%s"%(msg))  
 
 class CR_ProtoCol(ProtoCol):
     """立即定位"""
@@ -584,7 +584,7 @@ class CR_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0002*CR"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("CR_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("CR_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -596,7 +596,7 @@ class CR_ProtoCol(ProtoCol):
         """
         EventMesh.publish(constants.PROTOCOL.CR_SEND)
         EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始ud定位
-        #print("CR_ProtoCol:recv:%s"%(msg))   
+        #EventMesh.debug_log("CR_ProtoCol:recv:%s"%(msg))   
         
 class FIND_ProtoCol(ProtoCol):
     """查找设备"""
@@ -607,7 +607,7 @@ class FIND_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0004*FIND"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("FIND_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("FIND_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -625,7 +625,7 @@ class FIND_ProtoCol(ProtoCol):
         
         # EventMesh.publish("load_screen", {"screen": "FIND"})
         EventMesh.publish("OPEN_FIND_WATCH")#
-        #print("FIND_ProtoCol:recv:%s"%(msg)) 
+        #EventMesh.debug_log("FIND_ProtoCol:recv:%s"%(msg)) 
 
 class POWEROFF_ProtoCol(ProtoCol):
     """关机"""
@@ -636,7 +636,7 @@ class POWEROFF_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0008*POWEROFF"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("POWEROFF_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("POWEROFF_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -647,7 +647,7 @@ class POWEROFF_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         EventMesh.publish(constants.PROTOCOL.POWEROFF_SEND)
-        #print("POWEROFF_ProtoCol:recv:%s"%(msg))
+        #EventMesh.debug_log("POWEROFF_ProtoCol:recv:%s"%(msg))
         battery = EventMesh.publish("screen_get_battery")
         if battery != None:
             if battery[0] != "1":
@@ -663,7 +663,7 @@ class PHL_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0003*PHL"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("POWEROFF_ProtoCol:send:%s"%(data))
+        #EventMesh.debug_log("POWEROFF_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -674,10 +674,10 @@ class PHL_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         msg = msg[1:-1]
-        # print("phonebook:msg:%s\r\n"%msg)
+        # EventMesh.debug_log("phonebook:msg:%s\r\n"%msg)
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
-        # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
+        # EventMesh.debug_log("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
 
         phonebook = {}
         msg_tmp = msg_tmp[1:]
@@ -688,7 +688,7 @@ class PHL_ProtoCol(ProtoCol):
         # 0 1 2 3
         for phonebook_tmp in msg_tmp: 
             j+=1
-            # print("phonebook_tmp:{} len:{}".format(phonebook_tmp,len(phonebook_tmp)))
+            # EventMesh.debug_log("phonebook_tmp:{} len:{}".format(phonebook_tmp,len(phonebook_tmp)))
 
             if (j%2) == 0:
                 i+=1
@@ -698,11 +698,11 @@ class PHL_ProtoCol(ProtoCol):
                     phonebook[phonebook_name] = phonebook_oldtmp
                 
             phonebook_oldtmp = phonebook_tmp
-                # print("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
-        # print("phonebook!!!:{}".format(str(phonebook)))
+                # EventMesh.debug_log("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
+        # EventMesh.debug_log("phonebook!!!:{}".format(str(phonebook)))
         with open("/usr/static/storage_file/phonebook.json","w",encoding="utf-8") as fd:
             ujson.dump(phonebook,fd)
-            print("创建电话簿")
+            EventMesh.debug_log("创建电话簿")
         
         EventMesh.publish(constants.PROTOCOL.PHL_SEND)
         EventMesh.publish("set_phonebook_list",[1,phonebook])
@@ -725,7 +725,7 @@ class WT_ProtoCol(ProtoCol):
             MD5_SIGN = self.pack_MD5_head(MD5_head_data)
             send_data = self.PID+"*%s*%04X*%s"%(self.imei,data_len,msg_tmp)
             data = "[%s%s]"%(str(MD5_SIGN),send_data)
-            print("WT_ProtoCol:send:%s"%(data))
+            EventMesh.debug_log("WT_ProtoCol:send:%s"%(data))
             # 通过socket发送到服务器端
             EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -740,10 +740,10 @@ class WT_ProtoCol(ProtoCol):
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split('WT,')
-        # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
+        # EventMesh.debug_log("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
         msg_tmp = msg_tmp[1]
 
-        # print("msg_tmp :%s"%(msg_tmp))
+        # EventMesh.debug_log("msg_tmp :%s"%(msg_tmp))
 
         msg_date = msg_tmp.split(',')[0]
 
@@ -757,9 +757,9 @@ class WT_ProtoCol(ProtoCol):
 
         msg_city = UnicodeHexStr_To_Utf8Str(msg_city)
         msg_weather_content = UnicodeHexStr_To_Utf8Str(msg_weather_content)
-        # print("msg_date:{} msg_time:{} msg_weather_content:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,\
+        # EventMesh.debug_log("msg_date:{} msg_time:{} msg_weather_content:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,\
         #     msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city))
-        print("WT_ProtoCol RECV msg:%s"%(msg))
+        EventMesh.debug_log("WT_ProtoCol RECV msg:%s"%(msg))
 
         EventMesh.publish("set_weather_data",[msg_date,msg_time,msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city,1])
         EventMesh.publish("updata_weather_show")
@@ -775,7 +775,7 @@ class REMIND_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0006*REMIND"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("REMIND_ProtoCol:send:%s"%(data))
+        # EventMesh.debug_log("REMIND_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
@@ -785,7 +785,7 @@ class REMIND_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'SZKW*860132060004322*0035*REMIND,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
-        # print("REMIND_ProtoCol RECV msg:%s"%(msg))
+        # EventMesh.debug_log("REMIND_ProtoCol RECV msg:%s"%(msg))
         alarm_new = []
 
         msg = msg[1:-1]
@@ -794,7 +794,7 @@ class REMIND_ProtoCol(ProtoCol):
         msg_tmp = msg_tmp[1]
 
         alarm_new  = EventMesh.publish("read_alarminjson")
-        print("alarm_new start:{}",alarm_new)
+        EventMesh.debug_log("alarm_new start:{}",alarm_new)
         k=1
         count = 0
         if len(msg_tmp) == 0:
@@ -811,17 +811,17 @@ class REMIND_ProtoCol(ProtoCol):
                     k+=1
             # if len(alarm_new) > 2:
             #     for i in range(0,len(alarm_new)-2):
-            #         # print("alarm_new_tmp",alarm_new)
+            #         # EventMesh.debug_log("alarm_new_tmp",alarm_new)
             #         del alarm_new[2]
-            # print("alarm_new:{}",alarm_new)
+            # EventMesh.debug_log("alarm_new:{}",alarm_new)
             for j in range(2,2+k):#0 1是开关机,234是闹钟
-                print("j",j,j+2,2+k,k)
+                EventMesh.debug_log("j",j,j+2,2+k,k)
                 if j > 4:
                     break
                 alarm_day = []
                 alarm_week = []
                 alarm_total_data = []
-                # print("j!!!!!!!!!!",j)
+                # EventMesh.debug_log("j!!!!!!!!!!",j)
                 if k == 1:
                     if len(msg_tmp) != 0:
                         alarm_data = msg_tmp.split('-')#-作为分隔符
@@ -870,7 +870,7 @@ class REMIND_ProtoCol(ProtoCol):
                                     for i in range(0,7):
                                         if alarm_week[i] != '0':
                                             alarm_day.append(i)
-                                print("j+2",j+2)
+                                EventMesh.debug_log("j+2",j+2)
                                 alarm_new[j]["idx"] = j
                                 alarm_new[j]["hour"] = alarm_time_hour
                                 alarm_new[j]["minute"] = alarm_time_min
@@ -879,7 +879,7 @@ class REMIND_ProtoCol(ProtoCol):
                                 alarm_new[j]["repeart"] = alarm_day_num
                                 # alarm_new.append({"idx": j, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
                             
-            print("alarm_new end:{}",alarm_new)
+            EventMesh.debug_log("alarm_new end:{}",alarm_new)
             for j in range(2,5-k):#0 1是开关机,234是闹钟#5-1 0 1 2 3 4 5-1 = 4 3 4 k = 1 1+2+j = 
                 alarm_new[j+k]["idx"] = k+j
                 alarm_new[j+k]["hour"] = 16
@@ -908,7 +908,7 @@ class HRSTART_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0008*hrtstart"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("HRSTART_ProtoCol:send:%s"%(data))
+        # EventMesh.debug_log("HRSTART_ProtoCol:send:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -918,20 +918,20 @@ class HRSTART_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'SZKW*860132060004322*0035*REMIND,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
-        # print("REMIND_ProtoCol RECV msg:%s"%(msg))
+        # EventMesh.debug_log("REMIND_ProtoCol RECV msg:%s"%(msg))
         # HRSTART_ProtoCol RECV msg:b'SZKW*860132060004322*000D*hrtstart,7200' msg_:7200
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
         msg_tmp = msg_tmp[1]
-        print("HRSTART_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
+        EventMesh.debug_log("HRSTART_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
         hrTotal = int(msg_tmp)
         if hrTotal == 0:#关闭自动测量
-            print("HRSTART_ 1")
+            EventMesh.debug_log("HRSTART_ 1")
             EventMesh.publish("set_time_hr_spo2",[0,0])
         else:
             if hrTotal == 1:#单次测量
-                print("HRSTART_ 2".format(hrTotal))
+                EventMesh.debug_log("HRSTART_ 2".format(hrTotal))
                 get_hr_state = EventMesh.publish("get_hr_state")
                 get_spo2_state = EventMesh.publish("get_spo2_state")
                 # if (get_hr_state == 3 ) or (get_spo2_state == 0 and get_hr_state == 0):#只要两个不在测量 单次优先级最低
@@ -943,7 +943,7 @@ class HRSTART_ProtoCol(ProtoCol):
                     hrTotal = 300
                 elif hrTotal >= 65536:
                     hrTotal = 65536
-                print("HRSTART_ 3".format(hrTotal))
+                EventMesh.debug_log("HRSTART_ 3".format(hrTotal))
                 EventMesh.publish("set_time_hr_spo2",[1,hrTotal])
 
 
@@ -956,13 +956,13 @@ class HEART_ProtoCol(ProtoCol):
 
     def send(self, event, msg):
         # [SZKW*334588000000156*len*heart,x]
-        # print("HEART:send:{}".format(msg))
+        # EventMesh.debug_log("HEART:send:{}".format(msg))
         len_size = len(str(msg))+len("heart,")
         send_data = self.PID+"*%s*%04X*heart"%(self.imei,len_size)
         MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"heart")
         MD5_SIGN = self.pack_MD5_head(MD5_head_data)
         data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
-        # print("HEART_ProtoCol:data:%s"%(data))
+        # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -971,20 +971,20 @@ class HEART_ProtoCol(ProtoCol):
         @param event: 心率数据下发
         @param msg: 接收到的下行数据
         """
-        # print("HRSTART_ProtoCol RECV msg:")
+        # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
         #EventMesh.publish(constants.PROTOCOL.HEART_SEND)
 class OXYGEN_ProtoCol(ProtoCol):
     """上传血氧测试数据"""
     TYPE = "oxygen"
     def send(self, event, msg):
         # [SZKW*334588000000156*len*heart,x]
-        # print("oxstart:send:{}".format(msg))
+        # EventMesh.debug_log("oxstart:send:{}".format(msg))
         len_size = len(str(msg))+len("oxygen,")
         send_data = self.PID+"*%s*%04X*oxygen"%(self.imei,len_size)
         MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"oxygen")
         MD5_SIGN = self.pack_MD5_head(MD5_head_data)
         data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
-        # print("HEART_ProtoCol:data:%s"%(data))
+        # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -993,7 +993,7 @@ class OXYGEN_ProtoCol(ProtoCol):
         @param event: 心率数据下发
         @param msg: 接收到的下行数据
         """
-        # print("HRSTART_ProtoCol RECV msg:")
+        # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
         #EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND)
 
 class OXYGEN_One_ProtoCol(ProtoCol):#单次测量
@@ -1007,11 +1007,11 @@ class OXYGEN_One_ProtoCol(ProtoCol):#单次测量
 # [XT*334588000000156*0006*oxygen]
     def send(self, event, msg):
         # [SZKW*334588000000156*len*heart,x]
-        print("oxstart:")
+        EventMesh.debug_log("oxstart:")
         send_data = self.PID+"*%s*0007*oxstart"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("HEART_ProtoCol:data:%s"%(data))
+        # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1020,7 +1020,7 @@ class OXYGEN_One_ProtoCol(ProtoCol):#单次测量
         @param event: 血氧单次测量下发
         @param msg: 接收到的下行数据
         """
-        print("oxstart:{}".format(msg))
+        EventMesh.debug_log("oxstart:{}".format(msg))
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
@@ -1039,9 +1039,9 @@ class TEMP_ProtoCol(ProtoCol):
     TYPE = "temp"
     def send(self, event, msg):
         # [SZKW*334588000000156*len*heart,x]
-        # print("temp:send:{}".format(msg))
+        # EventMesh.debug_log("temp:send:{}".format(msg))
         len_size = len(str(msg[0]))+len("temp,")+1+len(str(msg[1]))
-        print("temp:send:{} len:{}".format(msg,len_size))
+        EventMesh.debug_log("temp:send:{} len:{}".format(msg,len_size))
         #  实例:[XT*334588000000156*0009*temp,36.2]
         # 代表终端的温度为:36.2
         # 平台回复:
@@ -1050,7 +1050,7 @@ class TEMP_ProtoCol(ProtoCol):
         MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"temp")
         MD5_SIGN = self.pack_MD5_head(MD5_head_data)
         data = "[%s%s,%d.%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
-        # print("temp:data:%s"%(data))
+        # EventMesh.debug_log("temp:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1059,7 +1059,7 @@ class TEMP_ProtoCol(ProtoCol):
         @param event: 
         @param msg: 接收到的下行数据
         """
-        # print("HRSTART_ProtoCol RECV msg:")
+        # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
         #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
 
 class WDSTART_ProtoCol(ProtoCol):
@@ -1070,7 +1070,7 @@ class WDSTART_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0007*wdstart"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("temp:data:%s"%(data))
+        # EventMesh.debug_log("temp:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1079,18 +1079,18 @@ class WDSTART_ProtoCol(ProtoCol):
         @param event: 体温下发频率数据
         @param msg: 接收到的下行数据
         """
-        # print("WDSTART_ProtoCol RECV msg:")
-        print("wdstart:{}".format(msg))
+        # EventMesh.debug_log("WDSTART_ProtoCol RECV msg:")
+        EventMesh.debug_log("wdstart:{}".format(msg))
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
         msg_tmp = msg_tmp[1]
 
         tempTotal = int(msg_tmp)
-        print("tempTotal:{}".format(tempTotal))
+        EventMesh.debug_log("tempTotal:{}".format(tempTotal))
         if tempTotal == 1:#单次测量
             get_temp_state = EventMesh.publish("get_temp_state")
-            print("get_temp_state:{}".format(get_temp_state))
+            EventMesh.debug_log("get_temp_state:{}".format(get_temp_state))
             if get_temp_state == 0:#只要两个不在测量 单次优先级最低
 
                 EventMesh.publish("set_temp_state",3)#3代表单次测量
@@ -1118,7 +1118,7 @@ class DLT_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0003*DLT"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("temp:data:%s"%(data))
+        EventMesh.debug_log("temp:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1127,7 +1127,7 @@ class DLT_ProtoCol(ProtoCol):
         @param event:
         @param msg: 接收到的下行数据
         """
-        # print("DLT_ProtoCol RECV msg:")
+        # EventMesh.debug_log("DLT_ProtoCol RECV msg:")
         
 
 #定位频率
@@ -1149,7 +1149,7 @@ class UPLOAD_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*UPLOAD,600]'
-        # print("DLT_ProtoCol RECV msg:".format(msg))
+        # EventMesh.debug_log("DLT_ProtoCol RECV msg:".format(msg))
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
@@ -1169,7 +1169,7 @@ class CENTER_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0006*CENTER"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("UPLOAD:data:%s"%(data))
+        EventMesh.debug_log("UPLOAD:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1179,12 +1179,12 @@ class CENTER_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*UPLOAD,600]'
-        # print("DLT_ProtoCol RECV msg:".format(msg))
+        # EventMesh.debug_log("DLT_ProtoCol RECV msg:".format(msg))
         msg = msg[1:-1]
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
         msg_tmp = msg_tmp[1]
-        print("CENTER_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
+        EventMesh.debug_log("CENTER_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
         center_dial = str(msg_tmp)
         EventMesh.publish("set_storage_config",["center_dial",center_dial])
         EventMesh.publish(constants.PROTOCOL.CENTER_SEND)  
@@ -1199,7 +1199,7 @@ class MONITOR_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0007*MONITOR"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("MONITOR:data:%s"%(data))
+        EventMesh.debug_log("MONITOR:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1213,18 +1213,18 @@ class MONITOR_ProtoCol(ProtoCol):
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split('MONITOR')
         msg_tmp = msg_tmp[1]
-        print("MONITOR_ProtoCol RECV msg:{} msg_:{}".format(msg,len(msg_tmp)))
+        EventMesh.debug_log("MONITOR_ProtoCol RECV msg:{} msg_:{}".format(msg,len(msg_tmp)))
         if len(msg_tmp) != 0:
             EventMesh.publish("save_phonename", contact)
             EventMesh.publish("save_phonenum", contact)
             EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
         else:
             read_data = EventMesh.publish("get_storage_config","center_dial")
-            print("MONITOR:data:%s"%(read_data))
+            EventMesh.debug_log("MONITOR:data:%s"%(read_data))
             if read_data != None: 
                 contact = read_data
                 if len(contact) > 0:
-                    print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
+                    EventMesh.debug_log("MONITOR RECV msg:{} {}".format(contact,type(contact)))
                     EventMesh.publish("save_phonename", contact)
                     EventMesh.publish("save_phonenum", contact)
                     EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
@@ -1239,7 +1239,7 @@ class bootoff_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0007*BOOTOFF"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("BOOTOFF:data:%s"%(data))
+        EventMesh.debug_log("BOOTOFF:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
     def recv(self, event, msg):
@@ -1254,7 +1254,7 @@ class bootoff_ProtoCol(ProtoCol):
         on_bt = msg_tmp[1]
         on_start = msg_tmp[2]
         on_end = msg_tmp[3]
-        print("BOOTOFF:send data:{} {} {}".format(on_bt,on_start,on_end))
+        EventMesh.debug_log("BOOTOFF:send data:{} {} {}".format(on_bt,on_start,on_end))
         #b'[SZKW*860132060006970*0015*BOOTOFF,1,06:00,23:59]'
         EventMesh.publish("add_alarm", [on_bt,on_start,on_end])
         EventMesh.publish(constants.PROTOCOL.BOOTOFF_SEND)  
@@ -1269,7 +1269,7 @@ class sosHome_dial_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0003*SOS"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("sosHome_dial_ProtoCol:data:%s"%(data))
+        EventMesh.debug_log("sosHome_dial_ProtoCol:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1284,14 +1284,14 @@ class sosHome_dial_ProtoCol(ProtoCol):
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
 
-        # print("sosHome_dial_ProtoCol:send data :{} {}".format(len(msg_tmp),msg_tmp))
+        # EventMesh.debug_log("sosHome_dial_ProtoCol:send data :{} {}".format(len(msg_tmp),msg_tmp))
         #b'[SZKW*860132060006970*0015*sosHome_dial_ProtoCol,15521469561,10086,15521469561]'
         i = 0
         for i in range(len(msg_tmp)-1):
-            # print("sos:send data :{}".format(msg_tmp[i+1]))
+            # EventMesh.debug_log("sos:send data :{}".format(msg_tmp[i+1]))
             if len(msg_tmp[i+1]) != 0:
                 EventMesh.publish("set_storage_config",["SOS_NUMBER{}".format(i+1),msg_tmp[i+1]])
-                # print("read_data:{} msg_tmp:{}".format(read_data,msg_tmp[i+1]))
+                # EventMesh.debug_log("read_data:{} msg_tmp:{}".format(read_data,msg_tmp[i+1]))
        
         if (len(msg_tmp)-1) == 3:
             EventMesh.publish("set_dial_sos_number",[msg_tmp[1],msg_tmp[2],msg_tmp[3]])
@@ -1312,7 +1312,7 @@ class LOWBAT_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0006*LOWBAT"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("LOWBAT:data:%s"%(data))
+        EventMesh.debug_log("LOWBAT:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1327,7 +1327,7 @@ class LOWBAT_ProtoCol(ProtoCol):
         msg_tmp = msg.decode('ascii')
         msg_tmp = msg_tmp.split(',')
         on_bt = msg_tmp[1]
-        print("LOWBAT:send data:{}".format(on_bt))
+        EventMesh.debug_log("LOWBAT:send data:{}".format(on_bt))
         #b'[SZKW*860132060006970*0015*LOWBAT,1,06:00,23:59]'
         EventMesh.publish("set_low_bat_btn",on_bt)
         EventMesh.publish(constants.PROTOCOL.LOWBAT_SEND)  
@@ -1342,7 +1342,7 @@ class Time_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0004*Time"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("Time:data:%s"%(data))
+        EventMesh.debug_log("Time:data:%s"%(data))
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1357,10 +1357,10 @@ class Time_ProtoCol(ProtoCol):
         msg_data = msg_tmp.split(',')
         
         timeSecond = int(msg_data[1])
-        #print("type {} timeSecond {}".format((msg_data[1]),timeSecond))
+        #EventMesh.debug_log("type {} timeSecond {}".format((msg_data[1]),timeSecond))
         next_alarm_time = utime.localtime(timeSecond)
-        #print("next_alarm_time",next_alarm_time)
-        #print("local time",msg)
+        #EventMesh.debug_log("next_alarm_time",next_alarm_time)
+        #EventMesh.debug_log("local time",msg)
        # machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6], tm[3], tm[4], tm[5], 0))
 
         machine.RTC().datetime((next_alarm_time[0],next_alarm_time[1],next_alarm_time[2],next_alarm_time[6],next_alarm_time[3],next_alarm_time[4],next_alarm_time[5],0))
@@ -1378,8 +1378,8 @@ class WLKEY_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0005*WLKEY"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("WLKEY:data:%s"%(data))
-        # print("WLKEY!!!!!!!!!!!!!")
+        # EventMesh.debug_log("WLKEY:data:%s"%(data))
+        # EventMesh.debug_log("WLKEY!!!!!!!!!!!!!")
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1389,7 +1389,7 @@ class WLKEY_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*KEYBRD]'
-        # print("WLKEY!!!!!!!!!!!!!",msg)
+        # EventMesh.debug_log("WLKEY!!!!!!!!!!!!!",msg)
         EventMesh.publish(constants.PROTOCOL.WLKEY_SEND)  
 
 #免打扰
@@ -1401,8 +1401,8 @@ class SILENCETIME2_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*000C*SILENCETIME2"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("KEYBRD:data:%s"%(data))
-        # print("SILENCETIME2!!!!!!!!!!!!!",msg)
+        # EventMesh.debug_log("KEYBRD:data:%s"%(data))
+        # EventMesh.debug_log("SILENCETIME2!!!!!!!!!!!!!",msg)
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1412,7 +1412,7 @@ class SILENCETIME2_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*KEYBRD]'
-        # print("SILENCETIME2!!!!!!!!!!!!!",msg)
+        # EventMesh.debug_log("SILENCETIME2!!!!!!!!!!!!!",msg)
         EventMesh.publish(constants.PROTOCOL.SILENCETIME2_SEND)  
 
 #键盘开关
@@ -1424,8 +1424,8 @@ class KEYBRD_ProtoCol(ProtoCol):
         send_data = self.PID+"*%s*0006*KEYBRD"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        # print("KEYBRD:data:%s"%(data))
-        # print("KEYBRD!!!!!!!!!!!!!",msg)
+        # EventMesh.debug_log("KEYBRD:data:%s"%(data))
+        # EventMesh.debug_log("KEYBRD!!!!!!!!!!!!!",msg)
         # 通过socket发送到服务器端
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
 
@@ -1435,7 +1435,7 @@ class KEYBRD_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*KEYBRD]'
-        # print("KEYBRD!!!!!!!!!!!!!",msg)
+        # EventMesh.debug_log("KEYBRD!!!!!!!!!!!!!",msg)
         EventMesh.publish(constants.PROTOCOL.KEYBRD_SEND)  
 class TK_ProtoCol(ProtoCol):
     """微聊"""
@@ -1443,7 +1443,7 @@ class TK_ProtoCol(ProtoCol):
     
 
     def send(self, event, msg):
-        # print("TK send:{}".format(msg))
+        # EventMesh.debug_log("TK send:{}".format(msg))
         if len(str(msg)) == 1:
 
             len_size = len(str(msg))+len("TKS,")
@@ -1452,7 +1452,7 @@ class TK_ProtoCol(ProtoCol):
             MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TKS")
             MD5_SIGN = self.pack_MD5_head(MD5_head_data)
             data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
-            print("TK:data:%s"%(data))
+            EventMesh.debug_log("TK:data:%s"%(data))
             # 通过socket发送到服务器端
             EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
         else:
@@ -1460,7 +1460,7 @@ class TK_ProtoCol(ProtoCol):
             #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
             arm_data = msg[1]
             arm_sec = msg[0]
-            # print("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+            # EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
 
             arm = bytearray()
             for i in range(len(arm_data)):
@@ -1487,7 +1487,7 @@ class TK_ProtoCol(ProtoCol):
             data.extend(MD5_SIGN)
             data.extend(send_data)
             data.extend(']')
-            # print("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
+            # EventMesh.debug_log("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
             EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
 
@@ -1500,7 +1500,7 @@ class TK_ProtoCol(ProtoCol):
         [SZKW*860132060004322*20BD*TK,#!AMR...]
         """
         #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
-        # print("TK recv:{}".format(msg))
+        # EventMesh.debug_log("TK recv:{}".format(msg))
         msg_tmp = msg.decode('ascii')
         str = msg_tmp.split('TK,')
         # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
@@ -1521,7 +1521,7 @@ class TK_ProtoCol(ProtoCol):
                 wechat_num += 1 
 
 
-            print("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
+            EventMesh.debug_log("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
             wechat_recode_list["%02d"%(wechat_num)] = "read:1"
             wechat_recode_list['num'] = wechat_num
             EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
@@ -1634,7 +1634,7 @@ class ProtoColResolver(object):
     def handler(self, data):
         # 这里接收数据
         
-        # print("handler -> {}".format(data))
+        # EventMesh.debug_log("handler -> {}".format(data))
         # if data.startswith('Init;'):
         #     data = data[5:]
         #     EventMesh.publish(constants.EVENT.SET_KEY, {"value": ujson.loads(data)['KEY']})
@@ -1644,15 +1644,15 @@ class ProtoColResolver(object):
         #     EventMesh.publish(constants.PROTOCOL.H04_RECV, data)
         try:
             if len(data) > 0: 
-                #print("handler:{}".format(len(data)))
+                #EventMesh.debug_log("handler:{}".format(len(data)))
                 data_tmp = data.decode('ascii')
                 data_tmp = data_tmp.split(']')[0] #去掉]
                 ProtoCol_type = data_tmp.split('*')[3] #拿到协议标识
                 ProtoCol_type = ProtoCol_type.split(',')[0]
                 ProtoCol_type = "%s_RECV"%(ProtoCol_type)
-                # print("ProtoColResolver:ProtoCol_type:%s\r\ndata:%s"%(ProtoCol_type,data))
+                # EventMesh.debug_log("ProtoColResolver:ProtoCol_type:%s\r\ndata:%s"%(ProtoCol_type,data))
                 EventMesh.publish(ProtoCol_type, data) #返回协议read
         except Exception as e:
-            print("handler:ERROR:")
+            EventMesh.debug_log("handler:ERROR:")
             usys.print_exception(e)
-            print("handler:error data:{}".format(len(data)))
+            EventMesh.debug_log("handler:error data:{}".format(len(data)))
index 073ed26..7631a1a 100644 (file)
@@ -28,13 +28,13 @@ r_data = bytearray(2)
 data = bytearray([0x60A0, 0])   #休眠
 i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
 def gsensor_cb(self, para):
-        print("gsensor_cb:{}".format(para))
+        EventMesh.debug_log("gsensor_cb:{}".format(para))
 gsensor = SC7A20()
-print("DeviceInfoManager:1.0")
+EventMesh.debug_log("DeviceInfoManager:1.0")
 gsensor.activate()
-print("DeviceInfoManager:1.1")
+EventMesh.debug_log("DeviceInfoManager:1.1")
 gsensor.init()
-print("DeviceInfoManager:2")
+EventMesh.debug_log("DeviceInfoManager:2")
 gsensor.set_callback(gsensor_cb)
 hsensor = GH3018()
 hsensor.activate()
@@ -47,4 +47,4 @@ hsensor.close()
 #lcd_ctrl.write(0)
 lv.autoSleep(1)
 pm.autosleep(1)
-print("test end2")
\ No newline at end of file
+EventMesh.debug_log("test end2")
\ No newline at end of file
index 7517b23..8c31f04 100644 (file)
@@ -23,10 +23,10 @@ import usys
 def audio_cb(event):
     if event == 0:
         EventMesh.publish("set_audio_state", 1)
-        print('audio-play start.') 
+        EventMesh.debug_log('audio-play start.') 
     elif event == 7:
         EventMesh.publish("set_audio_state", 0)
-        print('audio-play finish.')
+        EventMesh.debug_log('audio-play finish.')
 CALL_LOG_MAX = 50
 aud = audio.Audio(0)
 aud.setCallback(audio_cb)
@@ -34,18 +34,18 @@ aud.setCallback(audio_cb)
 def msg_cb(args):
     index = args[1]
     storage = args[2]
-    # print("index:{}".format(index))
+    # EventMesh.debug_log("index:{}".format(index))
     sms_data = sms.getSaveLoc()
     sms_max = sms_data[0][2]
     if index != -1:
         tmp = sms.searchTextMsg(index)
         detail = tmp[1]#内容
-        # print("msg_cb:detail {}".format,detail)
+        # EventMesh.debug_log("msg_cb:detail {}".format,detail)
         if  detail.find("SETIP:") != -1:#寻找是否有这个字符串
             tmp_test = detail.split("SETIP:")[1]
             if  tmp_test.find(":") != -1:
                 new_ip = tmp_test.split(':')[0]
-                # print("tmp_test:{} new_ip:{}".format(tmp_test,new_ip))
+                # EventMesh.debug_log("tmp_test:{} new_ip:{}".format(tmp_test,new_ip))
                 new_com = tmp_test.split(':')[1]
                 # new_md5 = detail.split(':')[3]
                 if len(new_ip) > 0 and len(new_com) > 0:
@@ -89,7 +89,7 @@ class UI(object):
         self.main_id = 0
         self.set_interrup_flag = 0
         self.UI_high_priority_flag = 0 #如果=1,则当前ui不被打断
-        # print("self.read_data:{} self.level:{}".format(self.read_data,self.level))
+        # EventMesh.debug_log("self.read_data:{} self.level:{}".format(self.read_data,self.level))
         # check = ql_fs.path_exists("/usr/static/storage_file/config.json")
         # if check == True:
         #     with open("/usr/static/storage_file/config.json","r") as fd:
@@ -160,13 +160,13 @@ class UI(object):
     def ui_queue_thread(self):
         while True:
             data = self.ui_queue.get()
-            #print("ui_queue_thread:data = {}".format(data))
+            #EventMesh.debug_log("ui_queue_thread:data = {}".format(data))
             if data != None:
                 try:
                     data["func"](data["data"])
                 except Exception as e:
                     usys.print_exception(e)
-                    print("ui_queue_thread:ERROR:{}".format(e))
+                    EventMesh.debug_log("ui_queue_thread:ERROR:{}".format(e))
             # for scr in self.screen_list:
             #     if scr.handle_message_event(data) == 1 :
             #         break
@@ -190,11 +190,11 @@ class UI(object):
         return self.sleep_flag
     
     def set_lcd_state(self, event, key):
-        print("key_:{}".format(key))
+        EventMesh.debug_log("key_:{}".format(key))
         self.sleep_flag = key
     
     def system_sleep_rest(self, event, key):
-        #print("system_sleep_rest!!!!!")
+        #EventMesh.debug_log("system_sleep_rest!!!!!")
         self.system_sleep_timeout_rest()
 
     
@@ -202,9 +202,9 @@ class UI(object):
     def __lcd_on(self):
         self.system_sleep_timeout_rest()
         if self.sleep_flag == 0 :
-            print("__lcd_on")
+            EventMesh.debug_log("__lcd_on")
             if self.sleep_lock == 1:
-                print("__lcd_on:sleep_lock:error!")
+                EventMesh.debug_log("__lcd_on:sleep_lock:error!")
                 utime.sleep_ms(200)
             self.sleep_lock = 1
             self.sleep_flag = 1
@@ -229,9 +229,9 @@ class UI(object):
     def __lcd_off(self):
         
         if self.sleep_flag == 1 :
-            print("__lcd_off")
+            EventMesh.debug_log("__lcd_off")
             if self.sleep_lock == 1:
-                print("__lcd_on:sleep_lock:error!")
+                EventMesh.debug_log("__lcd_on:sleep_lock:error!")
                 utime.sleep_ms(200)
             self.sleep_lock = 1
             self.sleep_flag = 0
@@ -257,7 +257,7 @@ class UI(object):
         self.__lcd_on()
 
     def system_sleep_timer_cb(self, *args):
-        #print("system_sleep_timer_count:{}".format(self.system_sleep_timer_count))
+        #EventMesh.debug_log("system_sleep_timer_count:{}".format(self.system_sleep_timer_count))
         time = EventMesh.publish("get_brightness_time")
         if time == None:
             time = 10
@@ -267,7 +267,7 @@ class UI(object):
             self.__lcd_off()
 
     def system_sleep_timeout_rest(self) :
-        #print("system_sleep_timeout_rest")
+        #EventMesh.debug_log("system_sleep_timeout_rest")
         self.system_sleep_timer_count = 0
 
     def start(self):
@@ -285,7 +285,7 @@ class UI(object):
         EventMesh.publish("publish_message_event_ui",{"func":self.load_screen,"data":msg})  
 
     def load_screen(self, msg):
-        print("msg1={}".format(msg))
+        EventMesh.debug_log("msg1={}".format(msg))
         if self.UI_high_priority_flag == 1:#电话界面屏蔽其他界面
             return
         if self.screen :
@@ -300,7 +300,7 @@ class UI(object):
                 else :
                     self.main_flag = 0
                 mem = gc.mem_free()
-                print('1剩余内存RAM:{} KB'.format(mem / 1024))
+                EventMesh.debug_log('1剩余内存RAM:{} KB'.format(mem / 1024))
     
                 self.screen = scr
                 
@@ -314,19 +314,19 @@ class UI(object):
                 self.screen_old = self.screen
                 if msg.get("meta"):
                     self.screen.meta_info = msg.get("meta")
-                print("load_screen:post_processor_before_initialization")
+                EventMesh.debug_log("load_screen:post_processor_before_initialization")
                 self.screen.post_processor_before_initialization()
-                print("load_screen:initialization")
+                EventMesh.debug_log("load_screen:initialization")
                 # self.screen.initialization()
                 
-                print("load_screen.load()")
+                EventMesh.debug_log("load_screen.load()")
                 # self.screen.load()
                 # self.lv.scr_load(self.screen.get_meta())
                 
                 self.screen.post_processor_after_initialization()
                 # self.__lcd_on()
                 mem = gc.mem_free()
-                print('2剩余内存RAM:{} KB'.format(mem / 1024))
+                EventMesh.debug_log('2剩余内存RAM:{} KB'.format(mem / 1024))