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"
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
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
46 /* FIXME: comment this. */
48 GSM_Error (*Initialise)( char *port_device, char *initlength,
49 GSM_ConnectionType connection,
50 void (*rlp_callback)(RLP_F96Frame *frame));
52 void (*DispatchMessage) (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
54 void (*Terminate)(void);
56 void (*KeepAlive)(void);
58 GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry );
60 GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry );
62 GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry);
64 GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry);
66 GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status);
68 GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status);
70 GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter );
72 GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter );
74 GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message );
76 GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message );
78 GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message);
80 GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message);
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 );
88 /* Works the same as GetRFLevel, except returns battery
90 GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level );
92 GSM_Error (*GetPowerSource)( GSM_PowerSource *source);
94 GSM_Error (*GetDisplayStatus)( int *Status);
96 GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code);
98 GSM_Error (*GetSecurityCodeStatus)( int *Status );
100 GSM_Error (*GetSecurityCode)( GSM_SecurityCode *Code);
102 GSM_Error (*GetIMEI)( char *imei );
104 GSM_Error (*GetRevision)( char *revision );
106 GSM_Error (*GetModel)( char *model );
108 GSM_Error (*GetDateTime)( GSM_DateTime *date_time);
110 GSM_Error (*SetDateTime)( GSM_DateTime *date_time);
112 GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time );
114 GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time );
116 GSM_Error (*DialVoice)( char *Number);
118 GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c));
120 GSM_Error (*GetIncomingCallNr)( char *Number );
122 GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo );
124 GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote);
126 GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote);
128 GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote);
130 GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen );
132 GSM_Error (*SendDTMF) ( char *String );
134 GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap );
136 GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap );
138 GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone , int *maxlength);
140 GSM_Error (*SetBinRingtone) ( GSM_BinRingtone *ringtone);
142 GSM_Error (*GetBinRingtone) ( GSM_BinRingtone *ringtone);
144 GSM_Error (*Reset) ( unsigned char type );
146 GSM_Error (*GetProfile) ( GSM_Profile *Profile );
148 GSM_Error (*SetProfile) ( GSM_Profile *Profile );
150 bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx );
152 GSM_Error (*CancelCall) ();
154 GSM_Error (*PressKey) (int key, int event);
156 GSM_Error (*EnableDisplayOutput) ();
158 GSM_Error (*DisableDisplayOutput) ();
160 GSM_Error (*EnableCellBroadcast) ();
162 GSM_Error (*DisableCellBroadcast) ();
164 GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message );
166 GSM_Error (*PlayTone) (int Herz, u8 Volume);
168 GSM_Error (*GetProductProfileSetting) ( GSM_PPS *PPS);
170 GSM_Error (*SetProductProfileSetting) ( GSM_PPS *PPS);
172 GSM_Error (*GetOperatorName) ( GSM_Network *operator);
174 GSM_Error (*SetOperatorName) ( GSM_Network *operator);
176 GSM_Error (*GetVoiceMailbox) ( GSM_PhonebookEntry *entry);
178 GSM_Error (*PhoneTests) ();
180 GSM_Error (*SimlockInfo) ( GSM_AllSimlocks *siml);
182 GSM_Error (*GetCalendarNotesInfo) (GSM_NotesInfo *NotesInfo);
184 GSM_Error (*GetSMSFolders) ( GSM_SMSFolders *folders);
186 GSM_Error (*ResetPhoneSettings) ();
188 GSM_Error (*GetWAPBookmark) ( GSM_WAPBookmark *bookmark);
190 GSM_Error (*SetWAPBookmark) ( GSM_WAPBookmark *bookmark);
192 GSM_Error (*GetWAPSettings) ( GSM_WAPSettings *settings);
194 GSM_Error (*CallDivert) ( GSM_CallDivert *cd );
196 GSM_Error (*AnswerCall) (char s);
198 GSM_Error (*GetManufacturer)( char *manufacturer );
204 /* FIXME: comment this. */
206 GSM_Error (*Initialise)( char *port_device, char *initlength,
207 GSM_ConnectionType connection,
208 void (*rlp_callback)(RLP_F96Frame *frame));
210 int (*SendMessage) (u16 message_length, u8 message_type, u8 *buffer);
212 int (*SendFrame) (u16 message_length, u8 message_type, u8 *buffer);
214 int (*WritePhone) (u16 length, u8 *buffer);
216 void (*Terminate)(void);
218 void (*StateMachine)(unsigned char rx_byte);
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 */
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. */
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. */
246 GSM_RFUnits RFLevelUnits;
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. */
253 float MaxBatteryLevel;
254 float MinBatteryLevel;
255 GSM_BatteryUnits BatteryLevelUnits;
257 /* Information about date, time and alarm support. In case of alarm
258 information we provide value for the number of alarms supported. */
260 GSM_DateTimeSupport DateTimeSupport;
261 GSM_DateTimeSupport AlarmSupport;
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);
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);
274 GSM_ConnectionType GetConnectionTypeFromString(char *Connection);
276 bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type);
277 bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type);
279 /* Define these as externs so that app code can pick them up. */
281 extern bool *GSM_LinkOK;
282 extern GSM_Information *GSM_Info;
283 extern GSM_Functions *GSM;
284 extern GSM_Protocol *Protocol;
286 GSM_PhonebookEntry *CurrentPhonebookEntry;
287 GSM_Error CurrentPhonebookError;
289 GSM_SpeedDial *CurrentSpeedDialEntry;
290 GSM_Error CurrentSpeedDialError;
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];
296 GSM_SMSMessage *CurrentSMSMessage;
297 GSM_Error CurrentSMSMessageError;
298 int CurrentSMSPointer;
300 GSM_SMSFolders *CurrentSMSFolders;
301 GSM_Error CurrentSMSFoldersError;
302 int CurrentSMSFoldersCount;
304 GSM_OneSMSFolder CurrentSMSFolder;
305 GSM_Error CurrentSMSFolderError;
306 int CurrentSMSFolderID;
308 GSM_MemoryStatus *CurrentMemoryStatus;
309 GSM_Error CurrentMemoryStatusError;
311 GSM_NetworkInfo *CurrentNetworkInfo;
312 GSM_Error CurrentNetworkInfoError;
314 GSM_SMSStatus *CurrentSMSStatus;
315 GSM_Error CurrentSMSStatusError;
317 GSM_MessageCenter *CurrentMessageCenter;
318 GSM_Error CurrentMessageCenterError;
320 int *CurrentSecurityCodeStatus;
321 GSM_Error CurrentSecurityCodeError;
322 GSM_SecurityCode *CurrentSecurityCode;
324 GSM_DateTime *CurrentDateTime;
325 GSM_Error CurrentDateTimeError;
327 GSM_Error CurrentResetPhoneSettingsError;
329 GSM_DateTime *CurrentAlarm;
330 GSM_Error CurrentAlarmError;
332 GSM_CalendarNote *CurrentCalendarNote;
333 GSM_Error CurrentCalendarNoteError;
335 GSM_NotesInfo CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
336 GSM_Error CurrentCalendarNotesInfoError;
338 int *CurrentFirstCalendarFreePos;
339 GSM_Error CurrentFirstCalendarFreePosError;
341 GSM_Error CurrentSetDateTimeError;
342 GSM_Error CurrentSetAlarmError;
344 GSM_Error CurrentEnableExtendedCommandsError;
350 int CurrentDisplayStatus;
351 GSM_Error CurrentDisplayStatusError;
353 char *CurrentNetmonitor;
354 GSM_Error CurrentNetmonitorError;
356 GSM_Bitmap *CurrentGetBitmap;
357 GSM_Error CurrentGetBitmapError;
359 GSM_Error CurrentSetBitmapError;
361 GSM_Error CurrentSendDTMFError;
363 GSM_Profile *CurrentProfile;
364 GSM_Error CurrentProfileError;
366 GSM_Error CurrentDisplayOutputError;
368 GSM_CBMessage *CurrentCBMessage;
369 GSM_Error CurrentCBError;
371 int CurrentPressKeyEvent;
372 GSM_Error CurrentPressKeyError;
374 GSM_Error CurrentPlayToneError;
376 GSM_Error CurrentDialVoiceError;
378 GSM_Error CurrentGetOperatorNameError;
379 GSM_Network *CurrentGetOperatorNameNetwork;
380 GSM_Error CurrentSetOperatorNameError;
382 GSM_Error CurrentGetIMEIError;
384 GSM_Error CurrentGetHWError;
386 unsigned char CurrentPPS[4];
387 GSM_Error CurrentProductProfileSettingsError;
389 char CurrentIncomingCall[20];
391 GSM_Error CurrentBinRingtoneError;
392 GSM_BinRingtone *CurrentGetBinRingtone;
394 GSM_Error CurrentRingtoneError;
396 GSM_Error CurrentMagicError;
398 GSM_Error CurrentSimlockInfoError;
399 GSM_AllSimlocks *CurrentSimLock;
401 GSM_Error CurrentGetWAPBookmarkError;
402 GSM_Error CurrentSetWAPBookmarkError;
403 GSM_WAPBookmark *WAPBookmark;
405 GSM_Error CurrentGetWAPSettingsError;
406 GSM_WAPSettings *WAPSettings;
408 GSM_Error CurrentCallDivertError;
409 GSM_CallDivert *CurrentCallDivert;
411 char *CurrentManufacturer;
413 /* This is the connection type used in gnokii. */
414 GSM_ConnectionType CurrentConnectionType;
416 /* Pointer to a callback function used to return changes to a calls status */
417 /* This saves unreliable polling */
418 void (*CurrentCallPassup)(char c);
420 /* Pointer to callback function in user code to be called when RLP frames
422 void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
424 /* Used to disconnect the call */
425 u8 CurrentCallSequenceNumber;
429 bool CurrentRequestTerminate;
431 bool CurrentDisableKeepAlive;
433 /* Prototype for the functions actually provided by gsm-api.c. */
435 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
437 bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
439 char *GetMygnokiiVersion();
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.*/
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*/
451 F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/
452 F_DATA71, /*Datacalls using AT commands*/
454 F_SMS, /*SMS with Inbox, Outbox*/ /*10*/
455 F_SMS71, /*SMS with SMS folders like in 7110*/
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*/
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*/
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*/
476 F_RING_SM,/*Binary ringtone in Smart Messaging*/
477 F_RINGBIN,/*Binary ringtone in binary format*/
479 F_WAP /*WAP functions available*/ /*30*/
503 /* For models table */
507 feat_index features[18];
510 extern char *GetModelName ();
511 int GetModelFeature (featnum_index num);
513 extern bool AppendLog(u8 *buffer, int length,bool format);
514 extern bool AppendLogText(u8 *buffer,bool format);
517 int SIMPhonebookUsed;
518 int SIMPhonebookSize;
519 GSM_PhonebookEntry SIMPhonebook[250];
521 int PhonePhonebookUsed;
522 int PhonePhonebookSize;
523 GSM_PhonebookEntry PhonePhonebook[500];
525 bool CallerAvailable;
526 GSM_Bitmap CallerGroups[5];
529 GSM_SpeedDial SpeedDials[8];
531 bool OperatorLogoAvailable;
532 GSM_Bitmap OperatorLogo;
534 bool StartupLogoAvailable;
535 GSM_Bitmap StartupLogo;
537 GSM_Bitmap StartupText;
540 #endif /* __gsm_api_h */