Nokia Smart Messaging vCard perl script


This perl script translates name, phone number and e-mail information into a format which is understood by many nokia phones (examples include the 5160, 5165, 6160, 6165 and 8260 there's probably others as well). The output of this script can then be e-mailed to your phone if your cellular provider offers that service. For the impatient, I'll provide some links right up front and then go on to explain what they're all about.

Click here to download the perl source code for the program.

Click here to use it online

How to Use This Program

This perl script can be used in three different ways, interactively from the command line, in batch mode from the command line or as a cgi program with a web server.

If you want to run this program from the command line, you will need a perl interpreter and a mailer installed on your computer. Linux machines generally have these things installed without any particular worry. Windows machines will probably need to have these things installed. You can get perl for windows from here and you can get a mailer from here.

Once you've done that, you can run this program from the command line. Use the command perl vcard.pl -? to find out what all your options are. You can also specify some of the parameters in the script itself to save yourself a little bit of typing. To do this, open vcard.pl in a text editor (notepad in Windows or vi or pico in Linux) and change the lines that start with $SENDMAIL $MAILHOST $FROM and $TO as appropriate for your system.

If you want to use the program in batch mode to send a large number of contacts to your phone at once you will need to create a text file with a list of your contacts. In between the Name and Phone number and again between the phone number and e-mail address press the tab key.The file should look something like this (with [tab] representing what you get when you press the tab key):

John Doe[tab]3215551212[tab]john@doe.net
Jane Doe[tab]4565551212[tab]jane@doe.com
Jill Doe[tab]8885551212[tab]jill@doe.org

In the event that you are running this script on a machine with personal firewall software like McAfee you'll need to specify that blat.exe is to be allowed access to the internet. You might need to add blat.exe to a registry entry similar to this key:

HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\On Access Scanner\BehaviourBlocking\PortBlockWhiteList_0

Or that's what Brad tells me anyway. I've never used McAfee personal firewall myself.

The final way to use this program is as a cgi script for a web server. To do this, you will need access to a machine that is running webserver software that you have access to the cgi-bin directory on. All you need to do then is copy vcard.pl into the cgi-bin directory and call it from your web browser. Alternately, you can just use it from this server by clicking here.

How this all works

The exact formats of different messages can be found in the document stdma_sm.pdf which you can download from the nokia smart messaging page . To actually download anything you need to give them an e-mail address and click on a disclaimer, so I can't link directly to the file. There are also a lot of other very good documents on that page.

For the purpose of providing some sort of answer to your question, the thing that you are most likely to want to do is send names and numbers from your PC to your phone. The format used is basically equivalent to vCard with ASCII armor and some extra headers. Your business card messages will start with the header segment

//SCKL23F4wwwwxxyyzz

where //SCKL signals the beginning of Smart Messaging data, wwww signals the origination port (doesn't matter what you use as long as it's a 4 digit hex number and it's the same for all parts of your message), 23F4 is the port on which the vCard receiver listens, xx is a reference number which must be common to all parts of your message, yy is the total number of parts in the message and zz is the sequence number.

As an example we'll say that you want to send to your phone a number for somone named AAA whose number is 1234567890. The vCard will look like this:

BEGIN:VCARD
N:AAA
TEL:1234567890
END:VCARD

This has to be converted to ASCIIhex to be sent to the phone, to the vCard data turns into:

424547494E3A56434152440D0A4E3A4141410D0A54454C3A313233343536373839300D0A454E443A56434152440D0A

Now we can split this into two separate SMS messages so that it can be sent to the phone. They're going to look like this:

//SCKL23F423F4990201 424547494E3A56434152440D0A4E3A4141410D0A54454C3A31
and
//SCKL23F423F4990202 3233343536373839300D0A454E443A56434152440D0A

Update: 11/2004

It seems that some phones fancier than my ancient 8260 have support for more than one phone number and one e-mail address per address book entry. In this case you could extend the code to provide entries similar to this:

TEL;TYPE=cell,pref:1234567890
TEL;TYPE=work:1231231234
EMAIL;TYPE=internet,pref:address@some.com
EMAIL;TYPE=internet:address@other.com

The full details of how vcards should be constructed can be found in RFC 2426. The actual subset of that specification that are supported by various different phone models will probably vary by phone model. If you have any particular knowledge you would like posted to this web page let me know and I'll get it added here.

If you have any questions, comments or complaints feel free to e-mail the authors.