~damg/ubuntu/quantal/asterisk/LP1097687

« back to all changes in this revision

Viewing changes to doc/tex/asterisk/node256.html

  • Committer: Bazaar Package Importer
  • Author(s): Lorenzo De Liso
  • Date: 2010-10-15 22:24:34 UTC
  • mfrom: (1.2.8 upstream) (8.3.8 sid)
  • Revision ID: james.westby@ubuntu.com-20101015222434-iy328q8in3lajzlv
Tags: 1:1.6.2.9-2ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control:
    + Build-depend on hardening-wrapper
    + Change Maintainer
    + Removed Uploaders field.
    + Removed Debian Vcs-Svn entry and replaced with ubuntu-voip Vcs-Bzr,
      to reflect divergence in packages.
  - debian/rules: Make use of hardening-wrapper
  - debian/asterisk.init: chown /dev/dahdi
  - debian/backports/hardy: add file
  - debian/backports/asterisk.init.hardy: add file
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8
8
<HTML>
9
9
<HEAD>
10
 
<TITLE>File formats</TITLE>
11
 
<META NAME="description" CONTENT="File formats">
 
10
<TITLE>Using smsq</TITLE>
 
11
<META NAME="description" CONTENT="Using smsq">
12
12
<META NAME="keywords" CONTENT="asterisk">
13
13
<META NAME="resource-type" CONTENT="document">
14
14
<META NAME="distribution" CONTENT="global">
20
20
 
21
21
<LINK REL="next" HREF="node257.html">
22
22
<LINK REL="previous" HREF="node255.html">
23
 
<LINK REL="up" HREF="node248.html">
 
23
<LINK REL="up" HREF="node249.html">
24
24
<LINK REL="next" HREF="node257.html">
25
25
</HEAD>
26
26
 
27
27
<BODY >
28
28
 
29
29
<DIV CLASS="navigation"><!--Navigation Panel-->
30
 
<A NAME="tex2html4004"
 
30
<A NAME="tex2html4007"
31
31
  HREF="node257.html">
32
32
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
33
33
 SRC="/usr/share/latex2html/icons/next.png"></A> 
34
 
<A NAME="tex2html4000"
35
 
  HREF="node248.html">
 
34
<A NAME="tex2html4003"
 
35
  HREF="node249.html">
36
36
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
37
37
 SRC="/usr/share/latex2html/icons/up.png"></A> 
38
 
<A NAME="tex2html3994"
 
38
<A NAME="tex2html3997"
39
39
  HREF="node255.html">
40
40
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
41
41
 SRC="/usr/share/latex2html/icons/prev.png"></A> 
42
 
<A NAME="tex2html4002"
 
42
<A NAME="tex2html4005"
43
43
  HREF="node1.html">
44
44
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
45
45
 SRC="/usr/share/latex2html/icons/contents.png"></A>  
46
46
<BR>
47
 
<B> Next:</B> <A NAME="tex2html4005"
48
 
  HREF="node257.html">Delivery reports</A>
49
 
<B> Up:</B> <A NAME="tex2html4001"
50
 
  HREF="node248.html">SMS</A>
51
 
<B> Previous:</B> <A NAME="tex2html3995"
52
 
  HREF="node255.html">Using smsq</A>
53
 
 &nbsp; <B>  <A NAME="tex2html4003"
 
47
<B> Next:</B> <A NAME="tex2html4008"
 
48
  HREF="node257.html">File formats</A>
 
49
<B> Up:</B> <A NAME="tex2html4004"
 
50
  HREF="node249.html">SMS</A>
 
51
<B> Previous:</B> <A NAME="tex2html3998"
 
52
  HREF="node255.html">extensions.conf</A>
 
53
 &nbsp; <B>  <A NAME="tex2html4006"
54
54
  HREF="node1.html">Contents</A></B> 
55
55
<BR>
56
56
<BR></DIV>
57
57
<!--End of Navigation Panel-->
58
58
 
59
 
<H1><A NAME="SECTION001380000000000000000">
60
 
File formats</A>
 
59
<H1><A NAME="SECTION001370000000000000000">
 
60
Using smsq</A>
61
61
</H1>
62
62
 
