Want to send SIP notify to Yealink Phone to make it press a button

I have a scenario where I need the FOP2 panel to send a notify to Yealink phones to have the PHONE press DND. Not just have the FOP panel set DND as it does.
I've put some custom code in the FOP2 presence file and it works, but it is cludgy for certain.
This is a FreePBX 14 standard install otherwise.
I think this would be better as a plug in, but I'm not sure how to handle that.
File: /var/www/html/fop2/admin/plugins/presencedndfpbx/presencedndfpbx.pl
I added this

    if($key eq "fop2state") {
        if($data ne "") {
            $return  = "Action: Command\r\n";
            $return .= "Command: pjsip send notify dndon-yealink endpoint $exten\r\n";
            $return .= "\r\n";
            push @allreturn, $return;

and this

        } else {
            $return  = "Action: Command\r\n";
            $return .= "Command: pjsip send notify dndoff-yealink endpoint $exten\r\n";
            $return .= "\r\n";
            push @allreturn, $return;

File: /etc/asterisk/sip_notify_custom.conf
i added

[dndon-yealink]
Content-Type=>message/sipfrag
Event=>ACTION-URI
Content=>key=DNDOn

[dndoff-yealink]
Content-Type=>message/sipfrag
Event=>ACTION-URI
Content=>key=DNDOff

Comments

  • The reason for this is to have the phone show DND with the built in icon when the operator sets a user's presence via FOP2.

  • Hi,
    Thanks for sharing. Your code looks alright, I think this can be done as a plugin, or maybe as a toggle setting in the presence dnd plugin.

    Although plugins can write into configuration files via AMI functions, those are a bit dangerous as anything written to conf files by hand might be lost in some cases (I have seen that happen) and I think its not safe. And now that I think of it, you can write dialplans in the form of extension,priority and I do not know fi you can write header sections and the like.

    Asking users to write some custom dialplan is a bit of an issue here. I might try to hack it into generate_override_contexts, but this is a bit too specific, like 90% of users won't need this at all either because they are not using Yealinks, or they do but they do not care nor configure them to get this working. And many users, quite a lot, are still using ancient Asterisk versions when PJSIP did not exists at all.

    I am not sure how to handle it either.. but I am keen on making something if other users find it useful. Any idea or suggestion is welcome.

  • edited October 2019

    Yeah, what I posted works great. But every time I update FOP2 I'm worried I will lose my changes to /var/www/html/fop2/admin/plugins/presencedndfpbx/presencedndfpbx.pl. That is why I was wondering if there was a way to make this into a plugin.
    I get the issue with creating contexts. Why not have the plugin create its own conf file in /etc/asterisk and then have the plugin modify /etc/asterisk/extensions_override_freepbx.conf to include it.

    This is definitely not something everyone will use. But I have found it quite helpful for places where users only have their dsk phone and the operator has the FOP2 panel.

  • Hi,
    The .conf file for sip notifications is not dialplan, so we cannot included it there, and you cannot use just any file unless is #included in sip_notify.conf. So the need for modification of a file is still present, and permission issues might arise, and it is always something 'sensitive'. We can create a new plugin using the presencedndfpbx one as a base, so you won't lose anything if you upgrade the plugin in the future. I will see if I find the time to maybe extend the plugin or write a new one for firing up notifications on presence change in a 'general' way.

    Best regards,

  • If you change your Yealink to use the system feature codes then the handset and FOP2 DND status will be synced and there is no need to virtually press the DND button remotely on the device.

  • @Kirk_S said:
    If you change your Yealink to use the system feature codes then the handset and FOP2 DND status will be synced and there is no need to virtually press the DND button remotely on the device.

    That is standard, and does nothing for the point of the post. Having an operator change it in FOP2 and then have the phone reflect the same status.

  • Great feedback JaredBusch! The exact scenario "Having an operator change it in FOP2 and then have the phone reflect the same status." works for us on hundreds of systems with the setup I described. Good luck with your "cludgy" code.

  • @Kirk_S said:
    Great feedback JaredBusch! The exact scenario "Having an operator change it in FOP2 and then have the phone reflect the same status." works for us on hundreds of systems with the setup I described. Good luck with your "cludgy" code.

    Changing the DND status in FOP2 does not cause the phone to to come off of DND. It does cause the PBX to not see the extension in DND.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file