BePhoney v0.8.0
by Jeremy Rand
July 7, 1997

This is the first public release of this program.  It is able to log information about incoming calls to disk.  This includes CallerID information if the service is available on the line.  Plus, it can be configured to answer the phone after a certain number of rings, play a greeting  and record a voice message.

There are two executables which perform this task.  A daemon (called BePhoneyd) watches configured modems, answers incoming calls and creates files with information about those calls.  The GUI application (called BePhoney) allows you to create greetings, configure modems on ports, control the daemon and listen to recorded messages.


Requirements:
	- AAPR of BeOS
	- a ZyXEL modem (see planned features for more information)
	- a serial cable which support hardware handshaking
	- a telephone or microphone for recording your greeting
	- CallerID enabled on the phone line (optional)


This Program is Shareware:

After BeDC in Boston, I will probably be investigating one of the registration sites on the Internet.  If you can't wait to pay, send $25 (US is great, Canadian is fine) to:

	Jeremy Rand
	30 McEwen Ave Apt 810
	Ottawa, Ont
	Canada
	K2B 5K8

This will get you full support from yours truly and free upgrades well into v2.0 (see the futures section at the end of this document for details).

To contact me on the net, send mail to jrand@newbridge.com


Installation:

This program requires the libprefs.so library by Jon Watte (version 1.1).  I have included a copy of the library with the package.  Copy "libprefs.so" to /boot/system/lib, if you already haven't installed the library.

If you want the daemon started automatically once you are finished with the configuration below, add BePhoneyd to the /boot/system/UserBootscript file.


Configuration:

There are two executables in the BePhoney package:
	- BePhoney is the GUI program for displaying info about past calls and configuring 
	the modem
	- BePhoneyd is the daemon which handles calls and does the dirty work of dealing
	with a voice modem

To start the program for the first time, double-click the "BePhoney" application.  You will be presented with a Control window for stopping and restarting the daemon.  Under the "Preferences -> Configure Port " submenu are a list of the serial ports on your machine.  Select the serial port which has the mode attached.  You will get a large window for configuring this port.

Currently, the modem type will be set to "None".  Select your modem type from those listed.  A number of options are available to you at this point.  These options will be explained on the section specifc to this configuration window.

For the time being, make sure the "Modem will monitor the line" checkbox is off and select "File -> Save" from the menu.  Close the window and it will ask you if you want to restart the daemon because the settings have changed.  Click on the "Restart" button.

At this point, the daemon is running and it knows you have a modem on that serial port.  Select "File -> New Greeting" from the menu bar.  This will give you a window for recording your greeting message.  It is currently "Untitled" but it will be named later in the procedure.

At this point, you need to hook up your input device to the modem.  This can either be a telephone attached to the phone jack on the modem or a microphone attached to the quarter inch plug (also on the modem).  This version of BePhoney does not let you record your greeting from devices attached to your computer, just devices directly attached to your modem.

Select the input device from the "Preferences -> Input Device" menu and make sure the serial port you configured is selected in the "Preferences -> Input Port" menu.  There is also the "Preferences -> Input Encoding" menu which you can set.  The default option is four bit ADPCM which is the highest quality but uses the most disk space.  For the greeting, you will only need one copy, so I would go with this highest quality encoding.

At this point, pick up the handset of the phone if you are using one and click on "Record Greeting", you will hear a beep and then speak clearly to record you message.  When you have finished, click "Stop" or hangup the handset.  You can play back your greeting by clicking on the "Play Greeting" button.  By default, it will play on the modem's speaker, but you can send it to the local phone jack instead using the "Preferences -> Output Device" menu.

Once you are happy with the greeting, save it by selecting "File -> Save As".  Remember where you put the file because you will need it later on.  Close the greeting window.

