http://marcin-wiacek.fkn.pl/english/zips/mygnokii.tar.gz
[gnokii.git] / include / gsm-sms.h
index 3cde6f3..fac18b9 100644 (file)
 /*
 
-  $Id$
-
   G N O K I I
 
   A Linux/Unix toolset and driver for Nokia mobile phones.
 
-  Copyright (C) 2001 Pawe³ Kot <pkot@linuxnews.pl>
-
   Released under the terms of the GNU GPL, see file COPYING for more details.
 
-  Include file for SMS library.
-
 */
 
-#ifndef __gnokii_sms_h_
-#define __gnokii_sms_h_
-
-#include "misc.h"
-#include "gsm-error.h"
-
-/* Maximum length of SMS center name */
-
-#define GSM_MAX_SMS_CENTER_NAME_LENGTH (20)
-
-/* Limits of SMS messages. */
-
-#define GSM_MAX_SMS_CENTER_LENGTH  (40)
-#define GSM_MAX_SENDER_LENGTH      (40)
-#define GSM_MAX_DESTINATION_LENGTH (40)
+#ifndef __gsm_sms_h
+#define __gsm_sms_h
 
-#define GSM_MAX_SMS_LENGTH         (160)
-#define GSM_MAX_8BIT_SMS_LENGTH    (140)
+#include "gsm-common.h"
+#include "gsm-datetime.h"
 
-#define SMS_MAX_ADDRESS_LENGTH      (40)
-
-/* FIXME: what value should be here? (Pawel Kot) */
-#define SMS_MAX_UDH_NUMBER 10
-
-/*** MEMORY INFO ***/
+/* This data-type is used to specify the type of the number. See the official
+   GSM specification 03.40, version 5.3.0, section 9.1.2.5, page 33. */
+typedef enum {
+  GNT_UNKNOWN=0x81,       /* Unknown number */
+  GNT_INTERNATIONAL=0x91, /* International number */
+  GNT_ALPHANUMERIC=0xD0   /* Alphanumeric number */
+} GSM_NumberType;
 
+/* For folder table */
 typedef struct {
-       int Unread; /* Number of unread messages */
-       int Number; /* Number of all messages */
-} GSM_SMSMemoryStatus;
-
-/*** DATE AND TIME ***/
+  int smsnum;
+  u8 folder;
+  int location;
+//future use  GSM_SMSMessage *message;
+} GSM_SMS2Foldertable;
 
+/* This data type is used to hold the current SMS status. */
 typedef struct {
-       int Year;          /* The complete year specification - e.g. 1999. Y2K :-) */
-       int Month;           /* January = 1 */
-       int Day;
-       int Hour;
-       int Minute;
-       int Second;
-       int Timezone;      /* The difference between local time and GMT */
-} SMS_DateTime;
-
-/*** USER DATA HEADER ***/
+  int UnRead;                           /* The number of unread messages */
+  int Number;                           /* The number of messages */
+  GSM_SMS2Foldertable foldertable[255]; /* for 6210/7110 */
+} GSM_SMSStatus;
 
-/* types of User Data Header */
+/* Define datatype for SMS Message Type */
 typedef enum {
-       SMS_NoUDH                = 0x00,
-       SMS_ConcatenatedMessages = 0x01,
-       SMS_OpLogo               = 0x02,
-       SMS_CallerIDLogo         = 0x03,
-       SMS_Ringtone             = 0x04,
-       SMS_VoiceMessage         = 0x05,
-       SMS_FaxMessage           = 0x06,
-       SMS_EmailMessage         = 0x07,
-       SMS_OtherMessage         = 0x08,
-       SMS_BusinessCard         = 0x09,
-       SMS_UnknownUDH           = 0x0a
-} SMS_UDHType;
+  GST_SMS,
+  GST_DR, /* Delivery Report */
+  GST_UN  /* Unknown */
+} GSM_SMSMessageType;
 
