summaryrefslogtreecommitdiff
path: root/docs/man/gammu-smsd-tables.7
blob: ed78880d1d5bdffff50fbad1b5ad647694c121eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
.\" Man page generated from reStructuredText.
.
.TH "GAMMU-SMSD-TABLES" "7" "Oct 18, 2016" "1.37.90" "Gammu"
.SH NAME
gammu-smsd-tables \- description of tables for database backends of gammu-smsd(1)
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.sp
The backends themselves are described in their sections, this document
describes general database structure and required tables.
.sp
More SMS daemons can share single database. If you do not specify PhoneID in
their configuration, all are treated equally and you have no guarantee which
one sends outgoing message. If you configure PhoneID and use it when inserting
message to the \fBoutbox\fP table (gammu\-smsd\-inject does this), each SMS
daemon will have separate outbox queue. See also smsd\-multi\&.
.SH RECEIVING OF MESSAGES
.sp
Received messages are stored in \fI\%inbox\fP table.
.SH TRANSMITTING OF MESSAGES
.sp
Transmitted messages are read from table \fI\%outbox\fP and possible subsequent parts
of the same message from \fI\%outbox_multipart\fP\&.
.SH DESCRIPTION OF TABLES
.SS gammu
.sp
Table holding single field \fBVersion\fP \- version of a database schema. See
\fI\%History of database structure\fP for details what has changed.
.SS inbox
.sp
Table where received messages will be stored.
.sp
Fields description:
.INDENT 0.0
.TP
.B \fBUpdatedInDB\fP (timestamp)
when somebody (daemon, user, etc.) updated it
.TP
.B \fBReceivingDateTime\fP (timestamp)
when SMS was received
.TP
.B \fBText\fP (text)
encoded SMS text (for all SMS)
.TP
.B \fBSenderNumber\fP (varchar(20))
decoded SMS sender number
.TP
.B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
SMS text coding
.TP
.B \fBUDH\fP (text)
encoded User Data Header text
.TP
.B \fBSMSCNumber\fP (varchar(20))
decoded SMSC number
.TP
.B \fBClass\fP (integer)
SMS class or \-1 (0 is flash SMS, 1 is normal one)
.TP
.B \fBTextDecoded\fP (varchar(160))
decoded SMS text (for Default Alphabet/Unicode SMS)
.TP
.B \fBID\fP (integer unsigned)
SMS identificator (for using with external applications)
.TP
.B \fBRecipientID\fP (text)
which Gammu daemon has added it
.TP
.B \fBProcessed\fP (enum(\(aqfalse\(aq, \(aqtrue\(aq))
you can use for marking, whether SMS was processed or not
.UNINDENT
.SS outbox
.sp
Messages enqueued for sending should be placed in this table. If message
is multipart, subsequent parts are stored in table \fI\%outbox_multipart\fP\&.
.sp
Fields description:
.INDENT 0.0
.TP
.B \fBUpdatedInDB\fP (timestamp)
when somebody (daemon, user, etc.) updated it
.TP
.B \fBInsertIntoDB\fP (timestamp)
when message was inserted into database
.TP
.B \fBSendingDateTime\fP (timestamp)
set it to some value, when want to force sending after some planned time
.TP
.B \fBSendBefore\fP (time)
Send message before specified time, can be used to limit messages from
being sent in night. Default value is 23:59:59
.sp
New in version 1.29.90.

.TP
.B \fBSendAfter\fP (time)
Send message after specified time, can be used to limit messages from
being sent in night. Default value is 00:00:00
.sp
New in version 1.29.90.

.TP
.B \fBText\fP (text)
SMS text encoded using hex values in proper coding. If you want to use
TextDecoded field, keep this NULL (or empty).
.TP
.B \fBDestinationNumber\fP (varchar(20))
recipient number
.TP
.B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
SMS text coding
.TP
.B \fBUDH\fP (text)
User Data Header encoded using hex values which will be used for constructing
the message. Without this, message will be sent as plain text.
.TP
.B \fBClass\fP (integer)
SMS class or \-1 (0 is normal SMS, 1 is flash one)
.TP
.B \fBTextDecoded\fP (varchar(160))
SMS text in "human readable" form
.TP
.B \fBID\fP (integer unsigned)
SMS/SMS sequence ID
.sp
Please note that this number has to be unique also for sentitems table, so
reusing message IDs might not be a good idea.
.TP
.B \fBMultiPart\fP (enum(\(aqfalse\(aq,\(aqtrue\(aq))
info, whether there are more SMS from this sequence in outbox_multipart
.TP
.B \fBRelativeValidity\fP (integer)
SMS relative validity like encoded using GSM specs
.TP
.B \fBSenderID\fP (text)
which SMSD instance should send this one sequence, see
\fBPhoneID\fP and smsd\-multi\&. If blank, first SMSD who
sees this message first will process it.
.TP
.B \fBSendingTimeOut\fP (timestamp)
used by SMSD instance for own targets
.TP
.B \fBDeliveryReport\fP (enum(\(aqdefault\(aq,\(aqyes\(aq,\(aqno\(aq))
when default is used, Delivery Report is used or not according to SMSD instance settings; yes forces Delivery Report.
.TP
.B \fBCreatorID\fP (text)
identification of program created the message
.TP
.B \fBRetries\fP (integer)
number of attempted retries when sending this message
.TP
.B \fBPriority\fP (integer)
priority of message, messages with higher priority are processed first
.UNINDENT
.SS outbox_multipart
.sp
Data for outgoing multipart messages.
.sp
Fields description:
.INDENT 0.0
.TP
.B \fBID\fP (integer unsigned)
the same meaning as values in outbox table
.TP
.B \fBText\fP (text)
the same meaning as values in outbox table
.TP
.B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
the same meaning as values in outbox table
.TP
.B \fBUDH\fP (text)
the same meaning as values in outbox table
.TP
.B \fBClass\fP (integer)
the same meaning as values in outbox table
.TP
.B \fBTextDecoded\fP (varchar(160))
the same meaning as values in outbox table
.TP
.B \fBID\fP (integer unsigned)
the same meaning as values in outbox table
.TP
.B \fBSequencePosition\fP (integer)
info, what is SMS number in SMS sequence (start at 2, first part is in \fI\%outbox\fP
table).
.UNINDENT
.SS phones
.sp
Information about connected phones. This table is periodically refreshed and
you can get information such as battery or signal level from here.
.sp
Fields description:
.INDENT 0.0
.TP
.B \fBID\fP (text)
PhoneID value
.TP
.B \fBUpdatedInDB\fP (timestamp)
when this record has been updated
.TP
.B \fBInsertIntoDB\fP (timestamp)
when this record has been created (when phone has been connected)
.TP
.B \fBTimeOut\fP (timestamp)
when this record expires
.TP
.B \fBSend\fP (boolean)
indicates whether SMSD is sending messages, depends on configuration directive \fBSend\fP
.TP
.B \fBReceive\fP (boolean)
indicates whether SMSD is receiving messages, depends on configuration directive \fBReceive\fP
.TP
.B \fBIMEI\fP (text)
IMEI of phone
.TP
.B \fBIMSI\fP (text)
SIM IMSI
.TP
.B \fBClient\fP (text)
client name, usually string Gammu with version
.TP
.B \fBBattery\fP (integer)
battery level in percent (or \-1 if unknown)
.TP
.B \fBSignal\fP (integer)
signal level in percent (or \-1 if unknown)
.TP
.B \fBSent\fP (integer)
Number of sent SMS messages (SMSD does not reset this counter, so it might
overflow).
.TP
.B \fBReceived\fP (integer)
Number of received SMS messages (SMSD does not reset this counter, so it might
overflow).
.UNINDENT
.SS sentitems
.sp
Log of sent messages (and unsent ones with error code). Also if delivery
reports are enabled, message state is updated after receiving delivery report.
.sp
Fields description:
.INDENT 0.0
.TP
.B \fBUpdatedInDB\fP (timestamp)
when somebody (daemon, user, etc.) updated it
.TP
.B \fBInsertIntoDB\fP (timestamp)
when message was inserted into database
.TP
.B \fBSendingDateTime\fP (timestamp)
when message has been sent
.TP
.B \fBDeliveryDateTime\fP (timestamp)
Time of receiving delivery report (if it has been enabled).
.TP
.B \fBStatus\fP (enum(\(aqSendingOK\(aq, \(aqSendingOKNoReport\(aq, \(aqSendingError\(aq, \(aqDeliveryOK\(aq, \(aqDeliveryFailed\(aq, \(aqDeliveryPending\(aq, \(aqDeliveryUnknown\(aq, \(aqError\(aq))
Status of message sending. SendingError means that phone failed to send the
message, Error indicates some other error while processing message.
.INDENT 7.0
.TP
.B \fBSendingOK\fP
Message has been sent, waiting for delivery report.
.TP
.B \fBSendingOKNoReport\fP
Message has been sent without asking for delivery report.
.TP
.B \fBSendingError\fP
Sending has failed.
.TP
.B \fBDeliveryOK\fP
Delivery report arrived and reported success.
.TP
.B \fBDeliveryFailed\fP
Delivery report arrived and reports failure.
.TP
.B \fBDeliveryPending\fP
Delivery report announced pending deliver.
.TP
.B \fBDeliveryUnknown\fP
Delivery report reported unknown status.
.TP
.B \fBError\fP
Some other error happened during sending (usually bug in SMSD).
.UNINDENT
.TP
.B \fBStatusError\fP (integer)
Status of delivery from delivery report message, codes are defined in GSM
specification 03.40 section 9.2.3.15 (TP\-Status).
.TP
.B \fBText\fP (text)
SMS text encoded using hex values
.TP
.B \fBDestinationNumber\fP (varchar(20))
decoded destination number for SMS
.TP
.B \fBCoding\fP (enum(\(aqDefault_No_Compression\(aq, \(aqUnicode_No_Compression\(aq, \(aq8bit\(aq, \(aqDefault_Compression\(aq, \(aqUnicode_Compression\(aq))
SMS text coding
.TP
.B \fBUDH\fP (text)
User Data Header encoded using hex values
.TP
.B \fBSMSCNumber\fP (varchar(20))
decoded number of SMSC, which sent SMS
.TP
.B \fBClass\fP (integer)
SMS class or \-1 (0 is normal SMS, 1 is flash one)
.TP
.B \fBTextDecoded\fP (varchar(160))
SMS text in "human readable" form
.TP
.B \fBID\fP (integer unsigned)
SMS ID
.TP
.B \fBSenderID\fP (text)
which SMSD instance sent this one sequence, see \fBPhoneID\fP
.TP
.B \fBSequencePosition\fP (integer)
SMS number in SMS sequence
.TP
.B \fBTPMR\fP (integer)
Message Reference like in GSM specs
.TP
.B \fBRelativeValidity\fP (integer)
SMS relative validity like encoded using GSM specs
.TP
.B \fBCreatorID\fP (text)
copied from CreatorID from outbox table
.UNINDENT
.SH HISTORY OF DATABASE STRUCTURE
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
Testing versions (see versioning) do not have to keep same table
structure as final releases. Below mentioned versions are for
informational purposes only, you should always use stable versions in
production environment.
.UNINDENT
.UNINDENT
.sp
History of schema versions:
.sp
16
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.IP \(bu 2
Removed unused \fBdaemons\fP, \fBpbk\fP and \fBpbk_groups\fP tables.
.IP \(bu 2
Added primary key to the \fBgammu\fP table.
.IP \(bu 2
Added \fBPriority\fP field to the \fI\%outbox\fP\&.
.IP \(bu 2
Added \fBIMSI\fP field to the \fI\%phones\fP\&.
.UNINDENT
.sp
Changed in version 1.37.90.

.UNINDENT
.UNINDENT
.sp
15
.INDENT 0.0
.INDENT 3.5
Added \fBRetries\fP field to the \fI\%outbox\fP\&.
.sp
Changed in version 1.36.7.

.UNINDENT
.UNINDENT
.sp
14
.INDENT 0.0
.INDENT 3.5
Added \fBNetCode\fP and \fBNetName\fP fields.
.sp
Changed in version 1.34.0.

.UNINDENT
.UNINDENT
.INDENT 0.0
.TP
.B 13
Added \fBSendBefore\fP and \fBSendAfter\fP fields.
.sp
Changed in version 1.29.90.

.sp
Also PostgreSQL fields are now case sensitive (same as other backends).
.sp
Changed in version 1.29.93.

.TP
.B 12
the changes only affect MySQL structure changing default values for
timestamps from \fB0000\-00\-00 00:00:00\fP to \fBCURRENT_TIMESTAMP()\fP by
using triggers, to update to this version, just execute triggers
definition at the end of SQL file.
.sp
Changed in version 1.28.94.

.TP
.B 11
all fields for storing message text are no longer limited to 160 chars,
but are arbitrary length text fields.
.sp
Changed in version 1.25.92.

.TP
.B 10
\fBDeliveryDateTime\fP is now NULL when message is not delivered, added several
indexes
.sp
Changed in version 1.22.95.

.TP
.B 9
added sent/received counters to phones table
.sp
Changed in version 1.22.93.

.TP
.B 8
Signal and battery state are now stored in database.
.sp
Changed in version 1.20.94.

.TP
.B 7
Added \fBCreatorID\fP to several tables.
.sp
Changed in version 1.07.00.

.TP
.B 6
Many fields in outbox can now be NULL.
.sp
Changed in version 1.06.00.

.TP
.B 5
Introduced daemons table and various other changes.
.sp
Changed in version 1.03.00.

.TP
.B 3
Introduced phones table and various other changes.
.sp
Changed in version 0.98.0.

.UNINDENT
.SH EXAMPLES
.SS Creating tables
.sp
SQL scripts to create all needed tables for most databases are included in
Gammu documentation (docs/sql). As well as some PHP scripts interacting with
the database.
.sp
For example to create SQLite tables, issue following command:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
sqlite3 smsd.db < docs/sql/sqlite.sql
.ft P
.fi
.UNINDENT
.UNINDENT
.SS Injecting a message using SQL
.sp
To send a message, you can either use gammu\-smsd\-inject, which does all the
magic for you, or you can insert the message manually. The simplest example is
short text message:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
INSERT INTO outbox (
    DestinationNumber,
    TextDecoded,
    CreatorID,
    Coding
) VALUES (
    \(aq800123465\(aq,
    \(aqThis is a SQL test message\(aq,
    \(aqProgram\(aq,
    \(aqDefault_No_Compression\(aq
);
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
Please note usage of \fBTextDecoded\fP field, for \fBText\fP field, you would have
to hex encode the unicode text:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
INSERT INTO outbox (
    DestinationNumber,
    Text,
    CreatorID,
    Coding
) VALUES (
    \(aq800123465\(aq,
    \(aq005400680069007300200069007300200061002000530051004c002000740065007300740020006d006500730073006100670065\(aq,
    \(aqProgram\(aq,
    \(aqDefault_No_Compression\(aq
);
.ft P
.fi
.UNINDENT
.UNINDENT
.SS Injecting long message using SQL
.sp
Inserting multipart messages is a bit more tricky, you need to construct also
UDH header and store it hexadecimally written into UDH field. Unless you have a
good reason to do this manually, use gammu\-smsd\-inject, C library
(\fBSMSD_InjectSMS()\fP) or Python library
(\fBgammu.smsd.SMSD.InjectSMS()\fP).
.sp
For long text message, the UDH starts with \fB050003\fP followed by byte as a
message reference (you can put any hex value there, but it should be \fBdifferent
for each message\fP, \fBD3\fP in following example), byte for number of messages
(\fB02\fP in example, it should be unique for each message you send to same phone
number) and byte for number of current message (\fB01\fP for first message,
\fB02\fP for second, etc.).
.sp
I most cases, the mutlipart message has to be class 1.
.sp
For example long text message of two parts could look like following:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
INSERT INTO outbox (
    CreatorID,
    MultiPart,
    DestinationNumber,
    UDH,
    TextDecoded,
    Coding,
    Class
) VALUES (
    \(aqGammu 1.23.91\(aq,
    \(aqtrue\(aq,
    \(aq123465\(aq,
    \(aq050003D30201\(aq,
    \(aqMqukqirip ya konej eqniu rejropocejor hugiygydewl tfej nrupxujob xuemymiyliralj. Te tvyjuh qaxumur ibewfoiws zuucoz tdygu gelum L ejqigqesykl kya jdytbez\(aq,
    \(aqDefault_No_Compression\(aq,
    1
)

INSERT INTO outbox_multipart (
    SequencePosition,
    UDH,
    Class,
    TextDecoded,
    ID,
    Coding,
    Class
) VALUES (
    2,
    \(aq050003D30202\(aq,
    \(aqu xewz qisubevumxyzk ufuylehyzc. Nse xobq dfolizygqysj t bvowsyhyhyemim ovutpapeaempye giuuwbib.\(aq,
    <ID_OF_INSERTED_RECORD_IN_OUBOX_TABLE>,
    \(aqDefault_No_Compression\(aq,
    1
)
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
Adding UDH means that you have less space for text, in above example you
can use only 153 characters in single message.
.UNINDENT
.UNINDENT
.SH AUTHOR
Michal Čihař <michal@cihar.com>
.SH COPYRIGHT
2009-2015, Michal Čihař <michal@cihar.com>
.\" Generated by docutils manpage writer.
.