7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 2001 Pawe³ Kot <pkot@linuxnews.pl>
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Include file for SMS library.
17 #ifndef __gnokii_sms_h_
18 #define __gnokii_sms_h_
21 #include "gsm-error.h"
23 /* Maximum length of SMS center name */
25 #define GSM_MAX_SMS_CENTER_NAME_LENGTH (20)
27 /* Limits of SMS messages. */
29 #define GSM_MAX_SMS_CENTER_LENGTH (40)
30 #define GSM_MAX_SENDER_LENGTH (40)
31 #define GSM_MAX_DESTINATION_LENGTH (40)
33 #define GSM_MAX_SMS_LENGTH (160)
34 #define GSM_MAX_8BIT_SMS_LENGTH (140)
36 #define SMS_MAX_ADDRESS_LENGTH (40)
38 /* FIXME: what value should be here? (Pawel Kot) */
39 #define SMS_MAX_UDH_NUMBER 10
44 int Unread; /* Number of unread messages */
45 int Number; /* Number of all messages */
46 } GSM_SMSMemoryStatus;
48 /*** DATE AND TIME ***/
51 int Year; /* The complete year specification - e.g. 1999. Y2K :-) */
52 int Month; /* January = 1 */
57 int Timezone; /* The difference between local time and GMT */
60 /*** USER DATA HEADER ***/
62 /* types of User Data Header */
65 SMS_ConcatenatedMessages = 0x01,
67 SMS_CallerIDLogo = 0x03,
69 SMS_VoiceMessage = 0x05,
70 SMS_FaxMessage = 0x06,
71 SMS_EmailMessage = 0x07,
72 SMS_OtherMessage = 0x08,
73 SMS_BusinessCard = 0x09,
81 unsigned short ReferenceNumber;
82 unsigned short MaximumNumber;
83 unsigned short CurrentNumber;
84 } ConcatenatedShortMessage; /* SMS_ConcatenatedMessages */
87 unsigned short MessageCount;
88 } SpecialSMSMessageIndication; /* SMS_VoiceMessage, SMS_FaxMessage, SMS_EmailMessage, SMS_OtherMessage */
92 } Logo; /* SMS_OpLogo, SMS_CallerIDLogo */
95 } Ringtone; /* SMS_Ringtone */
100 SMS_PID, /* Set Protocol Identifier to `Return Call Message' */
101 SMS_DCS, /* Set Data Coding Scheme "to indicate the type of message waiting and whether there are some messages or no messages" */
102 SMS_UDH /* Use User Data Header - Special SMS Message Indication; the maximium level of information, may not be supported by all phones */
103 } SMS_MessageWaitingType;
105 /*** DATA CODING SCHEME ***/
108 SMS_GeneralDataCoding,
110 } SMS_DataCodingSchemeType;
113 SMS_DefaultAlphabet = 0x00,
119 SMS_VoiceMail = 0x00,
124 } SMS_IndicationType;
127 SMS_DataCodingSchemeType Type;
130 unsigned short Class; /* 0 - no class
136 SMS_AlphabetType Alphabet;
140 SMS_AlphabetType Alphabet; /* ucs16 not supported */
142 SMS_IndicationType Type;
145 } SMS_DataCodingScheme;
147 /*** VALIDITY PERIOD ***/
150 SMS_NoValidityPeriod = 0x00,
151 SMS_EnhancedFormat = 0x01,
152 SMS_RelativeFormat = 0x02,
153 SMS_AbsoluteFormat = 0x03
154 } SMS_ValidityPeriodFormat;
157 SMS_EnhancedNoValidityPeriod = 0x00,
158 SMS_EnhancedRelativeFormat = 0x01,
159 SMS_EnhancedRelativeSeconds = 0x02, /* Only one ocetet more is used */
160 SMS_EnhancedRelativeSemiOctet = 0x03 /* 3 octets contain relative time in hours, minutes and seconds in semi-octet representation */
161 } SMS_EnhancedValidityPeriodType;
164 bool extension; /* we need to set it to 0 at the moment; FIXME: how to handle `1' here? */
166 SMS_EnhancedValidityPeriodType type;
168 unsigned short relative;
169 unsigned short seconds;
172 } SMS_EnhancedValidityPeriod;
174 /* Validity of SMS Messages. */
183 } SMS_ValidityPeriod;
186 SMS_ValidityPeriodFormat VPF;
188 SMS_EnhancedValidityPeriod Enhanced;
189 SMS_ValidityPeriod Relative; /* 8 bit */
190 SMS_DateTime Absolute;
192 } SMS_MessageValidity;
195 /* This data-type is used to specify the type of the number. See the official
196 GSM specification 03.40, version 6.1.0, section 9.1.2.5, page 35-37. */
198 SMS_Unknown = 0x81, /* Unknown number */
199 SMS_International = 0x91, /* International number */
200 SMS_National = 0xa1, /* National number */
201 SMS_Network = 0xb1, /* Network specific number */
202 SMS_Subscriber = 0xc1, /* Subscriber number */
203 SMS_Alphanumeric = 0xd0, /* Alphanumeric number */
204 SMS_Abbreviated = 0xe1 /* Abbreviated number */
207 /*** MESSAGE CENTER ***/
210 SMS_FText = 0x00, /* Plain text message. */
211 SMS_FFax = 0x22, /* Fax message. */
212 SMS_FVoice = 0x24, /* Voice mail message. */
213 SMS_FERMES = 0x25, /* ERMES message. */
214 SMS_FPaging = 0x26, /* Paging. */
215 SMS_FUCI = 0x2d, /* Email message in 8110i. */
216 SMS_FEmail = 0x32, /* Email message. */
217 SMS_FX400 = 0x31 /* X.400 message. */
221 int No; /* Number of the SMSC in the phone memory. */
223 char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */
224 SMS_MessageFormat Format; /* SMS is sent as text/fax/paging/email. */
225 SMS_ValidityPeriod Validity; /* Validity of SMS Message. */
226 char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */
227 char Recipient[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the default recipient. */
230 /*** SHORT MESSAGE CORE ***/
234 char number[SMS_MAX_ADDRESS_LENGTH];
237 typedef enum { /* Bits meaning */
238 SMS_Deliver = 0x00, /* 00 0 First 2 digits are taken from */
239 SMS_Delivery_Report = 0x01, /* 00 1 GSM 03.40 version 6.1.0 Release 1997 */
240 SMS_Submit = 0x02, /* 01 0 */
241 SMS_Submit_Report = 0x03, /* 01 1 */
242 SMS_Command = 0x04, /* 10 0 mark a report */
243 SMS_Status_Report = 0x05, /* 10 1 Section 9.2.3.1; 3rd digit is to */
244 SMS_Picture = 0x07 /* Looks like Happy N*kia Engineers (TM) invention */
248 SMS_Enquiry = 0x00, /* Enquiry relating to previosly submitted short message; sets SRR to 1 */
249 SMS_CancelStatusReport = 0x01, /* Cancel Status Report Request relating to previously submitted short message; sets SRR to 0 */
250 SMS_DeleteSM = 0x02, /* Delete previousle submitted Short Message; sets SRR to 0 */
251 SMS_EnableStatusReport = 0x03 /* Enable Status Report Request relating to previously submitted short message; sets SRR to 0 */
255 SMS_CommandType Type;
256 } SMS_MessageCommand;
258 /* Datatype for SMS status */
266 /* In contrast to GSM_MemoryType, SMS_MemoryType is phone dependant */
268 GMT_IN = 0x08, /* Inbox in 6210/7110 */
269 GMT_OU = 0x10, /* Outbox in 6210/7110 */
270 GMT_AR = 0x18, /* Archive in 6210/6110 */
271 GMT_TE = 0x20, /* Templates in 6210/7110 */
272 GMT_F1 = 0x29, /* 1st CUSTOM FOLDER in 6210/7110*/
291 GMT_F20 = 0xC1 /* 20th CUSTOM FOLDER in 6210/7110 */
294 /* Define datatype for SMS messages, describes precisely GSM Spec 03.40 */
296 /* Specification fields */
297 SMS_MessageType Type; /* Message Type Indicator - 2 bits (9.2.3.1) */
298 bool MoreMessages; /* More Messages to Send (9.2.3.2) */
299 bool ReplyViaSameSMSC; /* Reply Path (9.2.3.17) - `Reply via same centre' in the phone */
300 bool RejectDuplicates; /* Reject Duplicates (9.2.3.25) */
301 bool Report; /* Status Report (9.2.3.4, 9.2.3.5 & 9.2.3.26) - `Delivery reports' in the phone */
303 unsigned short Number; /* Message Number - 8 bits (9.2.3.18) */
304 unsigned short Reference; /* Message Reference - 8 bit (9.2.3.6) */
305 unsigned short PID; /* Protocol Identifier - 8 bit (9.2.3.9) */
306 unsigned short ReportStatus; /* Status - 8 bit (9.2.3.15), Failure Cause (9.2.3.22) */
307 unsigned short Length; /* User Data Length (9.2.3.16), Command Data Length (9.2.3.20) */
309 SMS_MessageCenter MessageCenter; /* SMSC Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */
310 SMS_Number RemoteNumber; /* Origination, destination, Recipient Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */
311 unsigned char MessageText[GSM_MAX_SMS_LENGTH]; /* User Data (9.2.3.24), Command Data (9.2.3.21) */
312 SMS_DataCodingScheme DCS; /* Data Coding Scheme (9.2.3.10) */
313 SMS_MessageValidity Validity; /* Validity Period Format & Validity Period (9.2.3.3 & 9.2.3.12) - `Message validity' in the phone */
315 unsigned short UDH_No; /* Number of presend UDHs */
316 unsigned int UDH_Length; /* Length of the whole UDH */
317 SMS_UDHInfo UDH[SMS_MAX_UDH_NUMBER]; /* User Data Header Indicator & User Data Header (9.2.3.23 & 9.2.3.24) */
319 SMS_DateTime SMSCTime; /* Service Centre Time Stamp (9.2.3.11) */
320 SMS_DateTime Time; /* Discharge Time (9.2.3.13) */
323 SMS_MemoryType MemoryType; /* memoryType (for 6210/7110: folder indicator */
324 SMS_MessageStatus Status; /* Status of the message: sent/read or unsent/unread */
326 // SMS_CommandType Command; /* Command Type - 8 bits (9.2.3.19); FIXME: use it!!!! */
327 // unsigned char Parameter[???]; /* Parameter Indicator (9.2.3.27); FIXME: how to use it??? */
330 /* Define the layout of the SMS message header */
334 short ReplyViaSameSMSC;
335 short RejectDuplicates;
342 short DataCodingScheme;
344 short UserDataHeader;
346 bool IsMessageCenterCoded;
348 bool IsRemoteNumberCoded;
354 bool IsUserDataCoded;
357 /* Define set of SMS Headers for the phone series */
360 SMSMessage_Layout Deliver;
361 SMSMessage_Layout Submit;
362 SMSMessage_Layout DeliveryReport;
363 SMSMessage_Layout Picture;
364 } SMSMessage_PhoneLayout;
366 extern SMSMessage_PhoneLayout layout;
370 /* Maximal number of SMS folders */
371 #define MAX_SMS_FOLDERS 24
373 /* Datatype for SMS folders ins 6210/7110 */
375 char Name[15]; /* Name for SMS folder */
376 bool SMSData; /* if folder contains sender, SMSC number and sending date */
377 u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */
378 u8 number; /* number of SMS messages in that folder*/
379 u8 FolderID; /* ID od fthe current folder */
383 SMS_Folder Folder[MAX_SMS_FOLDERS];
384 u8 FolderID[MAX_SMS_FOLDERS]; /* ID specific for this folder and phone. */
385 /* Used in internal functions. Do not use it. */
386 u8 number; /* number of SMS folders */
389 /*** CELL BROADCAST ***/
391 #define GSM_MAX_CB_MESSAGE (160)
393 /* Define datatype for Cell Broadcast message */
395 int Channel; /* channel number */
396 char Message[GSM_MAX_CB_MESSAGE + 1];
400 extern int EncodePDUSMS(GSM_SMSMessage *SMS, char *frame);
401 extern GSM_Error DecodePDUSMS(unsigned char *message, GSM_SMSMessage *SMS, int MessageLength);
402 /* Do not use these yet */
403 extern GSM_Error EncodeTextSMS();
404 extern GSM_Error DecodeTextSMS(unsigned char *message, GSM_SMSMessage *SMS);
406 /* FIXME: make this static */
407 extern char *GetBCDNumber(u8 *Number);
409 #endif /* __gnokii_sms_h_ */