-typedef struct {
-       SMS_UDHType Type;
-       union {
-               struct {
-                       unsigned short ReferenceNumber;
-                       unsigned short MaximumNumber;
-                       unsigned short CurrentNumber;
-               } ConcatenatedShortMessage; /* SMS_ConcatenatedMessages */
-               struct {
-                       bool Store;
-                       unsigned short MessageCount;
-               } SpecialSMSMessageIndication; /* SMS_VoiceMessage, SMS_FaxMessage, SMS_EmailMessage, SMS_OtherMessage */
-               struct {
-                       char NetworkCode[6];
-//                     ...
-               } Logo; /* SMS_OpLogo, SMS_CallerIDLogo */
-               struct {
-//                     ...
-               } Ringtone; /* SMS_Ringtone */
-       } u;
-} SMS_UDHInfo;
+#define GST_INBOX       0;    /* Mobile Terminated (MT) message - Inbox message  */
+#define GST_OUTBOX      1;    /* Mobile Originated (MO) message - Outbox message */
+#define GST_7110_INBOX  0x08; /* Inbox in 6210/7110 */
+#define GST_7110_OUTBOX 0x10; /* Outbox in 6210/7110 */
 
+/* Datatype for SMS status */
 typedef enum {
-       SMS_PID, /* Set Protocol Identifier to `Return Call Message' */
-       SMS_DCS, /* Set Data Coding Scheme "to indicate the type of message waiting and whether there are some messages or no messages" */
-       SMS_UDH  /* Use User Data Header - Special SMS Message Indication; the maximium level of information, may not be supported by all phones */
-} SMS_MessageWaitingType;
-
-/*** DATA CODING SCHEME ***/
+  GSS_SENTREAD       = 0x01, /* Sent or read message */
+  GSS_NOTSENTREAD    = 0x03, /* Not sent or not read message */
+  GSS_UNKNOWN       = 0x05, /* RTH FIXME: ? */
+  GSS_TEMPLATE      = 0x07  /* Template ? */
+} GSM_SMSMessageStatus;
 
+/* SMS Messages sent as... */
 typedef enum {
-       SMS_GeneralDataCoding,
-       SMS_MessageWaiting
-} SMS_DataCodingSchemeType;
+  GSMF_Text   = 0x00, /* Plain text message. */
+  GSMF_Fax    = 0x22, /* Fax message. */
+  GSMF_Voice  = 0x24, /* Voice mail message. */
+  GSMF_ERMES  = 0x25, /* ERMES message. */
+  GSMF_Paging = 0x26, /* Paging. */
+  GSMF_UCI    = 0x2d, /* Email message in 8110i. */
+  GSMF_Email  = 0x32, /* Email message. */
+  GSMF_X400   = 0x31  /* X.400 message. */
+} GSM_SMSMessageFormat;
 
+/* Validity of SMS Messages. */
+/* Ready values for TP-VP. Don't give them for function packing SMS validity
+   (creating TP-VP from validity value in minutes) */
 typedef enum {
-       SMS_DefaultAlphabet = 0x00,
-       SMS_8bit            = 0x01,
-       SMS_UCS2            = 0x02
-} SMS_AlphabetType;
-
+  GSMV_1_Hour   = 0x0b,
+  GSMV_6_Hours  = 0x47,
+  GSMV_24_Hours = 0xa7,
+  GSMV_72_Hours = 0xa9,
+  GSMV_1_Week   = 0xad,
+  GSMV_Max_Time = 0xff
+} GSM_SMSMessageValidity;
+
+/* 7 bit SMS Coding type */
 typedef enum {
-       SMS_VoiceMail = 0x00,
-       SMS_Fax       = 0x01,
-       SMS_Email     = 0x02,
-       SMS_Text      = 0x03,
-       SMS_Other     = 0x04
-} SMS_IndicationType;
+  GSM_Coding_Unicode = 0x01,
+  GSM_Coding_Default = 0x02,
+  GSM_Coding_8bit    = 0x03
+} GSM_Coding_Type;
 
+/* Define datatype for SMS Message Center */
 typedef struct {
-       SMS_DataCodingSchemeType Type;
-       union {
-               struct {
-                       unsigned short Class; /* 0 - no class
-                                                1 - Class 0
-                                                2 - Class 1
-                                                3 - Class 2
-                                                4 - Class 3 */
-                       bool Compressed;
-                       SMS_AlphabetType Alphabet;
-               } General;
-               struct {
-                       bool Discard;
-                       SMS_AlphabetType Alphabet; /* ucs16 not supported */
-                       bool Active;
-                       SMS_IndicationType Type;
-               } MessageWaiting;
-       } u;
-} SMS_DataCodingScheme;
-
-/*** VALIDITY PERIOD ***/
+  int No;                                          /* Number of the SMSC in the phone memory. */
+  char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH];       /* Name of the SMSC. */
+  GSM_SMSMessageFormat Format;                     /* SMS is sent as text/fax/paging/email. */
+  GSM_SMSMessageValidity Validity;                 /* Validity of SMS Message. */
+  char Number[GSM_MAX_SMS_CENTER_LENGTH];          /* Number of the SMSC. */
+  char DefaultRecipient[GSM_MAX_RECIPIENT_LENGTH]; /* Number of default recipient */
+} GSM_MessageCenter;
 
