Branch update for mygnokii2002_03_17_19_29nl
[gnokii.git] / include / gsm-api.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 various functions, definitions etc. used to implement
10   the handset interface.  See gsm-api.c for more details.
11
12 */
13
14 #ifndef __gsm_api_h
15 #define __gsm_api_h
16  
17 #include "misc.h"
18 #include "gsm-common.h"
19 #include "data/rlp-common.h"
20 #include "devices/device.h"
21 #include "gsm-phonebook.h"
22 #include "gsm-networks.h"
23 #include "gsm-bitmaps.h"
24 #include "gsm-datetime.h"
25 #include "gsm-calendar.h"
26 #include "gsm-sms.h"
27 #include "gsm-ringtones.h"
28 #include "gsm-wap.h"
29
30 #ifndef UCLINUX
31
32 /* Undefined functions in fbus/mbus files */
33 extern GSM_Error Unimplemented(void);
34 #define UNIMPLEMENTED (void *) Unimplemented
35 extern GSM_Error NotSupported(void);
36 #define NOTSUPPORTED (void *) NotSupported
37
38 #endif /* UCLINUX */
39
40 /* Define the structure used to hold pointers to the various API functions.
41    This is in effect the master list of functions provided by the gnokii API.
42    Modules containing the model specific code each contain one of these
43    structures which is "filled in" with the corresponding function within the
44    model specific code.  If a function is not supported or not implemented, a
45    generic not implemented function is used to return a GE_NOTIMPLEMENTED
46    error code. */
47
48 typedef struct {
49
50   /* FIXME: comment this. */
51
52   GSM_Error (*Initialise)( char *port_device, char *initlength,
53                            GSM_ConnectionType connection,
54                            void (*rlp_callback)(RLP_F96Frame *frame));
55
56   void      (*DispatchMessage) (u16 MessageLength, u8 *MessageBuffer, u8 MessageType); 
57
58   void      (*Terminate)(void); 
59
60   void      (*KeepAlive)(void);
61   
62   GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry );
63
64   GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry );
65
66   GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry);
67
68   GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry);
69
70   GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status);
71
72   GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status);
73
74   GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter );
75
76   GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter );
77
78   GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message );
79
80   GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message );
81
82   GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message);
83
84   GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message);
85
86     /* If units is set to a valid GSM_RFUnits value, the code
87        will return level in these units if it is able.  Otherwise
88        value will be returned as GRF_Arbitary.  If phone doesn't
89        support GetRFLevel, function returns GE_NOTSUPPORTED */
90   GSM_Error (*GetRFLevel)( GSM_RFUnits *units, float *level );
91
92     /* Works the same as GetRFLevel, except returns battery
93        level if known. */
94   GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level );
95
96   GSM_Error (*GetPowerSource)( GSM_PowerSource *source);
97
98   GSM_Error (*GetDisplayStatus)( int *Status);
99
100   GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code);
101
102   GSM_Error (*GetSecurityCodeStatus)( int *Status );
103
104   GSM_Error (*GetSecurityCode)( GSM_SecurityCode *Code);
105   
106   GSM_Error (*GetIMEI)( char *imei );
107
108   GSM_Error (*GetRevision)( char *revision );
109
110   GSM_Error (*GetModel)( char *model );
111
112   GSM_Error (*GetDateTime)( GSM_DateTime *date_time);
113
114   GSM_Error (*SetDateTime)( GSM_DateTime *date_time);
115
116   GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time );
117
118   GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time );
119
120   GSM_Error (*DialVoice)( char *Number);
121
122   GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c));
123
124   GSM_Error (*GetIncomingCallNr)( char *Number );
125
126   GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo );
127
128   GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote);
129
130   GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote);
131
132   GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote);
133
134   GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen );
135
136   GSM_Error (*SendDTMF) ( char *String );
137
138   GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap );
139   
140   GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap );
141
142   GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone , int *maxlength);
143
144   GSM_Error (*SetBinRingtone) ( GSM_BinRingtone *ringtone);
145   
146   GSM_Error (*GetBinRingtone) ( GSM_BinRingtone *ringtone);
147   
148   GSM_Error (*Reset) ( unsigned char type );
149
150   GSM_Error (*GetProfile) ( GSM_Profile *Profile );
151
152   GSM_Error (*SetProfile) ( GSM_Profile *Profile );
153   
154   bool      (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx );
155
156   GSM_Error (*CancelCall) ();
157      
158   GSM_Error (*PressKey) (int key, int event);
159   
160   GSM_Error (*EnableDisplayOutput) ();
161   
162   GSM_Error (*DisableDisplayOutput) ();
163  
164   GSM_Error (*EnableCellBroadcast) ();
165
166   GSM_Error (*DisableCellBroadcast) ();
167
168   GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message );
169
170   GSM_Error (*PlayTone) (int Herz, u8 Volume);
171
172   GSM_Error (*GetProductProfileSetting) ( GSM_PPS *PPS);
173
174   GSM_Error (*SetProductProfileSetting) ( GSM_PPS *PPS);
175
176   GSM_Error (*GetOperatorName) ( GSM_Network *operator);  
177
178   GSM_Error (*SetOperatorName) ( GSM_Network *operator);    
179
180   GSM_Error (*GetVoiceMailbox) ( GSM_PhonebookEntry *entry);  
181
182   GSM_Error (*PhoneTests) ();    
183
184   GSM_Error (*SimlockInfo) ( GSM_AllSimlocks *siml);    
185
186   GSM_Error (*GetCalendarNotesInfo) (GSM_NotesInfo *NotesInfo);
187
188   GSM_Error (*GetSMSFolders) ( GSM_SMSFolders *folders);      
189
190   GSM_Error (*ResetPhoneSettings) ();      
191
192   GSM_Error (*GetWAPBookmark) ( GSM_WAPBookmark *bookmark);      
193
194   GSM_Error (*SetWAPBookmark) ( GSM_WAPBookmark *bookmark);      
195
196   GSM_Error (*GetWAPSettings) ( GSM_WAPSettings *settings);      
197
198   GSM_Error (*CallDivert) ( GSM_CallDivert *cd );      
199
200   GSM_Error (*AnswerCall) (char s);
201
202   GSM_Error (*GetManufacturer)( char *manufacturer );
203
204 } GSM_Functions;
205
206 typedef struct {
207
208   /* FIXME: comment this. */
209
210   GSM_Error (*Initialise)( char *port_device, char *initlength,
211                            GSM_ConnectionType connection,
212                            void (*rlp_callback)(RLP_F96Frame *frame));
213
214   int (*SendMessage) (u16 message_length, u8 message_type, u8 *buffer);
215
216   int (*SendFrame)   (u16 message_length, u8 message_type, u8 *buffer); 
217
218   int (*WritePhone)  (u16 length, u8 *buffer); 
219
220   void (*Terminate)(void);      
221
222   void (*StateMachine)(unsigned char rx_byte);
223
224 } GSM_Protocol;
225
226 /* This structure is provided to allow common information about the particular
227    model to be looked up in a model independant way. Some of the values here
228    define minimum and maximum levels for values retrieved by the various Get
229    functions for example battery level. They are not defined as constants to
230    allow model specific code to set them during initialisation */
231
232 typedef struct {
233                 
234   char *FBUSModels;     /* Models covered by this type, pipe '|' delimited. */  
235   char *MBUSModels;     /* Models covered by this type, pipe '|' delimited. */
236   char *InfraredModels; /* Models covered by this type, pipe '|' delimited. */  
237   char *DLR3Models;     /* Models covered by this type, pipe '|' delimited. */
238   char *ATModels;       /* Models covered by this type, pipe '|' delimited. */
239   char *IrdaModels;     /* Models covered by this type, pipe '|' delimited. */
240   char *TekramModels;   /* Models covered by this type, pipe '|' delimited. */  
241   char *FBUS3110Models; /* Models covered by this type, pipe '|' delimited. */  
242   
243 /* Minimum and maximum levels for RF signal strength. Units are as per the
244    setting of RFLevelUnits.  The setting of RFLevelUnits indicates the 
245    default or "native" units used.  In the case of the 3110 and 6110 series
246    these are arbitrary, ranging from 0 to 4. */
247
248   float MaxRFLevel;
249   float MinRFLevel;
250   GSM_RFUnits RFLevelUnits;
251
252 /* Minimum and maximum levels for battery level. Again, units are as per the
253    setting of GSM_BatteryLevelUnits.  The value that BatteryLevelUnits is set
254    to indicates the "native" or default value that the phone supports.  In the
255    case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */
256
257   float MaxBatteryLevel;
258   float MinBatteryLevel;
259   GSM_BatteryUnits BatteryLevelUnits;
260
261 /* Information about date, time and alarm support. In case of alarm
262    information we provide value for the number of alarms supported. */
263
264   GSM_DateTimeSupport DateTimeSupport;
265   GSM_DateTimeSupport AlarmSupport;
266   int MaximumAlarms;
267 } GSM_Information;
268
269 void NULL_Terminate(void);
270 void NULL_KeepAlive();
271 bool NULL_WritePhone (u16 length, u8 *buffer);
272 void NULL_TX_DisplayMessage(u16 MessageLength, u8 *MessageBuffer);
273
274 GSM_Error NULL_WaitUntil (int time, GSM_Error *value);
275 GSM_Error NULL_SendMessageSequence (int time, GSM_Error *value,
276                u16 message_length, u8 message_type, u8 *buffer);
277
278 GSM_ConnectionType GetConnectionTypeFromString(char *Connection);
279
280 bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type);
281 bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type);
282
283 /* Define these as externs so that app code can pick them up. */
284
285 extern bool *GSM_LinkOK;
286 extern GSM_Information *GSM_Info;
287 extern GSM_Functions *GSM;
288 extern GSM_Protocol *Protocol;
289
290 extern GSM_PhonebookEntry *CurrentPhonebookEntry;
291 extern GSM_Error          CurrentPhonebookError;
292
293 extern GSM_SpeedDial      *CurrentSpeedDialEntry;
294 extern GSM_Error          CurrentSpeedDialError;
295
296 extern unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
297 extern unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
298 extern unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
299
300 #ifndef UCLINUX
301 extern GSM_SMSMessage     *CurrentSMSMessage;
302 extern GSM_Error          CurrentSMSMessageError;
303 extern int                CurrentSMSPointer;
304
305 extern GSM_SMSFolders      *CurrentSMSFolders;
306 extern GSM_Error          CurrentSMSFoldersError;
307 extern int                CurrentSMSFoldersCount;
308
309 extern GSM_OneSMSFolder   CurrentSMSFolder;
310 extern GSM_Error          CurrentSMSFolderError;
311 extern int                CurrentSMSFolderID;
312 #endif /* UCLINUX */
313
314 extern GSM_MemoryStatus   *CurrentMemoryStatus;
315 extern GSM_Error          CurrentMemoryStatusError;
316
317 #ifndef UCLINUX
318 extern GSM_NetworkInfo    *CurrentNetworkInfo;
319 extern GSM_Error          CurrentNetworkInfoError;
320
321 extern GSM_SMSStatus      *CurrentSMSStatus;
322 extern GSM_Error          CurrentSMSStatusError;
323
324 extern GSM_MessageCenter  *CurrentMessageCenter;
325 extern GSM_Error          CurrentMessageCenterError;
326
327 extern int                *CurrentSecurityCodeStatus;
328 extern GSM_Error          CurrentSecurityCodeError;
329 extern GSM_SecurityCode   *CurrentSecurityCode;
330
331 extern GSM_DateTime       *CurrentDateTime;
332 extern GSM_Error          CurrentDateTimeError;
333
334 extern GSM_Error          CurrentResetPhoneSettingsError;
335
336 extern GSM_DateTime       *CurrentAlarm;
337 extern GSM_Error          CurrentAlarmError;
338
339 extern GSM_CalendarNote   *CurrentCalendarNote;
340 extern GSM_Error          CurrentCalendarNoteError;
341
342 extern GSM_NotesInfo      CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
343 extern GSM_Error          CurrentCalendarNotesInfoError;
344
345 extern GSM_Error          CurrentSetDateTimeError;
346 extern GSM_Error          CurrentSetAlarmError;
347
348 extern int                *CurrentFirstCalendarFreePos;
349 extern GSM_Error          CurrentFirstCalendarFreePosError;
350 #endif /* UCLINUX */
351
352 extern GSM_Error          CurrentEnableExtendedCommandsError;
353
354 extern int                CurrentRFLevel,
355                    CurrentBatteryLevel,
356                    CurrentPowerSource;
357
358 #ifndef UCLINUX
359 extern int                CurrentDisplayStatus;
360 extern GSM_Error          CurrentDisplayStatusError;
361
362 extern char               *CurrentNetmonitor;
363 extern GSM_Error          CurrentNetmonitorError;
364
365 extern GSM_Bitmap         *CurrentGetBitmap;
366 extern GSM_Error          CurrentGetBitmapError;
367
368 extern GSM_Error          CurrentSetBitmapError;
369
370 extern GSM_Error          CurrentSendDTMFError;
371
372 extern GSM_Profile        *CurrentProfile;
373 extern GSM_Error          CurrentProfileError;
374
375 extern GSM_Error          CurrentDisplayOutputError;
376
377 extern GSM_CBMessage      *CurrentCBMessage;
378 extern GSM_Error          CurrentCBError;
379
380 extern int                CurrentPressKeyEvent;
381 extern GSM_Error          CurrentPressKeyError;
382
383 extern GSM_Error          CurrentPlayToneError;
384 #endif /* UCLINUX */
385
386 extern GSM_Error          CurrentDialVoiceError;
387
388 #ifndef UCLINUX
389 extern GSM_Error          CurrentGetOperatorNameError;
390 extern GSM_Network        *CurrentGetOperatorNameNetwork;
391 extern GSM_Error          CurrentSetOperatorNameError;
392 #endif /* UCLINUX */
393
394 extern GSM_Error          CurrentGetIMEIError;
395
396 extern GSM_Error          CurrentGetHWError;
397
398 #ifndef UCLINUX
399 extern unsigned char      CurrentPPS[4];
400 extern GSM_Error          CurrentProductProfileSettingsError;
401
402 extern char               CurrentIncomingCall[20];
403
404 extern GSM_Error          CurrentBinRingtoneError;
405 extern GSM_BinRingtone    *CurrentGetBinRingtone;
406
407 extern GSM_Error          CurrentRingtoneError; 
408 #endif /* UCLINUX */
409
410 extern GSM_Error          CurrentMagicError;
411
412 #ifndef UCLINUX
413 extern GSM_Error          CurrentSimlockInfoError;
414 extern GSM_AllSimlocks    *CurrentSimLock;
415
416 extern GSM_Error          CurrentGetWAPBookmarkError;
417 extern GSM_Error          CurrentSetWAPBookmarkError;
418 extern GSM_WAPBookmark    *WAPBookmark;
419
420 extern GSM_Error          CurrentGetWAPSettingsError;
421 extern GSM_WAPSettings    *WAPSettings;
422
423 extern GSM_Error          CurrentCallDivertError;
424 extern GSM_CallDivert    *CurrentCallDivert;
425
426 extern char              *CurrentManufacturer;
427 #endif /* UCLINUX */
428
429 /* This is the connection type used in gnokii. */
430 extern GSM_ConnectionType CurrentConnectionType;
431
432 /* Pointer to a callback function used to return changes to a calls status */
433 /* This saves unreliable polling */
434 extern void (*CurrentCallPassup)(char c);
435
436 /* Pointer to callback function in user code to be called when RLP frames
437    are received. */
438 extern void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
439
440 /* Used to disconnect the call */
441 extern u8 CurrentCallSequenceNumber;
442
443 extern bool CurrentLinkOK;
444
445 extern bool CurrentRequestTerminate;
446
447 #ifndef UCLINUX
448 extern bool CurrentDisableKeepAlive;
449 #endif /* UCLINUX */
450
451 /* Prototype for the functions actually provided by gsm-api.c. */
452
453 extern GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
454
455 #ifndef UCLINUX
456 extern bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
457 #endif /* UCLINUX */
458
459 extern char *GetMygnokiiVersion();
460
461 typedef enum {
462   F_CAL61=1,/*Calendar in 6110 style - 4 types,...*/
463   F_CAL33,  /*Calendar in 3310 style - 10 reminders, Unicode, 3 coding types*/
464   F_CAL71,  /*Calendar in 7110 style - 4 types, recurrance, etc.*/
465
466   F_PBK33SIM,/*Phonebook in Unicode(3310 style).Name and number.No internal*/
467   F_PBK33INT,/*Phonebook in Unicode(3310 style).Name and number.Internal available*/
468   F_PBK71INT,/*Extended phonebook-multiple numbers,Unicode(7110 style).Internal available*/
469   F_PBK61INT,/*Name and number,no Unicode(6110 style).Internal available*/
470
471   F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/
472   F_DATA71, /*Datacalls using AT commands*/
473
474   F_SMS,    /*SMS with Inbox, Outbox*/ /*10*/
475   F_SMS71,  /*SMS with SMS folders like in 7110*/ 
476
477   F_AUTH,   /*We can make authentication and have "Accessory connected" like in 6110*/
478   F_NETMON, /*Netmonitor available*/ 
479   F_CALER61,/*Caller groups in 6110 style - 5 groups with members*/
480   F_KEYB,   /*We can press keys*/
481   F_SMSCDEF,/*SMSC can have default recipient*/
482   F_SPEED,  /*We can handle speed dials*/
483   F_SCRSAV, /*We have screen savers*/
484   F_DTMF,   /*We can handle DTMF sequences*/
485   F_NOPOWER,/*We must get power/battery info from netmonitor*/ /*20*/
486
487   F_STANIM, /*Startup logo animated or static*/ 
488   F_STA   , /*Startup logo static*/
489   F_STA62 , /*Startup logo static size 6210*/ 
490   F_STA71 , /*Startup logo static size 7110*/
491
492   F_PROF61, /*Profiles numbered like in N6110*/
493   F_PROF51, /*Profiles numbered like in N5110*/
494   F_PROF33, /*Profiles numbered like in N3310.Unicode names*/
495
496   F_RING_SM,/*Binary ringtone in Smart Messaging*/
497   F_RINGBIN,/*Binary ringtone in binary format*/
498
499   F_WAP     /*WAP functions available*/ /*30*/
500 } feat_index;
501
502 typedef enum {
503   FN_CALENDAR=0,
504   FN_NETMONITOR,
505   FN_CALLERGROUPS,
506   FN_PHONEBOOK,
507   FN_AUTHENTICATION,
508   FN_DATACALLS,
509   FN_KEYPRESS,
510   FN_SMSCDEFAULT,
511   FN_SPEEDDIAL,
512   FN_SCREENSAVER,
513   FN_DTMF, /*10*/
514   FN_SMS,
515   FN_NOPOWERFRAME,
516   FN_STARTUP,
517   FN_PROFILES,
518   FN_RINGTONES,
519   FN_WAP,
520   FN_RINGNUMBER
521 } featnum_index;
522
523 /* For models table */
524 typedef struct {
525   char *model;
526   char *number;
527   feat_index features[18];  
528 } OnePhoneModel;
529
530 extern char *GetModelName ();
531 extern int GetModelFeature (featnum_index num);
532
533 #ifndef UCLINUX
534 extern bool AppendLog(u8 *buffer, int length,bool format);
535 extern bool AppendLogText(u8 *buffer,bool format);
536 #else /* UCLINUX */
537 #define AppendLog(buffer,length,format)
538 #define AppendLogText(buffer,format)
539 #endif /* UCLINUX */
540
541 typedef struct {
542   int                SIMPhonebookUsed;
543   int                SIMPhonebookSize;
544   GSM_PhonebookEntry SIMPhonebook[250];
545
546   int                PhonePhonebookUsed;
547   int                PhonePhonebookSize;
548   GSM_PhonebookEntry PhonePhonebook[500];
549
550   bool               CallerAvailable;
551   GSM_Bitmap         CallerGroups[5];
552
553   bool               SpeedAvailable;
554   GSM_SpeedDial      SpeedDials[8];
555
556   bool               OperatorLogoAvailable;
557   GSM_Bitmap         OperatorLogo;
558
559   bool               StartupLogoAvailable;
560   GSM_Bitmap         StartupLogo;
561
562   GSM_Bitmap         StartupText;
563 } GSM_Backup;
564
565 #endif  /* __gsm_api_h */