Inspired by this photography idea, I picked up a thermal Bluetooth printer from eBay. Specifically, a model DL58. I was impressed with the Chinese company that sold it to me; my request for access to the SDK was immediately and fully met. While I've got big plans for the printer, the first order of business was to get it printing basic text.
I don't really have any experiencing developing with Bluetooth devices, so I wasn't quite sure what I was in for. Thankfully, the device was discovered and paired with my phone without a hitch (pairing PIN: 1234). The first version of the SDK the eBay seller provided had the printing code wrapped up behind a shared native library. When I couldn't get this to work, the eBay seller provided an updated version of the code. This time, I could see that all the system was doing was making a Bluetooth socket connection to the device and sending text over the socket. Well that's easy enough. The printer does handle images too, and those are sent using some sort special binary header. That's something I'll be figuring out soon enough.
I then went to work taking my new found lessons in Bluetooth printing and turning them into a super simple app. I give you: DropPrint. DropPrint watches the directory /sdcard/DropPrint and when new files are discovered it prints them. Right now, DropPrint only understands two types of file: txt and scm files. I plan to also have it support image files, as well as bar code files (store "foo" in foo.qrc, and a qrcode with the contents "foo" get printed).
There's not much to DropPrint, but here's the requisite screenshot:
DropPrint's handling of txt files is obvious enough. But surely you're wondering what a scm file are all about. Well, it is what you think it is: Scheme file handling.
(begin (define (dec x) (- x 1)) (define (fib x) (cond ((= x 0) 1) ((= x 1) 1) (else (+ (fib (dec x)) (fib (dec x)))))) (let loop ((i 0)) (cond ((= i 10) 'done) (else (display i) (display " = ") (display (fib i)) (newline) (loop (+ i 1))))))
A few moments later, the printer spits out the following:
(Beware: it intentionally deletes the files after printing them)
In the bits-and-bytes world I live in, to actually have something physical generated is amazingly cool.
Now that I've got basic printing working, it's time to turn my attention to images. Stay tuned...