Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 6 months ago.
[C027] CellLocate results are different , using the tool(m-center) and using the mbed code.Why?
When CellLocate is done with mbed-C027, the results are different when using the tool and when using the mbed code.Why?
- tool result:35.7037449,139.7623999
- mbed result: latitude: 36.00000, longitude: 138.00000
Are they rounded off?
I think the cause is a parser of MDM.cpp. Is not there a mistake when getting floating point with sscanf? It is the following part.
}else if (sscanf(cmd, "UULOC: %d/%d/%d,%d:%d:%d.%*d,%f,%f,%d,%d,%d,%d,%d,%d,%d,%*d,%*d",\ &_loc[0].time.tm_mday, &_loc[0].time.tm_mon, &_loc[0].time.tm_year, &_loc[0].time.tm_hour, &_loc[0].time.tm_min, &_loc[0].time.tm_sec,\ &_loc[0].latitude, &_loc[0].longitude, &_loc[0].altitutude, &_loc[0].uncertainty, &_loc[0].speed, &_loc[0].direction, &_loc[0].verticalAcc, \ &b, &_loc[0].svUsed) == 15) { TRACE("Parsed UULOC position at index 0\r\n");
Original source is https://developer.mbed.org/teams/ublox/code/C027_Support/
[1] is mbed run log [2] is m-center log [3] is source code
[1]
Modem::wakeup Modem::init Modem::devStatus Device: LISA-U2 Power Save: Disabled CCID: 8981100023561854336 IMEI: 352648069548865 IMSI: 440103148290527 Manufacturer: u-blox Model: LISA-U200 Version: 22.90,A01.01 Modem::register Modem::netStatus CSD Registration: Home PSD Registration: Home Access Technology: 3G Signal Strength: -69 dBm Bit Error Rate: 25 Operator: NTT DOCOMO Location Area Code: 00EC Cell ID: 0448402F Modem::join Modem:IP 100.96.76.190 Make a Http Post Request Socket Recv "HTTP/1.1 200 OK Server: nginx/1.11.12 Date: Thu, 11 May 2017 01:58:12 GMT Content-Type: text/plain Content-Length: 14 Connection: close Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT Accept-Ranges: bytes Cache-Control: max-age=36000 Expires: Thu, 1" Testing TCP sockets with ECHO server Socket Send 31 " TCP Socket Hello World End " Socket Recv 63 "u-blox AG TCP/UDP test service TCP Socket Hello World End " Testing UDP sockets with ECHO server Socket SendTo echo.u-blox.com:7 195.34.89.241 31 " UDP Socket Hello World End " Socket RecvFrom 195.34.89.241:7 31 " UDP Socket Hello World End " Modem::disconnect Ussd Send Command *130# SMS and GPS Loop Command not supported CellLocate Request Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... CellLocate Request CellLocate position received, sensor_used: 0, latitude: 0.00000, longitude: 0.00000, altitute: 0 CellLocate Request CellLocate position received, sensor_used: 0, latitude: 36.00000, longitude: 138.00000, altitute: 0 <------------------------------------------------------------------------*1 CellLocate Request CellLocate position received, sensor_used: 0, latitude: 36.00000, longitude: 138.00000, altitute: 0 CellLocate Request CellLocate position received, sensor_used: 0, latitude: 36.00000, longitude: 138.00000, altitute: 0 CellLocate Request Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate... Waiting for CellLocate...
[2]
AT+UGAOP="eval1-les.services.u-blox.com",46434,1000,0 OK AT+ULOCCELL=0 OK AT+ULOC=2,2,1,100,5000 OK +UULOC: 01/01/2004,00:03:19.000,0.0000000,0.0000000,0,20000000,0,0,0,0,0,0,0 AT+UGAOP="eval1-les.services.u-blox.com",46434,1000,0 OK AT+ULOCCELL=0 OK AT+ULOC=2,2,1,100,5000 OK +UULOC: 11/05/2017,02:09:53.000,35.7037449,139.7623999,50,1000,0,0,0,2,0,0,0 <-------------------------------*2
[3]
int main(void) { /* int ret; #ifdef LARGE_DATA char buf[2048] = ""; #else char buf[512] = ""; #endif */ // Create the GPS object #if 1 // use GPSI2C class GPSI2C gps; #else // or GPSSerial class GPSSerial gps; #endif /* // Create the modem object MDMSerial mdm; // use mdm(D1,D0) if you connect the cellular shield to a C027 //mdm.setDebug(4); // enable this for debugging issues // initialize the modem MDMParser::DevStatus devStatus = {}; MDMParser::NetStatus netStatus = {}; bool mdmOk = mdm.init(SIMPIN, &devStatus); mdm.dumpDevStatus(&devStatus); */ int ret; char buf[256] = ""; //give time to module for powering up (ms) wait_ms(1000); // Create the modem object MDMSerial mdm; mdm.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS); wait(5); //mdm.setDebug(4); // enable this for debugging issues // initialize the modem MDMParser::DevStatus devStatus = {}; MDMParser::NetStatus netStatus = {}; bool mdmOk = mdm.init(SIMPIN, &devStatus); mdm.dumpDevStatus(&devStatus); if (mdmOk) { // wait until we are connected mdmOk = mdm.registerNet(&netStatus); mdm.dumpNetStatus(&netStatus); } if (mdmOk) { // join the internet connection MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD); if (ip == NOIP) printf("Not able to join network"); else { mdm.dumpIp(ip); printf("Make a Http Post Request\r\n"); int socket = mdm.socketSocket(MDMParser::IPPROTO_TCP); if (socket >= 0) { mdm.socketSetBlocking(socket, 10000); if (mdm.socketConnect(socket, "mbed.org", 80)) { const char http[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n"; mdm.socketSend(socket, http, sizeof(http)-1); ret = mdm.socketRecv(socket, buf, sizeof(buf)-1); if (ret > 0) printf("Socket Recv \"%*s\"\r\n", ret, buf); mdm.socketClose(socket); } mdm.socketFree(socket); } int port = 7; const char* host = "echo.u-blox.com"; MDMParser::IP ip = mdm.gethostbyname(host); char data[] = "\r\nxxx Socket Hello World\r\n" "End\r\n"; printf("Testing TCP sockets with ECHO server\r\n"); socket = mdm.socketSocket(MDMParser::IPPROTO_TCP); if (socket >= 0) { mdm.socketSetBlocking(socket, 10000); if (mdm.socketConnect(socket, host, port)) { memcpy(data, "\r\nTCP", 5); ret = mdm.socketSend(socket, data, sizeof(data)-1); if (ret == sizeof(data)-1) { printf("Socket Send %d \"%s\"\r\n", ret, data); } ret = mdm.socketRecv(socket, buf, sizeof(buf)-1); if (ret >= 0) { printf("Socket Recv %d \"%.*s\"\r\n", ret, ret, buf); } mdm.socketClose(socket); } mdm.socketFree(socket); } printf("Testing UDP sockets with ECHO server\r\n"); socket = mdm.socketSocket(MDMParser::IPPROTO_UDP, port); if (socket >= 0) { mdm.socketSetBlocking(socket, 10000); memcpy(data, "\r\nUDP", 5); ret = mdm.socketSendTo(socket, ip, port, data, sizeof(data)-1); if (ret == sizeof(data)-1) { printf("Socket SendTo %s:%d " IPSTR " %d \"%s\"\r\n", host, port, IPNUM(ip), ret, data); } ret = mdm.socketRecvFrom(socket, &ip, &port, buf, sizeof(buf)-1); if (ret >= 0) { printf("Socket RecvFrom " IPSTR ":%d %d \"%.*s\" \r\n", IPNUM(ip),port, ret, ret,buf); } mdm.socketFree(socket); } // disconnect mdm.disconnect(); } // http://www.geckobeach.com/cellular/secrets/gsmcodes.php // http://de.wikipedia.org/wiki/USSD-Codes const char* ussd = "*130#"; // You may get answer "UNKNOWN APPLICATION" printf("Ussd Send Command %s\r\n", ussd); ret = mdm.ussdCommand(ussd, buf); if (ret > 0) printf("Ussd Got Answer: \"%s\"\r\n", buf); } printf("SMS and GPS Loop\r\n"); char link[128] = ""; unsigned int i = 0xFFFFFFFF; const int wait = 100; bool abort = false; #ifdef CELLOCATE const int sensorMask = 3; // Hybrid: GNSS + CellLocate const int timeoutMargin = 5; // seconds const int submitPeriod = 60; // 1 minutes in seconds const int targetAccuracy = 1; // meters unsigned int j = submitPeriod * 1000/wait; bool cellLocWait = false; MDMParser::CellLocData loc; //Token can be released from u-blox site, when you got one replace "TOKEN" below //// if (!mdm.cellLocSrvHttp("TOKEN")) if (!mdm.cellLocSrvTcp("TOKEN")) mdm.cellLocSrvUdp(); /// mdm.cellLocConfigSensor(1); mdm.cellLocConfig(1); // Deep scan mode +ULOCCELL //mdm.cellUnsolIndication(1); #endif DigitalOut led(LED1); while (!abort) { led = !led; #ifndef CELLOCATE while ((ret = gps.getMessage(buf, sizeof(buf))) > 0) { int len = LENGTH(ret); //printf("NMEA: %.*s\r\n", len-2, msg); if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6)) { // talker is $GA=Galileo $GB=Beidou $GL=Glonass $GN=Combined $GP=GPS if ((buf[0] == '$') || buf[1] == 'G') { #define _CHECK_TALKER(s) ((buf[3] == s[0]) && (buf[4] == s[1]) && (buf[5] == s[2])) if (_CHECK_TALKER("GLL")) { double la = 0, lo = 0; char ch; if (gps.getNmeaAngle(1,buf,len,la) && gps.getNmeaAngle(3,buf,len,lo) && gps.getNmeaItem(6,buf,len,ch) && ch == 'A') { printf("GPS Location: %.5f %.5f\r\n", la, lo); sprintf(link, "I am here!\n" "https://maps.google.com/?q=%.5f,%.5f", la, lo); } } else if (_CHECK_TALKER("GGA") || _CHECK_TALKER("GNS") ) { double a = 0; if (gps.getNmeaItem(9,buf,len,a)) // altitude msl [m] printf("GPS Altitude: %.1f\r\n", a); } else if (_CHECK_TALKER("VTG")) { double s = 0; if (gps.getNmeaItem(7,buf,len,s)) // speed [km/h] printf("GPS Speed: %.1f\r\n", s); } } } } #endif #ifdef CELLOCATE if (mdmOk && (j++ == submitPeriod * 1000/wait)) { j=0; printf("CellLocate Request\r\n"); /// mdm.cellLocRequest(sensorMask, submitPeriod-timeoutMargin, targetAccuracy); mdm.cellLocRequest(MDMParser::CELL_LOCATE, 15, 1, MDMParser::CELL_DETAILED, 1); cellLocWait = true; } /// if (cellLocWait && mdm.cellLocGet(&loc)){ if (cellLocWait && mdm.cellLocGetData(&loc)){ cellLocWait = false; printf("CellLocate position received, sensor_used: %d, \r\n", loc.sensor ); printf(" latitude: %0.5f, longitude: %0.5f, altitute: %d\r\n", loc.latitude, loc.longitude, loc.altitutude); if (loc.sensor == 1) printf(" uncertainty: %d, speed: %d, direction: %d, vertical_acc: %d, satellite used: %d \r\n", loc.uncertainty,loc.speed,loc.direction,loc.verticalAcc,loc.svUsed); if (loc.sensor == 1 || loc.sensor == 2) sprintf(link, "I am here!\n" "https://maps.google.com/?q=%.5f,%.5f", loc.latitude, loc.longitude); } if (cellLocWait && (j%100 == 0 )) printf("Waiting for CellLocate...\r\n"); #endif Thread::wait(wait); } printf ("GNSS Power Off\r\n"); gps.powerOff(); printf ("Modem Power Off\r\n"); mdm.powerOff(); return 0; }
1 Answer
5 years, 11 months ago.
Hey U got any answer if you still able to see this quest?? I am facing same problem here.