Subject IAX call to the same call flow as another trunk

What I’d like to do might sound complicated, but if I first explain the use case, it might not sound so bad! From work, I like to be able to call home via an IAX trunk. Both work and home are FreePBX based.

If other people call our house phone and we’re not in, a call flow control (day night type) tells the caller if we’re in or not. However if I call via the IAX trunk, the call will just ring and ring, whether or not there’s anyone in at home.

I had the idea of somehow sending the IAX trunk through the same day/night control as the other trunk.

@billsimon helped massively with this with an idea for how it could be done.

I haven’t been able to come up with a way to send both trunks through the same call flow control, so for the time being I’ve just made a ‘test’ call flow day/night toggle.

However, when I try to use it, I get this in my logs:-

[2019-09-30 21:14:08] VERBOSE[1272] chan_iax2.c: Accepting UNAUTHENTICATED call from 192.x.x.x:4569:
> requested format = ulaw,
> requested prefs = (ulaw),
> actual format = ulaw,
> host prefs = (ulaw),
> priority = mine
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [4001@from-iax-partner-pbx:1] Goto("IAX2/home_to_work-9120", "app-daynight-toggle,s,3") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx_builtins.c: Goto (app-daynight-toggle,s,3)
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:3] Set("IAX2/home_to_work-9120", "INDEX=") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:4] Set("IAX2/home_to_work-9120", "MODE=DAY") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:5] GotoIf("IAX2/home_to_work-9120", "1?end1") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx_builtins.c: Goto (app-daynight-toggle,s,7)
[2019-09-30 21:14:08] WARNING[31765][C-0000018f] ast_expr2.fl: ast_yyerror(): syntax error: syntax error, unexpected '+', expecting $end; Input:
+ 1
^
[2019-09-30 21:14:08] WARNING[31765][C-0000018f] ast_expr2.fl: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:7] Set("IAX2/home_to_work-9120", "ITER=") in new stack
[2019-09-30 21:14:08] WARNING[31765][C-0000018f] ast_expr2.fl: ast_yyerror(): syntax error: syntax error, unexpected '<=', expecting $end; Input:
<=
^
[2019-09-30 21:14:08] WARNING[31765][C-0000018f] ast_expr2.fl: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:8] GotoIf("IAX2/home_to_work-9120", "?begin1") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:9] Set("IAX2/home_to_work-9120", "LOOPCNT=0") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:10] Set("IAX2/home_to_work-9120", "ITER=1") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:11] Set("IAX2/home_to_work-9120", "INDEX=") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:12] GotoIf("IAX2/home_to_work-9120", "0?day:night") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx_builtins.c: Goto (app-daynight-toggle,s,16)
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:16] Set("IAX2/home_to_work-9120", "DB(DAYNIGHT/C)=NIGHT") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:17] Set("IAX2/home_to_work-9120", "DEVICE_STATE(Custom:DAYNIGHT)=INUSE") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:18] Goto("IAX2/home_to_work-9120", "end2") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx_builtins.c: Goto (app-daynight-toggle,s,19)
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:19] Set("IAX2/home_to_work-9120", "ITER=2") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:20] GotoIf("IAX2/home_to_work-9120", "0?begin2") in new stack
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Executing [s@app-daynight-toggle:21] ExecIf("IAX2/home_to_work-9120", "0?Playback():Playback()") in new stack
[2019-09-30 21:14:08] WARNING[31765][C-0000018f] app_playback.c: Playback requires an argument (filename)
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] pbx.c: Spawn extension (app-daynight-toggle, s, 21) exited non-zero on 'IAX2/home_to_work-9120'
[2019-09-30 21:14:08] VERBOSE[31765][C-0000018f] chan_iax2.c: Hungup 'IAX2/home_to_work-9120'

so it’s a bit odd! I’ve followed Bill’s advice (I thought to the letter) but something seems to be amiss.
Thanks!

The method you linked in our former thread only works specifically for time conditions, not call flow control.

However, just to take a stab at it, you could probably point your call to Goto(app-daynight,3,1) if I am getting the right idea from the logs you posted.

Setting up a Misc. App. could be better here:

Then what you do from your partner PBX is send that code (10101, or whatever you use there) across the IAX trunk. It lands in the from-internal context and hits this Misc. App.

Thinking more on it, this would probably be a better approach for the Time Condition idea we discussed previously. Then you don’t need to land your IAX2 trunk in a custom context, just from-internal.

Keep playing with it till you get something you like…

1 Like

Thanks, Bill. Yes I forgot to mention (d’oh, always seem to forget to clarify something in my initial posts…) that I was pointing the [from-iax-partner-pbx] section of my extensions_custom.conf at

[from-iax-partner-pbx]
exten => _X.,1,Goto(app-daynight-toggle,s,3)

do you think if I amend from Goto(app-daynight-toggle,s,3) to Goto(app-daynight,3,1) that might be better?

I’ll give it a shot.

Thanks

EDIT:

[2019-10-01 09:04:35] VERBOSE[10700][C-00000196] pbx.c: Executing [4001@from-iax-partner-pbx:1] Goto("IAX2/home_to_work-12862", "app-daynight-toggle,3,1") in new stack
[2019-10-01 09:04:35] VERBOSE[10700][C-00000196] pbx_builtins.c: Goto (app-daynight-toggle,3,1)
[2019-10-01 09:04:35] WARNING[10700][C-00000196] pbx.c: Channel 'IAX2/home_to_work-12862' sent to invalid extension but no invalid handler: context,exten,priority=app-daynight-toggle,3,1
[2019-10-01 09:04:35] VERBOSE[10700][C-00000196] chan_iax2.c: Hungup 'IAX2/home_to_work-12862'

Now if I try it I get “all circuits are busy now” either immediately or after about four rings. Interesting. WIll keep playing. Thanks

Look at the /etc/asterisk/extensions_additional.conf file and find the context for [app-daynight]. You should be able to find the extension you want to point to.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.