As part of Asterisk's adaptation to the needs of superiors and their secretaries, I was puzzled by the indication of the DND mode (“Do Not Disturb” - “Do Not Disturb”) on the BLF (Busy Lamp Field) keys. On Habré there was a corresponding
post (and in the commentary there is also a useful link to the alternate method).
“DnD is a rather demanded function, but usually the mode is turned on on the phone itself, without notifying Asterisk about it, which will call the user’s phone, thinking that it’s in place and ready to answer the call. How do we turn on the DnD mode on Asterisk itself and so that the power button will blink in red when DnD is activated? »©
xtelekomHowever, it was not possible just to take and start using DND on the BLF.
1. The first method at first glance looks difficult. Without a detailed explanation, it is difficult to use the code in school, but in production it is scary. As shown by further research, you can get by with less code.
2. The red light should not blink (the subscriber is called, he does not pick up the phone, maybe you need to intercept the call?), But constantly on (the subscriber is busy).
3. In the second method, checking the current state of the DND always returned
true
. Naturally, the method did not work.
4. The problem of DND indication at the subscriber. Well, if the phone has the ability to dial when removing / installing DND. In my Chinese phone there is no such possibility, and the DND button itself is surprisingly inconvenient - it is a toggle switch on the back of the phone. Of course, there is no problem to hang DND (dialing, say, * 76) on the multifunction key, and hint on your number on the next MF-key. But it is logical if all the DND functionality (both switching and indication) will be on the same key. I came to the conclusion that in order to enable DND the subscriber will dial his number, then the observed and the dialed numbers will be the same, which is necessary.
')
In the process of doping, the technique evolved quite significantly, so I decided to share the results of the work. The results tried to make the most understandable and, if possible, equip with comments.
So, we have Asterisk 1.8.18.0, subscribers already exist and use the BLF function.
First of all, we will use the work of our colleagues and in a slightly modified form we implement the DND by dialing * 76. We add the following context to our dialplan:
[dnd-on-off] exten => *76,1,Answer ; DND? exten => *76,n,GotoIf($["${DB(DND/${CALLERID(number)})}" = ""]?activate:deactivate) ; DND — exten => *76,n(activate),Set(STATE=BUSY) ; "" ( hint) exten => *76,n,Set(DEVICE_STATE(Custom:DND${CALLERID(number)})=${STATE}) ; DND exten => *76,n,Set(DB(DND/${CALLERID(number)})=1) exten => *76,n,Hangup ;;; DND — exten => *76,n(deactivate),Set(STATE=NOT_INUSE) ; "" ( hint) exten => *76,n,Set(DEVICE_STATE(Custom:DND${CALLERID(number)})=${STATE}) ; DND exten => *76,n,Set(DB(DND/${CALLERID(number)})=) exten => *76,n,Hangup
Now add a context that will include the DND for dialing your number.
[dnd-on-off-2] ; - ? exten => _7XXX,1,GotoIf($["${CALLERID(number)}" = "${EXTEN}"]?godnd:gonext) ; - DND exten => _7XXX,n(godnd),Goto(dnd-on-off,*76,1) ; - ( 10) exten => _7XXX,n(gonext),Goto(10)
Now we will teach Asterisk to check the status of the called subscriber, and hang up on the detection of DND mode. To do this, add the line just before calling the subscriber.
; , DND exten => _7XXX,n,GotoIf($["${DB(DND/${EXTEN})}" = "1"]?gooff) exten => _7XXX,n,Dial(SIP/${EXTEN},20,Tt) exten => _7XXX,n(gooff),Hangup()
It remains to use new contexts where needed:
; , SIP- [outcoming-sip] ;;; : / DND include => dnd-on-off-2 ;;; "exten => _X.,1,Goto(10)" include => goto10 ;;; : / DND *76 include => dnd-on-off ;;; SIP- ( 10) include => sip-phones
Save and do
asterisk -rx "dialplan reload"
.
After that, on the phone, we transfer the favorite multifunction key to BLF mode and assign the subscriber’s hint to it. Pickup code is not specified, it is not needed. Although, of course, it all depends on the phone (I have a Flying Voice IP-622).
Now, after pressing the "Do Not Disturb" key, calls to the subscriber are stopped, the key itself lights up red, and the secretary turns on the red key "Chief", the mission is completed.
PS I would like to express special thanks to the Flying Voice IP622 phone, which, although it behaved slightly inadequately on the old firmware and slightly wry during the update, now shows itself well done. The functionality is rich, the support is hard-working, and the firmware interface v1.4 and v3 is almost identical. For its price just gorgeous.