MC8332GpsTask.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /********************************************************************************
  2. * File Name: MC8332GpsTask.h
  3. * Function Describe: Header file for MC8332GpsTask.c
  4. * Explain:
  5. * Writer:
  6. * Date: 2016-3-11
  7. *******************************************************************************/
  8. #include "includes.h"
  9. unsigned int Mododrex_Net;
  10. signed int netshowvalue=-1;
  11. FOTA_UPDATE fota_update;
  12. char *FindContentByChar( char *src,char c, char index,char *dest)
  13. {
  14. char i;
  15. char j=0;
  16. char *p=dest;
  17. for(i=0;i<strlen(src);i++)
  18. {
  19. if(src[i]==c)j++;
  20. if(j==index){
  21. p=&src[i+1];
  22. return p;
  23. }
  24. }
  25. return NULL;
  26. }
  27. void AtHandle(char *pMsg)
  28. {
  29. int csq;
  30. short targetIndex;
  31. unsigned char tempSocket,i,temp;
  32. unsigned short tempLen;
  33. char buf[80]="\r\n";
  34. char bufTemp[3];
  35. char buf3[40];//////////////////////////
  36. STATUE ipStatus;
  37. char *p=NULL;
  38. if(0==ModemStrCmp(pMsg,"+CSQ:"))
  39. {
  40. //UpdateCsqValue(GetCSQ(pMsg));
  41. g_iCSQ=GetCSQ(pMsg);
  42. }else if(0==ModemStrCmp(pMsg, "+CCLK:"))
  43. {//+CCLK: "17/09/28,04:48:35"
  44. //+CCLK: "80/01/06,00:10:44"
  45. //+CCLK: "17/10/19,07:22:35"
  46. g_usModeYTime=atoi(&pMsg[8]);
  47. g_usModemTime=atoi(&pMsg[11]);
  48. g_usModeDTime=atoi(&pMsg[14]);
  49. g_usModeHTime=atoi(&pMsg[17])+8;
  50. if(g_usModeHTime >= 24) g_usModeHTime -= 24;
  51. g_usModeMTime=atoi(&pMsg[20]);
  52. g_usModeSTime=atoi(&pMsg[23]);
  53. //SetTime(g_usModeHTime, g_usModeMTime, g_usModeSTime);//保存下来,以便下次启动,没登陆前可以使用本地时间显示
  54. SlwTrace(INF, "UpdateTime",1);
  55. }else if(0==ModemStrCmp(pMsg, "+POC:START"))
  56. {
  57. sutPocStatus.modemRstFlag=1;
  58. sutPocStatus.ModemInactiveCt=0;//当模块重启后重新计数串口通讯异常计数器
  59. }else if(0==ModemStrCmp(pMsg, "+COPS")){
  60. p=FindContentByChar(pMsg,',',3,buf);
  61. if(NULL!=p){
  62. netshowvalue=atoi(p);
  63. }
  64. if(netshowvalue==7){
  65. netshowvalue=4;
  66. }
  67. }
  68. }
  69. /************************************************
  70. 每10ms处理一次
  71. **************************************************/
  72. void GpsTaskTick(unsigned char reset)
  73. {
  74. static unsigned int sucSecCt=0;
  75. if(reset){
  76. sucSecCt=0;
  77. return;
  78. }
  79. if(sutGpsInfo.Updata==1){
  80. if(g_uiGpsStat==0){
  81. sutGpsInfo.isGpsWork=0;
  82. sutGpsInfo.isGpsValid=0;
  83. sutGpsInfo.GpsInactiveCt=0;
  84. SlwTrace(INF,"GPS Close------",1);
  85. g_usUart3RecvLen=0;
  86. GPS_PWREN_LOW;
  87. }else{
  88. sutGpsInfo.isGpsWork=0;
  89. sutGpsInfo.isGpsValid=0;
  90. sutGpsInfo.GpsInactiveCt=0;
  91. GPS_PWREN_HIGH;
  92. SlwTrace(INF,"GPS open------",1);
  93. }
  94. sutGpsInfo.Updata=0;
  95. }
  96. //GPS Uart消息处理
  97. if(g_usUart3RecvLen)
  98. {
  99. process_nema((char *)RxBuffer3);
  100. g_usUart3RecvLen=0;
  101. }
  102. //===========以下控制每秒执行一次============
  103. if(os_time_get() < sucSecCt) return;
  104. sucSecCt=os_time_get()+100;
  105. //////////////////20170112////////////////////
  106. GpsCtrlSendPos();//里面涉及到鉴权,所以得跑起来 //以及GPS上传时间
  107. }
  108. void AtQuery()
  109. {
  110. static unsigned char send_sucCt=0;
  111. if(g_ucGtMode==1)return;
  112. unsigned char QueryTime=2;
  113. if(sutPocStatus.FirstLogined) QueryTime=9;
  114. // switch(send_sucCt){
  115. //
  116. // case 0:
  117. // ModemSendAT("AT+CSQ\r\n");
  118. // break;
  119. // case 1:
  120. // ModemSendAT("AT+COPS?\r\n");
  121. // break;
  122. // }
  123. if(++send_sucCt>QueryTime) {
  124. ModemSendAT("AT+CSQ\r\n");
  125. os_dly_wait(1);
  126. ModemSendAT("AT+COPS?\r\n");
  127. send_sucCt=0;
  128. }
  129. }