diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c index ad83a13a56d840a980c524032b94b47ca224c785..2a31a4edb865f3f8eec08022808ef7a9406ea149 100644 --- a/channels/chan_brcm.c +++ b/channels/chan_brcm.c @@ -47,7 +47,6 @@ #include <semaphore.h> #include <sys/types.h> #include <sys/stat.h> // mkfifo() - #include "asterisk/lock.h" #include "asterisk/channel.h" #include "asterisk/options.h" @@ -213,7 +212,6 @@ static const char ubusStrObjRm[] = "ubus.object.remove"; // UBUS objects ad static int audio_rx_fd = 0, audio_tx_fd = 0; static pe_bus_t *audio_rx_bus, *audio_tx_bus; static pe_stream_t *audio_rx_stream; - #define RTP_HEADER_SIZE 12 #define RTP_DTMF_SIZE 4 @@ -1463,15 +1461,27 @@ static int handle_interdigit_timeout(const void *data) pvt_lock(p, "interdigit callback"); p->interdigit_timer_id = -1; struct brcm_subchannel *sub = brcm_get_active_subchannel(p); - - if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num)) - { + if (line_config[p->line_id].minimumnumberdigits && strlen(p->dtmfbuf) >= line_config[p->line_id].minimumnumberdigits){ + if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num)) + { //We have at least one matching extension in "normal" context, //and interdigit timeout has passed, so have asterisk start calling. //Asterisk will select the best matching extension if there are more than one possibility. ast_debug(9, "Interdigit timeout, extension(s) matching %s found\n", p->dtmfbuf); brcm_start_calling(p, sub, p->context); - } + } + } + //if no limit on minimum digits check extension exits + if(!line_config[p->line_id].minimumnumberdigits){ + if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num)) + { + //We have at least one matching extension in "normal" context, + //and interdigit timeout has passed, so have asterisk start calling. + //Asterisk will select the best matching extension if there are more than one possibility. + ast_debug(9, "Interdigit timeout, extension(s) matching %s found\n", p->dtmfbuf); + brcm_start_calling(p, sub, p->context); + } + } //ast_mutex_unlock(&p->lock); pvt_unlock(p); return 0; @@ -1555,19 +1565,22 @@ static int handle_dialtone_timeout(const void *data) void handle_dtmf_calling(struct brcm_subchannel *sub) { struct brcm_pvt *p = sub->parent; + char lastDigit; + char termination_digit; int dtmfbuf_len = strlen(p->dtmfbuf); char dtmf_last_char = p->dtmfbuf[(dtmfbuf_len - 1)]; - + + termination_digit = line_config[p->line_id].terminationdigit?line_config[p->line_id].terminationdigit:0x23; if (ast_exists_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num) && !ast_matchmore_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num)) { //We have a full match in the "direct" context, so have asterisk place a call immediately ast_debug(9, "Direct extension matching %s found\n", p->dtmfbuf); brcm_start_calling(p, sub, p->context_direct); } - else if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num) && dtmf_last_char == 0x23 && feature_access_code_match(p->dtmfbuf) != 1) { + else if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num) && dtmf_last_char == termination_digit && feature_access_code_match(p->dtmfbuf) != 1) { //We have a match in the "normal" context, and user ended the dialling sequence with a #, //so have asterisk place a call immediately if sequence is not partially matching a feature access code - ast_debug(9, "Pound-key pressed during dialling, extension %s found\n", p->dtmfbuf); + ast_debug(9, "Termination key %c pressed during dialling, extension %s found\n",termination_digit, p->dtmfbuf); brcm_start_calling(p, sub, p->context); } else if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num) && !ast_matchmore_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num)) @@ -1579,10 +1592,24 @@ void handle_dtmf_calling(struct brcm_subchannel *sub) brcm_start_calling(p, sub, p->context); } else { - //No matches. We schedule a (new) interdigit timeout to occur - int timeoutmsec = line_config[p->line_id].timeoutmsec; - ast_debug(9, "Scheduling new interdigit timeout in %d msec\n", timeoutmsec); - p->interdigit_timer_id = ast_sched_add(sched, timeoutmsec, handle_interdigit_timeout, p); + if (line_config[p->line_id].minimumnumberdigits && strlen(p->dtmfbuf) >= line_config[p->line_id].minimumnumberdigits ){ + int interdigitopenmsec = line_config[p->line_id].interdigitopenmsec; + if (interdigitopenmsec){ + ast_debug(9,"Scheduling interdigitopenmsec timeout of %d msec\n", interdigitopenmsec); + p->interdigit_timer_id = ast_sched_add(sched, interdigitopenmsec, handle_interdigit_timeout, p); + } + else{ + int timeoutmsec = line_config[p->line_id].timeoutmsec; + ast_debug(9,"Interdigitopenmsec not found !!Using timeoutsec timeout of %d msec\n", timeoutmsec); + p->interdigit_timer_id = ast_sched_add(sched, timeoutmsec, handle_interdigit_timeout, p); + } + } + else { + //No matches. We schedule a (new) interdigit timeout to occur + int timeoutmsec = line_config[p->line_id].timeoutmsec; + ast_debug(9, "Scheduling interdigit timeout of %d msec\n", timeoutmsec); + p->interdigit_timer_id = ast_sched_add(sched, timeoutmsec, handle_interdigit_timeout, p); + } } } @@ -3023,6 +3050,12 @@ static void line_settings_load(line_settings *line_config, struct ast_variable * line_config->ringsignal = ast_true(v->value)?1:0; } else if (!strcasecmp(v->name, "dialoutmsec")) { line_config->timeoutmsec = atoi(v->value); + } else if (!strcasecmp(v->name, "interdigitopenmsec")) { + line_config->interdigitopenmsec = atoi(v->value); + } else if (!strcasecmp(v->name, "minimumnumberdigits")) { + line_config->minimumnumberdigits = atoi(v->value); + } else if (!strcasecmp(v->name, "terminationdigit")) { + line_config->terminationdigit =v->value[0]; } else if (!strcasecmp(v->name, "autodial_timeoutmsec")) { line_config->autodial_timeoutmsec = atoi(v->value); } else if (!strcasecmp(v->name, "dialtone_timeoutmsec")) { diff --git a/channels/chan_brcm.h b/channels/chan_brcm.h index 70b82aa0307365817afdd2aff6ba84fdf71a514e..1b77b097549649c69b94c550ce4910eca129deff 100644 --- a/channels/chan_brcm.h +++ b/channels/chan_brcm.h @@ -199,6 +199,9 @@ typedef struct { int autodial_timeoutmsec; int ringsignal; int timeoutmsec; + int interdigitopenmsec; + int minimumnumberdigits; + char terminationdigit; int period; int hangup_xfer; int dialtone_timeoutmsec;