Skip to content

Commit

Permalink
added optional disconnection of modem data session after each send
Browse files Browse the repository at this point in the history
  • Loading branch information
ppescher committed Aug 8, 2016
1 parent b9e6533 commit b930137
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
31 changes: 25 additions & 6 deletions OpenTracker/gsm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,33 @@ int gsm_get_modem_status() {
}

int gsm_disconnect() {
debug_print(F("gsm_disconnect() started"));
int ret = 0;
debug_print(F("gsm_disconnect() started"));
#if GSM_DISCONNECT_AFTER_SEND
//disconnect GSM
gsm_port.print("AT+QIDEACT\r");
gsm_wait_for_reply(0,0);

//check if result contains DEACT OK
char *tmp = strstr(modem_reply, "DEACT OK");

if(tmp!=NULL) {
debug_print(F("gsm_disconnect(): DEACT OK found"));
ret = 1;
} else {
debug_print(F("gsm_disconnect(): DEACT OK not found."));
}
#else
//close connection, if previous attempts left it open
gsm_port.print("AT+QICLOSE\r");
gsm_wait_for_reply(0,0);

//ignore errors (will be taken care during connect)
ret = 1;
#endif

//close connection, if previous attempts left it open
gsm_port.print("AT+QICLOSE\r");
gsm_wait_for_reply(0,0);

debug_print(F("gsm_disconnect() completed"));
return 1;
return ret;
}

int gsm_set_apn() {
Expand Down
1 change: 1 addition & 0 deletions OpenTracker/tracker.h.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#define GSM_MODEM_COMMAND_TIMEOUT 10
#define GSM_SEND_FAILURES_REBOOT 30 // 0=disabled, increase to set the number of GSM failures that will trigger a reboot of the opentracker device
#define GSM_DISCONNECT_AFTER_SEND 0 // 0=keep modem data session active, only close TCP connection (default), 1=close data session after each send

#define ENGINE_RUNNING_LOG_FAST_AS_POSSIBLE 0 // 1=when the engine is running send interval is ignored

Expand Down

0 comments on commit b930137

Please sign in to comment.