nwbell

Asterisk and in-band signaling

17 posts in this topic

Does anybody here know of a way to include tone control (outside of DTMF) in the Asterisk dialplan? I am hoping to use such a thing to make a ghetto VoIP payfone.

The idea would be to do something like:

- User dials number on payfone connected to ATA
- Play back "insert-35-cents"
- Wait for 1700+2200 to be played in the proper order (for instance, a dime and a quarter - 66ms on, 66ms off, 66ms on, undetermined pause, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off)
- Money drops into the cash can by way of the stuck-open escrow relay - that's what makes it a GhettoPayfone(tm)
- Playback "thank-you"
- Dial the number

Any ideas?

Share this post


Link to post
Share on other sites
[quote name='nwbell' post='196410' date='Jul 14 2006, 06:27 PM']
Does anybody here know of a way to include tone control (outside of DTMF) in the Asterisk dialplan? I am hoping to use such a thing to make a ghetto VoIP payfone.

The idea would be to do something like:

- User dials number on payfone connected to ATA
- Play back "insert-35-cents"
- Wait for 1700+2200 to be played in the proper order (for instance, a dime and a quarter - 66ms on, 66ms off, 66ms on, undetermined pause, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off, 33ms on, 33ms off)
- Money drops into the cash can by way of the stuck-open escrow relay - that's what makes it a GhettoPayfone(tm)
- Playback "thank-you"
- Dial the number

Any ideas?
[/quote]

nwbell, that would be an awsome idea. A payphone module for asterisk! :-)

Hmmm, could a "voice recognition" software be used to detect the tones? i know there was a unix war dialer out there that used a "voice recognition" concept to detect carriers and SIT tones.

Share this post


Link to post
Share on other sites
I looked into this a while back but I came up fruitless. I even looked at writing ACTS support into Asterisk, but what I learned is Asterisk doesn't "hear" tones at all. It takes digital messages from the actual interface to the PSTN. Be it a TDM400P or PRI card. So to build support for this you will have to write it into the driver for the card you're using or design your own hardware. I'm not sure which.

Share this post


Link to post
Share on other sites
Phiber Optik will be discussing this in a week at HOPE so we'll just have to wait until then I guess.

Share this post


Link to post
Share on other sites
[quote name='natas' post='196473' date='Jul 15 2006, 03:20 AM']
Phiber Optik will be discussing this in a week at HOPE so we'll just have to wait until then I guess.
[/quote]

Yeah, I read about that - in fact, that was what gave me hope (no pun intended) for this project. I won't be able to make it out there, but maybe somebody could ask him for me ;)


This all ties together with the reason I needed the enclosures - for that county fair. They decided to up the number of fones they wanted to 4, but only 2 of my 4 units are converted (WECo single-slotter with a Protel 8000 chassis, IAXy, and Linksys WET11, all on a pedestal); the others are plain-stock. Being as it starts next week, maybe I'll just have to recruit an operator, set up a queue for them in Asterisk, and train them to listen for the proper ACTS tones before transferring the caller.

The whole goal is to provide wireless VoIP payfones during the fair. There is already DSL on site, so I will just set up a WAP and place the rigs in convenient places. Then all I have to do is leave a roll of quarters at the fair office (for refunds), and go back to my place and man the phone at extension '0'.

All the calls will be going out over VoIPjet and/or Voxee. I will be charging 35 cents flat for local and 20 cents per minute for long distance, so the project might actually make me a hundred or more bucks if I'm lucky (hence why I didn't just spring for a couple more Protel 8000 chassis - I already spent more than that on the two extra IAXy's and wireless bridges).


BTW, if any people in teh 320 read this, PM me and I'll tell you what county these are going to be in. There's tons of phreaky schtuff set up in the switch that serves these fones, and you may want to play with them if you get a chance. There are lots of cool test numbers, an extender, and other goodies to be found. (HINT: try 1-800-666-6666, and scan at least the 99xx block)

Share this post


Link to post
Share on other sites
here's what you could do...

1. have asterisk record the tones (to a wav file for example)
2. have asterisk call an agi app that analizes the tones
3. have the app return wether or not they are correct

there may also be a way to stream the call sound to an app, but I'm not sure.

but inorder for this to work you would have to have a constant open connection with asterisk, not sure how you could do this though. Edited by mystic

Share this post


Link to post
Share on other sites
[quote name='mystic' post='196893' date='Jul 17 2006, 08:45 PM']
here's what you could do...

1. have asterisk record the tones (to a wav file for example)
2. have asterisk call an agi app that analizes the tones
3. have the app return wether or not they are correct

there may also be a way to stream the call sound to an app, but I'm not sure.

