Liens importants

Exemple d'un CallBack

asterisk@laotseu:~$ cat /tmp/hello-world.call
Channel: SIP/FXO1/99306XXXXXXXX
MaxRetries: 3
RetryTime: 60
WaitTime: 30
Context: interne
Extension: 900
Priority: 1
Ca marche comme ca: (chez M…)
asterisk@laotseu:~$ sleep 600; cp /tmp/hello-world.call /var/spool/asterisk/outgoing/

Tester en SIP par l'exemple

Ceci est un cut'n paste en provenance de http://www.asterisk-france.org/showthread.php/1010-Temps-validit%C3%A9-authentification-SIP

Pour les tests de la mémoire il faut bien utiliser toute la chaîne d’authentification, REGISTER 401 REGISTER, sinon le test est mauvais. Je vais te donner la commande de 'sipsak' qui est capable de s’enregistrer avec le mot de passe:

/usr/bin/sipsak -U -d -n -x 3700 -C sip:3397075xxxx@83.xx.xx.xx:5060 -s sip:3397075xxxx@sip.domaine.fr:5060 -vvv -a MOTDEPASSE -H 83.xx.xx.xx.xx

En details:

  • -C = TON URI (ton contact)
  • -s = Destination (ton asterisk)
  • -a mot de passe de ton compte.

Iterations sur une chaine

exten => 914,1,NoOp(On apprend a compter a partir de ${ADLPALL})
exten => 914,n,Set(i=1)
exten => 914,n,Set(j=${CUT(ADLPALL,&,${i})})
exten => 914,n,While(${LEN(${j})} > 0)
exten => 914,n,NoOp(ICI ON TRAITE LE TRUC DU MACHIN   ${j} ${i})
exten => 914,n,Set(i=$[${i} + 1])
exten => 914,n,Set(j=${CUT(ADLPALL,&,${i})})
exten => 914,n,EndWhile
exten => 914,n,HangUp

Creer une macro, et l'utiliser

La macro

[macro-itexten]
exten => s,1,NoOp(On apprend a compter a partir de ${ARG1})
exten => s,n,Set(k=${ARG1})
exten => s,n,Set(i=1)
exten => s,n,Set(j=${CUT(k,&,${i})})
exten => s,n,While(${LEN(${j})} > 0)
exten => s,n,NoOp(ICI ON TRAITE LE TRUC DU MACHIN   ${j} ${i})
exten => s,n,Set(i=$[${i} + 1])
exten => s,n,Set(j=${CUT(k,&,${i})})
exten => s,n,EndWhile
exten => s,n,HangUp
Son appel
exten => 915,1,NoOp(Pouette)
exten => 915,n,Macro(itexten,${ADLPALL})

Adlp' Tools

Macro de creation des fichiers de callback

Cette macro evite de :

  1. Faire appel a un AGI specialisé pour faire un call-back
  2. Recoder systematiquement la creation d'un call-back

