From 65bc765846c6ec171f0ad9c201d39c072771179a Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Tue, 6 Nov 2012 11:34:34 +0100 Subject: [PATCH] FS-4659 gsmopen: give error and abort call when dialing was not through correctly (eg: get back OK). Also, grow the default timeout when expecting a string back from the modem to half a second - 500000 usec - so to avoid false negatives --- src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp | 8 +++++--- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp index 5bdda08f81..81d1192307 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -2189,7 +2189,7 @@ int gsmopen_serial_write_AT_expect1(private_t *tech_pvt, const char *data, const return -1; } - at_result = gsmopen_serial_read_AT(tech_pvt, 1, 100000, seconds, expected_string, expect_crlf); // minimum 1/10th sec timeout + at_result = gsmopen_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf); // minimum half a sec timeout UNLOCKA(tech_pvt->controldev_lock); POPPA_UNLOCKA(tech_pvt->controldev_lock); @@ -2700,6 +2700,8 @@ int gsmopen_hangup(private_t *tech_pvt) int gsmopen_call(private_t *tech_pvt, char *rdest, int timeout) { + int result; + //gsmopen_sleep(5000); DEBUGA_GSMOPEN("Calling GSM, rdest is: %s\n", GSMOPEN_P_LOG, rdest); //gsmopen_signaling_write(tech_pvt, "SET AGC OFF"); @@ -2707,11 +2709,11 @@ int gsmopen_call(private_t *tech_pvt, char *rdest, int timeout) //gsmopen_signaling_write(tech_pvt, "SET AEC OFF"); //gsmopen_sleep(10000); - gsmopen_serial_call(tech_pvt, rdest); + result=gsmopen_serial_call(tech_pvt, rdest); //ERRORA("failed to communicate with GSM client, now exit\n", GSMOPEN_P_LOG); //return -1; //} - return 0; + return result; } int gsmopen_senddigit(private_t *tech_pvt, char digit) diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 62f5cdd20f..18451d8cf2 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -1054,6 +1054,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_call_cause_t *cancel_cause) { private_t *tech_pvt = NULL; + int result; + if ((*new_session = switch_core_session_request(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) { switch_channel_t *channel = NULL; switch_caller_profile_t *caller_profile; @@ -1171,8 +1173,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_set_flag(tech_pvt, TFLAG_OUTBOUND); switch_mutex_unlock(tech_pvt->flag_mutex); switch_channel_set_state(channel, CS_INIT); - gsmopen_call(tech_pvt, rdest, 30); + result=gsmopen_call(tech_pvt, rdest, 30); switch_mutex_unlock(globals.mutex); + if(result != 0){ + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } return SWITCH_CAUSE_SUCCESS; }