MC8332GpsTask.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. unsigned int netshowvalue;
  11. FOTA_UPDATE fota_update;
  12. void AtHandle(char *pMsg)
  13. {
  14. int csq;
  15. short targetIndex;
  16. unsigned char tempSocket,i,temp;
  17. unsigned short tempLen;
  18. char buf[80]="\r\n";
  19. char bufTemp[3];
  20. char buf3[40];//////////////////////////
  21. STATUE ipStatus;
  22. if(0==ModemStrCmp(pMsg,"^SYSINFO:"))
  23. {
  24. if(pMsg[15]!=','){
  25. netshowvalue=atoi(&pMsg[15]);
  26. }else{
  27. netshowvalue=atoi(&pMsg[16]);
  28. }
  29. }
  30. if(0==ModemStrCmp(pMsg,"+CSQ:"))
  31. {
  32. //UpdateCsqValue(GetCSQ(pMsg));
  33. g_iCSQ=GetCSQ(pMsg);
  34. }else if(0==ModemStrCmp(pMsg, "+CCLK:"))
  35. {//+CCLK: "17/09/28,04:48:35"
  36. //+CCLK: "80/01/06,00:10:44"
  37. //+CCLK: "17/10/19,07:22:35"
  38. g_usModeYTime=atoi(&pMsg[8]);
  39. g_usModemTime=atoi(&pMsg[11]);
  40. g_usModeDTime=atoi(&pMsg[14]);
  41. g_usModeHTime=atoi(&pMsg[17])+8;
  42. if(g_usModeHTime >= 24) g_usModeHTime -= 24;
  43. g_usModeMTime=atoi(&pMsg[20]);
  44. g_usModeSTime=atoi(&pMsg[23]);
  45. SetTime(g_usModeHTime, g_usModeMTime, g_usModeSTime);//保存下来,以便下次启动,没登陆前可以使用本地时间显示
  46. SlwTrace(INF, "UpdateTime",1);
  47. }else if(0==ModemStrCmp(pMsg, "+POC:START"))
  48. {
  49. sutPocStatus.modemRstFlag=1;
  50. sutPocStatus.ModemInactiveCt=0;//当模块重启后重新计数串口通讯异常计数器
  51. }
  52. }
  53. /************************************************
  54. 每10ms处理一次
  55. **************************************************/
  56. void GpsTaskTick(unsigned char reset)
  57. {
  58. static unsigned int sucSecCt=0;
  59. if(reset){
  60. sucSecCt=0;
  61. return;
  62. }
  63. if(sutGpsInfo.Updata==1){
  64. if(g_uiGpsStat==0){
  65. sutGpsInfo.isGpsWork=0;
  66. sutGpsInfo.isGpsValid=0;
  67. sutGpsInfo.GpsInactiveCt=0;
  68. SlwTrace(INF,"GPS Close------",1);
  69. g_usUart3RecvLen=0;
  70. GPS_PWREN_LOW;
  71. }else{
  72. sutGpsInfo.isGpsWork=0;
  73. sutGpsInfo.isGpsValid=0;
  74. sutGpsInfo.GpsInactiveCt=0;
  75. GPS_PWREN_HIGH;
  76. SlwTrace(INF,"GPS open------",1);
  77. }
  78. sutGpsInfo.Updata=0;
  79. }
  80. //GPS Uart消息处理
  81. if(g_usUart3RecvLen)
  82. {
  83. process_nema((char *)RxBuffer3);
  84. g_usUart3RecvLen=0;
  85. }
  86. //===========以下控制每秒执行一次============
  87. if(os_time_get() < sucSecCt) return;
  88. sucSecCt=os_time_get()+100;
  89. //////////////////20170112////////////////////
  90. GpsCtrlSendPos();//里面涉及到鉴权,所以得跑起来 //以及GPS上传时间
  91. }
  92. void AtQuery()
  93. {
  94. static unsigned char send_sucCt=0;
  95. switch(send_sucCt){
  96. case 0:
  97. //ModemSendAT("AT+POC=509\r\n");
  98. break;
  99. case 1:
  100. ModemSendAT("AT+CSQ\r\n");
  101. break;
  102. case 2:
  103. ModemSendAT("AT^SYSINFO\r\n");
  104. break;
  105. }
  106. if(++send_sucCt>2) send_sucCt=0;
  107. }