Ants

Xbtrc: Remote Control application for X11 over BlueTooth

Author: Hylke W. van Dijk

Date: August 2005, Katlijk

Version: RC-1

Download

This xbtrc_rc-1.0.tgz tar file contains See the readme file (below) for instruction of usage and installation.

The current version, release candidate 1.0, is fully functional but we need some more feedback to package 1.0.

From the Readme file:


Introduction
============

This software consists of two parts

     1. A j2me client application, xbtrc, that runs on your mobile phone
     2. A python server, xbtrc-server, that runs on your PC

The two programs connect over BlueTooth and use a proprietary protocol
to exchange commands such as sendKeySymbol(), sendShortMessage(),
getMenuList(), and selectMenuItem().

Both the client and the server run two threads. The main thread of the
client reads the key pressed at your mobile and a second thread is
scheduled to listen for messages coming from the server. The main
thread of the server listens to the Bluetooth socket and executes the
instructions. Any reply message are dealt with by a separate sending
thread.

The server uses a configuration file (.xbtrc.rc) for fine tuning

The current status of the software is beta testing.


Application
============

The client application involves
    - Connect to an/the xbtrc server
    - Send X11 key symbols that are associated to ITU keys on your mobile phone
      to the server
    - (re)Load the configuration from  $HOME/.xbtrc.rc
    - Select and execute an application from the {Start} menu at the PC
    - Select and install a keymap configuration from the {Keymap} at
      the mobile phone
    - Toggle Echo. The default is that the server echos a readable 
      version of key symbol you sent. The string is displayed on the phone 
    - Exit
    

Prerequisites and installation
==============================

This is beta software, in case you did not notice. It has not been
extensively tested. I own a Nokia 6230 mobile phone. On my laptop (HP
with integrated Bluetooth) I use a recent Ubuntu (Hoarty) distribution.
$ uname -sr
  Linux 2.6.10-5-386


Client-side:

The current jar file (xbtrc.jar) and corresponding jad have been
compiled for MIDP 1.1; I am unsure whether they work on MIDP 1.0.

To upload the jars to your phone you have two options:
   - use GPRS/Wap from e.g. http://jugjug.homelinux.org/wap/
   - use gammu (apt-get install gammu)
     $ cd xbtrc-client/bin; gammu --nokiaaddfile Application xbtrc
     I included my working .gammurc file in this res directory.


Server-side:

The server relies on python2.4, python2.4-xlib, python2.4-xml, and
python2.4-bluez.  The first have Debian packages, for the last I
included a home-brewed Debian version of the python2.4-bluez in the
res directory. This package wraps the libbluetooth1 (2.11) library.
I am unsure whether the development files are required of that library.

Obviously you need a working X11 system, we use Xtest for sending key
symbols, and a bluez part for BlueTooth access (apt-get install
bluez-utils bluez-pin).


Given that you use python2.4 there is no need to modify xbtrc-server.py.

Copy (and  edit) the sample configuration file xbtrc.rc to your $HOME dir
$ cp ./res/xbtrc.rc $HOME/.xbtrc.rc

Make a link to xbtrc-server.py, e.g,
$ ln -s `pwd`/xbtc-server/xbtrc-server.py $HOME/bin/xbtrc-server

Start the server (at your PC)
$ xbtrc-server

Start the client (at the mobile)
- select the advertised xbtrc server and connect
- press the any key ;)

The current canvas shows still some debug information.  The time is
your phone time, the bottom line displays the message sent from the
server side. The rc message displays some info about the remote control
layer of client. 


Configuration
=============

The configuration file ($HOME/.xbtrc.rc by default) is read at server
start. It has two menus which are send to the client on connect. The
client may issue a reload of the configuration. We reread the configuration
file if expedient. 

The configuration file has a couple of sections. I only mention the
useful items here

parameter: 
   device.address:      limits access to the server to this address

menu: 
   item {name} {value}: The names are the entries of the menu sent to the phone
                        When name is selected at the phone, the server will
			execute {value}
keymenu:
  keymap {name}:        The names are the entries in the keymenu sent to the 
  keyitem {ITU} {X11}:  phone. When selected, the binary form of all keyitems 
                        are sent to the phone. 
			Keynames are defined as [modifier_]keyname
			Where the ITU keynames are defined in xbtrcCommand.py
			and the X11 key names are defined in
			Xlib.keysymdef.xkb of python bluez.
			Modifiers are defines as M[-M]* where M is one of
			{S,C,M,A} for Shift, Control, Meta, and Alt resp.
			It does not make sense to specify a modifier for ITU 
			keys. There is no way to generate them. One exception,
			I misuse the modifier for mouse movements. If you
			keep the Down/Up key pressed (at your phone) a 
			modifier is send that is translated in speed of the 
			mouse movement at the server.
			

Todo and known bugs
===================

- Not enough testing and using yet.
- I guess robustness must be improved.
- The mouse can be moved, but the interface needs fine tuning.
- Would be nice to focus applications from the phone. This requires the
  detection of a sensible list of running applications in the current screen.


Acknowledgement
===============

The remote application list part of this software has been inspired by
bluemote. The initial implementation of our client code used the
Bemused client code as a reference.



Refs
====

[1] Java Sun WTK for j2me; 
    http://java.sun.com/products/sjwtoolkit/download-2_2.html
[2] Gammu, bluetooth access to mobile; 
    http://www.mwiacek.com/
[3] Bluemote;
    http://www.geocities.com/saravkrish/progs/bluemote/
[4] Bemused;
    http://bemused.sourceforge.net/
[5] Pybluez: using (version 0.2); 
    http://org.csail.mit.edu/pybluez/


Hylke W. van Dijk
Last modified: March 01, 2006 (16:04:20).