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. */
232 char *MBUSModels; /* Models covered by this type, pipe '|' delimited. */
234 char *InfraredModels; /* Models covered by this type, pipe '|' delimited. */
236 char *DLR3Models; /* Models covered by this type, pipe '|' delimited. */
238 char *ATModels; /* Models covered by this type, pipe '|' delimited. */
240 char *IrdaModels; /* Models covered by this type, pipe '|' delimited. */
242 char *TekramModels; /* Models covered by this type, pipe '|' delimited. */
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. */
251 GSM_RFUnits RFLevelUnits;
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. */
258 float MaxBatteryLevel;
259 float MinBatteryLevel;
260 GSM_BatteryUnits BatteryLevelUnits;
262 /* Information about date, time and alarm support. In case of alarm
263 information we provide value for the number of alarms supported. */
265 GSM_DateTimeSupport DateTimeSupport;
266 GSM_DateTimeSupport AlarmSupport;
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);
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);
279 GSM_ConnectionType GetConnectionTypeFromString(char *Connection);
281 bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type);
282 bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type);
284 /* Define these as externs so that app code can pick them up. */
286 extern bool *GSM_LinkOK;
287 extern GSM_Information *GSM_Info;
288 extern GSM_Functions *GSM;
289 extern GSM_Protocol *Protocol;
291 GSM_PhonebookEntry *CurrentPhonebookEntry;
292 GSM_Error CurrentPhonebookError;
294 GSM_SpeedDial *CurrentSpeedDialEntry;
295 GSM_Error CurrentSpeedDialError;
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];
301 GSM_SMSMessage *CurrentSMSMessage;
302 GSM_Error CurrentSMSMessageError;
303 int CurrentSMSPointer;
305 GSM_SMSFolders *CurrentSMSFolders;
306 GSM_Error CurrentSMSFoldersError;
307 int CurrentSMSFoldersCount;
309 GSM_OneSMSFolder CurrentSMSFolder;
310 GSM_Error CurrentSMSFolderError;
311 int CurrentSMSFolderID;
313 GSM_MemoryStatus *CurrentMemoryStatus;
314 GSM_Error CurrentMemoryStatusError;
316 GSM_NetworkInfo *CurrentNetworkInfo;
317 GSM_Error CurrentNetworkInfoError;
319 GSM_SMSStatus *CurrentSMSStatus;
320 GSM_Error CurrentSMSStatusError;
322 GSM_MessageCenter *CurrentMessageCenter;
323 GSM_Error CurrentMessageCenterError;
325 int *CurrentSecurityCodeStatus;
326 GSM_Error CurrentSecurityCodeError;
327 GSM_SecurityCode *CurrentSecurityCode;
329 GSM_DateTime *CurrentDateTime;
330 GSM_Error CurrentDateTimeError;
332 GSM_Error CurrentResetPhoneSettingsError;
334 GSM_DateTime *CurrentAlarm;
335 GSM_Error CurrentAlarmError;
337 GSM_CalendarNote *CurrentCalendarNote;
338 GSM_Error CurrentCalendarNoteError;
340 GSM_NotesInfo CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
341 GSM_Error CurrentCalendarNotesInfoError;
343 int *CurrentFirstCalendarFreePos;
344 GSM_Error CurrentFirstCalendarFreePosError;
346 GSM_Error CurrentSetDateTimeError;
347 GSM_Error CurrentSetAlarmError;
349 GSM_Error CurrentEnableExtendedCommandsError;
355 int CurrentDisplayStatus;
356 GSM_Error CurrentDisplayStatusError;
358 char *CurrentNetmonitor;
359 GSM_Error CurrentNetmonitorError;
361 GSM_Bitmap *CurrentGetBitmap;
362 GSM_Error CurrentGetBitmapError;
364 GSM_Error CurrentSetBitmapError;
366 GSM_Error CurrentSendDTMFError;
368 GSM_Profile *CurrentProfile;
369 GSM_Error CurrentProfileError;
371 GSM_Error CurrentDisplayOutputError;
373 GSM_CBMessage *CurrentCBMessage;
374 GSM_Error CurrentCBError;
376 int CurrentPressKeyEvent;
377 GSM_Error CurrentPressKeyError;
379 GSM_Error CurrentPlayToneError;
381 GSM_Error CurrentDialVoiceError;
383 GSM_Error CurrentGetOperatorNameError;
384 GSM_Network *CurrentGetOperatorNameNetwork;
385 GSM_Error CurrentSetOperatorNameError;
387 GSM_Error CurrentGetIMEIError;
389 GSM_Error CurrentGetHWError;
391 unsigned char CurrentPPS[4];
392 GSM_Error CurrentProductProfileSettingsError;
394 char CurrentIncomingCall[20];
396 GSM_Error CurrentBinRingtoneError;
397 GSM_BinRingtone *CurrentGetBinRingtone;
399 GSM_Error CurrentRingtoneError;
401 GSM_Error CurrentMagicError;
403 GSM_Error CurrentSimlockInfoError;
404 GSM_AllSimlocks *CurrentSimLock;
406 GSM_Error CurrentGetWAPBookmarkError;
407 GSM_Error CurrentSetWAPBookmarkError;
408 GSM_WAPBookmark *WAPBookmark;
410 GSM_Error CurrentGetWAPSettingsError;
411 GSM_WAPSettings *WAPSettings;
413 GSM_Error CurrentCallDivertError;
414 GSM_CallDivert *CurrentCallDivert;
416 char *CurrentManufacturer;
418 /* This is the connection type used in gnokii. */
419 GSM_ConnectionType CurrentConnectionType;
421 /* Pointer to a callback function used to return changes to a calls status */
422 /* This saves unreliable polling */
423 void (*CurrentCallPassup)(char c);
425 /* Pointer to callback function in user code to be called when RLP frames
427 void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
429 /* Used to disconnect the call */
430 u8 CurrentCallSequenceNumber;
434 bool CurrentRequestTerminate;
436 bool CurrentDisableKeepAlive;
438 /* Prototype for the functions actually provided by gsm-api.c. */
440 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
442 bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
444 char *GetMygnokiiVersion();
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.*/
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*/
456 F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/
457 F_DATA71, /*Datacalls using AT commands*/
459 F_SMS, /*SMS with Inbox, Outbox*/
460 F_SMS71, /*SMS with SMS folders like in 7110*/ /*10*/
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*/
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*/
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*/
481 F_RING_SM,/*Binary ringtone in Smart Messaging*/
482 F_RINGBIN,/*Binary ringtone in binary format*/
484 F_WAP /*WAP functions available*/
508 /* For models table */
512 feat_index features[18];
515 extern char *GetModelName ();
516 int GetModelFeature (featnum_index num);
518 extern bool AppendLog(u8 *buffer, int length,bool format);
519 extern bool AppendLogText(u8 *buffer,bool format);
522 int SIMPhonebookUsed;
523 int SIMPhonebookSize;
524 GSM_PhonebookEntry SIMPhonebook[250];
526 int PhonePhonebookUsed;
527 int PhonePhonebookSize;
528 GSM_PhonebookEntry PhonePhonebook[500];
530 bool CallerAvailable;
531 GSM_Bitmap CallerGroups[5];
534 GSM_SpeedDial SpeedDials[8];
536 bool OperatorLogoAvailable;
537 GSM_Bitmap OperatorLogo;
539 bool StartupLogoAvailable;
540 GSM_Bitmap StartupLogo;
542 GSM_Bitmap StartupText;
545 #endif /* __gsm_api_h */