B.119. SMS()

Sends or receives SMS (Short Message System) messages.
SMS(queue[,options])
Manages the exchange of SMS messages with an SMS-capable telephone or through an SMS service center supporting ETSI ES 201 912[73]SMS protocol on analog or ISDN lines. Because the shell client smsq uses FSK[74]this is unlikely to work over compressed codecs such as GSM.
Options:
a
Act as recipient.
s
Act as transmitter (SMS service center) to communicate with a telephone set.
All send and receive queues are stored in /var/spool/asterisk/sms/: message coming from the service center to the device in sc-me.queue/, the message from the device to the service center in me-sc.queue/. A log is written to /var/log/asterisk/sms.
When connecting as a recipient (a), messages residing in me-sc.queue/ are sent and then deleted; received messages are written to sc-me.queue/ with a timestamp in the filename. When connecting as a transmitter (SMS service center), the reverse is true.
Message files are in the format described below. Absent parameters imply a default:
oa=Originating Address (sender's number)
This contains the complete national direct-dial number, including country code and preceded by the +. For example, +19255554101 would be a valid number.
da=Destination Address (recipient's number)
Again, a complete national direct-dial number with preceding +.
scts=Service Centre Time Stamp (timestamp)
Uses the format YYYY-MM-DD HH:MM:SS
pid=Protocol Identifier (decimal octet value)
dcs=Data coding scheme (decimal octet value)
mr=Message reference (decimal octet value)
ud=Message Text
If characters other than 10, 13, 32-126, 128-255 (decimal) occur in the message, ud= is replaced by ud# and the message contents are coded in hexadecimal.
srr=Status Report Request (0|1)
rp=Return Path (0|1)
vp=Validity Period (minutes)
When sending to an SMSC, only da and ud are used; oa is ignored. When sending to a device, only oa and ud are necessary; da is ignored.
An extension for receiving SMS messages might look like this (where 4165553331 is the number of our SMSC):
[incoming]
exten => _X.,1,GotoIf($["${CALLERIDNUM}" = "4165553331"]?sms-me-in,${EXTEN},1) 
; oder so:
;exten => _X./_0193010.,1,Goto(sms-me-in,${EXTEN},1)

[sms-me-in]
exten => _X.,1,Wait(1)
exten => _X.,n,SMS(me-incoming,a)
exten => _X.,n,System(handleincomingsms)
exten => _X.,n,Hangup()
where handleincomingsms might be a wrapper or command containing, for example, smsq --process=queue --queue=me-incoming which is executed for each incoming message.
Outgoing messages are written to files, but may also be generated with the following (outdated) sequence (4165553331 is the number of the SMSC):
[outgoing]
exten = 4165553331,1,Goto(sms-me-out,${CALLERIDNUM},1)

[sms-me-out]
exten => _X.,1,Set(CDR(accountcode)=SMS)
exten => _X.,n,Set(smsFrom=${CALLERIDNUM})
exten => _X.,n,SMS(${smsFrom},s,${EXTEN},${smsText})  ; Generate SMS
exten => _X.,n,SMS(${smsFrom},s)                       ; Send SMS
exten => _X.,n,Hangup()
Further information and many additional examples may be found at http://www.voip-info.org/wiki/view/Asterisk+cmd+Sms. With the extremely wide variation in SMS implementation, it is best not to expect SMS() to work right "out of the box."

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'SMS' =- 

[Synopsis]
Communicates with SMS service centres and SMS capable analogue phones

[Description]
  SMS(name|[a][s]):  SMS handles exchange of SMS data with a call to/from SMS capabale
phone or SMS PSTN service center. Can send and/or receive SMS messages.
Works to ETSI ES 201 912 compatible with BT SMS PSTN service in UK
Typical usage is to use to handle called from the SMS service centre CLI,
or to set up a call using 'outgoing' or manager interface to connect
service centre to SMS()
name is the name of the queue used in /var/spool/asterisk/sms
Arguments:
 a: answer, i.e. send initial FSK packet.
 s: act as service centre talking to a phone.
Messages are processed as per text file message queues.
smsq (a separate software) is a command to generate message
queues and send messages.
diff output to internal help in Asterisk 1.2:
- none - 


[73] ETSI: European Telecommunications Standards Institute

Frequency Shift Keying