The K-Zone: Some notes on using Linux with the Nokia 6310i

This article gives some general hints on using the Nokia 6310i GSM phone with Linux. Some parts of it may apply to other, similar Nokia phones, and a few may apply to other GSM phones from other vendors.

Background

I have to come clean about this: I don't know a huge amount about mobile phones. I appreciate that there is a whole popular culture attached to them, and I appreciate that they can be very useful, but I don't really understand them. In fact, I don't understand any part of them. However, since I have to have one, I'd like to be able to get it to work with my Linux-based laptops. OK, so mobile phones come with software, but it's generally for Windows so I'm not going to be able to use it without a load of hassle. I'm much more interested in getting my phone to work with Linux. The phone I have is a Nokia 6310i, which is a fairly modern model. It has all sorts of clever features, including a built-in data modem, so it should be quite useful in conjunction with a laptop. I understand that, as a GSM phone, a lot of what it does is in common with other GSM phones from other vendors. However, there is quite a lot that is vendor-specific and, indeed, model specific, as we shall see.
      What do I want to do? Well, I'd like to be able to use the phone as a modem for making data calls. I'd like to be able to upload and download phonebook entries between the laptop and the phone. I'd like to be able to modify the display logos and the ringtones. Most of all I'd like to be able to use the phone to get Internet access for the laptop. Most of these things have proved to be possible, with a bit of work.
      Ultimately the phone appears to the computer as a modem, that is, it is a serial device that understands `AT' modem commands. The easiest way to get started is to physically wire the phone to a computer's serial port using a cable; a suitable cable costs about £30. No special set-up is required: the phone does not need to be told that there is a serial cable attached, and it auto-detects baud rate, etc. The principle is not significantly different if you use bluetooth or infra-red connection. The phone is still seen by the communications software as a serial device, and still responds to the same `AT' command set. However, there are things to set up on the phone, and a raft of additional software to get working on the computer, so it may not be worth the effort. Bluetooth support is fairly new in Linux (it appears in the stock kernel from version 2.4.19) and, given my recent struggles to get ordinary wireless networking to work properly, it seemed safer to let it mature a bit. IRDA infra-red is a long-established technology, but many laptops don't have an infra-red port these days (mine don't).
      With a serial cable attached, you should be able to use a serial terminal emulator (such as Minicom) to talk to the phone. For example, the command ATI should give a brief information report, and ATDT NNNN should dial number NNNN. In fact, to make `ordinary' (e.g., non-Internet) data calls, the phone, cable, and Minicom should be all you need.
      The other computer-integration features of the phone are obtained through vendor-specific AT commands. In fact, some of these are standardised across the GSM industry, so they aren't truly vendor specific. For example, most GSM phones support the command AT+CPBR to retrieve phonebook entries. However, the features for uploading logos and ringtones are less likely to work the same from one phone to another. If you browse around the Forum Nokia Web site (not the main Nokia site), you should be able to find a document listing the AT commands and extended AT commands that Nokia GSM phones accept. If you have this document, and you know how to program your computer's serial ports, then in principle you have all you need to be able to write applications that interface with the phone. In practice, a lot of this software exists already, so this may not be necessary.

Internet access

You can use SLIP and PPP through the phone to get Internet access. Connection speeds are unlikely to be very good by modern standards, but adequate for e-mail. In practice, most ISPs support generic PPP, although some support PPP compression extensions as well. Setting up PPP support is a standard Linux operation and, provided the basic serial communication is working between the computer and the phone, it really has nothing to do with the phone at all. On RedHat systems, you can use the neat utility to set up a PPP connection graphically. All you need to know are the ISP's phone number and your user ID and password. Alternatively, more detailed instructions may be found in the Linux PPP package itself (on RedHat, look in /usr/share/doc/ppp-XXX). Things to watch out for are PPP support not being enabled in the kernel (if you haven't got a file called ppp_generic somewhere under the /lib/modules directory that's likely to be the case) and not having module aliases for the particular line disciplines in modules.conf. For a full set of functionality, you need the following aliases:
alias ppp ppp_generic
alias tty-ldisc-3 ppp_async
alias tty-ldisc-14 ppp_synctty
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate 
If you have compiled your own kernel you may need to reconfigure and recompile to get these modules (ppp_async, etc.) built but, if you have a standard commercial Linux distribution, they're probably in place already.
      If you've configured with neat or the like, you can probably start-up the PPP session by doing /sbin/ifup ppp0. Look in /var/log/messages if it doesn't work, and check that you're seeing the `D' (for `data') icon in the phone's display when the call is placed.

Phonebook, etc

