493: Undecipherable

-Blog-

-Projects-

-Urlaub-

-About me-

-RSS-

Bringing your contacts to a Nokia 7110

Dennis Guse

I just needed a new phone and decided to go for cool solution: Nokia 7110 (v4.84). I got one including serial data cable + dock and the only thing missing was: how do I get my contacts on the phone without typing?

The answer was quite simply: export your address book as vCard and send it to the phone via gnokii on an Ubuntu.

1 [global]
2 port = /dev/ttyS0
3 model = 7110
4 connection = serial
5 use_locking = yes
6 serial_baudrate = 9600

The Nokia 7110 has a bug: the vCard-parser is broken... So, I needed to fix my addressbook: basically remove all not needed data (emails, addresses, birthdays etc.). I implemented a small python-script using vObject.

It reads from stdin and writes to stdout:

cat addressbook.vcf | python script.py

 1 #!/usr/bin/python
 2 #encoding=UTF-8
 3 
 4 import vobject
 5 import sys
 6 import inspect
 7 
 8 #Remove entries except in list for one vcard.
 9 def vcard3_remove_all_entries_except(vcard):
10    allowedEntries = {'version', 'fn', 'tel', 'categories'}
11    entries_dict = vcard.contents
12    for key in entries_dict.keys():
13        if key not in allowedEntries:
14            del entries_dict[key]
15 
16 importedVCards = vobject.readComponents("".join(sys.stdin.readlines()))
17 try:
18     while (True):
19         vcard = importedVCards.next()
20         vcard3_remove_all_entries_except(vcard)
21         vcard.add('n');
22         try:
23             print(vcard.serialize())
24         except Exception as e:
25             print(e)
26 except StopIteration:
27     None

Sync with style:

cat contacts.vcf | python import.py | gnokii --writephonebook -o --vcard

And a tutorial to clean the Nokia 7110 can be found here.