[asterisk-users] [1.4.21.2] Checking that already off-hook?

Vincent vincent.delporte at bigfoot.com
Tue Sep 23 13:22:02 CDT 2008


On Tue, 23 Sep 2008 12:29:22 +0200, Vincent
<vincent.delporte at bigfoot.com> wrote:
>Isn't there a way to check the status an FXO card is in?

Apparently, it's OK to call Answer() even if the channel is already
open:

http://www.voip-info.org/wiki/view/Asterisk+cmd+Answer

So I guess I can simplify things this way:

[my-ivr]
HELLO=false

exten => s,1,GotoIf($[${LEN(${CALLERID(num)})} = 0]?nocid,1:cid,1)
       
exten => nocid,1,Set(HELLO=true);
exten => nocid,n,Answer()
exten => nocid,n,Playback(my_sound_files/hello)
exten => nocid,n,Read(CALLERID(num),my_sound_files/no_cid,10)
exten => nocid,n,GotoIf($[${LEN(${CALLERID(num)})} < 10]?cid,1)
exten => nocid,n,Hangup()

;If number in DB, rewrite CID name on the fly
exten =>
cid,1,AGI(check_cid.phpcli|${CALLERID(num)}|${CALLERID(name)})
exten => cid,n,Goto(main_menu,s,1)

[main_menu]
;OK to call Answer() even if line already off-hook
exten => s,1,Answer()
exten => s,n,ExecIf($[${HELLO} = true],Playback,my_sound_files/hello)
exten => s,n,Background(my_sound_files/main_menu)
exten => s,n,WaitExten(5)
exten => s,n,Hangup()

Thank you.




More information about the asterisk-users mailing list