a87900fa51a9528f44f6708e34914e8505d88c58
[gnokii.git] / include / gsm-common.h
1 /*
2
3   G N O K I I
4
5   A Linux/Unix toolset and driver for Nokia mobile phones.
6
7   Released under the terms of the GNU GPL, see file COPYING for more details.
8         
9   Header file for the definitions, enums etc. that are used by all models of
10   handset.
11
12 */
13
14 #ifndef __gsm_common_h
15 #define __gsm_common_h
16
17 #include "misc.h"
18
19 #define MYGNOKII
20
21 /* Maximum length of SMS center name */
22 #define GSM_MAX_SMS_CENTER_NAME_LENGTH  (20)
23
24 /* Limits of SMS messages. */
25 #define GSM_MAX_SMS_CENTER_LENGTH  (40)
26 #define GSM_MAX_RECIPIENT_LENGTH   (40)
27 #define GSM_MAX_SENDER_LENGTH      (40)
28 #define GSM_MAX_DESTINATION_LENGTH (40)
29 #define GSM_MAX_SMS_LENGTH         (160)
30 #define GSM_MAX_SMS_8_BIT_LENGTH   (140)
31 #define GSM_MAX_USER_DATA_HEADER_LENGTH (140)
32 /* The maximum length of an uncompressed concatenated short message is
33    255 * 153 = 39015 default alphabet characters */
34 #define GSM_MAX_CONCATENATED_SMS_LENGTH (39015)
35
36 #define GSM_MAX_CB_MESSAGE         (160)
37
38 /* Correct for phones in fbus-6110.c */
39 /* For other translation could be required */
40 #define PHONEKEY_1              0x01
41 #define PHONEKEY_2              0x02
42 #define PHONEKEY_3              0x03
43 #define PHONEKEY_4              0x04
44 #define PHONEKEY_5              0x05
45 #define PHONEKEY_6              0x06
46 #define PHONEKEY_7              0x07
47 #define PHONEKEY_8              0x08
48 #define PHONEKEY_9              0x09
49 #define PHONEKEY_0              0x0a
50 #define PHONEKEY_HASH           0x0b /* # */
51 #define PHONEKEY_ASTERISK       0x0c /* * */
52 #define PHONEKEY_POWER          0x0d
53 #define PHONEKEY_INCREASEVOLUME 0x10 /* doesn't available in some phones as separate button: ie. N5110 */
54 #define PHONEKEY_DECREASEVOLUME 0x11 /* doesn't available in some phones as separate button: ie. N5110 */
55 #define PHONEKEY_UP             0x17   
56 #define PHONEKEY_DOWN           0x18 
57 #define PHONEKEY_MENU           0x19
58 #define PHONEKEY_NAMES          0x1a /* doesn't available in some phone: ie. N5110 */
59 #define PHONEKEY_GREEN          0x0e /* in some phone ie. N5110 sometimes works identical to POWER */
60 #define PHONEKEY_RED            0x0f /* (c) key in some phone: ie. N5110 */
61
62 /* Correct for phones in fbus-6110.c */
63 /* For other translation could be required */
64 #define PRESSPHONEKEY   0x01
65 #define RELEASEPHONEKEY 0x02
66
67 /* Limits for IMEI, Revision and Model string storage. */
68 #define GSM_MAX_IMEI_LENGTH     (20)
69 #define GSM_MAX_REVISION_LENGTH (20)
70 #define GSM_MAX_MODEL_LENGTH    (10)
71
72 /* In 6210 test 57 there seems to be 75 chars */
73 #define NM_MAX_SCREEN_WIDTH 75
74
75 /* Power source types */
76 typedef enum {
77   GPS_ACDC=1, /* AC/DC powered (charging) */
78   GPS_BATTERY /* Internal battery */
79 } GSM_PowerSource;
80
81 /* Definition of security codes. */
82 typedef enum {
83   GSCT_SecurityCode = 0x01, /* Security code. */
84   GSCT_Pin,                 /* PIN. */
85   GSCT_Pin2,                /* PIN 2. */
86   GSCT_Puk,                 /* PUK. */
87   GSCT_Puk2,                /* PUK 2. */
88   GSCT_None                 /* Code not needed. */
89 } GSM_SecurityCodeType;
90
91 /* Security code definition. */
92 typedef struct {
93   GSM_SecurityCodeType Type; /* Type of the code. */
94   char Code[10];             /* Actual code. */
95 } GSM_SecurityCode;
96
97 /* Define an enum for specifying memory types for retrieving phonebook
98    entries, SMS messages etc. This type is not mobile specific - the model
99    code should take care of translation to mobile specific numbers - see 6110
100    code.
101    01/07/99:  Two letter codes follow GSM 07.07 release 6.2.0
102 */
103 typedef enum {
104   GMT_ME, /* Internal memory of the mobile equipment */
105   GMT_SM, /* SIM card memory */
106   GMT_FD, /* Fixed dial numbers */
107   GMT_ON, /* Own numbers */
108   GMT_EN, /* Emergency numbers */
109   GMT_DC, /* Dialled numbers */
110   GMT_RC, /* Received numbers */
111   GMT_MC, /* Missed numbers */
112   GMT_LD, /* Last dialed */
113   GMT_MT, /* combined ME and SIM phonebook */
114   GMT_TA, /* for compatibility only: TA=computer memory */
115   GMT_CB, /* Currently selected memory */
116   GMT_CG, /* Caller groups */
117   GMT_XX = 0xff /* Error code for unknown memory type (returned by fbus-xxxx functions. */
118 } GSM_MemoryType;
119
120 /* This define speed dialing entries. */
121 typedef struct {
122   int Number;                /* Which number is used to dialing? */
123   GSM_MemoryType MemoryType; /* Memory type of the number. */
124   int Location;              /* Location of the number in MemoryType. */
125 } GSM_SpeedDial;
126
127 /* Define enums for Battery units. */
128 typedef enum {
129   GBU_Arbitrary,
130   GBU_Volts,
131   GBU_Minutes,
132   GBU_Percentage
133 } GSM_BatteryUnits;
134
135 /* This enum is used for display status. */
136
137 typedef enum {
138   DS_Call_In_Progress, /* Call in progress. */
139   DS_Unknown,          /* The meaning is unknown now :-( */
140   DS_Unread_SMS,       /* There is Unread SMS. */
141   DS_Voice_Call,       /* Voice call active. */
142   DS_Fax_Call,         /* Fax call active. */
143   DS_Data_Call,        /* Data call active. */
144   DS_Keyboard_Lock,    /* Keyboard lock status. */
145   DS_SMS_Storage_Full  /* Full SMS Memory. */
146 } DisplayStatusEntity;
147
148 /* Constants for Profiles. */
149
150 #define PROFILE_MESSAGE_NOTONE     0x00
151 #define PROFILE_MESSAGE_STANDARD   0x01
152 #define PROFILE_MESSAGE_SPECIAL    0x02
153 #define PROFILE_MESSAGE_BEEPONCE   0x03
154 #define PROFILE_MESSAGE_ASCENDING  0x04
155
156 #define PROFILE_WARNING_OFF  0xff
157 #define PROFILE_WARNING_ON   0x04
158
159 #define PROFILE_CALLALERT_RINGING       0x01
160 #define PROFILE_CALLALERT_BEEPONCE      0x02
161 #define PROFILE_CALLALERT_OFF           0x04
162 #define PROFILE_CALLALERT_RINGONCE      0x05
163 #define PROFILE_CALLALERT_ASCENDING     0x06
164 #define PROFILE_CALLALERT_CALLERGROUPS  0x07
165
166 #define PROFILE_KEYPAD_OFF     0xff
167 #define PROFILE_KEYPAD_LEVEL1  0x00
168 #define PROFILE_KEYPAD_LEVEL2  0x01
169 #define PROFILE_KEYPAD_LEVEL3  0x02
170 //in 5110 I had also once 0x03
171
172 #define PROFILE_VOLUME_LEVEL1  0x06
173 #define PROFILE_VOLUME_LEVEL2  0x07
174 #define PROFILE_VOLUME_LEVEL3  0x08
175 #define PROFILE_VOLUME_LEVEL4  0x09
176 #define PROFILE_VOLUME_LEVEL5  0x0a
177
178 #define PROFILE_CALLERGROUPS_ALL         0xff
179 #define PROFILE_CALLERGROUPS_FAMILY      0x01
180 #define PROFILE_CALLERGROUPS_VIP         0x02
181 #define PROFILE_CALLERGROUPS_FRIENDS     0x04
182 #define PROFILE_CALLERGROUPS_COLLEAGUES  0x08
183 #define PROFILE_CALLERGROUPS_OTHERS      0x10
184
185 #define PROFILE_VIBRATION_OFF 0x00
186 #define PROFILE_VIBRATION_ON  0x01
187 #define PROFILE_VIBRATION_FIRST  0x02
188
189 /* Structure to hold profile entries. */
190
191 typedef struct {
192   int Number;          /* The number of the profile. */
193   char Name[40];       /* The name of the profile. */
194   int DefaultName;     /* 0-6, when default name is used, -1, when not */
195   int KeypadTone;      /* Volumen level for keypad tones. */
196   int Lights;          /* Lights on/off. */
197   int CallAlert;       /* Incoming call alert. */
198   int Ringtone;        /* Ringtone for incoming call alert. */
199   int Volume;          /* Volume of the ringing. */
200   int MessageTone;     /* The tone for message indication. */
201   int WarningTone;     /* The tone for warning messages. */
202   int Vibration;       /* Vibration? */
203   int CallerGroups;    /* CallerGroups. */
204   int ScreenSaver;     /* ScreenSaver */
205   int AutomaticAnswer; /* Does the phone auto-answer incoming call? */
206 } GSM_Profile;
207
208 typedef enum {
209   PPS_ALS=0,
210   PPS_HRData,
211   PPS_14400Data,
212   PPS_LCDContrast,
213   PPS_EFR,
214   PPS_FR,
215   PPS_HR,
216   PPS_GamesMenu,   /* N3210 5.26 and higher */
217   PPS_VibraMenu    /* N3210 */
218 } GSM_PPS_Settings;
219
220 typedef struct {
221   GSM_PPS_Settings Name;
222   bool bool_value;
223   int int_value;
224 } GSM_PPS;
225
226 typedef struct {
227     char data[10+1];//detailed info about this simlock
228     bool enabled;   //is enabled or not ?
229     int counter;    //how many times user tried to disable simlock using keypad
230     bool factory;   //is factory simlock ?
231 } GSM_OneSimlock;
232
233 typedef struct {
234     GSM_OneSimlock simlocks[4];
235 } GSM_AllSimlocks;
236
237 /* Data structures for the call divert */
238 typedef enum {
239         GSM_CDV_Busy = 0x01,     /* Divert when busy */ 
240         GSM_CDV_NoAnswer,        /* Divert when not answered */
241         GSM_CDV_OutOfReach,      /* Divert when phone off or no coverage */
242         GSM_CDV_AllTypes         /* Divert all calls without ringing */
243 } GSM_CDV_DivertTypes;
244
245 typedef enum {
246         GSM_CDV_VoiceCalls = 0x01,
247         GSM_CDV_FaxCalls,
248         GSM_CDV_DataCalls,
249         GSM_CDV_AllCalls
250 } GSM_CDV_CallTypes;
251
252 /* See GSM 02.82 for diverts types */
253 typedef enum {
254         GSM_CDV_Disable  = 0x00,
255         GSM_CDV_Enable   = 0x01,
256         GSM_CDV_Query    = 0x02, /* Is concrete divert enabled ? */
257         GSM_CDV_Register = 0x03, /* Sets divert */
258         GSM_CDV_Erasure  = 0x04  /* Erase concrete divert */
259 } GSM_CDV_Opers;
260
261 typedef struct {
262         GSM_CDV_DivertTypes DType;
263         GSM_CDV_CallTypes   CType;
264         GSM_CDV_Opers       Operation;
265         char                Number[GSM_MAX_SENDER_LENGTH + 1];
266         unsigned int        Timeout;
267         bool                Enabled;
268 } GSM_CallDivert;
269
270 /* Define standard GSM error/return code values. These codes are also used for
271    some internal functions such as SIM read/write in the model specific code. */
272
273 typedef enum {
274   GE_NONE = 0,              /* No error. */
275   GE_DEVICEOPENFAILED,      /* Couldn't open specified serial device. */
276   GE_UNKNOWNMODEL,          /* Model specified isn't known/supported. */
277   GE_NOTSUPPORTED,          /* We are sure, that function not supported by phone model */
278   GE_NOLINK,                /* Couldn't establish link with phone. */
279   GE_TIMEOUT,               /* Command timed out. */
280   GE_TRYAGAIN,              /* Try again. */
281   GE_INVALIDSECURITYCODE,   /* Invalid Security code. */
282   GE_NOTIMPLEMENTED,        /* Command called isn't implemented in model. */
283   GE_INVALIDSMSLOCATION,    /* Invalid SMS location. */
284   GE_INVALIDPHBOOKLOCATION, /* Invalid phonebook location. */ /*10*/
285   GE_INVALIDMEMORYTYPE,     /* Invalid type of memory. */
286   GE_INVALIDSPEEDDIALLOCATION, /* Invalid speed dial location. */
287   GE_INVALIDCALNOTELOCATION,/* Invalid calendar note location. */
288   GE_INVALIDDATETIME,       /* Invalid date, time or alarm specification. */
289   GE_EMPTYSMSLOCATION,      /* SMS location is empty. */
290   GE_PHBOOKNAMETOOLONG,     /* Phonebook name is too long. */
291   GE_PHBOOKNUMBERTOOLONG,   /* Phonebook number is too long. */
292   GE_PHBOOKWRITEFAILED,     /* Phonebook write failed. */
293   GE_SMSSENDOK,             /* SMS was send correctly. */
294   GE_SMSSENDFAILED,         /* SMS send fail. */ /*20*/
295   GE_SMSWAITING,            /* Waiting for the next part of SMS. */
296   GE_SMSTOOLONG,            /* SMS message too long. */
297   GE_NONEWCBRECEIVED,       /* Attempt to read CB when no new CB received */
298   GE_INTERNALERROR,         /* Problem occured internal to model specific code. */
299   GE_CANTOPENFILE,          /* Can't open file with bitmap/ringtone */
300   GE_WRONGNUMBEROFCOLORS,   /* Wrong number of colors in specified bitmap file */
301   GE_WRONGCOLORS,           /* Wrong colors in bitmap file */
302   GE_INVALIDFILEFORMAT,     /* Invalid format of file */
303   GE_SUBFORMATNOTSUPPORTED, /* Subformat of file not supported */
304   GE_TOOSHORT,              /* Too short file, structure, etc. to read */ /*30*/
305   GE_TOOLONG,               /* Too long file, structure, etc. to read */
306   GE_INVALIDIMAGESIZE,      /* Invalid size of bitmap (in file, etc.) */
307   GE_BUSY,                  /* Command is still being executed. */
308   GE_UNKNOWN,               /* Unknown error - well better than nothing!! */ /*34*/
309   GE_NOACCESS,
310   GE_USERCANCELED,
311   GE_MEMORYFULL,
312   GE_INVALIDRINGLOCATION,
313   GE_INSIDEBOOKMARKSMENU,
314   GE_INVALIDBOOKMARKLOCATION,
315   GE_INSIDESETTINGSMENU,
316   GE_INVALIDSETTINGSLOCATION,
317   
318   /* The following are here in anticipation of data call requirements. */
319
320   GE_LINEBUSY,              /* Outgoing call requested reported line busy */
321   GE_NOCARRIER,             /* No Carrier error during data call setup ? */
322   GE_SMSSAVEFAILED,         /* save sms failed */
323   GE_SMSISINMEM,            /* sms is already in memory */
324   GE_BUSYSMSLOCATION        /* there is a sms at the requested sms location */
325 } GSM_Error;
326
327 #endif  /* __gsm_common_h */