diff --git a/src/common/call.c b/src/common/call.c index 6e7ab2f..0b0ab17 100644 --- a/src/common/call.c +++ b/src/common/call.c @@ -35,6 +35,7 @@ extern int use_mncc_sock; extern int send_patterns; +extern int release_on_disconnect; /* stream patterns/announcements */ int16_t *ringback_spl = NULL; @@ -972,7 +973,6 @@ void call_mncc_recv(uint8_t *buf, int length) if (send_patterns) { PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n"); - set_state_process(callref, CALL_CONNECT); _indicate_answer(callref, number); break; } @@ -984,6 +984,14 @@ void call_mncc_recv(uint8_t *buf, int length) case MNCC_DISC_REQ: PDEBUG(DMNCC, DEBUG_INFO, "Received MNCC disconnect from Network with cause %d\n", mncc->cause.value); + if (is_process_state(callref) == CALL_CONNECT && release_on_disconnect) { + PDEBUG(DCALL, DEBUG_INFO, "Releaseing, because we don't send disconnect tones to mobile phone\n"); + + PDEBUG(DMNCC, DEBUG_INFO, "Releasing MNCC call towards Network\n"); + mncc->msg_type = MNCC_REL_IND; + mncc_write(buf, sizeof(struct gsm_mncc)); + goto release; + } set_state_process(callref, CALL_DISCONNECTED); PDEBUG(DCALL, DEBUG_INFO, "Call disconnected\n"); call_out_disconnect(callref, mncc->cause.value); @@ -991,6 +999,7 @@ void call_mncc_recv(uint8_t *buf, int length) case MNCC_REL_REQ: PDEBUG(DMNCC, DEBUG_INFO, "Received MNCC release from Network with cause %d\n", mncc->cause.value); +release: destroy_process(callref); PDEBUG(DCALL, DEBUG_INFO, "Call released\n"); call_out_release(callref, mncc->cause.value); diff --git a/src/common/main_common.c b/src/common/main_common.c index ac223f4..e104c56 100644 --- a/src/common/main_common.c +++ b/src/common/main_common.c @@ -47,6 +47,7 @@ int do_de_emphasis = 0; double rx_gain = 1.0; int use_mncc_sock = 0; int send_patterns = 1; +int release_on_disconnect = 1; int loopback = 0; int rt_prio = 0; const char *read_wave = NULL; @@ -94,7 +95,8 @@ void print_help_common(const char *arg0, const char *ext_usage) printf(" -c --call-device hw:,\n"); printf(" Sound card and device number for headset (default = '%s')\n", call_sounddev); printf(" -p --send-patterns 0 | 1\n"); - printf(" Connect call on setup/release to provide classic tones (default = '%d')\n", send_patterns); + printf(" Connect call on setup/release to provide classic tones towards fixed\n"); + printf(" network (default = '%d')\n", send_patterns); printf(" -L --loopback \n"); printf(" Loopback test: 1 = internal | 2 = external | 3 = echo\n"); printf(" -r --realtime \n"); diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c index 1f006ee..1ad3217 100644 --- a/src/nmt/nmt.c +++ b/src/nmt/nmt.c @@ -1641,8 +1641,8 @@ void call_out_disconnect(int callref, int cause) return; } - /* Release when not active */ - if (nmt->state == STATE_ACTIVE) + /* Release when not active and not waiting for answer */ + if (nmt->state == STATE_ACTIVE || nmt->state == STATE_MO_COMPLETE) return; switch (nmt->state) { case STATE_MT_RINGING: