onesty-tech

Member

Last active 8 years ago

  1. 8 years ago
    Wed Nov 16 07:34:30 2016
    onesty-tech posted in Extensions enventually shown DND.

    It looks like following. Should be completely stock we did not touch it in any way.

    package FOP2Callbacks;

    # Example module to customize and tweak FOP2 behaviour
    my %redirected;

    sub flashCommand {
    # This function is called when certain commands are sent from a flash client

    $command = shift;
    @parameters = @_;

    my $return = "";
    my @allreturn = ();

    if($command eq "setastdb") {

    # DND Integration from FOP2 to FreePBX ASTDB DND
    #
    # DEPRECATED! All of this can be done from the new plugin
    # architecture
    #
    # This is for debug
    #my $cont=0;
    #foreach my $param (@parameters) {
    # print "command $comando -- Parameter $cont = $param\n";
    # $cont++;
    #}

    #if($parameters[1] eq "fop2state") {
    # if($parameters[3] ne "") {
    # $return = "Action: Command\r\n";
    # $return .= "Command: database put DND ".$parameters[2]." YES\r\n";
    # $return .= "\r\n";
    # push @allreturn, $return;
    # } else {
    # $return = "Action: Command\r\n";
    # $return .= "Command: database del DND ".$parameters[2]."\r\n";
    # $return .= "\r\n";
    # push @allreturn, $return;
    # }
    #}

    return @allreturn;

    } elsif($command eq "pickupActive") {
    #my $cont=0;
    #foreach my $param (@parameters) {
    # print "command $comando -- Parameter $cont = $param\n";
    # $cont++;
    #}
    #print "Setting redirected(".$parameters[1].")\n";
    $redirected{$parameters[0]}=1;
    return @allreturn;

    } elsif($command eq "auth") {
    #my $cont=0;
    #foreach my $param (@parameters) {
    # print "command $comando -- Parameter $cont = $param\n";
    # $cont++;
    #}
    return @allreturn;
    } elsif($command eq "customconference") {
    # my $contexto = $parameters[2];
    # my $mychannel = main::get_btn_config( "$contexto", $parameters[0], 'MAINCHANNEL');
    # my $extension_to_dial = $parameters[1];
    #
    # $return = "Action: Originate\r\n";
    # $return .= "Channel: Local/$extension_to_dial\@from-internal\r\n";
    # $return .= "Application: ChanSpy\r\n";
    # $return .= "Data: $mychannel,BEq\r\n";
    # $return .= "\r\n";
    # push @allreturn, $return;
    # return @allreturn;
    }

    }

    sub amiCommand {

    # Received an event from Asterisk Manager Interfase

    $command = shift;

    if($command eq "LEAVE") {

    # Used with fop2-dummy context for writing a line
    # to queue_log so redirects OUT of a queue are not
    # counted as abandoned calls

    %event = @_;
    my $return = "";
    my @allreturn = ();

    if( defined ( $redirected { $event{Channel} } )) {
    # This abandon is in fact a call pickup or redirection
    # We perform a dummy originate to log a NOTABANDON event
    # in queue_log
    delete $redirected { $event{Channel} };

    my $tiempo = time();
    $tiempo = $tiempo + 30;
    my $uniid = $event{Uniqueid};
    my $queue = $event{Queue};

    $return = "Action: Originate\r\n";
    $return .= "Channel: Local/dummy\@fop2-dummy/n\r\n";
    $return .= "Application: QueueLog\r\n";
    $return .= "Data: $queue,$uniid,NONE,NOTABANDON,0,0,0\r\n";
    $return .= "Async: true\r\n";
    $return .= "\r\n";

    push @allreturn, $return;
    return @allreturn;
    }

    } elsif($command eq "HANGUP") {
    # Garbage Collect
    %event = @_;
    if( defined ( $redirected { $event{Channel} } )) {
    # This abandon is in fact a call pickup or redirection
    delete $redirected { $event{Channel} };
    }
    }
    }

    1;

  2. Mon Nov 14 18:54:39 2016
    onesty-tech posted in Extensions enventually shown DND.

    I am sorry, I actually missed that we OF COURSE use the Presence Box DND Integration plugin in Fop2 I just did not remember that this had to be done. That one we have installed and it actually sets "DND" in FreePBX and is correctly reflected in the FreePBX admin web site. I assume this one is responsible too for the devicestate events, which are caught by our Aastra daemon and handle the mentioned custom events I generate from the aastra scripts. This is the only customization I made. I generate the events as shown above to toggle FOP2 state - which works. But as I said I cannot reproduce the problem manually. If I push the button on the phone the fop2 web setting changes and vice versa. I can observe the corresponding events in ami. So there must be some code segment that is somehow trigged which changes the FOP2 presense box state without doing the rest. The only thing I can find afterwards is the mentioned astdb entry "/fop2state/PJSIP/279 : Do not Disturb" iirc the extension is not shown DND in the FreePBX web either.

  3. Mon Nov 14 08:14:59 2016
    onesty-tech posted in Extensions enventually shown DND.

    Hello!

    we are using neither of these plugins - we are synchronising the phone's DND state with FOP2's DND state (so I assume DND is processed within the phone). Therefore we adjusted the extension management scripts to generate custom events in case a user pushes the DND button:

    Aastra_send_userevent_Asterisk2('FOP2ASTDB',array('Family'=>'fop2state','Key'=>'PJSIP/'.$user,'Channel'=>'PJSIP/'.$user,'Value'=>'Do not Disturb'));

    (and vice-versa for disabling DND).

    The other way round worked out of the box so FOP2 seems to create the needed events for our extension management daemon to set the device DND if someone selects DND in the web interface (it processes extension state and device state events and reacts on them to set the phone's DND state)

    Generally this works well. And I can't see a scenario where only the state in FOP2 could change without affecting the other side. I don't think the users are doing something accidentially here as I said if they selected DND accidentially from the FOP2 web interface it should actually effect the phone too which it did not in those cases I described. Furthermore I just recently noticed that my very own extension had the same issue lastly and I usually don't even use the FOP2 web interface and am pretty sure I did not set anything in there for my phone. So I assume it is most probably an event that is being read from the asterisk manager interface and wrongly sets the FOP2 status to dnd.

    regards, Felix

  4. Thu Nov 10 13:54:31 2016
    onesty-tech started the conversation Extensions enventually shown DND.

    Hello!

    sometimes some extensions eventually go DND in FOP2. We have two states - available and dnd. But this happens without the user setting DND state neither from the phone nor from the web. Actually the phone is not dnd either. So the extension can be called happily. The astdb reflects e.g. "/fop2state/PJSIP/279 : Do not Disturb" but the phone is actually reachable. As soon as the user sets state from FOP2 or the phone the DND icon goes away in FOP2. We tried restarting fop2 but this does not help it seems to load the state from the astdb upon restart. Any idea how we can trace this down? This happens so randomly we were not able to trace this yet.

    regards, Felix

  5. Wed Oct 12 07:41:08 2016
    onesty-tech joined the forum.