The definitive guide to asterisk DND with the Cisco SPA5xx SIP Phone

The Problem

When someone calls through to our receptionist and she tries to transfer the call to another phone that just happens to be on DND, she gets a busy tone (as expected) and the call fails.  The problem is that the BLF on our attendant console is still GREEN, indicating the phone should be available, so she doesn't know that the phone is on DND until she tries to call it.  
What we would like to have is the BLF on the attendant console to go RED when the phone is set to DND.
I have this working on the CISCO SPA504G and SPA509G phones with the following hacks:

Phone Configuration

Phone -> Supplementary Services -> Service Annc Serv : Yes
Regional -> Vertical Service Announcement Codes -> Service Annc Base Number : *7
Regional -> Vertical Service Announcement Codes -> Service Annc Extension Codes : DDT:8;DDF:9
Now, what all that does is first, turns on Service Announce feature.  This means that when a _Vertical Service Activation Code_ is dialled, a call is placed to the PBX to the extension base number followed by a prefix.  DDT sets the prefix to 8 when DND is enabled.  DDF sets it to 9 when DND is disabled.  So, when DND is enabled by dialling *78* on the phone, a call is also placed to extension *78 on the PBX.  Likewise, when DND is disabled by dialling *79* on the phone, a call is also placed to extension *79 on the PBX.   We set these extensions up in a sec.
The problem we have is that this service announce feature only works when the vertical service activation code is dialled, and NOT when the DND button is pressed.  So we replace the standard DND button with our own that dials the vertical activation code instead.
Phone -> Programmable Softkeys -> PSK1 : fnc=sd;ext=*78*;nme=dnd;ext2=*79*;nme2=-dnd
Then in Idle Key List change any reference to dnd with psk1.  This will exactly replicate the function of the built in DND key and users won't know the difference.  How it works is the softkey has a built-in two state toggle function.  It will initially display dnd and when pressed dial the vertical service activation code *78* which puts the phone into DND mode.  Because we have service announce enabled it also calls the *78 extension to tell the server we are in DND mode.  The button then displays -dnd on the label.
Then the next time the button is pressed it toggles it's state back and dials *79* to disable DND, again notifying the PBX by calling the *79 extension.

Asterisk Configuration

In the extensions.conf file we need to add a couple of things.  First is extending the extension state hint to include a custom DND device state.
For each extension hint, we just add _&Custom:DND:${EXTEN}_ to the end.  So for example, the existing hint for extension 4335 would be:
exten => 4335,hint,SIP/${EXTEN}
So it would then become:
exten => 4335,hint,SIP/${EXTEN}&Custom:DND:${EXTEN}
Now that the hints are set up we need to add the *78 and *79 extensions to set the custom DND device state so we add the following to our [handsets] context in the extensions.conf file.
; DND Toggle
exten => *78,1,Answer
exten => *78,n,Set(DEVICE_STATE(Custom:DND:${CALLERID(num)})=INUSE)
exten => *78,n,Playback(ascending-2tone)
exten => *78,n,Hangup
exten => *79,1,Answer
exten => *79,n,Set(DEVICE_STATE(Custom:DND:${CALLERID(num)})=NOT_INUSE)
exten => *79,n,Playback(descending-2tone)
exten => *79,n,Hangup
And that's it!  (no, really).

What about the Linksys SPA Phones?

Unfortunately this currently only works on the Cisco SPA and not the old Linksys SipuraSPA phones for the following reasons.
  • Requires two-state programmable softkeys.
  • Requires programmable softkeys!!!
We can still set up the service announce feature and get the phone to notify the PBX when DND is activated on the phone, but ONLY when it is activated using *78*.
If we can somehow program a key to toggle DND then we are all set!

Leave a reply

Fill in your details below or log in: