newFun.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. #include "includes.h"
  2. //居中显示信息
  3. void FunShowMsg(char *info)
  4. {
  5. int x,y;
  6. SlwTrace(INF, info,1);
  7. x=(LCD_WIDTH-strlen(info)*8)/2;
  8. y=LCD_HEIGHT/2;
  9. GuiClearArea(0,y,LCD_WIDTH, 16);
  10. GuiShowStr(x,y,info,1);
  11. }
  12. //配置编码器菜单
  13. unsigned char tempCodetype;
  14. void CodeTypeUpdateShow(void)
  15. {
  16. char info[20];
  17. switch(tempCodetype){
  18. case 0:sprintf(info, "EVRC_HALF");break;
  19. case 1:sprintf(info, "AMRNB-122");break;
  20. case 2:sprintf(info, "EVRC_FULL");break;
  21. default:return;
  22. }
  23. FunShowMsg(info);
  24. }
  25. void SetCodeTypeShow(int update)
  26. {
  27. static unsigned short susCt=0;
  28. int x=4;//4
  29. int i;
  30. if(update==1){
  31. susCt=0;
  32. GuiClearAll();
  33. ShowCaption("编码器设置",1);//0
  34. GuiDrawHLine(0,159,20,1);
  35. GuiDrawHLine(0,159,104,1);
  36. if(modemInitReady==0){
  37. ShowMessageBox("模块暂未启动");
  38. OsDelayTime(100);
  39. UISetNextStatus(UIS_MENU_SYS_SET);
  40. }else{
  41. tempCodetype=sutPocStatus.codeType;
  42. CodeTypeUpdateShow();
  43. }
  44. }
  45. if(susCt==0)GuiShowStr(0,110,"[上]选择 [下]选择 ",0x01);
  46. else if(susCt==200) GuiShowStr(0,110,"[M]保存 [EXIT]退出",0x01);
  47. if(++susCt>=400)susCt=0;
  48. }
  49. void SetCodeTypeResponse(void)
  50. {
  51. char info[30];
  52. switch(g_ulKeyValue){
  53. case KEY_PANEL_UP:
  54. if(tempCodetype==0) tempCodetype=2;
  55. else tempCodetype--;
  56. CodeTypeUpdateShow();
  57. break;
  58. case KEY_PANEL_DOWN:
  59. if(tempCodetype==2) tempCodetype=0;
  60. else tempCodetype++;
  61. CodeTypeUpdateShow();
  62. break;
  63. case KEY_PANEL_MENU:
  64. if(tempCodetype != sutPocStatus.codeType){
  65. sutPocStatus.codeType=tempCodetype;
  66. sprintf(info, "AT+POC=40000001%02x\r\n", tempCodetype);
  67. ModemSendAT(info);
  68. SlwTrace(INF, "Update codetype",1);
  69. }
  70. UISetNextStatus(UIS_STANDBY);
  71. break;
  72. case KEY_PANEL_EXIT:
  73. UISetNextStatus(UIS_MENU_SYS_SET);
  74. break;
  75. }
  76. }
  77. //对讲版本空中升级API
  78. int getNewVersion;
  79. unsigned char fotaPocStatus;
  80. unsigned int fotaTick;
  81. void SetUpIntercomVerShow(int update)
  82. {
  83. char info[40];
  84. if(update){
  85. GuiClearAll();
  86. ShowCaption("升级对讲版本",1);//
  87. GuiDrawHLine(0,159,20,1);
  88. FunShowMsg("正在检测版本");
  89. GuiDrawHLine(0,159,104,1);
  90. GuiShowStr(0,110,"[M]升级 [EXIT]退出",0x01);
  91. getNewVersion=-1;
  92. fotaPocStatus=0;
  93. ModemSendAT("AT+FOTA?\r\n");//对应用在模块接收消息中添加获取版本代码
  94. fotaTick=os_time_get()+200;
  95. GuiShowStr(0,110,"[M]确定 [EXIT]退出",0x01);
  96. }
  97. switch(fotaPocStatus){
  98. case 0://获取版本信息
  99. if(os_time_get()<fotaTick){
  100. if(getNewVersion ==0){//没有更新版本
  101. fotaPocStatus=1;
  102. FunShowMsg("没有可更新版本");
  103. fotaTick=os_time_get()+150;
  104. }else if(getNewVersion>0){//有可更新版本
  105. //询问是否更新
  106. sprintf(info, "更新到V%d ?",getNewVersion);
  107. FunShowMsg(info);
  108. fotaPocStatus=2;
  109. }
  110. }else{//超时未检测到查询版本响应
  111. fotaPocStatus=1;
  112. FunShowMsg("检测超时");
  113. fotaTick=os_time_get()+150;
  114. }
  115. break;
  116. case 1:
  117. if(os_time_get()>fotaTick){//退出显示信息完毕
  118. UISetNextStatus(UIS_STANDBY);
  119. }
  120. break;
  121. }
  122. }
  123. void SetUpIntercomVerResponse(void)
  124. {
  125. switch(fotaPocStatus){
  126. case 2://等待用户确定
  127. if(KEY_PANEL_MENU==g_ulKeyValue){
  128. //确定
  129. fotaPocStatus=3;
  130. ModemSendAT("AT+FOTA=1\r\n");
  131. }else if(KEY_PANEL_EXIT==g_ulKeyValue){
  132. UISetNextStatus(UIS_MENU_SYS_SET);
  133. }
  134. break;
  135. }
  136. }
  137. void FotaStatusProcess(char *pMsg)
  138. {
  139. char info[30];
  140. switch(pMsg[0]){
  141. case '1'://1,0 1,19070702 表示查询POC版本响应
  142. getNewVersion=atoi(pMsg+2);//获取版本结果
  143. break;
  144. case '2'://表示开始执行FOTA升级操作
  145. FunShowMsg("正在升级...");
  146. break;
  147. case '3'://表示获取文件成功,正在安装
  148. FunShowMsg("正在安装...");
  149. break;
  150. case '4'://表示安装完成,正在重启模块
  151. FunShowMsg("正在重启...");
  152. sutPocStatus.modemRstFlag=1;
  153. fotaPocStatus=1;
  154. fotaTick=os_time_get()+150;
  155. break;
  156. case '0'://退出FOTA升级,原因可能是因为网络不稳定或者文件获取失败
  157. FunShowMsg("失败退出");
  158. fotaPocStatus=1;
  159. fotaTick=os_time_get()+150;
  160. break;
  161. }
  162. }
  163. //开机初始化时获取当前编码器API
  164. void ModemGetPocCodeType(void)
  165. {
  166. char bufTemp[40];
  167. short t,i,len,j;
  168. SUT_MODEM_AT_MSG *pMsg=&sutAtmPro;
  169. if(hgs_poc_type != POC_OWN) return;
  170. for(i=0;i<5;i++)
  171. {
  172. t=50;
  173. ModemSendAT("AT+POC=40000000\r\n");
  174. while(t--){
  175. if((pMsg->MsgLen = MsgQueueAccept(pMsg->MsgData,sizeof(pMsg->MsgData)))){
  176. if(0==ModemStrCmp((char *)pMsg->MsgData,"+POC:400000000")){//"+POC:400000000x"
  177. if(pMsg->MsgData[14]=='0') sutPocStatus.codeType=0;
  178. else sutPocStatus.codeType=1;
  179. break;
  180. }
  181. }else
  182. os_dly_wait(1);
  183. }
  184. }
  185. snprintf(bufTemp, sizeof(bufTemp),"\r\nGet codetype:%d", sutPocStatus.codeType);
  186. SlwTrace(INF, bufTemp, 1);
  187. }
  188. void ModemOwnPocSet(void)
  189. {
  190. if(hgs_poc_type != POC_OWN) return;
  191. ModemSendAT("AT+POC=3000000100\r\n");//GBK
  192. os_dly_wait(2);
  193. // ModemSendAT("AT+POC=030000\r\n");//启动登陆,POC默认打开的
  194. // os_dly_wait(2);
  195. }
  196. unsigned int pwrSaveTick;
  197. unsigned char sendEnableNow=0;
  198. void enableDataSend(void)
  199. {
  200. //此刻可以发GPS数据啦,我们让接下来2秒内可以发心跳或GPS位置包,我们只限制这两个就好了
  201. pwrSaveTick=os_time_get()+200;
  202. sendEnableNow=1;
  203. SlwTrace(INF, "Send enable",1);
  204. }
  205. char isSendDataEnable(void)
  206. {
  207. if(hgs_poc_type == POC_XIAN) return 1;//西安POC的话,就一直返回yes,不存在低功耗操作
  208. if(newPara.pwrMode == 1) return 1;//常规模式就一直返回yes
  209. if(sendEnableNow==0) return 0;
  210. else return 1;
  211. }
  212. void powerSaveHandle(void)
  213. {
  214. if(sendEnableNow==0) return;
  215. if(os_time_get() < pwrSaveTick) return;
  216. sendEnableNow=0;
  217. SlwTrace(INF, "Send disable",1);
  218. }