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.
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
MythControl on PocketPC
Specifically an Ipaq2210 with pocketPC 2003. Many thanks to Axel for the helpful tutorial. With some stuttering I have have MythControl up and running. The interface is a bit ugly since I don't actually have a bluetooth phone controlling MythTV so the numeric shortcuts are not as useful. I'm now really using it a bit like a remote keyboard. The joystick works to play, pause and fast forward but anyone who knows the ipaq2210 joystick will no it is beyond useless.
However, there are some differences worth documenting which helped me get my setup working.
My Linux installation is Ubuntu Edgy. I installed almost all the bluez packages and probably a few others. I still don't know what is actually required.
One irritation is that bluez-passkey-gnome seems to require a reboot after the key is set before it works. After a reboot I get a message whenever I put my bluetooth usb stick into my machine telling me its being made discoverable. Prior to the reboot I could try and pair my device till I was blue in the face and it wouldn't pair. Although, the serial service did appear as available.
After the reboot I succeeded in pairing the device and adding a serial connection and connecting that connection. However, after adding the relevant lines to RemoteSchema.xml I found that mythControl (PocketPC end) would crash on opening the file. Some kind of exception error. Unable to get mythControl to load properly with any RemoteSchema I changed Remote schema to connect using TCP/IP. A quick test with my PocketPC connected using synce showed that it could control mythfrontend but only while connected. Information about connecting using synce can be found here .
Once I got the remote working over USB+synce+TCP/IP I worked to get a TCP/IP connection using Bluetooth. This turned out to be very easy.
Information on connecting synce using bluetooth can be found here . Complete steps 1-5 (make up your own mind about step 4. Ubuntu manages pins differently-ish!). At step 5 use:
#dund --listen --msdun call dun
#dund --listen --activesync --msdun call dun
6 onwards are only required if you actually want to connect using ActiveSynce.
Now add the pairing and a new Internet Connection in bluetooth manager (PocketPC end). It should ask for a username and password and then connect. The "Interet via <your_server_name>" icon should turn green to show its connected. Now Its time to fire up mythControl!
As of today, MythControl looks for the xml files in /Storage/My Documents/MythControl/*.xml. This is not the location of the "My Documents" folder on my PocketPC. Perhaps its hard coded and perhaps its not. I just created the relevant path and put my *.xml files there! The only remaining thing to do is make sure that the IP address from step 3 in the tutorial matches the IP address in remote schema.