2006-12-09 Sending Pictures from the Treo 650 with Bluetooth
I've just taken another step towards bluetooth mastery - I can now send files from my phone to my computer.
My phone has this crappy 640x480 camera built into it. It's not a feature I cared about when I bought it, but because the phone is always with me, I've ended up using it quite a bit, and I now have 81 pictures and 5 short movies on it. I've wanted to transfer these to my computer, but the only way to do so is to send them via Verizon's picture email service at a cost of 25 cents a picture. Now I don't think I'm especially cheap, but I can't see paying 25 cents to upload a single, low resolution image to my computer. Especially when I'm paying $45/month for "unlimited data" and the phone sports USB, infra-red and bluetooth interfaces. Got to be a better way.
So first off, I got a one gig memory card for the phone. I found one on sale at Radio Shack for $40. I need to transfer the pictures to the memory card because the built-in camera software doesn't let me send pictures over bluetooth from the phone's memory (you can send other things, just not pictures). Furthermore, pictures don't appear to be stored as normal PalmOS databases - I'm not sure where they hide them - so I can't copy them using any other means. With the memory card, I can copy the pictures to the card where they show up as normal files (jpegs and mpegs) and use FileZ (a handy file manager) to send them over bluetooth.
The second obstacle was getting to where I could receive files on my computer. I did some research and discovered that the protocol by which files are sent from a phone is called "OBEX" (object exchange). Debian's package manager lists an "obexserver" that claims to accept files sent via OBEX and place them in /tmp. I tried this first, following the instructions in the manpage and couldn't get it to work. It is a very opaque piece of software - no command line options, no debug output - so I had no way of debugging what was going wrong. So I did some more digging.
The breakthrough came when I found the obexpush package. It includes a tool similar to obexserver only with command line options and debug output. I discovered that it wouldn't bind to bluetooth channel 1, which led me to try bringing down the "dund" server (which I keep bound to channel 1 to allow me to hot-sync) and after that it worked like a charm! I can now receive files over channel 1 (obexserver might work with dund down, I haven't tried it). Now I just need to set up something to allow me to bring up either dund or the OBEX server depending on whether I'm hot-syncing or pushing files.
I'm still looking for a good, in-depth technical discussion on the details of the bluetooth stack. As it stands, I'm building the concepts by experimenting with the tools, and this is just taking too long.