init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Revision 30:7e90ddd7ed12, committed 2018-12-24
- Comitter:
- pathfindr
- Date:
- Mon Dec 24 02:01:38 2018 +0000
- Parent:
- 29:059fc7324328
- Child:
- 31:c84fc6d8eaa3
- Commit message:
- ff
Changed in this revision
| README.md | Show annotated file Show diff for this revision Revisions of this file |
| modem.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/README.md Sun Dec 23 23:50:39 2018 +0000 +++ b/README.md Mon Dec 24 02:01:38 2018 +0000 @@ -15,4 +15,7 @@ 13) make activity broadcast an option in normal lcoation one just total hours 14) does enabling handshaking and auto sleep on the modem save power 15) swap motion_g so that it is actually a mg value -16) test motion start stop times exactly \ No newline at end of file +16) test motion start stop times exactly +17) add extra 1cm to gsm antenna +18) errors while sending causes need to double send ussd command, adds on 5-10 seconds +19) check voltage calibation \ No newline at end of file
--- a/modem.cpp Sun Dec 23 23:50:39 2018 +0000
+++ b/modem.cpp Mon Dec 24 02:01:38 2018 +0000
@@ -139,6 +139,12 @@
{
//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;
t.start();
@@ -267,9 +273,12 @@
flushSerial();
bool haveGPSFix = false;
bool haveCellFix = false;
-
char locDataOut[100];
-
+ Timer t;
+ t.start();
+ uint32_t startmillis;
+ uint32_t runtime;
+
if (accuracy >= 2) {
//Enable External LNA power - IS DISABLED BY DEFAULT
ATsendCMD("AT+QGPSCFG=\"lnacontrol\",1");
@@ -279,13 +288,11 @@
ATsendCMD("AT+QGPS=1");
ATwaitForWord("OK",ATTIMEOUT_SHORT);
- Timer t;
- t.start();
//TRY UNTIL TIMEOUT
uint8_t GPS_fixstage = 0;
uint8_t GPS_fixcount = 0;
- uint32_t startmillis = t.read_ms();
- uint32_t runtime = 0;
+ startmillis = t.read_ms();
+ runtime = 0;
while(!haveGPSFix && runtime < (timeout_seconds*1000)) {
watchdogKick();
Thread::wait(5000); //this goes first
@@ -333,12 +340,7 @@
//SHALL WE GET CELL LOCATION
if (!haveGPSFix && accuracy >= 1) {
- //PRIORITISE 2G connection (reason being uses less power in some instances and can get cell tower tirangulation)
- //ATsendCMD("AT+QCFG=\"nwscanseq\",0"); // 0 - auto, 1 - 2g priority, 2 - 3g priority
- //ATwaitForWord("OK",ATTIMEOUT_SHORT);
- //ATsendCMD("AT+QCFG=\"nwscanmode\",1"); // 0 - auto, 1 - 2g, 2 - 3g
- //ATwaitForWord("OK",ATTIMEOUT_SHORT);
-
+
_w_disable = 1; //turn off airplane mode
registerOnNetwork(2, 90000);
@@ -349,14 +351,19 @@
int mcc;
int mnc;
- ATsendCMD("AT+QENG=\"servingcell\"");
- ATwaitForWord("+QENG: \"servingcell\"",ATTIMEOUT_SHORT);
-
- if ((matchCount = _uart.scanf(",\"NOCONN\",\"%[^\"]\",%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");
- haveCellFix = true;
- //DEBUG("\ncellOut:%s\n",locDataOut);
+ startmillis = t.read_ms();
+ runtime = 0;
+ while(!haveCellFix && runtime < 15000) {
+ runtime = (t.read_ms() - startmillis);
+ 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");
+ haveCellFix = true;
+ //DEBUG("\ncellOut:%s\n",locDataOut);
+ }
+ }
}
//example from mulbs