-typedef enum {
-       SMS_NoValidityPeriod = 0x00,
-       SMS_EnhancedFormat   = 0x01,
-       SMS_RelativeFormat   = 0x02,
-       SMS_AbsoluteFormat   = 0x03
-} SMS_ValidityPeriodFormat;
+/* Define datatype for Cell Broadcast message */
+typedef struct {
+  int Channel;                                      /* channel number */
+  char Message[GSM_MAX_CB_MESSAGE + 1];
+  int New;
+} GSM_CBMessage;
 
+/* types of User Data Header */
 typedef enum {
-       SMS_EnhancedNoValidityPeriod  = 0x00,
-       SMS_EnhancedRelativeFormat    = 0x01,
-       SMS_EnhancedRelativeSeconds   = 0x02, /* Only one ocetet more is used */
-       SMS_EnhancedRelativeSemiOctet = 0x03  /* 3 octets contain relative time in hours, minutes and seconds in semi-octet representation */
-} SMS_EnhancedValidityPeriodType;
+  GSM_NoUDH,
+  GSM_ConcatenatedMessages,
+  GSM_OpLogo,
+  GSM_CallerIDLogo,
+  GSM_RingtoneUDH,
+  GSM_EnableVoice,
+  GSM_DisableVoice,
+  GSM_EnableEmail,
+  GSM_DisableEmail,
+  GSM_EnableFax,
+  GSM_DisableFax,
+  GSM_VoidSMS,
+  GSM_HangSMS,
+  GSM_BugSMS,
+  GSM_UnknownUDH, //Gnokii doesn't know this UDH
+  GSM_WAPBookmarkUDH,
+  GSM_WAPBookmarkUDHLong,
+  GSM_WAPSettingsUDH,
+  GSM_CalendarNoteUDH,
+  GSM_CalendarNoteUDH2,
+  GSM_PhonebookUDH,
+  GSM_ProfileUDH,
+} GSM_UDH;
+
+/* Define datatype for SMS messages, used for getting SMS messages from the
+   phones memory. */
+typedef struct {
+  GSM_Coding_Type Coding;
+  GSM_DateTime Time;                            /* Date of reception/response of messages. */
+  GSM_DateTime SMSCTime;                        /* Date of SMSC response if DeliveryReport messages. */
+  int Length;                                    /* Length of the SMS message. */
+  int Validity;                                  /* Validity Period of the SMS message. */
+  GSM_UDH UDHType;                               /* If UDH is present - type of UDH */
+  unsigned char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH]; /* If UDH is present - content of UDH */
+  unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1];  /* Room for null term. */
+  GSM_MessageCenter MessageCenter;               /* SMS Center. */
+  char Sender[GSM_MAX_SENDER_LENGTH + 1];        /* Sender of the SMS message. */
+  char Destination[GSM_MAX_DESTINATION_LENGTH+1];/* Destination of the message. */
+  int MessageNumber;                             /* Location in the memory, where SMS is saved */
+  GSM_MemoryType MemoryType;                     /* Type of memory message is stored in. */
+  GSM_SMSMessageType Type;                       /* Type of the SMS message */
+  GSM_SMSMessageStatus Status;                   /* Status of the SMS message */
+  int Class;                                     /* Class Message: 0, 1, 2, 3 or none; see GSM 03.38 */
+  bool Compression;                              /* Indicates whether SMS contains compressed data */
+  int Location;                                  /* Location in the memory, when save SMS */
+  bool ReplyViaSameSMSC;                         /* Indicates whether "Reply via same center" is set */
+  int folder;                                    /* Folder: 0-Inbox,1-Outbox, etc. */
+  bool SMSData;                                 /* if folder contains sender, SMSC number and sending date */
+  unsigned char Name[25+1];                      /* Name in Nokia 6210/7110, etc. Ignored in other */
+} GSM_SMSMessage;
 
 typedef struct {
-       bool extension; /* we need to set it to 0 at the moment; FIXME: how to handle `1' here? */
-       bool single_shot;
-       SMS_EnhancedValidityPeriodType type;
-       union {
-               unsigned short relative;
-               unsigned short seconds;
-               SMS_DateTime hms;
-       } period;
-} SMS_EnhancedValidityPeriod;
+  int number;
+  GSM_SMSMessage SMS[6];
+} GSM_MultiSMSMessage;
 
