Setting version to 1.29.0.
[gammu.git] / docs / man / gammu-smsd-tables.7
blob126083476372fd3f98ee018ae1cb870368134c1f
1 .TH "GAMMU-SMSD-TABLES" "7" "January 19, 2011" "1.29.0" "Gammu"
2 .SH NAME
3 gammu-smsd-tables \- description of tables for database backends of gammu-smsd(1)
5 .nr rst2man-indent-level 0
7 .de1 rstReportMargin
8 \\$1 \\n[an-margin]
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
12 \\n[rst2man-indent0]
13 \\n[rst2man-indent1]
14 \\n[rst2man-indent2]
16 .de1 INDENT
17 .\" .rstReportMargin pre:
18 . RS \\$1
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
23 .de UNINDENT
24 . RE
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
31 .\" Man page generated from reStructeredText.
33 .sp
34 The backends themselves are described in their sections, this document
35 describes general database structure and required tables.
36 .sp
37 More SMS daemons can share single database. If you do not specify PhoneID in
38 their configuration, all are treated equally and you have no guarantee which
39 one sends outgoing message. If you configure PhoneID and use it when inserting
40 message to the \fBoutbox\fP table (\fIgammu\-smsd\-inject\fP does this), each SMS
41 daemon will have separate outbox queue.
42 .SH RECEIVING OF MESSAGES
43 .sp
44 Received messages are stored in \fBinbox\fP table.
45 .SH TRANSMITTING OF MESSAGES
46 .sp
47 Transmitted messages are read from table \fBoutbox\fP and possible subsequent parts
48 of the same message from \fBoutbox_multipart\fP.
49 .SH DESCRIPTION OF TABLES
50 .SS daemons
51 .sp
52 Information about running daemons.
53 .SS gammu
54 .sp
55 Table holding single value \- version of a database schema. See HISTORY for
56 details what has changed.
57 .SS inbox
58 .sp
59 Table where received messages will be stored.
60 .sp
61 Fields description:
62 .INDENT 0.0
63 .TP
64 .B \fBUpdatedInDB\fP (timestamp)
65 .sp
66 when somebody (daemon, user, etc.) updated it
67 .TP
68 .B \fBReceivingDateTime\fP (timestamp)
69 .sp
70 when SMS was received
71 .TP
72 .B \fBText\fP (text)
73 .sp
74 encoded SMS text (for all SMS)
75 .TP
76 .B \fBSenderNumber\fP (varchar(20))
77 .sp
78 decoded SMS sender number
79 .TP
80 .B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
81 .sp
82 SMS text coding
83 .TP
84 .B \fBUDH\fP (text)
85 .sp
86 encoded User Data Header text
87 .TP
88 .B \fBSMSCNumber\fP (varchar(20))
89 .sp
90 decoded SMSC number
91 .TP
92 .B \fBClass\fP (integer)
93 .sp
94 SMS class or \-1 (0 is flash SMS, 1 is normal one)
95 .TP
96 .B \fBTextDecoded\fP (varchar(160))
97 .sp
98 decoded SMS text (for Default Alphabet/Unicode SMS)
99 .TP
100 .B \fBID\fP (integer unsigned)
102 SMS identificator (for using with external applications)
104 .B \fBRecipientID\fP (text)
106 which Gammu daemon has added it
108 .B \fBProcessed\fP (enum(\(aqfalse\(aq, \(aqtrue\(aq))
110 you can use for marking, whether SMS was processed or not
111 .UNINDENT
112 .SS outbox
114 Messages enqueued for sending should be placed in this table. If message
115 is multipart, subsequent parts are stored in table outbox_multipart.
117 Fields description:
118 .INDENT 0.0
120 .B \fBUpdatedInDB\fP (timestamp)
122 when somebody (daemon, user, etc.) updated it
124 .B \fBInsertIntoDB\fP (timestamp)
126 when message was inserted into database
128 .B \fBSendingDateTime\fP (timestamp)
130 set it to some value, when want to force sending after some planned time
132 .B \fBText\fP (text)
134 SMS text encoded using hex values in proper coding. If you want to use
135 TextDecoded field, keep this NULL (or empty).
137 .B \fBDestinationNumber\fP (varchar(20))
139 recipient number
141 .B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
143 SMS text coding
145 .B \fBUDH\fP (text)
147 User Data Header encoded using hex values which will be used for constructing
148 the message. Without this, message will be sent as plain text.
150 .B \fBClass\fP (integer)
152 SMS class or \-1 (0 is normal SMS, 1 is flash one)
154 .B \fBTextDecoded\fP (varchar(160))
156 SMS text in "human readable" form
158 .B \fBID\fP (integer unsigned)
160 SMS/SMS sequence ID
162 Please note that this number has to be unique also for sentitems table, so
163 reusing message IDs might not be a good idea.
165 .B \fBMultiPart\fP (enum(\(aqfalse\(aq,\(aqtrue\(aq))
167 info, whether there are more SMS from this sequence in outbox_multipart
169 .B \fBRelativeValidity\fP (integer)
171 SMS relative validity like encoded using GSM specs
173 .B \fBSenderID\fP (text)
175 which SMSD instance should send this one sequence
177 .B \fBSendingTimeOut\fP (timestamp)
179 used by SMSD instance for own targets
181 .B \fBDeliveryReport\fP (enum(\(aqdefault\(aq,\(aqyes\(aq,\(aqno\(aq))
183 when default is used, Delivery Report is used or not according to SMSD instance settings; yes forces Delivery Report.
185 .B \fBCreatorID\fP (text)
187 sender identification, it has to match PhoneID in SMSD configuration to make
188 SMSD process this message
189 .UNINDENT
190 .SS outbox_multipart
192 Data for outgoing multipart messages.
194 Fields description:
195 .INDENT 0.0
197 .B \fBID\fP (integer unsigned)
199 the same meaning as values in outbox table
201 .B \fBText\fP (text)
203 the same meaning as values in outbox table
205 .B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
207 the same meaning as values in outbox table
209 .B \fBUDH\fP (text)
211 the same meaning as values in outbox table
213 .B \fBClass\fP (integer)
215 the same meaning as values in outbox table
217 .B \fBTextDecoded\fP (varchar(160))
219 the same meaning as values in outbox table
221 .B \fBID\fP (integer unsigned)
223 the same meaning as values in outbox table
225 .B \fBSequencePosition\fP (integer)
227 info, what is SMS number in SMS sequence (start at 2, first part is in outbox
228 table).
229 .UNINDENT
230 .SS phones
232 Information about connected phones. This table is periodically refreshed and
233 you can get information such as battery or signal level from here.
235 Fields description:
236 .INDENT 0.0
238 .B \fBID\fP (text)
240 PhoneID value
242 .B \fBUpdatedInDB\fP (timestamp)
244 when this record has been updated
246 .B \fBInsertIntoDB\fP (timestamp)
248 when this record has been created (when phone has been connected)
250 .B \fBTimeOut\fP (timestamp)
252 when this record expires
254 .B \fBSend\fP (boolean)
256 indicates whether SMSD is sending messages, depends on configuration directive \fBSend\fP
258 .B \fBReceive\fP (boolean)
260 indicates whether SMSD is receiving messages, depends on configuration directive \fBReceive\fP
262 .B \fBIMEI\fP (text)
264 IMEI of phone
266 .B \fBClient\fP (text)
268 client name, usually string Gammu with version
270 .B \fBBattery\fP (integer)
272 battery level in percent (or \-1 if unknown)
274 .B \fBSignal\fP (integer)
276 signal level in percent (or \-1 if unknown)
278 .B \fBSent\fP (integer)
280 Number of sent SMS messages (SMSD does not reset this counter, so it might
281 overflow).
283 .B \fBReceived\fP (integer)
285 Number of received SMS messages (SMSD does not reset this counter, so it might
286 overflow).
287 .UNINDENT
288 .SS sentitems
290 Log of sent messages (and unsent ones with error code). Also if delivery
291 reports are enabled, message state is updated after receiving delivery report.
293 Fields description:
294 .INDENT 0.0
296 .B \fBUpdatedInDB\fP (timestamp)
298 when somebody (daemon, user, etc.) updated it
300 .B \fBInsertIntoDB\fP (timestamp)
302 when message was inserted into database
304 .B \fBSendingDateTime\fP (timestamp)
306 when message has been sent
308 .B \fBDeliveryDateTime\fP (timestamp)
310 Time of receiving delivery report (if it has been enabled).
312 .B \fBStatus\fP (enum(\(aqSendingOK\(aq, \(aqSendingOKNoReport\(aq, \(aqSendingError\(aq, \(aqDeliveryOK\(aq, \(aqDeliveryFailed\(aq, \(aqDeliveryPending\(aq, \(aqDeliveryUnknown\(aq, \(aqError\(aq))
314 Status of message sending. SendingError mens that phone failed to send the
315 message, Error indicates some other error while processing message.
316 .INDENT 7.0
318 .B \fBSendingOK\fP
320 Message has been sent, waiting for delivery report.
322 .B \fBSendingOKNoReport\fP
324 Message has been sent without asking for delivery report.
326 .B \fBSendingError\fP
328 Sending has failed.
330 .B \fBDeliveryOK\fP
332 Delivery report arrived and reported success.
334 .B \fBDeliveryFailed\fP
336 Delivery report arrived and reports failure.
338 .B \fBDeliveryPending\fP
340 Delivery report announced pending deliver.
342 .B \fBDeliveryUnknown\fP
344 Delivery report reported unknown status.
346 .B \fBError\fP
348 Some other error happened during sending (usually bug in SMSD).
349 .UNINDENT
351 .B \fBStatusError\fP (integer)
353 Status of delivery from delivery report message, codes are defined in GSM
354 specification 03.40 section 9.2.3.15 (TP\-Status).
356 .B \fBText\fP (text)
358 SMS text encoded using hex values
360 .B \fBDestinationNumber\fP (varchar(20))
362 decoded destination number for SMS
364 .B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
366 SMS text coding
368 .B \fBUDH\fP (text)
370 User Data Header encoded using hex values
372 .B \fBSMSCNumber\fP (varchar(20))
374 decoded number of SMSC, which sent SMS
376 .B \fBClass\fP (integer)
378 SMS class or \-1 (0 is normal SMS, 1 is flash one)
380 .B \fBTextDecoded\fP (varchar(160))
382 SMS text in "human readable" form
384 .B \fBID\fP (integer unsigned)
386 SMS ID
388 .B \fBSenderID\fP (text)
390 which SMSD instance sent this one sequence
392 .B \fBSequencePosition\fP (integer)
394 SMS number in SMS sequence
396 .B \fBTPMR\fP (integer)
398 Message Reference like in GSM specs
400 .B \fBRelativeValidity\fP (integer)
402 SMS relative validity like encoded using GSM specs
404 .B \fBCreatorID\fP (text)
406 copied from CreatorID from outbox table, matches PhoneID
407 .UNINDENT
408 .SS pbk
410 Not used by SMSD currently, included only for application usage.
411 .SS pbk_groups
413 Not used by SMSD currently, included only for application usage.
414 .SH HISTORY
416 History of schema versions:
417 .INDENT 0.0
419 .B 12
421 the changes only affect MySQL structure changing default values for
422 timestamps from \fB0000\-00\-00 00:00:00\fP to \fBCURRENT_TIMESTAMP()\fP by
423 using triggers, to update to this version, just execute triggers
424 definition at the end of SQL file.
426 .B 11
428 all fields for storing message text are no longer limited to 160 chars,
429 but are arbitrary length text fields (1.25.92)
431 .B 10
433 \fBDeliveryDateTime\fP is now NULL when message is not delivered, added several
434 indexes
436 .B 9
438 added sent/received counters to phones table
440 .B 8
442 introduced phones table
444 .B 7
446 added CreatorID to tables (it holds PhoneID if set)
447 .UNINDENT
448 .SH EXAMPLES
449 .SS Creating tables
451 SQL scripts to create all needed tables for most databases are included in
452 Gammu documentation (docs/sql). As well as some PHP scripts interacting with
453 the database.
455 For example to create SQLite tables, issue following command:
458 .ft C
459 sqlite3 smsd.db < docs/sql/sqlite.sql
460 .ft P
462 .SS Injecting a message using SQL
464 To send a message, you can either use \fIgammu\-smsd\-inject\fP, which does all the
465 magic for you, or you can insert the message manually. The simplest example is
466 short text message:
469 .ft C
470 INSERT INTO outbox (
471     DestinationNumber,
472     TextDecoded,
473     CreatorID,
474     Coding
475 ) VALUES (
476     \(aq800123465\(aq,
477     \(aqThis is a SQL test message\(aq,
478     \(aqProgram\(aq,
479     \(aqDefault_No_Compression\(aq
481 .ft P
483 .SS Injecting long message using SQL
485 Inserting multipart messages is a bit more tricky, you need to construct also
486 UDH header and store it hexadecimally written into UDH field. Unless you have
487 a good reason to do this manually, use \fIgammu\-smsd\-inject\fP.
489 For long text message, the UDH starts with \fB050003\fP followed by byte as a
490 message reference (you can put anything there, but it should be different for
491 each message, \fBD3\fP in following example), byte for number of messages (\fB02\fP
492 in example, it should be unique for each message you send to same phone number)
493 and byte for number of current message (\fB01\fP for first message, \fB02\fP for
494 second, etc.).
496 For example long text message of two parts could look like following:
499 .ft C
500 INSERT INTO outbox (
501     CreatorID,
502     MultiPart,
503     DestinationNumber,
504     UDH,
505     TextDecoded,
506     Coding
507 ) VALUES (
508     \(aqGammu 1.23.91\(aq,
509     \(aqtrue\(aq,
510     \(aq123465\(aq,
511     \(aq050003D30201\(aq,
512     \(aqMqukqirip ya konej eqniu rejropocejor hugiygydewl tfej nrupxujob xuemymiyliralj. Te tvyjuh qaxumur ibewfoiws zuucoz tdygu gelum L ejqigqesykl kya jdytbez\(aq,
513     \(aqDefault_No_Compression\(aq
516 INSERT INTO outbox_multipart (
517     SequencePosition,
518     UDH,
519     Class,
520     TextDecoded,
521     ID,
522     Coding
523 ) VALUES (
524     2,
525     \(aq050003D30202\(aq,
526     \(aqu xewz qisubevumxyzk ufuylehyzc. Nse xobq dfolizygqysj t bvowsyhyhyemim ovutpapeaempye giuuwbib.\(aq,
527     <ID_OF_INSERTED_RECORD_IN_OUBOX_TABLE>,
528     \(aqDefault_No_Compression\(aq
530 .ft P
532 .IP Note
534 Adding UDH means that you have less space for text, in above example you
535 can use only 153 characters in single message.
537 .SH AUTHOR
538 Michal Čihař <michal@cihar.com>
539 .SH COPYRIGHT
540 2009-2011, Michal Čihař <michal@cihar.com>
541 .\" Generated by docutils manpage writer.
542 .\"