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