-/* Validity of SMS Messages. */
+/* Maximal number of SMS folders */
+/* #define MAX_SMS_FOLDERS 10 */
+#define MAX_SMS_FOLDERS 24
 
-typedef enum {
-       SMS_V1H   = 0x0b,
-       SMS_V6H   = 0x47,
-       SMS_V24H  = 0xa7,
-       SMS_V72H  = 0xa9,
-       SMS_V1W   = 0xad,
-       SMS_VMax  = 0xff
-} SMS_ValidityPeriod;
+typedef struct {
+  char Name[15];     /* Name for SMS folder */
+  u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */
+  u8 number;         /* number of SMS messages in that folder*/
+} GSM_OneSMSFolder;
 
 typedef struct {
-       SMS_ValidityPeriodFormat VPF;
-       union {
-               SMS_EnhancedValidityPeriod Enhanced;
-               SMS_ValidityPeriod Relative; /* 8 bit */
-               SMS_DateTime Absolute;
-       } u;
-} SMS_MessageValidity;
+  GSM_OneSMSFolder Folder[MAX_SMS_FOLDERS];
+  u8 FoldersID[MAX_SMS_FOLDERS]; // ID specific for this folder and phone.
+                                // Used in internal functions. Do not use it.
+  u8 number; //number of SMS folders
+} GSM_SMSFolders;
+
+/* Identifiers for Smart Messaging 3.0 multipart SMS */
+#define SM30_ISOTEXT      0 // ISO 8859-1 text
+#define SM30_UNICODETEXT  1
+#define SM30_OTA          2
+#define SM30_RINGTONE     3                     
+#define SM30_PROFILENAME  4
+#define SM30_SCREENSAVER  6
+
+/* TP-Message-Type-Indicator */
+/* See GSM 03.40 version 6.1.0 Release 1997 Section 9.2.3.1 */
+typedef enum {                 
+       SMS_Deliver = 0x00, /* when we save SMS in Inbox */
+       SMS_Deliver_Report, 
+       SMS_Status_Report,  /* Delivery Report received by phone */
+       SMS_Command,
+       SMS_Submit,         /* when we send SMS or save it in Outbox */
+       SMS_Submit_Report  
+} SMS_MessageType;
 
+/* Structure to hold UDH Header */
+typedef struct {
+  GSM_UDH UDHType;     /* Type */
+  int Length;          /* Length */
+  unsigned char *Text; /* Text */
+} GSM_UDHHeader;
 
-/* This data-type is used to specify the type of the number. See the official
-   GSM specification 03.40, version 6.1.0, section 9.1.2.5, page 35-37. */
-typedef enum {
-       SMS_Unknown       = 0x81, /* Unknown number */
-       SMS_International = 0x91, /* International number */
-       SMS_National      = 0xa1, /* National number */
-       SMS_Network       = 0xb1, /* Network specific number */
-       SMS_Subscriber    = 0xc1, /* Subscriber number */
-       SMS_Alphanumeric  = 0xd0, /* Alphanumeric number */
-       SMS_Abbreviated   = 0xe1  /* Abbreviated number */
-} SMS_NumberType;
+typedef struct {
+  unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1];
+    /* TP-User-Data. See GSM 03.40 section 9.2.3.24. Room for null term. */
 
-/*** MESSAGE CENTER ***/
+  unsigned char Number[GSM_MAX_SENDER_LENGTH + 1];
+ /*In SMS-Deliver       TP-Originating-Address.See GSM 03.40 section 9.2.3.7 */
+ /*In SMS-Submit        TP-Destination-Address.See GSM 03.40 section 9.2.3.8 */
+ /*In SMS-Status-Report TP-Recipient-Address.  See GSM 03.40 section 9.2.3.14*/
 
