:pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
[gnokii.git] / include / mbus-6160.h
1 /*
2
3   $Id$
4
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
10
11   Released under the terms of the GNU GPL, see file COPYING for more details.
12
13   Header file for 6160 code.    
14
15   $Log$
16   Revision 1.1.1.1  2001/11/25 21:59:20  short
17   :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
18
19   Revision 1.16  2001/06/28 00:28:46  pkot
20   Small docs updates (Pawel Kot)
21
22
23 */
24
25 #ifndef         __mbus_6160_h
26 #define         __mbus_6160_h
27
28 #ifndef         __gsm_common_h
29 #include        "gsm-common.h"  /* Needed for GSM_Error etc. */
30 #endif
31
32         /* Global variables */
33 extern bool                                     MB61_LinkOK;
34 extern GSM_Functions            MB61_Functions;
35 extern GSM_Information          MB61_Information;
36
37
38         /* Prototypes for the functions designed to be used externally. */
39 GSM_Error   MB61_Initialise(char *port_device, char *initlength,
40                             GSM_ConnectionType connection,
41                             void (*rlp_callback)(RLP_F96Frame *frame));
42
43 bool            MB61_OpenSerial(void);
44 void            MB61_Terminate(void);
45
46 int             MB61_GetMemoryType(GSM_MemoryType memory_type);
47
48 GSM_Error       MB61_GetMemoryLocation(GSM_PhonebookEntry *entry);
49
50 GSM_Error       MB61_WritePhonebookLocation(GSM_PhonebookEntry *entry);
51
52 GSM_Error       MB61_GetSpeedDial(GSM_SpeedDial *entry);
53
54 GSM_Error       MB61_SetSpeedDial(GSM_SpeedDial *entry);
55
56 GSM_Error       MB61_GetMemoryStatus(GSM_MemoryStatus *Status);
57
58 GSM_Error       MB61_GetSMSStatus(GSM_SMSStatus *Status);
59 GSM_Error       MB61_GetSMSCenter(GSM_MessageCenter *MessageCenter);
60 GSM_Error       MB61_GetSMSMessage(GSM_SMSMessage *message);
61
62 GSM_Error       MB61_GetSMSCenter(GSM_MessageCenter *MessageCenter);
63 GSM_Error       MB61_SetSMSCenter(GSM_MessageCenter *MessageCenter);
64
65 GSM_Error       MB61_DeleteSMSMessage(GSM_SMSMessage *message);
66
67 GSM_Error       MB61_SendSMSMessage(GSM_SMSMessage *SMS, int size);
68
69 GSM_Error       MB61_GetRFLevel(GSM_RFUnits *units, float *level);
70
71 GSM_Error       MB61_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
72
73         /* These aren't presently implemented. */
74 GSM_Error       MB61_SaveSMSMessage(GSM_SMSMessage *SMS);
75 GSM_Error       MB61_GetPowerSource(GSM_PowerSource *source);
76 GSM_Error       MB61_GetDisplayStatus(int *Status);
77
78 GSM_Error       MB61_EnterSecurityCode(GSM_SecurityCode SecurityCode);
79 GSM_Error       MB61_GetSecurityCodeStatus(int *Status);
80
81 GSM_Error       MB61_GetIMEI(char *imei);
82 GSM_Error       MB61_GetRevision(char *revision);
83 GSM_Error       MB61_GetModel(char *model);
84 GSM_Error       MB61_GetDateTime(GSM_DateTime *date_time);
85 GSM_Error       MB61_SetDateTime(GSM_DateTime *date_time);
86 GSM_Error       MB61_GetAlarm(int alarm_number, GSM_DateTime *date_time);
87 GSM_Error       MB61_SetAlarm(int alarm_number, GSM_DateTime *date_time);
88 GSM_Error       MB61_DialVoice(char *Number);
89 GSM_Error       MB61_DialData(char *Number, char type,  void (* callpassup)(char c));
90 GSM_Error       MB61_GetIncomingCallNr(char *Number);
91 GSM_Error       MB61_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo);
92 GSM_Error       MB61_GetCalendarNote(GSM_CalendarNote *CalendarNote);
93 GSM_Error       MB61_WriteCalendarNote(GSM_CalendarNote *CalendarNote);
94 GSM_Error       MB61_DeleteCalendarNote(GSM_CalendarNote *CalendarNote);
95 GSM_Error       MB61_Netmonitor(unsigned char mode, char *Screen);
96 GSM_Error       MB61_SendDTMF(char *String);
97 GSM_Error       MB61_GetBitmap(GSM_Bitmap *Bitmap);
98 GSM_Error       MB61_SetBitmap(GSM_Bitmap *Bitmap);
99 GSM_Error       MB61_SetRingTone(GSM_Ringtone *ringtone);
100 GSM_Error       MB61_SendRingTone(GSM_Ringtone *ringtone, char *dest);
101 GSM_Error       MB61_Reset(unsigned char type);
102 GSM_Error       MB61_GetProfile(GSM_Profile *Profile);
103 GSM_Error       MB61_SetProfile(GSM_Profile *Profile);
104 bool            MB61_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx);
105 GSM_Error       MB61_CancelCall(void);
106
107 GSM_Error       MB61_EnableDisplayOutput();
108 GSM_Error       MB61_DisableDisplayOutput();
109
110 GSM_Error       MB61_EnableCellBroadcast ();
111 GSM_Error       MB61_DisableCellBroadcast(void);
112 GSM_Error       MB61_ReadCellBroadcast (GSM_CBMessage *Message);
113         /* All defines and prototypes from here down are specific to 
114            this model and so are #ifdef out if __mbus_6160_c isn't 
115            defined. */
116 #ifdef  __mbus_6160_c
117
118 #define         MB61_MAX_RECEIVE_LENGTH         (160)
119
120 #define         MB61_MAX_TRANSMIT_LENGTH                (200) /* Arbitrary */
121 #define         MSG_ADDR_PC                                             (0x1d)
122 #define         MSG_ADDR_PHONE                                  (0x00)
123 #define         MSG_ADDR_SERVICE                                (0x10)
124 #define         MSG_ADDR_UNKNOWN                                (0xf8)
125 #define         MSG_ADDR_GLOBAL                                 (0xff)
126
127 #define         MAX_5160_PHONEBOOK_ENTRIES                      (100)
128 #define         MAX_5160_PHONEBOOK_NUMBER_LENGTH        (16)
129 #define         MAX_5160_PHONEBOOK_NAME_LENGTH          (16)
130
131 #define         MAX_6160_PHONEBOOK_ENTRIES                      (199)
132 #define         MAX_6161_PHONEBOOK_ENTRIES                      (199)   /* Assumed */
133 #define         MAX_6162_PHONEBOOK_ENTRIES                      (199)   /* Assumed */ 
134 #define         MAX_616X_PHONEBOOK_NUMBER_LENGTH        (16)
135 #define         MAX_616X_PHONEBOOK_NAME_LENGTH          (16)
136
137 #define         MAX_6185_PHONEBOOK_ENTRIES                      (200)   /* Assumed */
138 #define         MAX_6185_PHONEBOOK_NUMBER_LENGTH        (16)    /* Assumed */
139 #define         MAX_6185_PHONEBOOK_NAME_LENGTH          (16)    /* Assumed */
140
141     /* States for receive code. */
142 enum    MB61_RX_States {MB61_RX_Sync,
143                         MB61_RX_GetDestination,
144                         MB61_RX_GetSource,
145                         MB61_RX_GetCommand,
146                         MB61_RX_GetLengthMSB,
147                         MB61_RX_GetLengthLSB,
148                         MB61_RX_GetMessage,
149                         MB61_RX_GetCSum};
150
151     /* This table duplicates info in xgnokii, maybe we need a single
152        data structure for this someplace in the common codebase ... HAB */
153 enum    MB61_Models             {MB61_ModelUnknown,
154                                                  MB61_Model5160,        /* NSW-1 */
155                                                  MB61_Model6110,    /* NSE-3 */
156                                                  MB61_Model6160,    /* NSW-3 */
157                                                  MB61_Model6161,        /* ????? */
158                                                  MB61_Model6162,        /* ????? */
159                                                  MB61_Model6185,    /* NSD-3 */
160                                                  MB61_Model7110     /* NSE-5 */
161
162 };
163                                         
164
165         /* We need to keep track of what response is expected as there
166        is no unambiguous field in responses from the phone to 
167        provide this information. */
168 enum    MB61_Responses  {MB61_Response_Unknown,
169                                                  MB61_Response_0xD0_Init,
170                                                  MB61_Response_0xD2_ID,
171                                                  MB61_Response_0xD2_Version,
172                                                  MB61_Response_0x40_WriteAcknowledge,
173                                                  MB61_Response_0x40_PhonebookRead,
174                                                  MB61_Response_0x40_LongPhonebookRead};
175
176         /* Prototypes for internal functions. */
177 void    MB61_ThreadLoop(void);
178 void    MB61_SigHandler(int status);
179 void    MB61_ThreadLoop(void);
180 void    MB61_UpdateSequenceNumber(void);
181
182 bool    MB61_TX_SendStandardAcknowledge(u8 sequence_number);
183
184 int     MB61_TX_SendMessage(u8 destination, u8 source, u8 command, u8 sequence_byte, int message_length, u8 *buffer);
185 void    MB61_TX_SendPhoneIDRequest(void);
186 bool    MB61_TX_SendPhonebookReadRequest(u8 entry);
187 bool    MB61_TX_SendLongPhonebookReadRequest(u8 entry);
188 GSM_Error       MB61_TX_SendPhonebookWriteRequest(GSM_PhonebookEntry *entry);
189
190 bool    MB61_InitialiseLink(void);
191 void    MB61_SetExpectedResponse(enum MB61_Responses response);
192 bool    MB61_WaitForExpectedResponse(int timeout);
193 void    MB61_RX_StateMachine(char rx_byte);
194 enum    MB61_RX_States MB61_RX_DispatchMessage(void);
195 void    MB61_RX_DisplayMessage(void);
196 void    MB61_RX_Handle0x40_PhonebookRead(void);
197 void    MB61_RX_Handle0x40_LongPhonebookRead(void);
198 void    MB61_RX_Handle0xD2_ID(void);
199 void    MB61_RX_Handle0xD2_Version(void);
200
201 #endif  /* __mbus_6160_c */
202
203 #endif  /* __mbus_6160_h */