Remote Control with WM Smartphone
This howto describes how to use your Windows Mobile Smartphone (2003 or WM5) as remote control for your MythBox. The approach uses either Bluetooth or TCP/IP (GPRS/WiFi) to control the box.
- 1 Introduction
- 2 Installation
- 3 Using MythControl
- 4 Tips and Tricks
- 5 Feedback
I started this project after my old Palm m500 finally broke after I have been using it as remote control for my MythBox a couple of years with OmniRemote. I bought a new Windows Mobile 5 Smartphone and started some experiments to use its Bluetooth capabilities to control MythTV. The result is a project which I called MythControl and that consists of a little server application running on the MythBox and a Windows Mobile Smartphone remote control application.
After I got it running, it turned out to work better than I thought and way better than the Omniremote solution.
- Since it uses Bluetooth, you don't have to point the remote directly at the IR receiver, instead you can even use it in a different room!
- The reaction is way faster than an infrared solution, it feels more like using a keyboard.
- The keys of the smartphone are more convenient to press than any touchscreen.
And with the remote control being completely customizable, I found this to be a perfect remote for my MythBox.
The application supports Windows Smartphone 2003 and Windows Mobile 5 at this point and communicates either via Bluetooth or TCP/IP (GPRS/WiFi) with the server.
If you want to use Bluetooth for the server communication, we have to pair your bluetooth smartphone with your Linux box first, then we can install the server application and the smartphone remote control. In case you want to use TCP/IP, you can skip this preparation step.
Preparing Bluetooth Installation
For two Bluetooth devices to be able to communicate, they have to get paired first. This is just a very short description on howto pair your smartphone with your Linux box, please refer to the Bluetooth documentation for your Linux distribution for more details. A howto for Gentoo Linux can be found . Please make sure to include Rfcomm in your setup.
You need to have the Bluez tools and development libraries are installed. I use Bluez version 3.7, I can't tell if it works for any other version.
Check your Bluetooth device on your Linux box.
A call to 'hciconfig' should return something like:
# hciconfig hci0: Type: USB BD Address: 08:00:17:1B:42:96 ACL MTU: 339:4 SCO MTU: 60:9 UP RUNNING RX bytes:5603 acl:177 sco:0 events:209 errors:0 TX bytes:40682 acl:270 sco:0 commands:30 errors:0
If no Bluetooth device is being displayed, please check your Bluetooth Dongle, your Bluetooth kernel configuration and your distribution specific Bluetooth startup.
Put your Bluetooth device in 'Discoverable' mode.
# hciconfig hci0 piscan
Start the passkey-agent to set the passkey.
# passkey-agent --default 1234 &
Please replace 1234 with the pairing pin you are going to use. You will have to enter the same pin in your mobile phone in the next step. Since this is the only security precaution, please make sure not to choose something simple!
Offer a RFCOMM serial port emulation on your Linux box.
# sdptool add --channel=3 SP
Please configure your system to execute this command during bootup after the Bluetooth subsystem has been started.
Now it's time to pair your smartphone with the Linux box. On your WM5 smartphone, go to Settings->Connections->Bluetooth. Make sure Bluetooth is activated and go further to Menu->Devices. The phone lists the devices know to it. If your box has never been added before, go tho Menu->New. The smartphone now scans for devices in the area. Your MythBox should show up in the list after the scanning has finished. Select your MythBox and press 'Next'. The phone will now prompt you for the passkey. Enter the passkey you specified for the passkey-agent above and press 'Next' again. A confirmation message will be displayed.
You can now proceed with the MythControl installation.
MythControlServer Installation on your MythBox
Download MythControl-version.zip from . Unzip it on your Linux box and enter the MythControlServer directory.
# make # make install
By default the mythControlServer application is installed in /usr/local/bin. Edit the makefile to specify a different location.
DO NOT START MYTHCONTROLSERVER AS ROOT!!! Any device that successfully paired with your Linux box can send any command to execute to the server, not only mythtv commands! It is therefore important to start mythControlServer as regular user.
You can specify with the -r and -n option on what RFComm channel or what TCP port mythControlServer should listen to. You can also specify both. If you don't specify anything, it will listen on RFComm channel 3 by default.
I start mythControlServer by adding these two commands to my .xsession file right before mythfrontend is executed.
Make sure the network remote control interface is enabled in mythfrontend. Goto Setup->General->General page and check that 'Network Remote Control Interface' is enabled and the 'Network Remote Control Port' is set to 6546.
MythControl Installation on your Smartphone
If you have a Windows Mobile 5 Smartphone, you first need to install the .NET Compact Framework 2 on your smartphone. It can be downloaded at . This is not necessary for a Windows Smartphone 2003.
Download MythControl-version.zip from  and execute the MSI installer on your desktop computer you synchronize with your smartphone. The installer will ask you for installation directory, your smartdevice version and will then install MythControl on your smartphone via ActiveSync.
The installer installs two configuration files in MyDocuments/MythControl on your smartphone. Copy 'MythControlSettings.xml' to your desktop computer for edit. This is how it looks like:
The Title element obviously specifies the title of the application. You can set this to whatever you want it to be. DirectCommand is explained later in this howto. DisplayLicense determines whether the license disclaimer should be displayed on application start.
Next, copy 'RemoteSchema.xml' to your desktop computer for edit. It starts like this:
Modify the Connector according to your server. The connector above is an example for a Bluetooth connector. The value of the property is the Bluetooth address of the MythBox. To use TCP/IP, use a connector like this:
You can also specify multiple connectors, the first one will be used as default. Please note that each connector needs to have a unique name within the file.
After you have finished adapting the two files according to your needs, copy them back on your smartphone.
To start the application, goto Start->MythControl.
This section is more about how MythControl works and how to design your own remote since the usage of MythControl is pretty straight-forward.
You can define multiple RemoteSchemas for MythControl. A RemoteSchema is basically a mapping from smartphone keys to functions. For every key you can specify a label to be displayed on the screen and a command to send to your MythBox. Keys for use with MythControl are the navigation keys ('Up', 'Down', 'Left', 'Right', 'Select' and 'Back') and all the number keys including * and #.
Since you probably need more than 12 commands to control your MythBox, you can add two menus accessible through the left and right softkeys. The left menu will always contain some basic functions like Quit and two sub menus to send digits or letters, but you can add unlimited more remote commands or sub menus. The right menu can be completely customized by you. Since the default name of the left menu is 'Menu' and the default name of the right menu is 'More', these two menus will be called MenuList and MoreList.
Switch to different Schema
Besides label and command, you can specify for every key or menu item also another RemoteSchema to change to when the key or menu item is invoked. This allows you to create subschemas or schemas for other functionality. I use this functionality extensively. For example you can create a RemoteSchema for LiveTV, one for Recordings, one for Music and so on. For each of these RemoteSchemas you can add a menu item to switch to the other RemoteSchema. If you further specify a mythtv jump command for these menu items, MythTV will jump to the function called at the same time as the remote layout changes.
You can currently specify two different types of commands in MythControl. Every command that starts with 'mythtv ' will be send to the Mythfrontend remote network interface (without the leading 'mythtv'). Every command that starts with 'cmd ' will be executed in a shell. This allows you to execute almost everything via MythControl.
Example RemoteSchema.xml file
The RemoteSchemas are defined in an xml file 'RemoteSchema.xml' that is installed on your smartphone by the installer in MyDocuments->MythControl. Copy the file to your local machine for edit. Here is an example:
The MenuList and MoreList elements define the two softkey menus. Both lists may contain RemoteActionItem elements. Each RemoteActionItem may directly represent a command or have other RemoteActionItem subelements to represent a submenu.
RemoteActionItems and Key..Actions may have four attributes:
- 'Label' specifies the label displayed on the screen
- 'Command' specifies the command to be sent to the MythBox (either starting with 'mythtv' or 'cmd' as described previously)
- 'GotoSchema' specifies the name of a RemoteSchema to switch to.
- 'Connector' specifies the name of the Connector to use for this command.
This allows you to design your remote control in a very flexible way. An example remote schema is installed with MythControl. Please see in the Helpful Tools section below for additional tools and shell scripts I use. Adopt it to your taste...
Tips and Tricks
Rfcomm kernel patches
The Linux kernels 2.6.18 and 2.6.19 (and maybe later versions?) include a Rfcomm implementation that sometimes crashed my whole system when accessing it via Bluetooth. Marcel Holtmann (thanks again!) provided me with a patch that works great for me. In the Helpful Tools section below you'll find a patch for both kernel verions.
Other applications than MythTV like Xine
Since I use Xine for playing video and DVD, I was looking for a solution to control Xine as well with MythControl. I found a little tool 'sendxevent' by Heinrich Langos and Christoph Bartelmus (thanks!), which sends a mouse or key event to any X window application. It works great with MythControl and Xine. See the link in the Helpful Tools section below to download it.
Controlling TV or Receivers
One disadvantage of a Bluetooth remote as supposed to an IR remote is that you can't control any IR device like TV or surround receiver. But there is a solution :-)! I bought an  and use LIRC to send IR commands from my MythBox to my TV and receiver. Since MythControl can remotely execute any command through 'cmd', I can also send IR commands to my external devices like this. That way, I can also switch my TV on and off as well as control the volume on my receiver via MythControl.
Shell Scripts and Helpful Tools
These  are additional helper shell scripts I call from MythControl to do everything described here in this article.
This solution really works great for me, but I haven't heard any feedback from anybody else, neither positive or negative. Please let me know if you have any problems setting MythControl up, I'm happy to help. I'd also appreciate any positive feedback if the tool is useful for anybody... Just drop me a line in the firstname.lastname@example.org mailing list!
- Axel Ruder