-typedef enum {
-       SMS_FText   = 0x00, /* Plain text message. */
-       SMS_FFax    = 0x22, /* Fax message. */
-       SMS_FVoice  = 0x24, /* Voice mail message. */
-       SMS_FERMES  = 0x25, /* ERMES message. */
-       SMS_FPaging = 0x26, /* Paging. */
-       SMS_FUCI    = 0x2d, /* Email message in 8110i. */
-       SMS_FEmail  = 0x32, /* Email message. */
-       SMS_FX400   = 0x31  /* X.400 message. */
-} SMS_MessageFormat;
+  unsigned char SMSCNumber[GSM_MAX_SMS_CENTER_LENGTH];
+    /* SMSC number */
 
-typedef struct {
-       int                     No;                                     /* Number of the SMSC in the phone memory. */
-       SMS_NumberType          Type;
-       char                    Name[GSM_MAX_SMS_CENTER_NAME_LENGTH];   /* Name of the SMSC. */
-       SMS_MessageFormat       Format;                                 /* SMS is sent as text/fax/paging/email. */
-       SMS_ValidityPeriod      Validity;                               /* Validity of SMS Message. */
-       char                    Number[GSM_MAX_SMS_CENTER_LENGTH];      /* Number of the SMSC. */
-       char                    Recipient[GSM_MAX_SMS_CENTER_LENGTH];   /* Number of the default recipient. */
-} SMS_MessageCenter;
+  unsigned char TPPID;
+    /* TP-Protocol-Identifier. See GSM 03.40 section 9.2.3.9 */
 
-/*** SHORT MESSAGE CORE ***/
+  unsigned char TPDCS;
+    /* TP-Data-Coding-Scheme. See GSM 03.40 section 9.2.3.10 */
 
-typedef struct {
-       SMS_NumberType type;
-       char number[SMS_MAX_ADDRESS_LENGTH];
-} SMS_Number;
-
-typedef enum {                     /* Bits meaning */
-       SMS_Deliver         = 0x00, /* 00 0 First 2 digits are taken from */
-       SMS_Delivery_Report = 0x01, /* 00 1 GSM 03.40 version 6.1.0 Release 1997 */
-       SMS_Submit          = 0x02, /* 01 0 */
-       SMS_Submit_Report   = 0x03, /* 01 1 */
-       SMS_Command         = 0x04, /* 10 0 mark a report */
-       SMS_Status_Report   = 0x05, /* 10 1 Section 9.2.3.1; 3rd digit is to */
-       SMS_Picture         = 0x07  /* Looks like Happy N*kia Engineers (TM) invention */
-} SMS_MessageType;
+  unsigned char DeliveryDateTime[7];
+ /* For SMS-Submit        TP-Validity-Period. See GSM 03.40 section 9.2.3.12 */
+ /* For SMS-Status-Report TP-Discharge Time.  See GSM 03.40 section 9.2.3.13 */
 
-typedef enum {
-       SMS_Enquiry            = 0x00, /* Enquiry relating to previosly submitted short message; sets SRR to 1 */
-       SMS_CancelStatusReport = 0x01, /* Cancel Status Report Request relating to previously submitted short message; sets SRR to 0 */
-       SMS_DeleteSM           = 0x02, /* Delete previousle submitted Short Message; sets SRR to 0 */
-       SMS_EnableStatusReport = 0x03  /* Enable Status Report Request relating to previously submitted short message; sets SRR to 0 */
-} SMS_CommandType;
+  unsigned char SMSCDateTime[7];
+    /* TP-Service-Centre-Time-Stamp in SMS-Status-Report.
+       See GSM 03.40 section 9.2.3.11 */
 
-typedef struct {
-       SMS_CommandType Type;
-} SMS_MessageCommand;
+  unsigned char TPStatus;
+    /* TP-Status in SMS-Status-Report. See GSM 03.40 section 9.2.3.15 */
 
-/* Datatype for SMS status */
-typedef enum {
-       SMS_Read   = 0x01,
-       SMS_Unread = 0x03,
-       SMS_Sent   = 0x05,
-       SMS_Unsent = 0x07
-} SMS_MessageStatus;
+  unsigned char TPUDL;
+    /* TP-User-Data-Length. See GSM 03.40 section 9.2.3.16 */
 
