Hi to all, 

I have a callweaver pbx with a sangoma a200 with both fxs and fxo. My
telco uses revered polarity for answer and hangup and ive noticed that
when im making calls , when the polarity reversal happens the call gets
answered and then immediatly hung up.
When the calls are inbound, everything works fine so i did some checking
and ive found out that upon making calls the  the p->polaritydelaytv was
not initiated, hence the opbx_tvdiff_ms(opbx_tvnow(),
p->polaritydelaytv) > p->polarityonanswerdelay was allways true upon
dialing out.

So ive checked and i saw the polaritydelaytv initiated only when the
call gets answered.

Ive fixed this by simply initiating the p->polaritydelaytv upon answer
polarity reversal,

So...


case ZT_EVENT_POLARITY:
                        /*
                         * If we get a Polarity Switch event, check to
see
                         * if we should change the polarity state and
                         * mark the channel as UP or if this is an
indication
                         * of remote end disconnect.
                         */
                        if (p->polarity == POLARITY_IDLE) {
                                p->polarity = POLARITY_REV;
                                if (p->answeronpolarityswitch &&
                                    ((opbx->_state ==
OPBX_STATE_DIALING) ||
                                     (opbx->_state ==
OPBX_STATE_RINGING))) {
                                        opbx_log(LOG_DEBUG, "Answering
on polarity switch!\n");
                                        opbx_setstate(p->owner,
OPBX_STATE_UP);

gettimeofday(&p->polaritydelaytv, NULL);
                                } else
                                        opbx_log(LOG_DEBUG, "Ignore
switch to REVERSED Polarity on channel %d, state %d\n", p->channel,
opbx->_state);
                        }

                        /* Removed else statement from here as it was
preventing hangups from ever happening*/
                        /* Added OPBX_STATE_RING in if statement below
to deal with calling party hangups that take place when ringing */
                        if(p->hanguponpolarityswitch &&
                                (p->polarityonanswerdelay > 0) &&
                               (p->polarity == POLARITY_REV) &&
                                ((opbx->_state == OPBX_STATE_UP) ||
(opbx->_state == OPBX_STATE_RING)) ) {
                                /* Added log_debug information below to
provide a better indication of what is going on */
                                opbx_log(LOG_DEBUG, "Polarity Reversal
event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp=
%d, pdelay= %d, tv= %d\n", p->channel, opbx->_state, p->polarity,
p->answeronpolarityswitch, p->hanguponpolarityswitch,
p->polarityonanswerdelay, opbx_tvdiff_ms(opbx_tvnow(),
p->polaritydelaytv) );
                                if(opbx_tvdiff_ms(opbx_tvnow(),
p->polaritydelaytv) > p->polarityonanswerdelay) { // That now works
allways
                                        opbx_log(LOG_DEBUG, "Polarity
Reversal detected and now Hanging up on channel %d\n", p->channel);
                                        opbx_softhangup(p->owner,
OPBX_SOFTHANGUP_EXPLICIT);
                                        p->polarity = POLARITY_IDLE;
                                } else {
                                        opbx_log(LOG_DEBUG, "Polarity
Reversal detected but NOT hanging up (too close to answer event) on
channel %d, state %d\n", p->channel, opbx->_state);
                                }
                                ....

And i have now the problem fixed. Since my version is kind of a
"costumized" version of callweaver Ive check recent chan_zap.c code to
see if that is changed but it seems to be the same way so i propose that
this line to be added.


Regards


Carlos Galveias
_______________________________________________
Callweaver-dev mailing list
[email protected]
http://lists.callweaver.org/mailman/listinfo/callweaver-dev

Reply via email to