# HOWTO: Connect a Win Mobile 2003 PDA to Linux via infrared

## dogshu

Long title:  HOWTO: Connect a Windows Mobile 2003 PDA to Linux (and the Internet!) via infrared.

My boss recently bought me the low-end Dell Axim X50.  Its pretty cool for a Windows machine, but it doesn't include 802.11b support, only infrared and bluetooth.  I don't have any bluetooth enabled devices besides the X50, and the compact flash 802.11b card I ordered won't be here until next week, so I decided to set up an infrared network between the X50 and my Gentoo laptop.  It was a bit more difficult to set up than I expected, so I'll describe how to do it here.

I chose to have the added benefit of an internet connection through infrared, but if you just want a private network between a linux box and the PDA, this guide should be able to help you with that too.

First let's make sure all of the other necessary kernel configuration options are enabled.  On Linux 2.6.10, you need to make sure the following options are checked:

Device Drivers -> Networking Support -> IrDA subsystem support -> Cache last LSAP

Device Drivers -> Networking Support -> IrDA subsystem support -> Fast RRs (low latency)

Also, the IrCOMM protocol needs to be built into the kernel or built as a module.  Depending on your hardware, you will also need to enable one or more things under "Infrared-port device drivers".  For example, I have "Toshiba Type-O IR Port" enabled as a module in that menu.

Under Device Drivers -> Networking Support, make sure "PPP support for async serial ports", "PPP support for sync tty ports", "PPP Deflate compression", and "PPP BSD-Compress compression" are enabled or being built as modules.  If you want internet access over infrared, go here:

Device Drivers -> Networking Support -> Network packet filtering -> IP: Netfilter Configuration

and enable "Connection tracking", "IP tables support", "Full NAT", and "MASQUERADE target support".  You probably should also enable "FTP protocol support", "IRC protocol support", and "TFTP protocol support", so that those things work over the internet.

I build all of those things as modules, so in my infrared initialization script, I have the following:

```
modprobe donauboe

modprobe ppp_async

modprobe ircomm-tty

modprobe ipt_MASQUERADE

modprobe ip_nat_ftp

modprobe ip_nat_tftp

modprobe ip_nat_irc
```

Now let's get low-level Infrared working on your Linux machine.  My laptop has a "toshoboe" infrared interface, so getting infrared going was as simple as running:

```
modprobe donauboe

ifconfig irda0 up
```

However, it may be more involved for you, depending on the infrared hardware on your Linux box.  Go to this page:

http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/IrDA.html

and scroll down to "Low level drivers".  Hopefully you will be able to get your infrared hardware working with the information there.  Don't forget to run "ifconfig irda0 up" after setting up the interface!

Now let's make sure infrared is working.  If you haven't already, install irda-utils, there is an ebuild for it.  Now turn on your PDA, and point its infrared interface at your Linux machine's infrared interface.  Remember that there must be a line of sight between the linux box and the PDA.  A distance of about 3 - 6 feet worked best for me.  From your Linux machine, run "irdaping foo" (as far as I can tell an argument is required, but can be any string you want.  I used "foo").  If you get "No such device", your infrared hardware isn't set up properly.  If you get "Network is down", you forgot to run "ifconfig irda0 up".  But hopefully you will receive ping replies from the PDA.  If you do not, get this working before proceeding.

I use dnsmasq to provide DNS service to the PDA.  This is optional, if you want you can modify the "pppd" line later in this document to point to your upstream DNS server.  However, I like using dnsmasq because it will automatically forward DNS requests to whatever you happen to have in your /etc/resolv.conf at the time, which is good for laptops.  Also, it will allow your PDA to resolve the name "linuxbox" as the Linux infrared host, so you don't have to remember the IP address.  So, install dnsmasq, there is an ebuild for it.  Then, append these lines to the end of /etc/hosts:

```
# infrared hosts

192.168.55.1 linuxbox.infrared linuxbox

192.168.55.2 pda.infrared pda
```

and add this to /etc/dnsmasq.conf:

```
local=/infrared/
```

Now let's get pppd set up.  I upgraded to 2.4.3 during the course of my testing.  I don't know if that version of pppd is required, but it certainly gave more descriptive error messages.  So if you have problems with earlier versions of ppp, upgrade to 2.4.3.  The ebuild is under net-dialup/ppp.

I use kind of a strange method of getting ppp going, using "init".  I add this line to /etc/inittab:

```
s3:45:respawn:/usr/sbin/pppd passive nodetach noauth child-timeout 0 ms-dns 192.168.55.1 local lock 192.168.55.1:192.168.55.2 ircomm0 115200
```

