-
AT+CGNSPWR=1 //打开GPS电源
正常返回“OK”
AT+CGNSPWR=0 //关闭GPS电源
2、AT+CGNSSEQ="RMC"//定义NMEA解析
返回:
“OK”
3、AT+CGNSINF //获取GPS定位信息
返回:
AT+CGPSINF
+CGNSINF:1,1,20151031073440.000,22.275393,113.507882,5.200,0.02,351.3,1,,1.2,1.9,1.5,,12,9,,,46,,
OK
数据内容定义,请查阅“SIM800 Series_GNSS_Application Note V1.00”
-
AT+CGNSURC=1//间隔1S输出定位信息
返回:
+UGNSINF:1,1,20151031073659.000,22.275405,113.507875,4.700,0.04,250.6,1,,1.2,1.9,1.5,,12,9,,,48,,
之后串口就会不断的输出NMEA信息
详细的配置和信息的解析,请查看“SIM800 Series_GNSS_ApplicationNote V1.00”。
定位不成功:
+UGNSINF:1,0,20161105064849.104,,,,0.00,0.0,0,,,,,,4,0,,,38,,
+UGNSINF:1,0,20161105064945.303,,,,726.95,234.9,0,,,,,,7,3,,,45,,
定位成功:
+UGNSINF:1,1,20161105065046.000,22.827863,113.61953,38.100,0.00,242.5,1,,1.3,1.6,0.9,,9,6,,,46,,
+UGNSINF: 1,1,20161105073116.000,22.858005,113.263150,40.900,7.56,166.2,1,,0.9,1.2,0.8,,10,9,,,42,,
{
if((p1 = (char*)strstr((const char*)Uart2_Buf
, "+UGNSINF: 1,1,")), (p1 != NULL)) //寻找开始符
{
if((p2 = (char*)strstr((const char*)p1, "x0dx0a")), (p2 != NULL)) //寻找结束符
{
*p2 = 0;//添加结束符
p2 = strtok((p1), ",");
p2 = (char*)strtok(NULL, ",");
p2 = (char*)strtok(NULL, ",");
UART1_SendString
("时间:");
UART1_SendString
((char *)p2);
UART1_SendLR
();
p2 = (char*)strtok(NULL, ",");
UART1_SendString
("纬度:");
UART1_SendString
((char *)p2);
UART1_SendLR
();
p2 = (char*)strtok(NULL, ",");
UART1_SendString
("经度:");
UART1_SendString
((char *)p2);
UART1_SendLR
();
p2 = (char*)strtok(NULL, ",");
UART1_SendString
("海拔:");
UART1_SendString((char *)p2);
UART1_SendLR();
UART1_SendLR();
CLR_Buf2();
}
}
}