5 A Linux/Unix toolset and driver for Nokia mobile phones.
7 Released under the terms of the GNU GPL, see file COPYING for more details.
14 #include "gsm-common.h"
15 #include "gsm-datetime.h"
17 /* This data-type is used to specify the type of the number. See the official
18 GSM specification 03.40, version 5.3.0, section 9.1.2.5, page 33. */
20 GNT_UNKNOWN=0x81, /* Unknown number */
21 GNT_INTERNATIONAL=0x91, /* International number */
22 GNT_ALPHANUMERIC=0xD0 /* Alphanumeric number */
25 /* For folder table */
30 //future use GSM_SMSMessage *message;
31 } GSM_SMS2Foldertable;
33 /* This data type is used to hold the current SMS status. */
35 int UnRead; /* The number of unread messages */
36 int Number; /* The number of messages */
37 GSM_SMS2Foldertable foldertable[255]; /* for 6210/7110 */
40 /* Define datatype for SMS Message Type */
43 GST_DR, /* Delivery Report */
47 #define GST_INBOX 0; /* Mobile Terminated (MT) message - Inbox message */
48 #define GST_OUTBOX 1; /* Mobile Originated (MO) message - Outbox message */
49 #define GST_7110_INBOX 0x08; /* Inbox in 6210/7110 */
50 #define GST_7110_OUTBOX 0x10; /* Outbox in 6210/7110 */
52 /* Datatype for SMS status */
54 GSS_SENTREAD = 0x01, /* Sent or read message */
55 GSS_NOTSENTREAD = 0x03, /* Not sent or not read message */
56 GSS_UNKNOWN = 0x05, /* RTH FIXME: ? */
57 GSS_TEMPLATE = 0x07 /* Template ? */
58 } GSM_SMSMessageStatus;
60 /* SMS Messages sent as... */
62 GSMF_Text = 0x00, /* Plain text message. */
63 GSMF_Fax = 0x22, /* Fax message. */
64 GSMF_Voice = 0x24, /* Voice mail message. */
65 GSMF_ERMES = 0x25, /* ERMES message. */
66 GSMF_Paging = 0x26, /* Paging. */
67 GSMF_UCI = 0x2d, /* Email message in 8110i. */
68 GSMF_Email = 0x32, /* Email message. */
69 GSMF_X400 = 0x31 /* X.400 message. */
70 } GSM_SMSMessageFormat;
72 /* Validity of SMS Messages. */
73 /* Ready values for TP-VP. Don't give them for function packing SMS validity
74 (creating TP-VP from validity value in minutes) */
82 } GSM_SMSMessageValidity;
84 /* 7 bit SMS Coding type */
86 GSM_Coding_Unicode = 0x01,
87 GSM_Coding_Default = 0x02,
88 GSM_Coding_8bit = 0x03
91 /* Define datatype for SMS Message Center */
93 int No; /* Number of the SMSC in the phone memory. */
94 char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */
95 GSM_SMSMessageFormat Format; /* SMS is sent as text/fax/paging/email. */
96 GSM_SMSMessageValidity Validity; /* Validity of SMS Message. */
97 char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */
98 char DefaultRecipient[GSM_MAX_RECIPIENT_LENGTH]; /* Number of default recipient */
101 /* Define datatype for Cell Broadcast message */
103 int Channel; /* channel number */
104 char Message[GSM_MAX_CB_MESSAGE + 1];
108 /* types of User Data Header */
111 GSM_ConcatenatedMessages,
124 GSM_UnknownUDH, //Gnokii doesn't know this UDH
126 GSM_WAPBookmarkUDHLong,
129 GSM_CalendarNoteUDH2,
134 /* Define datatype for SMS messages, used for getting SMS messages from the
137 GSM_Coding_Type Coding;
138 GSM_DateTime Time; /* Date of reception/response of messages. */
139 GSM_DateTime SMSCTime; /* Date of SMSC response if DeliveryReport messages. */
140 int Length; /* Length of the SMS message. */
141 int Validity; /* Validity Period of the SMS message. */
142 GSM_UDH UDHType; /* If UDH is present - type of UDH */
143 unsigned char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH]; /* If UDH is present - content of UDH */
144 unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1]; /* Room for null term. */
145 GSM_MessageCenter MessageCenter; /* SMS Center. */
146 char Sender[GSM_MAX_SENDER_LENGTH + 1]; /* Sender of the SMS message. */
147 char Destination[GSM_MAX_DESTINATION_LENGTH+1];/* Destination of the message. */
148 int MessageNumber; /* Location in the memory, where SMS is saved */
149 GSM_MemoryType MemoryType; /* Type of memory message is stored in. */
150 GSM_SMSMessageType Type; /* Type of the SMS message */
151 GSM_SMSMessageStatus Status; /* Status of the SMS message */
152 int Class; /* Class Message: 0, 1, 2, 3 or none; see GSM 03.38 */
153 bool Compression; /* Indicates whether SMS contains compressed data */
154 int Location; /* Location in the memory, when save SMS */
155 bool ReplyViaSameSMSC; /* Indicates whether "Reply via same center" is set */
156 int folder; /* Folder: 0-Inbox,1-Outbox, etc. */
157 bool SMSData; /* if folder contains sender, SMSC number and sending date */
158 unsigned char Name[25+1]; /* Name in Nokia 6210/7110, etc. Ignored in other */
163 GSM_SMSMessage SMS[6];
164 } GSM_MultiSMSMessage;
166 /* Maximal number of SMS folders */
167 /* #define MAX_SMS_FOLDERS 10 */
168 #define MAX_SMS_FOLDERS 24
171 char Name[15]; /* Name for SMS folder */
172 u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */
173 u8 number; /* number of SMS messages in that folder*/
177 GSM_OneSMSFolder Folder[MAX_SMS_FOLDERS];
178 u8 FoldersID[MAX_SMS_FOLDERS]; // ID specific for this folder and phone.
179 // Used in internal functions. Do not use it.
180 u8 number; //number of SMS folders
183 /* Identifiers for Smart Messaging 3.0 multipart SMS */
184 #define SM30_ISOTEXT 0 // ISO 8859-1 text
185 #define SM30_UNICODETEXT 1
187 #define SM30_RINGTONE 3
188 #define SM30_PROFILENAME 4
189 #define SM30_SCREENSAVER 6
191 /* TP-Message-Type-Indicator */
192 /* See GSM 03.40 version 6.1.0 Release 1997 Section 9.2.3.1 */
194 SMS_Deliver = 0x00, /* when we save SMS in Inbox */
196 SMS_Status_Report, /* Delivery Report received by phone */
198 SMS_Submit, /* when we send SMS or save it in Outbox */
202 /* Structure to hold UDH Header */
204 GSM_UDH UDHType; /* Type */
205 int Length; /* Length */
206 unsigned char *Text; /* Text */
210 unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1];
211 /* TP-User-Data. See GSM 03.40 section 9.2.3.24. Room for null term. */
213 unsigned char Number[GSM_MAX_SENDER_LENGTH + 1];
214 /*In SMS-Deliver TP-Originating-Address.See GSM 03.40 section 9.2.3.7 */
215 /*In SMS-Submit TP-Destination-Address.See GSM 03.40 section 9.2.3.8 */
216 /*In SMS-Status-Report TP-Recipient-Address. See GSM 03.40 section 9.2.3.14*/
218 unsigned char SMSCNumber[GSM_MAX_SMS_CENTER_LENGTH];
222 /* TP-Protocol-Identifier. See GSM 03.40 section 9.2.3.9 */
225 /* TP-Data-Coding-Scheme. See GSM 03.40 section 9.2.3.10 */
227 unsigned char DeliveryDateTime[7];
228 /* For SMS-Submit TP-Validity-Period. See GSM 03.40 section 9.2.3.12 */
229 /* For SMS-Status-Report TP-Discharge Time. See GSM 03.40 section 9.2.3.13 */
231 unsigned char SMSCDateTime[7];
232 /* TP-Service-Centre-Time-Stamp in SMS-Status-Report.
233 See GSM 03.40 section 9.2.3.11 */
235 unsigned char TPStatus;
236 /* TP-Status in SMS-Status-Report. See GSM 03.40 section 9.2.3.15 */
239 /* TP-User-Data-Length. See GSM 03.40 section 9.2.3.16 */
242 /* TP-Validity Period in SMS-Submit. See GSM 03.40 section 9.2.3.12 */
245 /* TP-Message Reference in SMS-Submit. See GSM 03.40 section 9.2.3.6 */
247 unsigned char firstbyte;
248 /* Byte contains in SMS-Deliver:
249 TP-Message-Type-Indicator (2 bits) See GSM 03.40 section 9.2.3.1
251 TP-More-Messages-To-Send (1 bit). See GSM 03.40 section 9.2.3.2
253 TP-Reply-Path (1 bit). See GSM 03.40 section 9.2.3.17
254 TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23
255 TP-Status-Report-Indicator (1 bit). See GSM 03.40 section 9.2.3.4
257 Byte contains in SMS-Submit:
259 TP-Message-Type-Indicator (2 bits) See GSM 03.40 section 9.2.3.1
261 TP-Reject-Duplicates (1 bit). See GSM 03.40 section
262 TP-Validity-Period-Format (2 bits).See GSM 03.40 section 9.2.3.3
264 TP-Reply-Path (1 bit). See GSM 03.40 section 9.2.3.17
265 TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23
266 TP-Status-Report-Request (1 bit). See GSM 03.40 section 9.2.3.5 */
267 } GSM_ETSISMSMessage;
269 int GSM_PackSemiOctetNumber (u8 *Number, u8 *Output, bool semioctet);
270 char *GSM_UnpackSemiOctetNumber(u8 *Number, bool semioctet);
272 int GSM_UnpackEightBitsToSeven(int fillbits, int in_length, int out_length, unsigned char *input, unsigned char *output);
273 int GSM_PackSevenBitsToEight (int offset, unsigned char *input, unsigned char *output);
275 GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length);
276 GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
278 GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req);
280 GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
282 GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
284 void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
285 GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType);
287 int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
288 unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding);
289 void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS,
290 unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding);
292 #endif /* __gsm_sms_h */