Skip to content

Commit

Permalink
Reduce time for waiting for USSD
Browse files Browse the repository at this point in the history
- correctly initialize counter, so that we count the first reply
- wait only 10 seconds if we receive further reply

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Aug 22, 2016
1 parent 4eefbee commit 17a5fa1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gammu/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,15 @@ void GetUSSD(int argc UNUSED, char *argv[])
error=GSM_SetIncomingUSSD(gsm,TRUE);
Print_Error(error);

num_replies = 0;

error=GSM_DialService(gsm, argv[2]);
/* Fallback to voice call, it can work with some phones */
if (error == ERR_NOTIMPLEMENTED || error == ERR_NOTSUPPORTED) {
error=GSM_DialVoice(gsm, argv[2], GSM_CALL_DefaultNumberPresence);
}
Print_Error(error);

num_replies = 0;
last_replies = 0;
last_reply = time(NULL);
while (!gshutdown) {
Expand All @@ -155,10 +156,11 @@ void GetUSSD(int argc UNUSED, char *argv[])
} else if (num_replies == 0 && difftime(time(NULL), last_reply) > 60) {
/* Wait one minute for reply */
gshutdown = TRUE;
} else if (num_replies > 0 && difftime(time(NULL), last_reply) > 30) {
/* Wait for consequent replies for 30 seconds */
} else if (num_replies > 0 && difftime(time(NULL), last_reply) > 10) {
/* Wait for consequent replies for 10 seconds */
gshutdown = TRUE;
}

GSM_ReadDevice(gsm, FALSE);
}

Expand Down

0 comments on commit 17a5fa1

Please sign in to comment.