I am trying to get my SMS gateway to send SMS using AT commands. I am connecting via SSH i a command prompt. I am a beginner to this, so please bear over with me. The following lines work:
DEV=/dev/ttyACM1
DESTNUM="PHONENUMER"
SMS="Test SMS from ø"
echo -e "ATZ\r" >$DEV
echo -e "AT+CMGF=1\r" >$DEV
echo -e "AT+CMGS=\"$DESTNUM\"\r" >$DEV
echo -e "$SMS\x1A" >$DEV
So the above sends the sms correctly, but it does not include the dansih letter "ø". Usually this is included in UTF-8.
How do I get my code working with the danish characters? Any ideas?
By default, short messages are sent using GSM aplhabet (03.38), defined by 3GPP TS 23.038. This setting can be changed by issuing AT+CSMP
command (Set Text Mode Parameters - I'll not examine it in depth in this answer).
More specifically, 7-bits aplhabet is used, so that the device can encode 8 characters in 7 bytes (8x7=56), saving "precious space" to send some more information.
This alphabet is a clever derivation from 7-bit ASCII. A set of codes used in ASCII for "useless" characters (especially control characters) are instead used to add specific characters from alphabet such as Danish:
Danish Character | GSM 03.38 code |
---|---|
Ø | \x0B |
ø | \x0C |
Å | \x0D |
å | \x0F |
Æ | \x1C |
æ | \x1D |
For this reason, all you need is to write a special routine converting specific Danish characters into the corresponding escape code.