Select the serial port that your modem is connected to in "Preferences->Configure Port".  Now, make sure there is an x in the "Modem will monitor the line" box.  Drag and drop the greeting you just recorded onto the serial port configuration window, or type in the path to that file beside the "Greeting File" prompt.  Drag and drop a directory to store a record of the i ncoming calls onto the configuration window, or enter the path beside the "Spool Directory" prompt.

This is the minimum configuration necessary to turn your voice modem into a basic answering machine.  You can read the following sections for more info on available options, or just save these settings now from the "File -> Save" menu.  When you close the window, select "Restart" to restart the daemon, and your modem is now an answering machine.


Menu Bar Options:

This section will only talk about options in the menu bar which are available in all windows:

"File -> New Greeting" - this option creates an untitled window in which you can record and save your greetings.  See the section on greeting windows.

"File -> Open Message..." - this option gives you a standard open panel to select a message to open.  It will produce a message window when successful.

"File -> Close" - this option closes the current window.  If this is the last window in BePhoney, the application quits.  Note that this will not stop the daemon if it is running.

"File -> About" - this brings up a simple about window that tells you something about me and the program.

"File -> Quit" - this will attempt to quit BePhoney.  If there are any unsaved greetings or configuration windows, you will be prompted if you really want to close those windows without saving.  This will not quit the daemon process.

"Preferences -> BePhoneyd Control" - this brings up a control window.  See the section on the control window for more information.

"Preferences -> Configure Port" - this submenu contains a list of the possible serial ports where you can configure a modem.  By selecting one of these, a configuration window will be opened.  See the section on configuration windows.

Other menu items are only enabled in certain windows.  These items will be discussed with each individual window.


Configuration Windows:

This window allows you to configure all the options for a specific serial port:

1. The "Select a modem type" popup allows you to configure the type of modem on the port.

2. "Modem will monitor the line" checkbox is used to tell the daemon to watch for incoming calls on this modem.  If this is unchecked, you can use the port for recording greetings or listening to recorded messages, but the modem will not watch for incoming calls.

3. "Automatically launch on incoming call" checkbox is used to tell the daemon to "double click" on the newly created file when a call comes in.  This will start the BePhoney application if it isn't already running and display a message window with the information about the call.

4. The "Answer phone on how many rings" text box allows you to select when the modem will play the greeting.  To make it never answer the phone, set it to something like "99" (a future enhancement will have a real "never answer phone" option).

5. The "Maximum time between rings" is a measure of the largest time in seconds between two incoming rings for the daemon to consider it another ring against the same call.  In North America, it seems you can set this as low as about 6 to 7 seconds with the daemon thinking every ring is a new call.  Setting it too large might make the daemon think the first ring of a new call is actually another ring of the last call.  This can lead to the daemon answering too soon.  I have found 10 to be a good compromise.

6. The "Spool Directory" is a text field where you enter the path of the directory where the call files should be stored.  You can drop a directory on the configuration window if you would rather not type the path.

7. The "Greeting File" is a text field where you enter the path to the file which you recorded as your greeting.  You can drop the greeting file on the configuration window if you would rather not type the path.

8. "Select a default message encoding" is a popup for picking the encoding of messages stored when the daemon has answered the phone, played its greeting and is now recording the caller's message.  The higher the number of bits the better the sound quality, but you trade a larger use of disk space.  I have found the average message to be on the order of 100K at 4 bit ADPCM (the highest quality) which I consider very reasonable for the sound quality.  Feel free to experiment with this to find a setting which you find works well.

9. The "Automatically adjust the receive gain" means that the mode will adjust the volume of a received message automatically at record time.  I would recommend leaving this option on.

10. The "Receive Gain" and "Transmit Gain" text field allow you to change the gain used in recording and playing messages.  The receive gain is only available if the automatic adjusting option is off (see number 9).  I would recommend against changing these too much.

11. The "Silence Sensitivity" allows you to change how silent the line has to be for the modem to actually detect that silence.  A setting of 1 means the line has to be very silent, while 31 means that the line can have a bit of noise and the modem will still consider that silence.  Adjust this number higher if you find the modem is not detecting silence and hanging up properly at the end of calls.  Also, a setting of 0 will turn off silence detection.  You do not want this because the modem will not know when someone has finished their message otherwise.

12. The "Silence Interval" allows you to select how long the modem has to hear silence before it will report this silence to the daemon.  If people often leave you messages where they sit silently thinking of the next thing to say, you might want to increase this number.  Do not set this number to 0 since it turns off silence detection (see number 11).

13. The "DTMF Sensitiivity" tells the modem how accurately it has to detect a DTMF for it to be reported as one.  The higher the number, the more chance a non-DTMF will be reported as one, but the less chance the mode has to missing a real DTMF because of noise.  Setting this number to 0 turns off DTMF detection.

14. The "DTMF Interval" selects how long the mode must detect a DTMF to report that DTMF to the daemon.  Setting this number to 0 turns off DTMF detection.

"File -> Save" saves the settings as shown in the window.


Control Window:

This window has two buttons:

"Start Daemon" or "Restart Daemon" if the daemon is already running.
"Stop Daemon" is enabled if the daemon is running.

There are no special menu items.  If you drop files on this window, it will attempt to open them as messages.


Call Windows:

This window has two content sections.  One section displays the name of the file (the default names were too long for the window title bar to be readable).  The other section holds the CallerID information if there is any recorded with the call.  There is a "Play Message" box which is enabled if the file contains a message.  Click on it to hear the message recorded.  This will enable the "Stop" button, until the message is done playing.  If you click "Stop" while the message is playing, the playback should stop and the "Play Message" button should be re-enabled.

The related menu items are:

"File -> Delete Message" - this item will prompt you to check that you are sure and then remove the message from the disk.  The window will be closed.

"Preferences -> Output Port" - this submenu allows you to select among the configured port which modem will play the message when you click "Play message".  This is always set to the first port found configured by default.  This option is only useful to people who have more than one voice modem configured on their system (hello, anyone out there with anything like this, didn't think so)

"Preferences -> Output Device" - this submenu allows you to choose if the message is played on the modem's speaker or on the modem's local phone jack.  The speaker is always the default.

You can drop files on this window and BePhoney will attempt to open them as messages.  Note that greeting files are no different really from message files.  So, to hear a greeting you have already recorded, open it as a message and click "Play Message".

Also, this window is live.  This means that I am using a node monitor to check to see if the related file has changed in any way.  This means that if the daemon finishes writing the message to disk after the window has been created, the "Play Message" button will enable automagically.  I love the BeOS.


Greeting Windows:

These windows allow you to record new greetings.  There is a "Record Greeting" button which allows you to do just that.  It will warn you if you are recording over an unsaved greeting.  The "Play Greeting" button is enabled when a greeting has been successfully recorded.  The "Stop" button is enabled when a greeting is being recorded or played back and allows you to terminate the current action (I told you adding a stop to the message window would be easy).

The following menu items are used in the greeting windows:

"File -> Save" - this will open a save panel the first time you try to save your greeting.  Once it is saved, the title of the window will change to match the file name.  Further saves will overwrite the file.

"File -> Save As" - this will always give you a save panel where you can choose where to save the greeting.  It will change the title of the window when the file is saved.

"Preferences -> Input Port" - this submenu gives you the ability to select the modem which you will use to record the greeting assuming you have more than one modem configured.  If you don't, you can ignore this submenu.

"Preferences -> Input Device" - this submenu allows you to select whether you want to record from the local phone jack on the modem or the microphone jack on the modem.  By default, the local phone jack is selected.

"Preferences -> Input Encoding" - this submenu allows you to choose the voice encoding to use when you record your greeting.  The more bits in the encoding the higher the sound quality but the more disk space the greeting will use.

"Preferences -> Output Port" - with this submenu, you can select which modem to play the message on, if you have more than one voice modem configured.

"Preferences -> Output Device" - this submenu allows you to select between the modem's speaker or the modem's local phone jack when you playback your recorded greeting.  By default, the speaker is selected.

You can drop files on this window and BePhoney will attempt to open them as message files.


Tech Details:

These are just some interesting technical details of the current incarnation of BePhoney.

1. The daemon creates a file for each call that comes in within the spool directory.  These files have a mime type of "application/x-jsr-CallType".

2. The daemon store the message encoding and any CallerID information in attributes.  If you don't have CallerID, but want to see what the info would look like in the window, you can add these attributes to a call file:

$ addattr "CID Time" "the time of the call" filename
$ addattr "CID Number" "the number which called you" filename
$ addattr "CID Name" "the name of the person who called you" filename

3. Try the above with the message window open for the file you are changing to see the node monitors in action.  They are cool!

4. The voice data is stored in the data portion of the call file.


Known Bugs and Limitations:

The following are things for me to work on and you to watch out for:

1. The lack of limits on the size of an individual message, the length in time of a message or the total disk used by all messages, it is possible for that same Aunt Ruby to fill up your hard drive.  In practice, these messages are rather small by today's HD sizes, but this will be resolved in a future release.

2. The icons are strange and the mini icon for the call files doesn't seem to be showing up.  The BePhoney icon is supposed to be a phone handset with an audio tape inserted into it.  The BePhoneyd icons is a phone handset with an audio tape nearby and the call files are just audio tapes.  Any suggestions would be appreciated.

3. If you want to dial out (say using PPP) on a your configured voice modem, the port has to be configured for no monitoring, or you have to quit the daemon.  There is no way for a program to monitor a serial port in the BeOS and give it up to someone who wants exclusive access (like PPP) yet.  If you want to dial out, use BePhoney to quit the daemon, or configure the port for no monitoring and restart the daemon.  Don't forget to set everything back when you are done.  If anyone knows a good way around this, let me know.

All of these are rather minor and I hope to have solutions to all of these except number three around v0.9.0 (see the section on futures).  If you find something a bit more serious or just something annoying, let me know.


History:

v0.1.0	Unreleased version, basically all my development code
v0.8.0	First public release.  Basic support for ZyXEL voice modems

Planned Future Enhancements:

v?.?.?	Add support for playing and recording messages and greetings using the sound interfaces on the local computer.  This will probably involve writting a datatype for dealing with these files.  Let me know how important this feature is to you so I can properly place this in the list below

v0.9.0	Add support for Rockwell based modems (hopefully around Sept-Oct 97)
v1.0.0	Add support for USRobotics voice modems (hopefully around Dec 97)
v2.0.0	Add support for receiving faxes (summer 98)
v3.0.0	Add support for data dialins with passwords and shell access (autumn 98)

That is the official feature set I want to see in the longer term.  In the more immediate term, I am hoping the new scripting architecture can make this program much more configurable.  I have built the "VoiceModem" class so it inherits from BLooper.  This class abstracts all you need to control a particular voice modem and you just send BMessages to it to tell it to play a greeting, or wait for a call etc.  The BLooper will also send you BMessages when it sees DTMF tones etc.  With scripting, I don't see why you couldn't build one of those voice mail jails (ie "Press one to speak to sales, press two to speak to support...").

Right now, I have a bit of C++ code which responds to messages from the VoiceModem class and sends BMessages to tell it to answer the phone etc.  In the future, once scripting is documented and we have a language, I hope to replace all of this with a default script which does basic answering machine tasks.  The configuration window will allow you to select which script is associated with which ports.  People can write their own voice mail systems in the scripting language of their choice.  Plus the scripts can control different brands of modem without much extra coding (the main difference between the modems are the supported voice encodings, the scripts will have to choose the right ones).

Today, BePhoney could potentially control four ZyXEL modems on four serial ports on a BeBox.  With these scripts, you could create a four line customizable voice mail system.  If anyone knows how expensive commercial versions of this kind of system are, I would be interested.

Anyways, I am done dreaming.  Let me know what you think of it.