but inorder for this to work you would have to have a constant open connection with asterisk, not sure how you could do this though.
[/quote]

Yeah, I was thinking about this yesterday. You can use Monitor() to possibly do this.

Share this post


Link to post
Share on other sites
[quote name='mystic' post='196893' date='Jul 17 2006, 05:45 PM']
here's what you could do...

1. have asterisk record the tones (to a wav file for example)
2. have asterisk call an agi app that analizes the tones
3. have the app return wether or not they are correct

there may also be a way to stream the call sound to an app, but I'm not sure.

but inorder for this to work you would have to have a constant open connection with asterisk, not sure how you could do this though.
[/quote]

Ugh, what a hack. Write tone recognition into Zaptel or chan_iax :)

Share this post


Link to post
Share on other sites
[quote name='Strom Carlson' post='197031' date='Jul 18 2006, 05:06 PM']
Ugh, what a hack. Write tone recognition into Zaptel or chan_iax :)
[/quote]

For the record, I'm dealing with an IAX device (not sure if I said that or not).

Share this post


Link to post
Share on other sites
[quote name='nwbell' post='197034' date='Jul 18 2006, 03:21 PM']
[quote name='Strom Carlson' post='197031' date='Jul 18 2006, 05:06 PM']
Ugh, what a hack. Write tone recognition into Zaptel or chan_iax :)
[/quote]

For the record, I'm dealing with an IAX device (not sure if I said that or not).
[/quote]

Ah...an IAXy? :)

What I think would actually be the most elegant way to handle it would be to build full coin control support into zaptel. Theoretically, the S110m FXS modules can generate just enough juice to operate the solenoid and do coin collect / return.

Unfortunately, my C skills blow, and my hardware driver skills blow even more :)

Share this post


Link to post
Share on other sites
[quote name='Strom Carlson' post='197035' date='Jul 18 2006, 05:28 PM']
Ah...an IAXy? :)
[/quote]

Indeed. They're not cheap, but they work amazingly well - my switch lives behind a NAT, and all I have to do is open one port and reprovision the IAXy, and it's soup.

[quote name='Strom Carlson' post='197035' date='Jul 18 2006, 05:28 PM']
What I think would actually be the most elegant way to handle it would be to build full coin control support into zaptel. Theoretically, the S110m FXS modules can generate just enough juice to operate the solenoid and do coin collect / return.

Unfortunately, my C skills blow, and my hardware driver skills blow even more :)
[/quote]

Same here. I wouldn't begin to be able to write something like that, but I would sure as hell put it to good use if somebody else did :)

By the way, what is the correct way to write the plural of IAXy?

Share this post


Link to post
Share on other sites
[quote name='nwbell' post='197193' date='Jul 19 2006, 05:31 PM']
By the way, what is the correct way to write the plural of IAXy?
[/quote]

I asked some guys at Digium, and they seem to think it's probably "IAXies" :)

Share this post


Link to post
Share on other sites
[quote name='Strom Carlson' post='197035' date='Jul 18 2006, 03:28 PM']
[quote name='nwbell' post='197034' date='Jul 18 2006, 03:21 PM']
[quote name='Strom Carlson' post='197031' date='Jul 18 2006, 05:06 PM']
Ugh, what a hack. Write tone recognition into Zaptel or chan_iax :)
[/quote]

For the record, I'm dealing with an IAX device (not sure if I said that or not).
[/quote]

Ah...an IAXy? :)

What I think would actually be the most elegant way to handle it would be to build full coin control support into zaptel. Theoretically, the S110m FXS modules can generate just enough juice to operate the solenoid and do coin collect / return.

Unfortunately, my C skills blow, and my hardware driver skills blow even more :)
[/quote]

I'm interested in doing the same thing. The WECO 2C2 in my house is connected to a coin service line from SBC at the moment, which is nice since the phone works as it should. But coin service is an expensive novelty (over 60$/month after taxes). I'm seriously contemplating writing coin detect into zaptel. I'd just like to make sure nobody else has already done it (not into re-inventing the wheel).

As far as coin relay control goes, you need +/-130VDC between ground and tip. In my case, "ground" can just be a third conductor between Asterisk and the payphone. This would require hardware, since the TDM400 isn't capable of producing electrical potentials with respect to ground (or in my case, that third conductor instead of real ground). But this would be relatively simple to do with a script and AGI. Just set some of the lines on your parallel port to control a relay that sends the DC signal voltage to the coin relay. In fact, with EAGI, you have access to the audio stream in one of the file descriptors, so it would be possible to do the tone detection there rather than in the driver. But it seems likely that doing it in the driver may be easier and more reliable (since it's set up for dual-tone detection already).

Share this post