-/* In contrast to GSM_MemoryType, SMS_MemoryType is phone dependant */
-typedef enum {
-       GMT_IN = 0x08, /* Inbox in 6210/7110 */
-       GMT_OU = 0x10, /* Outbox in 6210/7110 */
-       GMT_AR = 0x18, /* Archive in 6210/6110 */
-       GMT_TE = 0x20, /* Templates in 6210/7110 */
-       GMT_F1 = 0x29, /* 1st CUSTOM FOLDER in 6210/7110*/
-       GMT_F2 = 0x31,
-       GMT_F3 = 0x39,
-       GMT_F4 = 0x41,
-       GMT_F5 = 0x49,
-       GMT_F6 = 0x51,
-       GMT_F7 = 0x59,
-       GMT_F8 = 0x61,
-       GMT_F9 = 0x69,
-       GMT_F10 = 0x71,
-       GMT_F11 = 0x79,
-       GMT_F12 = 0x81,
-       GMT_F13 = 0x89,
-       GMT_F14 = 0x91,
-       GMT_F15 = 0x99,
-       GMT_F16 = 0xA1,
-       GMT_F17 = 0xA9,
-       GMT_F18 = 0xB1,
-       GMT_F19 = 0xB9,
-       GMT_F20 = 0xC1 /* 20th CUSTOM FOLDER in 6210/7110 */
-} SMS_MemoryType;
-
-/* Define datatype for SMS messages, describes precisely GSM Spec 03.40 */
-typedef struct {
-       /* Specification fields */
-       SMS_MessageType Type;                          /* Message Type Indicator - 2 bits (9.2.3.1) */
-       bool MoreMessages;                             /* More Messages to Send (9.2.3.2) */
-       bool ReplyViaSameSMSC;                         /* Reply Path (9.2.3.17) - `Reply via same centre' in the phone */
-       bool RejectDuplicates;                         /* Reject Duplicates (9.2.3.25) */
-       bool Report;                                   /* Status Report (9.2.3.4, 9.2.3.5 & 9.2.3.26) - `Delivery reports' in the phone */
-
-       unsigned short Number;                         /* Message Number - 8 bits (9.2.3.18) */
-       unsigned short Reference;                      /* Message Reference - 8 bit (9.2.3.6) */
-       unsigned short PID;                            /* Protocol Identifier - 8 bit (9.2.3.9) */
-       unsigned short ReportStatus;                   /* Status - 8 bit (9.2.3.15), Failure Cause (9.2.3.22) */
-       unsigned short Length;                         /* User Data Length (9.2.3.16), Command Data Length (9.2.3.20) */
-
-       SMS_MessageCenter MessageCenter;               /* SMSC Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */
-       SMS_Number RemoteNumber;                       /* Origination, destination, Recipient Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */
-       unsigned char MessageText[GSM_MAX_SMS_LENGTH]; /* User Data (9.2.3.24), Command Data (9.2.3.21) */
-       SMS_DataCodingScheme DCS;                      /* Data Coding Scheme (9.2.3.10) */
-       SMS_MessageValidity Validity;                  /* Validity Period Format & Validity Period (9.2.3.3 & 9.2.3.12) - `Message validity' in the phone */
-  
-       unsigned short UDH_No;                         /* Number of presend UDHs */
-       unsigned int UDH_Length;                       /* Length of the whole UDH */
-       SMS_UDHInfo UDH[SMS_MAX_UDH_NUMBER];           /* User Data Header Indicator & User Data Header (9.2.3.23 & 9.2.3.24) */
-
-       SMS_DateTime SMSCTime;                         /* Service Centre Time Stamp (9.2.3.11) */
-       SMS_DateTime Time;                             /* Discharge Time (9.2.3.13) */
-
-       /* Other fields */
-       SMS_MemoryType MemoryType;                     /* memoryType (for 6210/7110: folder indicator */
-       SMS_MessageStatus Status;                      /* Status of the message: sent/read or unsent/unread */
-
-//     SMS_CommandType Command;                       /* Command Type - 8 bits (9.2.3.19); FIXME: use it!!!! */
-//     unsigned char Parameter[???];                  /* Parameter Indicator (9.2.3.27); FIXME: how to use it??? */
-} GSM_SMSMessage;
+  unsigned char TPVP;
+    /* TP-Validity Period in SMS-Submit. See GSM 03.40 section 9.2.3.12 */
 
