5 A Linux/Unix toolset and driver for Nokia mobile phones.
7 Released under the terms of the GNU GPL, see file COPYING for more details.
9 Header file for the various functions, definitions etc. used to implement
10 the handset interface. See gsm-api.c for more details.
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"
27 #include "gsm-ringtones.h"
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
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
50 /* FIXME: comment this. */
52 GSM_Error (*Initialise)( char *port_device, char *initlength,
53 GSM_ConnectionType connection,
54 void (*rlp_callback)(RLP_F96Frame *frame));
56 void (*DispatchMessage) (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
58 void (*Terminate)(void);
60 void (*KeepAlive)(void);
62 GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry );
64 GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry );
66 GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry);
68 GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry);
70 GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status);
72 GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status);
74 GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter );
76 GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter );
78 GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message );
80 GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message );
82 GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message);
84 GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message);
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 );
92 /* Works the same as GetRFLevel, except returns battery
94 GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level );
96 GSM_Error (*GetPowerSource)( GSM_PowerSource *source);
98 GSM_Error (*GetDisplayStatus)( int *Status);
100 GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code);
102 GSM_Error (*GetSecurityCodeStatus)( int *Status );
104 GSM_Error (*GetSecurityCode)( GSM_SecurityCode *Code);
106 GSM_Error (*GetIMEI)( char *imei );
108 GSM_Error (*GetRevision)( char *revision );
110 GSM_Error (*GetModel)( char *model );
112 GSM_Error (*GetDateTime)( GSM_DateTime *date_time);
114 GSM_Error (*SetDateTime)( GSM_DateTime *date_time);
116 GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time );
118 GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time );
120 GSM_Error (*DialVoice)( char *Number);
122 GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c));
124 GSM_Error (*GetIncomingCallNr)( char *Number );
126 GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo );
128 GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote);
130 GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote);
132 GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote);
134 GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen );
136 GSM_Error (*SendDTMF) ( char *String );
138 GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap );
140 GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap );
142 GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone , int *maxlength);
144 GSM_Error (*SetBinRingtone) ( GSM_BinRingtone *ringtone);
146 GSM_Error (*GetBinRingtone) ( GSM_BinRingtone *ringtone);
148 GSM_Error (*Reset) ( unsigned char type );
150 GSM_Error (*GetProfile) ( GSM_Profile *Profile );
152 GSM_Error (*SetProfile) ( GSM_Profile *Profile );
154 bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx );
156 GSM_Error (*CancelCall) ();
158 GSM_Error (*PressKey) (int key, int event);
160 GSM_Error (*EnableDisplayOutput) ();
162 GSM_Error (*DisableDisplayOutput) ();
164 GSM_Error (*EnableCellBroadcast) ();
166 GSM_Error (*DisableCellBroadcast) ();
168 GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message );
170 GSM_Error (*PlayTone) (int Herz, u8 Volume);
172 GSM_Error (*GetProductProfileSetting) ( GSM_PPS *PPS);
174 GSM_Error (*SetProductProfileSetting) ( GSM_PPS *PPS);
176 GSM_Error (*GetOperatorName) ( GSM_Network *operator);
178 GSM_Error (*SetOperatorName) ( GSM_Network *operator);
180 GSM_Error (*GetVoiceMailbox) ( GSM_PhonebookEntry *entry);
182 GSM_Error (*PhoneTests) ();
184 GSM_Error (*SimlockInfo) ( GSM_AllSimlocks *siml);
186 GSM_Error (*GetCalendarNotesInfo) (GSM_NotesInfo *NotesInfo);
188 GSM_Error (*GetSMSFolders) ( GSM_SMSFolders *folders);
190 GSM_Error (*ResetPhoneSettings) ();
192 GSM_Error (*GetWAPBookmark) ( GSM_WAPBookmark *bookmark);
194 GSM_Error (*SetWAPBookmark) ( GSM_WAPBookmark *bookmark);
196 GSM_Error (*GetWAPSettings) ( GSM_WAPSettings *settings);
198 GSM_Error (*CallDivert) ( GSM_CallDivert *cd );
200 GSM_Error (*AnswerCall) (char s);
202 GSM_Error (*GetManufacturer)( char *manufacturer );
208 /* FIXME: comment this. */
210 GSM_Error (*Initialise)( char *port_device, char *initlength,
211 GSM_ConnectionType connection,
212 void (*rlp_callback)(RLP_F96Frame *frame));
214 int (*SendMessage) (u16 message_length, u8 message_type, u8 *buffer);
216 int (*SendFrame) (u16 message_length, u8 message_type, u8 *buffer);
218 int (*WritePhone) (u16 length, u8 *buffer);
220 void (*Terminate)(void);
222 void (*StateMachine)(unsigned char rx_byte);
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 */
234 char *FBUSModels; /* Models covered by this type, pipe '|' delimited. */
236 char *MBUSModels; /* Models covered by this type, pipe '|' delimited. */
238 char *InfraredModels; /* Models covered by this type, pipe '|' delimited. */
240 char *DLR3Models; /* Models covered by this type, pipe '|' delimited. */
242 char *ATModels; /* Models covered by this type, pipe '|' delimited. */
244 char *IrdaModels; /* Models covered by this type, pipe '|' delimited. */
246 char *TekramModels; /* Models covered by this type, pipe '|' delimited. */
248 /* Minimum and maximum levels for RF signal strength. Units are as per the
249 setting of RFLevelUnits. The setting of RFLevelUnits indicates the
250 default or "native" units used. In the case of the 3110 and 6110 series
251 these are arbitrary, ranging from 0 to 4. */
255 GSM_RFUnits RFLevelUnits;
257 /* Minimum and maximum levels for battery level. Again, units are as per the
258 setting of GSM_BatteryLevelUnits. The value that BatteryLevelUnits is set
259 to indicates the "native" or default value that the phone supports. In the
260 case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */
262 float MaxBatteryLevel;
263 float MinBatteryLevel;
264 GSM_BatteryUnits BatteryLevelUnits;
266 /* Information about date, time and alarm support. In case of alarm
267 information we provide value for the number of alarms supported. */
269 GSM_DateTimeSupport DateTimeSupport;
270 GSM_DateTimeSupport AlarmSupport;
274 void NULL_Terminate(void);
275 void NULL_KeepAlive();
276 bool NULL_WritePhone (u16 length, u8 *buffer);
277 void NULL_TX_DisplayMessage(u16 MessageLength, u8 *MessageBuffer);
279 GSM_Error NULL_WaitUntil (int time, GSM_Error *value);
280 GSM_Error NULL_SendMessageSequence (int time, GSM_Error *value,
281 u16 message_length, u8 message_type, u8 *buffer);
283 GSM_ConnectionType GetConnectionTypeFromString(char *Connection);
285 bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type);
286 bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type);
288 /* Define these as externs so that app code can pick them up. */
290 extern bool *GSM_LinkOK;
291 extern GSM_Information *GSM_Info;
292 extern GSM_Functions *GSM;
293 extern GSM_Protocol *Protocol;
295 extern GSM_PhonebookEntry *CurrentPhonebookEntry;
296 extern GSM_Error CurrentPhonebookError;
298 extern GSM_SpeedDial *CurrentSpeedDialEntry;
299 extern GSM_Error CurrentSpeedDialError;
301 extern unsigned char Current_IMEI[GSM_MAX_IMEI_LENGTH];
302 extern unsigned char Current_Revision[GSM_MAX_REVISION_LENGTH];
303 extern unsigned char Current_Model[GSM_MAX_MODEL_LENGTH];
306 extern GSM_SMSMessage *CurrentSMSMessage;
307 extern GSM_Error CurrentSMSMessageError;
308 extern int CurrentSMSPointer;
310 extern GSM_SMSFolders *CurrentSMSFolders;
311 extern GSM_Error CurrentSMSFoldersError;
312 extern int CurrentSMSFoldersCount;
314 extern GSM_OneSMSFolder CurrentSMSFolder;
315 extern GSM_Error CurrentSMSFolderError;
316 extern int CurrentSMSFolderID;
319 extern GSM_MemoryStatus *CurrentMemoryStatus;
320 extern GSM_Error CurrentMemoryStatusError;
323 extern GSM_NetworkInfo *CurrentNetworkInfo;
324 extern GSM_Error CurrentNetworkInfoError;
326 extern GSM_SMSStatus *CurrentSMSStatus;
327 extern GSM_Error CurrentSMSStatusError;
329 extern GSM_MessageCenter *CurrentMessageCenter;
330 extern GSM_Error CurrentMessageCenterError;
332 extern int *CurrentSecurityCodeStatus;
333 extern GSM_Error CurrentSecurityCodeError;
334 extern GSM_SecurityCode *CurrentSecurityCode;
336 extern GSM_DateTime *CurrentDateTime;
337 extern GSM_Error CurrentDateTimeError;
339 extern GSM_Error CurrentResetPhoneSettingsError;
341 extern GSM_DateTime *CurrentAlarm;
342 extern GSM_Error CurrentAlarmError;
344 extern GSM_CalendarNote *CurrentCalendarNote;
345 extern GSM_Error CurrentCalendarNoteError;
347 extern GSM_NotesInfo CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
348 extern GSM_Error CurrentCalendarNotesInfoError;
350 extern GSM_Error CurrentSetDateTimeError;
351 extern GSM_Error CurrentSetAlarmError;
353 extern int *CurrentFirstCalendarFreePos;
354 extern GSM_Error CurrentFirstCalendarFreePosError;
357 extern GSM_Error CurrentEnableExtendedCommandsError;
359 extern int CurrentRFLevel,
364 extern int CurrentDisplayStatus;
365 extern GSM_Error CurrentDisplayStatusError;
367 extern char *CurrentNetmonitor;
368 extern GSM_Error CurrentNetmonitorError;
370 extern GSM_Bitmap *CurrentGetBitmap;
371 extern GSM_Error CurrentGetBitmapError;
373 extern GSM_Error CurrentSetBitmapError;
375 extern GSM_Error CurrentSendDTMFError;
377 extern GSM_Profile *CurrentProfile;
378 extern GSM_Error CurrentProfileError;
380 extern GSM_Error CurrentDisplayOutputError;
382 extern GSM_CBMessage *CurrentCBMessage;
383 extern GSM_Error CurrentCBError;
385 extern int CurrentPressKeyEvent;
386 extern GSM_Error CurrentPressKeyError;
388 extern GSM_Error CurrentPlayToneError;
391 extern GSM_Error CurrentDialVoiceError;
394 extern GSM_Error CurrentGetOperatorNameError;
395 extern GSM_Network *CurrentGetOperatorNameNetwork;
396 extern GSM_Error CurrentSetOperatorNameError;
399 extern GSM_Error CurrentGetIMEIError;
401 extern GSM_Error CurrentGetHWError;
404 extern unsigned char CurrentPPS[4];
405 extern GSM_Error CurrentProductProfileSettingsError;
407 extern char CurrentIncomingCall[20];
409 extern GSM_Error CurrentBinRingtoneError;
410 extern GSM_BinRingtone *CurrentGetBinRingtone;
412 extern GSM_Error CurrentRingtoneError;
415 extern GSM_Error CurrentMagicError;
418 extern GSM_Error CurrentSimlockInfoError;
419 extern GSM_AllSimlocks *CurrentSimLock;
421 extern GSM_Error CurrentGetWAPBookmarkError;
422 extern GSM_Error CurrentSetWAPBookmarkError;
423 extern GSM_WAPBookmark *WAPBookmark;
425 extern GSM_Error CurrentGetWAPSettingsError;
426 extern GSM_WAPSettings *WAPSettings;
428 extern GSM_Error CurrentCallDivertError;
429 extern GSM_CallDivert *CurrentCallDivert;
431 extern char *CurrentManufacturer;
434 /* This is the connection type used in gnokii. */
435 extern GSM_ConnectionType CurrentConnectionType;
437 /* Pointer to a callback function used to return changes to a calls status */
438 /* This saves unreliable polling */
439 extern void (*CurrentCallPassup)(char c);
441 /* Pointer to callback function in user code to be called when RLP frames
443 extern void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
445 /* Used to disconnect the call */
446 extern u8 CurrentCallSequenceNumber;
448 extern bool CurrentLinkOK;
450 extern bool CurrentRequestTerminate;
453 extern bool CurrentDisableKeepAlive;
456 /* Prototype for the functions actually provided by gsm-api.c. */
458 extern GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
461 extern bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
464 extern char *GetMygnokiiVersion();
467 F_CAL61=0,/*Calendar in 6110 style - 4 types,...*/
468 F_CAL33, /*Calendar in 3310 style - 10 reminders, Unicode, 3 coding types*/
469 F_CAL71, /*Calendar in 7110 style - 4 types, recurrance, etc.*/
471 F_PBK33, /*Phonebook in Unicode. 3310 style - name and entry*/
472 F_PBK71, /*Extended phonebook - multiple numbers,Unicode.Like in 7110*/
474 F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/
475 F_DATA71, /*Datacalls using AT commands*/
477 F_SMS, /*SMS with Inbox, Outbox*/
478 F_SMS71, /*SMS with SMS folders like in 7110*/
480 F_AUTH, /*We can make authentication and have "Accessory connected" like in 6110*/
481 F_NETMON, /*Netmonitor available*/ /*10*/
482 F_CALER61,/*Caller groups in 6110 style - 5 groups with members*/
483 F_KEYB, /*We can press keys*/
484 F_SMSCDEF,/*SMSC can have default recipient*/
485 F_SPEED, /*We can handle speed dials*/
486 F_SCRSAV, /*We have screen savers*/
487 F_DTMF, /*We can handle DTMF sequences*/
488 F_NOPOWER,/*We must get power/battery info from netmonitor*/
490 F_STANIM, /*Startup logo animated or static*/
491 F_STA , /*Startup logo static*/
492 F_STA62 , /*Startup logo static size 6210*/ /*20*/
493 F_STA71 , /*Startup logo static size 7110*/
495 F_PROF61, /*Profiles numbered like in N6110*/
496 F_PROF51, /*Profiles numbered like in N5110*/
497 F_PROF33, /*Profiles numbered like in N3310.Unicode names*/
499 F_RING_SM,/*Binary ringtone in Smart Messaging*/
500 F_RINGBIN,/*Binary ringtone in binary format*/
502 F_WAP /*WAP functions available*/
525 /* For models table */
529 feat_index features[17];
532 extern char *GetModelName ();
533 extern int GetModelFeature (featnum_index num);
536 extern bool AppendLog(u8 *buffer, int length,bool format);
537 extern bool AppendLogText(u8 *buffer,bool format);
539 #define AppendLog(buffer,length,format)
540 #define AppendLogText(buffer,format)
544 int SIMPhonebookUsed;
545 int SIMPhonebookSize;
546 GSM_PhonebookEntry SIMPhonebook[250];
548 int PhonePhonebookUsed;
549 int PhonePhonebookSize;
550 GSM_PhonebookEntry PhonePhonebook[500];
552 bool CallerAvailable;
553 GSM_Bitmap CallerGroups[5];
556 GSM_SpeedDial SpeedDials[8];
558 bool OperatorLogoAvailable;
559 GSM_Bitmap OperatorLogo;
561 bool StartupLogoAvailable;
562 GSM_Bitmap StartupLogo;
564 GSM_Bitmap StartupText;
567 #endif /* __gsm_api_h */