Adding Custom Headers to PJSip Endpoints

I recently got a project to set up a couple wall-mounted tablets with SIP capability to act as intercoms (Crestron TSW-xx60s, to be exact). However, I’m currently running into an issue with their intercom/auto-answer capability.

These endpoints are expecting the header Answer-Mode: auto to be sent, but this doesn’t appear to be an option anywhere in the endpoint configuration (or I’m blind, one of the two).

I’ve been able to (at minimum) hack in support by modifying extensions_additional.conf for test purposes, but this is obviously sub-optimal given that file is frequently overwritten. The changes were:

[autoanswer]
include => autoanswer-custom
exten => s,1,GosubIf($["${ARG1}" != ""]?func-set-sipheader,s,1(Alert-Info,${ARG1}))
exten => s,n,GosubIf($["${ARG2}" != ""]?func-set-sipheader,s,1(Call-Info,${ARG2}))
exten => s,n,Gosub(func-set-sipheader,s,1(Answer-Mode,Auto))  # <-- added
exten => s,n,Gosub(func-apply-sipheaders,s,1())
exten => s,n,Return()

Is there a way to properly configure PJSIP to send this header to these endpoints? Ideally, this would respect existing auto-answer flags, but I’d be okay with it being global for now if necessary.

That’s not the header normally used for go into eavesdropping mode! That is normally done with options on alert-info.

You need to use a pre-dial hook. There is an article on this, but I’m not sure if it has been updated for the move to subroutine, in FreePBX 17,

Normally, yeah! I love weird hardware, makes life interesting. And very painful.

So, I guess then I’d need to set up macro-dialout-one-predial-hook and define something that injects this header any time I dial via *80?

Or, in other words, there’s no way to just inject this directly into the auto-answer logic in one place.

EDIT: The below works when I have Internal Auto Answer set to Intercom, which is at least a step forward.

[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf)
exten => s,n,GotoIf($["${INTERCOM_CALL}"="TRUE"]?intercom_flag)
exten => s,n,Return
exten => s,n(intercom_flag),NoOp(Incoming INTERCOM CALL)
exten => s,n,Gosub(func-set-sipheader,s,1(Answer-Mode,Auto))
exten => s,n,Return

That said, it doesn’t look like this hook is fired when using *80<extension>?

Just put that text into
/etc/asterisk/extensions_override_freepbx.conf
restart Asterisk and you should be good to go.

IMO, there is not much risk; if a software update modifies the autoanswer context, it would probably be to handle new devices and if you don’t have them, nothing will break. Worst case, you’ll need to update your copy to match.

That’s because the intercom check for *80 is done before it ever reaches that point. The check is done before the call hits the [macro-dial-one] context and never makes it there if intercom is active. The macro-dialout-one-predial-hook is called from [macro-dial-one] context. So it must make it to that context in order to be used, which it isn’t.

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