Michal Čihař - Archive for July 22, 2008

Synchronizace s mobilem - konečně

Už dlouho na mém seznamu úkolů hnije synchronizace mezi telefonem (Sony-Ericsson K750i) a nějakou rozumnou PIM aplikací v Linuxu (protože používám GNOME, tak jako cesta nejmenšího odporu se jeví Evolution). Už jsem se o to pokoušel několikrát, ale zatím to nikdy nefungovalo. Dneska (když už bylo venku tak jak bylo) jsem tomu věnoval opět nějaký čas a tentokrát jsem uspěl na první pokus :-).

Než jsem s čímkoliv začal, zazálohoval jsem si všechno z telefonu. Gammu to zvládne v pohodě a čemu jinému bych měl věřit než nástroji, který jsem si sám napsal?

 gammu backup /tmp/phonebook.vcf
gammu backup /tmp/calendar.vcs

A teď už je na čase si hrát s OpenSyncem . Pro tyto účely se může hodit setup guide a SyncML guide . Protože jsem dřív míval problémy s oběmi konci synchronizace - jak telefon tak Evolution končily s nějakou chybou, rozhodl jsem se na to jít tentokrát pomalu a začít se synchronizací z telefonu do souborů:

 msynctool --addgroup file2phone
msynctool --addmember file2phone file-sync
msynctool --addmember file2phone syncml-obex-client

Teď už jenom nastavit ukládání souborů:

 msynctool --configure file2phone 1

A nastavit cestu, kam se mají data ukládat:

 <?xml version="1.0"?>
<config>
  <!-- directory path for file-sync -->
  <path>/home/foo/phone-backup/</path>

  <!-- should care of subdirectories (TRUE or FALSE) -->
  <recursive>FALSE</recursive>
</config>

Tím máme jednoduchou část za sebou a potřebujeme nastavit připojení k telefonu:

 msynctool --configure file2phone 2

Naštěstí můžeme použít příklad z SyncML guide , jen stačí přidat Bluetooth adresu (dá se zjistit pomocí hcitool scan ) a kanál ( sdptool browse 00:b0:0b:fa:ce:00 ):

 <?xml version="1.0"?>
<config>
  <bluetooth_address>00:b0:0b:fa:ce:00</bluetooth_address>
  <bluetooth_channel>7</bluetooth_channel>
  <identifier>Sony Ericss</identifier>
  <version>1</version>
  <wbxml>1</wbxml>
  <username></username>
  <password></password>
  <type>2</type>
  <usestringtable>0</usestringtable>
  <onlyreplace>0</onlyreplace>
  <onlyLocaltime>0</onlyLocaltime>
  <recvLimit>0</recvLimit>
  <maxObjSize>0</maxObjSize>
  <contact_db>Contacts</contact_db>
  <calendar_db>Agenda</calendar_db>
  <note_db>Notes</note_db>
</config>

A teď už by měla fungovat synchronizace kontaktů z telefonu do vybraného adresáře:

 msynctool --sync file2phone

Když už toto funguje, stačí přidat Evolution a mělo by být hotovo. Vytváření synchronizační skupiny je stejné, jen se použije jiný plugin. Synchronizaci s Evolution většinou není potřeba nijak nastavovat, výchozí hodnoty jsou rozumné (použije se jediná databáze, kterou Evolution automaticky vytvořila):

 msynctool --addgroup phone2evo
msynctool --addmember phone2evo evo2-sync
msynctool --addmember phone2evo syncml-obex-client
msynctool --configure phone2evo 1
msynctool --configure phone2evo 2

Ale ještě pořád není vyhráno - telefony Sony-Ericsson phones většinou mají rozbité cosi v synchronizaci poznámek (nebo to je možná rozbité v OpenSync, ale vyjde to nastejno, prostě bez tohoto kroku synchronizace neprojde) a je potřeba vypnout jejich synchronizaci. To můžeme udělat změněním filtrů ve vytvořené synchronizační skupině (filtr je v souboru ~/.opensync-0.22/group2/filter.conf ):

 <?xml version="1.0"?>
