123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /********************************************************************************
- * File Name: MC8332GpsTask.h
- * Function Describe: Header file for MC8332GpsTask.c
- * Explain:
- * Writer:
- * Date: 2016-3-11
- *******************************************************************************/
- #include "includes.h"
- unsigned int Mododrex_Net;
- signed int netshowvalue=-1;
- FOTA_UPDATE fota_update;
- char *FindContentByChar( char *src,char c, char index,char *dest)
- {
- char i;
- char j=0;
- char *p=dest;
- for(i=0;i<strlen(src);i++)
- {
- if(src[i]==c)j++;
- if(j==index){
- p=&src[i+1];
- return p;
- }
- }
- return NULL;
- }
- void AtHandle(char *pMsg)
- {
- int csq;
- short targetIndex;
- unsigned char tempSocket,i,temp;
- unsigned short tempLen;
- char buf[80]="\r\n";
- char bufTemp[3];
- char buf3[40];//////////////////////////
- STATUE ipStatus;
- char *p=NULL;
-
-
- if(0==ModemStrCmp(pMsg,"+CSQ:"))
- {
-
- //UpdateCsqValue(GetCSQ(pMsg));
- g_iCSQ=GetCSQ(pMsg);
- }else if(0==ModemStrCmp(pMsg, "+CCLK:"))
- {//+CCLK: "17/09/28,04:48:35"
- //+CCLK: "80/01/06,00:10:44"
- //+CCLK: "17/10/19,07:22:35"
- g_usModeYTime=atoi(&pMsg[8]);
- g_usModemTime=atoi(&pMsg[11]);
- g_usModeDTime=atoi(&pMsg[14]);
- g_usModeHTime=atoi(&pMsg[17])+8;
- if(g_usModeHTime >= 24) g_usModeHTime -= 24;
- g_usModeMTime=atoi(&pMsg[20]);
- g_usModeSTime=atoi(&pMsg[23]);
- //SetTime(g_usModeHTime, g_usModeMTime, g_usModeSTime);//保存下来,以便下次启动,没登陆前可以使用本地时间显示
-
- SlwTrace(INF, "UpdateTime",1);
- }else if(0==ModemStrCmp(pMsg, "+POC:START"))
- {
- sutPocStatus.modemRstFlag=1;
- sutPocStatus.ModemInactiveCt=0;//当模块重启后重新计数串口通讯异常计数器
- }else if(0==ModemStrCmp(pMsg, "+COPS")){
- p=FindContentByChar(pMsg,',',3,buf);
- if(NULL!=p){
- netshowvalue=atoi(p);
- }
- if(netshowvalue==7){
- netshowvalue=4;
- }
- }
-
-
- }
- /************************************************
- 每10ms处理一次
- **************************************************/
- void GpsTaskTick(unsigned char reset)
- {
- static unsigned int sucSecCt=0;
- if(reset){
- sucSecCt=0;
- return;
- }
- if(sutGpsInfo.Updata==1){
- if(g_uiGpsStat==0){
- sutGpsInfo.isGpsWork=0;
- sutGpsInfo.isGpsValid=0;
- sutGpsInfo.GpsInactiveCt=0;
- SlwTrace(INF,"GPS Close------",1);
- g_usUart3RecvLen=0;
- GPS_PWREN_LOW;
- }else{
- sutGpsInfo.isGpsWork=0;
- sutGpsInfo.isGpsValid=0;
- sutGpsInfo.GpsInactiveCt=0;
- GPS_PWREN_HIGH;
- SlwTrace(INF,"GPS open------",1);
- }
- sutGpsInfo.Updata=0;
- }
-
- //GPS Uart消息处理
- if(g_usUart3RecvLen)
- {
-
- process_nema((char *)RxBuffer3);
- g_usUart3RecvLen=0;
- }
-
- //===========以下控制每秒执行一次============
- if(os_time_get() < sucSecCt) return;
- sucSecCt=os_time_get()+100;
-
- //////////////////20170112////////////////////
- GpsCtrlSendPos();//里面涉及到鉴权,所以得跑起来 //以及GPS上传时间
- }
-
- void AtQuery()
- {
- static unsigned char send_sucCt=0;
- if(g_ucGtMode==1)return;
- unsigned char QueryTime=2;
-
- if(sutPocStatus.FirstLogined) QueryTime=9;
- // switch(send_sucCt){
- //
- // case 0:
- // ModemSendAT("AT+CSQ\r\n");
- // break;
- // case 1:
- // ModemSendAT("AT+COPS?\r\n");
- // break;
- // }
- if(++send_sucCt>QueryTime) {
- ModemSendAT("AT+CSQ\r\n");
- os_dly_wait(1);
- ModemSendAT("AT+COPS?\r\n");
- send_sucCt=0;
- }
-
- }
|