63
63
<P>
64
 
By default all queues are held in a director /var/spool/asterisk/sms.
65
 
   Within this directory are sub directories mtrx, mttx, morx, motx which
66
 
   hold the received messages and the messages ready to send. Also,
67
 
   /var/log/asterisk/sms is a log file of all messages handled.
68
 
 
69
 
<P>
70
 
The file name in each queue directory starts with the queue parameter
71
 
   to SMS which is normally the CLI used for an outgoing message or the
72
 
   called number on an incoming message, and may have -X (X being sub
73
 
   address) appended. If no queue ID is known, then 0 is used by smsq by
74
 
   default. After this is a dot, and then any text. Files are scanned for
75
 
   matching queue ID and a dot at the start. This means temporary files
76
 
   being created can be given a different name not starting with a queue
77
 
   (we recommend a . on the start of the file name for temp files).
78
 
   Files in these queues are in the form of a simple text file where each
79
 
   line starts with a keyword and an = and then data. udh and ud have
80
 
   options for hex encoding, see below.
81
 
 
82
 
<P>
83
 
UTF-8. The user data (ud) field is treated as being UTF-8 encoded
84
 
   unless the DCS is specified indicating 8 bit format. If 8 bit format
85
 
   is specified then the user data is sent as is.
86
 
   The keywords are as follows:
87
 
<PRE>
88
 
   oa Originating address
89
 
   The phone number from which the message came
90
 
   Present on mobile terminated messages and is the CLI for morx messages
91
 
   da
92
 
   Destination Address
93
 
   The phone number to which the message is sent
94
 
   Present on mobile originated messages
95
 
   scts
96
 
   The service centre time stamp
97
 
   Format YYYY-MM-DDTHH:MM:SS
98
 
   Present on mobile terminated messages
99
 
   pid
100
 
   One byte decimal protocol ID
101
 
   See GSM specs for more details
102
 
   Normally 0 or absent
103
 
   dcs
104
 
   One byte decimal data coding scheme
105
 
   If omitted, a sensible default is used (see below)
106
 
   See GSM specs for more details
107
 
   mr
108
 
   One byte decimal message reference
109
 
   Present on mobile originated messages, added by default if absent
110
 
   srr
111
 
   0 or 1 for status report request
112
 
   Does not work in UK yet, not implemented in app_sms yet
113
 
   rp
114
 
   0 or 1 return path
115
 
   See GSM specs for details
116
 
   vp
117
 
   Validity period in seconds
118
 
   Does not work in UK yet
119
 
   udh
120
 
   Hex string of user data header prepended to the SMS contents,
121
 
   excluding initial length byte.
122
 
   Consistent with ud, this is specified as udh# rather than udh=
123
 
   If blank, this means that the udhi flag will be set but any user data
124
 
   header must be in the ud field
125
 
   ud
126
 
   User data, may be text, or hex, see below
127
 
</PRE>
128
 
 
129
 
<P>
130
 
udh is specified as as udh# followed by hex (2 hex digits per byte).
131
 
   If present, then the user data header indicator bit is set, and the
132
 
   length plus the user data header is added to the start of the user
133
 
   data, with padding if necessary (to septet boundary in 7 bit format).
134
 
   User data can hold an USC character codes U+0000 to U+FFFF. Any other
135
 
   characters are coded as U+FEFF
136
 
 
137
 
<P>
138
 
ud can be specified as ud= followed by UTF-8 encoded text if it
139
 
   contains no control characters, i.e. only (U+0020 to U+FFFF). Any
140
 
   invalid UTF-8 sequences are treated as is (U+0080-U+00FF).
141
 
 
142
 
<P>
143
 
ud can also be specified as ud# followed by hex (2 hex digits per
144
 
   byte) containing characters U+0000 to U+00FF only.
145
 
 
146
 
<P>
147
 
ud can also be specified as ud## followed by hex (4 hex digits per
148
 
   byte) containing UCS-2 characters.
149
 
 
150
 
<P>
151
 
When written by app_sms (e.g. incoming messages), the file is written
152
 
   with ud= if it can be (no control characters). If it cannot, the a
153
 
   comment line ;ud= is used to show the user data for human readability