[macro-CallBackScript]
;;;;; Macro(CallBackScript,SIP/pouette,"Pouette",MaxRetries-RetryTime-WaitTime-Account,Quand,Extention@Context,SetVars)
;;;;; Macro(CallBackScript,SIP/pouette,"Pouette",MaxRetries-RetryTime-WaitTime-Account,Quand,Application      ,Params )
;;;;;                          1           2         3                                   4        5             6 
;;;;;    * Specify where and how to call
;;;;;        A o Channel: <channel>: Channel to use for the call.
;;;;;        A o CallerID: "name" <number> Caller ID, Please note: It may not work if you do not respect the format: CallerID: "Some Name" <1234>
;;;;;        B1o MaxRetries: <number> Number of retries before failing (not including the initial attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
;;;;;        B2o RetryTime: <number> Seconds between retries, Don't hammer an unavailable phone. Default is 300 (5 min).
;;;;;        B3o WaitTime: <number> Seconds to wait for an answer. Default is 45.
;;;;;        B4o Account: Set the account code to use.
;;;;;    * If the call answers, connect it here:
;;;;;        C o Context: <context-name> Context in extensions.conf
;;;;;        C o Extension: <ext> Extension definition in extensions.conf
;;;;;          o Priority: <priority> Priority of extension to start with
;;;;;        C o Set: Set a variable for use in the extension logic (example: file1=/tmp/to ); in Asterisk 1.0.x use 'SetVar' instead of 'Set'
;;;;;        D o Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
;;;;;        D o Data: The options to be passed to application
;;;;;    * New (?) in Asterisk 1.4
;;;;;          o Set: Can now also write to dialplan functions like CDR()
;;;;;          o AlwaysDelete: Yes/No - If the file's modification time is in the future, the call file will not be deleted
;;;;;          o Archive: Yes/No - Move to subdir "outgoing_done" with "Status: value", where value can be Completed, Expired or Failed.
exten => s,1,NoOp(Puttin)
exten => s,n,Set(FiEx=${RAND(1,10000)})
exten => s,n,Set(MaxRet=${CUT(ARG3,-,1)})
exten => s,n,Set(MaxRet=${IF(${LEN(${MaxRet})} ? ${MaxRet} : 0)})
exten => s,n,Set(RetryT=${CUT(ARG3,-,2)})
exten => s,n,Set(RetryT=${IF(${LEN(${RetryT})} ? ${RetryT} : 200)})
exten => s,n,Set(WaitTi=${CUT(ARG3,-,3)})
exten => s,n,Set(WaitTi=${IF(${LEN(${WaitTi})} ? ${WaitTi} : 45)})
exten => s,n,Set(Accoun=${CUT(ARG3,-,4)})
exten => s,n,Set(Accoun=${IF(${LEN(${Accoun})} ? ${Accoun} : ScriptEd)})
exten => s,n,Set(A=Channel: ${ARG1}\\nCallerID: ${ARG2}\\nMaxRetries: ${MaxRet}\\nRetryTime: ${RetryT}\\nWaitTime: ${WaitTi}\\nAccount: ${Accoun}\\n)
exten => s,n,Set(Cont=${CUT(ARG5,@,2)})
exten => s,n,Set(Exte=${CUT(ARG5,@,1)})
exten => s,n,Set(B=Context: ${Cont}\\nExtension: ${Exte}\\nPriority: 1\\n${ARG6})
exten => s,n,Set(C=Application: ${ARG5}\\nData: ${ARG6})
exten => s,n,Set(i=7)
exten => s,n,While(${LEN(${ARG${i}})})
exten => s,n,Set(C=${C},${ARG${i}})
exten => s,n,Set(i=$[${i} + 1])
exten => s,n,EndWhile
exten => s,n,Set(SysC=${IF(${LEN(${Cont})>0}?B:C)})
exten => s,n,system(echo "${A}${${SysC}}" >/tmp/recall.call-${FiEx})
exten => s,n,GotoIf($[${LEN(${ARG4})}=0]?touchfait)
exten => s,n,Set(Touh=${ARG4})
exten => s,n,GotoIf($[${LEN(${CUT(ARG4,+,2)})}=0]?noaddi)
exten => s,n,Set(i=${CUT(ARG4,+,2)})
exten => s,n,Set(j=${STRFTIME(${EPOCH},,%Y%m%d%H%M)})
exten => s,n,Set(Touh=${MATH(${i}+${j})})
exten => s,n,Set(Touh=${CUT(Touh,.,1)})
exten => s,n(noaddi),system(touch -t ${Touh} /tmp/recall.call-${FiEx})
exten => s,n(touchfait),NoOp(On va tenter de faire quelquechose de drole, ou pas...)
exten => s,n,system(mv /tmp/recall.call-${FiEx} /var/spool/asterisk/outgoing/)
TODO: Mettre des exemples d'appel Ci-joint des exemples d'usage de la macro
[interne]
exten => 913,1,NoOp(On apprend a compter)
exten => 913,n,Macro(CallBackScript,SIP/z6poi,,,,echo)
exten => 913,n,HangUp()

exten => 914,1,NoOp(On apprend a compter)
exten => 914,n,Macro(CallBackScript,SIP/z6poi,,,,repondeur@interne)
exten => 914,n,HangUp()

exten => 915,1,NoOp(On apprend a compter)
exten => 915,n,Macro(CallBackScript,SIP/z6poi,,,+5,Voicemail,1234,b)
exten => 915,n,HangUp()

exten => 916,1,NoOp(On demontre la conference)
exten => 916,n,Macro(InMeetifAvailable,Chambre,${ADLPALLI},a Couchee)
exten => 916,n,HangUp

exten => repondeur,1,NoOp(Zi repondeur)
exten => repondeur,n,Voicemail(1234,b)
exten => repondeur,n,HangUp

Selection de ligne sortante par priorité

Cette macro evite de :

  1. d'utiliser les autres methodes de selection d'un groupe de ligne

Elle va

  1. Tester si la ligne est disponible
  2. Si elle l'est elle passe l'appel dessus
  3. Sinon elle passe a la suivante

Conseil

  1. Placer dans la derniere ligne en fait un appel vers un PlayBack…
docs/linuxeries/asterisk/start.txt · Dernière modification: 2014/03/19 11:30 (édition externe)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki