NSLU2-Linux
view · edit · print · history

There are various USB phones available which are marketed as VoIP phones. While usually rather cheap their built-in logic does not provide much more than an audio device, reading a user's key presses and possibly displaying simple messages.

The following article describes how to connect and use a YeaLink USB-P1K handset with the NSLU2 as a standalone SIP VoIP phone. The USB-P1K was chosen because it is well-supported by the Linux kernel module yealink (see http://savannah.nongnu.org/projects/usbb2k-api/). It is sold for ~30€ under various brand names (cistrix, comsel, freshtel, laser, peoplefone, siptronic, us robotics, etc). Please note that nowadays most devices advertised as USB-P1K are actually its successor, the USB-P1KH. Although it is not supported by the driver shipped with the kernel, there is a new version of the yealink kernel module available at http://www.devbase.at/svn/view.cgi/yealink-module/?root=voip for kernel versions >= 2.6.18.

There is no support for models other than the USB-P1K(H) at this time, but some may not need much work in the application.

Table of contents

Basic Architecture

As mentioned above the USB-P1K provides the basic phone interface (speaker, microphone, keys, display) but no VoIP functionality. On the other side there are the numerous VoIP soft phones, most of which can only be controlled via their GUI and therefore are not suitable for the NSLU2.

This gap is closed by Yeaphone, which interfaces to the kernel module and provides VoIP functionality by using the liblinphone SIP phone backend.

Yeaphone's main features are:

  • Display the phone number of incoming and outgoing calls
  • Show the duration of a call
  • Store and recall 10 phone numbers
  • Mute the ring tone of incoming calls
  • Adjustable volume of the speaker
  • Send DTMF tones

Installation

The necessary parts are

  • Linphone >= 1.7.1
  • Yeaphone 0.1.5
  • only for linux kernels < 2.6.18: patched kernel module usbhid

The BitBake files are available in the OpenEmbedded database but can also be downloaded from the developer's web-site for Yeaphone: http://www.devbase.at/voip/yeaphone.php

For SlugOS/BE 4.8beta downloading the necessary files into the cross-compile environment could look like:

cd ~/slugos-4.8-beta/openembedded/packages/linphone/
wget  http://download.devbase.at/voip/linphone_2.1.1.bb
mkdir ../yeaphone
cd ../yeaphone
wget http://download.devbase.at/voip/yeaphone_0.1.5.bb
cd ~/slugos-4.8-beta/

Then you can compile Yeaphone:

bb yeaphone

Note that this will only build the console version of linphone (as yeaphone's dependency). If you also want the GUI to be built you need to adjust the BitBake file linphone_2.1.1.bb.

Alternatively there are compiled packages available for everything you will need to run Yeaphone at feed.devbase.at.

Software Setup

Setting a SIP Server

The SIP servers for Yeaphone have to be configured through linphonec, the console version of Linphone. The following example shows how to get a working connection to a VoIP provider (user input printed bold).

    root@NSLU2:~# linphonec
    Ready
    linphonec> proxy add
    Adding new proxy setup. Hit ^D to abort.
    Enter proxy sip address: sip:sipgate.at
    Your identity for this proxy: sip:1234567@sipgate.at
    Do you want to register on this proxy (yes/no): yes
    Specify register expiration time in seconds (default is 600): 600
    Expiration: 600 seconds
    Specify route if needed: [leave empty]
    No route specified.
    --------------------------------------------
    sip address: sip:sipgate.at
    route:
    identity: sip:1234567@sipgate.at
    register: yes
    expires: 600
    --------------------------------------------
    Accept the above proxy configuration (yes/no) ?: yes
    Proxy added.
    linphonec>
    Password for 1234567 on "sipgate.at": [enter password]
    Registration on sip:sipgate.at sucessful.
    linphonec>

Using linphonec the VoIP connection can be tested immediately before using Yeaphone. Commands still have to be entered through the terminal and the PC keyboard though. Note that if other sound cards are connected to the system, than it is likely that at this stage the speaker and microphone of the Yealink handset are not used yet. Yeaphone will later choose the correct audio settings automatically.

The most important commands of linphonec are:

  • help [<command>]
    shows the available commands and provides a detailed description for each command
  • call <phone number or SIP address>
    dials the specified phone number of SIP address
  • answer
    answers an incoming call
  • terminate
    terminates an (incoming or outgoing) call
  • quit
    unregisters at the VoIP provider and quits linphonec

Providing Yeaphone-Specific Parameters

Now the configuration file ~/.yeaphonerc has to be created manually. In order to correctly understand the phone number of incoming calls, Yeaphone needs the parameters intl-access-code, natl-access-code, and country-code according to your country.

An example for Austria would be:

    intl-access-code  00
    natl-access-code  0
    country-code      43

For the USA this would be:

    intl-access-code  011
    natl-access-code  1
    country-code      

In ~/.yeaphonerc you can also spedify custom ringtones for different numbers by adding lines according to the following example:

    ringtone_default   /usr/share/yeaphone/ringtones/default_p1k.bin
    ringtone_01234567  /usr/share/yeaphone/ringtones/special_p1k.bin
    ringtone_0555777   doorbell_p1k.bin

If you specify relative paths to the ringtones, they are based on $HOME/.yeaphone/ringtone.

Another feature to be configured in ~/.yeaphonerc is the minimum ring duration. If for a certain caller ID the duration of the ring should be at least 5 seconds, this can be specified as:

    minring_01234567  5

If in its idle state the handset should not only display the current date and time but also a certain fixed text, then the option display-id comes in handy. This makes sense especially in an environment where multiple handsets are operated next to each other and there is danger of confusing them. Example:

    display-id  "  --1234--"

Creating a rule for udev

As Yeaphone should not be run by the user <i>root</i> for security reasons, the access rights of the files providing the interface to the yealink driver have to be adjusted. The following line changes the group from root to voip assuming that the yeaphone user is a member of this group. The line has to be writting to a file called /etc/udev/rules.d/99-yealink.rules.

    KERNEL=="event*", DRIVERS=="yealink", GROUP="voip", RUN+="/bin/sh -c '/bin/chgrp voip /sys$env{PHYSDEVPATH}/*'"

To activate the rule on a running system, the handset has to be unplugged and plugged in again.

Using Yeaphone

When invoking yeaphone the output on the console should look similar to this:

    user@NSLU2:~# <b>yeaphone</b>
    Ready
    Registration on sip:sipgate.at successful.

At the same time the current date and time are show on the handset's display, a quick sequence of status messages appear, and finally the lower part of the display should be empty (or show the text set with 'display-id'). Now the handset's keyboard can be used to place and receive calls.

The various phone keys have the following functions:

  1. before a phone call
    • 0-9,*,#
      Dial a phone number
    • C
      Remove the last character of the dialed number
    • C pressed long
      Remove the complete number
    • <red key>
      Remove the complete number
    • <green key>
      Initiate the call
    • ▲ + <0-9>
      No number dialed yet: Recall and display a number from memory X
      Number already dialed: Store the currently displayed number at memory X
  2. during a phone call
    • 0-9,*,#
      Generate DTMF tones
    • <red key>
      Terminate the call
    • VOL-/+ (on some models: IN/OUT)
      Adjust the speaker's volume
  3. after a phone call (with the last number displayed)
    • 0-9,*,#
      Dial a new phone number
    • C
      Remove the complete number
    • <red key>
      Remove the complete number
    • <green key>
      Redial the last number
    • ▲ + <0-9>
      Store the last number to memory X
  4. when the phone rings
    • #
      Mute the ringing without picking up
    • <red key>
      Immediately terminate the call without picking up
    • <green key>
      Pick up
  5. general
    • <red key> pressed long
      Start and stop the VoIP connection (corresponds to turning on/off a phone)

For special use cases Yeaphone provides a few command-line options. In a multi-head environment you may choose a specific handset (out of multiple connected devices) using the option --id. With option -w or --wait the application can be instructed to wait for the device to be connected and to not terminate if the device gets disconnected.

    --id=<id>       Attach to the device with an ID <id>.
    --wait=[<sec>]  Check for the handset every <sec> seconds.
    -w              Check for the handset every 10 seconds.
    --help|-h       Print this help message.

Performance Considerations

The following performance measurements have been done using linphonec on a TurboSlug with an ARM5-optimized SPEEX library 1.2beta1 and SlugOS/4.8 (OABI):

  • Codecs PCMU, PCMA, GSM: There is no significant CPU load during the phone call.
  • Echo Cancellation: With echo cancellation turned on the NSLU2 simply cannot keep up with the audio streams, only a fraction of the signal reaches the speaker.
  • SPEEX (wide-band, 16kb): The CPU load is between 50 and 70 %, occasionally there are audible cuts. The memory consumption rises to 50 %!
  • SPEEX (narrow-band, 8kb): The CPU load stays between 30 and 40 %, there are still some audible cuts.

Conclusion: The NSLU2 does not have enough horse power for echo cancellation or the SPEEX codecs, these should be turned off in the configuration file ~/.linphonerc.

view · edit · print · history · Last edited by Thomas Reitmayr.
Originally by Thomas Reitmayr.
Page last modified on October 06, 2008, at 09:23 PM