154
 
   and ud# or ud## is used.
 
64
smsq is a simple helper application designed to make it easy to send
 
65
   messages from a command line. it is intended to run on the Asterisk
 
66
   box and have direct access to the queue directories for SMS and for
 
67
   Asterisk.
 
68
 
 
69
<P>
 
70
In its simplest form you can send an SMS by a command such as
 
71
   smsq 0123456789 This is a test to 0123456789
 
72
   This would create a queue file for a mobile originated TX message in
 
73
   queue 0 to send the text "This is a test to 0123456789" to 0123456789.
 
74
   It would then place a file in the /var/spool/asterisk/outgoing
 
75
   directory to initiate a call to 17094009 (the default message centre
 
76
   in smsq) attached to application SMS with argument of the queue name
 
77
   (0).
 
78
 
 
79
<P>
 
80
Normally smsq will queue a message ready to send, and will then create
 
81
   a file in the Asterisk outgoing directory causing Asterisk to actually
 
82
   connect to the message centre or device and actually send the pending
 
83
   message(s).
 
84
 
 
85
<P>
 
86
Using <code>--process</code>, smsq can however be used on received queues to run a
 
87
   command for each file (matching the queue if specified) with various
 
88
   environment variables set based on the message (see below);
 
89
   smsq options:
 
90
<PRE>
 
91
   --help
 
92
   Show help text
 
93
   --usage
 
94
   Show usage
 
95
   --queue
 
96
   -q
 
97
   Specify a specific queue
 
98
   In no specified, messages are queued under queue "0"
 
99
   --da
 
100
   -d
 
101
   Specify destination address
 
102
   --oa
 
103
   -o
 
104
   Specify originating address
 
105
   This also implies that we are generating a mobile terminated message
 
106
   --ud
 
107
   -m
 
108
   Specify the actual message
 
109
   --ud-file
 
110
   -f
 
111
   Specify a file to be read for the context of the message
 
112
   A blank filename (e.g. --ud-file= on its own) means read stdin. Very
 
113
   useful when using via ssh where command line parsing could mess up the
 
114
   message.
 
115
   --mt
 
116
   -t
 
117
   Mobile terminated message to be generated
 
118
   --mo
 
119
   Mobile originated message to be generated
 
120
   Default
 
121
   --tx
 
122
   Transmit message
 
123
   Default
 
124
   --rx
 
125
   -r
 
126
   Generate a message in the receive queue
 
127
   --UTF-8
 
128
   Treat the file as UTF-8 encoded (default)
 
129
   --UCS-1
 
130
   Treat the file as raw 8 bit UCS-1 data, not UTF-8 encoded
 
131
   --UCS-2
 
132
   Treat the file as raw 16 bit bigendian USC-2 data
 
133
   --process
 
134
   Specific a command to process for each file in the queue
 
135
   Implies --rx and --mt if not otherwise specified.
 
136
   Sets environment variables for every possible variable, and also ud,
 
137
   ud8 (USC-1 hex), and ud16 (USC-2 hex) for each call. Removes files.
 
138
   --motx-channel
 
139
   Specify the channel for motx calls
 
140
   May contain X to use sub address based on queue name or may be full
 
141
   number
 
142
   Default is Local/1709400X
 
143
   --motx-callerid
 
144
   Specify the caller ID for motx calls
 
145
   The default is the queue name without -X suffix
 
146
   --motx-wait
 
147
   Wait time for motx call
 
148
   Default 10
 
149
   --motx-delay
 
150
   Retry time for motx call
 
151
   Default 1
 
152
   --motx-retries
 
153
   Retries for motx call
 
154
   Default 10
 
155
   --mttx-channel
 
156
   Specify the channel for mttx calls
 
157
   Default is Local/ and the queue name without -X suffix
 
158
   --mtttx-callerid
 
159
   Specify the callerid for mttx calls
 
160
   May include X to use sub address based on queue name or may be full
 
161
   number
 
162
   Default is 080058752X0
 
163
   --mttx-wait
 
164
   Wait time for mttx call
 
165
   Default 10
 
166
   --mttx-delay
 
167
   Retry time for mttx call
 
168
   Default 30
 
