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
Revision 28:4d9509e3b1cf, committed 2014-04-08
- Comitter:
- mazgch
- Date:
- Tue Apr 08 14:11:03 2014 +0000
- Parent:
- 27:e35f2118368f
- Child:
- 29:53d346010624
- Commit message:
- collect more information
Changed in this revision
| MDM.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MDM.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MDM.cpp Tue Apr 08 13:53:27 2014 +0000
+++ b/MDM.cpp Tue Apr 08 14:11:03 2014 +0000
@@ -27,7 +27,6 @@
MDMParser::MDMParser(void)
{
-
// device info
_model = MODEL_UNKNOWN;
_sim = SIM_UNKNOWN;
@@ -197,19 +196,19 @@
if ((type == TYPE_UNKNOWN) && model) {
if (strstr(buf, "SARA-G350")) {
*model = MODEL_SARA_G350;
- TRACE("Identified Model: SARA-G350 2G\n");
+ /*TRACE("Identified Model: SARA-G350 2G\n")*/;
} else if (strstr(buf, "LISA-U200")) {
*model = MODEL_LISA_U200;
- TRACE("Identified Model: LISA-U200 2G/3G\n");
+ /*TRACE("Identified Model: LISA-U200 2G/3G\n")*/;
} else if (strstr(buf, "LISA-C200")) {
*model= MODEL_LISA_C200;
- TRACE("Identified Model: LISA-C200 CDMA\n");
+ /*TRACE("Identified Model: LISA-C200 CDMA\n")*/;
}
}
return WAIT;
}
-bool MDMParser::init(const char* pin)
+bool MDMParser::init(const char* pin, DevStatus* status)
{
for(int i = 0; i < 5; i++) {
// check interface and disable local echo
@@ -306,6 +305,14 @@
sendFormated("AT+CIMI\r\n");
if (OK != waitFinalResp(_cbCIMI, _imsi))
return false;
+ if (status)
+ {
+ status->model = _model;
+ status->sim = _sim;
+ status->ccid = _ccid;
+ status->imsi = _imsi;
+ status->imei = _imei;
+ }
return true;
}
@@ -313,7 +320,7 @@
{
if ((type == TYPE_PLUS) && ccid){
if (sscanf(buf, "\r\n+CCID: %[^\r]\r\n", ccid) == 1)
- TRACE("Got CCID: %s\n", ccid);
+ /*TRACE("Got CCID: %s\n", ccid)*/;
}
return WAIT;
}
@@ -322,7 +329,7 @@
{
if ((type == TYPE_UNKNOWN) && imei){
if (sscanf(buf, "\r\n%[^\r]\r\n%*[^\r]\r\n", imei) == 1)
- TRACE("Got IMEI: %s\n", imei);
+ /*TRACE("Got IMEI: %s\n", imei)*/;
}
return WAIT;
}
@@ -331,7 +338,7 @@
{
if ((type == TYPE_UNKNOWN) && imei){
if (sscanf(buf, "\r\n%[^\r]\r\n", imei) == 1)
- TRACE("Got IMEI: %s\n", imei);
+ /*TRACE("Got IMEI: %s\n", imei)*/;
}
return WAIT;
}
@@ -340,12 +347,12 @@
{
if ((type == TYPE_UNKNOWN) && imsi) {
if (sscanf(buf, "\r\n%[^\r]\r\n", imsi) == 1)
- TRACE("Got IMSI: %s\n", imsi);
+ /*TRACE("Got IMSI: %s\n", imsi)*/;
}
return WAIT;
}
-bool MDMParser::checkNetStatus(Status* info /*= NULL*/)
+bool MDMParser::checkNetStatus(NetStatus* status /*= NULL*/)
{
// check registration
sendFormated("AT+CREG?\r\n");
@@ -374,12 +381,12 @@
sendFormated("AT+CSQ\r\n");
if (OK != waitFinalResp())
return false;
- if (info) {
- info->num = _num;
- info->opr = _opr;
- info->rssi = _rssi;
- info->net = _net;
- info->act = _act;
+ if (status) {
+ status->num = _num;
+ status->opr = _opr;
+ status->rssi = _rssi;
+ status->net = _net;
+ status->act = _act;
}
return true;
}
@@ -411,7 +418,7 @@
return ip;
}
-bool MDMParser::join(const char* apn, const char* user /*= NULL*/, const char* password /*= NULL*/)
+bool MDMParser::join(const char* apn /*= NULL*/, const char* user /*= NULL*/, const char* password /*= NULL*/)
{
if (_model == MODEL_LISA_C200) {
#ifdef TODO // TODO implement
--- a/MDM.h Tue Apr 08 13:53:27 2014 +0000
+++ b/MDM.h Tue Apr 08 14:11:03 2014 +0000
@@ -42,9 +42,13 @@
#define SOCKET_ERROR -1
#define SOCKET_OK 0
typedef uint32_t IP;
+
+ typedef enum { MODEL_UNKNOWN, MODEL_SARA_G350, MODEL_LISA_U200, MODEL_LISA_C200 } Model;
+ typedef enum { SIM_UNKNOWN, SIM_PIN, SIM_READY } Sim;
+ typedef struct { Model model; Sim sim; const char* imsi; const char* imei; const char* ccid; } DevStatus;
typedef enum { NET_UNKNOWN, NET_DENIED, NET_NONE, NET_HOME, NET_ROAMING } Net;
typedef enum { ACT_UNKNOWN, ACT_GSM, ACT_EDGE, ACT_UTRAN, ACT_CDMA } AcT;
- typedef struct { const char* num; const char* opr; int rssi; Net net; AcT act; } Status;
+ typedef struct { const char* num; const char* opr; int rssi; Net net; AcT act; } NetStatus;
MDMParser(void);
@@ -65,11 +69,11 @@
return waitFinalResp((_CALLBACKPTR)cb, (void*)param, timeout_ms);
}
// network
- bool init(const char* pin = NULL);
- bool checkNetStatus(Status* info = NULL);
+ bool init(const char* pin = NULL, DevStatus* status = NULL);
+ bool checkNetStatus(NetStatus* status = NULL);
bool powerOff(void);
// internet connection
- bool join(const char* apn, const char* user = NULL, const char* password = NULL);
+ bool join(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
bool disconnect(void);
bool gethostbyname(const char* host, IP* ip);
// socket interface
@@ -95,8 +99,6 @@
static int _parseFormated(Pipe<char>* pipe, int len, const char* fmt);
virtual int _send(const void* buf, int len) = 0;
private:
- typedef enum { MODEL_UNKNOWN, MODEL_SARA_G350, MODEL_LISA_U200, MODEL_LISA_C200 } Model;
- typedef enum { SIM_UNKNOWN, SIM_PIN, SIM_READY } Sim;
static int _cbATI(int type, const char* buf, int len, Model* model);
static int _cbCIMI(int type, const char* buf, int len, char* imsi);
static int _cbUDNSRN(int type, const char* buf, int len, IP* ip);
