так и делается, все работаетtonny_bennet писал(а):узнали статус, если занят сообщали об этом и дали возможность подождать
телепаты в отпуске - лето, жаркоtonny_bennet писал(а):но почему не работает и как сделать чтобы заработало я так и не понял
Код: Выделить всё
[from-internal-custom]
include => custom-check-number
[custom-check-number]
exten => 138,1,NoOp(Enter in custom-check-number)
exten => 138,n,Set(devst=${DEVICE_STATE(SIP/${EXTEN})})
exten => 138,n,ExecIf($["${devst}" = "INUSE"]?Playback(minutes))
exten => 138,n,NoOp(Exit from custom-check-number)
Код: Выделить всё
-- Executing [138@from-internal:1] NoOp("SIP/105-000077d8", "Enter in custom-check-number") in new stack
-- Executing [138@from-internal:2] Set("SIP/105-000077d8", "devst=NOT_INUSE") in new stack
-- Executing [138@from-internal:3] ExecIf("SIP/105-000077d8", "0?Playback(minutes)") in new stack
-- Executing [138@from-internal:4] NoOp("SIP/105-000077d8", "Exit from custom-check-number") in new stack
-- Executing [138@from-internal:5] Progress("SIP/105-000077d8", "") in new stack
-- Executing [138@from-internal:6] Playback("SIP/105-000077d8", "silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer") in new stack
-- <SIP/105-000077d8> Playing 'silence/1.gsm' (language 'ru')
-- <SIP/105-000077d8> Playing 'cannot-complete-as-dialed.alaw' (language 'ru')
-- <SIP/105-000077d8> Playing 'check-number-dial-again.alaw' (language 'ru')
-- Executing [138@from-internal:7] Wait("SIP/105-000077d8", "1") in new stack
-- Executing [138@from-internal:8] Congestion("SIP/105-000077d8", "20") in new stack
== Spawn extension (from-internal, 138, 8) exited non-zero on 'SIP/105-000077d8'
-- Executing [h@from-internal:1] Macro("SIP/105-000077d8", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/105-000077d8", "1?endmixmoncheck") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] NoOp("SIP/105-000077d8", "End of MIXMON check") in new stack
-- Executing [s@macro-hangupcall:10] GotoIf("SIP/105-000077d8", "1?nomeetmemon") in new stack
-- Goto (macro-hangupcall,s,28)
-- Executing [s@macro-hangupcall:28] NoOp("SIP/105-000077d8", "End of MEETME check") in new stack
-- Executing [s@macro-hangupcall:29] GotoIf("SIP/105-000077d8", "1?noautomon") in new stack
-- Goto (macro-hangupcall,s,34)
-- Executing [s@macro-hangupcall:34] NoOp("SIP/105-000077d8", "TOUCH_MONITOR_OUTPUT=") in new stack
-- Executing [s@macro-hangupcall:35] GotoIf("SIP/105-000077d8", "1?noautomon2") in new stack
-- Goto (macro-hangupcall,s,41)
-- Executing [s@macro-hangupcall:41] NoOp("SIP/105-000077d8", "MONITOR_FILENAME=") in new stack
-- Executing [s@macro-hangupcall:42] GotoIf("SIP/105-000077d8", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,45)
-- Executing [s@macro-hangupcall:45] GotoIf("SIP/105-000077d8", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,48)
-- Executing [s@macro-hangupcall:48] GotoIf("SIP/105-000077d8", "1?theend") in new stack
-- Goto (macro-hangupcall,s,50)
-- Executing [s@macro-hangupcall:50] AGI("SIP/105-000077d8", "hangup.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
-- <SIP/105-000077d8>AGI Script hangup.agi completed, returning 0
-- Executing [s@macro-hangupcall:51] Hangup("SIP/105-000077d8", "") in new stack
== Spawn extension (macro-hangupcall, s, 51) exited non-zero on 'SIP/105-000077d8' in macro 'hangupcall'
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/105-000077d8'
то надо использовать макрос (и/или gosub), именно макросы возвращают выполнение в ту же точку, откуда вызывались.после выполнения всех пунктов в custom-check-number, как мне кажется, должен вернуться обратно в from-internal-custom и обратно в from-internal.
Код: Выделить всё
[from-internal-custom]
exten => _X.,1,Macro(check-number,${ARG1})
exten => _X.,n,(NoOp We are the champions!)
[macro-check-number]
exten => s,1,NoOp(check status on-line for number ${ARG1})
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(minutes))
exten => s,n,NoOp(Exit from macro-check-number)
Код: Выделить всё
[from-internal-custom]
exten => 155,1,Macro(check-number,${EXTEN})
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(minutes))
exten => s,n,NoOp(Exit from macro-check-number)
Код: Выделить всё
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [155@from-internal:1] Macro("SIP/105-00007858", "check-number,155") in new stack
-- Executing [s@macro-check-number:1] NoOp("SIP/105-00007858", "Enter in custom-check-number") in new stack
-- Executing [s@macro-check-number:2] Set("SIP/105-00007858", "devst=NOT_INUSE") in new stack
-- Executing [s@macro-check-number:3] ExecIf("SIP/105-00007858", "0?Playback(minutes)") in new stack
-- Executing [s@macro-check-number:4] NoOp("SIP/105-00007858", "Exit from custom-check-number") in new stack
-- Executing [155@from-internal:2] Goto("SIP/105-00007858", ",return,1") in new stack
-- Goto (from-internal,return,1)
-- Executing [h@from-internal:1] Macro("SIP/105-00007858", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/105-00007858", "1?endmixmoncheck") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] NoOp("SIP/105-00007858", "End of MIXMON check") in new stack
-- Executing [s@macro-hangupcall:10] GotoIf("SIP/105-00007858", "1?nomeetmemon") in new stack
-- Goto (macro-hangupcall,s,28)
-- Executing [s@macro-hangupcall:28] NoOp("SIP/105-00007858", "End of MEETME check") in new stack
-- Executing [s@macro-hangupcall:29] GotoIf("SIP/105-00007858", "1?noautomon") in new stack
-- Goto (macro-hangupcall,s,34)
-- Executing [s@macro-hangupcall:34] NoOp("SIP/105-00007858", "TOUCH_MONITOR_OUTPUT=") in new stack
-- Executing [s@macro-hangupcall:35] GotoIf("SIP/105-00007858", "1?noautomon2") in new stack
-- Goto (macro-hangupcall,s,41)
-- Executing [s@macro-hangupcall:41] NoOp("SIP/105-00007858", "MONITOR_FILENAME=") in new stack
-- Executing [s@macro-hangupcall:42] GotoIf("SIP/105-00007858", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,45)
-- Executing [s@macro-hangupcall:45] GotoIf("SIP/105-00007858", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,48)
-- Executing [s@macro-hangupcall:48] GotoIf("SIP/105-00007858", "1?theend") in new stack
-- Goto (macro-hangupcall,s,50)
-- Executing [s@macro-hangupcall:50] AGI("SIP/105-00007858", "hangup.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
-- <SIP/105-00007858>AGI Script hangup.agi completed, returning 0
-- Executing [s@macro-hangupcall:51] Hangup("SIP/105-00007858", "") in new stack
== Spawn extension (macro-hangupcall, s, 51) exited non-zero on 'SIP/105-00007858' in macro 'hangupcall'
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/105-00007858'
Код: Выделить всё
-- Executing [155@from-internal:1] Macro("SIP/105-00007874", "check-number,155") in new stack
-- Executing [s@macro-check-number:1] NoOp("SIP/105-00007874", "Enter in custom-check-number") in new stack
-- Executing [s@macro-check-number:2] Set("SIP/105-00007874", "devst=INUSE") in new stack
-- Executing [s@macro-check-number:3] ExecIf("SIP/105-00007874", "1?Playback(minutes)") in new stack
-- <SIP/105-00007874> Playing 'minutes.alaw' (language 'ru')
-- Executing [s@macro-check-number:4] NoOp("SIP/105-00007874", "Exit from custom-check-number") in new stack
-- Executing [155@from-internal:2] Goto("SIP/105-00007874", ",return,1") in new stack
-- Goto (from-internal,return,1)
-- Executing [h@from-internal:1] Macro("SIP/105-00007874", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/105-00007874", "1?endmixmoncheck") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] NoOp("SIP/105-00007874", "End of MIXMON check") in new stack
-- Executing [s@macro-hangupcall:10] GotoIf("SIP/105-00007874", "1?nomeetmemon") in new stack
-- Goto (macro-hangupcall,s,28)
-- Executing [s@macro-hangupcall:28] NoOp("SIP/105-00007874", "End of MEETME check") in new stack
-- Executing [s@macro-hangupcall:29] GotoIf("SIP/105-00007874", "1?noautomon") in new stack
-- Goto (macro-hangupcall,s,34)
-- Executing [s@macro-hangupcall:34] NoOp("SIP/105-00007874", "TOUCH_MONITOR_OUTPUT=") in new stack
-- Executing [s@macro-hangupcall:35] GotoIf("SIP/105-00007874", "1?noautomon2") in new stack
-- Goto (macro-hangupcall,s,41)
-- Executing [s@macro-hangupcall:41] NoOp("SIP/105-00007874", "MONITOR_FILENAME=") in new stack
-- Executing [s@macro-hangupcall:42] GotoIf("SIP/105-00007874", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,45)
-- Executing [s@macro-hangupcall:45] GotoIf("SIP/105-00007874", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,48)
-- Executing [s@macro-hangupcall:48] GotoIf("SIP/105-00007874", "1?theend") in new stack
-- Goto (macro-hangupcall,s,50)
-- Executing [s@macro-hangupcall:50] AGI("SIP/105-00007874", "hangup.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
-- <SIP/105-00007874>AGI Script hangup.agi completed, returning 0
-- Executing [s@macro-hangupcall:51] Hangup("SIP/105-00007874", "") in new stack
== Spawn extension (macro-hangupcall, s, 51) exited non-zero on 'SIP/105-00007874' in macro 'hangupcall'
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/105-00007874'
Код: Выделить всё
-- Executing [155@from-internal:2] Goto("SIP/105-00007858", ",return,1") in new stack
-- Goto (from-internal,return,1)
А каким должен он быть? Я так и не могу понять логику вложенных контекстов. Казалось сначала, что они аналогичны процедурам из языка Pascal: вызвал, отработал и вернул выполнение в точку, где оно было прервано. Сейчас получается, что при выполнении макроса, он выходит в контекст from-internal, а не в from-internal-custom, и начинает работу с экстеншена return.ded писал(а):нет второго шага!
Откуда берётся return в принципе не понятно.Коды возврата
Команда Macro вернет значение -1, если любая из команд в макроопределении вернет -1, иначе возвращает 0.