README.sms 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. * The SMS application
  2. ---------------------
  3. SMS() is an application to handles calls to/from text message capable phones and
  4. message centres using ETSI ES 201 912 protocol 1 FSK messaging over analog calls.
  5. Basically it allows sending and receiving of text messages over the PSTN. It is
  6. compatible with BT Text service in the UK and works on ISDN and PSTN lines. It is
  7. designed to connect to an ISDN or zap interface directly and uses FSK so would
  8. probably not work over any sort of compressed link (like a VoIP call using GSM codec).
  9. Typical applications include:-
  10. 1. Connection to a message centre to send text messages - probably initiated via the
  11. manager interface or "outgoing" directory
  12. 2. Connection to an POTS line with an SMS capable phone to send messages - probably
  13. initiated via the manager interface or "outgoing" directory
  14. 3. Acceptance of calls from the message centre (based on CLI) and storage of
  15. received messages
  16. 4. Acceptance of calls from a POTS line with an SMS capable phone and storage of
  17. received messages
  18. * Arguments to sms():
  19. - First argument is queue name
  20. - Second is options:
  21. a: SMS() is to act as the answering side, and so send the initial FSK frame
  22. s: SMS() is to act as a service centre side rather than as terminal equipment
  23. - If a third argument is specified, then SMS does not handle the call at all,
  24. but takes the third argument as a destination number to send an SMS to
  25. - The forth argument onward is a message to be queued to the number in the
  26. third argument. All this does is create the file in the me-sc directory.
  27. If 's' is set then the number is the source
  28. address and the message placed in the sc-me directory.
  29. All text messages are stored in /var/spool/asterisk/sms
  30. A log is recorded in /var/log/asterisk/sms
  31. There are two subdirectories called sc-me.<queuename> holding all
  32. messages from service centre to phone, and me-sc.<queuename> holding all
  33. messages from phone to service centre.
  34. In each directory are messages in files, one per file, using any filename not
  35. starting with a dot.
  36. When connected as a service centre, SMS(s) will send all messages waiting in
  37. the sc-me-<queuename> directory, deleting the files as it goes. Any
  38. received in this mode are placed in the me-sc-<queuename> directory.
  39. When connected as a client, SMS() will send all messages waiting in the
  40. me-sc-<queuename> directory, deleting the files as it goes. Any received in
  41. this mode are placed in the sc-me-<queuename> directory.
  42. Message files created by SMS() use a time stamp/reference based filename.
  43. The format of the sms file is lines that have the form of key=value
  44. Keys are :
  45. oa Originating Address
  46. Telephone number, national number if just digits
  47. Telephone number starting with + then digits for international
  48. Ignored on sending messages to service centre (CLI used)
  49. da Destination Address
  50. Telephone number, national number if just digits
  51. Telephone number starting with + then digits for international
  52. scts Service Centre Time Stamp
  53. In the format YYYY-MM-DD HH:MM:SS
  54. pid Protocol Identifier (decimal octet value)
  55. dcs Data coding scheme (decimal octet value)
  56. mr Message reference (decimal octet value)
  57. ud The message (see escaping below)
  58. srr 0/1 Status Report Request
  59. rp 0/1 Return Path
  60. vp mins validity period
  61. Omitted fields have default values.
  62. Note that there is special format for ud, ud# instead of ud= which is followed
  63. by raw hex (2 characters per octet). This is used in output where characters
  64. other than 10,13,32-126,128-255 are included in the data. In this case a comment (line
  65. starting ;) is added showing the printable characters
  66. When generating files to send to a service centre, only da and ud need be
  67. specified. oa is ignored.
  68. When generating files to send to a phone, only oa and ud need be specified. da is ignored.
  69. When receing a message as a service centre, only the destination address is
  70. sent, so the originating address is set to the callerid.
  71. EXAMPLES
  72. The following are examples of use within the UK using BT Text SMS/landline
  73. service.
  74. This is a context to use with a manager script.
  75. [smsdial]
  76. ; create and send a text message, expects number+message and
  77. ; connect to 17094009
  78. exten => _X.,1,SMS(${CALLERIDNUM},,${EXTEN},${CALLERIDNAME})
  79. exten => _X.,n,SMS(${CALLERIDNUM})
  80. exten => _X.,n,Hangup
  81. The script sends
  82. action: originate
  83. callerid: message <from>
  84. exten: to
  85. channel: Local/17094009
  86. context: smsdial
  87. priority: 1
  88. You put the message as the name of the caller ID (messy, I know), the
  89. originating number and hence queue name as the number of the caller ID and the
  90. exten as the number to which the sms is to be sent. The context uses SMS to
  91. create the message in the queue and then SMS to communicate iwth 17094009 to
  92. actually send the message.
  93. Note that the 9 on the end of 17094009 is the sub address 9 meaning no sub
  94. address (BT specific). If a different digit is used then that is the sub
  95. address for the sending message source address (appended to the outgoing CLI
  96. by BT).
  97. For incoming calls you can use a context like this :-
  98. [incoming]
  99. exten => _XXXXXX/_8005875290,1,SMS(${EXTEN:3},a)
  100. exten => _XXXXXX/_8005875290,n,System(/usr/lib/asterisk/smsin ${EXTEN:3})
  101. exten => _XXXXXX/_80058752[0-8]0,1,SMS(${EXTEN:3}${CALLERIDNUM:8:1},a)
  102. exten => _XXXXXX/_80058752[0-8]0,n,System(/usr/lib/asterisk/smsin ${EXTEN>:3}${CALLERIDNUM:8:1})
  103. exten => _XXXXXX/_80058752[0-8]0,n,Hangup
  104. In this case the called number we get from BT is 6 digits (XXXXXX) and we are
  105. using the last 3 digits as the queue name.
  106. Priority 1 causes the SMS to be received and processed for the incoming call.
  107. It is from 080058752X0. The two versions handle the queue name as 3 digits (no
  108. sub address) or 4 digits (with sub address). In both cases, after the call a
  109. script (smsin) is run - this is optional, but is useful to actually processed
  110. the received queued SMS. In our case we email them based on the target number.
  111. Priority 3 hangs up.
  112. If using the CAPI drivers they send the right CLI and so the _800... would be
  113. _0800...