Windows Mobile 获取基站信息(LAC,CellID)
2010-06-01 15:56:00 来源:WEB开发网{
return "-9";
}
bufpos = 0;
strcpy(outbuf,"AT+creg=2");
if (!WriteFile(hCom, outbuf, 10, &nWritten, NULL))
{
return "-10";
}
if (nWritten != 10)
{
return "-11";
}
if (!WaitCommEvent(hCom, &event, NULL))
{
return "-12";
}
while(1)
{
if (!ReadFile(hCom, buf+bufpos, 256 - bufpos, &nRead, NULL))
{
return "-13";
}
if (nRead == 0)
break;
bufpos += nRead;
if (bufpos >= 256)
break;
}
strcpy(outbuf,"AT+creg?");
if (!WriteFile(hCom, outbuf, 9, &nWritten, NULL))
{
return "-14";
}
if (nWritten != 9)
{
return "-15";
}
if (!WaitCommEvent(hCom, &event, NULL))
{
return "-16";
}
while(1)
{
if (!ReadFile(hCom, buf+bufpos, 256 - bufpos, &nRead, NULL))
{
return "-17";
}
if (nRead == 0)
break;
bufpos += nRead;
if (bufpos >= 256)
break;
}
puts(buf);
rildevresult = 0;
if (!EscapeCommFunction(hCom, CLRDTR))
{
return "-4";
}
if (hCom!=NULL)
{
CloseHandle(hCom);
hCom= NULL;
}
char* cregResponse = strpbrk( buf, "CREG" );
return cregResponse;
}
总结:
通过获取基站信息,手机可以实现定位,这对于没有GPS设备的手机来说是一个不错的想法。
更多精彩
赞助商链接