169
   --mttx-retries
 
170
   Retries for mttx call
 
171
   Default 100
 
172
   --default-sub-address
 
173
   The default sub address assumed (e.g. for X in CLI and dialled numbers
 
174
   as above) when none added (-X) to queue
 
175
   Default 9
 
176
   --no-dial
 
177
   -x
 
178
   Create queue, but do not dial to send message
 
179
   --no-wait
 
180
   Do not wait if a call appears to be in progress
 
181
   This could have a small window where a message is queued but not
 
182
   sent, so regular calls to smsq should be done to pick up any missed
 
183
   messages
 
184
   --concurrent
 
185
   How many concurrent calls to allow (per queue), default 1
 
186
   --mr
 
187
   -n
 
188
   Message reference
 
189
   --pid
 
190
   -p
 
191
   Protocol ID
 
192
   --dcs
 
193
   Data coding scheme
 
194
   --udh
 
195
   Specific hex string of user data header specified (not including the
 
196
   initial length byte)
 
197
   May be a blank string to indicate header is included in the user data
 
198
   already but user data header indication to be set.
 
199
   --srr
 
200
   Status report requested
 
201
   --rp
 
202
   Return path requested
 
203
   --vp
 
204
   Specify validity period (seconds)
 
205
   --scts
 
206
   Specify timestamp (YYYY-MM-DDTHH:MM:SS)
 
207
   --spool-dir
 
208
   Spool dir (in which sms and outgoing are found)
 
209
   Default /var/spool/asterisk
 
210
</PRE>
 
211
 
 
212
<P>
 
213
Other arguments starting '-' or '<code>--</code>' are invalid and will cause an
 
214
   error. Any trailing arguments are processed as follows:-
 
215
 
 
216
<P>
 
217
 
 
218
<UL>
 
219
<LI>If the message is mobile originating and no destination address
 
220
       has been specified, then the first argument is assumed to be a
 
221
       destination address
 
222
 
 
223
<P>
 
224
</LI>
 
225
<LI>If the message is mobile terminating and no destination address
 
226
       has been specified, then the first argument is assumed to be the
 
227
       queue name
 
228
 
 
229
<P>
 
230
</LI>
 
231
<LI>If there is no user data, or user data file specified, then any
 
232
       following arguments are assumed to be the message, which are
 
233
       concatenated.
 
234
 
 
235
<P>
 
236
</LI>
 
237
<LI>If no user data is specified, then no message is sent. However,
 
238
       unless <code>--no-dial</code> is specified, smsq checks for pending messages
 
239
       and generates an outgoing anyway
 
240
</LI>
 
241
</UL>
 
242
 
 
243
<P>
 
244
Note that when smsq attempts to make a file in
 
245
   /var/spool/asterisk/outgoing, it checks if there is already a call
 
246
   queued for that queue. It will try several filenames, up to the
 
247
   <code>--concurrent</code> setting. If these files exist, then this means Asterisk
 
248
   is already queued to send all messages for that queue, and so Asterisk
 
249
   should pick up the message just queued. However, this alone could
 
250
   create a race condition, so if the files exist then smsq will wait up
 
251
   to 3 seconds to confirm it still exists or if the queued messages have
 
252
   been sent already. The <code>--no-wait</code> turns off this behaviour. Basically,
 
253
   this means that if you have a lot of messages to send all at once,
 
254
   Asterisk will not make unlimited concurrent calls to the same message
 
255
   centre or device for the same queue. This is because it is generally
 
256
   more efficient to make one call and send all of the messages one after
 
257
   the other.
 
258
 
 
259
<P>
 
260
smsq can be used with no arguments, or with a queue name only, and it
 
261
   will check for any pending messages and cause an outgoing if there are
 
262
   any. It only sets up one outgoing call at a time based on the first
 
263
   queued message it finds. A outgoing call will normally send all queued
 
264
   messages for that queue. One way to use smsq would be to run with no
 
265
   queue name (so any queue) every minute or every few seconds to send
 
266
   pending message. This is not normally necessary unless <code>--no-dial</code> is
 
267
   selected. Note that smsq does only check motx or mttx depending on the
 
268
   options selected, so it would need to be called twice as a general
 
