Hello, who is calling or calling in Asterisk
Given the specifics of telephone networks in Russia, problems with determining the number when setting up analogue GTS lines on Asterisk arise quite often. The variety of GATS and the quality of telephone lines installed back in Soviet times always pose problems for IP PBX integrators.

Asterisk IP PBX was installed, and was successfully used. After some time, it became possible to connect the caller ID, tk. the city lines were transferred to a digital GATS with CallerID support, before that the lines were connected to an analog GATS (yes, analog exchanges are still alive), but the number identification did not work.
To begin, consider a little theoretical information about what standards for determining a phone number are.
Number Theory
Caller ID (also called Russian Caller ID) - the work of Soviet analog GATS, was common in the early 90's, but is still found. Information about the number of the calling subscriber is transmitted in the form of a code called the “Interval Package”. It is not a service as such, because it was not intended for subscribers. The telephone number is transmitted in the form of 7 digits. A telephone set that supports caller ID during an incoming call “picks up the phone” and reads the telephone station service signals, while the calling signal is simulated for the caller. On Asterisk, this type of caller ID cannot be made to earn.
CallerID (aka Euro Caller ID) is a service provided on digital GATS. A method for sending a request and receiving Caller ID information in the interval between calls. That is, unlike Caller ID, there is no “pick-up” here. Several standards are common in CallerID: the
Bellcore standard is used in the USA, Canada, Australia, China, Hong Kong, Singapore, Italy and some UK telephone companies.
DTMF standard: digits are transmitted in the same way as tone dialing using short dual-frequency messages.
FSK standard: The data stream is transmitted by frequency modulation before the first or second call on the line. As experience has shown, most digital GATS of Rostelecom operate according to this standard.
Practice, or why nothing works
To determine the number in DAHDI channels in most cases, adding the following lines to chan_dahdi.conf is enough:
chan_dahdi.conf
If the definition of the number does not work, I recommend first connecting a regular CallerID-enabled telephone and see if the definition works on it. In our case, the number on the TA was determined without problems, but on Asterisk did not want to. Moreover, when the TA was connected in parallel to the asterisk, the detection stopped working on the phone.
We proceed to further analysis. We record the audio channel of the line and analyze the recording in the audio editor. In it we will try to find the CallerID data.
Recording of the first dahdi channel is carried out by the following command:
We start the recording team and call our line. After that we stop the execution of dahdi_monitor, as a result, we will have the file streamrx.wav. We copy it to ourselves and open it in an audio editor (for example Audacity).

As you can see, no callerid data comes to us. Since an ordinary telephone determines the number, it can be assumed that there are problems with the equipment (board or FXO module).
We put the obviously working FXO module into the board and check again.

Now the number determination works without problems, on the record we see the CallerID data in the FSK standard. As you can see, in this case there was a problem with the module.
Repair of the FXO module
FXO modules from different manufacturers for analog cards are built practically according to the same scheme based on two microcircuits: SI3019 and SI3050.
Example of a circuit from a datasheet on Si3050 Si3018 / 19: In this diagram, the line is connected to the RING and TIP pins. What elements should I look for in case of problems with the module? - Diode bridge D1 (can also be made in the form of two assemblies of 2 diodes). Sometimes it is out of order on the lines of analog automatic telephone exchanges and when the permissible voltage is exceeded. At the same time, the module itself can remain operational, but some of the diodes do not work. Checked after desoldering from the circuit. - Dinistor RV1 (275 V, 100 A). In our case, it turned out to be workable. - Resistors R30, R32 (15 M ?, 1/8 W, 5%), R31, R33 (5.1 M ?, 1/8 W, 5%), R8, R7 (20 M ?, 1/8 W). With them, too, everything was in order.

The problem was in the Si3019 chip. The resistance at the point of connection of the Ring1 pin was two times less than on the working module. After replacing the Si3019 chip, everything worked without problems.
Also in the thunderstorm period, in the absence of external protection, the Z1 zener diode (43 V, 1/2 W) often fails. The symptoms are the following: the module does not see the incoming call; when you try to make a call through this channel, there is no action other than silence. It is solved by replacing the zener diode.

