.TH "GAMMU-SMSD-SQL" "7" "February 24, 2012" "1.31.90" "Gammu" .SH NAME gammu-smsd-sql \- gammu-smsd(1) backend using SQL abstraction layer to use any supported database as a message storage . .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 .. .\" Man page generated from reStructeredText. . .SH DESCRIPTION .sp SQL service stores all its data in database. It can use one of these SQL backends (configuration option \fBDriver\fP in smsd section): .INDENT 0.0 .IP \(bu 2 \fBnative_mysql\fP for \fIgammu\-smsd\-mysql\fP .IP \(bu 2 \fBnative_pgsql\fP for \fIgammu\-smsd\-pgsql\fP .IP \(bu 2 \fBodbc\fP for \fIgammu\-smsd\-odbc\fP .IP \(bu 2 .INDENT 2.0 .TP .B drivers supported by DBI for \fIgammu\-smsd\-dbi\fP, which include: .INDENT 7.0 .IP \(bu 2 \fBsqlite3\fP \- for SQLite 3 .IP \(bu 2 \fBmysql\fP \- for MySQL .IP \(bu 2 \fBpgsql\fP \- for PostgeSQL .IP \(bu 2 \fBfreetds\fP \- for MS SQL Server or Sybase .UNINDENT .UNINDENT .UNINDENT .SH SQL CONNECTION PARAMETERS .sp Common for all backends: .INDENT 0.0 .IP \(bu 2 \fBUser\fP \- user connecting to database .IP \(bu 2 \fBPassword\fP \- password for connecting to database .IP \(bu 2 \fBHost\fP \- database host or data source name .IP \(bu 2 \fBDatabase\fP \- database name .IP \(bu 2 \fBDriver\fP \- \fBnative_mysql\fP, \fBnative_pgsql\fP, \fBodbc\fP or DBI one .IP \(bu 2 \fBSQL\fP \- SQL dialect to use .UNINDENT .sp Specific for DBI: .INDENT 0.0 .IP \(bu 2 \fBDriversPath\fP \- path to DBI drivers .IP \(bu 2 \fBDBDir\fP \- sqlite/sqlite3 directory with database .UNINDENT .IP "See also" .sp The variables are fully described in \fIgammurc\fP documentation. .RE .SH SQL QUERIES .sp Almost all queries are configurable. You can edit them in \fB[sql]\fP section. There are several variables used in SQL queries. We can separate them into three groups: .INDENT 0.0 .IP \(bu 2 phone specific, which can be used in every query, see \fI\%Phone Specific Parameters\fP .IP \(bu 2 SMS specific, which can be used in queries which works with SMS messages, see \fI\%SMS Specific Parameters\fP .IP \(bu 2 query specific, which are numeric and are specific only for given query (or set of queries), see \fI\%Configurable queries\fP .UNINDENT .SS Phone Specific Parameters .INDENT 0.0 .TP .B \fB%I\fP IMEI of phone .TP .B \fB%P\fP PHONE ID (hostname) .TP .B \fB%N\fP client name (eg. Gammu 1.12.3) .UNINDENT .SS SMS Specific Parameters .INDENT 0.0 .TP .B \fB%R\fP remote number [1] .TP .B \fB%C\fP delivery datetime .TP .B \fB%e\fP delivery status on receiving or status error on sending .TP .B \fB%t\fP message reference .TP .B \fB%d\fP receiving datetime for received sms .TP .B \fB%E\fP encoded text of SMS .TP .B \fB%c\fP SMS coding (ie 8bit or UnicodeNoCompression) .TP .B \fB%F\fP sms centre number .TP .B \fB%u\fP UDH header .TP .B \fB%x\fP class .TP .B \fB%T\fP decoded SMS text .TP .B \fB%A\fP CreatorID of SMS (sending sms) .TP .B \fB%V\fP relative validity .UNINDENT .IP [1] 5 Sender number for received messages (insert to inbox or delivery notifications), destination otherwise. .SH CONFIGURABLE QUERIES .sp All configurable queries can be set in \fB[sql]\fP section. Sequence of rows in selects are mandatory. .sp All default queries noted here are noted for MySQL. Actual time and time addition are selected for default queries during initialization. .INDENT 0.0 .TP .B delete_phone Deletes phone from database. .sp Default value: .sp .nf .ft C DELETE FROM phones WHERE IMEI = %I .ft P .fi .UNINDENT .INDENT 0.0 .TP .B insert_phone Inserts phone to database. .sp Default value: .sp .nf .ft C INSERT INTO phones (IMEI, ID, Send, Receive, InsertIntoDB, TimeOut, Client, Battery, SignalStrength) VALUES (%I, %P, %1, %2, NOW(), (NOW() + INTERVAL 10 SECOND) + 0, %N, \-1, \-1) .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP enable send (yes or no) \- configuration option Send .TP .B \fB%2\fP enable receive (yes or no) \- configuration option Receive .UNINDENT .UNINDENT .INDENT 0.0 .TP .B save_inbox_sms_select Select message for update delivery status. .sp Default value: .sp .nf .ft C SELECT ID, Status, SendingDateTime, DeliveryDateTime, SMSCNumber FROM sentitems WHERE DeliveryDateTime IS NULL AND SenderID = %P AND TPMR = %t AND DestinationNumber = %R .ft P .fi .UNINDENT .INDENT 0.0 .TP .B save_inbox_sms_update_delivered Update message delivery status if message was delivered. .sp Default value: .sp .nf .ft C UPDATE sentitems SET DeliveryDateTime = %C, Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP delivery status returned by GSM network .TP .B \fB%2\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B save_inbox_sms_update Update message if there is an delivery error. .sp Default value: .sp .nf .ft C UPDATE sentitems SET Status = %1, StatusError = %e WHERE ID = %2 AND TPMR = %t .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP delivery status returned by GSM network .TP .B \fB%2\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B save_inbox_sms_insert Insert received message. .sp Default value: .sp .nf .ft C INSERT INTO inbox (ReceivingDateTime, Text, SenderNumber, Coding, SMSCNumber, UDH, Class, TextDecoded, RecipientID) VALUES (%d, %E, %R, %c, %F, %u, %x, %T, %P) .ft P .fi .UNINDENT .INDENT 0.0 .TP .B update_received Update statistics after receiving message. .sp Default value: .sp .nf .ft C UPDATE phones SET Received = Received + 1 WHERE IMEI = %I .ft P .fi .UNINDENT .INDENT 0.0 .TP .B refresh_send_status Update messages in outbox. .sp Default value: .sp .nf .ft C UPDATE outbox SET SendingTimeOut = (NOW() + INTERVAL locktime SECOND) + 0 WHERE ID = %1 AND (SendingTimeOut < NOW() OR SendingTimeOut IS NULL) .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B find_outbox_sms_id Find sms messages for sending. .sp Default value: .sp .nf .ft C SELECT ID, InsertIntoDB, SendingDateTime, SenderID FROM outbox WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW() AND SendBefore >= CURTIME() AND SendAfter <= CURTIME() AND ( SenderID is NULL OR SenderID = \(aq\(aq OR SenderID = %P ) ORDER BY InsertIntoDB ASC LIMIT %1 .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP limit of sms messages sended in one walk in loop .UNINDENT .UNINDENT .INDENT 0.0 .TP .B find_outbox_body Select body of message. .sp Default value: .sp .nf .ft C SELECT Text, Coding, UDH, Class, TextDecoded, ID, DestinationNumber, MultiPart, RelativeValidity, DeliveryReport, CreatorID FROM outbox WHERE ID=%1 .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B find_outbox_multipart Select remaining parts of sms message. .sp Default value: .sp .nf .ft C SELECT Text, Coding, UDH, Class, TextDecoded, ID, SequencePosition FROM outbox_multipart WHERE ID=%1 AND SequencePosition=%2 .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of message .TP .B \fB%2\fP Number of multipart message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B delete_outbox Remove messages from outbox after threir successful send. .sp Default value: .sp .nf .ft C DELETE FROM outbox WHERE ID=%1 .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B delete_outbox_multipart Remove messages from outbox_multipart after threir successful send. .sp Default value: .sp .nf .ft C DELETE FROM outbox_multipart WHERE ID=%1 .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B create_outbox Create message (insert to outbox). .sp Default value: .sp .nf .ft C INSERT INTO outbox (CreatorID, SenderID, DeliveryReport, MultiPart, InsertIntoDB, Text, DestinationNumber, RelativeValidity, Coding, UDH, Class, TextDecoded) VALUES (%1, %P, %2, %3, NOW(), %E, %R, %V, %c, %u, %x, %T) .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP creator of message .TP .B \fB%2\fP delivery status report \- yes/default .TP .B \fB%3\fP multipart \- FALSE/TRUE .TP .B \fB%4\fP Part (part number) .TP .B \fB%5\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B create_outbox_multipart Create message remaining parts. .sp Default value: .sp .nf .ft C INSERT INTO outbox_multipart (SequencePosition, Text, Coding, UDH, Class, TextDecoded, ID) VALUES (%4, %E, %c, %u, %x, %T, %5) .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP creator of message .TP .B \fB%2\fP delivery status report \- yes/default .TP .B \fB%3\fP multipart \- FALSE/TRUE .TP .B \fB%4\fP Part (part number) .TP .B \fB%5\fP ID of message .UNINDENT .UNINDENT .INDENT 0.0 .TP .B add_sent_info Insert to sentitems. .sp Default value: .sp .nf .ft C INSERT INTO sentitems (CreatorID,ID,SequencePosition,Status,SendingDateTime, SMSCNumber, TPMR, SenderID,Text,DestinationNumber,Coding,UDH,Class,TextDecoded, InsertIntoDB,RelativeValidity) VALUES (%A, %1, %2, %3, NOW(), %F, %4, %P, %E, %R, %c, %u, %x, %T, %5, %V) .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP ID of sms message .TP .B \fB%2\fP part number (for multipart sms) .TP .B \fB%3\fP message state (SendingError, Error, SendingOK, SendingOKNoReport) .TP .B \fB%4\fP message reference (TPMR) .TP .B \fB%5\fP time when inserted in db .UNINDENT .UNINDENT .INDENT 0.0 .TP .B update_sent Update sent statistics after sending message. .sp Default value: .sp .nf .ft C UPDATE phones SET Sent= Sent + 1 WHERE IMEI = %I .ft P .fi .UNINDENT .INDENT 0.0 .TP .B refresh_phone_status Update phone status (battery, signal). .sp Default value: .sp .nf .ft C UPDATE phones SET TimeOut= (NOW() + INTERVAL 10 SECOND) + 0, Battery = %1, SignalStrength = %2 WHERE IMEI = %I .ft P .fi .sp Query specific parameters: .INDENT 7.0 .TP .B \fB%1\fP battery percent .TP .B \fB%2\fP signal percent .UNINDENT .UNINDENT .SH AUTHOR Michal Čihař .SH COPYRIGHT 2009-2012, Michal Čihař .\" Generated by docutils manpage writer. .\" .