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.9 2002/04/03 00:08:19 short
18 Found in "gnokii-working" directory, some November-patches version
20 Revision 1.80 2001/08/20 23:36:27 pkot
21 More cleanup in AT code (Manfred Jonsson)
23 Revision 1.79 2001/07/27 00:02:22 pkot
24 Generic AT support for the new structure (Manfred Jonsson)
26 Revision 1.78 2001/06/28 00:28:45 pkot
27 Small docs updates (Pawel Kot)
32 #ifndef __gsm_common_h
33 #define __gsm_common_h
37 #include "gsm-common.h"
38 #include "data/rlp-common.h"
40 /* Type of connection. Now we support serial connection with FBUS cable and
41 IR (only with 61x0 models) */
44 GCT_Serial, /* Serial connection. */
45 GCT_Infrared, /* Infrared connection. */
46 GCT_Tekram, /* Tekram Ir-Dongle */
50 /* Maximum length of device name for serial port */
52 #define GSM_MAX_DEVICE_NAME_LENGTH (100)
54 /* Define an enum for specifying memory types for retrieving phonebook
55 entries, SMS messages etc. This type is not mobile specific - the model
56 code should take care of translation to mobile specific numbers - see 6110
58 01/07/99: Two letter codes follow GSM 07.07 release 6.2.0
62 GMT_ME, /* Internal memory of the mobile equipment */
63 GMT_SM, /* SIM card memory */
64 GMT_FD, /* Fixed dial numbers */
65 GMT_ON, /* Own numbers */
66 GMT_EN, /* Emergency numbers */
67 GMT_DC, /* Dialled numbers */
68 GMT_RC, /* Received numbers */
69 GMT_MC, /* Missed numbers */
70 GMT_LD, /* Last dialed */
71 GMT_MT, /* combined ME and SIM phonebook */
72 GMT_TA, /* for compatibility only: TA=computer memory */
73 GMT_CB, /* Currently selected memory */
74 GMT_XX = 0xff /* Error code for unknown memory type (returned by fbus-xxxx functions). */
77 /* Power source types */
80 GPS_ACDC=1, /* AC/DC powered (charging) */
81 GPS_BATTERY /* Internal battery */
84 /* This data-type is used to specify the type of the number. See the official
85 GSM specification 03.40, version 5.3.0, section 9.1.2.5, page 33. */
88 GNT_UNKNOWN=0x81, /* Unknown number */
89 GNT_INTERNATIONAL=0x91 /* International number */
93 /* Maximum length of SMS center name */
95 #define GSM_MAX_SMS_CENTER_NAME_LENGTH (20)
97 /* Limits of SMS messages. */
99 #define GSM_MAX_SMS_CENTER_LENGTH (40)
100 #define GSM_MAX_SENDER_LENGTH (40)
101 #define GSM_MAX_DESTINATION_LENGTH (40)
102 #define GSM_MAX_SMS_LENGTH (160)
103 #define GSM_MAX_SMS_8BIT_LENGTH (140)
105 #define GSM_MAX_CB_MESSAGE (160)
107 /* The maximum length of an uncompressed concatenated short message is
108 255 * 153 = 39015 default alphabet characters */
109 #define GSM_MAX_CONCATENATED_SMS_LENGTH (39015)
111 /* All the concatenated UDH headers may get long (at least logo+concatenation).
112 * Theoretically it can be (GSM_MAX_SMS_LENGTH*7/8).
114 #define GSM_MAX_USER_DATA_HEADER_LENGTH (256)
116 /* types of User Data Header */
119 GSM_ConcatenatedMessages,
125 /* Define datatype for SMS Message Type */
128 GST_MO, /* Mobile Originated (MO) message - Outbox message */
129 GST_MT, /* Mobile Terminated (MT) message - Inbox message */
130 GST_DR, /* Delivery Report */
132 } GSM_SMSMessageType;
134 /* Datatype for SMS status */
135 /* FIXME - This needs to be made clearer and or turned into a
136 bitfield to allow compound values (read | sent etc.) */
139 GSS_SENTREAD = true, /* Sent or read message */
140 GSS_NOTSENTREAD = false /* Not sent or not read message */
141 } GSM_SMSMessageStatus;
143 /* SMS Messages sent as... */
146 GSMF_Text = 0x00, /* Plain text message. */
147 GSMF_Fax = 0x22, /* Fax message. */
148 GSMF_Voice = 0x24, /* Voice mail message. */
149 GSMF_ERMES = 0x25, /* ERMES message. */
150 GSMF_Paging = 0x26, /* Paging. */
151 GSMF_UCI = 0x2d, /* Email message in 8110i. */
152 GSMF_Email = 0x32, /* Email message. */
153 GSMF_X400 = 0x31 /* X.400 message. */
154 } GSM_SMSMessageFormat;
156 /* Validity of SMS Messages. */
161 GSMV_24_Hours = 0xa7,
162 GSMV_72_Hours = 0xa9,
165 } GSM_SMSMessageValidity;
167 /* Define datatype for SMS Message Center */
170 int No; /* Number of the SMSC in the phone memory. */
171 char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */
172 GSM_SMSMessageFormat Format; /* SMS is sent as text/fax/paging/email. */
173 GSM_SMSMessageValidity Validity; /* Validity of SMS Message. */
174 char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */
175 char Recipient[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the default recipient. */
178 /* Define datatype for Cell Broadcast message */
180 int Channel; /* channel number */
181 char Message[GSM_MAX_CB_MESSAGE + 1];
187 /* Definition of security codes. */
190 GSCT_SecurityCode = 0x01, /* Security code. */
192 GSCT_Pin2, /* PIN 2. */
194 GSCT_Puk2, /* PUK 2. */
195 GSCT_None /* Code not needed. */
196 } GSM_SecurityCodeType;
198 /* Security code definition. */
201 GSM_SecurityCodeType Type; /* Type of the code. */
202 char Code[10]; /* Actual code. */
205 /* Structure used for passing dates/times to date/time functions such as
206 GSM_GetTime and GSM_GetAlarm etc. */
209 bool AlarmEnabled; /* Is the alarm set? */
210 int Year; /* The complete year specification - e.g. 1999. Y2K :-) */
211 int Month; /* January = 1 */
216 int Timezone; /* The difference between local time and GMT, FIXME: WHICH UNITS? --- FIX THE CODE! */
219 /* Define datatype for SMS messages, used for getting SMS messages from the
223 GSM_DateTime Time; /* Date of reception/response of messages. */
224 GSM_DateTime SMSCTime; /* Date of SMSC response if DeliveryReport messages. */
225 int Validity; /* Validity Period of the SMS message (unit is minutes). */
226 bool UDHPresent; /* If UDH is present */
227 unsigned char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH]; /* If UDH is present - content of UDH, UDH[0] specifies length */
228 char MessageText[GSM_MAX_SMS_LENGTH + 1]; /* (+1) is room for null term, sized by GSM_SMSMessage.MessageTextLength
229 * GSM_SMSMessage.EightBit==false => MessageText is also '\0'-terminated
231 int MessageTextLength; /* Unit is determined by GSM_SMSMessage.EightBit */
232 GSM_MessageCenter MessageCenter; /* SMS Center. */
233 char Sender[GSM_MAX_SENDER_LENGTH + 1]; /* Sender of the SMS message. */
234 char Destination[GSM_MAX_DESTINATION_LENGTH + 1]; /* Destination of the message. */
235 int MessageNumber; /* Location in the memory (output argument). */
236 GSM_MemoryType MemoryType; /* Type of memory message is stored in. */
237 GSM_SMSMessageType Type; /* Type of the SMS message */
238 GSM_SMSMessageStatus Status; /* Status of the SMS message */
239 int Class; /* Class Message: 0, 1, 2, 3 or none (value -1 !); see GSM 03.38 */
240 bool EightBit; /* Indicates whether SMS contains 8 bit data */
241 bool Compression; /* Indicates whether SMS contains compressed data */
242 int Location; /* Location in the memory (input argument). */
243 bool ReplyViaSameSMSC; /* Indicates whether "Reply via same center" is set */
246 /* This structure is used to get the current network status */
249 char NetworkCode[10]; /* GSM network code */
250 char CellID[10]; /* CellID */
251 char LAC[10]; /* LAC */
254 /* Limits for sizing of array in GSM_PhonebookEntry. Individual handsets may
255 not support these lengths so they have their own limits set. */
257 #define GSM_MAX_PHONEBOOK_NAME_LENGTH (50) /* For 7110 */
258 #define GSM_MAX_PHONEBOOK_NUMBER_LENGTH (48) /* For 7110 */
259 #define GSM_MAX_PHONEBOOK_TEXT_LENGTH (60) /* For 7110 */
260 #define GSM_MAX_PHONEBOOK_SUB_ENTRIES (8) /* For 7110 */
261 /* 7110 is able to in one
262 * entry 5 numbers and 2
263 * texts [email,notice,postal] */
265 /* Here is a macro for models that do not support caller groups. */
267 #define GSM_GROUPS_NOT_SUPPORTED -1
269 /* This data type is used to report the number of used and free positions in
270 memory (sim or internal). */
273 GSM_MemoryType MemoryType; /* Type of the memory */
274 int Used; /* Number of used positions */
275 int Free; /* Number of free positions */
278 /* This data type is used to hold the current SMS status. */
281 int UnRead; /* The number of unread messages (currently not used) */
282 int Used; /* The number of currently stored messages */
283 int Slots; /* Reading will try all 1..Slots locations */
288 /* Some phones (at the moment 6210/7110) supports extended phonebook
289 with additional data. Here we have structures for them */
307 GSM_Date = 0x13 /* Date is used for DC,RC,etc (last calls) */
311 GSM_EntryType EntryType;
312 GSM_Number_Type NumberType;
314 char Number[GSM_MAX_PHONEBOOK_TEXT_LENGTH + 1]; /* Number */
315 GSM_DateTime Date; /* or the last calls list */
318 } GSM_SubPhonebookEntry;
320 /* Define datatype for phonebook entry, used for getting/writing phonebook
324 bool Empty; /* Is this entry empty? */
325 char Name[GSM_MAX_PHONEBOOK_NAME_LENGTH + 1]; /* Plus 1 for
327 char Number[GSM_MAX_PHONEBOOK_NUMBER_LENGTH + 1]; /* Number */
328 GSM_MemoryType MemoryType; /* Type of memory */
329 int Group; /* Group */
330 int Location; /* Location */
331 GSM_DateTime Date; /* The record date and time
333 GSM_SubPhonebookEntry SubEntries[GSM_MAX_PHONEBOOK_SUB_ENTRIES];
335 * additional phonebook
337 int SubEntriesCount; /* Should be 0, if extended
338 phonebook is not used */
339 } GSM_PhonebookEntry;
343 /* This define speed dialing entries. */
346 int Number; /* Which number is used to dialing? */
347 GSM_MemoryType MemoryType; /* Memory type of the number. */
348 int Location; /* Location of the number in MemoryType. */
351 /* Define enum used to describe what sort of date/time support is
355 GDT_None, /* The mobile phone doesn't support time and date. */
356 GDT_TimeOnly, /* The mobile phone supports only time. */
357 GDT_DateOnly, /* The mobile phone supports only date. */
358 GDT_DateTime /* Wonderful phone - it supports date and time. */
359 } GSM_DateTimeSupport;
361 /* Define enums for RF units. GRF_CSQ asks for units in form used
362 in AT+CSQ command as defined by GSM 07.07 */
373 /* Define enums for Battery units. */
382 /* Define enums for Calendar Note types */
385 GCN_REMINDER=1, /* Reminder */
387 GCN_MEETING, /* Meeting */
388 GCN_BIRTHDAY /* Birthday */
389 } GSM_CalendarNoteType;
391 /* Calendar note type */
394 int Location; /* The number of the note in the phone memory */
395 GSM_CalendarNoteType Type; /* The type of the note */
396 GSM_DateTime Time; /* The time of the note */
397 GSM_DateTime Alarm; /* The alarm of the note */
398 char Text[20]; /* The text of the note */
399 char Phone[20]; /* For Call only: the phone number */
400 double Recurance; /* Recurance of the note */
403 /* This structure is provided to allow common information about the particular
404 model to be looked up in a model independant way. Some of the values here
405 define minimum and maximum levels for values retrieved by the various Get
406 functions for example battery level. They are not defined as constants to
407 allow model specific code to set them during initialisation */
411 char *Models; /* Models covered by this type, pipe '|' delimited. */
413 /* Minimum and maximum levels for RF signal strength. Units are as per the
414 setting of RFLevelUnits. The setting of RFLevelUnits indicates the
415 default or "native" units used. In the case of the 3110 and 6110 series
416 these are arbitrary, ranging from 0 to 4. */
420 GSM_RFUnits RFLevelUnits;
422 /* Minimum and maximum levels for battery level. Again, units are as per the
423 setting of GSM_BatteryLevelUnits. The value that BatteryLevelUnits is set
424 to indicates the "native" or default value that the phone supports. In the
425 case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */
427 float MaxBatteryLevel;
428 float MinBatteryLevel;
429 GSM_BatteryUnits BatteryLevelUnits;
431 /* FIXME: some very similar code is in common/misc.c */
433 /* Information about date, time and alarm support. In case of alarm
434 information we provide value for the number of alarms supported. */
436 GSM_DateTimeSupport DateTimeSupport;
437 GSM_DateTimeSupport AlarmSupport;
439 u8 StartupLogoH; /* Logo Widths and Heights - if supported */
447 /* Define standard GSM error/return code values. These codes are also used for
448 some internal functions such as SIM read/write in the model specific code. */
451 GE_NONE = 0, /* No error. */
452 GE_DEVICEOPENFAILED, /* Couldn't open specified serial device. */
453 GE_UNKNOWNMODEL, /* Model specified isn't known/supported. */
454 GE_NOLINK, /* Couldn't establish link with phone. */
455 GE_TIMEOUT, /* Command timed out. */
456 GE_TRYAGAIN, /* Try again. */
457 GE_INVALIDSECURITYCODE, /* Invalid Security code. */
458 GE_NOTIMPLEMENTED, /* Command called isn't implemented in model. */
459 GE_INVALIDSMSLOCATION, /* Invalid SMS location. */
460 GE_INVALIDPHBOOKLOCATION, /* Invalid phonebook location. */
461 GE_INVALIDMEMORYTYPE, /* Invalid type of memory. */
462 GE_INVALIDSPEEDDIALLOCATION, /* Invalid speed dial location. */
463 GE_INVALIDCALNOTELOCATION,/* Invalid calendar note location. */
464 GE_INVALIDDATETIME, /* Invalid date, time or alarm specification. */
465 GE_EMPTYSMSLOCATION, /* SMS location is empty. */
466 GE_PHBOOKNAMETOOLONG, /* Phonebook name is too long. */
467 GE_PHBOOKNUMBERTOOLONG, /* Phonebook number is too long. */
468 GE_PHBOOKWRITEFAILED, /* Phonebook write failed. */
469 GE_SMSSENDOK, /* SMS was send correctly. */
470 GE_SMSSENDFAILED, /* SMS send fail. */
471 GE_SMSWAITING, /* Waiting for the next part of SMS. */
472 GE_SMSTOOLONG, /* SMS message too long. */
473 GE_NONEWCBRECEIVED, /* Attempt to read CB when no new CB received */
474 GE_INTERNALERROR, /* Problem occured internal to model specific code. */
475 GE_CANTOPENFILE, /* Can't open file with bitmap/ringtone */
476 GE_WRONGNUMBEROFCOLORS, /* Wrong number of colors in specified bitmap file */
477 GE_WRONGCOLORS, /* Wrong colors in bitmap file */
478 GE_INVALIDFILEFORMAT, /* Invalid format of file */
479 GE_SUBFORMATNOTSUPPORTED, /* Subformat of file not supported */
480 GE_FILETOOSHORT, /* Too short file to read */
481 GE_FILETOOLONG, /* Too long file to read */
482 GE_INVALIDIMAGESIZE, /* Invalid size of bitmap (in file, sms etc.) */
483 GE_NOTSUPPORTED, /* Function not supported by the phone */
484 GE_BUSY, /* Command is still being executed. */
486 GE_UNKNOWN, /* Unknown error - well better than nothing!! */
488 GE_NOTWAITING, /* Not waiting for a response from the phone */
491 /* The following are here in anticipation of data call requirements. */
493 GE_LINEBUSY, /* Outgoing call requested reported line busy */
494 GE_NOCARRIER /* No Carrier error during data call setup ? */
498 /* This enum is used for display status. */
501 DS_Call_In_Progress, /* Call in progress. */
502 DS_Unknown, /* The meaning is unknown now :-( */
503 DS_Unread_SMS, /* There is Unread SMS. */
504 DS_Voice_Call, /* Voice call active. */
505 DS_Fax_Call, /* Fax call active. */
506 DS_Data_Call, /* Data call active. */
507 DS_Keyboard_Lock, /* Keyboard lock status. */
508 DS_SMS_Storage_Full /* Full SMS Memory. */
509 } DisplayStatusEntity;
523 #define GSM_MAX_BITMAP_SIZE 864
525 /* Structure to hold incoming/outgoing bitmaps (and welcome-notes). */
528 u8 height; /* Bitmap height (pixels) */
529 u8 width; /* Bitmap width (pixels) */
530 u16 size; /* Bitmap size (bytes) */
531 GSM_Bitmap_Types type; /* Bitmap type */
532 char netcode[7]; /* Network operator code */
533 char text[256]; /* Text used for welcome-note or callergroup name */
534 char dealertext[256]; /* Text used for dealer welcome-note */
535 bool dealerset; /* Is dealer welcome-note set now ? */
536 unsigned char bitmap[GSM_MAX_BITMAP_SIZE]; /* Actual Bitmap */
537 char number; /* Caller group number */
538 char ringtone; /* Ringtone no sent with caller group */
542 /* NoteValue is encoded as octave(scale)*14 + note */
543 /* where for note: c=0, d=2, e=4 .... */
544 /* ie. c#=1 and 5 and 13 are invalid */
545 /* note=255 means a pause */
547 #define MAX_RINGTONE_NOTES 256
549 /* Structure to hold note of ringtone. */
556 /* Structure to hold ringtones. */
562 GSM_RingtoneNote notes[MAX_RINGTONE_NOTES];
565 /* Structure to hold profile entries. */
568 int Number; /* The number of the profile. */
569 char Name[40]; /* The name of the profile. */
570 int DefaultName; /* 0-6, when default name is used, -1, when not. */
571 int KeypadTone; /* Volume level for keypad tones. */
572 int Lights; /* Lights on/off. */
573 int CallAlert; /* Incoming call alert. */
574 int Ringtone; /* Ringtone for incoming call alert. */
575 int Volume; /* Volume of the ringing. */
576 int MessageTone; /* The tone for message indication. */
577 int WarningTone; /* The tone for warning messages. */
578 int Vibration; /* Vibration? */
579 int CallerGroups; /* CallerGroups. */
580 int AutomaticAnswer; /* Does the phone auto-answer incoming call? */
584 #define FO_SUBMIT 0x01
586 #define FO_VPF_NONE 0x00
587 #define FO_VPF_REL 0x10
588 #define FO_VPF_ABS 0x18
589 #define FO_VPF_ENH 0x08
593 #define FO_DEFAULT (FO_SUBMIT | FO_VPF_REL | FO_SRR)
595 #define PID_DEFAULT 0x00
596 #define PID_TYPE0 0x40
597 #define PID_REPLACE1 0x41
598 #define PID_REPLACE2 0x42
599 #define PID_REPLACE3 0x43
600 #define PID_REPLACE4 0x44
601 #define PID_REPLACE5 0x45
602 #define PID_REPLACE6 0x46
603 #define PID_REPLACE7 0x47
604 #define PID_RETURN_CALL 0x5f
606 #define DCS_DEFAULT 0x00
607 #define DCS_MSG_WAIT_VOICE_DISCARD 0xc8
608 #define DCS_MSG_WAIT_VOICE_OFF 0xc0
609 #define DCS_MSG_WAIT_VOICE_STORE 0xd8
610 #define DCS_DATA 0xf4
611 #define DCS_CLASS0 0xf0
612 #define DCS_CLASS1 0xf1
613 #define DCS_CLASS2 0xf2
614 #define DCS_CLASS3 0xf3
616 /* Limits for IMEI, Revision and Model string storage. */
618 #define GSM_MAX_IMEI_LENGTH (20)
619 #define GSM_MAX_REVISION_LENGTH (16)
620 #define GSM_MAX_MODEL_LENGTH (64)
621 #define GSM_MAX_MANUFACTURER_LENGTH (36)
625 /* This is a generic holder for high level information - eg a GSM_Bitmap */
628 GSM_SMSMessage *SMSMessage;
629 GSM_PhonebookEntry *PhonebookEntry;
630 GSM_SpeedDial *SpeedDial;
631 GSM_MemoryStatus *MemoryStatus;
632 GSM_SMSStatus *SMSStatus;
633 GSM_MessageCenter *MessageCenter;
638 GSM_NetworkInfo *NetworkInfo;
639 GSM_CalendarNote *CalendarNote;
642 GSM_Ringtone *Ringtone;
644 GSM_Profile *Profile;
645 GSM_BatteryUnits *BatteryUnits;
647 GSM_RFUnits *RFUnits;
649 GSM_Error (*OutputFn)(char *Display, char *Indicators);
650 char *IncomingCallNr;
651 GSM_PowerSource *PowerSource;
652 GSM_SecurityCode *SecurityCode;
653 GSM_SecurityCodeType *SecurityCodeStatus;
654 GSM_DateTime *DateTime;
656 GSM_DateTime *AlarmDateTime;
660 void (*DataCallPassUp)(char c);
661 unsigned char *NetMonitorMode;
662 char *NetMonitorScreen;
665 RLP_F96Frame *RLPFrame;
666 bool *RLPFrame_out_dtx;
667 GSM_CBMessage *CBMessage;
676 /* Global structures intended to be independant of phone etc */
677 /* Obviously currently rather Nokia biased but I think most things */
678 /* (eg at commands) can be enumerated */
681 /* A structure to hold information about the particular link */
682 /* The link comes 'under' the phone */
684 char PortDevice[20]; /* The port device */
685 int InitLength; /* Number of chars sent to sync the serial port */
686 GSM_ConnectionType ConnectionType; /* Connection type, serial, ir etc */
688 /* A regularly called loop function */
689 /* timeout can be used to make the function block or not */
690 GSM_Error (*Loop)(struct timeval *timeout);
692 /* A pointer to the function used to send out a message */
693 /* This is used by the phone specific code to send a message over the link */
694 GSM_Error (*SendMessage)(u16 messagesize, u8 messagetype, void *message);
699 /* Small structure used in GSM_Phone */
700 /* Messagetype is passed to the function in case it is a 'generic' one */
703 GSM_Error (*Functions)(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
704 } GSM_IncomingFunctionType;
724 GOP_GetDisplayStatus,
725 GOP_EnterSecurityCode,
726 GOP_GetSecurityCodeStatus,
733 GOP_GetIncomingCallNr,
746 GOP_WriteCalendarNote,
747 GOP_DeleteCalendarNote,
755 GOP_EnableDisplayOutput,
756 GOP_DisableDisplayOutput,
757 GOP_EnableCellBroadcast,
758 GOP_DisableCellBroadcast,
759 GOP_ReadCellBroadcast,
763 GOP_Max /* don't append anything after this entry */
766 /* This structure contains the 'callups' needed by the statemachine */
767 /* to deal with messages from the phone and other information */
769 typedef struct _GSM_Statemachine GSM_Statemachine;
772 /* These make up a list of functions, one for each message type and NULL terminated */
773 GSM_IncomingFunctionType *IncomingFunctions;
774 GSM_Error (*DefaultFunction)(int messagetype, unsigned char *buffer, int length);
775 GSM_Information Info;
776 GSM_Error (*Functions)(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state);
780 /* The states the statemachine can take */
783 Startup, /* Not yet initialised */
784 Initialised, /* Ready! */
785 MessageSent, /* A command has been sent to the link(phone) */
786 WaitingForResponse, /* We are waiting for a response from the link(phone) */
787 ResponseReceived /* A response has been received - waiting for the phone layer to collect it */
790 /* How many message types we can wait for at one */
791 #define SM_MAXWAITINGFOR 3
794 /* All properties of the state machine */
796 struct _GSM_Statemachine{
797 GSM_State CurrentState;
801 /* Store last message for resend purposes */
806 /* The responses we are waiting for */
807 unsigned char NumWaitingFor;
808 unsigned char NumReceived;
809 unsigned char WaitingFor[SM_MAXWAITINGFOR];
810 GSM_Error ResponseError[SM_MAXWAITINGFOR];
811 /* Data structure to be filled in with the response */
812 GSM_Data *Data[SM_MAXWAITINGFOR];
817 /* Define the structure used to hold pointers to the various API functions.
818 This is in effect the master list of functions provided by the gnokii API.
819 Modules containing the model specific code each contain one of these
820 structures which is "filled in" with the corresponding function within the
821 model specific code. If a function is not supported or not implemented, a
822 generic not implemented function is used to return a GE_NOTIMPLEMENTED
827 /* FIXME: comment this. */
829 GSM_Error (*Initialise)( char *port_device, char *initlength,
830 GSM_ConnectionType connection,
831 void (*rlp_callback)(RLP_F96Frame *frame));
833 void (*Terminate)(void);
835 GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry );
837 GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry );
839 GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry);
841 GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry);
843 GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status);
845 GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status);
847 GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter );
849 GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter );
851 GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message );
853 GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message );
855 GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message );
857 GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message );
859 /* If units is set to a valid GSM_RFUnits value, the code
860 will return level in these units if it is able. Otherwise
861 value will be returned as GRF_Arbitary. If phone doesn't
862 support GetRFLevel, function returns GE_NOTSUPPORTED */
863 GSM_Error (*GetRFLevel)( GSM_RFUnits *units, float *level );
865 /* Works the same as GetRFLevel, except returns battery
867 GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level );
869 GSM_Error (*GetPowerSource)( GSM_PowerSource *source);
871 GSM_Error (*GetDisplayStatus)( int *Status);
873 GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code);
875 GSM_Error (*GetSecurityCodeStatus)( int *Status );
877 GSM_Error (*GetIMEI)( char *imei );
879 GSM_Error (*GetRevision)( char *revision );
881 GSM_Error (*GetModel)( char *model );
883 GSM_Error (*GetManufacturer)( char *manufacturer );
885 GSM_Error (*GetDateTime)( GSM_DateTime *date_time);
887 GSM_Error (*SetDateTime)( GSM_DateTime *date_time);
889 GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time );
891 GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time );
893 GSM_Error (*DialVoice)( char *Number);
895 GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c));
897 GSM_Error (*GetIncomingCallNr)( char *Number );
899 GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo );
901 GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote);
903 GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote);
905 GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote);
907 GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen );
909 GSM_Error (*SendDTMF) ( char *String );
911 GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap );
913 GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap );
915 GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone );
917 GSM_Error (*Reset) ( unsigned char type );
919 GSM_Error (*GetProfile) ( GSM_Profile *Profile );
921 GSM_Error (*SetProfile) ( GSM_Profile *Profile );
923 bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx );
925 GSM_Error (*CancelCall) ();
927 GSM_Error (*EnableDisplayOutput) ();
929 GSM_Error (*DisableDisplayOutput) ();
931 GSM_Error (*EnableCellBroadcast) ();
933 GSM_Error (*DisableCellBroadcast) ();
935 GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message );
937 GSM_Error (*SetKey) (int c, int up);
939 GSM_Error (*HandleString) (char *s);
941 GSM_Error (*AnswerCall) (char s);
946 bool first; /* MUST be set to "true" during the first call of SMS_Deconcatenate() */
947 bool singleshot; /* no concatenation wrapping was needed */
948 unsigned sequence; /* =1 for the first part etc. */
949 u8 *sequencep; /* For updating inside-PDU header sequence number */
950 size_t cargoitems; /* How many items of MessageText fit in one SMS part */
951 } GSM_Deconcatenate_state;
953 /* Undefined functions in fbus/mbus files */
954 extern GSM_Error Unimplemented(void);
955 #define UNIMPLEMENTED (void *) Unimplemented
957 extern unsigned char GSM_Default_Alphabet[];
959 /* Coding functions */
960 extern void EncodeAscii (unsigned char* dest, const unsigned char* src, int len);
961 extern void DecodeAscii (unsigned char* dest, const unsigned char* src, int len);
962 extern void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len);
963 extern void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len);
965 extern unsigned char EncodeWithDefaultAlphabet(unsigned char);
966 extern unsigned char DecodeWithDefaultAlphabet(unsigned char);
967 extern wchar_t EncodeWithUnicodeAlphabet(unsigned char);
968 extern unsigned char DecodeWithUnicodeAlphabet(wchar_t);
969 extern GSM_MemoryType StrToMemoryType (const char *s);
970 extern unsigned char SMS_Validity_to_VP(int Validity);
971 extern int SMS_VP_to_Validity(GSM_SMSMessageValidity Validity);
972 extern int SemiOctetPack(char *Number, unsigned char *Output);
973 extern char *SemiOctetUnpack(char *dest,size_t destlen,u8 *Number,size_t nibbles);
974 extern char *SemiOctetUnpack_static(u8 *Number,size_t nibbles);
975 #define SEMIOCTETUNPACK_STATIC_BYTES(Number) (SemiOctetUnpack_static((Number)+1,*(Number)*2))
976 #define SEMIOCTETUNPACK_STATIC_NIBBLES(Number) (SemiOctetUnpack_static((Number)+1,*(Number) ))
977 extern int PackSevenBitsToEight(int UsedBits, unsigned char *input, unsigned char *output);
978 extern int UnpackEightBitsToSeven(int offset, int in_length, int out_length,
979 unsigned char *input, unsigned char *output);
980 extern GSM_Error SMS_SetupUDH(GSM_SMSMessage *sms,GSM_UDH UDHType);
981 extern GSM_UDH SMS_DetectUDH(GSM_SMSMessage *sms);
982 extern bool SMS_Deconcatenate(GSM_Deconcatenate_state *state,GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh);
983 extern u8 *SMS_BlockFromHex(u8 *d,const char *s,size_t len);
984 extern char *SMS_BlockToHex(char *d,const u8 *s,size_t len);
986 inline void GSM_DataClear(GSM_Data *data);
988 #endif /* __gsm_common_h */