From: d15521469561 Date: Wed, 17 May 2023 01:37:59 +0000 (+0800) Subject: main增加sos协议 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=8475f4e6a789ee74e294df561b2daca430219c6f;p=mirrors%2FASR1603_G5.git main增加sos协议 --- diff --git a/2.sdk/images/customer_fs.bin b/2.sdk/images/customer_fs.bin index 23b470bb..7750ac0d 100644 Binary files a/2.sdk/images/customer_fs.bin and b/2.sdk/images/customer_fs.bin differ diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appAlipay.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appAlipay.py index e931de15..44c4bf42 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appAlipay.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appAlipay.py @@ -11,7 +11,7 @@ import constants from misc import Power import pm from ui import Screen - +from code import code_39_generate_barcode style_font_youyuan_20 = lv.style_t() style_font_youyuan_20.init() style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff)) @@ -635,54 +635,44 @@ alipay_paycode.set_size(240, 320) alipay_paycode.add_style(style_alipay_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT) # 1 - 条形码界面 -alipay_barcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT) +# alipay_barcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT) #椭圆背景 -alipay_paycode_cont = lv.obj(alipay_barcode) -alipay_paycode_cont.set_size(240,220) -alipay_paycode_cont.set_pos(0,21) -alipay_paycode_cont.add_style(style_cont_alipay, lv.PART.MAIN | lv.STATE.DEFAULT) - - -#提示词 -alipay_paycode_label = lv.label(alipay_barcode) -alipay_paycode_label.set_pos(0, 33) -alipay_paycode_label.set_size(240, 24) -alipay_paycode_label.set_long_mode(lv.label.LONG.WRAP) -alipay_paycode_label.set_text("收银员扫一扫,完成付款") -alipay_paycode_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -alipay_paycode_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +# alipay_paycode_cont = lv.obj(alipay_barcode) +# alipay_paycode_cont.set_size(240,220) +# alipay_paycode_cont.set_pos(0,21) +# alipay_paycode_cont.add_style(style_cont_alipay, lv.PART.MAIN | lv.STATE.DEFAULT) #条形码 alipay_paycode_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5) alipay_paycode_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4) -alipay_bar = lv.qrcode(alipay_barcode, 150, alipay_paycode_fg_color, alipay_paycode_bg_color) -alipay_bar.set_pos(33,61) -alipay_bar.set_style_border_color(alipay_paycode_bg_color, 0) -alipay_bar.set_style_border_width(5, 0) +# alipay_bar = lv.qrcode(alipay_barcode, 150, alipay_paycode_fg_color, alipay_paycode_bg_color) +# alipay_bar.set_pos(33,61) +# alipay_bar.set_style_border_color(alipay_paycode_bg_color, 0) +# alipay_bar.set_style_border_width(5, 0) #编号 # 2 - 二维码界面 -alipay_qrcode = alipay_paycode.add_tile(1, 0, lv.DIR.LEFT | lv.DIR.RIGHT) - -#白色背景 +alipay_qrcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT) -#提示词 -alipay_paycode_label1 = lv.label(alipay_qrcode) -alipay_paycode_label1.set_pos(0, 33) -alipay_paycode_label1.set_size(240, 24) -alipay_paycode_label1.set_long_mode(lv.label.LONG.WRAP) -alipay_paycode_label1.set_text("收银员扫一扫,完成付款") -alipay_paycode_label1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -alipay_paycode_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #二维码 - alipay_paycode_alipay_qr = lv.qrcode(alipay_qrcode, 150, alipay_paycode_fg_color, alipay_paycode_bg_color) -alipay_paycode_alipay_qr.set_pos(33,61) +alipay_paycode_alipay_qr.set_pos(45,61) alipay_paycode_alipay_qr.set_style_border_color(alipay_paycode_bg_color, 0) alipay_paycode_alipay_qr.set_style_border_width(5, 0) + +#提示词 +alipay_paycode_label = lv.label(alipay_qrcode) +alipay_paycode_label.set_pos(0, 33) +alipay_paycode_label.set_size(240, 24) +alipay_paycode_label.set_long_mode(lv.label.LONG.WRAP) +alipay_paycode_label.set_text("收银员扫一扫,完成付款") +alipay_paycode_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +alipay_paycode_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + class Alipay_paycode(Screen): NAME = "alipay_paycode" @@ -694,8 +684,9 @@ class Alipay_paycode(Screen): self.alipay_qr_data = str(self.meta_info) print("alipay_paycode:",str(self.meta_info)) alipay_paycode_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data)) - alipay_bar.update(self.alipay_qr_data,len(self.alipay_qr_data)) - + # alipay_bar.update(self.alipay_qr_data,len(self.alipay_qr_data)) + # code_39_generate_barcode(alipay_barcode,self.alipay_qr_data,120,320) + def Close(self): EventMesh.publish("alipay_exit") pass @@ -864,10 +855,12 @@ alipay_parent_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5) alipay_parent_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4) alipay_parent_alipay_qr = lv.qrcode(alipay_parent_screen, 150, alipay_parent_fg_color, alipay_parent_bg_color) -alipay_parent_alipay_qr.set_pos(8,171) +alipay_parent_alipay_qr.set_pos(45,171) # Add a border with bg_color alipay_parent_alipay_qr.set_style_border_color(alipay_parent_bg_color, 0) alipay_parent_alipay_qr.set_style_border_width(5, 0) +alipay_parent_alipay_qr.set_style_border_width(5, 0) + class Alipay_parent(Screen): NAME = "alipay_parent" diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appWechat.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appWechat.py index afc5f441..5acc130c 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appWechat.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/appWechat.py @@ -182,14 +182,15 @@ class WechatScreen(Screen): #读取json文件中的键作为label文本; #print("self.wechat_list.self.wechat_num:{}".format(self.wechat_num)) - print("self.wechat_recode_list:{}".format(self.wechat_recode_list)) + # print("self.wechat_recode_list:{}".format(self.wechat_recode_list)) self.wechat_list.delete()#先删除一次控件 self.wechat_list = lv.obj(wechat_screen) self.wechat_list.set_pos(0, 0) self.wechat_list.set_size(240, 250) self.wechat_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.wechat_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - self.play_img_cnt = None + self.play_img_cnt = lv.img(self.wechat_list) + self.play_img_cnt.set_size(30, 30) if index == 2: self.wechat_list.add_flag(lv.obj.FLAG.HIDDEN) j = 1 diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/code.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/code.py index 6b81d641..7ba9301f 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/code.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/code.py @@ -1,195 +1,24 @@ -from machine import LCD, Pin import lvgl as lv -from tp import cst816 - -test = ( - - 0, 0, 0x11, - 2, 0, 120, - - 0, 1, 0x36, - 1, 1, 0x00, - - 0, 1, 0x35, - 1, 1, 0x01, - - 0, 1, 0x3a, - 1, 1, 0x05, - - 0, 5, 0xB2, - 1, 1, 0x0c, - 1, 1, 0x0c, - 1, 1, 0x00, - 1, 1, 0x33, - 1, 1, 0x33, - - 0, 1, 0xB7, - 1, 1, 0x77, - - 0, 1, 0xBB, - 1, 1, 0x2c, - - 0, 1, 0xC0, - 1, 1, 0x2C, - - 0, 1, 0xC2, - 1, 1, 0x01, - - 0, 1, 0xC3, - 1, 1, 0x21, - - 0, 1, 0xC4, - 1, 1, 0x20, - - 0, 1, 0xC6, - 1, 1, 0x10, - - 0, 2, 0xD0, - 1, 1, 0xA4, - 1, 1, 0xA1, - - 0, 14, 0xE0, - 1, 1, 0xd0, - 1, 1, 0x03, - 1, 1, 0x08, - 1, 1, 0x0e, - 1, 1, 0x12, - 1, 1, 0x2d, - 1, 1, 0x42, - 1, 1, 0x45, - 1, 1, 0x53, - 1, 1, 0x29, - 1, 1, 0x16, - 1, 1, 0x15, - 1, 1, 0x22, - 1, 1, 0x24, - - 0, 14, 0xE1, - 1, 1, 0xd0, - 1, 1, 0x03, - 1, 1, 0x08, - 1, 1, 0x0e, - 1, 1, 0x13, - 1, 1, 0x2c, - 1, 1, 0x42, - 1, 1, 0x54, - 1, 1, 0x50, - 1, 1, 0x2c, - 1, 1, 0x16, - 1, 1, 0x16, - 1, 1, 0x20, - 1, 1, 0x27, - # 0, 0, 0x11, - 0, 0, 0x21, - 0, 0, 0x29, - # 0, 1, 0xe7, - # 1, 1, 0x11, -) - -XSTART_H = 0xf0 -XSTART_L = 0xf1 -YSTART_H = 0xf2 -YSTART_L = 0xf3 -XEND_H = 0xE0 -XEND_L = 0xE1 -YEND_H = 0xE2 -YEND_L = 0xE3 - -XSTART = 0xD0 -XEND = 0xD1 -YSTART = 0xD2 -YEND = 0xD3 - -lcd = LCD() - -test1 = bytearray(test) - -test2 = ( - 0, 4, 0x2a, - 1, 1, XSTART_H, - 1, 1, XSTART_L, - 1, 1, XEND_H, - 1, 1, XEND_L, - 0, 4, 0x2b, - 1, 1, YSTART_H, - 1, 1, YSTART_L, - 1, 1, YEND_H, - 1, 1, YEND_L, - 0, 0, 0x2c, -) -test_invalid = bytearray(test2) - -test3 = ( - 0, 0, 0x28, - 2, 0, 120, - 0, 0, 0x10, -) -test_displayoff = bytearray(test3) - -test4 = ( - 0, 0, 0x11, - 2, 0, 120, - 0, 0, 0x29, -) -test_displayon = bytearray(test4) - -gpio4 = Pin(Pin.GPIO18, Pin.OUT, Pin.PULL_PU, 0) -gpio4.write(1) -lcd.lcd_init(test1, 240, 320, 52000, 1, 4, 0, test_invalid, test_displayon, test_displayoff, None, TESel=True, TEPin=7) -lcd.lcd_clear(0xf800) -gpio5 = Pin(Pin.GPIO17, Pin.OUT, Pin.PULL_PU, 0) -gpio5.write(1) - -LCD_SIZE_W = 240 -LCD_SIZE_H = 320 - -# 初始化lvgl -lv.init() - -# Register SDL display driver. -disp_buf1 = lv.disp_draw_buf_t() -buf1_1 = bytearray(LCD_SIZE_W * LCD_SIZE_H * 2) -buf1_2 = bytearray(LCD_SIZE_W * LCD_SIZE_H * 2) -disp_buf1.init(buf1_1, buf1_2, len(buf1_1)) -disp_drv = lv.disp_drv_t() -disp_drv.init() -disp_drv.draw_buf = disp_buf1 -disp_drv.flush_cb = lcd.lcd_write -disp_drv.hor_res = LCD_SIZE_W -disp_drv.ver_res = LCD_SIZE_H -disp_drv.register() - -# CST816初始化 -tp_cst816 = cst816(i2c_no = 2,irq=33,reset=32) -tp_cst816.activate() -tp_cst816.init() -print("cst816 init...") -# LVGL触摸注册 -indev_drv = lv.indev_drv_t() -indev_drv.init() -indev_drv.type = lv.INDEV_TYPE.POINTER -indev_drv.read_cb = tp_cst816.read -indev_drv.register() -gpio6 = Pin(Pin.GPIO33, Pin.OUT, Pin.PULL_PU, 0) -gpio6.write(0) - - -# 启动lvgv线程 -lv.tick_inc(5) -lv.task_handler() -print("lvgl init complete") - # 界面风格1 +# style_bar = lv.style_t() +# style_bar.init() +# style_bar.set_border_width(0) +# style_bar.set_radius(0) +# style_bar.set_pad_top(0) +# style_bar.set_pad_bottom(0) +# style_bar.set_pad_left(0) +# style_bar.set_pad_right(0) style_bar = lv.style_t() style_bar.init() -style_bar.set_border_width(0) style_bar.set_radius(0) -style_bar.set_pad_top(0) -style_bar.set_pad_bottom(0) +style_bar.set_bg_color(lv.color_make(0x00, 0x00, 0x00)) +style_bar.set_bg_opa(255) +style_bar.set_border_width(0) style_bar.set_pad_left(0) style_bar.set_pad_right(0) - -screen = lv.obj() +style_bar.set_pad_top(0) +style_bar.set_pad_bottom(0) +#screen = lv.obj() # Code 39字符集和对应的二进制码 code_39_dict = {'0': '0001101000', '1': '1001000010', '2': '0011000010', '3': '1011000000', '4': '0001100010', @@ -208,7 +37,7 @@ code_39_end = '010010100' #结束符结尾'0'去掉 # Code 39条形码的宽度系数 code_39_narrow = 1 -code_39_wide = 3 +code_39_wide = 2 def code_39_encode(data): @@ -251,26 +80,27 @@ def code_39_generate_barcode(screen, data, width=180, height=80): # 在LVGL中创建一个容器对象 container = lv.obj(screen) - # container.set_size(width, height) + container.set_size(240, 330) container.add_style(style_bar,lv.PART.MAIN | lv.STATE.DEFAULT) container.center() # 计算每个条的宽度 - bar_width = width // (len(binary_data)) - + bar_width = height // (len(binary_data)) + print("bar_width is :{} len(binary_data):{}".format(bar_width,len(binary_data))) # 按照二进制码中的1和0,分别创建LVGL矩形对象 for i in range(len(binary_data)): + print("left_curr_line is :{} width:{}".format(left_curr_line,width)) if i % 2 == 0: # 创建一个黑色矩形 bar = lv.obj(container) bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT) if binary_data[i] == '1': real_width = bar_width * code_39_wide - bar.set_size(real_width, height) + bar.set_size(120, 2) else: real_width = bar_width * code_39_narrow - bar.set_size(real_width, height) - bar.align(lv.ALIGN.TOP_LEFT, left_curr_line, 0) + bar.set_size(120, 2 ) + bar.set_pos(60, 0+left_curr_line+20) bar.set_style_bg_color(lv.color_make(0x00, 0x00, 0x00), lv.PART.MAIN | lv.STATE.DEFAULT) left_curr_line += real_width else: @@ -279,18 +109,19 @@ def code_39_generate_barcode(screen, data, width=180, height=80): bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT) if binary_data[i] == '1': real_width = bar_width * code_39_wide - bar.set_size(real_width, height) + bar.set_size(120, 2) else: real_width = bar_width * code_39_narrow - bar.set_size(real_width, height) - bar.align(lv.ALIGN.TOP_LEFT, left_curr_line, 0) + bar.set_size(120, 2) + bar.set_pos(60, 0+left_curr_line+20) + # bar.align(lv.ALIGN.TOP_LEFT, left_curr_line, 0) bar.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF), lv.PART.MAIN | lv.STATE.DEFAULT) left_curr_line += real_width - container.set_size(left_curr_line, height) + container.set_size(240,330 ) -if __name__ == "__main__": - code_39_generate_barcode(screen,"A123 321") - lv.scr_load(screen) +# if __name__ == "__main__": +# code_39_generate_barcode(screen,"A123 321") +# lv.scr_load(screen) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py index 4ae047a6..b733c166 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py @@ -1483,6 +1483,29 @@ class SockManager(Abstract): while True: try: r = self.sock.recv(512) + + if not r: + self.run_flag = False + if(self.sock != None) : + self.sock.close() + _thread.stack_size(24*1024) + _thread.start_new_thread(self.reconnect, ()) + _thread.stack_size(8*1024) + break + data = data + r + if data[-1] != 0x5d and len(data)<20*1024: #']': + continue + self.connect_tmp = 1 #有数据,就认为是连接状态 + print("TCP recv: data:len:{}".format(len(data))) + EventMesh.publish(constants.EVENT.SET_CONNECT, 1) + data_str = data.decode('ascii') + data_str = data_str.split(']') + if len(data_str) < 3 : + self.resolver.handler(data) + else : + for i in range(len(data_str)): + self.resolver.handler(data_str[i].decode("utf-8")) + data = b'' except Exception as e: self.run_flag = False if(self.sock != None) : @@ -1491,29 +1514,6 @@ class SockManager(Abstract): _thread.start_new_thread(self.reconnect, ()) _thread.stack_size(8*1024) break - if not r: - self.run_flag = False - if(self.sock != None) : - self.sock.close() - _thread.stack_size(24*1024) - _thread.start_new_thread(self.reconnect, ()) - _thread.stack_size(8*1024) - break - data = data + r - if data[-1] != 0x5d and len(data)<20*1024: #']': - continue - self.connect_tmp = 1 #有数据,就认为是连接状态 - print("TCP recv: data:len:{}".format(len(data))) - EventMesh.publish(constants.EVENT.SET_CONNECT, 1) - data_str = data.decode('ascii') - data_str = data_str.split(']') - if len(data_str) < 3 : - self.resolver.handler(data) - else : - for i in range(len(data_str)): - self.resolver.handler(data_str[i].decode("utf-8")) - data = b'' - class NetManager(Abstract): THRESHOLD = 10 @@ -1567,6 +1567,7 @@ class LocationManager(Abstract): self.location_check_data_timer_count = 0 self.location_type = 0 #定位类型,0:正常定位,有gps数据或60秒关闭;1:测试模式,只有发CLOSE_LOCATION消息才关闭 self.location_thread_flag = 0 + self.location_thread_id = 0 @staticmethod def get_date(): return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3]) @@ -1606,7 +1607,7 @@ class LocationManager(Abstract): self.location_timer_count = 0 self.timer_read_GPS_info.start(1000, 1, self.location_timer) if self.location_thread_flag == 0: - _thread.start_new_thread(self.location_thread, ()) + self.location_thread_id = _thread.start_new_thread(self.location_thread, ()) self.wifi_data = [] self.gps_data = [] self.cell_data = [] @@ -1621,7 +1622,9 @@ class LocationManager(Abstract): wifiScan.control(0) self.timer_read_GPS_info.stop() self.location_timer_count = 5*60 #让线程结束 - + self.location_thread_flag = 0 + if(self.location_thread_id != 0): + _thread.stop_thread(self.location_thread_id) def WIFI_INFO(self, event, msg): self.wifi_data = msg @@ -1654,77 +1657,82 @@ class LocationManager(Abstract): def location_timer(self, *args, **kwargs): - data = "" + self.location_timer_count = self.location_timer_count +1 self.location_check_data_timer_count = self.location_check_data_timer_count+1 def location_thread(self): + data = "" self.location_thread_flag = 1 - while True: - match_gga_data = [] - match_gsv_data = [] - - if self.location_check_data_timer_count > 3 :#5秒查一次 - self.location_check_data_timer_count = 0 - #print(self.location_timer_count) - #检查wifi数据 - if self.wifi_data == [] or (self.wifi_data != [] and self.wifi_data[0] == 0):#and self.wifi_data[0] <= 0: - EventMesh.publish(constants.EVENT.WIFISCANOPEN) - #检查GNSS数据 - if self.gps_data == [] and quecgnss.get_state() == 2: - self.gps.__gps_nmea_data_clean() - data = quecgnss.read(4096) - #print(data[1].decode()) - if data[0] > 0 : #有数据 - match_gga_data = self.match.GxGGA(data[1]).split(",") - match_gsv_data = self.match.GxGSV(data[1]).split(",") - if self.gps.__check_gps_valid(data[1].decode()): #数据齐全 - match_gmc_data = self.match.GxRMC(data[1]).split(",") - match_vtg_data = self.match.GxVTG(data[1]).split(",") + try : + while True: + match_gga_data = [] + match_gsv_data = [] + + if self.location_check_data_timer_count > 3 :#5秒查一次 + self.location_check_data_timer_count = 0 + #print(self.location_timer_count) + #检查wifi数据 + if self.wifi_data == [] or (self.wifi_data != [] and self.wifi_data[0] == 0):#and self.wifi_data[0] <= 0: + EventMesh.publish(constants.EVENT.WIFISCANOPEN) + #检查GNSS数据 + if self.gps_data == [] and quecgnss.get_state() == 2: + self.gps.__gps_nmea_data_clean() + data = quecgnss.read(4096) + #print(data[1].decode()) + if data[0] > 0 : #有数据 match_gga_data = self.match.GxGGA(data[1]).split(",") - data = self.gps.read_coordinates(data[1]) - latitude_tmp = str(data[1]).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_gmc_data[4] ) - longitude_tmp = str(data[0]).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_gmc_data[6] ) #match_gmc_data[6] + str(data[1]) - high = str(data[2]) - self.gps_data = { - "latitude": latitude, - "longitude": longitude, - "high": high, - "direction": match_vtg_data[1], - "speed": match_vtg_data[5], - "number": match_gga_data[7], - } - #检查基站数据 - if self.cell_data == []: - self.cell_data = net.getCellInfo() - for cell in self.cell_data: - if cell and cell[0][0] == 0 : - self.cell_data = cell - break - if self.location_timer_count >= 60*4 : #4分钟关闭线程 - break - if self.location_type == 1: #测试模式 - EventMesh.publish("PUSH_LOCATION_DATA", [data,self.wifi_data,self.cell_data]) - elif self.location_type == 0: #正常模式 - if self.gps_data != [] or self.location_timer_count > 40: #or( self.wifi_data != [] and self.cell_data != []): - #print("publish:READ_LOCATION") - EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data]) + match_gsv_data = self.match.GxGSV(data[1]).split(",") + if self.gps.__check_gps_valid(data[1].decode()): #数据齐全 + match_gmc_data = self.match.GxRMC(data[1]).split(",") + match_vtg_data = self.match.GxVTG(data[1]).split(",") + match_gga_data = self.match.GxGGA(data[1]).split(",") + data = self.gps.read_coordinates(data[1]) + latitude_tmp = str(data[1]).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_gmc_data[4] ) + longitude_tmp = str(data[0]).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_gmc_data[6] ) #match_gmc_data[6] + str(data[1]) + high = str(data[2]) + self.gps_data = { + "latitude": latitude, + "longitude": longitude, + "high": high, + "direction": match_vtg_data[1], + "speed": match_vtg_data[5], + "number": match_gga_data[7], + } + #检查基站数据 + if self.cell_data == []: + self.cell_data = net.getCellInfo() + for cell in self.cell_data: + if cell and cell[0][0] == 0 : + self.cell_data = cell + break + if self.location_timer_count >= 60*4 : #4分钟关闭线程 EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 break - if len(match_gsv_data) >= 3: - #print("match_gsv_data[3]:{}".format(match_gsv_data[3])) - if (int(match_gsv_data[3]) < 3 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 10): #超过10秒且卫星个数少于3 + if self.location_type == 1: #测试模式 + EventMesh.publish("PUSH_LOCATION_DATA", [data,self.wifi_data,self.cell_data]) + elif self.location_type == 0: #正常模式 + if self.gps_data != [] or self.location_timer_count > 40: #or( self.wifi_data != [] and self.cell_data != []): #print("publish:READ_LOCATION") EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data]) - EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 + EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 break - utime.sleep_ms(1000) + if len(match_gsv_data) >= 3: + #print("match_gsv_data[3]:{}".format(match_gsv_data[3])) + if (int(match_gsv_data[3]) < 3 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 10): #超过10秒且卫星个数少于3 + #print("publish:READ_LOCATION") + EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data]) + EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 + break + utime.sleep_ms(1000) + except Exception as e: + print("location_thread:ERROR:{}".format(e)) self.location_thread_flag = 0 @@ -2218,7 +2226,7 @@ class getVolumSizeManager(Abstract):#设置或获取音量大小数据 def get_volum_size(self, event, msg): return self.volume_size -class getSosFlagManager(Abstract):#设置或获取音量大小数据 +class getSosFlagManager(Abstract):#设置sos def __init__(self): self.sos_flag = 0 self.sos_num = 0 @@ -2260,10 +2268,13 @@ class getSosFlagManager(Abstract):#设置或获取音量大小数据 def set_sos_flag(self, event, msg): self.sos_flag = msg + if self.sos_flag == 1: number = EventMesh.publish("get_dial_sos_number") + if number != None: if len(number) > 0: + EventMesh.publish("save_phonename",number[0]) EventMesh.publish("save_phonenum",number[0]) voiceCall.callStart(str(number[0])) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py index 94517e00..074fd0d9 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py @@ -1049,7 +1049,7 @@ class ProtoColResolver(object): # data = data[7:] # EventMesh.publish(constants.PROTOCOL.H04_RECV, data) try: - print("handler:{} data type:{}".format(data,type(data))) + print("handler:{}".format(len(data))) data_tmp = data.decode('ascii') data_tmp = data_tmp.split(']')[0] #去掉] ProtoCol_type = data_tmp.split('*')[3] #拿到协议标识 @@ -1058,5 +1058,5 @@ class ProtoColResolver(object): # print("ProtoColResolver:ProtoCol_type:%s\r\ndata:%s"%(ProtoCol_type,data)) EventMesh.publish(ProtoCol_type, data) #返回协议read except Exception as e: - print("handler:ERROR!!!!!!!!!!!") - print("handler:error data:{}".format(data)) + print("handler:ERROR:{}".format(e)) + print("handler:error data:{}".format(len(data))) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py index 22c305de..589d80e2 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py @@ -2617,7 +2617,7 @@ class CountdownScreen(Screen): self.g_state = 0 self.g_end = 0 self.total = 0 - + self.time_tmp = 0 def initialization(self): global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\ @@ -2812,8 +2812,10 @@ class CountdownScreen(Screen): countdown_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)), lv.EVENT.CLICKED, None) # countdown_stop_imgbtn.add_event_cb(lambda e: self.stop(e), - # lv.EVENT.CLICKED, None) - + # lv.EVENT.CLICKED, None) + date_tmp = utime.localtime() + self.time_tmp = utime.mktime(date_tmp) + self.timer_cb = 1 if self.g_state == 0: countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN) countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN) @@ -2833,6 +2835,7 @@ class CountdownScreen(Screen): self.hour = 0 self.min = 0 self.sec = 0 + self.timeSecond = self.time_tmp self.show_value() @@ -2889,6 +2892,7 @@ class CountdownScreen(Screen): if self.g_state != 2: self.g_state = 1 self.g_end = 0 + self.show_value() self.timer.start(1000,1,self.fun) countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN) @@ -2929,6 +2933,11 @@ class CountdownScreen(Screen): # EventMesh.publish("load_screen", {"screen": "countdown"}) def fun(self,e): + date_tmp = utime.localtime() + self.time_tmp = utime.mktime(date_tmp) + total_sec = self.time_tmp - self.timeSecond + down_sec = self.total - total_sec + print("down_sec:{} total_sec:{} self.time_tmp:{} self.timeSecond:{}".format(down_sec,total_sec,self.time_tmp,self.timeSecond)) self.hour = self.total//3600 self.min = self.total%3600//60 @@ -2986,7 +2995,14 @@ class CountdownScreen(Screen): countdown_min.set_text(str("%02d"%(self.min))) countdown_hour.set_text(str("%02d"%(self.hour))) + # def lcd_on(self): + # if self.timer_cb != 0: + # self.timer_cb = 0 + # self.timer.start(1000,1,self.fun) + # def lcd_off(self): + # self.timer_cb = 1 + # self.timer.stop() def done_return(self): if self.g_state == 0: @@ -3570,7 +3586,13 @@ class UI(object): if self.main_flag != 1 and self.sleep_flag == 0: - self.__lcd_on() + if event == "btn8_long_press": + if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机 + EventMesh.publish("set_sos_flag", 1) + else: + EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"}) + else: + self.__lcd_on() return # if event == "btn1_press": # self.screen.btn1_press() @@ -3625,6 +3647,7 @@ class UI(object): self.PWM_backlight.open() self.sleep_lock = 0 self.screen.lcd_on() + self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb) def publish_call_in(self, event, msg): EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg}) @@ -3649,6 +3672,7 @@ class UI(object): EventMesh.publish("set_lcd_state",self.sleep_flag) self.sleep_lock = 0 self.screen.lcd_off() + self.system_sleep_timer.stop() def system_sleep(self, event, msg) : self.__lcd_off() diff --git a/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/firmware_base_release_pack.zip b/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/firmware_base_release_pack.zip index 6ea890b9..35441ace 100644 Binary files a/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/firmware_base_release_pack.zip and b/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/firmware_base_release_pack.zip differ diff --git a/2.sdk/project/K5/usr/main.py b/2.sdk/project/K5/usr/main.py index 82bb5e2e..7affdf6f 100644 --- a/2.sdk/project/K5/usr/main.py +++ b/2.sdk/project/K5/usr/main.py @@ -132,12 +132,12 @@ if __name__ == '__main__': 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 + ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,sosHome_dial_ProtoCol import mgr as mgr print("init7:{}".format(utime.localtime())) from mgr import ConfigStoreManager, LocationManager, SockManager,getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\ - NetManager,AddrBookManager,MsgdetailManager,PhoneCallingManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager + NetManager,AddrBookManager,MsgdetailManager,PhoneCallingManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getSosFlagManager print("init8:{}".format(utime.localtime())) @@ -181,6 +181,7 @@ if __name__ == '__main__': app.append_manager(getUpLoadDataManager()) app.append_manager(getVolumSizeManager()) app.append_manager(getTempTimeManager()) + app.append_manager(getSosFlagManager()) app.append_manager(getplayAudiodStateManager()) print("init44444444444444444444444441:{}".format(utime.localtime())) @@ -211,6 +212,7 @@ if __name__ == '__main__': pcr.add_support(CENTER_ProtoCol()) pcr.add_support(bootoff_ProtoCol()) pcr.add_support(WDSTART_ProtoCol()) + pcr.add_support(sosHome_dial_ProtoCol()) sm = SockManager() sm.add_support_resolver(pcr) app.append_manager(sm)