Sharing contacts to S30+ phones over SMS

tl;dr

Send a data SMS to port 9204 of the target device with a single vCard akin to this:

BEGIN:VCARD
VERSION:2.1
N;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:;=
Test=20Contact;;;
TEL;VOICE;CELL:+15417543010
END:VCARD

Other vCard format versions appear to work, as long as the same field names are present.

Fields other than name and telephone are dropped, and FN can be used instead of N if necessary.

It doesn't seem to be obligatory to encode the data, which can as well be in raw UTF-8, which is not technically spec-conformant (vCards should be ASCII encoded).

Only one vCard per data SMS is supported. It might be necessary to use UDHs, because even single vCards tend to get fairly wordy and might not fit in a single message.

The long version

There are numerous resources discussing the specifics of transforming regular vCard files into a format understood by S30+ phones. However, they all assume that the data will be transferred over an SD card. There are some S30+ phones which don't support external storage or, indeed, any storage at all.

Since whenever, there has existed a format called vCard. It was originally created for storing contacts, arising from e-mail and actually being excellent for use in old-time phones. So all manner of phones used and continue to use it for exchange of contacts. Actually the S30+ backup format is literally just a concatenated vCard file, with some peculiarities with regard to storage.

Transfer method

Let's try to get back on track. The Nokia 105 mentioned before only supports contact transfer via SMS, which is exactly how it was done before the dawn of smartphones (I actually recall once typing out a vCard in an SMS and sending it -- and that actually came through on the other end successfully). But if you just type out the information and send it, you'll just receive it as a text message and the phone won't recognize that it's a vCard. What's going on?

Apparently the information exchange doesn't occur over plain SMS (if you try sending a contact to a non-Nokia phone, the message just seems to disappear). It's using a sort-of obscure mechanism called Data SMS, which is essentially the same as regular SMS, but the traffic goes over the data connection instead of the voice connection, with the intention of having a sort of a separation of concerns, because these messages are not intended for exchanging short text messages, but instead for services or, as in this case, machine data.

With some trial-and-error, I've determined that the port S30+ phones use for exchange of vCards is 9204.

Transfer format

As mentioned numerous times before, the data format for contact exchange is vCard. From a quick glance at the specification, the particulars of the format seem to be observed well.

The particular vCard version used is 2.1. The specification seems to have fallen off the back of the Internet, but here's an archived version. Other versions of the spec appear to work as well, as long as no other exotic aliases for the name and telephone fields are used.

In particular, the default export format uses a full N field with the respective structure, but only having the "Given Name" part filled out, i.e.:

N;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:;=
Test=20Name;;;

Note that:

As mentioned in the TL;DR, only the name and telephone fields are used, and the rest are dropped. The name field will get truncated to 16 characters, regardless of what the vCard contains.

The phone receives no more than one vCard per message, so you can't transfer whole contact libraries with this method. Well, technically you can, but it takes a bit more work than just concatenating all the files and sending them away.

Update 2018-07

I only now noticed that I didn't mention how I did the transfer!

Okay, I'll be brief but Tasker is great for such things. I wired up a HTTP server on a nearby computer and just manually invoked Tasker to periodically re-fetch the file and send it over via a Data SMS, both of which it supports well.