diff options
author | Riccardo Vangelisti <riccardo.vangelisti@sadel.it> | 2015-05-06 10:00:20 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2015-05-23 17:42:36 +0200 |
commit | 486929c83e003912c3f33ac2fefcd71e33ff254f (patch) | |
tree | 58cc2337178428353e92b98dba69620f7bd1bf77 | |
parent | b35f0ae062b5a03e0c5fc17d3412a5754cfd34b9 (diff) | |
download | ModemManager-486929c83e003912c3f33ac2fefcd71e33ff254f.tar.gz |
base-call: fixed bug when hangup call.
Ok, busy and no carrier messages are handled by serial-parser.
-rw-r--r-- | src/mm-base-call.c | 87 |
1 files changed, 34 insertions, 53 deletions
diff --git a/src/mm-base-call.c b/src/mm-base-call.c index dc5148ada..8998f4f83 100644 --- a/src/mm-base-call.c +++ b/src/mm-base-call.c @@ -115,7 +115,7 @@ handle_start_auth_ready (MMBaseModem *modem, g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "This CALL was received, cannot send it"); + "This call was not in unknown state, cannot start it"); handle_start_context_free (ctx); return; } @@ -473,7 +473,7 @@ call_start_ready (MMBaseModem *modem, CallStartContext *ctx) { GError *error = NULL; - const gchar *response; + const gchar *response = NULL; response = mm_base_modem_at_command_finish (modem, res, &error); if (error) { @@ -488,18 +488,8 @@ call_start_ready (MMBaseModem *modem, return; } - mm_dbg ("%s: '%s'", __FUNCTION__, response); - /* check response for error */ - if( strstr(response, "OK")) { - /* Update state */ - mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_ACTIVE); - mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), - mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), - MM_CALL_STATE_ACTIVE, - MM_CALL_STATE_REASON_ACCEPTED); - } - else if( strstr(response, "NO CARRIER") || strstr(response, "BUSY") ) { + if( response && strlen(response) > 0 ) { g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't start the call: " "Modem response '%s'", response); @@ -509,17 +499,13 @@ call_start_ready (MMBaseModem *modem, mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY); - } - else { - g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Couldn't start the call: " - "Unhandled response '%s'", response); + } else { /* Update state */ - mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_TERMINATED); + mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_ACTIVE); mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), - MM_CALL_STATE_TERMINATED, - MM_CALL_STATE_REASON_ERROR); + MM_CALL_STATE_ACTIVE, + MM_CALL_STATE_REASON_ACCEPTED); } if (error) { @@ -549,13 +535,21 @@ call_start (MMBaseCall *self, ctx->self = g_object_ref (self); ctx->modem = g_object_ref (self->priv->modem); - cmd = g_strdup_printf ("ATD %s;", mm_gdbus_call_get_number (MM_GDBUS_CALL (self)) ); + cmd = g_strdup_printf ("ATD%s;", mm_gdbus_call_get_number (MM_GDBUS_CALL (self)) ); mm_base_modem_at_command (ctx->modem, cmd, - 60, + 90, FALSE, (GAsyncReadyCallback)call_start_ready, ctx); + + /* Update state */ + mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_RINGING_OUT); + mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), + mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), + MM_CALL_STATE_RINGING_OUT, + MM_CALL_STATE_REASON_OUTGOING_STARTED); + g_free (cmd); } @@ -609,14 +603,7 @@ call_accept_ready (MMBaseModem *modem, } /* check response for error */ - if( strstr(response, "OK")) { - /* Update state */ - mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_ACTIVE); - mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), - mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), - MM_CALL_STATE_ACTIVE, - MM_CALL_STATE_REASON_ACCEPTED); - } else { + if( response && strlen(response) > 0 ) { g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't accept the call: " "Unhandled response '%s'", response); @@ -626,6 +613,13 @@ call_accept_ready (MMBaseModem *modem, mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR); + } else { + /* Update state */ + mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_ACTIVE); + mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), + mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), + MM_CALL_STATE_ACTIVE, + MM_CALL_STATE_REASON_ACCEPTED); } if (error) { @@ -658,7 +652,7 @@ call_accept (MMBaseCall *self, cmd = g_strdup_printf ("ATA"); mm_base_modem_at_command (ctx->modem, cmd, - 10, + 2, FALSE, (GAsyncReadyCallback)call_accept_ready, ctx); @@ -715,25 +709,12 @@ call_hangup_ready (MMBaseModem *modem, return; } - /* check response for error */ - if( strstr(response, "OK")) { - /* Update state */ - mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_TERMINATED); - mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), - mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), - MM_CALL_STATE_TERMINATED, - MM_CALL_STATE_REASON_TERMINATED); - } else { - g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Couldn't hangup the call: " - "Unhandled response '%s'", response); - /* Update state */ - mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_TERMINATED); - mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), - mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), - MM_CALL_STATE_TERMINATED, - MM_CALL_STATE_REASON_ERROR); - } + /* Update state */ + mm_gdbus_call_set_state (MM_GDBUS_CALL (ctx->self), MM_CALL_STATE_TERMINATED); + mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (ctx->self), + mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)), + MM_CALL_STATE_TERMINATED, + MM_CALL_STATE_REASON_TERMINATED); if (error) { g_simple_async_result_take_error (ctx->result, error); @@ -762,10 +743,10 @@ call_hangup (MMBaseCall *self, ctx->self = g_object_ref (self); ctx->modem = g_object_ref (self->priv->modem); - cmd = g_strdup_printf ("ATH"); + cmd = g_strdup_printf ("+CHUP"); mm_base_modem_at_command (ctx->modem, cmd, - 10, + 2, FALSE, (GAsyncReadyCallback)call_hangup_ready, ctx); |