<filter>
  <note/>
</filter>

A teď už konečně můžeme zkusit synchronizaci a mělo by to fungovat:

 msynctool --sync phone2evo

Pokud chcete o trochu víc klikat, dá se to samé udělat pomocí GUI multisync0.90 , ale stejně nakonec skončíte u editování XML souborů :-).

Phone synchronisation, finally

One of long standing things on my todo list was to make synchronisation work from my cell phone (Sony-Ericsson K750i) to some PIM application on Linux side (as a GNOME user Evolution is the natural choice). I tried it several times but it never actually worked. Today I gave it yet another try and I finally succeeded on first attempt :-).

As a first step I just wanted to make a backup of all things. Gammu can do it quite well and it's the tool I trust for this purpose:

gammu backup /tmp/phonebook.vcf
gammu backup /tmp/calendar.vcs

Now it's time to play with OpenSync. We will use setup guide and SyncML guide as a starting point. As I had in past problems with both sides - both phone and Evolution failed with some random errors, I wanted to go step by step. So I started with setting up phone to files synchronisation:

msynctool --addgroup file2phone
msynctool --addmember file2phone file-sync
msynctool --addmember file2phone syncml-obex-client

Now we need to configure file storage, just tell it where it should store the data:

msynctool --configure file2phone 1

And change path in your editor to something like:

<?xml version="1.0"?>
<config>
  <!-- directory path for file-sync -->
  <path>/home/foo/phone-backup/</path>

  <!-- should care of subdirectories (TRUE or FALSE) -->
  <recursive>FALSE</recursive>
</config>

Now the more tricky part comes, we need to set up phone end:

msynctool --configure file2phone 2

Fortunately we can use example from the SyncML guide and just fill in Bluetooth address (you can get it using hcitool scan) and channel (sdptool browse 00:b0:0b:fa:ce:00):

<?xml version="1.0"?>
<config>
  <bluetooth_address>00:b0:0b:fa:ce:00</bluetooth_address>
  <bluetooth_channel>7</bluetooth_channel>
  <identifier>Sony Ericss</identifier>
  <version>1</version>
  <wbxml>1</wbxml>
  <username></username>
  <password></password>
  <type>2</type>
  <usestringtable>0</usestringtable>
  <onlyreplace>0</onlyreplace>
  <onlyLocaltime>0</onlyLocaltime>
  <recvLimit>0</recvLimit>
  <maxObjSize>0</maxObjSize>
  <contact_db>Contacts</contact_db>
  <calendar_db>Agenda</calendar_db>
  <note_db>Notes</note_db>
</config>

And now we should be able to synchronise whole phonebook from phone to selected directory:

msynctool --sync file2phone

Okay, this works, let's try more complicated thing - include Evolution in the chain. The steps are the same, config file for phone is the same, Evolution plugin has sane defaults you usually don't have to touch:

msynctool --addgroup phone2evo
msynctool --addmember phone2evo evo2-sync
msynctool --addmember phone2evo syncml-obex-client
msynctool --configure phone2evo 1
msynctool --configure phone2evo 2

But now comes the tricky thing - Sony-Ericsson phones usually have something broken around notes (or it is broken in OpenSync, I don't care, simply synchronisation fails without this step) and we have to avoid synchronisation of them. This can be done by changing filter file in group we've created above (usually in file ~/.opensync-0.22/group2/filter.conf):

<?xml version="1.0"?>
<filter>
  <note/>
</filter>

And finally we can start the synchronisation and it should work:

msynctool --sync phone2evo

You can also GUI multisync0.90 to do the configuration and start synchronisation, but it is not much different, you also still have to edit XML files.

Wammu 0.28

I just released version 0.28 of Wammu. This release fixes various problems found by users. Full list of changes:

  • Fixed freeze while searching for Bluetooth devices.
  • Fixed guided configuration of Bluetooth devices (no more complains about not existing device).
  • Fixed saving of backups to folder with non ASCII names.
  • Validation is less strict and allows hopefully all number.

This release also comes with binary for Windows with embedded Gammu 1.20.0.