NSLU2-Linux
view · edit · print · history

If you have an unlimited incoming subscription for your cell phone and want to take advantage of the low VoIP international rates your Asterisk PBX has, this callback macro might be of interest. You can call from your cell phone home and when your voicemail picks up, press * and enter you password. Then Select 3 "advanced options" and 4 "place outgoing call". Then dial the callback extension (555 in this example) and wait for confirmation. You will receive immediately an incoming call on your cell phone and when answered you will hear an invitation to dial the number you wish to call.

  • This stuff has to be added to your extensions.conf (and configure your data in the following constants):

; for callback
CB_PROTOCOL=SIP
CB_PROVIDER=gizmo
CB_CALLING_DEFAULT=17475551234
CB_NO_CID=spa3102fxo1
CB_SCRIPT=/opt/sbin/asterisk-cb
CB_ASTERISK_CID=16045552222

[macro-callback]
; Callback macro:
;   ${ARG1} - Callback Channel Type (SIP or IAX2)
;   ${ARG2} - Provider
exten => s,1,Playback(wait-moment)
exten => s,n,GotoIf($["${CALLERID(num)}" = ""]?no_cid)
exten => s,n,GotoIf($["${CALLERID(num)}" = "${CB_NO_CID}"]?no_cid)
exten => s,n,Set(CB_CALLING=${CALLERID(num)})
exten => s,n,Goto(do_cb)
exten => s,n(no_cid),Set(CB_CALLING=${CB_CALLING_DEFAULT})
exten => s,n(do_cb),System(${CB_SCRIPT} ${ARG1} ${ARG2} ${CB_CALLING} ${CB_ASTERISK_CID})
exten => s,n,GotoIf($[${SYSTEMSTATUS} = SUCCESS}]?done)
exten => s,n,Playback(service&privacy-not&activated&vm-goodbye)
exten => s,n,Hangup
exten => s,n(done),Playback(service&activated&vm-goodbye)
exten => s,n,Hangup


[callthrough]
exten => s,1,Set(NR=)
exten => s,2,Background(vm-enter-num-to-call&and-prs-pound-whn-finished)
exten => s,3,Set(TIMEOUT(response)=10)
exten => s,4,WaitExten

exten => *,1,Goto(s,1)
exten => #,1,Playback(vm-dialout)
exten => #,2,Dial(Local/${NR})
exten => #,3,Macro(failann,${DIALSTATUS})

exten => _X,1,Set(NR=${NR}${EXTEN})
exten => _X,2,Goto(s,3)

exten => t,1,Playback(vm-goodbye)
exten => t,2,HangUp


[default]
; ...
; callback extension
exten => 555,1,Macro(callback,${CB_PROTOCOL},${CB_PROVIDER})

  • This is the callback shell script:

# cat /opt/sbin/asterisk-cb
#! /bin/sh

OUTGOING_SPOOL_DIR="/opt/var/spool/asterisk/outgoing"

if [ $# != 4 ]
then exit 1
fi

case "$1" in
  SIP)
    ORIGINATING_CHANNEL="SIP/$3@$2"
    ;;
  IAX2)
    ORIGINATING_CHANNEL="IAX2/$2/$3"
    ;;
  *)
    exit 1
    ;;
esac

cat > $OUTGOING_SPOOL_DIR/cb.tmp <<INLINE
Channel: $ORIGINATING_CHANNEL
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: callthrough
Extension: s
Priority: 1
CallerID: $4
INLINE

mv $OUTGOING_SPOOL_DIR/cb.tmp $OUTGOING_SPOOL_DIR/cb.call

exit 0

view · edit · print · history · Last edited by cdoban.
Originally by cdoban.
Page last modified on January 27, 2007, at 06:56 AM