Then run "init 4" to enable pppd on the infrared port, and "init 3" to disable it.  This method is pretty Gentoo-specific, since distributions like Red Hat have quite a bit more stuff depending on the init level.  You'll find that running "init 4" or "init 3" on other distributions will probably kill X Windows, and possibly other things.  If you're not running Gentoo, you can skip the inittab stuff and adapt the pppd command to the script I provide below.

Now let's get the connection configured on your Windows Mobile 2003 PDA.  Go to Start -> Settings -> Connections -> Connections, and select "Add a new modem connection" under "My ISP".  Pick a name for the connection, and pick "Generic IrDA" under "Select a modem".  Hit next.  Even though we are not going to dial a phone number, we need to type one in.  Enter any number you want, but I recommend making it at least a few digits long, since you're going to need to select it with your stylus when you connect.  I chose "37337".  Hit next.  Select "Advanced..."  Under "General", set the baud rate to 115200 and uncheck "Wait for tone..."  Under "Port settings", make sure that "Enter dialing commands manually" is checked.  Under "TCP/IP", make sure that the two "compression" options are enabled, and "use slip" is disabled.  The "Use server assigned..." options should be enabled under "TCP/IP" and "Servers".  Hit OK and then hit finish.

Since infrared networking isn't really something you're going to want enabled on your Linux box all the time, or for very long, I've written a small script to bring the infrared network up and down on the Linux machine.  Here it is:

```
#!/bin/sh

ifconfig irda0 up

init 4

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.55.0/24 -j MASQUERADE

/etc/init.d/dnsmasq start

# pause before shutdown

echo -e -n "\nPress any key to shutdown the infrared gateway.\n"

read -n 1

# shutdown

/etc/init.d/dnsmasq stop

iptables -t nat -F

echo 0 > /proc/sys/net/ipv4/ip_forward

init 3

ifconfig irda0 down

```

Of course you will need to replace eth0 with your internet interface, if its different.

Now we should be all set up to make the connection.  Run the above script as root, and let it sit at the "Press any key to..." prompt.  Now point the infrared interface on the PDA at the infrared interface on the Linux box, at a distant of a few feet.  Hit the connectivity icon near the start menu and the clock (it should look like two arrows with an X next to them).  Select "37337" or whatever you picked as a number.  If it asks you for a username, password, and domain, just leave it blank and hit OK.  Now it will bring up the "manual dialing terminal" and a pop up saying "Dialing..".  Hide the "Dialing" pop-up, and hit OK in the top right corner of the screen to exit the manual dialing terminal.  Give it a few seconds... hopefully the connectivity icon will change to two solid arrows with no X.

Now you should be connected to the Linux box and the internet (if your Linux box has internet access)!  Open up Internet Explorer and go to www.google.com.  I hope it worked for you!  Now you have infrared internet access on your PDA.  Not only that, you can use it to access your linux box (using the hostname "linuxbox") and transfer files securely using pocketpc versions of scp and ssh.  Of course you can set up an FTP server on the linux box if you want to be able to transfer files without any extra software, and don't care about security.

If it didn't work for you, go back and double check that you followed all of the steps.  Also, check /var/log/messages for ppp errors.  You can add "debug" to the ppp command line to assist in your debugging.  Also, Jean Tourrilhes has a web page (the first link below) with a wealth of information that may be able to help you get going.

References:

http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/IrDA.html

http://www.tuxmobil.org/Infrared-HOWTO/Infrared-HOWTO.html (pretty out of date, unfortunately)

http://gimel.esc.cam.ac.uk/james/resources/toshoboe/

http://dev.gentoo.org/~brix/papers/A920/A920.html

----------

## dec

Great post, thank you very much.  :Smile: 

----------

## dogshu

Cool!  I'm glad it was useful for someone.

FYI, after this I managed to get the PDA to talk to my Samba share.  Unfortunately I couldn't get Samba 3.x to work with Windows Mobile 2003.  Since there's no ebuild for Samba 2.x, I had to download and install Samba 2.2.12 myself.  After that though, it was pretty straightforward to get the PDA talking to Samba.  Here's my smb.conf:

```

[global]

workgroup = DOGSHU

server string = Samba Server

log file = /var/log/smbd.%m

max log size = 50

security = user

wins support = yes

dns proxy = no

encrypt passwords = yes

[homes]

     comment = Home Directories

     browseable = no

     writable = yes

     valid users = %S

[media]

     comment = Media Archive

     path = /media

     read only = yes

     browseable = yes

```

----------

