SetSystemPara.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. #include "includes.h"
  2. typedef enum{
  3. PMODE_DEFAULT_LOW,
  4. PMODE_SUPER_LOW,
  5. PMODE_NORMAL
  6. }PWR_ENUMDEF;
  7. unsigned short LcdOnTimeCt;
  8. unsigned int g_uiGpsStat = 1;
  9. SUT_MENU sutMenuSysSetup;
  10. unsigned char Net_temp_flag;
  11. //超长功耗
  12. #define MODE_LONG_LOW_PWR_NONE_4G 5
  13. #define MODE_LONG_LOW_PWR_IS_4G 55
  14. //默认为低功耗模式
  15. #define MODE_LOW_PWR_NONE_4G 5
  16. #define MODE_LOW_PWR_IS_4G 25
  17. //使用常规非低功耗模式
  18. #define MODE_NORMAL__NONE_4G 5
  19. #define MODE_NORMAL__IS_4G 5
  20. //终端放弃设置模式,由服务器决定使用什么情况
  21. #define MODE_AUTO____NONE_4G 0
  22. #define MODE_AUTO____IS_4G 0
  23. static const char*g_ausNetOut[]={"Auto"," 2G "," 3G "," 4G "};
  24. void ModemSetPwrMode(unsigned char mode)
  25. {
  26. char info[30];
  27. unsigned char seg1,seg2;
  28. switch(mode){
  29. case PMODE_DEFAULT_LOW: seg1=MODE_LOW_PWR_NONE_4G;seg2=MODE_LOW_PWR_IS_4G;break;//默认为低功耗模式
  30. case PMODE_SUPER_LOW: seg1=MODE_LONG_LOW_PWR_NONE_4G;seg2=MODE_LONG_LOW_PWR_IS_4G;break;//超长功耗
  31. case PMODE_NORMAL: seg1=MODE_NORMAL__NONE_4G;seg2=MODE_NORMAL__IS_4G;break;//使用常规非低功耗模式
  32. default:return;
  33. }
  34. snprintf(info, sizeof(info), "AT+UDP=%d,%d\r\n",seg1,seg2);
  35. ModemSendAt(info);
  36. SlwTrace(INF, info,0);
  37. }
  38. void GetPwrMode(char *msg)
  39. {//0,5,30
  40. //1,30,30
  41. int seg1,seg2;
  42. short i;
  43. char buf[15];
  44. //if(msg[0]=='0') return;
  45. for(i=2;i<strlen(msg);i++){
  46. if(msg[i]==','){
  47. seg1=atoi(msg+2);
  48. seg2=atoi(msg+i+1);
  49. if(seg1==MODE_LOW_PWR_NONE_4G && seg2==MODE_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_DEFAULT_LOW){
  50. goto SAVE_PWR_MODE;
  51. }else if(seg1==MODE_LONG_LOW_PWR_NONE_4G && seg2==MODE_LONG_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_SUPER_LOW){
  52. goto SAVE_PWR_MODE;
  53. }else if(seg1==MODE_NORMAL__NONE_4G && seg2==MODE_NORMAL__IS_4G && newPara.pwrMode != PMODE_NORMAL){
  54. goto SAVE_PWR_MODE;
  55. }else if(seg2!=MODE_LOW_PWR_IS_4G&&seg2!=MODE_LONG_LOW_PWR_IS_4G&& seg2!=MODE_NORMAL__IS_4G){
  56. //Seg2 3个模式都不满足切换为常规模式
  57. seg1=MODE_NORMAL__NONE_4G;
  58. seg2=MODE_NORMAL__IS_4G;
  59. newPara.pwrMode = PMODE_NORMAL;
  60. goto SAVE_PWR_MODE;
  61. }
  62. }
  63. }
  64. return;
  65. SAVE_PWR_MODE:
  66. // snprintf(buf, sizeof(buf), "AT+UDP=%d,%d\r\n",seg1,seg2);
  67. // ModemSendAt(buf);
  68. // SlwTrace(INF,buf,1);
  69. ModemSetPwrMode(newPara.pwrMode);
  70. ModifyConfigureFile(0);
  71. }
  72. /*****************************************************
  73. 深圳北纬22.33 东经114.07
  74. 经过试验数据比较准确,但是东西南北不知道
  75. ******************************************************/
  76. void GetCoordinates(unsigned char type)
  77. {
  78. //type 0 UI时调用
  79. // 1 上传时调用
  80. char buf[30];
  81. char buf1[8];
  82. char buf2[4]={0};
  83. char temp[3];
  84. char temp1[3];
  85. char temp2[5];
  86. char temp3[5];
  87. int i,num,num1,w,j;
  88. double Jnum1,Jnum2,Jnum3;//有小数位 8位有效
  89. double Wnum1,Wnum2,Wnum3;//有小数位 8位有效
  90. unsigned char laTemp[4],loTemp[4];
  91. laTemp[0] = (sutGpsInfo.latitue>>24);
  92. laTemp[1] = (sutGpsInfo.latitue>>16);
  93. laTemp[2] = (sutGpsInfo.latitue>>8);
  94. laTemp[3] = (sutGpsInfo.latitue);
  95. loTemp[0] = (sutGpsInfo.longitue>>24);
  96. loTemp[1] = (sutGpsInfo.longitue>>16);
  97. loTemp[2] = (sutGpsInfo.longitue>>8);
  98. loTemp[3] = (sutGpsInfo.longitue);
  99. AscStrTurnHexStr((char *)loTemp,buf1);
  100. memset(temp, 0, sizeof(temp));
  101. for(i=0;i<3;i++) temp[i]=buf1[i];
  102. j=atoi(temp);
  103. memset(temp2, 0, sizeof(temp2));
  104. for(i=0;i<6;i++) temp2[i]=buf1[i+3];
  105. num=atoi(temp2);
  106. Jnum1=num/1000;
  107. Jnum1 /=60;
  108. Jnum2 = (num%1000)*60;
  109. Jnum2 /=3600000;
  110. Jnum3=Jnum1+Jnum2;
  111. sutGpsInfo.testJD = j*1000000+Jnum3*1000000;//上传时使用
  112. AscStrTurnHexStr((char *)laTemp,buf2);
  113. for(i=0;i<3;i++) temp1[i]=buf2[i];
  114. w=atoi(temp1);
  115. for(i=0;i<6;i++) temp3[i]=buf2[i+3];
  116. num1=atoi(temp3);
  117. Wnum1=num1/1000;
  118. Wnum1 /=60;
  119. Wnum2 = (num1%1000)*60;
  120. Wnum2 /=3600000;
  121. Wnum3=Wnum1+Wnum2;
  122. sutGpsInfo.testWD = w*1000000+Wnum3*1000000;
  123. if(type == 0){//UI时要显示
  124. snprintf(buf, sizeof(buf)," 纬度 %s: %.3d.%05d","S",w,(unsigned int)(Wnum3*100000));
  125. GuiShowStr(0,STATUS_ITEM_HEIGH,buf,0x01,0);
  126. snprintf(buf, sizeof(buf)," 经度 %s: %d.%05d","W",j,(unsigned int)(Jnum3*100000));
  127. GuiShowStr(0,STATUS_ITEM_HEIGH+16,buf,0x01,0);
  128. }
  129. }
  130. unsigned char validApnNum;
  131. char *APNNAME[APN_NUM+1]=
  132. {
  133. "APN1",
  134. "APN2",
  135. "APN3",
  136. "APN4",
  137. ""
  138. };
  139. static const char *accIconFileNameAPN[]={
  140. "APN.bmp",
  141. "APN1.bmp",
  142. ""
  143. };
  144. void SetAPNShow(int update)
  145. {
  146. int i;
  147. static char GroupsFeatures[APN_NUM];
  148. if(update){
  149. if(showApn!=1)
  150. {
  151. ShowMessageBox("禁止修改");
  152. uTimerHardDly(200);
  153. UISetNextStatus(UIS_MENU_SYS_SET);
  154. return;
  155. }
  156. if(validApnNum==1)
  157. {
  158. ShowMessageBox("配置文件无APN");
  159. uTimerHardDly(200);
  160. UISetNextStatus(UIS_MENU_SYS_SET);
  161. return;
  162. }
  163. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  164. GuiClearAll();
  165. ShowCaption("设置APN",2);//
  166. //GuiDrawHLine(0,159,20,1);
  167. //设置Features 将决定选择图标
  168. GroupsFeatures[newPara.apnList.defaultuse]=1;
  169. ListBoxInit(&sutListBox,APNNAME,0,accIconFileNameAPN,GroupsFeatures);
  170. //----------------------------
  171. GuiDrawHLine(0,159,110,1);
  172. GuiShowStr(0,SUBSCRIPT_LOCATION,"[OK]切换 [S]详情",0x01,0);
  173. }
  174. }
  175. char *LCDNAME[LCD_NUM+1]=
  176. {
  177. "5",
  178. "4",
  179. "3",
  180. "2",
  181. "1",
  182. ""
  183. };
  184. void SetLcdBrightShow(int update)
  185. {
  186. static char GroupsFeatures[LCD_NUM];
  187. if(update){
  188. GuiClearAll();
  189. ShowCaption("背光调节",2);
  190. //设置Features 将决定选择图标
  191. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  192. GroupsFeatures[newPara.LcdPulse]=1;
  193. ListBoxInit(&sutListBox,LCDNAME,0,accIconFileNameAPN,GroupsFeatures);
  194. //----------------------------
  195. GuiDrawHLine(0,159,110,1);
  196. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]切换",0x01,0);
  197. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  198. //sutUIstatus.ItemRefresh=0;
  199. }
  200. }
  201. void SetLcdBrightResponse(void)
  202. {
  203. unsigned long key;
  204. key=ListBoxResponse(&sutListBox);
  205. if(KEY_PANEL_MENU==key){
  206. if(sutListBox.handle != newPara.LcdPulse){
  207. // if(sutListBox.handle==0)Test_EnableSpk=0;
  208. // else Test_EnableSpk=1;
  209. newPara.LcdPulse=sutListBox.handle;
  210. ModifyConfigureFile(1);
  211. }
  212. //sutUIstatus.ItemRefresh=1;
  213. UI_Stack.OK_back=1;
  214. UISetNextStatus(UIS_MENU_SYS_SET);
  215. }else if(KEY_PANEL_OK==key){
  216. UISetNextStatus(UIS_MENU_SYS_SET);
  217. }
  218. }
  219. void SetSYSResponse(void)
  220. {
  221. unsigned long key;
  222. key=MenuResponse(&sutMenuSysSetup);
  223. if(KEY_PANEL_MENU==key){
  224. switch(sutMenuSysSetup.handle){
  225. case 0:
  226. UISetNextStatus(UIS_SET_LCD);
  227. break;
  228. case 1:
  229. UISetNextStatus(UIS_SET_LCDBRIGHT);
  230. break;
  231. case 2:
  232. UISetNextStatus(UIS_SET_SIMCARD);
  233. break;
  234. case 3:
  235. UISetNextStatus(UIS_SET_USBTTL);
  236. break;
  237. case 4:
  238. UISetNextStatus(UIS_SET_PWRMODE);
  239. break;
  240. case 5:
  241. UISetNextStatus(UIS_SET_SERVER_PASS);
  242. break;
  243. case 6:
  244. UISetNextStatus(UIS_SET_POC_FOTA);
  245. break;
  246. }
  247. PushUiStack(&UI_Stack,sutMenuSysSetup.handle);
  248. }
  249. else if(KEY_PANEL_OK==key){
  250. UISetNextStatus(UIS_MENU_MAIN); //UIS_MENU_SYS_SET
  251. }
  252. }
  253. char showIndex;
  254. void ShowAPNMessage(char index)
  255. {
  256. char buf[40];
  257. char temp[40];
  258. unsigned char len;
  259. unsigned char i,y,maxLen;
  260. i=0;
  261. y=STATUS_ITEM_HEIGH;
  262. maxLen=14;
  263. GuiClearRect(0, y, LCD_WIDTH-1,LCD_HEIGHT-25);
  264. snprintf(buf, sizeof(buf), "%s:",APNNAME[showIndex]);
  265. GuiShowStr(1,y+16*i++,buf,0x01,0);
  266. len=strlen(newPara.apnList.apnList[showIndex].account);
  267. memcpy(temp, newPara.apnList.apnList[showIndex].account, maxLen);
  268. temp[maxLen]=0;
  269. snprintf(buf, sizeof(buf), "Name:%s",temp);
  270. GuiShowStr(1,y+16*i++,buf,0x01,0);
  271. if(len > maxLen)
  272. {
  273. // memcpy(temp, newPara.apnList.apnList[showIndex].account, maxLen);temp[maxLen]=0;
  274. // snprintf(buf, sizeof(buf), "%s",temp);
  275. // buf[len-maxLen]=0;
  276. strcpy(buf,&(newPara.apnList.apnList[showIndex].account[maxLen]));
  277. GuiShowStr(1,y+16*i++,buf,0x01,0);
  278. }
  279. len=strlen(newPara.apnList.apnList[showIndex].pass);
  280. memcpy(temp, newPara.apnList.apnList[showIndex].pass, maxLen);
  281. temp[maxLen]=0;
  282. snprintf(buf, sizeof(buf), "Pass:%s",temp);
  283. GuiShowStr(1,y+16*i++,buf,0x01,0);
  284. if(len > maxLen)
  285. {
  286. // memcpy(temp, newPara.apnList.apnList[showIndex].pass, maxLen);temp[maxLen]=0;
  287. // snprintf(buf, sizeof(buf), "%s",temp);
  288. // buf[len-maxLen]=0;
  289. strcpy(buf,&(newPara.apnList.apnList[showIndex].pass[maxLen]));
  290. GuiShowStr(1,y+16*i++,buf,0x01,0);
  291. }
  292. }
  293. void SetApnDetailShow(int update)
  294. {
  295. char buf[40];
  296. if(update)
  297. {
  298. GuiClearAll();
  299. ShowCaption("APN详情",2);//
  300. //GuiDrawHLine(0,159,20,1);
  301. showIndex=0;
  302. ShowAPNMessage(showIndex);
  303. //----------------------------
  304. GuiDrawHLine(0,159,110,1);
  305. GuiShowStr(0,SUBSCRIPT_LOCATION," [EXIT]返回",0x01,0);
  306. }
  307. }
  308. //居中显示信息
  309. void FunShowMsg(char *info)
  310. {
  311. int x,y;
  312. SlwTrace(INF, info,1);
  313. x=(LCD_WIDTH-strlen(info)*8)/2;
  314. y=LCD_HEIGHT/2;
  315. GuiClearArea(0,y,LCD_WIDTH, 16);
  316. GuiShowStr(x,y,info,1,0);
  317. }
  318. //配置编码器菜单
  319. unsigned char tempCodetype;
  320. void CodeTypeUpdateShow(void)
  321. {
  322. char info[20];
  323. switch(tempCodetype){
  324. case 0:sprintf(info, "EVRC_HALF");break;
  325. case 1:sprintf(info, "EVRC_FULL");break;
  326. case 2:sprintf(info, "AMRNB-122");break;
  327. default:return;
  328. }
  329. FunShowMsg(info);
  330. }
  331. void SetCodeTypeShow(int update)
  332. {
  333. static unsigned short susCt=0;
  334. int x=4;//4
  335. int i;
  336. if(update==1){
  337. susCt=0;
  338. GuiClearAll();
  339. ShowCaption("编码器设置",1);//0
  340. //GuiDrawHLine(0,159,20,1);
  341. GuiDrawHLine(0,159,110,1);
  342. if(modemInitReady==0){
  343. ShowMessageBox("模块暂未启动");
  344. uTimerHardDly(50);
  345. UISetNextStatus(UIS_MENU_SYS_SET);
  346. }else{
  347. tempCodetype=sutPocStatus.codeType;
  348. CodeTypeUpdateShow();
  349. }
  350. }
  351. if(susCt==0){
  352. GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  353. }else if(susCt==200){
  354. GuiShowStr(0,SUBSCRIPT_LOCATION,"[M]保存[EXIT]退出",0x01,0);
  355. }
  356. if(++susCt>=400)susCt=0;
  357. }
  358. void SetCodeTypeResponse(void)
  359. {
  360. char info[30];
  361. switch(g_ulKeyValue){
  362. case KEY_PANEL_UP:
  363. if(tempCodetype==0) tempCodetype=1;
  364. else tempCodetype--;
  365. CodeTypeUpdateShow();
  366. break;
  367. case KEY_PANEL_DOWN:
  368. if(tempCodetype==1) tempCodetype=0;
  369. else tempCodetype++;
  370. CodeTypeUpdateShow();
  371. break;
  372. case KEY_PANEL_MENU:
  373. if(tempCodetype != sutPocStatus.codeType){
  374. sutPocStatus.codeType=tempCodetype;
  375. sprintf(info, "AT+POC=40000001%02x\r\n", tempCodetype);
  376. ModemSendAt(info);
  377. SlwTrace(INF, "Update codetype",1);
  378. }
  379. UISetNextStatus(UIS_STANDBY);
  380. break;
  381. case KEY_PANEL_EXIT:
  382. UISetNextStatus(UIS_MENU_SYS_SET);
  383. break;
  384. }
  385. }
  386. void SetGPSTimeShowDetail(unsigned char timeIndex)
  387. {
  388. unsigned short tempTime;
  389. char buf[10];
  390. tempTime = GPS_TimeTable[timeIndex];
  391. GuiClearRect(100,STATUS_ITEM_HEIGH+16+16,LCD_WIDTH-1, STATUS_ITEM_HEIGH+16+16+16);
  392. if(tempTime==0)
  393. {
  394. GuiShowStr(100,STATUS_ITEM_HEIGH+16+16," 关闭 ",0x01,0);//130
  395. //GuiReverseRect(108,56,16*2,16);
  396. }else
  397. {
  398. snprintf(buf, sizeof(buf)," %02d 秒",tempTime);
  399. GuiShowStr(100,STATUS_ITEM_HEIGH+16+16,buf,0x01,0);//130
  400. // if(tempTime > 99) GuiReverseRect(108,56,24,16);
  401. // else GuiReverseRect(108,56,16,16);
  402. }
  403. }
  404. /*********************************************************/
  405. void SetGPSShow(int update)
  406. {
  407. static unsigned short susCt=0;
  408. if(update){
  409. GuiClearAll();
  410. ShowCaption("定位设置",1);//
  411. GuiShowStr(0,STATUS_ITEM_HEIGH+16+16,"定位上传设置: 秒",0x01,0); //sutGpsInfo.SendTime
  412. //GuiDrawHLine(0,159,20,1);
  413. GetCoordinates(0);
  414. sutGpsInfo.GPS_TimeIndexBackup = newPara.gpsTimeIndex;
  415. SetGPSTimeShowDetail(sutGpsInfo.GPS_TimeIndexBackup);
  416. GuiDrawHLine(0,159,110,1);
  417. susCt=0;
  418. }
  419. if(susCt==0){
  420. GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  421. }else if(susCt==200){
  422. GuiShowStr(0,SUBSCRIPT_LOCATION,"[M]保存[EXIT]退出",0x01,0);
  423. }
  424. if(++susCt>=400)susCt=0;
  425. }
  426. void SetGPSResponse(void)
  427. {
  428. switch(g_ulKeyValue)
  429. {
  430. case KEY_PANEL_UP:
  431. case KEY_PANEL_DOWN:
  432. if(hgs_poc_type!=POC_OWN)break;
  433. if(g_ulKeyValue==KEY_PANEL_UP)
  434. {
  435. if(sutGpsInfo.GPS_TimeIndexBackup<(GPS_TABLE_NUM-1))
  436. sutGpsInfo.GPS_TimeIndexBackup++;
  437. else
  438. sutGpsInfo.GPS_TimeIndexBackup=0;
  439. }else{
  440. if(sutGpsInfo.GPS_TimeIndexBackup==0)
  441. sutGpsInfo.GPS_TimeIndexBackup=GPS_TABLE_NUM-1;
  442. else
  443. sutGpsInfo.GPS_TimeIndexBackup--;
  444. }
  445. SetGPSTimeShowDetail(sutGpsInfo.GPS_TimeIndexBackup);
  446. break;
  447. case KEY_PANEL_OK:
  448. if(hgs_poc_type!=POC_OWN)break;
  449. if(sutGpsInfo.GPS_TimeIndexBackup != newPara.gpsTimeIndex)
  450. {//changed
  451. newPara.gpsTimeIndex = sutGpsInfo.GPS_TimeIndexBackup;
  452. GpsTimeUpdate();
  453. //save sys
  454. ModifyConfigureFile(1);
  455. }
  456. UI_Stack.OK_back=1;
  457. UISetNextStatus(UIS_MENU_MAIN);
  458. break;
  459. case KEY_PANEL_MENU: UISetNextStatus(UIS_MENU_MAIN);break;
  460. //case KEY_PANEL_MENU: UISetNextStatus(UIS_MENU_MAIN);break;
  461. }
  462. }
  463. /***************************提示音设置******************************/
  464. unsigned char tempKeySound;
  465. char *KeySoundNAME[5]=
  466. {
  467. "关闭提示音",
  468. "按键+收发音",
  469. "仅收发音",
  470. ""
  471. };
  472. void SetKeySoundShow(int update)
  473. {
  474. static unsigned short susCt=0;
  475. static char GroupsFeatures[4];
  476. if(update){
  477. GuiClearAll();
  478. ShowCaption("提示音设置",1);
  479. //设置Features 将决定选择图标
  480. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  481. GroupsFeatures[newPara.KeySound]=1;
  482. ListBoxInit(&sutListBox,KeySoundNAME,0,accIconFileNameAPN,GroupsFeatures);
  483. //----------------------------
  484. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  485. GuiDrawHLine(0,159,110,1);
  486. }
  487. if(susCt==20){
  488. // GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择[下]选择",0x01,0);
  489. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  490. }else if(susCt==200){
  491. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]保存",0x01,0);
  492. }
  493. if(++susCt>=400)susCt=0;
  494. }
  495. void SetKeysoundResponse(void)
  496. {
  497. unsigned long key;
  498. char buf[20];
  499. key=ListBoxResponse(&sutListBox);
  500. if(KEY_PANEL_MENU==key){
  501. if(sutListBox.handle != newPara.KeySound){
  502. //AT+TONES=1
  503. //ModemSendAt
  504. newPara.KeySound=sutListBox.handle;
  505. if(newPara.KeySound){
  506. if(hgs_poc_type==POC_OWN)ModemSendAt("AT+TONES=1\r\n");
  507. else if(hgs_poc_type==POC_BND){
  508. snprintf(buf,sizeof(buf),"AT+POC=tonevol=%d\r\n",newPara.VolumLv);
  509. ModemSendAt(buf);
  510. }
  511. }else{
  512. //AT+POC=ttsvol=6
  513. if(hgs_poc_type==POC_OWN)ModemSendAt("AT+TONES=0\r\n");
  514. else ModemSendAt("AT+POC=tonevol=0\r\n");
  515. }
  516. ModifyConfigureFile(1);
  517. }
  518. //sutUIstatus.ItemRefresh=1;
  519. UI_Stack.OK_back=1;
  520. UISetNextStatus(UIS_MENU_MAIN);
  521. }else if(KEY_PANEL_OK==key){
  522. UISetNextStatus(UIS_MENU_MAIN);
  523. }
  524. }
  525. // char CardUseShow[3][11];
  526. char *CardUseShow[3]=
  527. {
  528. "卡1",
  529. "卡2",
  530. ""
  531. };
  532. void SetCardShow(int update)
  533. {
  534. static unsigned short susCt=0;
  535. char i=0;
  536. char GroupsFeatures[2];
  537. if(update){
  538. GuiClearAll();
  539. ShowCaption("SIM卡选择",1);
  540. //设置Features 将决定选择图标
  541. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  542. //CardStatue
  543. GroupsFeatures[SIMSelect]=1;
  544. ListBoxInit(&sutListBox,CardUseShow,0,accIconFileNameAPN,GroupsFeatures);
  545. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  546. //----------------------------
  547. GuiDrawHLine(0,127,110,1);
  548. }
  549. if(susCt==20){
  550. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  551. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  552. }else if(susCt==200){
  553. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]保存",0x01,0);
  554. }
  555. if(++susCt>=400)susCt=0;
  556. }
  557. void SetCardResponse(void)
  558. {
  559. unsigned long key;
  560. char buf[20];
  561. key=ListBoxResponse(&sutListBox);
  562. if(KEY_PANEL_MENU==key){
  563. snprintf(buf,sizeof(buf),"AT+SIMCROSS=%d\r\n",sutListBox.handle);
  564. ModemSendAt(buf);
  565. SIMSelect=sutListBox.handle;
  566. //sutUIstatus.ItemRefresh=1;
  567. sutPocStatus.modemRstFlag=1;
  568. UISetNextStatus(UIS_STANDBY);
  569. }else if(KEY_PANEL_OK==key){
  570. if(UI_Stack.FastUiChange==1){
  571. UI_Stack.FastUiChange=0;
  572. UISetNextStatus(UIS_STANDBY);
  573. }else UISetNextStatus(UIS_MENU_SYS_SET);
  574. }
  575. }
  576. unsigned char SetTimeIndex;
  577. void SetLCDShow(int update)
  578. {
  579. static unsigned short susCt=0;
  580. char buf[10];
  581. char buf1[6];
  582. int x=4;//4
  583. int i;
  584. if(update==1){
  585. SetTimeIndex=newPara.lcdParaDefaultIndex;
  586. GuiClearAll();
  587. ShowCaption("LCD设置",1);//0
  588. //GuiDrawHLine(0,159,20,1);
  589. GuiShowStr(x,56," 背光时间: ",1,0);
  590. if(SetTimeIndex==4) snprintf(buf, sizeof(buf),"常亮 ");
  591. else snprintf(buf, sizeof(buf),"%3d 秒",newPara.lcdParaList[SetTimeIndex]);
  592. GuiShowStr(x+(12*5),56,buf,1,0);
  593. //GuiReverseRect(x+(16*5),56,32,16);
  594. snprintf(buf1, sizeof(buf1),"%3d",SetTimeIndex);
  595. SlwTrace(INF,buf1,1);
  596. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  597. GuiDrawHLine(0,LCD_WIDTH-1,110,1);
  598. susCt=0;
  599. //return;
  600. }else if(update == 2){
  601. GuiClearRect(x+(12*5),56,LCD_WIDTH,16);
  602. if(SetTimeIndex==4) snprintf(buf, sizeof(buf),"常亮 ");
  603. else snprintf(buf, sizeof(buf),"%3d 秒",newPara.lcdParaList[SetTimeIndex]);
  604. GuiShowStr(x+(12*5),56,buf,1,0);
  605. //GuiReverseRect(x+(16*5),56,32,16);
  606. GuiDrawHLine(0,LCD_WIDTH-1,110,1);
  607. }
  608. if(susCt==0){
  609. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  610. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  611. }else if(susCt==200){
  612. // GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]保存",0x01,0);
  613. }
  614. if(++susCt>=400)susCt=0;
  615. }
  616. void SetLCDResponse(void)
  617. {
  618. int FileIndex;
  619. unsigned long key;
  620. char Buf[10];
  621. int x=4;//4
  622. //TimeOut[]
  623. // key=ListBoxResponse(&sutListBox);
  624. switch(g_ulKeyValue){
  625. case KEY_PANEL_UP:
  626. if(++SetTimeIndex>=5)SetTimeIndex=0;
  627. SetLCDShow(2);//0
  628. break;
  629. case KEY_PANEL_DOWN:
  630. if(SetTimeIndex>0)SetTimeIndex--;
  631. else SetTimeIndex=4;
  632. SetLCDShow(2);//0
  633. break;
  634. case KEY_PANEL_MENU:
  635. if(SetTimeIndex != newPara.lcdParaDefaultIndex){
  636. newPara.lcdParaDefaultIndex=SetTimeIndex;
  637. //save sys
  638. ModifyConfigureFile(1);
  639. }
  640. UI_Stack.OK_back=1;
  641. UISetNextStatus(UIS_MENU_SYS_SET);
  642. break;
  643. case KEY_PANEL_OK:
  644. UISetNextStatus(UIS_MENU_SYS_SET);
  645. break;
  646. }
  647. }
  648. void GetMododexWithCard(void)
  649. {
  650. char buf[30];
  651. //根据CardType和ModeSetup转换为Mododex值的一个表
  652. //static const unsigned char MododrxTable[3][3]={{11,24,5},{2,8,5},{17,21,5}};
  653. static const unsigned char MododrxTable[3][4]={{11,15,10,5},{2,25,7,5},{17,25,1,5}};
  654. snprintf(buf,sizeof(buf),"AT+MODODREX=%d\r\n",MododrxTable[thisYunYingShang][newPara.netMode]);
  655. ModemSendAt(buf);
  656. }
  657. void SetNetShow(int update)
  658. {
  659. static unsigned short susCt=0;
  660. static const char *Netmode[NET_NUM+1]=
  661. {
  662. "AUTO",
  663. "2G",
  664. "4G",
  665. ""
  666. };
  667. //static
  668. char NetsFeatures[NET_NUM]={0};
  669. if(update){
  670. GuiClearAll();
  671. ShowCaption("网络设置",2);//
  672. NetsFeatures[newPara.netMode/2]=1;
  673. ListBoxInit(&sutListBox,Netmode,0,accIconFileNameAPN,NetsFeatures);
  674. //----------------------------
  675. GuiDrawHLine(0,LCD_WIDTH-1,110,1);
  676. }
  677. if(susCt==0){
  678. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  679. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  680. }else if(susCt==200){
  681. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]保存",0x01,0);
  682. }
  683. if(++susCt>=400)susCt=0;
  684. }
  685. void SetNetResponse(void)
  686. {
  687. unsigned long key;
  688. unsigned char buf[15];
  689. key=ListBoxResponse(&sutListBox);
  690. if(KEY_PANEL_MENU==key){
  691. if(sutListBox.handle*2 != newPara.netMode){
  692. newPara.netMode=sutListBox.handle*2;
  693. snprintf(buf,sizeof(buf),"AT+CTEC=%d,%d\r\n",netshowvalue,newPara.netMode);
  694. ModemSendAt(buf);
  695. ModifyConfigureFile(1);
  696. }
  697. UI_Stack.OK_back=1;
  698. UISetNextStatus(UIS_MENU_MAIN);
  699. }else if(KEY_PANEL_OK==key){
  700. UISetNextStatus(UIS_MENU_MAIN);
  701. }
  702. }
  703. unsigned char USBSeletCt=0;
  704. void SetUSBorTTLShow(int update)
  705. {
  706. static unsigned short susCt=0;
  707. static const char *Netmode[3+1]=
  708. {
  709. "TTL",
  710. "USB",
  711. "升级模式",
  712. ""
  713. };
  714. //static
  715. char NetsFeatures[3]={0};
  716. if(update){
  717. GuiClearAll();
  718. ShowCaption("串口切换",2);//
  719. NetsFeatures[USBSeletCt]=1;
  720. ListBoxInit(&sutListBox,Netmode,0,accIconFileNameAPN,NetsFeatures);
  721. //----------------------------
  722. GuiDrawHLine(0,159,110,1);
  723. }
  724. if(susCt==0){
  725. // GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  726. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  727. }else if(susCt==200){
  728. // GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]保存",0x01,0);
  729. }
  730. if(++susCt>=400)susCt=0;
  731. }
  732. void SetUSBorTTLResponse(void)
  733. {
  734. unsigned long key;
  735. unsigned char buf[15];
  736. key=ListBoxResponse(&sutListBox);
  737. if(KEY_PANEL_MENU==key){
  738. if(sutListBox.handle != USBSeletCt){
  739. USBSeletCt=sutListBox.handle;
  740. switch(USBSeletCt)
  741. {
  742. case 0://TTL
  743. MODEM_UPDATE_LOW;
  744. break;
  745. case 1://USB
  746. // ModemSendAt("AT+ROUTE=0,1\r\n");//打开POClog
  747. MODEM_UPDATE_LOW;
  748. break;
  749. case 2://MODEMUPDATE
  750. MODEM_UPDATE_HIGH;
  751. sutPocStatus.modemRstFlag=1;
  752. break;
  753. }
  754. }
  755. UI_Stack.OK_back=1;
  756. UISetNextStatus(UIS_MENU_SYS_SET);
  757. }else if(KEY_PANEL_OK==key){
  758. UISetNextStatus(UIS_MENU_SYS_SET);
  759. }
  760. }
  761. void SetPowerModeShow(int update)
  762. {
  763. int i;
  764. static const char *ModeName[]={//这里数量变了记得修改 PWR_MODE_NUM
  765. "低功耗模式",
  766. "超长待机模式",
  767. "常规模式",
  768. ""
  769. };
  770. char GroupsFeatures[PWR_MODE_NUM];
  771. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  772. if(update){
  773. GuiClearAll();
  774. ShowCaption("模式设置",2);//
  775. //GuiDrawHLine(0,159,20,1);
  776. //设置Features 将决定选择图标
  777. GroupsFeatures[newPara.pwrMode]=1;
  778. ListBoxInit(&sutListBox,ModeName,0,accIconFileNameAPN,GroupsFeatures);
  779. //----------------------------
  780. GuiDrawHLine(0,LCD_WIDTH-1,110,1);
  781. // GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]切换",0x01,0);
  782. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  783. }
  784. }
  785. /***************************场景模式设置******************************/
  786. void SetSoundModeShow(int update)
  787. {
  788. int i;
  789. static const char *ModeName[]={
  790. "室内模式",
  791. "室外模式",
  792. ""
  793. };
  794. char GroupsFeatures[2];
  795. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  796. if(update){
  797. GuiClearAll();
  798. ShowCaption("场景模式",2);//
  799. //GuiDrawHLine(0,159,20,1);
  800. //设置Features 将决定选择图标
  801. memset(GroupsFeatures,0,sizeof(GroupsFeatures));
  802. GroupsFeatures[newPara.SoundMode]=1;
  803. ListBoxInit(&sutListBox,ModeName,0,accIconFileNameAPN,GroupsFeatures);
  804. //----------------------------
  805. GuiDrawHLine(0,LCD_WIDTH-1,110,1);
  806. GuiShowStr(0,SUBSCRIPT_LOCATION,"[OK]切换 [EXIT]退出",0x01,0);
  807. //sutUIstatus.ItemRefresh=0;
  808. }
  809. }
  810. void SetSoundModeResponse(void)
  811. {
  812. unsigned long key;
  813. key=ListBoxResponse(&sutListBox);
  814. if(KEY_PANEL_MENU==key)
  815. {
  816. if(newPara.SoundMode!=sutListBox.handle){
  817. newPara.SoundMode=sutListBox.handle;
  818. if(newPara.SoundMode==1)ModemSendAt("at+syscmd=start_pcm volume 7 7\r\n");
  819. else ModemSendAt("at+syscmd=start_pcm volume 7 5\r\n");
  820. ModifyConfigureFile(1);
  821. //sutUIstatus.ItemRefresh=1;
  822. }
  823. UI_Stack.OK_back=1;
  824. UISetNextStatus(UIS_MENU_SYS_SET);
  825. }
  826. else if(KEY_PANEL_EXIT==key)UISetNextStatus(UIS_MENU_SYS_SET);
  827. }
  828. //对讲版本空中升级API
  829. int getNewVersion;
  830. unsigned char fotaPocStatus;
  831. unsigned int fotaTick;
  832. void SetUpIntercomVerShow(int update)
  833. {
  834. char info[40];
  835. if(update){
  836. GuiClearAll();
  837. ShowCaption("升级对讲版本",1);//
  838. //GuiDrawHLine(0,159,20,1);
  839. FunShowMsg("正在检测版本");
  840. GuiDrawHLine(0,127,110,1);
  841. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[M]升级 [EXIT]退出",0x01,0);
  842. GuiShowStr(0,SUBSCRIPT_LOCATION,"<退出 确定 下翻>",0x01,0);
  843. getNewVersion=-1;
  844. fotaPocStatus=0;
  845. ModemSendAt("AT+FOTA?\r\n");//对应用在模块接收消息中添加获取版本代码
  846. uTimerStart(&fotaTick,400);//200
  847. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[M]确定 [EXIT]退出",0x01,0);
  848. }
  849. switch(fotaPocStatus){
  850. case 0://获取版本信息
  851. if(uTimerExpired(&fotaTick)){
  852. if(getNewVersion ==0){//没有更新版本
  853. fotaPocStatus=1;
  854. FunShowMsg("没有可更新版本");
  855. uTimerStart(&fotaTick,150);
  856. }else if(getNewVersion>0){//有可更新版本
  857. //询问是否更新
  858. sprintf(info, "更新到V%d ?",getNewVersion);
  859. FunShowMsg(info);
  860. fotaPocStatus=2;
  861. }else{//超时未检测到查询版本响应
  862. fotaPocStatus=1;
  863. FunShowMsg("检测超时");
  864. uTimerStart(&fotaTick,150);
  865. }
  866. }
  867. break;
  868. case 1:
  869. if(uTimerExpired(&fotaTick)){//退出显示信息完毕
  870. UISetNextStatus(UIS_STANDBY);
  871. }
  872. break;
  873. }
  874. }
  875. void SetUpIntercomVerResponse(void)
  876. {
  877. switch(fotaPocStatus){
  878. case 2://等待用户确定
  879. if(KEY_PANEL_MENU==g_ulKeyValue){
  880. //确定
  881. fotaPocStatus=3;
  882. ModemSendAt("AT+FOTA=1\r\n");
  883. }else if(KEY_PANEL_OK==g_ulKeyValue){
  884. UISetNextStatus(UIS_MENU_SYS_SET);
  885. }
  886. break;
  887. }
  888. }
  889. /*
  890. 针对cat1
  891. AT+FOTA? 查询FOTA状态
  892. +FOTA:1,0 无版本可以升级/当前版本最新
  893. +FOTA:1,2012 有最新的版本可以升级 2012版本
  894. AT+FOTA=1 有版本升级的情况下发,表示启动升级
  895. +FOTA:0 表示升级失败/停止
  896. +FOTA:1 表示正在升级
  897. +FOTA:2 表示升级成功即将重启
  898. */
  899. void FotaStatusProcess(char *pMsg)
  900. {
  901. char info[30];
  902. switch(pMsg[0]){
  903. case '1'://1,0 1,19070702 表示查询POC版本响应
  904. if(strlen(pMsg)>2){
  905. getNewVersion=atoi(pMsg+2);//获取版本结果
  906. }else{
  907. FunShowMsg("正在升级...");
  908. }
  909. break;
  910. case '2'://表示安装完成,正在重启模块
  911. FunShowMsg("正在重启...");
  912. sutPocStatus.modemRstFlag=1;
  913. fotaPocStatus=1;
  914. uTimerStart(&fotaTick,150);
  915. break;
  916. case '0'://退出FOTA升级,原因可能是因为网络不稳定或者文件获取失败
  917. FunShowMsg("失败退出");
  918. fotaPocStatus=1;
  919. uTimerStart(&fotaTick,150);
  920. break;
  921. }
  922. }
  923. void UIShowInformation(int update)
  924. {
  925. u16 x,y;
  926. char temp[11];
  927. char buf[50];
  928. static unsigned char flag=0;
  929. unsigned char LineSpace;//行宽
  930. LineSpace=18;
  931. if(update)
  932. {
  933. flag=0;
  934. GuiClearAll();
  935. ShowCaption("终端信息",1); //0
  936. //GuiDrawHLine(0,159,20,1);
  937. }
  938. x=2,y=STATUS_ITEM_HEIGH+5;//
  939. if(
  940. KEY_PANEL_DOWN==g_ulKeyValue ||
  941. update)
  942. {
  943. g_ulKeyValue = 0;
  944. g_uslockCnt=0;
  945. if(flag==0 || flag==2)
  946. {//显示PSN
  947. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  948. //终端型号
  949. // snprintf(buf, sizeof(buf),"终端型号:%s",sutProductPara.ProductName);
  950. // GuiShowStr(x,y,buf,0x01,0);
  951. // y+=LineSpace;
  952. //终端编码
  953. snprintf(buf, sizeof(buf),"PSN:%lu",sutProductPara.PSN);
  954. GuiShowStr(x,y,buf,0x01,0);
  955. y+=LineSpace;
  956. //应用版本号
  957. snprintf(buf, sizeof(buf),"应用版本:V%d",sutProductPara.ProductVersion);
  958. GuiShowStr(x,y,buf,0x01,0);
  959. y+=LineSpace;
  960. //内部版本号
  961. snprintf(buf, sizeof(buf),"内部版本:%d",CUSTOMER_CODE);
  962. GuiShowStr(x,y,buf,0x01,0);
  963. // y+=LineSpace;
  964. // //模块版本号
  965. // snprintf(buf, sizeof(buf),"模块版本:L%d",g_iModemVer);
  966. // GuiShowStr(x,y,buf,0x01,0);
  967. flag=1;
  968. }else if(flag==1)
  969. {
  970. g_ulKeyValue = 0;
  971. g_uslockCnt=0;
  972. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  973. //对讲版本号
  974. //snprintf(buf, sizeof(buf),"对讲版本:V%d",g_iPocVer);
  975. if(hgs_poc_type==POC_NULL)snprintf(buf, sizeof(buf),"平台:未知");
  976. else if(hgs_poc_type==POC_OWN)snprintf(buf, sizeof(buf),"平台:HGS");
  977. else if(hgs_poc_type==POC_BND)snprintf(buf, sizeof(buf),"平台:BND");
  978. GuiShowStr(x,y,buf,0x01,0);
  979. y+=LineSpace;
  980. //校验码
  981. // GetCheckCodeByPsnMEID(temp,sutProductPara.PSN,DEV_HARDID);
  982. // snprintf(buf, sizeof(buf),"校验码:%s",temp);
  983. snprintf(buf, sizeof(buf),"PocVer:%s",g_iPocVer);
  984. GuiShowStr(x,y,buf,0x01,0);
  985. y+=LineSpace;
  986. temp[0]=0;
  987. //显示MCU主频率
  988. snprintf(buf, sizeof(buf),"MCU主频:%d.%d Mhz",USER_MAIN_SYSCLK/1000000,USER_MAIN_SYSCLK%1000000/100000);
  989. GuiShowStr(x,y,buf,0x01,0);
  990. y+=LineSpace;
  991. //
  992. memset(buf,sizeof(buf),0);
  993. snprintf(buf,sizeof(buf),"模块:%s",ModemVer);
  994. GuiShowStr(x,y,buf,0x01,0);
  995. flag=2;
  996. }
  997. }else if(KEY_UP_DOWN_IP == g_ulKeyValue)
  998. {
  999. g_ulKeyValue=0;
  1000. if(flag==1 || flag==2)
  1001. {
  1002. //显示IP
  1003. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  1004. //交换IP
  1005. GuiShowStr(x,y,"交换服务器:",0x01,0);
  1006. y+= LineSpace;
  1007. snprintf(buf, sizeof(buf),"%s",showPIP);
  1008. GuiShowStr(x,y,buf,0x01,0);
  1009. y+=LineSpace;
  1010. //GPS IP
  1011. GuiShowStr(x,y,"定位服务器:",0x01,0);
  1012. y+= LineSpace;
  1013. snprintf(buf, sizeof(buf),"%s",showGIP);
  1014. GuiShowStr(x,y,buf,0x01,0);
  1015. y+=LineSpace;
  1016. snprintf(buf, sizeof(buf),"PORT:%d",newPara.gpsPort);
  1017. GuiShowStr(x,y,buf,1,0);
  1018. flag=0;
  1019. }
  1020. }
  1021. }
  1022. void UIShowPOCSerPass(int update){
  1023. if(update){
  1024. GuiClearAll();//clear
  1025. ShowCaption("密码验证",1); //0
  1026. //GuiDrawHLine(0,LCD_WIDTH,20,1);
  1027. NumEditInit(&sutNumEdit,(LCD_WIDTH-6*8)/2,(LCD_HEIGHT-16)/2,"000000");
  1028. NumEditShow(&sutNumEdit);
  1029. GuiDrawHLine(0,LCD_WIDTH,104,1);
  1030. //GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]加值 [OK]移动",0x01,0);
  1031. GuiShowStr(0,SUBSCRIPT_LOCATION,"<加值 确定 下翻>",0x01,0);
  1032. }
  1033. }
  1034. void POCSetSerPassResponse(void){
  1035. unsigned long key;
  1036. NumEditResponse(&sutNumEdit);
  1037. if(KEY_PANEL_MENU==g_ulKeyValue){
  1038. if(memcmp(sutNumEdit.buffer, menu_key, 6)==0) UISetNextStatus(UIS_SET_SERVER);
  1039. else{
  1040. ShowMessageBox("密码错误");
  1041. uTimerHardDly(50);
  1042. UI_Stack.OK_back=1;
  1043. UISetNextStatus(UIS_MENU_SYS_SET);
  1044. }
  1045. }
  1046. //if(KEY_PANEL_OK==g_ulKeyValue) UISetNextStatus(UIS_MENU_SYS_SET);
  1047. }
  1048. void UIShowPOCSer(int update){
  1049. int i;
  1050. unsigned char tempSer;
  1051. static const char *accIconFileName[]={
  1052. "Ser.bmp",
  1053. "Sersel.bmp",
  1054. ""
  1055. };
  1056. static const char *NameAddr[]={
  1057. "杭州服务器",
  1058. "山东服务器",
  1059. "IP分发服务器",
  1060. "集群服务器",
  1061. "自定义服务器",
  1062. ""
  1063. };
  1064. static char *tempAddr[5];
  1065. static char ItemFeatures[4+1];
  1066. if(update){
  1067. GuiClearAll();
  1068. ShowCaption("服务器列表",2); //0
  1069. //GuiDrawHLine(0,159,20,1);
  1070. GuiDrawHLine(0,159,110,1);
  1071. GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]确定",0x01,0);
  1072. tempSer=newPara.serList.defaultuse;
  1073. if(hgs_poc_type != POC_OWN){
  1074. if(tempSer >= 2) tempSer -= 2;
  1075. }
  1076. for(i=0;i<=SER_US;i++){
  1077. if(i==tempSer) ItemFeatures[i]=1;
  1078. else ItemFeatures[i]=0;
  1079. }
  1080. //初始化ListBox控件
  1081. if(hgs_poc_type == POC_OWN)
  1082. ListBoxInit(&sutListBox,NameAddr,0,accIconFileName,ItemFeatures);
  1083. else{
  1084. for(i=0;i<2;i++) tempAddr[i]=(char *)NameAddr[i];
  1085. tempAddr[i++]=(char *)NameAddr[4];
  1086. tempAddr[i++]=(char *)NameAddr[5];
  1087. ListBoxInit(&sutListBox,tempAddr,0,accIconFileName,ItemFeatures);
  1088. }
  1089. return;
  1090. }
  1091. }
  1092. void POCSetSerResponse(void)
  1093. {
  1094. char buf[50],buf1[100];
  1095. unsigned long key;
  1096. char *pip,*domain=NULL;
  1097. unsigned char tempSer;
  1098. key=ListBoxResponse(&sutListBox);
  1099. if(KEY_PANEL_OK==key) UISetNextStatus(UIS_MENU_SYS_SET);
  1100. else if(KEY_PANEL_MENU==key){
  1101. tempSer=sutListBox.handle;
  1102. if(hgs_poc_type != POC_OWN){
  1103. if(tempSer >= 2) tempSer += 2;//西安POC没有集群跟IP分发
  1104. }
  1105. if(tempSer != newPara.serList.defaultuse){
  1106. newPara.serList.defaultuse=tempSer;
  1107. ShowMessageBox("配置完成");
  1108. //sys save
  1109. ModifyConfigureFile(0);
  1110. getGIPAddr();//更新GPS参数
  1111. pip=getPIPAddr();
  1112. domain=getDOMAINAddr();
  1113. //西安的POC不支持单段设置,且必须同时配置id与ip,最好不配置domain
  1114. if(hgs_poc_type==POC_OWN)snprintf(buf, sizeof(buf),"ip=%s;domain=%s;", pip, domain);
  1115. else snprintf(buf, sizeof(buf),"id=%ld;ip=%s;", sutProductPara.PSN,pip);
  1116. AscStrToHexStr(buf,buf1);
  1117. ModemSendAt("AT+POC=010000");
  1118. ModemSendAt(buf1);
  1119. ModemSendAt("\r\n");
  1120. IWDG_ReloadCounter();
  1121. uTimerHardDly(20);
  1122. //os_dly_wait(20);
  1123. ModemSendAt("AT+POC=040000\r\n");
  1124. //OsDelayTime(100);
  1125. }
  1126. UISetNextStatus(UIS_STANDBY );
  1127. }
  1128. }
  1129. void SetAPNResponse(void)
  1130. {
  1131. unsigned long key;
  1132. key=ListBoxResponse(&sutListBox);
  1133. if(KEY_PANEL_OK==key)
  1134. {
  1135. ShowMessageBox("即将重启更新...");
  1136. if(newPara.apnList.defaultuse != sutListBox.handle){
  1137. newPara.apnList.defaultuse = sutListBox.handle;
  1138. //save sys
  1139. ModifyConfigureFile(0);
  1140. //uTimerHardDly(200);
  1141. //modemPwrOffNow=1;
  1142. sutPocStatus.modemRstFlag=1;
  1143. UISetNextStatus(UIS_STANDBY);
  1144. }else UISetNextStatus(UIS_MENU_SYS_SET);
  1145. }else if(KEY_OPTION==key) UISetNextStatus(UIS_APN_DETAIL);
  1146. else if(KEY_PANEL_MENU==key)UISetNextStatus(UIS_MENU_SYS_SET);
  1147. }
  1148. void SetApnDetailResponse(void)
  1149. {
  1150. if(KEY_PANEL_DOWN==g_ulKeyValue)
  1151. {
  1152. showIndex++;
  1153. if(showIndex >= validApnNum) showIndex=0;
  1154. ShowAPNMessage(showIndex);
  1155. }else if(KEY_PANEL_UP==g_ulKeyValue)
  1156. {
  1157. if(showIndex==0) showIndex=validApnNum;
  1158. if(showIndex > 0) showIndex--;
  1159. ShowAPNMessage(showIndex);
  1160. }
  1161. else if(KEY_PANEL_OK==g_ulKeyValue) UISetNextStatus(UIS_SET_APN);
  1162. }
  1163. void SetPowerModeResponse()
  1164. {
  1165. unsigned long key;
  1166. key=ListBoxResponse(&sutListBox);
  1167. if(KEY_PANEL_MENU==key){
  1168. if(sutListBox.handle != newPara.pwrMode){
  1169. newPara.pwrMode=sutListBox.handle;
  1170. ModifyConfigureFile(1);
  1171. }
  1172. UI_Stack.OK_back=1;
  1173. UISetNextStatus(UIS_MENU_SYS_SET);
  1174. }else if(KEY_PANEL_OK==key){
  1175. UISetNextStatus(UIS_MENU_SYS_SET);
  1176. }
  1177. }
  1178. unsigned char TempMicLv=0x6c;
  1179. //SUT_MENU sutMenuMain;
  1180. /*********************************************************/
  1181. void SetMicLvSelectShow(int update)
  1182. {
  1183. static unsigned short susCt=0;
  1184. char buf[4];
  1185. if(update==1){
  1186. susCt=0;
  1187. GuiClearAll();
  1188. ShowCaption("麦克风增益",1);//
  1189. GuiDrawHLine(0,159,110,1);
  1190. if(modemInitReady==0){
  1191. ShowMessageBox("模块暂未启动");
  1192. uTimerHardDly(50);
  1193. UISetNextStatus(UIS_MENU_SYS_SET);
  1194. }else{
  1195. TempMicLv=newPara.Miclv;
  1196. snprintf(buf,sizeof(buf),"%03d",TempMicLv);
  1197. FunShowMsg(buf);
  1198. }
  1199. }
  1200. if(susCt==0){
  1201. GuiShowStr(0,SUBSCRIPT_LOCATION,"[上]选择 [下]选择",0x01,0);
  1202. }else if(susCt==200){
  1203. GuiShowStr(0,SUBSCRIPT_LOCATION,"[M]保存 [EXIT]退出",0x01,0);
  1204. }
  1205. if(++susCt>=400)susCt=0;
  1206. }
  1207. void SetMicLvSelectResponse()
  1208. {
  1209. char info[30];
  1210. switch(g_ulKeyValue){
  1211. case KEY_PANEL_UP:
  1212. if(TempMicLv==0x6E) TempMicLv=100;
  1213. else TempMicLv++;
  1214. snprintf(info,sizeof(info),"%03d",TempMicLv);
  1215. FunShowMsg(info);
  1216. break;
  1217. case KEY_PANEL_DOWN:
  1218. if(TempMicLv==100) TempMicLv=0x6E;
  1219. else TempMicLv--;
  1220. snprintf(info,sizeof(info),"%03d",TempMicLv);
  1221. FunShowMsg(info);
  1222. break;
  1223. case KEY_PANEL_MENU:
  1224. uTimerHardDly(50);
  1225. newPara.Miclv=TempMicLv;
  1226. sprintf(info, "AT+CACCP=2,1,6,\"%02x00%02x00\"\r\n", TempMicLv/16,TempMicLv%16);
  1227. ModemSendAt(info);
  1228. printf("%s---%02x----%02x",info,TempMicLv/16,TempMicLv%16);
  1229. ModifyConfigureFile(0);
  1230. break;
  1231. case KEY_PANEL_EXIT:
  1232. UISetNextStatus(UIS_MENU_SYS_SET);
  1233. break;
  1234. }
  1235. }
  1236. void PoweroffWaitShow(int update)
  1237. {
  1238. if(update==1){
  1239. GuiClearAll();
  1240. ShowMessageBox("确认关机?");
  1241. GuiShowStr(0,SUBSCRIPT_LOCATION,"[EXIT]退出[M]确认",0x01,0);
  1242. }
  1243. }
  1244. void PoweroffWaitResponse()
  1245. {
  1246. switch(g_ulKeyValue){
  1247. case KEY_PANEL_MENU:
  1248. GuiShowBmp(0,0,"BYEBYE.bmp");
  1249. uTimerHardDly(50);
  1250. MODEM_PWREN_LOW;
  1251. PWR_EN_LOW;
  1252. MODEM_LED1_LOW;
  1253. while(1);
  1254. break;
  1255. case KEY_PANEL_EXIT:
  1256. UISetNextStatus(UIS_STANDBY);
  1257. break;
  1258. }
  1259. }