mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
6a9083527e
commit
6b9f2079f1
|
@ -33,10 +33,13 @@ 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)
|
||||||
|
{
|
||||||
|
m_gsm = gsm;
|
||||||
|
if (m_gsm)
|
||||||
{
|
{
|
||||||
// we need to make sure that we setup the operator selection to be in 'numeric' format.
|
// we need to make sure that we setup the operator selection to be in 'numeric' format.
|
||||||
// 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
|
// 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
|
||||||
|
@ -48,6 +51,7 @@ int LinkMonitor::init()
|
||||||
WARN(" NET_PROTOCOL error from sending the AT+COPS command to the modem. ");
|
WARN(" NET_PROTOCOL error from sending the AT+COPS command to the modem. ");
|
||||||
return NET_PROTOCOL;
|
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue