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   
232   char *MBUSModels; /* Models covered by this type, pipe '|' delimited. */
233
234   char *InfraredModels; /* Models covered by this type, pipe '|' delimited. */
235   
236   char *DLR3Models; /* Models covered by this type, pipe '|' delimited. */
237
238   char *ATModels; /* Models covered by this type, pipe '|' delimited. */
239
240   char *IrdaModels; /* Models covered by this type, pipe '|' delimited. */
241
242   char *TekramModels; /* Models covered by this type, pipe '|' delimited. */  
243   
244 /* Minimum and maximum levels for RF signal strength. Units are as per the
245    setting of RFLevelUnits.  The setting of RFLevelUnits indicates the 
246    default or "native" units used.  In the case of the 3110 and 6110 series
247    these are arbitrary, ranging from 0 to 4. */
248
249   float MaxRFLevel;
250   float MinRFLevel;
251   GSM_RFUnits RFLevelUnits;
252
253 /* Minimum and maximum levels for battery level. Again, units are as per the
254    setting of GSM_BatteryLevelUnits.  The value that BatteryLevelUnits is set
255    to indicates the "native" or default value that the phone supports.  In the
256    case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */
257
258   float MaxBatteryLevel;
259   float MinBatteryLevel;
260   GSM_BatteryUnits BatteryLevelUnits;
261
262 /* Information about date, time and alarm support. In case of alarm
263    information we provide value for the number of alarms supported. */
264
265   GSM_DateTimeSupport DateTimeSupport;
266   GSM_DateTimeSupport AlarmSupport;
267   int MaximumAlarms;
268 } GSM_Information;
269
270 void NULL_Terminate(void);
271 void NULL_KeepAlive();
272 bool NULL_WritePhone (u16 length, u8 *buffer);
273 void NULL_TX_DisplayMessage(u16 MessageLength, u8 *MessageBuffer);
274
275 GSM_Error NULL_WaitUntil (int time, GSM_Error *value);
276 GSM_Error NULL_SendMessageSequence (int time, GSM_Error *value,
277                u16 message_length, u8 message_type, u8 *buffer);
278
279 GSM_ConnectionType GetConnectionTypeFromString(char *Connection);
280
281 bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type);
282 bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type);
283
284 /* Define these as externs so that app code can pick them up. */
285
286 extern bool *GSM_LinkOK;
287 extern GSM_Information *GSM_Info;
288 extern GSM_Functions *GSM;
289 extern GSM_Protocol *Protocol;
290
291 GSM_PhonebookEntry *CurrentPhonebookEntry;
292 GSM_Error          CurrentPhonebookError;
293
294 GSM_SpeedDial      *CurrentSpeedDialEntry;
295 GSM_Error          CurrentSpeedDialError;
296
297 unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
298 unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
299 unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
300
301 GSM_SMSMessage     *CurrentSMSMessage;
302 GSM_Error          CurrentSMSMessageError;
303 int                CurrentSMSPointer;
304
305 GSM_SMSFolders      *CurrentSMSFolders;
306 GSM_Error          CurrentSMSFoldersError;
307 int                CurrentSMSFoldersCount;
308
309 GSM_OneSMSFolder   CurrentSMSFolder;
310 GSM_Error          CurrentSMSFolderError;
311 int                CurrentSMSFolderID;
312
313 GSM_MemoryStatus   *CurrentMemoryStatus;
314 GSM_Error          CurrentMemoryStatusError;
315
316 GSM_NetworkInfo    *CurrentNetworkInfo;
317 GSM_Error          CurrentNetworkInfoError;
318
319 GSM_SMSStatus      *CurrentSMSStatus;
320 GSM_Error          CurrentSMSStatusError;
321
322 GSM_MessageCenter  *CurrentMessageCenter;
323 GSM_Error          CurrentMessageCenterError;
324
325 int                *CurrentSecurityCodeStatus;
326 GSM_Error          CurrentSecurityCodeError;
327 GSM_SecurityCode   *CurrentSecurityCode;
328
329 GSM_DateTime       *CurrentDateTime;
330 GSM_Error          CurrentDateTimeError;
331
332 GSM_Error          CurrentResetPhoneSettingsError;
333
334 GSM_DateTime       *CurrentAlarm;
335 GSM_Error          CurrentAlarmError;
336
337 GSM_CalendarNote   *CurrentCalendarNote;
338 GSM_Error          CurrentCalendarNoteError;
339
340 GSM_NotesInfo      CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
341 GSM_Error          CurrentCalendarNotesInfoError;
342
343 int                *CurrentFirstCalendarFreePos;
344 GSM_Error          CurrentFirstCalendarFreePosError;
345
346 GSM_Error          CurrentSetDateTimeError;
347 GSM_Error          CurrentSetAlarmError;
348
349 GSM_Error          CurrentEnableExtendedCommandsError;
350
351 int                CurrentRFLevel,
352                    CurrentBatteryLevel,
353                    CurrentPowerSource;
354
355 int                CurrentDisplayStatus;
356 GSM_Error          CurrentDisplayStatusError;
357
358 char               *CurrentNetmonitor;
359 GSM_Error          CurrentNetmonitorError;
360
361 GSM_Bitmap         *CurrentGetBitmap;
362 GSM_Error          CurrentGetBitmapError;
363
364 GSM_Error          CurrentSetBitmapError;
365
366 GSM_Error          CurrentSendDTMFError;
367
368 GSM_Profile        *CurrentProfile;
369 GSM_Error          CurrentProfileError;
370
371 GSM_Error          CurrentDisplayOutputError;
372
373 GSM_CBMessage      *CurrentCBMessage;
374 GSM_Error          CurrentCBError;
375
376 int                CurrentPressKeyEvent;
377 GSM_Error          CurrentPressKeyError;
378
379 GSM_Error          CurrentPlayToneError;
380
381 GSM_Error          CurrentDialVoiceError;
382
383 GSM_Error          CurrentGetOperatorNameError;
384 GSM_Network        *CurrentGetOperatorNameNetwork;
385 GSM_Error          CurrentSetOperatorNameError;
386
387 GSM_Error          CurrentGetIMEIError;
388
389 GSM_Error          CurrentGetHWError;
390
391 unsigned char      CurrentPPS[4];
392 GSM_Error          CurrentProductProfileSettingsError;
393
394 char               CurrentIncomingCall[20];
395
396 GSM_Error          CurrentBinRingtoneError;
397 GSM_BinRingtone    *CurrentGetBinRingtone;
398
399 GSM_Error          CurrentRingtoneError; 
400
401 GSM_Error          CurrentMagicError;
402
403 GSM_Error          CurrentSimlockInfoError;
404 GSM_AllSimlocks    *CurrentSimLock;
405
406 GSM_Error          CurrentGetWAPBookmarkError;
407 GSM_Error          CurrentSetWAPBookmarkError;
408 GSM_WAPBookmark    *WAPBookmark;
409
410 GSM_Error          CurrentGetWAPSettingsError;
411 GSM_WAPSettings    *WAPSettings;
412
413 GSM_Error          CurrentCallDivertError;
414 GSM_CallDivert    *CurrentCallDivert;
415
416 char              *CurrentManufacturer;
417
418 /* This is the connection type used in gnokii. */
419 GSM_ConnectionType CurrentConnectionType;
420
421 /* Pointer to a callback function used to return changes to a calls status */
422 /* This saves unreliable polling */
423 void (*CurrentCallPassup)(char c);
424
425 /* Pointer to callback function in user code to be called when RLP frames
426    are received. */
427 void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
428
429 /* Used to disconnect the call */
430 u8 CurrentCallSequenceNumber;
431
432 bool CurrentLinkOK;
433
434 bool CurrentRequestTerminate;
435
436 bool CurrentDisableKeepAlive;
437
438 /* Prototype for the functions actually provided by gsm-api.c. */
439
440 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
441
442 bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
443
444 char *GetMygnokiiVersion();
445
446 typedef enum {
447   F_CAL61=0,/*Calendar in 6110 style - 4 types,...*/
448   F_CAL33,  /*Calendar in 3310 style - 10 reminders, Unicode, 3 coding types*/
449   F_CAL71,  /*Calendar in 7110 style - 4 types, recurrance, etc.*/
450
451   F_PBK33SIM,/*Phonebook in Unicode(3310 style).Name and number.No internal*/
452   F_PBK33INT,/*Phonebook in Unicode(3310 style).Name and number.Internal available*/
453   F_PBK71INT,/*Extended phonebook-multiple numbers,Unicode(7110 style).Internal available*/
454   F_PBK61INT,/*Name and number,no Unicode(6110 style).Internal available*/
455
456   F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/
457   F_DATA71, /*Datacalls using AT commands*/
458
459   F_SMS,    /*SMS with Inbox, Outbox*/
460   F_SMS71,  /*SMS with SMS folders like in 7110*/ /*10*/
461
462   F_AUTH,   /*We can make authentication and have "Accessory connected" like in 6110*/
463   F_NETMON, /*Netmonitor available*/ 
464   F_CALER61,/*Caller groups in 6110 style - 5 groups with members*/
465   F_KEYB,   /*We can press keys*/
466   F_SMSCDEF,/*SMSC can have default recipient*/
467   F_SPEED,  /*We can handle speed dials*/
468   F_SCRSAV, /*We have screen savers*/
469   F_DTMF,   /*We can handle DTMF sequences*/
470   F_NOPOWER,/*We must get power/battery info from netmonitor*/
471
472   F_STANIM, /*Startup logo animated or static*/ /*20*/
473   F_STA   , /*Startup logo static*/
474   F_STA62 , /*Startup logo static size 6210*/ 
475   F_STA71 , /*Startup logo static size 7110*/
476
477   F_PROF61, /*Profiles numbered like in N6110*/
478   F_PROF51, /*Profiles numbered like in N5110*/
479   F_PROF33, /*Profiles numbered like in N3310.Unicode names*/
480
481   F_RING_SM,/*Binary ringtone in Smart Messaging*/
482   F_RINGBIN,/*Binary ringtone in binary format*/
483
484   F_WAP     /*WAP functions available*/
485 } feat_index;
486
487 typedef enum {
488   FN_CALENDAR=0,
489   FN_NETMONITOR,
490   FN_CALLERGROUPS,
491   FN_PHONEBOOK,
492   FN_AUTHENTICATION,
493   FN_DATACALLS,
494   FN_KEYPRESS,
495   FN_SMSCDEFAULT,
496   FN_SPEEDDIAL,
497   FN_SCREENSAVER,
498   FN_DTMF, /*10*/
499   FN_SMS,
500   FN_NOPOWERFRAME,
501   FN_STARTUP,
502   FN_PROFILES,
503   FN_RINGTONES,
504   FN_WAP,
505   FN_RINGNUMBER
506 } featnum_index;
507
508 /* For models table */
509 typedef struct {
510   char *model;
511   char *number;
512   feat_index features[18];  
513 } OnePhoneModel;
514
515 extern char *GetModelName ();
516 int GetModelFeature (featnum_index num);
517
518 extern bool AppendLog(u8 *buffer, int length,bool format);
519 extern bool AppendLogText(u8 *buffer,bool format);
520
521 typedef struct {
522   int                SIMPhonebookUsed;
523   int                SIMPhonebookSize;
524   GSM_PhonebookEntry SIMPhonebook[250];
525
526   int                PhonePhonebookUsed;
527   int                PhonePhonebookSize;
528   GSM_PhonebookEntry PhonePhonebook[500];
529
530   bool               CallerAvailable;
531   GSM_Bitmap         CallerGroups[5];
532
533   bool               SpeedAvailable;
534   GSM_SpeedDial      SpeedDials[8];
535
536   bool               OperatorLogoAvailable;
537   GSM_Bitmap         OperatorLogo;
538
539   bool               StartupLogoAvailable;
540   GSM_Bitmap         StartupLogo;
541
542   GSM_Bitmap         StartupText;
543 } GSM_Backup;
544
545 #endif  /* __gsm_api_h */