Auto Exporting Personal Wiki as PDF and Sending to Bluetooth Device in Linux

galaxy_ace_2_bluetooth

I have a lot of information, reminders and so forth on my personal Wiki (Mediawiki). At first I was thinking of installing Mediawiki on my Android Phone and keeping the two Wiki’s synced, but this is not practical on Android. I found the Pdf-Book extension for Mediawiki and set a cron job to export my entire Wiki to a PDF book every day. Really nice extension. It creates a TOC that links to each exported page in a single document. Polaris Office 4.0 on Android is capable of using TOC PDF links. Here is the anacron line.

1 15 barneypedia-export wget -O /home/djbarney/DJ_Barney_Docs/Backup/Phone_Sync/barneypedia.pdf /
"http://192.168.1.5/wiki/index.php?title=Category:Pdf-export&action=pdfbook"

So I have that writing to a file every day. The following shows how to use the command line to send this file via Bluetooth to my device, which I’ll add to the anacron line.

Install bluez-tools

sudo apt-get install bluez-tools

Find out the MAC address of the device using bt-device. For some reason I could not get hcitool (part of the bluez package) to scan for devices.

$ bt-device -l
 Added devices:
 GT-I8160 (78:52:1A:B4:65:AC)

Test the connection using l2ping (bluez package). I had to use sudo here. I think I’m supposed to put myself in some kind of group but I don’t think it matters too much at the moment.

$ sudo l2ping 78:52:1A:B4:65:AC
 Ping: 78:52:1A:B4:65:AC from 00:15:83:15:A3:10 (data size 44) ...
 44 bytes from 78:52:1A:B4:65:AC id 0 time 8.85ms
 44 bytes from 78:52:1A:B4:65:AC id 1 time 7.83ms
 44 bytes from 78:52:1A:B4:65:AC id 2 time 24.87ms
 44 bytes from 78:52:1A:B4:65:AC id 3 time 10.84ms
 44 bytes from 78:52:1A:B4:65:AC id 4 time 18.84ms
 44 bytes from 78:52:1A:B4:65:AC id 5 time 12.86ms
 44 bytes from 78:52:1A:B4:65:AC id 6 time 24.85ms
 44 bytes from 78:52:1A:B4:65:AC id 7 time 10.90ms
 44 bytes from 78:52:1A:B4:65:AC id 8 time 7.73ms
 44 bytes from 78:52:1A:B4:65:AC id 9 time 11.90ms
 44 bytes from 78:52:1A:B4:65:AC id 10 time 11.88ms
 11 sent, 11 received, 0% loss

Then use sdptool (bluez package) to find the Bluetooth channel we need to send the file on.

sudo sdptool browse 00:16:CF:DC:B9:81

You’ll see lots of information. You only need this section. Notice the channel number.

Service Name: OBEX Object Push
Service RecHandle: 0x10004
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Now we need to bind the device using rfcomm (bluez package).

sudo rfcomm bind /dev/rfcomm0 78:52:1A:B4:65:AC 12

Now you can send a file to the device using ussp-push (ussp-push package).

sudo ussp-push /dev/rfcomm0 DJ_Barney_Docs/Backup/Phone_Sync/barneypedia.pdf barneypedia.pdf

That’s it ! Now I can take my valuable Wiki information where ever I go.

By the way, I originally started investigating this issue using the MATE Bluetooth applet. Originally I could only send files via Bluetooth but not receive. That was fixed by whatever libraries installed or updated when installing the utilities above. But OBEX file browsing has never worked.

mate-obex-browse

This apparently is due to a current problem in MATE. However, even though I seem to remember being able to do this before, bt-device shows this.

$ bt-device -i GT-I8160
[78:52:1A:B4:65:AC]
  Name: GT-I8160
  Alias: GT-I8160 [rw]
  Address: 78:52:1A:B4:65:AC
  Icon: phone
  Class: 0x5a020c
  Paired: 1
  Trusted: 0 [rw]
  Blocked: 0 [rw]
  Connected: 0
  UUIDs: [OBEXObjectPush, AudioSource, AVRemoteControlTarget, HeadsetAudioGateway,/
 NAP, HandsfreeAudioGateway, PhoneBookAccess, 00001132-0000-1000-8000-00805f9b34fb, PnPInformation]

OBEX push but no OBEX FTP ! Ha, that must have been on my previous Nokia phone. But apparently MATE do have some kind of problem with this anyway. Maybe this blog post can help them test with these commands.

Reference documents

  1. How to run Bluez
  2. How to use OBEX
  3. How to use OBEX: ussp-push
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s