Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 133:57b208dd96fb
- Parent:
- 131:965a7cbc1e58
- Child:
- 134:2fbd5723e063
--- a/MDM.cpp Wed Nov 11 16:26:19 2015 +0000 +++ b/MDM.cpp Thu Nov 26 09:42:01 2015 +0000 @@ -162,7 +162,7 @@ const char* cmd = buf+3; int a, b, c, d, r; char s[32]; - + // SMS Command --------------------------------- // +CNMI: <mem>,<index> if (sscanf(cmd, "CMTI: \"%*[^\"]\",%d", &a) == 1) { @@ -185,9 +185,19 @@ int socket = _findSocket(a); TRACE("Socket %d: handle %d closed by remote host\r\n", socket, a); if ((socket != SOCKET_ERROR) && _sockets[socket].connected) - _sockets[socket].connected = false; - } - if (_dev.dev == DEV_LISA_C2) { + _sockets[socket].connected = false; + // +UULOC: <date>,<time>,<lat>,<long>,<alt>,<uncertainty>,<speed>, <direction>,<vertical_acc>,<sensor_used>,<SV_used>,<antenna_status>, <jamming_status> + }else if (sscanf(cmd, "UULOC: %d/%d/%d,%d:%d:%d.%*d,%f,%f,%d,%d,%d,%d,%d,%d,%d,%*d,%*d",\ + &_loc.time.tm_mday, &_loc.time.tm_mon, &_loc.time.tm_year, &_loc.time.tm_hour, &_loc.time.tm_min, &_loc.time.tm_sec,\ + &_loc.latitue, &_loc.longitude, &_loc.altitutude, &_loc.uncertainty, &_loc.speed, &_loc.direction, &_loc.verticalAcc, \ + &_loc.sensorUsed, &_loc.svUsed) == 15) { + _loc.time.tm_mon -= 1; + _loc.time.tm_wday=0; + _loc.time.tm_yday=0; + _loc.validData = true; + TRACE("Parsed UULOC position\r\n"); + } + if (_dev.dev == DEV_LISA_C2) { // CDMA Specific ------------------------------------------- // +CREG: <n><SID>,<NID>,<stat> if (sscanf(cmd, "CREG: %*d,%d,%d,%d",&a,&b,&c) == 3) { @@ -512,7 +522,8 @@ { if ((type == TYPE_UNKNOWN) && dev) { if (strstr(buf, "SARA-G35")) *dev = DEV_SARA_G35; - else if (strstr(buf, "LISA-U2")) *dev = DEV_LISA_U2; + else if (strstr(buf, "LISA-U200-03S")) *dev = DEV_LISA_U2_03S; + else if (strstr(buf, "LISA-U2")) *dev = DEV_LISA_U2; else if (strstr(buf, "LISA-C2")) *dev = DEV_LISA_C2; else if (strstr(buf, "SARA-U2")) *dev = DEV_SARA_U2; else if (strstr(buf, "LEON-G2")) *dev = DEV_LEON_G2; @@ -1465,7 +1476,91 @@ } return WAIT; } - +// ---------------------------------------------------------------- +int MDMParser::cellLocSrvHttp (const char* token, const char* server_1, const char* server_2, int days/* = 14*/, \ + int period/* = 4*/, int resolution/* = 1*/) +{ + bool ok = false; + LOCK(); + if (_dev.dev == DEV_LISA_U2_03S || _dev.dev == DEV_SARA_U2 ){ + sendFormated("AT+UGSRV=\"%s\",\"%s\",\"%s\"\r\n", server_1, server_2, token, days, period, resolution); + ok = (RESP_OK == waitFinalResp()); + } else + ok = false; //command not supported by module + UNLOCK(); + return ok; +} + +int MDMParser::cellLocSrvUdp(const char* server_1 /*= "cell-live1.services.u-blox.com"*/, int port /*= 46434*/, \ + int latency/* = 1000*/, int mode/* = 0*/) +{ + bool ok = false; + LOCK(); + if (_dev.dev != DEV_TOBY_L2){ + sendFormated("AT+UGAOP=\"%s\",%d,%d,%d\r\n", server_1, port, latency, mode); + ok = (RESP_OK == waitFinalResp()); + } else + ok = false; //command not supported by module + UNLOCK(); + return ok; +} + +int MDMParser::cellLocUnsolIndication(int mode) +{ + bool ok = false; + LOCK(); + if (_dev.dev == DEV_LISA_U2_03S){ + sendFormated("AT+ULOCIND=%d\r\n", mode); + ok = (RESP_OK == waitFinalResp()); + } else + ok = false; //command not supported by module + UNLOCK(); + return ok; +} + +int MDMParser::cellLocConfigSensor(int scanMode) +{ + bool ok = false; + LOCK(); + if (_dev.dev != DEV_TOBY_L2){ + sendFormated("AT+ULOCCELL=%d\r\n", scanMode); + ok = (RESP_OK == waitFinalResp()); + }else + ok = false; //command not supported by module + UNLOCK(); + return ok; +} + +int MDMParser::cellLocRequest(int sensor, int timeout, int accuracy, int numHypotesis /* =1*/) +{ + bool ok = false; + + LOCK(); + _loc.validData = false; + if (_dev.dev == DEV_LISA_U2_03S){ + sendFormated("AT+ULOC=2,%d,1,%d,%d,%d\r\n", sensor, timeout, accuracy, numHypotesis); + ok = (RESP_OK == waitFinalResp()); + } else if (_dev.dev != DEV_TOBY_L2){ + sendFormated("AT+ULOC=2,%d,1,%d,%d\r\n", sensor, timeout, accuracy); + ok = (RESP_OK == waitFinalResp()); + } + else ok = false; //command not supported by module + + + UNLOCK(); + return ok; +} + +int MDMParser::cellLocGet(CellLocData *data){ + waitFinalResp(NULL,NULL,0); + if (_loc.validData){ + memcpy(data, &_loc, sizeof(_loc)); + _loc.validData = false; + return true; + } + return false; +} + // ---------------------------------------------------------------- bool MDMParser::setDebug(int level) { @@ -1481,7 +1576,7 @@ _DPRINT dprint, void* param) { dprint(param, "Modem::devStatus\r\n"); - const char* txtDev[] = { "Unknown", "SARA-G35", "LISA-U2", "LISA-C2", + const char* txtDev[] = { "Unknown", "SARA-G35", "LISA-U2", "LISA-U2-03S", "LISA-C2", "SARA-U2", "LEON-G2", "TOBY-L2", "MPCI-L2" }; if (status->dev < sizeof(txtDev)/sizeof(*txtDev) && (status->dev != DEV_UNKNOWN)) dprint(param, " Device: %s\r\n", txtDev[status->dev]); @@ -1777,4 +1872,4 @@ int MDMUsb::getLine(char* buffer, int length) { return NOT_FOUND; } -#endif +#endif \ No newline at end of file