7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Header file for the definitions, enums etc. that are used by all models of
17 Revision 1.1.1.1 2001/11/25 21:59:20 short
18 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
20 Revision 1.83 2001/11/17 20:18:33 pkot
21 Added dau9p connection type for 6210/7110
23 Revision 1.82 2001/11/13 16:12:21 pkot
24 Preparing libsms to get to work. 6210/7110 SMS and SMS Folder updates
26 Revision 1.81 2001/11/08 16:34:20 pkot
27 Updates to work with new libsms
29 Revision 1.80 2001/08/20 23:36:27 pkot
30 More cleanup in AT code (Manfred Jonsson)
32 Revision 1.79 2001/07/27 00:02:22 pkot
33 Generic AT support for the new structure (Manfred Jonsson)
35 Revision 1.78 2001/06/28 00:28:45 pkot
36 Small docs updates (Pawel Kot)
41 #ifndef __gsm_common_h
42 #define __gsm_common_h
46 #include "data/rlp-common.h"
49 /* Type of connection. Now we support serial connection with FBUS cable and
50 IR (only with 61x0 models) */
53 GCT_Serial, /* Serial connection. */
54 GCT_DAU9P, /* Serial connection using DAU9P cable; use only with 6210/7110 if you want faster initialization */
55 GCT_Infrared, /* Infrared connection. */
56 GCT_Tekram, /* Tekram Ir-Dongle */
60 /* Maximum length of device name for serial port */
62 #define GSM_MAX_DEVICE_NAME_LENGTH (100)
64 /* Define an enum for specifying memory types for retrieving phonebook
65 entries, SMS messages etc. This type is not mobile specific - the model
66 code should take care of translation to mobile specific numbers - see 6110
68 01/07/99: Two letter codes follow GSM 07.07 release 6.2.0
72 GMT_ME, /* Internal memory of the mobile equipment */
73 GMT_SM, /* SIM card memory */
74 GMT_FD, /* Fixed dial numbers */
75 GMT_ON, /* Own numbers */
76 GMT_EN, /* Emergency numbers */
77 GMT_DC, /* Dialled numbers */
78 GMT_RC, /* Received numbers */
79 GMT_MC, /* Missed numbers */
80 GMT_LD, /* Last dialed */
81 GMT_MT, /* combined ME and SIM phonebook */
82 GMT_TA, /* for compatibility only: TA=computer memory */
83 GMT_CB, /* Currently selected memory */
84 GMT_XX = 0xff /* Error code for unknown memory type (returned by fbus-xxxx functions). */
87 /* Power source types */
90 GPS_ACDC=1, /* AC/DC powered (charging) */
91 GPS_BATTERY /* Internal battery */
94 /* Definition of security codes. */
97 GSCT_SecurityCode = 0x01, /* Security code. */
99 GSCT_Pin2, /* PIN 2. */
101 GSCT_Puk2, /* PUK 2. */
102 GSCT_None /* Code not needed. */
103 } GSM_SecurityCodeType;
105 /* Security code definition. */
108 GSM_SecurityCodeType Type; /* Type of the code. */
109 char Code[10]; /* Actual code. */
112 /* This structure is used to get the current network status */
115 char NetworkCode[10]; /* GSM network code */
116 char CellID[10]; /* CellID */
117 char LAC[10]; /* LAC */
120 /* Limits for sizing of array in GSM_PhonebookEntry. Individual handsets may
121 not support these lengths so they have their own limits set. */
123 #define GSM_MAX_PHONEBOOK_NAME_LENGTH (50) /* For 7110 */
124 #define GSM_MAX_PHONEBOOK_NUMBER_LENGTH (48) /* For 7110 */
125 #define GSM_MAX_PHONEBOOK_TEXT_LENGTH (60) /* For 7110 */
126 #define GSM_MAX_PHONEBOOK_SUB_ENTRIES (8) /* For 7110 */
127 /* 7110 is able to in one
128 * entry 5 numbers and 2
129 * texts [email,notice,postal] */
131 /* Here is a macro for models that do not support caller groups. */
133 #define GSM_GROUPS_NOT_SUPPORTED -1
135 /* This data type is used to report the number of used and free positions in
136 memory (sim or internal). */
139 GSM_MemoryType MemoryType; /* Type of the memory */
140 int Used; /* Number of used positions */
141 int Free; /* Number of free positions */
144 /* Some phones (at the moment 6210/7110) supports extended phonebook
145 with additional data. Here we have structures for them */
161 GSM_Date = 0x13 /* Date is used for DC,RC,etc (last calls) */
165 bool AlarmEnabled; /* Is alarm set ? */
166 int Year; /* The complete year specification - e.g. 1999. Y2K :-) */
167 int Month; /* January = 1 */
172 int Timezone; /* The difference between local time and GMT */
176 GSM_EntryType EntryType;
177 GSM_Number_Type NumberType;
179 char Number[GSM_MAX_PHONEBOOK_TEXT_LENGTH + 1]; /* Number */
180 GSM_DateTime Date; /* or the last calls list */
183 } GSM_SubPhonebookEntry;
185 /* Define datatype for phonebook entry, used for getting/writing phonebook
189 bool Empty; /* Is this entry empty? */
190 char Name[GSM_MAX_PHONEBOOK_NAME_LENGTH + 1]; /* Plus 1 for
192 char Number[GSM_MAX_PHONEBOOK_NUMBER_LENGTH + 1]; /* Number */
193 GSM_MemoryType MemoryType; /* Type of memory */
194 int Group; /* Group */
195 int Location; /* Location */
196 GSM_DateTime Date; /* The record date and time
198 GSM_SubPhonebookEntry SubEntries[GSM_MAX_PHONEBOOK_SUB_ENTRIES];
200 * additional phonebook
202 int SubEntriesCount; /* Should be 0, if extended
203 phonebook is not used */
204 } GSM_PhonebookEntry;
206 /* This define speed dialing entries. */
209 int Number; /* Which number is used to dialing? */
210 GSM_MemoryType MemoryType; /* Memory type of the number. */
211 int Location; /* Location of the number in MemoryType. */
214 /* Define enum used to describe what sort of date/time support is
218 GDT_None, /* The mobile phone doesn't support time and date. */
219 GDT_TimeOnly, /* The mobile phone supports only time. */
220 GDT_DateOnly, /* The mobile phone supports only date. */
221 GDT_DateTime /* Wonderful phone - it supports date and time. */
222 } GSM_DateTimeSupport;
224 /* Define enums for RF units. GRF_CSQ asks for units in form used
225 in AT+CSQ command as defined by GSM 07.07 */
236 /* Define enums for Battery units. */
245 /* Define enums for Calendar Note types */
248 GCN_REMINDER=1, /* Reminder */
250 GCN_MEETING, /* Meeting */
251 GCN_BIRTHDAY /* Birthday */
252 } GSM_CalendarNoteType;
254 /* Calendar note type */
257 int Location; /* The number of the note in the phone memory */
258 GSM_CalendarNoteType Type; /* The type of the note */
259 GSM_DateTime Time; /* The time of the note */
260 GSM_DateTime Alarm; /* The alarm of the note */
261 char Text[20]; /* The text of the note */
262 char Phone[20]; /* For Call only: the phone number */
263 double Recurance; /* Recurance of the note */
266 /* This structure is provided to allow common information about the particular
267 model to be looked up in a model independant way. Some of the values here
268 define minimum and maximum levels for values retrieved by the various Get
269 functions for example battery level. They are not defined as constants to
270 allow model specific code to set them during initialisation */
274 char *Models; /* Models covered by this type, pipe '|' delimited. */
276 /* Minimum and maximum levels for RF signal strength. Units are as per the
277 setting of RFLevelUnits. The setting of RFLevelUnits indicates the
278 default or "native" units used. In the case of the 3110 and 6110 series
279 these are arbitrary, ranging from 0 to 4. */
283 GSM_RFUnits RFLevelUnits;
285 /* Minimum and maximum levels for battery level. Again, units are as per the
286 setting of GSM_BatteryLevelUnits. The value that BatteryLevelUnits is set
287 to indicates the "native" or default value that the phone supports. In the
288 case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */
290 float MaxBatteryLevel;
291 float MinBatteryLevel;
292 GSM_BatteryUnits BatteryLevelUnits;
294 /* FIXME: some very similar code is in common/misc.c */
296 /* Information about date, time and alarm support. In case of alarm
297 information we provide value for the number of alarms supported. */
299 GSM_DateTimeSupport DateTimeSupport;
300 GSM_DateTimeSupport AlarmSupport;
302 u8 StartupLogoH; /* Logo Widths and Heights - if supported */
310 /* This enum is used for display status. */
313 DS_Call_In_Progress, /* Call in progress. */
314 DS_Unknown, /* The meaning is unknown now :-( */
315 DS_Unread_SMS, /* There is Unread SMS. */
316 DS_Voice_Call, /* Voice call active. */
317 DS_Fax_Call, /* Fax call active. */
318 DS_Data_Call, /* Data call active. */
319 DS_Keyboard_Lock, /* Keyboard lock status. */
320 DS_SMS_Storage_Full /* Full SMS Memory. */
321 } DisplayStatusEntity;
335 #define GSM_MAX_BITMAP_SIZE 864
337 /* Structure to hold incoming/outgoing bitmaps (and welcome-notes). */
340 u8 height; /* Bitmap height (pixels) */
341 u8 width; /* Bitmap width (pixels) */
342 u16 size; /* Bitmap size (bytes) */
343 GSM_Bitmap_Types type; /* Bitmap type */
344 char netcode[7]; /* Network operator code */
345 char text[256]; /* Text used for welcome-note or callergroup name */
346 char dealertext[256]; /* Text used for dealer welcome-note */
347 bool dealerset; /* Is dealer welcome-note set now ? */
348 unsigned char bitmap[GSM_MAX_BITMAP_SIZE]; /* Actual Bitmap */
349 char number; /* Caller group number */
350 char ringtone; /* Ringtone no sent with caller group */
354 /* NoteValue is encoded as octave(scale)*14 + note */
355 /* where for note: c=0, d=2, e=4 .... */
356 /* ie. c#=1 and 5 and 13 are invalid */
357 /* note=255 means a pause */
359 #define MAX_RINGTONE_NOTES 256
361 /* Structure to hold note of ringtone. */
368 /* Structure to hold ringtones. */
374 GSM_RingtoneNote notes[MAX_RINGTONE_NOTES];
377 /* Structure to hold profile entries. */
380 int Number; /* The number of the profile. */
381 char Name[40]; /* The name of the profile. */
382 int DefaultName; /* 0-6, when default name is used, -1, when not. */
383 int KeypadTone; /* Volume level for keypad tones. */
384 int Lights; /* Lights on/off. */
385 int CallAlert; /* Incoming call alert. */
386 int Ringtone; /* Ringtone for incoming call alert. */
387 int Volume; /* Volume of the ringing. */
388 int MessageTone; /* The tone for message indication. */
389 int WarningTone; /* The tone for warning messages. */
390 int Vibration; /* Vibration? */
391 int CallerGroups; /* CallerGroups. */
392 int AutomaticAnswer; /* Does the phone auto-answer incoming call? */
396 #define FO_SUBMIT 0x01
398 #define FO_VPF_NONE 0x00
399 #define FO_VPF_REL 0x10
400 #define FO_VPF_ABS 0x18
401 #define FO_VPF_ENH 0x08
405 #define FO_DEFAULT (FO_SUBMIT | FO_VPF_REL | FO_SRR)
407 #define PID_DEFAULT 0x00
408 #define PID_TYPE0 0x40
409 #define PID_REPLACE1 0x41
410 #define PID_REPLACE2 0x42
411 #define PID_REPLACE3 0x43
412 #define PID_REPLACE4 0x44
413 #define PID_REPLACE5 0x45
414 #define PID_REPLACE6 0x46
415 #define PID_REPLACE7 0x47
416 #define PID_RETURN_CALL 0x5f
418 #define DCS_DEFAULT 0x00
419 #define DCS_MSG_WAIT_VOICE_DISCARD 0xc8
420 #define DCS_MSG_WAIT_VOICE_OFF 0xc0
421 #define DCS_MSG_WAIT_VOICE_STORE 0xd8
422 #define DCS_DATA 0xf4
423 #define DCS_CLASS0 0xf0
424 #define DCS_CLASS1 0xf1
425 #define DCS_CLASS2 0xf2
426 #define DCS_CLASS3 0xf3
428 /* Limits for IMEI, Revision and Model string storage. */
429 #define GSM_MAX_IMEI_LENGTH (20)
430 #define GSM_MAX_REVISION_LENGTH (6)
431 #define GSM_MAX_MODEL_LENGTH (6)
435 /* This is a generic holder for high level information - eg a GSM_Bitmap */
438 SMS_Folder *SMSFolder;
439 SMS_FolderList *SMSFolderList;
440 GSM_SMSMessage *SMSMessage;
441 GSM_PhonebookEntry *PhonebookEntry;
442 GSM_SpeedDial *SpeedDial;
443 GSM_MemoryStatus *MemoryStatus;
444 GSM_SMSMemoryStatus *SMSStatus;
445 SMS_MessageCenter *MessageCenter;
450 GSM_NetworkInfo *NetworkInfo;
451 GSM_CalendarNote *CalendarNote;
453 GSM_Ringtone *Ringtone;
454 GSM_Profile *Profile;
455 GSM_BatteryUnits *BatteryUnits;
457 GSM_RFUnits *RFUnits;
459 GSM_Error (*OutputFn)(char *Display, char *Indicators);
460 char *IncomingCallNr;
461 GSM_PowerSource *PowerSource;
462 GSM_DateTime *DateTime;
466 /* Global structures intended to be independant of phone etc */
467 /* Obviously currently rather Nokia biased but I think most things */
468 /* (eg at commands) can be enumerated */
471 /* A structure to hold information about the particular link */
472 /* The link comes 'under' the phone */
474 char PortDevice[20]; /* The port device */
475 int InitLength; /* Number of chars sent to sync the serial port */
476 GSM_ConnectionType ConnectionType; /* Connection type, serial, ir etc */
478 /* A regularly called loop function */
479 /* timeout can be used to make the function block or not */
480 GSM_Error (*Loop)(struct timeval *timeout);
482 /* A pointer to the function used to send out a message */
483 /* This is used by the phone specific code to send a message over the link */
484 GSM_Error (*SendMessage)(u16 messagesize, u8 messagetype, void *message);
489 /* Small structure used in GSM_Phone */
490 /* Messagetype is passed to the function in case it is a 'generic' one */
493 GSM_Error (*Functions)(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
494 } GSM_IncomingFunctionType;
514 GOP_GetIncomingCallNr,
523 GOP_Max, /* don't append anything after this entry */
526 /* This structure contains the 'callups' needed by the statemachine */
527 /* to deal with messages from the phone and other information */
529 typedef struct _GSM_Statemachine GSM_Statemachine;
532 /* These make up a list of functions, one for each message type and NULL terminated */
533 GSM_IncomingFunctionType *IncomingFunctions;
534 GSM_Error (*DefaultFunction)(int messagetype, unsigned char *buffer, int length);
535 GSM_Information Info;
536 GSM_Error (*Functions)(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state);
540 /* The states the statemachine can take */
543 Startup, /* Not yet initialised */
544 Initialised, /* Ready! */
545 MessageSent, /* A command has been sent to the link(phone) */
546 WaitingForResponse, /* We are waiting for a response from the link(phone) */
547 ResponseReceived /* A response has been received - waiting for the phone layer to collect it */
550 /* How many message types we can wait for at one */
551 #define SM_MAXWAITINGFOR 3
554 /* All properties of the state machine */
556 struct _GSM_Statemachine{
557 GSM_State CurrentState;
561 /* Store last message for resend purposes */
566 /* The responses we are waiting for */
567 unsigned char NumWaitingFor;
568 unsigned char NumReceived;
569 unsigned char WaitingFor[SM_MAXWAITINGFOR];
570 GSM_Error ResponseError[SM_MAXWAITINGFOR];
571 /* Data structure to be filled in with the response */
572 GSM_Data *Data[SM_MAXWAITINGFOR];
577 /* Define the structure used to hold pointers to the various API functions.
578 This is in effect the master list of functions provided by the gnokii API.
579 Modules containing the model specific code each contain one of these
580 structures which is "filled in" with the corresponding function within the
581 model specific code. If a function is not supported or not implemented, a
582 generic not implemented function is used to return a GE_NOTIMPLEMENTED
587 /* FIXME: comment this. */
589 GSM_Error (*Initialise)( char *port_device, char *initlength,
590 GSM_ConnectionType connection,
591 void (*rlp_callback)(RLP_F96Frame *frame));
593 void (*Terminate)(void);
595 GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry );
597 GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry );
599 GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry);
601 GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry);
603 GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status);
605 GSM_Error (*GetSMSStatus)( GSM_SMSMemoryStatus *Status);
607 GSM_Error (*GetSMSCenter)( SMS_MessageCenter *MessageCenter );
609 GSM_Error (*SetSMSCenter)( SMS_MessageCenter *MessageCenter );
611 GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message );
613 GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message );
615 GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message, int size );
617 GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message );
619 /* If units is set to a valid GSM_RFUnits value, the code
620 will return level in these units if it is able. Otherwise
621 value will be returned as GRF_Arbitary. If phone doesn't
622 support GetRFLevel, function returns GE_NOTSUPPORTED */
623 GSM_Error (*GetRFLevel)( GSM_RFUnits *units, float *level );
625 /* Works the same as GetRFLevel, except returns battery
627 GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level );
629 GSM_Error (*GetPowerSource)( GSM_PowerSource *source);
631 GSM_Error (*GetDisplayStatus)( int *Status);
633 GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code);
635 GSM_Error (*GetSecurityCodeStatus)( int *Status );
637 GSM_Error (*GetIMEI)( char *imei );
639 GSM_Error (*GetRevision)( char *revision );
641 GSM_Error (*GetModel)( char *model );
643 GSM_Error (*GetManufacturer)( char *manufacturer );
645 GSM_Error (*GetDateTime)( GSM_DateTime *date_time);
647 GSM_Error (*SetDateTime)( GSM_DateTime *date_time);
649 GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time );
651 GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time );
653 GSM_Error (*DialVoice)( char *Number);
655 GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c));
657 GSM_Error (*GetIncomingCallNr)( char *Number );
659 GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo );
661 GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote);
663 GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote);
665 GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote);
667 GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen );
669 GSM_Error (*SendDTMF) ( char *String );
671 GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap );
673 GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap );
675 GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone );
677 GSM_Error (*SendRingtone) ( GSM_Ringtone *ringtone, char *dest );
679 GSM_Error (*Reset) ( unsigned char type );
681 GSM_Error (*GetProfile) ( GSM_Profile *Profile );
683 GSM_Error (*SetProfile) ( GSM_Profile *Profile );
685 bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx );
687 GSM_Error (*CancelCall) ();
689 GSM_Error (*EnableDisplayOutput) ();
691 GSM_Error (*DisableDisplayOutput) ();
693 GSM_Error (*EnableCellBroadcast) ();
695 GSM_Error (*DisableCellBroadcast) ();
697 GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message );
699 GSM_Error (*SetKey) (int c, int up);
701 GSM_Error (*HandleString) (char *s);
703 GSM_Error (*AnswerCall) (char s);
707 /* Undefined functions in fbus/mbus files */
708 extern GSM_Error Unimplemented(void);
709 #define UNIMPLEMENTED (void *) Unimplemented
711 extern GSM_MemoryType StrToMemoryType (const char *s);
713 inline void GSM_DataClear(GSM_Data *data);
715 #endif /* __gsm_common_h */