diff --git a/src/callbacks.c b/src/callbacks.c index d6dbb45..5c19c03 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -110,7 +110,7 @@ void on_phone_call_reject(gpointer data) { Phone * phone = data; - phone_call_hangup(phone); + phone_call_reject(phone); } diff --git a/src/gsm.c b/src/gsm.c index 85b2ac1..afcd793 100644 --- a/src/gsm.c +++ b/src/gsm.c @@ -455,6 +455,13 @@ int gsm_call_hangup(GSM * gsm) } +/* gsm_call_reject */ +int gsm_call_reject(GSM * gsm) +{ + return gsm_modem_call_reject(gsm->modem); +} + + /* gsm_enter_sim_pin */ int gsm_enter_sim_pin(GSM * gsm, char const * code) { diff --git a/src/gsm.h b/src/gsm.h index 5abad02..a253b50 100644 --- a/src/gsm.h +++ b/src/gsm.h @@ -71,8 +71,9 @@ typedef enum _GSMError GSM_ERROR_NO_CARRIER, GSM_ERROR_NO_DIALTONE, GSM_ERROR_OPERATOR_MODE_FAILED, - GSM_ERROR_SIGNAL_LEVEL_FAILED, + GSM_ERROR_REJECT_FAILED, GSM_ERROR_RESET_FAILED, + GSM_ERROR_SIGNAL_LEVEL_FAILED, GSM_ERROR_SIM_PIN_REQUIRED, GSM_ERROR_SIM_PIN_WRONG } GSMError; @@ -281,6 +282,7 @@ int gsm_call_answer(GSM * gsm); int gsm_call(GSM * gsm, GSMCallType calltype, char const * number); int gsm_call_contact(GSM * gsm, GSMCallType calltype, unsigned int index); int gsm_call_hangup(GSM * gsm); +int gsm_call_reject(GSM * gsm); int gsm_enter_sim_pin(GSM * gsm, char const * code); diff --git a/src/modem.c b/src/modem.c index a6e236c..106249b 100644 --- a/src/modem.c +++ b/src/modem.c @@ -182,6 +182,23 @@ int gsm_modem_call_last(GSMModem * gsmm, GSMCallType calltype) } +/* gsm_modem_call_reject */ +static void _modem_call_reject_callback(GSM * gsm); + +int gsm_modem_call_reject(GSMModem * gsmm) +{ + char const cmd[] = "AT+CHUP"; + + return gsm_queue_full(gsmm->gsm, GSM_PRIORITY_HIGH, cmd, + GSM_ERROR_REJECT_FAILED, _modem_call_reject_callback); +} + +static void _modem_call_reject_callback(GSM * gsm) +{ + gsm_is_phone_active(gsm); +} + + /* gsm_modem_enter_sim_pin */ static void _modem_enter_sim_pin_callback(GSM * gsm); diff --git a/src/modem.h b/src/modem.h index 104af90..b4ab2b4 100644 --- a/src/modem.h +++ b/src/modem.h @@ -47,6 +47,7 @@ int gsm_modem_call_contact(GSMModem * gsmm, GSMCallType calltype, unsigned int index); int gsm_modem_call_hangup(GSMModem * gsmm); int gsm_modem_call_last(GSMModem * gsmm, GSMCallType calltype); +int gsm_modem_call_reject(GSMModem * gsmm); int gsm_modem_enter_sim_pin(GSMModem * gsmm, char const * code); diff --git a/src/phone.c b/src/phone.c index 199a4ec..a80fc1a 100644 --- a/src/phone.c +++ b/src/phone.c @@ -323,6 +323,13 @@ void phone_call_hangup(Phone * phone) } +/* phone_call_reject */ +void phone_call_reject(Phone * phone) +{ + gsm_call_reject(phone->gsm); +} + + /* phone_code_append */ int phone_code_append(Phone * phone, char character) { @@ -807,6 +814,7 @@ static struct { "Phone functional", gsm_is_functional }, { "Registered", gsm_is_registered }, { "Registration", gsm_fetch_registration }, + { "Reject call", gsm_call_reject }, { "Signal level", gsm_fetch_signal_level }, { "SIM PIN status", gsm_is_pin_needed }, { "SIM PIN valid", gsm_is_pin_valid }, @@ -1496,7 +1504,9 @@ static void _phone_set_status(Phone * phone, GSMStatus status) GSM_OPERATOR_FORMAT_LONG); gsm_fetch_operator(phone->gsm); gsm_fetch_signal_level(phone->gsm); +#ifndef DEBUG _phone_track(phone, PHONE_TRACK_SIGNAL_LEVEL, TRUE); +#endif return; } _phone_track(phone, PHONE_TRACK_REGISTRATION, track_registration); @@ -1573,8 +1583,10 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data) GSM_OPERATOR_MODE_AUTOMATIC); gsm_set_registration_report(phone->gsm, report); gsm_is_phone_active(phone->gsm); +#ifndef DEBUG _phone_track(phone, PHONE_TRACK_CONTACT_LIST, TRUE); _phone_track(phone, PHONE_TRACK_MESSAGE_LIST, TRUE); +#endif return 0; case GSM_EVENT_TYPE_INCOMING_CALL: phone_show_call(phone, TRUE, PHONE_CALL_INCOMING, "", diff --git a/src/phone.h b/src/phone.h index a75e803..28d7f9d 100644 --- a/src/phone.h +++ b/src/phone.h @@ -76,6 +76,7 @@ void phone_show_write(Phone * phone, gboolean show); /* calls */ void phone_call_answer(Phone * phone); void phone_call_hangup(Phone * phone); +void phone_call_reject(Phone * phone); /* code */ int phone_code_append(Phone * phone, char character);