Saturday, January 19, 2008

Ubuntu Gutsy: Synchronizing Google Calendar with your Nokia phones using opensync on bluetooth


This is a follow up on my older post - Synchronising your calendars with google Calendar, where I described an easy way to sync your phone calendar with your remote google calendar. Quite a lot of folks wanted an alternate way. An ability to sync over bluetooth or usb, when your phone has no access to internet.


Note: This was tested in Gnome using the gnome bluetooth libraries.
For simplicity, let me break down the process into some discrete steps.

StepA: Installing bluetooth libraries

1. Get the gnome-bluetooth library using apt
sudo apt-get install gnome-bluetooth

2. Restart bluetooth
sudo /etc/init.d/bluetooth restart



StepB: Pairing your phone with your laptop

1. Pairing is really really important. Don't proceed to next step without completing this.

2. In your linux pc, check if you can discover your phone
sudo hcitool scan

A six octet number like (00:12:D2:2E:22:1E), which is the MAC address of your phone will be displayed. Note it down somewhere.

3.Change hcid.conf option
sudo gedit /etc/hcid.conf

and replace security user; to security auto;
4. You can also specify a PIN no. if you want

5. Restart bluetooth services

6. Now,In your phone, go to your bluetooth settings > Paired devices. Add a new paired devices (your PC) and set it as authorized. It might prompt you for a PIN if you had specified it earlier.

7. Now verify if the pairing works. (Type this in terminal as normal user)
nautilus obex://

You should now be able to browse your phone.


StepC: Getting the opensync libraries


1.Add following repositories to /etc/apt/sources.list:
sudo /etc/apt/sources.list

and add these lines to the file
deb http://opensync.gforge.punktart.de/repo/opensync-0.21/ feisty main
deb-src http://opensync.gforge.punktart.de/repo/opensync-0.21/ feisty main


2. Add the keys to the repo by typing these in the command line
gpg --keyserver hkp://subkeys.pgp.net/ --recv-keys CB210090B029CB84
gpg --export CB210090B029CB84 | sudo apt-key add -



3. Get the packages using apt
sudo apt-get install opensyncutils opensync-plugin-evolution opensync-plugin-syncml opensync-plugin-google* multisync-tools multisync0.90



StepD: Creating new sync profile on your phone

1. Go to Menu > Connectivity > Sync (depending on your phone)

2. Select Options > New Sync profile. This will create a new sync profile similar to the PC Suite profile.

3. Edit this new sync profile similar to this :

Sync profile name: PC

Applications > Just select Calendar

Connection settings >
Server version: 1.1
Data bearer: bluetooth
Host Address: PC
Username : None
Password: None
Allow Sync requests: Yes
Accept Sync requests: Yes


4. Remember the profile name.


StepE: Finding your Nokia SyncML Server channel number


1. Use the sdptool to discover services and their channel numbers.
sdptool browse | grep more


2.This is what I get.

Service Name: Nokia SyncML Server
Service RecHandle: 0x1000a
Service Class ID List:
UUID 128: 00005601-0000-1000-8000-0002ee000001
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 13
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"" (0x00005601-0000-1000-8000-0002ee000001)
Version: 0x0100



3. Note the channel number, (13 in this case)


StepF: Configuring multisync

1. Launch multisync
multisync0.90


2. Create a new group, say NokiaGCal (click on add)

3. Click on edit and add google-calendar and syncml-obex-client as members to this group. They should be visible if all packages have been installed correctly in previous step.

4. Edit the settings for the google-calenar by replacing USER with your google username and Password with your google account password. (note. there are 2 USER tokens and 1 password token that need to be replaced)

5. Edit the syncml-obex-client settings as follows

<?xml version="1.0"?>
<config>
<!-- (Only for bluetooth) The bluetooth address if the bluetooth mode is selected -->
<bluetooth_address>00:12:D2:2E:22:1E</bluetooth_address>

<!-- (Only for bluetooth) The bluetooth channel to use. `sdptool browse $MAC` to search for the correct channel -->
<bluetooth_channel>13</bluetooth_channel>

<!-- (Only for USB) The usb interface number of the SYNCML-SYNC target. use syncml-obex-client -u (you will need access to the USB raw device) to find it. -->
<interface>0</interface>

<!-- The string that the plugin will use to identify itself. Some devices need a special string here. -->
<identifier>PC</identifier>

<!-- The syncml version to use: 0 for 1.0, 1 for 1.1 and 2 for 1.2 -->
<version>1</version>

<!-- if the plugin should use wbxml -->
<wbxml>1</wbxml>

<!-- The username to use. Leave empty to not require a username -->
<username></username>

<!-- the password for the username -->
<password></password>

<!-- sets the connection type to use. 5 means obex over usb, 2 means obex over bluetooth -->
<type>2</type>

<!-- If wbxml is enabled, defines wether the wbxml should use string tables -->
<usestringtable>0</usestringtable>

<!-- Never send ADD command, but send REPLACE (not needed normally) -->
<onlyreplace>0</onlyreplace>

<!-- Workaround around for mobile phones which only use local timestamps and _no_ UTC timestamps! -->
<onlyLocaltime>0</onlyLocaltime>

<!-- Sets the maximum allowed size in bytes of incoming messages (some device need this option set). Example: 10000 -->
<recvLimit>10000</recvLimit>

<maxObjSize>1000</maxObjSize>

<!-- The name of the contacts db. Must be the same as the phones sends -->
<contact_db></contact_db>

<!-- The name of the calendar db. Must be the same as the phones sends -->
<calendar_db>Calendar</calendar_db>

<!-- The name of the note db. Must be the same as the phones sends -->
<note_db></note_db>
</config>



6. Replace the bluetooth and channel tags with your bluetooth MAC address and channel as discovered in previous steps.


StepG: Finally time to sync


1. Click on refresh against your group to start the sync.

2. If all goes well all your contacts are now syncronized with your google calendar.


Passing Remarks

Phew...Long article. Long process. But this is the basics of syncing a lot of stuff with your phone and other devices. Now you should be able to do an on the fly sync with google calendar using your laptops bluetooth for your phone. You can also sync evolution, sunbird/thunderbird etc contacts and calendar using the relevant plugins
Some other articles to help you..

http://www.ugov.be/wiki/index.php/Ubuntu_with_Nokia_E65
http://ubuntuforums.org/showthread.php?t=260676

6 comments:

Anonymous said...

If "nautilus obex://" dos not work you should do:
sudo aptitude install gnome-vfs-obexftp

Then it should work.

Anoj said...

thanks! forgot to add that

Unknown said...

I am using Ubuntu 8.10 and could not follow your instructions.

StepB:
-----
I did "sudo hcitool scan", and found the MAC address of my phone, but:

* What should I do with it?
* The file hcid.conf does not exist on my machine?

On StepB.5: How do I restart the bluetooth service?

Unknown said...

@ יוסי
the hcid.conf appears to have moved to /etc/bluetoot/hcid.conf in Intrepid

as for restarting the bluetooth service, have a look at Step A, 2.

hope it helps

vak said...

hcid.conf doesn't exist in Ubuntu 10.04 in no package anymore?

I can't get nautilus obex:// working on Ubuntu 10.04

Anoj said...

Hi vak, the post was writter 2.5 years back and 4 Ubuntu iterations ago :) Maybe you can figure an easier way to do this and share with us