DTMF not recognised by Asterisk / Python


#1

Hi,
I’ve got a working Dial Plan that simply calls a python script. The python script is a State Machine and in each state requests new DTMF digits to progress.

The script is working fine except that asterisk is failing to recognise certain digits. The number 3 never gets registered. 6 is intermittent. Interestingly 9 works fine. I need all 9 digits to be functional.

How can I fix this error?

For reference I am VERY new to the world of unix/linux and don’t totally know my way around the file system or know many of the command so if any advice that’s given could contain clear instructions or a link to an explanation that would be amazing.

Thanks
Dave


#2

Are these digits being played over an analog line?


#3

Nope - Digital.

Edit: For clarity. DTMF tones are analogue signals but my mobile phone is definitely on a digital line right? Hence I’m on a digital line.


#4

And I assume that you are viewing the DTMF tones in the log?


#5

yep. I’m both viewing a log ad also getting asterisk to say the digits pressed back to me.

a standard call may look something like this

line --> "wait for 4 digits"
input -----> 1233333333345 * These are digits that I actually typed onto my phone
output —> 1245.

or for the number 6

line —> wait for 4 digits
input -> 1466666
output -> 1466 * Here it took 5 goes at a 6 before it recognised 2 of them and had the required 4 digits.

With my mobiles this will happen

line -----> wait for some digits
input —> 123456789
output -> 1222456789 * Here it’s registered the “2” DTMF more than once and not noticed the “3”


#6

Have you already tried relaxdtmf=yes and/or set toneduration to something like 80 or 160?


#7

I changed relaxdtfm = yes in sip.conf but that made no difference. However ever single line in sip.conf was edited out. Is that usual? Does that mean I should be changing relaxdtmf somewhere else.

Wouldn’t toneduration set the length of tone than asterisk would play a DTMF for?


#8

I’m no expert here, just trying to help out :smile:

Let’s step back a second; how is your Asterisk box setup? SIP trunk, PRI, etc?

If you dial from a SIP phone does it recognize the DTMF?

How is the script generating the DTMF tones (is Asterisk generating them?)?


#9

ok for clarity.

I am sending DTMF tones to asterisk which it needs to recognise. Unless I’ve wildly misunderstood the way DTMF works I shouldn’t ever be generating a DTMF from asterisk, just receiving one from the phone.

#edit:
[i] I have no idea how DTMF works so if there is some good reason why recognising a DTMF sent from a phone requires asterisk to generate them then let me know please.[i/]

As for the rest. I have no idea. Unfortunately I didn’t setup the remote server that all of this running on or install asterisk so I have no idea how asterisk is setup or what the Asterisk Box is. :frowning:

Sorry to not be of more help with the responses.


#10

Looks like I misunderstood. I thought that the script was playing these tones. I don’t really know how to help you any further since we don’t have any more information, but I don’t usually give up that easy.

Are you definitely using SIP? relaxdtmf would go under the [general] section of the sip.conf, but you say that file was completely commented out… were there any lines not commented out? Were there #include lines? “#” is not a comment in these config files.

Did you reload asterisk after making that edit?

You say you didn’t setup Asterisk or the server, but do you know if it is using anything else, like FreePBX, Trixbox, etc? This would probably be stated in the conf files.


#11

I’ don’t think I am using SIP. I’m “calling” my .agi script from my mobile phone or work-phone. Neither of which are internet based. I only looked in SIP.conf because I found a line on the internet which told me to!

Not all of the line in SIP.conf are commented out. But most are. Some settings are clearly still there, but I don’t know if my asterisk dial plan is even using SIP.conf

I currently have relaxdtmf = yes and it’s making absolutely no noticable difference to anything.


#12

Well, this is an important detail in troubleshooting. If you’re able to call your asterisk box from your mobile phone, then it is connected to the public switched telephone network (PSTN) somehow. We’d need to find out how it is interfaced with the pstn.

It could be PRI, Analog, SIP trunk, etc.

Can you maybe post your chan_dahdi.conf to see if we can figure it out?


#13

Had a chat with the guy running this thing and he said the following.

  1. It’s running of a off a digium AEX 410 with 4 FXO ports. We’re using the standard phone lines. He said “standard analogue phone lines” but that confuses me because I was fairly certain that mobiles etc… used digital lines. I suspect that I’m not really understanding what you’re referring to when you say “analogue” or “digital” line.

Sorry to keep giving such poor info. If it help my situation is that I’m an intern and I was asked to setup the Dial Plan for a Remote Server by writing a python script to passing that to asterisk.

I’ve never used linux / unix before. I’ve never written any serious python before. I’m one year into my uni course and have very little knowledge of phone systems or what’s actually going on here. So if it seems like I have no idea what I’m doing it’s because I don’t. Obviously it would be useful for me to read up on all this stuff BUT I need this problem fixed A.S.A.P and learning everything there is to know about Asterisk, VoIP and SIP etc… may well get me the answer but only in the year 2013!

I was hoping there was a simple / standard solution that wouldn’t require in-depth analysis of the system and .conf files!

Regarding chan_dahdi.conf I CAN post it but nano won’t allow me to c/p the whole file. However it is using the default demo config files. They haven’t been changed from the default.

Thanks for your help so far!
Dave


#14

Alright, well now we’re getting somewhere. If you are using putty to ssh in to the Asterisk box, you can use cat to see the whole file, then maximize putty so that you can highlight the whole thing.

cat /etc/asterisk/chan_dahdi.conf

That will print the whole file to std out.

Take a look at this link as it explains the whole chan_dahdi.conf file: voip-info.org/wiki/view/chan_dahdi.conf

The AEX 410 card with 4 FXO ports is what is interfacing the Asterisk server with the public telephone network. So that means you call from your mobile through the telephone network (probably all digital) but then at some point it is converted to analog and then terminates at your analog interface card (the AEX 410).

So, with all of that said, I’d test relaxdtmf=yes in chan_dahdi.conf where the 4 FXO channels are setup. Then you’d need to restart asterisk for the change to take effect.

If restarting asterisk is not going to cause issues to anyone else at this time, then do the following at the ssh prompt:

asterisk -R

core restart now

Then see if relaxing the dtmf improves anything.


#15

There is another complication with mobile phones, in that they use a codec that is incompatible with DTMF, so have to send the key presses in the signalling channel. The base station then regenerates the DTMF. I assume you are using the phone’s keys and not some external source of DTMF, as the latter will not work over a mobile phone.

The fact that some digits work and others don’t work, suggests a problem with the analogue line quality, although it could also happen if Asterisk weren’t getting enough CPU power, but that is unlikely, given the card requires a real machine and you have a small system.

Is there any chance that you have selected a non-standard codec for the card (should be Mu-Law for North America and A-Law for most of the rest of the world, and should definitely not be GSM).

Incidentally, Asterisk can source DTMF under some circumstances, which probably don’t apply here, even when it is originally incoming. It sometimes needs to regenerate it.

As it is as Digium card you may qualify for DIgium commercial support. I think that covers both the card itself and interfacing and configuration.