--- channels/chan_zap.c.orig 2004-06-11 19:20:07.000000000 +0300 +++ channels/chan_zap.c 2004-06-11 19:26:53.000000000 +0300 @@ -195,6 +195,15 @@ static int echotraining; +static int pulse = 0; + +static int make_time = 60; + +static int break_time = 40; + +static int pause_time = 800; + + static int echocanbridged = 0; static int busydetect = 0; @@ -475,6 +484,10 @@ int callwaitrings; int echocancel; int echotraining; + int pulse; + int pause_time; + int make_time; + int break_time; int echocanbridged; int echocanon; int echobreak; @@ -1259,6 +1272,43 @@ return res; } +/* + * Send one pulse + */ +void send_pulse(fd) +{ + // t1 - pulse time + // t2 - pause between pulses + // t1/t2 should be about 60/40 + // pulse frequency is 10 Hz + zt_set_hook(fd, ZT_ONHOOK); + usleep(make_time*1000); + zt_set_hook(fd, ZT_OFFHOOK); + usleep(break_time*1000); +} + +/* + * ATDP digit :) + */ + +void dial_pulse_digit(int fd, unsigned char digit) +{ + /* skip if it is something else then digit */ + if((digit < 1) || (digit > 12)) + return; + + while(digit) + { + send_pulse(fd); + digit--; + } + // pause between pulses - 800 ms + usleep(pause_time*1000); +} + + + + static inline int zt_confmute(struct zt_pvt *p, int muted) { int x, y, res; @@ -3470,6 +3520,52 @@ case SIG_SF: case SIG_SFWINK: case SIG_SF_FEATD: + if(pulse) + { + int i = 0; + + + while( i < strlen(p->dop.dialstr)) + { + unsigned char digit; + switch(p->dop.dialstr[i]) + { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + digit = p->dop.dialstr[i] - '0'; + break; + case '0': + digit = 10; + break; + case '*': + digit = 11; + break; + case '#': + digit = 12; + break; + default: + // just skip it + digit = 255; + break; + } + + dial_pulse_digit(p->subs[SUB_REAL].zfd, digit); + i++; + } + // VERY DIRTY & UGLY HACK + // we need it to inform astersik that connection + // established + p->dop.dialstr[0] = 'w'; + p->dop.dialstr[1] = '\x00'; + res = ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop); + } else if (!ast_strlen_zero(p->dop.dialstr)) res = ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop); else if (res < 0) { @@ -5986,6 +6082,10 @@ tmp->callreturn = callreturn; tmp->echocancel = echocancel; tmp->echotraining = echotraining; + tmp->pulse = pulse; + tmp->make_time = make_time; + tmp->break_time = break_time; + tmp->pause_time = pause_time; tmp->echocanbridged = echocanbridged; tmp->busydetect = busydetect; tmp->busycount = busycount; @@ -8440,6 +8540,14 @@ } } else if (!strcasecmp(v->name, "echotraining")) { echotraining = ast_true(v->value); + } else if (!strcasecmp(v->name, "pulse")) { + pulse = ast_true(v->value); + } else if (!strcasecmp(v->name, "make_time")) { + make_time = atoi(v->value); + } else if (!strcasecmp(v->name, "break_time")) { + break_time = atoi(v->value); + } else if (!strcasecmp(v->name, "pause_time")) { + pause_time = atoi(v->value); } else if (!strcasecmp(v->name, "hidecallerid")) { hidecallerid = ast_true(v->value); } else if (!strcasecmp(v->name, "callreturn")) {