Getting there with asterisk.adsi

Comment on Asterisk cmd ADSIProg
chriswnl
Joined: Sun 27 of Mar, 2005

Getting there with asterisk.adsi

Posted:Sun 27 of Mar, 2005 (22:13 UTC)
For anyone who has played around with ADSI and Asterisk you've probably seen it's been a big self learning process. I had the same issue and by no means would I ever declare myself an expert at it but at least the penny is beginning to drop so I wanted to add my findings here in the hope that someone who is a little bit more understanding of these things might pick it all up and we might see some more knowledge exchange on ADSI.

;
; Asterisk default ADSI script
;
;; comments with the three ; supplied by Chris Willis
asterisk at mokum (then the dot) org
;
; Begin with the preamble requirements
;

;;; I have no idea what the Version bit is for here but the DESCRIPTION just seems to get
;;; printed when you update your phone via ADSIProg() with the a message like:
;;; Receiving programming
;;; Asterisk PBX
;;; or whatever else you have here
DESCRIPTION "Asterisk PBX" ; Name of vendor
VERSION 0x00 ; Version of stuff

;;; It seems you have to program slots 1 and 2. The following FDN and SECURITY codes worked
;;; for me after I reset the phone (see:
;;; www.mail-achive.com/asterisk-users@lists.digium.com/msg29886.html on how to do that

;;; I believe you have to program each slot separately so do slot 1 like this then
;;; add ; infront of it and later remove the ;s from Slot 2

; SLOT 1 for my PT390
FDN 0x0000000F
SECURITY 0X9BDBF7AC
; SLOT 2 - Self Loading
;FDN 0x85EFD9DA
;SECURITY 0X78921D49

;
; Flags
;;; I just left this as it was but it sounds quite selfexplanatory at this stage at least
;
FLAG "nocallwaiting"

;
; Predefined strings
;;; These are like variables. So under the first bit after DISPLAY is the name of the
;;; variable you can use later on. The bit that follows after the IS, cannot be more
;;; than 20 characters or it gets truncated.
;
DISPLAY "titles" IS "** My Asterisk **"
DISPLAY "owneris" IS "My Name" ; allow my name to appear on screen in case I forget it
DISPLAY "phonenumber" IS "123-456-7890" ; I wanted my phone number to appear on screen
DISPLAY "extnnr" IS "Extension 123" ; reminds me of the extension I created for phone
;;; the JUSTIFY stuff tells the system where to put the text when used, by default
DISPLAY "talkingto" IS "Call active" JUSTIFY CENTER
DISPLAY "callname" IS "$Call1p" JUSTIFY CENTER
DISPLAY "callnum" IS "$Call1s" JUSTIFY CENTER
DISPLAY "incoming" IS "Incoming call!" JUSTIFY CENTER
DISPLAY "ringing" IS "Calling... " JUSTIFY CENTER
DISPLAY "callended" IS "Call ended" JUSTIFY CENTER
DISPLAY "missedcall" IS "Missed call" JUSTIFY CENTER
DISPLAY "busy" IS "Party busy" JUSTIFY CENTER
DISPLAY "reorder" IS "Reorder" JUSTIFY CENTER
DISPLAY "callback" IS "Call back" JUSTIFY CENTER
DISPLAY "empty" IS "asdf"

;
; Begin soft key definitions
;

;;; these are the soft keys (the 6 keys around the screen) which can change depending
;;; on what the phone is doing. Keeping it simple for now, I just use them as
;;; speed dial functions.
;;;
;;; In the example below, speeddial1_OH is the name I am giving to the softkey which I
;;; will later use when I want it to appear on the screen. the second fied is the name
;;; which will appear on the screen. NOTE this has a max of 7 characters. The third
;;; field seems to be unused by my PT390 but could be used by a different phone, I'm
;;; guessing/assuming.

KEY "speeddial1_OH" IS "MyName" OR "My Full Name"
OFFHOOK
;;; the offhook statement takes the phone off hook so if you show this button when the
;;; phone is idle, pressing it will pick up the line (ie without having to do it yourself
VOICEMODE
;;; I want to talk, not send data (datamode is also an option but haven't used it
WAITDIALTONE
;;; don't do anything until I hear a dial tone
SENDDTMF "0123456789"
;;; dial the number - this gets passed to Asterisk
ENDKEY
;;; end the key definition


;;; The next is the same speeddial but is designed for when I pick up the phone to make a
;;; call. I don't need any OFFHOOK statement here as the phone is already off-hook.

KEY "speeddial1" IS "MyName" OR "My Full Name"

;;; so all we need to do is send the number
SENDDTMF "0123456789"
ENDKEY
;;; don't forget to specify the end of the definition


;;; Now here is another speed dial just for the sake of demonstration
KEY "speeddial2_OH" IS "John" OR "John Doe"
OFFHOOK
VOICEMODE
WAITDIALTONE
SENDDTMF "9876543210"
ENDKEY

KEY "speeddial2" IS "John" OR "John Doe"
SENDDTMF "9876543210"
ENDKEY

;;; This next one just leaves the softkey blank and you might want to use that later on to
;;; keep your phone looking the same when in use/idle.

KEY "blank" is "" or "Blank"
GOTO "offhook"
ENDKEY

;;; I use 100 in features.conf to park calls. You should change the 100 here to whatever
;;; you use.

KEY "park" IS "Park" OR "Park Call"
SENDDTMF "#100"
ENDKEY

KEY "transfer" IS "X-fer" OR "Transfer"
SENDDTMF "#"
ENDKEY

;;; Flash is the quick tapping of the hook to initiate a transfer on an old POTS line. In
;;; the UK this key is normally the R button, standing for Recall.

KEY "flash" is "Flash" or "Recall"
FLASH
ENDKEY

;;; If you have voicemail accessible via the phone you might want an on-hook and an
;;; off-hook version of the key defined. Change the access number to whatever your
;;; voicemail is on
KEY "vmail_OH" IS "VMail" OR "Voicemail"
OFFHOOK
VOICEMODE
WAITDIALTONE
SENDDTMF "8500"
ENDKEY

KEY "vmail" IS "VMail" OR "Voicemail"
SENDDTMF "8500"
ENDKEY

;;; good for going back if you're predialling a number

KEY "backspace" IS "BackSpc" OR "Backspace"
BACKSPACE
ENDKEY

;;; this is just something that KPN offers in Holland. You may or may not have such a
;;; service where you are. Basically if a called party is busy, you can press 5 to have
;;; the system call you back. Given the way VOIP works this isn't going to be much good
;;; if half your calls are routed through another supplier but still. It's in there.

KEY "callback" IS "CallBck" OR "Call back on busy"
SENDDTMF "5"
;;; showdisplay allows you to put the words stored in the variable on the screen.
;;; in this case, variable 'callback' has value 'Call back' and will be displayed at
;;; line 4
SHOWDISPLAY "callback" AT 4
ENDKEY


;
; Begin main subroutine
;;; Up to now, you haven't printed a single thing to your phone! You've just set up variables
;;; so that the fun can now begin.
;;;
;;; I have not even got all these different events sorted out in my own head yet, so am not
;;; going to comment throughout. However, IFEVENT is quite obvious - ie if it's happening;
;;; SHOWDISPLAY "variable" at 1 would show the value of variable in line 1 etc eg:

SUB "main" IS
IFEVENT NEARANSWER THEN
CLEAR
SHOWDISPLAY "titles" AT 1 NOUPDATE
SHOWDISPLAY "talkingto" AT 2 NOUPDATE
SHOWDISPLAY "callname" AT 3
SHOWDISPLAY "callnum" AT 4
SHOWKEYS "park"
SHOWKEYS "blank"
SHOWKEYS "transfer"
SHOWKEYS "blank"
SHOWKEYS "blank"
SHOWKEYS "flash"
GOTO "stableCall"
ENDIF
IFEVENT OFFHOOK THEN
CLEAR
CLEARFLAG "nocallwaiting"
CLEARDISPLAY
SHOWDISPLAY "titles" AT 1
SHOWKEYS "vmail"
SHOWKEYS "blank"
SHOWKEYS "blank"
SHOWKEYS "speeddial1"
SHOWKEYS "speeddial2"
GOTO "offHook"
ENDIF
IFEVENT IDLE THEN
CLEAR
SHOWDISPLAY "owneris" AT 1
SHOWDISPLAY "phonenumber" AT 2
SHOWDISPLAY "extnnr" AT 3
SHOWKEYS "vmail_OH"
SHOWKEYS "blank"
SHOWKEYS "blank"
SHOWKEYS "speeddial1_OH"
SHOWKEYS "speeddial2_OH"
ENDIF
IFEVENT CALLERID THEN
CLEAR
; SHOWDISPLAY "titles" AT 1 NOUPDATE
; SHOWDISPLAY "incoming" AT 2 NOUPDATE
SHOWDISPLAY "callname" AT 3 NOUPDATE
SHOWDISPLAY "callnum" AT 4
ENDIF
IFEVENT RING THEN
CLEAR
SHOWDISPLAY "titles" AT 1 NOUPDATE
SHOWDISPLAY "incoming" AT 2
ENDIF
IFEVENT ENDOFRING THEN
SHOWDISPLAY "missedcall" AT 2
CLEAR
SHOWDISPLAY "titles" AT 1
SHOWKEYS "vmail_OH"
ENDIF
IFEVENT TIMER THEN
CLEAR
SHOWDISPLAY "empty" AT 4
ENDIF
ENDSUB

SUB "offHook" IS
IFEVENT FARRING THEN
CLEAR
SHOWDISPLAY "titles" AT 1 NOUPDATE
SHOWDISPLAY "ringing" AT 2 NOUPDATE
SHOWDISPLAY "callname" at 3 NOUPDATE
SHOWDISPLAY "callnum" at 4
ENDIF
IFEVENT FARANSWER THEN
CLEAR
SHOWDISPLAY "talkingto" AT 2
SHOWKEYS "park"
SHOWKEYS "blank"
SHOWKEYS "transfer"
SHOWKEYS "blank"
SHOWKEYS "blank"
SHOWKEYS "flash"
GOTO "stableCall"
ENDIF
IFEVENT BUSY THEN
CLEAR
SHOWDISPLAY "titles" AT 1 NOUPDATE
SHOWDISPLAY "busy" AT 2 NOUPDATE
SHOWDISPLAY "callname" at 3 NOUPDATE
SHOWDISPLAY "callnum" at 4
ENDIF
IFEVENT REORDER THEN
CLEAR
SHOWDISPLAY "titles" AT 1 NOUPDATE
SHOWDISPLAY "reorder" AT 2 NOUPDATE
SHOWDISPLAY "callname" at 3 NOUPDATE
SHOWDISPLAY "callnum" at 4
ENDIF
ENDSUB

SUB "stableCall" IS
IFEVENT REORDER THEN
SHOWDISPLAY "callended" AT 2
ENDIF
ENDSUB

;;; I really hope this has been a help. If it has, great! But please please please don't ask
;;; me too many questions about this. I'm just learning it myself. Any ideas on how to hook
;;; it up to an LDAP server would be very very welcome.