def post_processor_after_initialization(self):
#utime.sleep_ms(1000)
- EventMesh.publish(constants.EVENT.START_LOCATION, 1) #测试模式
+ EventMesh.publish(constants.EVENT.START_LOCATION_TEST) #测试模式
def timer_FactoryModeLocation_cb(self, *args, **kwargs):
EventMesh.publish("system_sleep_rest")#防止黑屏
class EVENT:
CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND"
START_LOCATION = "START_LOCATION"
+ START_LOCATION_TEST = "START_LOCATION_TEST"
READ_LOCATION = "READ_LOCATION"
CLOSE_LOCATION = "CLOSE_LOCATION"
GPSOPEN = "GPSOPEN"
-import sms
-
-class App(object):
- def __init__(self):
- self.managers = []
-
- def append_manager(self, manager):
- if isinstance(manager, Abstract):
- manager.post_processor_after_instantiation()
- self.managers.append(manager)
- return self
-
- def start(self):
- for manager in self.managers:
- manager.post_processor_before_initialization()
- manager.initialization()
- manager.post_processor_after_initialization()
-
-
-class watchApp(App):
- def __init__(self):
- super(watchApp, self).__init__()
- self.__ui = None
-
- def set_ui(self, ui):
- self.__ui = ui
-
- def start(self):
- if self.__ui is not None:
- self.__ui.start()
- super().start()
-
-
-
-if __name__ == '__main__':
- import uos
- import ql_fs
- import utime
- if ql_fs.path_exists("/ext") == False:
- ldev = uos.VfsLfs1(32, 32, 32, "ext_fs",0,3)
- 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()))
- import EventMesh
- from common import Abstract
- print("init2:{}".format(utime.localtime()))
- from lcd import tp_cst816
- print("init3:{}".format(utime.localtime()))
-
- from usr.ui_main_menu import MainMenuScreen
- # from ui_WatchFaceScreen import WatchFaceScreen
-
- from appFactoryMode import FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeAlipayInitScreen
- import ui as _ui
- # import ui as _ui
- print("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()))
-
- ui.add_screen(_ui.PopupScreen())
- ui.add_screen(_ui.PhoneScreen())
- ui.add_screen(_ui.HeartrateScreen())
- import ui_setting as _ui_setting
- ui.add_screen(_ui_setting.SettingScreen())
- ui.add_screen(_ui.ToolboxScreen())
- ui.add_screen(_ui.StepScreen())
- ui.add_screen(_ui.CountdownScreen())
- ui.add_screen(_ui.StopwatchScreen())
- ui.add_screen(_ui.WeatherScreen())
- ui.add_screen(_ui.Spo2Screen())
- ui.add_screen(_ui.TemperatureScreen())
- ui.add_screen(_ui.ContactsScreen())
- from appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol,NewWechatPopupScreen
- ui.add_screen(WechatScreen())
- from alarm import ClkListScreen,ClockManager,NewEditClk,CLKTimeScreen,ClkPeriod,PopupAlarmScreen
- from ui_health import HealthScreen
- ui.add_screen(ClkListScreen())
- ui.add_screen(_ui.CountdownEndScreen())
- ui.add_screen(NewEditClk())
- ui.add_screen(CLKTimeScreen())
- ui.add_screen(ClkPeriod())
-
- # ui.add_screen(_ui_setting.LanguageScreen())
- ui.add_screen(_ui_setting.DialswitchScreen())
- # ui.add_screen(_ui.ThemeswitchScreen())
- ui.add_screen(_ui_setting.ImeiScreen())
- ui.add_screen(_ui_setting.AppScreen())
- ui.add_screen(_ui_setting.BrightnessScreen())
- ui.add_screen(_ui_setting.VolumeScreen())
- ui.add_screen(_ui_setting.RestoreScreen())
- ui.add_screen(_ui_setting.PoweroffScreen())
- ui.add_screen(_ui_setting.VersionScreen())
- ui.add_screen(_ui_setting.UpdateScreen())
- ui.add_screen(_ui_setting.AlarmvolumeScreen())
- ui.add_screen(_ui_setting.MsgvolumeScreen())
- ui.add_screen(_ui_setting.PhoneringScreen())
- ui.add_screen(_ui_setting.totalvolumeScreen())
- ui.add_screen(_ui_setting.PoweroffConfirmScreen())
- ui.add_screen(_ui.DialingScreen())
- ui.add_screen(_ui.CallLogScreen())
- from appAlipay import Alipay ,AlipayOpenScreen,Alipay_1_1,Alipay_invite,Alipay_inviting,\
- Alipay_success,Alipay_paycode,Alipay_pay_success,Alipay_collect,Alipay_parent
- ui.add_screen(AlipayOpenScreen())
- ui.add_screen(Alipay_1_1())
- ui.add_screen(Alipay_invite())
- ui.add_screen(Alipay_inviting())
- ui.add_screen(Alipay_success())
- ui.add_screen(Alipay_paycode())
- ui.add_screen(Alipay_pay_success())
- ui.add_screen(Alipay_collect())
- ui.add_screen(Alipay_parent())
- ui.add_screen(_ui.UIFINDScreen())
- ui.add_screen(_ui.MsgDetailScreen())
- ui.add_screen(_ui.IncomingCallScreen())
- ui.add_screen(_ui.OnCallScreen())
- ui.add_screen(_ui.MessageFullScreen())
- # ui.add_screen(_ui.PowerOnScreen())
- ui.add_screen(FactoryModeLocationScreen())
- ui.add_screen(FactoryModeScreen())
- ui.add_screen(FactoryModeAlipayInitScreen())
- ui.add_screen(PopupAlarmScreen())
- ui.add_screen(_ui.LowPowerScreen())
- ui.add_screen(_ui.NewMessageScreen())
- ui.add_screen(NewWechatPopupScreen())
- ui.add_screen(HealthScreen())
- # ui.add_screen(_ui.Setting3Screen())
- print("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()))
-
- 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()))
-
-
- #from ui_WatchFaceScreen import WatchFaceScreen
-
-
- # from usr.test_sms import HRSTART_ProtoCol,getHrTimeManager,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,getBrightnessManager,\
- # getStorageDataManager
- print("init9:{}".format(utime.localtime()))
- #from usr.ui_wechat import WechatScreen,TK_ProtoCol
-
- print("init10:{}".format(utime.localtime()))
-
-
- app = watchApp()
- app.set_ui(ui)
- app.append_manager(mgr.AlarmVolumeLevelManager()) \
- .append_manager(mgr.MsgVolumeLevelManager()) \
- .append_manager(mgr.PhoneVolumeLevelManager()) \
- .append_manager(mgr.DeviceInfoManager()) \
- .append_manager(mgr.BatteryManager()) \
-
- # .append_manager(mgr.StopwatchManager()) \
- # .append_manager(mgr.CountdownManager()) \
-
- app.append_manager(Alipay())
- app.append_manager(ConfigStoreManager())
- app.append_manager(NetManager())
- app.append_manager(LocationManager())
- app.append_manager(AddrBookManager())
- app.append_manager(mgr.MsgManager())
- app.append_manager(MsgdetailManager())
- app.append_manager(mgr.CallLogManager())
- app.append_manager(mgr.getWeatherDataManager())
- app.append_manager(PhoneCallingManager())
- app.append_manager(ClockManager())
- app.append_manager(gethistoryDataManager())
- app.append_manager(getHrTimeManager())
- app.append_manager(getBrightnessManager())
- app.append_manager(getStorageDataManager())
- app.append_manager(getUpLoadDataManager())
- app.append_manager(getVolumSizeManager())
- app.append_manager(getTempTimeManager())
- app.append_manager(getplayAudiodStateManager())
- app.append_manager(getLowBatManager())
- app.append_manager(getBootOffManager())
- app.append_manager(getOldTimeManager())
- app.append_manager(getSosFlagManager())
- app.append_manager(CountdownManager())
-
- print("init21:{}".format(utime.localtime()))
-
- print("init11:{}".format(utime.localtime()))
- pcr = ProtoColResolver()
- pcr.add_support(LK_ProtoCol())
- pcr.add_support(PING_ProtoCol())
- pcr.add_support(KA_ProtoCol())
- pcr.add_support(UD_ProtoCol())
- pcr.add_support(CR_ProtoCol())
- pcr.add_support(FIND_ProtoCol())
- pcr.add_support(POWEROFF_ProtoCol())
- pcr.add_support(PHL_ProtoCol())
- pcr.add_support(TK_ProtoCol())
- pcr.add_support(MESSAGE_ProtoCol())
- pcr.add_support(WT_ProtoCol())
- pcr.add_support(REMIND_ProtoCol())
- pcr.add_support(HRSTART_ProtoCol())
- pcr.add_support(HEART_ProtoCol())
- pcr.add_support(OXYGEN_ProtoCol())
- pcr.add_support(OXYGEN_One_ProtoCol())
- pcr.add_support(TEMP_ProtoCol())
- pcr.add_support(DLT_ProtoCol())
- pcr.add_support(UPLOAD_ProtoCol())
- pcr.add_support(MONITOR_ProtoCol())
- # pcr.add_support(CENTER_ProtoCol())
- pcr.add_support(CENTER_ProtoCol())
- pcr.add_support(bootoff_ProtoCol())
- pcr.add_support(WDSTART_ProtoCol())
- pcr.add_support(LOWBAT_ProtoCol())
- pcr.add_support(sosHome_dial_ProtoCol())
-
- sm = SockManager()
- sm.add_support_resolver(pcr)
- app.append_manager(sm)
- print("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()))
- import atcmd
- resp=bytearray(50)
- atcmd.sendSync('AT+log=52,1\r\n',resp,'',20)
- print("AT+log=52,1:{}".format(resp))
-
-
+import main_init
+main_init.main_init()
\ No newline at end of file
import audio
from machine import I2C
from Gsensor import SC7A20
-from Hsensor import GH3018
+try :
+ from Hsensor import GH3018
+except Exception as e:
+ print("Hsensor none GH3018:{}".format(e))
+#
+try :
+ from Hsensor import HX3918
+except Exception as e:
+ print("Hsensor none HX3918:{}".format(e))
from machine import RTC
import quecgnss
import wifiScan
BATTERY_OCV_TABLE = {
"nix_coy_mnzo2": {
55: {
- 4300: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
20: {
- 4300: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
0: {
- 4300: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
},
self.gsensor.init()
print("DeviceInfoManager:2")
self.gsensor.set_callback(self.gsensor_cb)
- self.hsensor = GH3018()
+ try :
+ self.hsensor = HX3918()
+ except Exception as e:
+ print("Hsensor none HX3918:{}".format(e))
+ try :
+ self.hsensor = GH3018()
+ except Exception as e:
+ print("Hsensor none GH3018:{}".format(e))
+ #
self.hsensor.activate()
self.hsensor.init()
self.hsensor.close()
EventMesh.subscribe(constants.EVENT.SET_CID, self.set_cid)
EventMesh.subscribe(constants.EVENT.GET_IMSI, self.get_imsi)
EventMesh.subscribe(constants.EVENT.GET_PASSWORD, self.get_password)
- EventMesh.subscribe(constants.EVENT.SET_PASSWORD, self.set_password)
- EventMesh.subscribe(constants.EVENT.READ_LOCATION, self.READ_LOCATION)
+ EventMesh.subscribe(constants.EVENT.SET_PASSWORD, self.set_password)
EventMesh.subscribe(constants.EVENT.SET_PING, self.set_ping)
EventMesh.subscribe(constants.EVENT.GET_PING, self.get_ping)
EventMesh.subscribe(constants.EVENT.SET_CONNECT, self.set_connect)
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)))
if self.upload_time != None:
- if math.fabs(time_tmp - self.UD_time) > self.upload_time: #7分钟一次定位
+ if math.fabs(time_tmp - self.UD_time) > self.upload_time: #30分钟一次定位
self.UD_time = time_tmp
if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
- EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count())
temp = Power.getVbatt()
#quecgnss.gnssEnable(0)
- def READ_LOCATION(self, event, msg) :
- #print("READ_LOCATIO",msg)
- EventMesh.publish(constants.PROTOCOL.UD_SEND,msg)
+
def get_device_ope(self, event, msg):
"""
self.start_location_flag = 0
self.location_thread_id = 0
self.location_thread_id = _thread.start_new_thread(self.location_thread, ())
+ self.location_queue = Queue(100)
#quecgnss.init()
#quecgnss.gnssEnable(0)
@staticmethod
EventMesh.subscribe(constants.EVENT.GPSOPEN, self.gps_open)
EventMesh.subscribe(constants.EVENT.GPSCLOSE, self.gps_close)
EventMesh.subscribe(constants.EVENT.START_LOCATION, self.start_location)
+ EventMesh.subscribe(constants.EVENT.START_LOCATION_TEST, self.start_location_test)
EventMesh.subscribe(constants.EVENT.WIFIINFO, self.WIFI_INFO)
EventMesh.subscribe(constants.EVENT.WIFISCANOPEN,self.WIFI_scan_open)
EventMesh.subscribe(constants.EVENT.CLOSE_LOCATION,self.close_location)
def get_location_flag(self, event, msg):
return self.location_flag
def start_location(self, event, msg):
- print("start_location")
+ self.location_queue.put(msg)#测试类型入队
+ print("start_location:{}".format(msg))
self.timer_read_GPS_info.start(1000, 1, self.location_timer)
if( self.location_flag == 1):
return
self.location_timer_count = 0
self.location_flag = 1
#self.gps_open(event, msg)
-
- if msg != None :
- self.location_type = msg
- else :
- self.location_type = 0
+
self.start_location_flag = 1
-
+
+ def start_location_test(self, event, msg):
+ print("start_location_test")
+ self.timer_read_GPS_info.start(1000, 1, self.location_timer)
+ if( self.location_flag == 1):
+ return
+ self.location_timer_count = 0
+ self.location_flag = 1
+ #self.gps_open(event, msg)
+ self.location_type = 1
+ self.start_location_flag = 1
+
def close_location(self, event, msg):
self.location_flag = 0
+ self.location_type = 0
self.gps.power_switch(0)
wifiScan.control(0)
self.timer_read_GPS_info.stop()
#print("wifiScan.asyncStart")
else :
print("WIFI_scan_open:error1")
-
-
-
def gps_open(self, event, msg):
#print("publish:gps_open")
#quecgnss.init()
quecgnss.gnssEnable(1)
self.gps.__gps_nmea_data_clean()
-
-
def gps_close(self, event, msg):
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")
+ date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
+ date = date[2:]
+ GPS_type = "V"
+ latitude = "0.000000,N"
+ longitude = "0.000000,E"
+ speed = "0.00"
+ direction = "0.0"
+ high = "100.0"
+ number = "0"
+ if msg[0] != [] :#有GPS数据
+ GPS_type = "A"
+ # 纬度
+ latitude = msg[0]["latitude"]
+ # 经度
+ longitude = msg[0]["longitude"]
+ # 速度
+ speed = msg[0]["speed"]
+ # 方向
+ direction = "0"
+ if msg[0]["direction"] :
+ direction = msg[0]["direction"]
+ # 高度
+ high = msg[0]["high"]
+ high_tmp = high.split(".")
+ if len(high_tmp) >= 2 :
+ high = "%s"%(high_tmp[0])
+ # 讯号质量:搜索到的卫星数目
+ number = msg[0]["number"]
+ #gsm 信号强度
+ gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
+ # 电池电量百分比
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ battery_caption = str(bat_tmp[1])
+ #步数
+ old_step = 0
+ step = 0
+ step = EventMesh.publish("get_old_step_value")
+ if step != 0:
+ read_data = EventMesh.publish("get_storage_data")
+ b = str("old_step_new") in read_data.keys()
+ if b == True:
+ old_step = read_data["old_step_new"]
+ else:
+ old_step = 0
+ if old_step != step:
+ read_data["old_step"] = step
+ read_data["old_step_new"] = step
+ EventMesh.publish("set_storage_data", read_data)
+ with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
+ ujson.dump(read_data,fd)
+ old_step = step
+ # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
+ #翻转次数
+ turn_count = "0"
+ #终端状态
+ state = "00000000"
+ #基站数据
+ CELL_num = len(msg[2])
+ CELL_data = "1," #时延
+ if msg[2] != []:
+ for CELL in msg[2] :
+ if CELL[0] == 0 :
+ CELL_data += "%X,"%(int(CELL[2])) #MCC
+ CELL_data += str(CELL[3]) +","#MNC
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ else :
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ CELL_data = CELL_data[:(len(CELL_data)-1)]
+ #WIFI数据
+ WIFI_num = 0
+ WIFI_data = ""
+ if msg[1] :
+ WIFI_num = msg[1][0]
+ i = 0
+ for MAC in msg[1][1] :
+ WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
+ i += 1
+ WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
+ WIFI_data = WIFI_data.lower()
+ #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
+ # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
+ #定位数据
+ send_data = "%s,%s,%s"%(date,GPS_type,latitude)
+ send_data += ",%s,%s,%s"%(longitude,speed,direction)
+ send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
+ send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
+ send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
+ send_data += ",%d,%s"%(WIFI_num,WIFI_data)
+ #print("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.publish(TYPE,send_data)
+ else :
+ break
+
+
def location_thread(self):
data = ""
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])
+ self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
#break
if len(match_gsv_data) >= 3:
#print("match_gsv_data[3]:{}".format(match_gsv_data[3]))
#if (self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 10): #超过10秒且卫星个数少于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])
+ self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+
EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
#break
utime.sleep_ms(1000)
utime.sleep_ms(1000)
print("location_thread:ERROR:{}\r\n{}".format(e,Exception))
print("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data))
- EventMesh.publish(constants.EVENT.READ_LOCATION, [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)#关闭定位
-
-
-# class AddrBookManager(Abstract):
-# # 通讯录
-# def post_processor_after_instantiation(self):
-# EventMesh.subscribe("get_addr_book_list", self.get)
-# # 可通过此push_addr_book_list主动推送
-
-# def get(self, event, msg):
-# print("phonebook %s"%(msg))
-# return {
-# "张三": "15692025051",
-# "李四": "15692025051",
-# "崔崔": "15692025051",
-# "鱼鱼": "15692025051",
-# "坤坤": "15692025051",
-# }
-# def set(self, event, msg):
-# print("phonebook %s"%(msg))
class AddrBookManager(Abstract):
# 通讯录
def __init__(self):
if check == True:
with open("/ext/static/storage_file/config.json","r") as fd:
self.read_data = ujson.load(fd)
+ print("config.json:{}".format(self.read_data))
b1 = str("set_new_ip_addr") in self.read_data.keys()
if b1 == True:
self.newip = self.read_data["set_new_ip_addr"]
with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_data,fd)
+ print("config.json:{}".format(self.read_data))
# print("msg:{} self.read_data:{}".format(msg,self.read_data))
number = str(msg[2])
sms.sendPduMsg(number, 'set ok', 'UCS2')
import machine
import _thread
+#服务器选择1,防走丢,2大锤
+server_type = 1
from queue import Queue
def unicode_to_utf8(src):
ref = 0xe08080
# self.server_addr = "8.134.110.49"
# self.server_port = 30346
-
- self.server_addr = "api.xcloudtech.com"
- self.server_port = 9000
- ip_infor = {}
- ip_infor = EventMesh.publish("get_new_ip")
- # print("ip_infor:{} ".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))
+ if server_type == 1:
+ self.server_addr = "api.xcloudtech.com"
+ self.server_port = 9000
+ ip_infor = {}
+ ip_infor = EventMesh.publish("get_new_ip")
+ print("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))
+ elif server_type == 2:
+ self.server_addr = "8.134.110.49"
+ self.server_port = 30346
+ else :
+ self.server_addr = "api.xcloudtech.com"
+ self.server_port = 9000
+ ip_infor = {}
+ ip_infor = EventMesh.publish("get_new_ip")
+ print("ip_infor:{} ".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))
+
_thread.start_new_thread(self.connect, ())
self.socket_send_queue = Queue()
data = data + r
print("TCP recv: data:len:{}".format(len(data)))
- #print("TCP recv: data:{}".format(data))
+ if server_type == 2:
+ print("TCP recv: data:{}".format(data))
if data[-1] != 0x5d and len(data)<20*1024: #']':
continue
self.connect_tmp = 1 #有数据,就认为是连接状态
HEADER = "#@{}@#;"
SEPARATOR = ";"
END = ";" + chr(0x01)
- PID = "SZKW"
- # PID = "qAELPTKmFanR4RHe"
- #md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
-
- # PID = "qAELPTKmFanR4RHe"
- # md5_key = "3JyCjsw4ryXKzjzudayY"
+ #PID = "SZKW"
+ #PID = "qAELPTKmFanR4RHe"
+
def __init__(self):
self.content = None
self.check_sum = None
- self.location_old_data = None
self.password = EventMesh.publish(constants.EVENT.GET_PASSWORD)
self.imei = EventMesh.publish(constants.EVENT.GET_IMEI)
self.cid = EventMesh.publish(constants.EVENT.GET_CID)
self.imsi = EventMesh.publish(constants.EVENT.GET_IMSI)
self.key = EventMesh.publish(constants.EVENT.GET_KEY)
self.HEADER = self.HEADER.format(self.TYPE)
-
- self.md5_key = "19ED5F01235A6B360A09C1800432C31B"
- # self.md5_key = "3JyCjsw4ryXKzjzudayY"
+ if server_type == 1:
+ self.md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ self.PID = "SZKW"
+ elif server_type == 2:
+ self.md5_key = "3JyCjsw4ryXKzjzudayY"
+ self.PID = "qAELPTKmFanR4RHe"
+
# ip_infor = {}
# ip_infor = EventMesh.publish("get_new_ip")
# if ip_infor != None:
EventMesh.publish(constants.PROTOCOL.PING_SEND)
EventMesh.publish(constants.PROTOCOL.KA_SEND)
EventMesh.publish(constants.PROTOCOL.TIME_SEND)
- EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
-
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.WT_SEND) #开始WT定位
class PING_ProtoCol(ProtoCol):
"""获取绑定状态"""
class UD_ProtoCol(ProtoCol):
"""位置信息"""
TYPE = "UD"
+ UD_count = 0#每6次定位获取一次天气数据
def send(self, event, msg):
#"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
#[6f62cfc40fc50173f9a7b21e87be3424IS*861217001020120*00f6*UD,220726,211210,A,22.649529,N,114.119165,E,0.28,137.4,100.0,8,24,63,119,0,00000000,2,1,460,11,30472,125667122,24,30472,218944048,19,4,
# wifi0,34:93:44:01:28:b9,-74,wifi1,34:20:03:96:35:ad,-78,wifi2,ea:b5:7b:e8:56:54,-80,wifi3,c4:49:bb:d4:d9:78,-88]
- date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
- date = date[2:]
- GPS_type = "V"
- latitude = "0.000000,N"
- longitude = "0.000000,E"
- speed = "0.00"
- direction = "0.0"
- high = "100.0"
- number = "0"
- if msg[0] != [] :#有GPS数据
- GPS_type = "A"
- # 纬度
- latitude = msg[0]["latitude"]
- # 经度
- longitude = msg[0]["longitude"]
- # 速度
- speed = msg[0]["speed"]
- # 方向
- direction = "0"
- if msg[0]["direction"] :
- direction = msg[0]["direction"]
- # 高度
- high = msg[0]["high"]
- high_tmp = high.split(".")
- if len(high_tmp) >= 2 :
- high = "%s"%(high_tmp[0])
- # 讯号质量:搜索到的卫星数目
- number = msg[0]["number"]
- #gsm 信号强度
- gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
- # 电池电量百分比
- bat_tmp = EventMesh.publish("screen_get_battery")
- battery_caption = str(bat_tmp[1])
- #步数
- old_step = 0
- step = 0
- step = EventMesh.publish("get_old_step_value")
- if step != 0:
- read_data = EventMesh.publish("get_storage_data")
- b = str("old_step_new") in read_data.keys()
- if b == True:
- old_step = read_data["old_step_new"]
- else:
- old_step = 0
- if old_step != step:
- read_data["old_step"] = step
- read_data["old_step_new"] = step
- EventMesh.publish("set_storage_data", read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
- old_step = step
- # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
- #翻转次数
- turn_count = "0"
- #终端状态
- state = "00000000"
- #基站数据
- CELL_num = len(msg[2])
- CELL_data = "1," #时延
- if msg[2] != []:
- for CELL in msg[2] :
- if CELL[0] == 0 :
- CELL_data += "%X,"%(int(CELL[2])) #MCC
- CELL_data += str(CELL[3]) +","#MNC
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- else :
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- CELL_data = CELL_data[:(len(CELL_data)-1)]
- #WIFI数据
- WIFI_num = 0
- WIFI_data = ""
- if msg[1] :
- WIFI_num = msg[1][0]
- i = 0
- for MAC in msg[1][1] :
- WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
- i += 1
- WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
- WIFI_data = WIFI_data.lower()
- #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
- # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
- send_data = "UD,%s,%s,%s"%(date,GPS_type,latitude)
- send_data += ",%s,%s,%s"%(longitude,speed,direction)
- send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
- send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
- send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
- send_data += ",%d,%s"%(WIFI_num,WIFI_data)
+
+
+ self.UD_count+=1
+ #每6次定位获取一次天气数据
+ if self.UD_count>=6:
+ self.UD_count = 0
+ EventMesh.publish(constants.PROTOCOL.WT_SEND,msg)
+ send_data ="UD,"+msg
send_len = len(send_data)
- wt_data = "%s"%(send_data)
+ #wt_data = "%s"%(send_data)
send_data = self.PID+"*%s*%04X*%s"%(self.imei,send_len,send_data)
MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,send_len,"UD")
+ print("UD:MD5_head_data:{}".format(MD5_head_data))
MD5_SIGN = self.pack_MD5_head(MD5_head_data)
data = "[%s%s]"%(str(MD5_SIGN),send_data)
-
-
- #这个是发送WT位置数据到手机端
- msg_tmp = wt_data.split('UD,')
- msg_tmp = "WT,"+msg_tmp[1]
- data_1_len = len(msg_tmp)
- # print("WT_ProtoCol:msg_tmp:%s"%(msg_tmp))
- MD5_head_data_1 = self.PID+"*%s*%04x*WT"%(self.imei,data_1_len)
- MD5_SIGN_1 = self.pack_MD5_head(MD5_head_data_1)
- send_data_1 = self.PID+"*%s*%04X*%s"%(self.imei,data_1_len,msg_tmp)
- data_1 = "[%s%s]"%(str(MD5_SIGN_1),send_data_1)
- # print("WT_ProtoCol:send:%s"%(data_1))
- EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data_1)
- # 通过socket发送到服务器端
-
+ # wt_data = EventMesh.publish("get_weather_data")
+ # # #如果没有天气数据,则获取天气数据
+ # if wt_data != None or wt_data[0] == None :
+ #
EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
def recv(self, event, msg):
- """
-
- @param event: PING
- @param msg: 接收到的下行数据
- """
+ pass
# print("UD_ProtoCol:recv:%s"%(msg))
class CR_ProtoCol(ProtoCol):
@param msg: 接收到的下行数据
"""
EventMesh.publish(constants.PROTOCOL.CR_SEND)
- EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始ud定位
#print("CR_ProtoCol:recv:%s"%(msg))
class FIND_ProtoCol(ProtoCol):
class WT_ProtoCol(ProtoCol):
"""天气数据"""
TYPE = "WT"
-
+ WT_T = 0
def send(self, event, msg):
# [SZKW*867387060319491*0008*WT]
- send_data = self.PID+"*%s*0002*WT"%(self.imei)
- MD5_SIGN = self.pack_MD5_head(send_data)
- data = "[%s%s]"%(str(MD5_SIGN),send_data)
- # print("WT_ProtoCol:send:%s"%(data))
- # 通过socket发送到服务器端
- EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ # if self.WT_T != 0:
+ # tmp_WT =
+ if(msg != ""):
+ msg_tmp = "WT," + msg
+ data_len = len(msg_tmp)
+ MD5_head_data = self.PID+"*%s*%04X*WT"%(self.imei,data_len)
+ 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))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
def recv(self, event, 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")
- EventMesh.publish(constants.PROTOCOL.WT_SEND)
+
class REMIND_ProtoCol(ProtoCol):
"""闹钟数据"""
style_screen.set_pad_top(0)
style_screen.set_pad_bottom(0)
+style_white_screen = lv.style_t()
+style_white_screen.init()
+style_white_screen.set_radius(0)
+style_white_screen.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_white_screen.set_bg_opa(255)
+style_white_screen.set_border_width(0)
+style_white_screen.set_pad_left(0)
+style_white_screen.set_pad_right(0)
+style_white_screen.set_pad_top(0)
+style_white_screen.set_pad_bottom(0)
+
+style_gray_bg = lv.style_t()
+style_gray_bg.init()
+style_gray_bg.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+style_gray_bg.set_border_width(0)
+style_gray_bg.set_shadow_opa(0)
+style_gray_bg.set_pad_left(0)
+style_gray_bg.set_pad_right(0)
+style_gray_bg.set_pad_top(0)
+style_gray_bg.set_pad_bottom(0)
+
style_bar = lv.style_t()
style_bar.init()
style_bar.set_radius(10)
style_font_youyuan_20_black.set_text_color(lv.color_make(0x00, 0x00, 0x00))
style_font_youyuan_20_black.set_text_font_v2("font_28.bin",28,0)
+#灰色背景黑色字
+style_font_28_black_bg_gray = lv.style_t()
+style_font_28_black_bg_gray.init()
+style_font_28_black_bg_gray.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+style_font_28_black_bg_gray.set_text_font_v2("font_28.bin",28,0)
+style_font_28_black_bg_gray.set_bg_color(lv.color_make(0xe1,0xdb,0xdb))
+
+#黑色
+style_black = lv.style_t()
+style_black.init()
+style_black.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+
style_font_youyuan_20_red = lv.style_t()
style_font_youyuan_20_red.init()
def fun(self,*argc):
EventMesh.publish("system_sleep_rest")#防止黑屏
self.count+=1
- if self.count > 10:
+ if self.count > 2*60:
self.count = 0
self.timer.stop()
- EventMesh.publish("return_prev_screen")
+ #EventMesh.publish("return_prev_screen")
def done_click(self):
EventMesh.publish("return_prev_screen")
style_sms_bg_btn.set_bg_opa(255)
style_sms_bg_btn.set_border_color(lv.color_make(0xff, 0xff, 0xff))
style_sms_bg_btn.set_border_opa(255)
+style_sms_bg_btn.set_border_width(0)
+style_sms_bg_btn.set_pad_left(0)
+style_sms_bg_btn.set_pad_right(0)
+style_sms_bg_btn.set_pad_top(0)
+style_sms_bg_btn.set_pad_bottom(0)
msg_list_screen = None
self.meta = None
self.msg_detail = {}
self.msg_nums = 0
+ self.msg_nums_old = 0
self.sms_detail_list = None
self.sms_detail_list_dict = []
-
+ self.sms_data = [] #最新短信内容
def post_processor_before_initialization(self):
- self.msg_nums = sms.getMsgNums() #获取短信条数
+ pass
+ # self.msg_nums = sms.getMsgNums() #获取短信条数
+ # if self.msg_nums_old != self.msg_nums:
+ # self.sms_data = []
+ # self.msg_nums_old = self.msg_nums
def initialization(self):
global msg_list_screen,msg_top_title,msg_cont_detail,msg_list_t,msg_list_t_done_img,no_msg_text,msg_cont_list_screen
self.msg_nums = sms.getMsgNums()
- # print("self.msg_nums:{} type:{}".format(self.msg_nums,type(sms.getMsgNums())))
+ if self.msg_nums_old != self.msg_nums:
+ self.sms_data = []
+ self.msg_nums_old = self.msg_nums
+
self.btn_create(1)
print("PopupScreen:initialization2")
- def sms_create_list(self,event,msg):
- self.msg_nums = sms.getMsgNums()
- self.btn_create(1)
-
+ # def sms_create_list(self,event,msg):
+ # self.msg_nums = sms.getMsgNums()
+ # self.btn_create(1)
+
+ def sms_deal_phone_number(self,args):
+ data=enumerate(args)
+ data_str1=""
+ data_str2=""
+ data_str3=""
+ for index,value in data:
+ if index % 2 == 0:
+ data_str1=data_str1+value
+ else:
+ data_str2=data_str2+value
+ for i in range(0,len(data_str1)):
+ data_str3=data_str3+data_str2[i]
+ data_str3=data_str3+data_str1[i]
+ return data_str3
def sms_get_message_info(self,index):
"""
:param index :短信索引值
:sub_message_len :此条短信内容长度
"""
- message0= sms.searchPduMsg(index)
- print("message0 {}".format(message0))
- self.message = message0
- sca_num = int(message0[0:2],16)
+ message0=sms.searchPduMsg(index)
+ #print("sms_get_message_info:message0:{}".format(message0))
+ if message0 == -1:
+ return -1
+
+ sca_num = int(message0[0:2],16) - 1
data_len = 2
+ addr_type= message0[data_len:data_len+1*2]
+ data_len = data_len+1*2
+
sca = message0[data_len:data_len+sca_num*2]
+ # 电话号码高低位需要转换
+ sca = self.sms_deal_phone_number(sca)
+
+ # if sca_num % 2 == 1:
+ # print("Get SCA phone {}".format(sca[:-1]))
+ # else:
+ # print("Get SCA phone {}".format(sca))
+
data_len = data_len+sca_num*2
+
pdu_tye = int(message0[data_len:data_len+1*2],16)
-
data_len = data_len+1*2
- mr = message0[data_len:data_len+1*2]
-
+
+ oa_num = int(message0[data_len:data_len+1*2],16)
data_len = data_len+1*2
- oa = message0[data_len:data_len+sca_num*2]
-
- data_len = data_len+sca_num*2
+ oa_addr_type = message0[data_len:data_len+1*2]
+ data_len = data_len+1*2
+
+ if oa_num % 2 == 1:
+ oa_num_t = int((oa_num + 1)/2)
+ else:
+ oa_num_t = int((oa_num )/2)
+
+ oa = message0[data_len:data_len+oa_num_t*2]
+ # 电话号码高低位需要转换
+ oa = self.sms_deal_phone_number(oa)
+
+ # if oa_num % 2 == 1:
+ # print("Get OA phone {}".format(oa[:-1]))
+ # else:
+ # print("get OA phone {}".format(oa))
+
+ data_len = data_len+oa_num_t*2
pid = message0[data_len:data_len+1*2]
data_len = data_len+1*2
dcs = message0[data_len:data_len+1*2]
-
data_len = data_len+1*2
- scts = message0[data_len:data_len+7*2]
+ scts = message0[data_len:data_len+7*2]
data_len = data_len+7*2
sub_message_len = int(message0[data_len:data_len+1*2],16)
data_len = data_len+1*2
sub_message_head = message0[data_len:data_len+6*2]
data_len = data_len+6*2
+
+ # 或短信用户数据
sub_message_data = message0[data_len:data_len+sub_message_len*2]
- print("sub_message_head {}".format(sub_message_head))
- message_ref = int(sub_message_head[6:8],16)
- print("sub_message_head[0:8] {}".format(sub_message_head[0:8]))
- message_total_num = int(sub_message_head[8:10])
- message_seq = int(sub_message_head[10:12],16)
- return message_ref,message_total_num,message_seq,pdu_tye,sub_message_len,sub_message_data
+
+ #长短信
+ if ((pdu_tye & 0x40 ) >> 6) == 1:
+ #长短信,处理长短信用户报文头
+ message_ref = int(sub_message_head[6:8],16)
+ message_total_num = int(sub_message_head[8:10],16)
+ message_seq = int(sub_message_head[10:12],16)
+ return [message_ref,message_total_num,message_seq,pdu_tye,sub_message_len,message0]
+ else:
+ # 短短信
+ return [0,1,1,pdu_tye,sub_message_len,message0]
def btn_create(self,msg):
EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_screen,"data":msg})
print("self.msg_nums:{}".format(self.msg_nums))
if self.msg_nums > 0 :
- msg_list_t_done_img.add_flag(lv.obj.FLAG.HIDDEN)
- no_msg_text.add_flag(lv.obj.FLAG.HIDDEN)
- self.sms_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
- # self.sms_detail_list.delete()#先删除一次控件
- # self.sms_detail_list = lv.obj(msg_cont_list_screen)
- # self.sms_detail_list.set_pos(0, 0)
- # self.sms_detail_list.set_size(230, 271)
- # self.sms_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
- # self.sms_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
- if self.msg_nums > MSG_MAX:
- j = self.msg_nums-MSG_MAX
+
+ #隐藏短信控件,加提示信息
+ if msg_cont_list_screen != None:
+ msg_list_t_done_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.set_text("正在加载···")
+ if self.sms_detail_list != None:
+ self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
+ SMS_lis={}
+ SMS_lis_count = 0
+ #self.sms_data = [] #短信数组
+ if self.sms_data == [] :
+ for i in range(self.msg_nums):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ message=self.sms_get_message_info(self.msg_nums-i-1)
+ if message == -1:
+ break
+ #print("self.msg_nums:{} message:{} {} {}".format(self.msg_nums-i-1,message[0],message[1],message[2]))
+ #message:[253, 3, 1, 100, 140, '751F4EA776EE524D6D4']
+ if message[1]>1 :#长短信
+ if message[0] in SMS_lis:#存在列表
+ SMS_lis[message[0]].append(message)
+
+ else :#列表是新的
+ SMS_lis[message[0]] = [message]#新增列表
+ #print("SMS_lis:{}".format(SMS_lis))
+ #SMS_lis[message[0]].append(message)#新增列表数据
+ if len(SMS_lis[message[0]]) == message[1]:#存满一条
+ SMS_lis_tmp = SMS_lis[message[0]]
+ data = ""
+ message_pdu = []
+ for k in range(len(SMS_lis_tmp)):
+ for j in range(len(SMS_lis_tmp)): #排序
+ if SMS_lis_tmp[j][2] == k+1:
+ message_pdu = sms.decodePdu(SMS_lis_tmp[j][5],20)
+ if(message_pdu!=-1):
+ data += message_pdu[1]
+ break
+ #print("data:{}".format(data))
+ data_tmp = []
+ data_tmp.append(message_pdu[0])
+ data_tmp.append(data)
+ self.sms_data.append(data_tmp)
+ SMS_lis_count += 1
+ if(SMS_lis_count >= MSG_MAX):
+ break
+ else :
+ SMS_lis_count += 1
+ message_pdu = sms.decodePdu(message[5],20)
+ data = message_pdu[1]
+ data_tmp = []
+ data_tmp.append(message_pdu[0])
+ data_tmp.append(data)
+ self.sms_data.append(data_tmp)
+ print("data:{}".format(data))
+ if(SMS_lis_count >= MSG_MAX):
+ break
+ MSG_nums = len (self.sms_data)
for i in range(MSG_MAX):
- # if count > (MSG_MAX-1):#j = 12 -5 7 6 5 4 3 2 1
- # break
- if i >= self.msg_nums :#7
+ if i >= MSG_nums :
self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
continue
- # tmp_data = list(self.sms_get_message_info(j))
- # print("Get tmp_data 0 {}".format(tmp_data))
-
-
- tmp = sms.searchTextMsg(j)
+ tmp = self.sms_data[i]
if tmp != -1:
#msg_btn = lv.btn(self.sms_detail_list)
self.sms_detail_list_dict[i]["msg_btn"].set_size(230,65)
detail1 = tmp[1]
#_btn_label4 = lv.label(msg_btn)
self.sms_detail_list_dict[i]["_btn_label4"].set_pos(0, 34)
- self.sms_detail_list_dict[i]["_btn_label4"].set_size(180, 28)
+ self.sms_detail_list_dict[i]["_btn_label4"].set_size(230, 28)
self.sms_detail_list_dict[i]["_btn_label4"].set_text(detail1)
self.sms_detail_list_dict[i]["_btn_label4"].set_long_mode(lv.label.LONG.DOT)
self.sms_detail_list_dict[i]["_btn_label4"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
title1 = tmp[0]
#_btn_label5 = lv.label(msg_btn)
self.sms_detail_list_dict[i]["_btn_label5"].set_pos(0, 5)
- self.sms_detail_list_dict[i]["_btn_label5"].set_size(180, 25)
+ self.sms_detail_list_dict[i]["_btn_label5"].set_size(230, 28)
self.sms_detail_list_dict[i]["_btn_label5"].set_text(title1)
self.sms_detail_list_dict[i]["_btn_label5"].set_long_mode(lv.label.LONG.DOT)
self.sms_detail_list_dict[i]["_btn_label5"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
self.sms_detail_list_dict[i]["msg_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
#if msg == 1:
- self.sms_detail_list_dict[i]["msg_btn"].scroll_to_view(lv.ANIM.OFF)
+ #self.sms_detail_list_dict[i]["msg_btn"].scroll_to_view(lv.ANIM.OFF)
count = count + 1
else :
self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
- j = j + 1
-
-
+ #显示控件
+ if msg_list_t_done_img != None:
+ msg_list_t_done_img.add_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.add_flag(lv.obj.FLAG.HIDDEN)
+ self.sms_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
else:
if msg_cont_list_screen != None:
msg_list_t_done_img.clear_flag(lv.obj.FLAG.HIDDEN)
no_msg_text.clear_flag(lv.obj.FLAG.HIDDEN)
no_msg_text.set_text("暂无信息")
- self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
+ if self.sms_detail_list != None:
+ self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
def sms_cb(self,e):
msg_detail_screen = None
msg_detail_title = None
msg_detail_cont = None
+msg_detail_cont_obj = None
class MsgDetailScreen(Screen):
NAME = "msg_detail"
def initialization(self):
- global msg_detail_screen,msg_detail_title,msg_detail_cont
+ global msg_detail_screen,msg_detail_title,msg_detail_cont,msg_detail_cont_obj
if msg_detail_screen == None:
msg_detail_screen = lv.obj()
print("msg_detail_screen")
- msg_detail_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ msg_detail_screen.add_style(style_white_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
msg_detail_title = lv.label(msg_detail_screen)
msg_detail_title.set_pos(0, 10)
- msg_detail_title.set_size(240, 40)
+ msg_detail_title.set_size(240, 35)
msg_detail_title.set_long_mode(lv.label.LONG.WRAP)
msg_detail_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
- msg_detail_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
- msg_detail_cont = lv.label(msg_detail_screen)
- msg_detail_cont.set_pos(0, 50)
- msg_detail_cont.set_size(240, 270)
+ msg_detail_title.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ msg_detail_cont_obj = lv.obj(msg_detail_screen)
+ msg_detail_cont_obj.set_pos(0, 45)
+ msg_detail_cont_obj.set_size(240, 270)
+ msg_detail_cont_obj.add_style(style_white_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ msg_detail_cont = lv.label(msg_detail_cont_obj)
+ msg_detail_cont.set_pos(0, 5)
+ msg_detail_cont.set_size(240, lv.SIZE.CONTENT)
msg_detail_cont.set_long_mode(lv.label.LONG.WRAP)
msg_detail_cont.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
- msg_detail_cont.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ msg_detail_cont.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
self.meta = msg_detail_screen
#获取字符串
self.name = EventMesh.publish("get_msg_name")
self.content = EventMesh.publish("get_msg_content")
msg_detail_title.set_text(self.name)
+ # tmp_y=(len(self.content)//15+1)*28
+ # msg_detail_cont.set_size(240, tmp_y)
msg_detail_cont.set_text(self.content)
def done_return(self):
no_connect_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
self.meta = weather_screen
+ #EventMesh.publish(constants.PROTOCOL.WT_SEND)
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.WT_SEND) #开始WT定位
def post_processor_after_initialization(self):
EventMesh.publish("updata_weather_show")
#define CONFIG_LVGL_JPG_DECODE 1
#define CONFIG_LVGL_PNG_DECODE 1
#define CONFIG_LVGL_IMGBTN 1
-#define CONFIG_GH301x 1
-//#define CONFIG_HX3918 1
+//#define CONFIG_GH301x 1
+#define CONFIG_HX3918 1
#define CONFIG_MBEDTLS 1
#define CONFIG_SC7A20 1
#define CONFIG_LVGL_WIN 1
CONFIG_LCD=y
# CONFIG_UART_SLIP is not set
# CONFIG_POC is not set
-CONFIG_GH301x=y
-#CONFIG_HX3918=y
+#CONFIG_GH301x=y
+CONFIG_HX3918=y
CONFIG_SC7A20=y