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