gpsCtl.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #include "includes.h"
  2. SUT_MESS sutMess;
  3. //GPS_DEF gpsInfo;
  4. const unsigned short GPS_TimeTable[GPS_TABLE_NUM]={0,5,10,15,30,60,120,300};
  5. void gpsDataInit(void){
  6. //memset((unsigned char *)&sutMess, 0, sizeof(SUT_MESS));
  7. memset((unsigned char *)&sutGpsInfo, 0, sizeof(SUT_GPS_INF));
  8. GPSInit();
  9. GpsTimeUpdate();
  10. }
  11. unsigned short getGPSTimeValue(unsigned char index){
  12. return GPS_TimeTable[index];
  13. }
  14. static unsigned char gpsCheckCnt=1;//榛樿�寮€鏈烘煡璇�竴娆?
  15. void gpsCheckInfo(void){//鏌ヨ�GPS淇℃伅
  16. gpsCheckCnt++;
  17. }
  18. /*鎺у埗鏌ヨ�GPS鐘舵€?
  19. dly:鎺ュ彛琚�皟鐢ㄧ殑棰戠巼锛屽崟浣峬s*/
  20. /*
  21. AT+POC=11000032322e32333231312c3130332e3132333132312c352c32302c362e302c0425242
  22. 52600
  23. 其中 32322e32333231312c3130332e3132333132312c352c32302c362e302c042524252600 表示
  24. 北纬 22.23211 东经 103.123121 速度 5km/h,方向角 20 度,精度因子为 6.0,共有 4 颗卫星,
  25. 信噪比分别为 37db, 36db, 37db, 38db。
  26. */
  27. void gpsProCtl(int dly){
  28. static unsigned short cnt=0;
  29. unsigned char GpsDatabuf[100];
  30. unsigned char restohex[20];
  31. unsigned char destohex[40];
  32. if(GPS_TimeTable[newPara.gpsTimeIndex]==0)return;
  33. if(sutApp.gtMode!=0) return;
  34. if(++cnt<(GPS_TimeTable[newPara.gpsTimeIndex]*1000/dly) && gpsCheckCnt==0) return;
  35. cnt=0;
  36. if(sutGpsInfo.g_GpsEnable)msgToModem("AT+GPSRD=\"ALL\"\r\n");
  37. gpsCheckCnt=0;
  38. if(sutGpsInfo.isGpsValid){
  39. snprintf(restohex,sizeof(restohex),"%d.%06d,%d.%06d",sutGpsInfo.latitue/1000000,sutGpsInfo.latitue%1000000,sutGpsInfo.longitue/1000000,sutGpsInfo.longitue%1000000);
  40. AscStrTurnHexStr(restohex,destohex);
  41. snprintf(GpsDatabuf,sizeof(GpsDatabuf),"AT+POC=110000%s2c352c32302c362e302c042524252600\r\n",destohex);
  42. msgAtSend(GpsDatabuf);
  43. //MSG_INFO(1,GpsDatabuf);
  44. }
  45. }
  46. /*
  47. +CGPS:bf,ba,gf,[Lat],[Long]
  48. bf:0 閮ㄦ爣鍏抽棴 1 閮ㄦ爣鎵撳紑
  49. ba:0 閮ㄦ爣鏈�壌鏉?1 閮ㄦ爣宸查壌鏉?
  50. gf:0 GPS鍏抽棴 1 GPS鎵撳紑
  51. Lat: 宸插畾浣嶆墠鏈夛紝瀹氫綅绾�害 搴?搴?宸叉斁澶?000000)
  52. Long: 宸插畾浣嶆墠鏈夛紝瀹氫綅缁忓害 搴?搴?宸叉斁澶?000000)
  53. msg=bf,ba,gf,[Lat],[Long]
  54. */
  55. void proGpsMsg(char *msg){
  56. // int i;
  57. // unsigned char needCloseGps=0;
  58. // unsigned char needOpenGps=0;
  59. // unsigned char dotNum=0,lach=0;
  60. // unsigned char bblF=0,bbAuth=0,gpsF=0;
  61. // unsigned int Lat=0,Long=0;
  62. // //鑾峰彇閮ㄦ爣寮€鍏崇姸鎬?
  63. // bblF=atoi(msg);
  64. // for(i=0;i<strlen(msg);i++){
  65. // if(msg[i]==',') dotNum++;
  66. // if(lach==','){
  67. // if(dotNum==1) bbAuth=atoi(&msg[i]);
  68. // else if(dotNum==2) gpsF=atoi(&msg[i]);
  69. // else if(dotNum==3) Lat=atoi(&msg[i]);
  70. // else if(dotNum==4) Long=atoi(&msg[i]);
  71. // }
  72. // lach=msg[i];
  73. // }
  74. // //浼樺厛鏍规嵁gpsEnable鎵撳紑鎴栧叧闂璆PS
  75. // if(newPara.gpsEnable==0){
  76. // needCloseGps=1;
  77. // }else{
  78. // //鏍规嵁GPS涓婁紶闂撮殧锛屾墦寮€/鍏抽棴GPS
  79. // if(newPara.gpsTimeIndex<GPS_TABLE_NUM){
  80. // if(GPS_TimeTable[newPara.gpsTimeIndex]==0) needCloseGps=1;
  81. // else needOpenGps=1;
  82. // }
  83. // }
  84. // if(needCloseGps!=0 && gpsF!=0){
  85. // MSG_INFO(1, "Shut GPS");
  86. // msgAtSend("AT+SGPS=0\r\n");
  87. // gpsCheckInfo();//妫€鏌ヤ笅鏄�惁鎴愬姛
  88. // }
  89. // if(needOpenGps!=0 && gpsF==0){
  90. // MSG_INFO(1, "Open GPS");
  91. // msgAtSend("AT+SGPS=1\r\n");
  92. // gpsCheckInfo();//妫€鏌ヤ笅鏄�惁鎴愬姛
  93. // }
  94. // //鏍规嵁bubiaoEnable鎵撳紑鎴栧叧闂璆PS
  95. // if(newPara.bubiaoEnable==0){
  96. // if(bblF!=0){
  97. // MSG_INFO(1, "Shut BUBIAO");
  98. // msgAtSend("AT+BUBIAO=0\r\n");
  99. // gpsCheckInfo();//妫€鏌ヤ笅鏄�惁鎴愬姛
  100. // }
  101. // }else{
  102. // if(bblF==0){
  103. // MSG_INFO(1, "Open BUBIAO");
  104. // msgAtSend("AT+BUBIAO=1\r\n");
  105. // gpsCheckInfo();//妫€鏌ヤ笅鏄�惁鎴愬姛
  106. // }
  107. // }
  108. // //鏇存柊鍊?
  109. // gpsInfo.bblF=bblF;
  110. // gpsInfo.bbAuth=bbAuth;
  111. // gpsInfo.Lat=Lat;
  112. // gpsInfo.Long=Long;
  113. // gpsInfo.update++;
  114. // if(Lat==0 && Long==0) gpsInfo.gpsLocated=0;
  115. // else gpsInfo.gpsLocated=1;
  116. }