More clarification: this code would be channel-agnostic and not related to the actual device technology. I would need to trigger this manually in the dialplan when this behavior is desirable. In reality, this is for FXS ports so would only ever likely be used with DAHDI or SIP endpoints.
Here’s a simple example: say you have a POTS phone hooked up to an ATA or channel bank set to hotline into Asterisk so you get dial tone from the switch instead of fake dial tone from the ATA, and if you hook flash, it places another call to the hotline code as well (as Cisco/Linksys ATAs do). All is good. With the goal of making it work like an actual POTS switch, you should NOT be able to hook flash if there is not currently 1 answered call (any incoming call, or an outgoing call that has been answered). Currently, I have Asterisk just hang up if a second call comes in without 1 answered call. The caller hears reorder locally from the ATA, flashes once, and connects back to the first call - which could be dial tone, ringing, or whatever. This is better than the scenario where you have to flash twice to get rid of the second call. For obvious reasons, the second call can’t simply be silence - it needs to be disconnected sot that he could hook flash later when it is allowed.
People have complained about this and want it to work exactly like a POTS switch such as a 5ESS. The goal here is maximal realism, since my Asterisk is not really a PBX but more a Class 5 end office. So, rather than the caller being jarred by hearing local reorder, I would like an invalid hook flash to simply appear as if it had no effect. One cannot prevent the ATA from placing a second call, so this must be done Asterisk side. The idea somebody suggested to me was essentially hanging up the first call the ATA originated and “resuming” it on the second call. Rejecting the incoming call with any kind of SIP cause code won’t work, since that will trigger the ATA to provide local reorder. Instead, it should seem as if nothing has happened - the first call will drop, which means that if the caller hook flashes again, it will try yet another time to make a second call, rather than bridging the two channels together.
That’s the backstory in a nutshell. Calls are already confbridge and Local dial hell enough to this end, and I would like to avoid using yet more confbridges or local dials in order to achieve this.
Implementation wise, I don’t care if the old or the new channel ID number becomes the new one. The only requirements are that the literal channel state is inherited in the same way - so any channel variables set are now accessible on the new call, and the caller ends up thinking that the hook flash had no effect, even though it did.
I’m choosing to tackle this problem first, as I think about how I want to implement Call Hold and other features that will involve doing similar things. Call Hold involves hook flashing and dialing the call hold code, which can be done over and over again, and since one would need to prevent a 3-way call from happening, I’d need to drop the call appearance to the device and only bridge him again once the call hold code is dialed again.
By the way, one natural question is why not send hook flash events to Asterisk instead of relying on an ATA’s dumb capability of trying to make a 3-way call? Apparently, Asterisk has no way of handling these or exposing these, even though they make it into Asterisk (and I can see them do so). Additionally, I don’t know if channel banks or non-Grandstream ATAs have this capability, and I need a unified way of handling all technologies.