Telephone Alerts | 2 | WebReference

Telephone Alerts | 2

123

Telephone Alerts

Dialing Out

In this article, we won't being covering vgetty's ability to answer incoming calls, only its ability to place calls. This actually makes it alot easier since we don't have to fiddle with the vgetty configuration file.

Perl cannot directly interact with the modem. It must use an application called vm which handles the communication between the modem and Perl script. For example, the following command would call a Perl script that makes a phone call to 555-1212 and play a file called message.rmd:

vm shell -l ttyS0 -S simple_alert.pl

The -l flag specifies the serial device of the modem. In my case, I'm using an external modem, thus it's ttyS0. The -S flag sets the default shell for scripts, in this case our Perl script. The Perl code used to dial out and play a file is fairly simple:

1  #!/usr/bin/perl
2  use Modem::Vgetty;
3  my $phone   = "555-1212";
4  my $message = "message.rmd";
5  my $voice   = new Modem::Vgetty;
6  $voice->device('DIALUP_LINE');
7  $voice->add_handler('BUSY_TONE', 'finish',
		sub { $v->stop; exit 0; });
8 $voice->enable_events;
9 $voice->dial($phone);
10 $voice->waitfor('READY');
11 $voice->play_and_wait($message);

Line 3 contains the phone number to call, line 4 is the audio file we will be playing, line 6 and 7 initialize the modem and set a callback routine to exit the program if it encounters a busy signal. Line 8 tells vgetty to start dispatching events, such as a person answering the phone, pressing a number on their phone, etc. Line 9 dials the phone number. Like 10 pauses until the dialing has finished, and line 11 plays the audio file and waits until it's completed.

Creating Audio Files

There are several ways to create audio files for your voice modem, but the only one I'd recommend is to use the vm command. Voice modems cannot play any audio format. All audio must be converted into a format associated with the modem type. For example, the following command creates a message using the internal microphone in the modem:

vm record -l ttyS0 -m message.rmd

To play back the audio file you just recorded, try:

vm play -l ttyS0 -s message.rmd


123

http://www.internet.com

Produced by Jonathan Eisenzopf
Created: October 12, 2000
Revised: October, 2000

URL: http://www.webreference.com/perl/tutorial/14/2.html