269
   check.
 
270
 
 
271
<P>
 
272
UTF-8 is used to parse command line arguments for user data, and is
 
273
   the default when reading a file. If an invalid UTF-8 sequence is
 
274
   found, it is treated as UCS-1 data (i.e, as is).
 
275
   The <code>--process</code> option causes smsq to scan the specified queue (default
 
276
   is mtrx) for messages (matching the queue specified, or any if queue
 
277
   not specified) and run a command and delete the file. The command is
 
278
   run with a number of environment variables set as follows. Note that
 
279
   these are unset if not needed and not just taken from the calling
 
280
   environment. This allows simple processing of incoming messages
 
281
<PRE>
 
282
   $queue
 
283
   Set if a queue specified
 
284
   $?srr
 
285
   srr is set (to blank) if srr defined and has value 1.
 
286
   $?rp
 
287
   rp is set (to blank) if rp defined and has value 1.
 
288
   $ud
 
289
   User data, UTF-8 encoding, including any control characters, but with
 
290
   nulls stripped out
 
291
   Useful for the content of emails, for example, as it includes any
 
292
   newlines, etc.
 
293
   $ude
 
294
   User data, escaped UTF-8, including all characters, but control
 
295
   characters \n, \r, \t, \f, \xxx and \ is escaped as \\
 
296
   Useful guaranteed one line printable text, so useful in Subject lines
 
297
   of emails, etc
 
298
   $ud8
 
299
   Hex UCS-1 coding of user data (2 hex digits per character)
 
300
   Present only if all user data is in range U+0000 to U+00FF
 
301
   $ud16
 
302
   Hex UCS-2 coding of user data (4 hex digits per character)
 
303
   other
 
304
   Other fields set using their field name, e.g. mr, pid, dcs, etc. udh
 
305
   is a hex byte string
 
306
</PRE>
155
307
 
156
308
<P>
157
309
 
158
310
<DIV CLASS="navigation"><HR>
159
311
<!--Navigation Panel-->
160
 
<A NAME="tex2html4004"
 
312
<A NAME="tex2html4007"
161
313
  HREF="node257.html">
162
314
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
163
315
 SRC="/usr/share/latex2html/icons/next.png"></A> 
164
 
<A NAME="tex2html4000"
165
 
  HREF="node248.html">
 
316
<A NAME="tex2html4003"
 
317
  HREF="node249.html">
166
318
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
167
319
 SRC="/usr/share/latex2html/icons/up.png"></A> 
168
 
<A NAME="tex2html3994"
 
320
<A NAME="tex2html3997"
169
321
  HREF="node255.html">
170
322
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
171
323
 SRC="/usr/share/latex2html/icons/prev.png"></A> 
172
 
<A NAME="tex2html4002"
 
324
<A NAME="tex2html4005"
173
325
  HREF="node1.html">
174
326
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
175
327
 SRC="/usr/share/latex2html/icons/contents.png"></A>  
176
328
<BR>
177
 
<B> Next:</B> <A NAME="tex2html4005"
178
 
  HREF="node257.html">Delivery reports</A>
179
 
<B> Up:</B> <A NAME="tex2html4001"
180
 
  HREF="node248.html">SMS</A>
181
 
<B> Previous:</B> <A NAME="tex2html3995"
182
 
  HREF="node255.html">Using smsq</A>
183
 
 &nbsp; <B>  <A NAME="tex2html4003"
 
329
<B> Next:</B> <A NAME="tex2html4008"
 
330
  HREF="node257.html">File formats</A>
 
331
<B> Up:</B> <A NAME="tex2html4004"
 
332
  HREF="node249.html">SMS</A>
 
333
<B> Previous:</B> <A NAME="tex2html3998"
 
334
  HREF="node255.html">extensions.conf</A>
 
335
 &nbsp; <B>  <A NAME="tex2html4006"
184
336
  HREF="node1.html">Contents</A></B> </DIV>
185
337
<!--End of Navigation Panel-->
186
338
<ADDRESS>
187
339
lmadsen
188
 
2010-05-03
 
340
2010-06-17
189
341
</ADDRESS>
190
342
</BODY>
191
343
</HTML>