Add detection of LISA-C to select CDMA protocol when using serial port.

Make link monitor compatible with CDMA (no AT+COPS).
pull/132/head
mazgch 2013-12-17 11:35:23 +01:00
parent 6a9083527e
commit 6b9f2079f1
3 changed files with 64 additions and 12 deletions

View File

@ -33,20 +33,24 @@ using std::sscanf;
LinkMonitor::LinkMonitor(ATCommandsInterface* pIf) : m_pIf(pIf), m_rssi(0), m_registrationState(REGISTRATION_STATE_UNKNOWN), m_bearer(BEARER_UNKNOWN) LinkMonitor::LinkMonitor(ATCommandsInterface* pIf) : m_pIf(pIf), m_rssi(0), m_registrationState(REGISTRATION_STATE_UNKNOWN), m_bearer(BEARER_UNKNOWN)
{ {
m_gsm = true;
} }
int LinkMonitor::init() int LinkMonitor::init(bool gsm)
{ {
// we need to make sure that we setup the operator selection to be in 'numeric' format. m_gsm = gsm;
// i.e. it is made up of a network and country code when returned by the modem e.g. Operator = 23415. This allows easy logic parsing for if (m_gsm)
// setting up other network parameters in future.
DBG("LinkMonitor::init() being called. This should only happen once: executinging AT+COPS=0,2");
int ret = m_pIf->executeSimple("AT+COPS=0,2", NULL, DEFAULT_TIMEOUT); //Configure to set the operator string to Country Code and mobile network code
if(ret != OK)
{ {
WARN(" NET_PROTOCOL error from sending the AT+COPS command to the modem. "); // we need to make sure that we setup the operator selection to be in 'numeric' format.
return NET_PROTOCOL; // i.e. it is made up of a network and country code when returned by the modem e.g. Operator = 23415. This allows easy logic parsing for
// setting up other network parameters in future.
DBG("LinkMonitor::init() being called. This should only happen once: executinging AT+COPS=0,2");
int ret = m_pIf->executeSimple("AT+COPS=0,2", NULL, DEFAULT_TIMEOUT); //Configure to set the operator string to Country Code and mobile network code
if(ret != OK)
{
WARN(" NET_PROTOCOL error from sending the AT+COPS command to the modem. ");
return NET_PROTOCOL;
}
} }
return OK; return OK;
} }
@ -136,7 +140,7 @@ int LinkMonitor::getState(int* pRssi, REGISTRATION_STATE* pRegistrationState, BE
m_rssi = 0; m_rssi = 0;
m_registrationState = REGISTRATION_STATE_UNKNOWN; m_registrationState = REGISTRATION_STATE_UNKNOWN;
m_bearer = BEARER_UNKNOWN; m_bearer = BEARER_UNKNOWN;
int ret = m_pIf->execute("AT+CREG?;+COPS?;+CSQ", this, NULL, DEFAULT_TIMEOUT); //Configure to get registration info & get it; get signal quality int ret = m_pIf->execute(m_gsm ? "AT+CREG?;+COPS?;+CSQ" : "AT+CREG?;+CSQ", this, NULL, DEFAULT_TIMEOUT); //Configure to get registration info & get it; get signal quality
if(ret != OK) if(ret != OK)
{ {
return NET_PROTOCOL; return NET_PROTOCOL;

View File

@ -39,7 +39,7 @@ public:
/** Initialize monitor /** Initialize monitor
*/ */
int init(); int init(bool gsm = true);
/** Registration State /** Registration State
*/ */
@ -82,6 +82,7 @@ private:
ATCommandsInterface* m_pIf; ATCommandsInterface* m_pIf;
int m_rssi; int m_rssi;
bool m_gsm;
REGISTRATION_STATE m_registrationState; REGISTRATION_STATE m_registrationState;
BEARER m_bearer; BEARER m_bearer;

View File

@ -45,6 +45,36 @@ UbloxModem::UbloxModem(IOStream* atStream, IOStream* pppStream) :
{ {
} }
class AtiProcessor : public IATCommandsProcessor
{
public:
AtiProcessor()
{
i = 0;
str[0] = '\0';
}
const char* getInfo(void) { return str; }
private:
virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line)
{
int l = strlen(line);
if (i + l + 2 > sizeof(str))
return NET_OVERFLOW;
if (i) str[i++] = ',';
strcat(&str[i], line);
i += l;
return OK;
}
virtual int onNewEntryPrompt(ATCommandsInterface* pInst)
{
return OK;
}
protected:
char str[256];
int i;
};
class CREGProcessor : public IATCommandsProcessor class CREGProcessor : public IATCommandsProcessor
{ {
public: public:
@ -309,6 +339,22 @@ int UbloxModem::init()
} }
ATCommandsInterface::ATResult result; ATCommandsInterface::ATResult result;
AtiProcessor atiProcessor;
do
{
ret = m_at.execute("ATI", &atiProcessor, &result);
}
while (ret != OK);
{
const char* info = atiProcessor.getInfo();
DBG("Modem Identification [%s]", info);
if (strstr(info, "LISA-C200"))
{
m_gsm = false; // it is CDMA modem
m_onePort = true; // force use of only one port
}
}
CREGProcessor cregProcessor(m_gsm); CREGProcessor cregProcessor(m_gsm);
//Wait for network registration //Wait for network registration
do do
@ -393,6 +439,7 @@ int UbloxModem::getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegis
if(!m_linkMonitorInit) if(!m_linkMonitorInit)
{ {
ret = m_linkMonitor.init(); ret = m_linkMonitor.init();
ret = m_linkMonitor.init(m_gsm);
if(ret) if(ret)
{ {
return ret; return ret;