-/* Define the layout of the SMS message header */
-typedef struct {
-       bool IsSupported;
-       short MoreMessages;
-       short ReplyViaSameSMSC;
-       short RejectDuplicates;
-       short Report;
-       short Number;
-       short Reference;
-       short PID;
-       short ReportStatus;
-       short Length;
-       short DataCodingScheme;
-       short Validity;
-       short UserDataHeader;
-       short MessageCenter;
-       bool IsMessageCenterCoded;
-       short RemoteNumber;
-       bool IsRemoteNumberCoded;
-       short SMSCTime;
-       short Time;
-       short MemoryType;
-       short Status;
-       short UserData;
-       bool IsUserDataCoded;
-} SMSMessage_Layout;
-
-/* Define set of SMS Headers for the phone series */
-typedef struct {
-       unsigned short Type;
-       SMSMessage_Layout Deliver;
-       SMSMessage_Layout Submit;
-       SMSMessage_Layout DeliveryReport;
-       SMSMessage_Layout Picture;
-} SMSMessage_PhoneLayout;
+  unsigned char TPMR;
+    /* TP-Message Reference in SMS-Submit. See GSM 03.40 section 9.2.3.6 */
 
-extern SMSMessage_PhoneLayout layout;
+  unsigned char firstbyte;
+    /* Byte contains in SMS-Deliver:
+       TP-Message-Type-Indicator     (2 bits) See GSM 03.40 section 9.2.3.1
 
-/*** FOLDERS ***/
+       TP-More-Messages-To-Send      (1 bit). See GSM 03.40 section 9.2.3.2
 
-/* Maximal number of SMS folders */
-#define MAX_SMS_FOLDERS 24
+       TP-Reply-Path                 (1 bit). See GSM 03.40 section 9.2.3.17
+       TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23
+       TP-Status-Report-Indicator    (1 bit). See GSM 03.40 section 9.2.3.4
 
-/* Datatype for SMS folders ins 6210/7110 */
-typedef struct {
-       char Name[15];     /* Name for SMS folder */
-       bool SMSData;      /* if folder contains sender, SMSC number and sending date */
-       u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */
-       u8 number;         /* number of SMS messages in that folder*/
-       u8 FolderID;       /* ID od fthe current folder */
-} SMS_Folder;
+       Byte contains in SMS-Submit:
 
-typedef struct {
-       SMS_Folder Folder[MAX_SMS_FOLDERS];
-       u8 FolderID[MAX_SMS_FOLDERS]; /* ID specific for this folder and phone. */
-                                      /* Used in internal functions. Do not use it. */
-       u8 number;                     /* number of SMS folders */
-} SMS_FolderList;
+       TP-Message-Type-Indicator     (2 bits) See GSM 03.40 section 9.2.3.1
 
-/*** CELL BROADCAST ***/
+       TP-Reject-Duplicates          (1 bit). See GSM 03.40 section
+       TP-Validity-Period-Format     (2 bits).See GSM 03.40 section 9.2.3.3
 
-#define GSM_MAX_CB_MESSAGE         (160)
+       TP-Reply-Path                 (1 bit). See GSM 03.40 section 9.2.3.17
+       TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23
+       TP-Status-Report-Request      (1 bit). See GSM 03.40 section 9.2.3.5 */
+} GSM_ETSISMSMessage;
 
-/* Define datatype for Cell Broadcast message */
-typedef struct {
-       int Channel;                                      /* channel number */
-       char Message[GSM_MAX_CB_MESSAGE + 1];
-       int New;
-} GSM_CBMessage;
+int   GSM_PackSemiOctetNumber  (u8 *Number, u8 *Output, bool semioctet);
+char *GSM_UnpackSemiOctetNumber(u8 *Number, bool semioctet);
+
+int GSM_UnpackEightBitsToSeven(int fillbits, int in_length, int out_length, unsigned char *input, unsigned char *output);
+int GSM_PackSevenBitsToEight  (int offset, unsigned char *input, unsigned char *output);
+
+GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length);
+GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
+
+GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req);
+
+GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
 
-extern int EncodePDUSMS(GSM_SMSMessage *SMS, char *frame);
-extern GSM_Error DecodePDUSMS(unsigned char *message, GSM_SMSMessage *SMS, int MessageLength);
+GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
 
-/* Do not use these yet */
-extern GSM_Error EncodeTextSMS();
-extern GSM_Error DecodeTextSMS(unsigned char *message, GSM_SMSMessage *SMS);
+void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
+GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType);
 
-/* We really do need this in the other code */
-extern char *GetBCDNumber(u8 *Number);
-extern int SemiOctetPack(char *Number, unsigned char *Output, SMS_NumberType type);
+int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
+    unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding);
+void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS,
+    unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding);
 
-#endif /* __gnokii_sms_h_ */
+#endif /* __gsm_sms_h */