The phone maintains a number of different phonebooks, that is, lists of name-number mappings. If you aren't familiar with mobile phone technology, this in itself is a problem, as the names of these phonebooks are non-obvious. However, the most common places to store phone numbers are in the memory of the phone itself (the `ME' book), and in the SIM card (the `SM' book). These books are totally separate in so far as communication with the computer is concerned.
      Like most GSM phones, the 6310i uses extended AT commands to manipulate the phonebook. For example, to get entry #1 from the current phonebook, we can issue the command
AT+CPBR=1
A potential problem with this is that the `current' phonebook might not be where the entry you want is stored. If this is the case, then you'll need to select the current phonebook before issuing the command. The default is to read the SIM card phonebook; to select the phone's internal memory, do
AT+CPBS="ME"
The phonebook procedures are all described (tersely, but adequately) in the Nokia AT command documentation. This is all very well if you want to develop some software yourself, but if you just want to synchronise phonebooks it may be better to seek some existing software. There are two main software packages available for Linux: Gnokii, and gsmlib. Gnokii is described below; for simple reading and writing of phonebooks gsmlib is probably quicker.
      gsmlib is actually a project to develop a client library to support applications that communicate with GSM phones. However, the package comes with a number of useful utilities, one of which is gsmpb. gsmpb copies a phonebook from a file to the phone or vice versa. For example, to download the phone's internal phonebook to a file called phonebook.txt:
gsmbp -V -y -d phonebook.txt -s /dev/phone -p me
This assumes that /dev/phone is a link to the real device entry for the phone (e.g., to /dev/ttyS0).
      The gsmpb phonebook file format is intended to be human-readable, and simply consists of a name and a number on each line. For me, this is a perfectly adequate way to store my phone numbers on my laptop. If you want to synchronise to some other contact manager software, e.g., gnomecard, then you'll need to write some code (perhaps a Perl script) to reconcile the contact manager's data file with the file retrieved from the phone. There may well be software around to do this, of course.
      One limitation of the gsmpb utility is that it does not seem to support multiple numbers attached to one name. The phone does support this; for example, a person can be assigned a fixed and a mobile number. gsmpb sends and retrieves only the first number in each entry.
      The 6310i also supports a rudimentary calendar, in which events can be attached to certain days. The AT commands required to manipulate the calendar are undocumented, but may be supported by Gnokii for some phone models.

Logo management

The technicalities of uploading logos to the phone are surprisingly complex. Logos are sent as multiple SMS text messages, in `Smart Message' format. This means in essence that the logo data is broken up into pieces small enough to fit into an SMS message (e.g., 140 bytes) and then multiple messages are send. Each SMS message contains a data header which defines the `port' to which the message is to be send, and contains a sequence number so that the messages can be reassembled in the phone. Extended AT commands are used to upload the SMS fragments to the phone's message store, where the appropriate `port' number identifies them as a logo. The data format is sufficiently complex and ugly that I don't intend to describe it even in outline, because Gnokii handles logo uploads perfectly well.
      The Nokia phones can assign graphical logos to a number of different displays. The most common one to change is the `operator' logo, because it is visible most of the time. This logo is supposed to identify the mobile network operator but, as most people don't change network all that much, this logo is usually a permanent backdrop.
      Nokia operator logos are 72x14 pixels in size, and must be fully monochrome. That is, a pixel is either black or white, and there's nothing in between. The format of the data that must be uploaded to the phone is called (by Nokia) `NGG'. This format does allow for multi-colour or greyscale images, but most phones don't support them.
      There are a number of commercial organisations that specialise in the supply of operator logos to mobile phones using SMS. They charge between 50p and £3.00 to do this. If you have computer connectivity to the phone, you can do it free of charge using a graphics program (e.g., Gimp), Gnokii, and a script called ppm2nokia to generate the NGG file. ppm2nokia was posted to the Gnokii mailing list, and is widely available (give me a call if you can't find it).
      Gnokii is a general GSM phone interface program with a nice graphical user interface (as well as an ugly, but fast, command-line interface). Depending on the model of phone it can send, receive and view SMS messages, upload logos and ringtones, and manage calendar entries. Gnokii is available in RPM format for some Linux distributions, but it's straightforward to build it from source.
      Start by creating your logo as a black-and-white image 72 pixels wide by 14 pixels high. This is straightforward using Gimp. Save the image as a PPM file, then convert it to NGG format:
ppm2nokia < logo.ppm > logo.ngg
Then use Gnokii to upload it to the phone:
gnokii --setlogo op logo.ngg
And that's all there is to it. You can create and upload caller group logos the same way.

Ringtones

Gnokii provides facilities to upload ringtones in `RTTTL' format. However, I have been unable to get this to work with the 6310i. I don't know as yet whether this is a trivial configuration matter, or whether this phone manages ringtones in a completely different way to other Nokia models.

Java support

The 6310i has support for Java J2ME `midlets' but, as far as I know, there is no way to upload these to the phone using Linux. Nor does Nokia's Java emulator run on anything except Windows. Developing Java applications looks like being a Windows job for now, sadly. However, it ought to be possible to develop a J2ME application using a generic J2ME emulator (such as Sun's Wireless Toolkit), and then transfer the code to th 6310i over the air. You'd need a suitabliy-equipped web site, and it would probably be expensive to do extensive testing this way, but it could be done.

Summary

Linux support for the Nokia 6310i allows it to be used for making data calls, and for Internet access. It is also possible to upload logos and synchronise phonebooks. So far I have not been able to use Linux software to upload Java midlets or set ringtones.
©1994-2006 Kevin Boone, all rights reserved