Custom apps to make calls

Hello everyone.

I’m starting to learn Asterisk code to start to develop an app to asterisk, or improve exists.

My first app is to a simples DIAL context.

I’m trying to make this

exten _X.,1,Dial(SIP/number@trunk)

but using a custom APP

exten => _X.,Dial(Magnus(${EXTEN}))

I create the app_magnus.c

struct ast_dial *dial;
char *info;
info = ast_strdupa(data);

AST_DECLARE_APP_ARGS(args,
	AST_APP_ARG(exten);
);

AST_STANDARD_APP_ARGS(args, info);


if (ast_strlen_zero(args. exten)) {
	ast_log(LOG_WARNING, “%s requires an argument (exten)\n", app);
	return -1;
}


if (!(dial = ast_dial_create())) {
	ast_log(LOG_WARNING, "Failed to create dialing structure.\n");
	return 0;
}

if (ast_dial_append(dial, "SIP", number, NULL) == -1) {
	ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", "SIP");
	ast_dial_destroy(dial);
	return 0;
}	

res =  ast_dial_run(dial, args.exten@MYTRUNK, 0);

ast_bridge_basic_new();
ast_dial_hangup(dial);
ast_dial_destroy(dial);

the problem is:
When I answer the call in LEG b the LEG a hangup.

thanks for your help

Firstly, this is not a developer forum.

Secondly, there are multiple errors in the following line.

Do you know the link to DEV forum?

exten => _X.,Dial(Magnus(${EXTEN}))

Magnus is the name of my APP that I’m developing.

Thanks

There isn’t a forum. There are mailing lists and IRC channels.

https://wiki.asterisk.org/wiki/display/AST/Mailing+Lists

https://wiki.asterisk.org/wiki/display/AST/IRC

Where is the priority or label ?

And only Exec, ExecIf and ExecIfTime allow an application as a parameter of the primary application, to the best of my knowledge.

1 Like