Asterisk IP PBX was installed, and was successfully used. After some time, it became possible to connect the caller ID, tk. the city lines were transferred to a digital GATS with CallerID support, before that the lines were connected to an analog GATS (yes, analog exchanges are still alive), but the number identification did not work.
To begin, consider a little theoretical information about what standards for determining a phone number are.
Number Theory
Caller ID (also called Russian Caller ID) - the work of Soviet analog GATS, was common in the early 90's, but is still found. Information about the number of the calling subscriber is transmitted in the form of a code called the “Interval Package”. It is not a service as such, because it was not intended for subscribers. The telephone number is transmitted in the form of 7 digits. A telephone set that supports caller ID during an incoming call “picks up the phone” and reads the telephone station service signals, while the calling signal is simulated for the caller. On Asterisk, this type of caller ID cannot be made to earn.
CallerID (aka Euro Caller ID) is a service provided on digital GATS. A method for sending a request and receiving Caller ID information in the interval between calls. That is, unlike Caller ID, there is no “pick-up” here. Several standards are common in CallerID: the
Bellcore standard is used in the USA, Canada, Australia, China, Hong Kong, Singapore, Italy and some UK telephone companies.
DTMF standard: digits are transmitted in the same way as tone dialing using short dual-frequency messages.
FSK standard: The data stream is transmitted by frequency modulation before the first or second call on the line. As experience has shown, most digital GATS of Rostelecom operate according to this standard.
Practice, or why nothing works
To determine the number in DAHDI channels in most cases, adding the following lines to chan_dahdi.conf is enough:
chan_dahdi.conf
usecallerid=yes ; включаем CallerID
callerid=asreceived ; передаем callerid в неизменном виде
If the definition of the number does not work, I recommend first connecting a regular CallerID-enabled telephone and see if the definition works on it. In our case, the number on the TA was determined without problems, but on Asterisk did not want to. Moreover, when the TA was connected in parallel to the asterisk, the detection stopped working on the phone.
We proceed to further analysis. We record the audio channel of the line and analyze the recording in the audio editor. In it we will try to find the CallerID data.
Recording of the first dahdi channel is carried out by the following command:
dahdi_monitor 1 -v -r streamrx.wav
We start the recording team and call our line. After that we stop the execution of dahdi_monitor, as a result, we will have the file streamrx.wav. We copy it to ourselves and open it in an audio editor (for example Audacity).

As you can see, no callerid data comes to us. Since an ordinary telephone determines the number, it can be assumed that there are problems with the equipment (board or FXO module).
We put the obviously working FXO module into the board and check again.

Now the number determination works without problems, on the record we see the CallerID data in the FSK standard. As you can see, in this case there was a problem with the module.
Repair of the FXO module
FXO modules from different manufacturers for analog cards are built practically according to the same scheme based on two microcircuits: SI3019 and SI3050.
Example of a circuit from a datasheet on Si3050 Si3018 / 19: In this diagram, the line is connected to the RING and TIP pins. What elements should I look for in case of problems with the module? - Diode bridge D1 (can also be made in the form of two assemblies of 2 diodes). Sometimes it is out of order on the lines of analog automatic telephone exchanges and when the permissible voltage is exceeded. At the same time, the module itself can remain operational, but some of the diodes do not work. Checked after desoldering from the circuit. - Dinistor RV1 (275 V, 100 A). In our case, it turned out to be workable. - Resistors R30, R32 (15 M ?, 1/8 W, 5%), R31, R33 (5.1 M ?, 1/8 W, 5%), R8, R7 (20 M ?, 1/8 W). With them, too, everything was in order.

The problem was in the Si3019 chip. The resistance at the point of connection of the Ring1 pin was two times less than on the working module. After replacing the Si3019 chip, everything worked without problems.
Also in the thunderstorm period, in the absence of external protection, the Z1 zener diode (43 V, 1/2 W) often fails. The symptoms are the following: the module does not see the incoming call; when you try to make a call through this channel, there is no action other than silence. It is solved by replacing the zener diode.