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.
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Diff: modem.cpp
- Revision:
- 31:c84fc6d8eaa3
- Parent:
- 30:7e90ddd7ed12
- Child:
- 32:dff4858bdf37
--- a/modem.cpp Mon Dec 24 02:01:38 2018 +0000
+++ b/modem.cpp Tue Jan 01 15:44:24 2019 +0000
@@ -26,7 +26,7 @@
int targetIndex = 0;
bool havefullmatch = false;
char captured[32];
- memset (captured,0,sizeof(captured));
+ memset(captured,0,sizeof(captured));
Timer t;
t.start();
uint32_t startmillis = t.read_ms();
@@ -81,15 +81,15 @@
ATwaitForWord("OK",ATTIMEOUT_SHORT);
//PRIORITISE 2G connection (reason being uses less power in some instances and can get cell tower tirangulation)
- ATsendCMD("AT+QCFG=\"nwscanseq\",1"); //2G priority
- //ATsendCMD("AT+QCFG=\"nwscanseq\",2"); //3G priority
+ //ATsendCMD("AT+QCFG=\"nwscanseq\",1"); //2G priority
+ ATsendCMD("AT+QCFG=\"nwscanseq\",2"); //3G priority
//ATsendCMD("AT+QCFG=\"nwscanseq\",0"); //AUTO
ATwaitForWord("OK",ATTIMEOUT_SHORT);
//CONNECTION TYPE
//ATsendCMD("AT+QCFG=\"nwscanmode\",1"); //2G only connection
- //ATsendCMD("AT+QCFG=\"nwscanmode\",2"); //3G only connection
- //ATwaitForWord("OK",ATTIMEOUT_SHORT);
+ ATsendCMD("AT+QCFG=\"nwscanmode\",2"); //3G only connection
+ ATwaitForWord("OK",ATTIMEOUT_SHORT);
return true;
} else {
@@ -139,11 +139,6 @@
{
//CHECK WE ARE NOT ALREADY ON NETOWRK
if (!GLOBAL_registeredOnNetwork) {
-
- ATsendCMD("AT+QCFG=\"nwscanseq\",1"); //2G priority
- //ATsendCMD("AT+QCFG=\"nwscanseq\",2"); //3G priority
- //ATsendCMD("AT+QCFG=\"nwscanseq\",0"); //AUTO
- ATwaitForWord("OK",ATTIMEOUT_SHORT);
int attempt = 0;
Timer t;
@@ -222,7 +217,7 @@
led1 = 0;
if ( (matchCount = _uart.scanf(",\"%d#%[^#]",USSDmessageIndex,ATinBuffer) ) > 0 ) {
if (USSDmessageIndex == messageIndex) {
- //NEED TO GET THIS WORKING SO WE KNOW WE ARE DEALING WITH THE RIGT MESSAGE
+ //NEED TO GET THIS WORKING SO WE KNOW WE ARE DEALING WITH THE RIGHT MESSAGE
//MOVE THE BELOW INTO THIS IF STAEMEBNTS
}
led1 = 1;
@@ -274,6 +269,7 @@
bool haveGPSFix = false;
bool haveCellFix = false;
char locDataOut[100];
+ memset(locDataOut,0,sizeof(locDataOut));
Timer t;
t.start();
uint32_t startmillis;
@@ -358,8 +354,8 @@
ATsendCMD("AT+QENG=\"servingcell\"");
if (ATwaitForWord("+QENG: \"servingcell\",\"NOCONN\",",ATTIMEOUT_SHORT)) {
if ((matchCount = _uart.scanf("\"%[^\"]\",%d,%d,%[^,],%[^,]",&type,&mcc,&mnc,&lac,&cellID)) == 5 ) {
- //sprintf(locDataOut,",h:%d.%d.%s.%s\0",mcc,mnc,lac,cellID);
- sprintf(locDataOut,",h:41806.2252.234.30\0");
+ sprintf(locDataOut,",h:%s.%s.%d.%d\0",cellID,lac,mcc,mnc);
+ //sprintf(locDataOut,",h:41806.2252.234.30\0");
haveCellFix = true;
//DEBUG("\ncellOut:%s\n",locDataOut);
}
@@ -381,6 +377,11 @@
}
//RETURN
+ if (accuracy == 0) {
+ sprintf(locDataOut,"\0");
+ } else if (!haveGPSFix && !haveCellFix) {
+ sprintf(locDataOut,",g:0\0");
+ }
return locDataOut;
}