123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- #include "includes.h"
- //居中显示信息
- void FunShowMsg(char *info)
- {
- int x,y;
- SlwTrace(INF, info,1);
- x=(LCD_WIDTH-strlen(info)*8)/2;
- y=LCD_HEIGHT/2;
- GuiClearArea(0,y,LCD_WIDTH, 16);
- GuiShowStr(x,y,info,1);
- }
- //配置编码器菜单
- unsigned char tempCodetype;
- void CodeTypeUpdateShow(void)
- {
- char info[20];
-
- switch(tempCodetype){
- case 0:sprintf(info, "EVRC_HALF");break;
- case 1:sprintf(info, "AMRNB-122");break;
- case 2:sprintf(info, "EVRC_FULL");break;
- default:return;
- }
-
- FunShowMsg(info);
- }
- void SetCodeTypeShow(int update)
- {
- static unsigned short susCt=0;
- int x=4;//4
- int i;
- if(update==1){
- susCt=0;
- GuiClearAll();
- ShowCaption("编码器设置",1);//0
- GuiDrawHLine(0,159,20,1);
- GuiDrawHLine(0,159,104,1);
- if(modemInitReady==0){
- ShowMessageBox("模块暂未启动");
- OsDelayTime(100);
- UISetNextStatus(UIS_MENU_SYS_SET);
- }else{
- tempCodetype=sutPocStatus.codeType;
- CodeTypeUpdateShow();
- }
- }
- if(susCt==0)GuiShowStr(0,110,"[上]选择 [下]选择 ",0x01);
- else if(susCt==200) GuiShowStr(0,110,"[M]保存 [EXIT]退出",0x01);
- if(++susCt>=400)susCt=0;
- }
- void SetCodeTypeResponse(void)
- {
- char info[30];
- switch(g_ulKeyValue){
- case KEY_PANEL_UP:
- if(tempCodetype==0) tempCodetype=2;
- else tempCodetype--;
- CodeTypeUpdateShow();
- break;
- case KEY_PANEL_DOWN:
- if(tempCodetype==2) tempCodetype=0;
- else tempCodetype++;
- CodeTypeUpdateShow();
- break;
- case KEY_PANEL_MENU:
- if(tempCodetype != sutPocStatus.codeType){
- sutPocStatus.codeType=tempCodetype;
- sprintf(info, "AT+POC=40000001%02x\r\n", tempCodetype);
- ModemSendAT(info);
- SlwTrace(INF, "Update codetype",1);
- }
- UISetNextStatus(UIS_STANDBY);
- break;
- case KEY_PANEL_EXIT:
- UISetNextStatus(UIS_MENU_SYS_SET);
- break;
- }
- }
- //对讲版本空中升级API
- int getNewVersion;
- unsigned char fotaPocStatus;
- unsigned int fotaTick;
- void SetUpIntercomVerShow(int update)
- {
- char info[40];
- if(update){
- GuiClearAll();
- ShowCaption("升级对讲版本",1);//
- GuiDrawHLine(0,159,20,1);
- FunShowMsg("正在检测版本");
- GuiDrawHLine(0,159,104,1);
- GuiShowStr(0,110,"[M]升级 [EXIT]退出",0x01);
- getNewVersion=-1;
- fotaPocStatus=0;
- ModemSendAT("AT+FOTA?\r\n");//对应用在模块接收消息中添加获取版本代码
- fotaTick=os_time_get()+200;
- GuiShowStr(0,110,"[M]确定 [EXIT]退出",0x01);
- }
- switch(fotaPocStatus){
- case 0://获取版本信息
- if(os_time_get()<fotaTick){
- if(getNewVersion ==0){//没有更新版本
- fotaPocStatus=1;
- FunShowMsg("没有可更新版本");
- fotaTick=os_time_get()+150;
- }else if(getNewVersion>0){//有可更新版本
- //询问是否更新
- sprintf(info, "更新到V%d ?",getNewVersion);
- FunShowMsg(info);
- fotaPocStatus=2;
- }
- }else{//超时未检测到查询版本响应
- fotaPocStatus=1;
- FunShowMsg("检测超时");
- fotaTick=os_time_get()+150;
- }
- break;
- case 1:
- if(os_time_get()>fotaTick){//退出显示信息完毕
- UISetNextStatus(UIS_STANDBY);
- }
- break;
- }
- }
- void SetUpIntercomVerResponse(void)
- {
- switch(fotaPocStatus){
- case 2://等待用户确定
- if(KEY_PANEL_MENU==g_ulKeyValue){
- //确定
- fotaPocStatus=3;
- ModemSendAT("AT+FOTA=1\r\n");
- }else if(KEY_PANEL_EXIT==g_ulKeyValue){
- UISetNextStatus(UIS_MENU_SYS_SET);
- }
- break;
- }
- }
- void FotaStatusProcess(char *pMsg)
- {
- char info[30];
- switch(pMsg[0]){
- case '1'://1,0 1,19070702 表示查询POC版本响应
- getNewVersion=atoi(pMsg+2);//获取版本结果
- break;
- case '2'://表示开始执行FOTA升级操作
- FunShowMsg("正在升级...");
- break;
- case '3'://表示获取文件成功,正在安装
- FunShowMsg("正在安装...");
- break;
- case '4'://表示安装完成,正在重启模块
- FunShowMsg("正在重启...");
- sutPocStatus.modemRstFlag=1;
- fotaPocStatus=1;
- fotaTick=os_time_get()+150;
- break;
- case '0'://退出FOTA升级,原因可能是因为网络不稳定或者文件获取失败
- FunShowMsg("失败退出");
- fotaPocStatus=1;
- fotaTick=os_time_get()+150;
- break;
- }
- }
- //开机初始化时获取当前编码器API
- void ModemGetPocCodeType(void)
- {
- char bufTemp[40];
- short t,i,len,j;
- SUT_MODEM_AT_MSG *pMsg=&sutAtmPro;
- if(hgs_poc_type != POC_OWN) return;
- for(i=0;i<5;i++)
- {
- t=50;
- ModemSendAT("AT+POC=40000000\r\n");
- while(t--){
- if((pMsg->MsgLen = MsgQueueAccept(pMsg->MsgData,sizeof(pMsg->MsgData)))){
- if(0==ModemStrCmp((char *)pMsg->MsgData,"+POC:400000000")){//"+POC:400000000x"
- if(pMsg->MsgData[14]=='0') sutPocStatus.codeType=0;
- else sutPocStatus.codeType=1;
- break;
- }
- }else
- os_dly_wait(1);
- }
- }
- snprintf(bufTemp, sizeof(bufTemp),"\r\nGet codetype:%d", sutPocStatus.codeType);
- SlwTrace(INF, bufTemp, 1);
- }
- void ModemOwnPocSet(void)
- {
- if(hgs_poc_type != POC_OWN) return;
- ModemSendAT("AT+POC=3000000100\r\n");//GBK
- os_dly_wait(2);
- // ModemSendAT("AT+POC=030000\r\n");//启动登陆,POC默认打开的
- // os_dly_wait(2);
- }
- unsigned int pwrSaveTick;
- unsigned char sendEnableNow=0;
- void enableDataSend(void)
- {
- //此刻可以发GPS数据啦,我们让接下来2秒内可以发心跳或GPS位置包,我们只限制这两个就好了
- pwrSaveTick=os_time_get()+200;
- sendEnableNow=1;
- SlwTrace(INF, "Send enable",1);
- }
- char isSendDataEnable(void)
- {
- if(hgs_poc_type == POC_XIAN) return 1;//西安POC的话,就一直返回yes,不存在低功耗操作
- if(newPara.pwrMode == 1) return 1;//常规模式就一直返回yes
- if(sendEnableNow==0) return 0;
- else return 1;
- }
- void powerSaveHandle(void)
- {
- if(sendEnableNow==0) return;
- if(os_time_get() < pwrSaveTick) return;
- sendEnableNow=0;
- SlwTrace(INF, "Send disable",1);
- }
|