
Linux USB phone howto
The document describes the installation and configuration of a USB phone for Linux, based on the Yealink P1K. As a result, complete control of phone calls was achieved, without the participation of a mouse and keyboard.
I always wanted to have a mobile VoIP phone. This is such a phone that is always with you, just like a mobile phone, but at the same time it is a VoIP phone, i.e. connected to your own IP PBX server (options like Nokia E65 and similar ones do not offer, I don’t want to warm my ears with a mobile Wi-Fi microwave, so only USB phones remain). Windows users simply live, all kinds of X-Lite and others include drivers for all kinds of USB phones, and all kinds of USB phones come with a disk with different softphones. But for those with Linux desktops, easy ways have been ordered. Nevertheless, go!
Googling on the topic “linux usb phone” showed that the Yealink P1K USB phone turned out to be the only phone that could be successfully connected. At the same time, half of those who tried could not connect it. Well then, let's try.
I will not describe the long way that has been done in the process of walking the rake. I can only say thanks to Thomas Reitmair, the author of the Yeaphone package www.devbase.at/voip/yeaphone.php , for his responsiveness and help. So, to get a mobile VoIP phone, you need the following components: - USB P1K phone - kernel module p1k yealink.ko - softphone linphone. - yeaphone package.
Starting with some version, Linux contains in the section Device drivers → Input device support → Miscellaneous devices → Yealink usb-p1k voip phone. However, this module is out of date! We need to take the module from the site of Thomas. Apparently, this is his home machine, so a copy of the files relevant at the time of this writing is attached here (Revision: 142). As Thomas said: This was just my case, and the output of lsusb proved it: The module assembled without problems on my relatively fresh 2.6.31-gentoo. The assembly is simple: the resulting file must be sent to the right place:
Another “false road” is the linphone softphone version. The fact is that all packages published on sites are designed for version 2.x branches, and all fresh distributions install linphone version 3.x. For example, I have net-voip / linphone-3.1.1 installed. It is with the version that the assembly error of yeaphone is connected, something like this: The fact is that in the 3rd branch the API was changed. Thomas made the patch, but for some reason did not update the tar.gz packages, and the normally compiled code lies only in svn. If any kind of problem arises, I recommend reading the comment section on Thomas's website. For your convenience, I also attach to the article a package with yaphone.
Even after I put everything together, an attempt to start yaphone led to the message:
And it looked like this: The thing is that the usbhid module “takes” the device for itself, and the yealink module does not see it. If we unload the usbhid module (attention, we are left without a mouse), and temporarily move usbhid.ko, say, to tmp, reload the yealink module, and stick the phone, the dmesg message will look like this: As you can see, the phone was detected and showed its serial number . In order not to have to manually play with the module each time, you need to add a rule to udev, which will call a script that "detaches" the phone from usbhid and "attaches" it to yealink. The script is shown in the application, but the conclusion of its work: The output of dmesg will confirm that everything went well.
The final touch is the adaptation of /etc/udev/rules.d/99-yealink.rules Please note that instead of max you need to insert the group under which your account is working. To see your groups, run the groups command. The rebind-yealink.sh script is in the application. If at startup the phone displays something like this: it means that you need to deal with 99-yealink.rules - it either does not work out due to a syntax error, or an error is made in the account. cd / sys / bus / usb / and watch permissions.
Register the startup phone in startup (rc.local, local.start or as in your distribution package correctly):
Here you also need to change max to the name of your account.
After installing all the components, you can begin to configure. It is necessary to configure:
Next, you need to configure your audio device. If the GTK interface is assembled, then you can do it in it, otherwise as follows: This command will configure all sound channels (playback, capture & ring) to use a USB phone.
Well, in conclusion, I will give an example of settings. The ~ / .yeahonerc file contains the configuration, and the ~ / .yaphone / ringtone / folder contains ringtones. Ringtones are nasty, it would be great if someone added their more melodic ones, such as “a grasshopper was sitting in the grass” ... Also, you need to make sure that only one proxy server is configured, and it is selected as default in the ~ / .linphonerc file. If you receive such a message, this means that you need to edit the ~ / .linphonerc pens.
As a result, as soon as I connect the Skype mate P1K USB phone to my laptop, it connects to the server for a maximum of 10 seconds. As soon as I pull out the USB cable from the laptop, the softphone unregisters. For the 3rd day of operation, no problems were found.
Udev rules
Script for udev to remove a phone from usbhid
Yaphone 0.1.8
Module to the kernel
Introduction
I always wanted to have a mobile VoIP phone. This is such a phone that is always with you, just like a mobile phone, but at the same time it is a VoIP phone, i.e. connected to your own IP PBX server (options like Nokia E65 and similar ones do not offer, I don’t want to warm my ears with a mobile Wi-Fi microwave, so only USB phones remain). Windows users simply live, all kinds of X-Lite and others include drivers for all kinds of USB phones, and all kinds of USB phones come with a disk with different softphones. But for those with Linux desktops, easy ways have been ordered. Nevertheless, go!
USB phone selection
Googling on the topic “linux usb phone” showed that the Yealink P1K USB phone turned out to be the only phone that could be successfully connected. At the same time, half of those who tried could not connect it. Well then, let's try.
Installation
I will not describe the long way that has been done in the process of walking the rake. I can only say thanks to Thomas Reitmair, the author of the Yeaphone package www.devbase.at/voip/yeaphone.php , for his responsiveness and help. So, to get a mobile VoIP phone, you need the following components: - USB P1K phone - kernel module p1k yealink.ko - softphone linphone. - yeaphone package.
USB phone Yealink P1K and yealink.ko kernel module
Starting with some version, Linux contains in the section Device drivers → Input device support → Miscellaneous devices → Yealink usb-p1k voip phone. However, this module is out of date! We need to take the module from the site of Thomas. Apparently, this is his home machine, so a copy of the files relevant at the time of this writing is attached here (Revision: 142). As Thomas said: This was just my case, and the output of lsusb proved it: The module assembled without problems on my relatively fresh 2.6.31-gentoo. The assembly is simple: the resulting file must be sent to the right place:
You might own a P1KH (USB ID 6993:b700) which uses a slightly different
communication protocol compared to the P1K. The P1K is the only model
supported by the kernel module shipped with the regular Linux kernel.
However if yours is a P1KH (or a B2K, B3G, P4K) then you should try my
version of this module:
svn co --username guest --password readonly svn://devbase.homelinux.org:5070/voip/yealink-module
explorer t2-trunk # lsusb
...
Bus 003 Device 019: ID 6993:b700 Freshtel
max@explorer /tmp/yealink-module/trunk $ make
make -C /usr/src/linux SUBDIRS=`pwd` modules
make[1]: Entering directory `/usr/src/linux-2.6.31-gentoo-r6'
CC [M] /tmp/yealink-module/trunk/yealink.o
Building modules, stage 2.
MODPOST 1 modules
CC /tmp/yealink-module/trunk/yealink.mod.o
LD [M] /tmp/yealink-module/trunk/yealink.ko
make[1]: Leaving directory `/usr/src/linux-2.6.31-gentoo-r6'
max@explorer /tmp/yealink-module/trunk $
cp yealink.ko /lib/modules/2.6.31-gentoo-r6/kernel/drivers/input/
Softphone linphone and wrapper yeaphone
Another “false road” is the linphone softphone version. The fact is that all packages published on sites are designed for version 2.x branches, and all fresh distributions install linphone version 3.x. For example, I have net-voip / linphone-3.1.1 installed. It is with the version that the assembly error of yeaphone is connected, something like this: The fact is that in the 3rd branch the API was changed. Thomas made the patch, but for some reason did not update the tar.gz packages, and the normally compiled code lies only in svn. If any kind of problem arises, I recommend reading the comment section on Thomas's website. For your convenience, I also attach to the article a package with yaphone.
home/adyna/Desktop/yeaphone-0.1.6/src/ylcontrol.c:578: undefined reference to `gstate_get_state'
/home/adyna/Desktop/yeaphone-0.1.6/src/ylcontrol.c:579: undefined reference to `gstate_get_state'
/home/adyna/Desktop/yeaphone-0.1.6/src/ylcontrol.c:580: undefined reference to `gstate_get_state'
Fight with usbhid
Even after I put everything together, an attempt to start yaphone led to the message:
No appropriate handset found, exiting...
And it looked like this: The thing is that the usbhid module “takes” the device for itself, and the yealink module does not see it. If we unload the usbhid module (attention, we are left without a mouse), and temporarily move usbhid.ko, say, to tmp, reload the yealink module, and stick the phone, the dmesg message will look like this: As you can see, the phone was detected and showed its serial number . In order not to have to manually play with the module each time, you need to add a rule to udev, which will call a script that "detaches" the phone from usbhid and "attaches" it to yealink. The script is shown in the application, but the conclusion of its work: The output of dmesg will confirm that everything went well.
usbcore: registered new interface driver yealink
yealink: Yealink phone driver: 20090418 (C) Thomas Reitmayr, Henk Vergonet
usb 3-1: USB disconnect, address 22
usb 3-1: new full speed USB device using uhci_hcd and address 23
usb 3-1: configuration #1 chosen from 1 choice
generic-usb 0003:6993:B700.0020: hiddev0,hidraw3: USB HID v1.10 Device [Yealink Network Technology Ltd. VOIP USB Phone ] on usb-0000:00:1a.1-1/input3
yealink: Yealink phone driver: 20090418 (C) Thomas Reitmayr, Henk Vergonet
usb 3-1: new full speed USB device using uhci_hcd and address 19
usb 3-1: configuration #1 chosen from 1 choice
yealink: Detected Model USB-P1KH (Version 0x1005)
yealink: Serial Number ff0adb4abc96
input: Yealink USB-P1KH as /devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.3/input/input20
explorer /tmp # sh /tmp/rebind-yealink.sh
Found Yealink phone at /sys/devices/pci0000:00/0000:00:1a.1/usb3/3-1
found HID interface at 3-1:1.3
successfully detached driver 'usbhid'
successfully reattached driver 'yealink'
explorer /tmp #
udev and permissions
The final touch is the adaptation of /etc/udev/rules.d/99-yealink.rules Please note that instead of max you need to insert the group under which your account is working. To see your groups, run the groups command. The rebind-yealink.sh script is in the application. If at startup the phone displays something like this: it means that you need to deal with 99-yealink.rules - it either does not work out due to a syntax error, or an error is made in the account. cd / sys / bus / usb / and watch permissions.
explorer ~ # cat /etc/udev/rules.d/99-yealink.rules
KERNEL=="event*", ATTRS{name}=="Yealink*", GROUP="max", RUN+="/bin/sh -c '/bin/chgrp max /sys$env{DEVPATH}/device/device/*'"
ACTION=="add|change", SUBSYSTEMS=="usb", ATTRS{idVendor}=="6993", ATTRS{idProduct}=="b700", RUN+="/usr/local/sbin/rebind-yealink.sh"
opmascha@explorer ~ $ yeaphone
path_sysfs = /sys/bus/usb/drivers/yealink/5-1:1.3/
path_event = /dev/input/event11
/sys/bus/usb/drivers/yealink/5-1:1.3/model: Permission denied
Detected handset Yealink USB-P1K
/sys/bus/usb/drivers/yealink/5-1:1.3/line2: Permission denied
/sys/bus/usb/drivers/yealink/5-1:1.3/line1: Permission denied
/sys/bus/usb/drivers/yealink/5-1:1.3/line3: Permission denied
/sys/bus/usb/drivers/yealink/5-1:1.3/hide_icon: Permission denied
Startup
Register the startup phone in startup (rc.local, local.start or as in your distribution package correctly):
su - max -c '/usr/local/bin/yeaphone -w' > /dev/null 2>&1 &
Here you also need to change max to the name of your account.
Customization
After installing all the components, you can begin to configure. It is necessary to configure:
- SIP account (by the way, this is one of the limitations: if linphone supports an unlimited number of accounts, then yeaphone is only one, because it does not know how to sort them);
- Audio Device - USB VoIP Phone
- add. yaphone settings (ringtone, dialing options, etc.).
SIP Account
- There are two ways to do this:
- Launch the linphone-3 GUI (if built), and set up an account in it.
- Configure from the console. Here is an example from the console:
linphonec> proxy add
Adding new proxy setup. Hit ^D to abort.
Enter proxy sip address: sip:sipnet.ru
Your identity for this proxy: sip:1234567890@sipnet.ru
Do you want to register on this proxy (yes/no): yes
Specify register expiration time in seconds (default is 600): 180
Expiration: 180 seconds
Specify route if needed:
No route specified.
--------------------------------------------
sip address: sip:sipnet.ru
route:
identity: sip:1234567890@sipnet.ru
register: yes
expires: 180
registered: no
--------------------------------------------
Accept the above proxy configuration (yes/no) ?: yes
Proxy added.
linphonec> Registration on sip:sipnet.ru successful.
linphonec> Registration on sip:sipnet.ru successful.
linphonec>
Audio configuration
Next, you need to configure your audio device. If the GTK interface is assembled, then you can do it in it, otherwise as follows: This command will configure all sound channels (playback, capture & ring) to use a USB phone.
linphonec> soundcard list
0: ALSA: default device
1: ALSA: HDA Intel
2: ALSA: VOIP USB Phone
linphonec> soundcard use 2
Using sound device ALSA: VOIP USB Phone
linphonec>
Yeaphone setup
Well, in conclusion, I will give an example of settings. The ~ / .yeahonerc file contains the configuration, and the ~ / .yaphone / ringtone / folder contains ringtones. Ringtones are nasty, it would be great if someone added their more melodic ones, such as “a grasshopper was sitting in the grass” ... Also, you need to make sure that only one proxy server is configured, and it is selected as default in the ~ / .linphonerc file. If you receive such a message, this means that you need to edit the ~ / .linphonerc pens.
max@explorer /tmp $ cat ~/.yeaphonerc
intl-access-code 810
natl-access-code 8
country-code 7
display-id " --123--"
ringtone_default default_p1k.bin
#ringtone_default default_p1kh.bin
#ringtone_default falling2_p1k.bin
#ringtone_default falling_p1k.bin
#ringtone_default rising_p1k.bin
#ringtone_default special_p1k.bin
Warning: Could not parse given sip address. A sip url usually looks like sip:user@domain
Conclusion
As a result, as soon as I connect the Skype mate P1K USB phone to my laptop, it connects to the server for a maximum of 10 seconds. As soon as I pull out the USB cable from the laptop, the softphone unregisters. For the 3rd day of operation, no problems were found.
Applications
Udev rules
Script for udev to remove a phone from usbhid
Yaphone 0.1.8
Module to the kernel