Started playing with LOCAL_PEEK
[from-internal]
exten => *123,1,Noop(Testing local peek)
same => n,Playback(beep)
same => n,Gosub(sp-sub-a1,s,1)
same => n,Goto(test-local-peek,s,1)
[test-local-peek]
exten => s,1,Gosub(sp-sub-b1,s,1)
same => n,Hangup()
[sp-sub-a1]
exten => s,1,Noop(In sub A1)
same => n,Set(myvar1=Sub1)
same => n,Gosub(sp-sub-a2,s,1)
same => n,Return()
[sp-sub-a2]
exten => s,1,Noop(In sub A2)
same => n,Noop(LOCAL PEEK: ${LOCAL_PEEK(0,myvar1)})
same => n,Return()
[sp-sub-b1]
exten => s,1,Noop(In sub B1)
same => n,Gosub(sp-sub-b2,s,1)
same => n,Return()
[sp-sub-b2]
exten => s,1,Noop(In sub B2)
same => n,Noop(LOCAL PEEK: ${LOCAL_PEEK(0,myvar1)})
same => n,Return()
Asterisk log:
Executing [*123@from-internal:1] NoOp("PJSIP/64066-00000036", "Testing local peek") in new stack
-- Executing [*123@from-internal:2] Playback("PJSIP/64066-00000036", "beep") in new stack
> 0x7f700c19f5a0 -- Strict RTP learning after remote address set to: 192.168.10.102:12166
> 0x7f700c19f5a0 -- Strict RTP qualifying stream type: audio
> 0x7f700c19f5a0 -- Strict RTP switching source address to my.wan.ip:12166
-- <PJSIP/64066-00000036> Playing 'beep.ulaw' (language 'en')
-- Executing [*123@from-internal:3] Gosub("PJSIP/64066-00000036", "sp-sub-a1,s,1") in new stack
-- Executing [s@sp-sub-a1:1] NoOp("PJSIP/64066-00000036", "In sub A1") in new stack
-- Executing [s@sp-sub-a1:2] Set("PJSIP/64066-00000036", "myvar1=Sub1") in new stack
-- Executing [s@sp-sub-a1:3] Gosub("PJSIP/64066-00000036", "sp-sub-a2,s,1") in new stack
-- Executing [s@sp-sub-a2:1] NoOp("PJSIP/64066-00000036", "In sub A2") in new stack
-- Executing [s@sp-sub-a2:2] NoOp("PJSIP/64066-00000036", "LOCAL PEEK: Sub1") in new stack
-- Executing [s@sp-sub-a2:3] Return("PJSIP/64066-00000036", "") in new stack
-- Executing [s@sp-sub-a1:4] Return("PJSIP/64066-00000036", "") in new stack
-- Executing [*123@from-internal:4] Goto("PJSIP/64066-00000036", "test-local-peek,s,1") in new stack
-- Goto (test-local-peek,s,1)
-- Executing [s@test-local-peek:1] Gosub("PJSIP/64066-00000036", "sp-sub-b1,s,1") in new stack
-- Executing [s@sp-sub-b1:1] NoOp("PJSIP/64066-00000036", "In sub B1") in new stack
-- Executing [s@sp-sub-b1:2] Gosub("PJSIP/64066-00000036", "sp-sub-b2,s,1") in new stack
-- Executing [s@sp-sub-b2:1] NoOp("PJSIP/64066-00000036", "In sub B2") in new stack
-- Executing [s@sp-sub-b2:2] NoOp("PJSIP/64066-00000036", "LOCAL PEEK: Sub1") in new stack
-- Executing [s@sp-sub-b2:3] Return("PJSIP/64066-00000036", "") in new stack
-- Executing [s@sp-sub-b1:3] Return("PJSIP/64066-00000036", "") in new stack
-- Executing [s@test-local-peek:2] Hangup("PJSIP/64066-00000036", "") in new stack
== Spawn extension (test-local-peek, s, 2) exited non-zero on 'PJSIP/64066-00000036'
So when do I increase the 0 if it always returns the correct information? I am afraid that I am missing the basics how the stack frames work in Asterisk.