Busy from local hardware and busy from a remote number

Colleagues, please tell me the answer to the my question!

How to reliably distinguish answer “busy” from my local hardware and answer “busy” from remote number I’m making a call to.

Undoubtedly, the case when the hardware is busy or not in working condition and the case of the busy number is fundamentally different and they must be distinguished.
If the equipment is occupied, I must continue to move along the dialplan for outgoing connections, and make a call through the next communication channel according to priority.
If the number to which the call is being taken is busy, then I must stop calling and send a busy signal to my subscriber.

Is there any way to reliably distinguish between these two states?

Thank you in advance for your reply,
Ogogon.

Which channel technology are you using? For VoIP this may depend on your service provider.

In general you do it by looking at HANGUPCAUSE, with some possible experimentation.

What do you mean by this? Because there are two different channels/connections involved here.

  1. The user (phone) is going to make the call to the PBX, that’s channel A.
  2. PBX is going to process that call and send it to the PSTN. That’s channel B.
  3. Channel B returns a busy, because the destination is busy. So now you need to take that response from Channel B and send it out another provider. Why? I’m not sure. It’s a Busy.
  4. Once Channel B is done it will send the result back to Channel A which sends the final reply to the endpoint (phone).

So you need to clarify what you are asking about.

He wants to distinguish between subscriber engaged and equipment engaged conditions. In the UK, for analogue callers, there used to be different, but similar busy tones, but most people got voice announcements like “All lines to Hogwarts are engaged”.

The problems of foggy Albion are a little far away for us, something else excites me.
Most cheap SIP-FXS/FXO/GSM gateways, made in Asia, return the same code if the equipment is busy or if the numbers are busy. 486 Busy Here.
And, unfortunately, they do not have the settings to change this. What plunges into gloom.
Adequate gateways made in the USA/Europe/Israel cost as a ballistic missile, or at least as a wing from a Boeing. And it also plunges into gloom.

So I decided to take an interest in overcoming this difficulty.