Link to post
Share on other sites
[url="http://www.projectmf.com/"]http://www.projectmf.com/[/url]

This would likely be the place to start, but I haven't done much with it yet - been too busy.

Share this post


Link to post
Share on other sites
Hi guys,

I know this thread's been dormant for a while but I've been interested in getting something like this up and running with Asterisk as well....

Given that Asterisk has the "busydetect" - can't we just modify that to detect the coin deposited tones?

I finally got around to requesting the polarity-reversal feature on the Digium bugs site and was successful in getting someone to code it in for me.. so that's already taken care of (as at May 2010)... so really it comes down to coin detection and voltage control which I'm sure can be coded in to the Dahdi drivers someplace??

Cheers

Share this post


Link to post
Share on other sites
[quote name='armeniki' timestamp='1291703206' post='356154']
Hi guys,

I know this thread's been dormant for a while but I've been interested in getting something like this up and running with Asterisk as well....

Given that Asterisk has the "busydetect" - can't we just modify that to detect the coin deposited tones?

I finally got around to requesting the polarity-reversal feature on the Digium bugs site and was successful in getting someone to code it in for me.. so that's already taken care of (as at May 2010)... so really it comes down to coin detection and voltage control which I'm sure can be coded in to the Dahdi drivers someplace??
[/quote]
I've actually put some effort into this recently. At a local hackerspace, a friend and I are putting in a nickel payphone. It charges a nickel for any call in the world, except maybe Cuba and satphones because they're so expensive. I'm approximately the world's least enthusiastic Asterisk fan, so I used this as a project to learn how to use FreeSWITCH. (More about why I hate Hurrsterisk later, if you care. FreeSWITCH is configured in XML, for better or for worse, is written by competent programmers, and has a bit steeper learning curve than Asterisk.)

Among other things, the payphone has a Linksys PAP2 in it, set up to operate as a hotline to <sip:dialtone@switch.host-name>. Here's what I have so far on the FreeSWITCH side of things, stripped of identifying words and irrelevant bits.

[code]
<context name="payphone" description="Dialplan for payphone">
<extension name="dialtone">
<condition field="destination_number" expression="^dialtone$">
<variable name="nibble_account" value="1" />
<action application="set" data="nibble_rate=0.05" />
<!-- give the man a nickel -->
<action application="tone_detect" data="nickel 2200,1700 r 0 nibblebill 'adjust 0.05' 1" />
<action application="read" data="1 18 'tone_stream://%(20000,0,350,440)' dialled 20000 '#'" />
<action application="transfer" data="${dialled}"/>
<!-- <action application="info"/> -->
</condition>
</extension>

<extension name="outbound_free" -- usa toll-free -->
<condition field="destination_number" expression="^\+(18(00|88|77|66|55)\d{7})$">
<!-- <action application="set" data="nibble_rate=0.00"/> -->
<action application="bridge" data="sofia/gateway/outbound/$1"/>
</condition>
</extension>

<extension name="outbound_paid" -- all paid calls -->
<condition field="destination_number" expression="^\+(\d+)$">
<!-- <action application="set" data="$${nibble_account}"/> -->
<action application="bridge" data="sofia/gateway/outbound/$1"/>
</condition>
</extension>

</context>
[/code]
It's not perfect, and in fact not really tested at all. For charging to work correctly, the ATA you use has to support early forward audio, which most [i]seem[/i] to do.

There are a lot of extension patterns in there that translate dialstrings into phone numbers (1-NXX-NXX-XXXX => +1NXXNXXXXXX, 011-X* -> +X*, etc.); these mostly end up in the outbound_paid or outbound_free extensions eventually.

The dialtone extension collects digits and nickel tones. Every time it detects a nickel it increments the mod_nibblebill module's internal money counter by five cents, and every time it detects a DTMF digit it adds that to the current dialstring. I'm not sure how well that will work with quarters, but it should work okay with nickels and maybe dimes too. We're charging a nickel, so why would anyone put in a quarter? :)

Share this post


Link to post
Share on other sites
My two cents...

[url="http://www.voip-info.org/wiki/view/Asterisk+EAGI"]EAGI() dialplan application[/url] allows call audio signal to be passed into AGI script. My idea is to do the following:

* Configure the payphone extension in batphone mode - that is, as soon as someone picks it up, the Asterisk calls, say extension 1337.
* When extension 1337 receives a call, is runs callbouncer.pl or something via EAGI() application. Call audio, as well as AGI signalling inpho is available to this script.
* callbouncer.pl contains [url="http://www.dspguide.com/"]digital signal processing[/url] code to detect ACTS/redbox tones. If these tones are detected, it allows one to dial out and talk for pre-configured amount of time. Edited by Mr. X

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now