summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/alcatel/alcatel.h
blob: 718f436f6e339d7ca96af3b707c7c5588b7df96b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* (c) 2002-2004 by Michal Cihar */

/*
 * High level functions for communication with Alcatel One Touch 501 and
 * compatible mobile phone.
 *
 * This code implements functions to communicate with Alcatel phones,
 * currently seem to work:
 *  - BE5 series (501/701)
 *  - BF5 series (715)
 *  - BH4 series (535/735)
 * For some functions it uses normal AT  mode (not implemented here, look at 
 * ../at/atgen.[ch]) for others it  switches into binary mode and initialises 
 * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and 
 * communicates over it. Don't ask me why Alcatel uses such silly thing...
 */

#ifndef alcatel_h
#define alcatel_h

#include "../../gsmcomon.h"

#ifndef GSM_USED_AT
# define GSM_USED_AT
#endif
#ifndef GSM_USED_ALCABUS
# define GSM_USED_ALCABUS
#endif

/**
 * Determines which mode is phone currently using.
 */
typedef enum {
	/**
	 * Phone accepts normal AT commands.
	 */
	ModeAT = 1,
	/**
	 * Binary mode using proprietary protocol.
	 */
	ModeBinary
} GSM_Alcatel_Mode;

/**
 * Protocol version being used for binary mode.
 */
typedef enum {
	/**
	 * Version 1.0 used in BE5 phones (501, 701).
	 */
	V_1_0 = 1,
	/**
	 * Version 1.1 used in BF5 phones (715, 535, 735).
	 */
	V_1_1
} GSM_Alcatel_ProtocolVersion;

/**
 * State of binary mode.
 */
typedef enum {
	/**
	 * Binary mode is active. No type selected.
	 */
	StateAttached = 1,
	/**
	 * Opened session of some type.
	 */
	StateSession,
	/**
	 * Some item is being edited.
	 */
	StateEdit
} GSM_Alcatel_BinaryState;

/**
 * Type of active binary session.
 */
typedef enum {
	/**
	 * Calendar events.
	 */
	TypeCalendar = 1,
	/**
	 * Contacts.
	 */
	TypeContacts,
	/**
	 * To do items.
	 */
	TypeToDo
} GSM_Alcatel_BinaryType;

/**
 * Alcatel internal types.
 */
typedef enum {
	/**
	 * Date, stored as @ref GSM_DateTime.
	 */
	Alcatel_date,
	/**
	 * Time, stored as @ref GSM_DateTime.
	 */
	Alcatel_time,
	/**
	 * String, strored as chars
	 */
	Alcatel_string,	/* char	*/
	/**
	 * Phone number (can contain anything, but dialling it then may cause
	 * strange problems to phone) strored as chars.
	 */
	Alcatel_phone,
	/**
	 * Enumeration, usually used for user defined values (categories),
	 * stored as int.
	 */
	Alcatel_enum,
	/**
	 * Boolean, stored as int.
	 */
	Alcatel_bool,
	/**
	 * 32-bit unsigned integer, stored as int.
	 */
	Alcatel_int,
	/**
	 * 8-bit usigned integer, stored as int.
	 */
	Alcatel_byte
} GSM_Alcatel_FieldType;

/**
 * Return value for GetMemoryStatus. There is no way ho to determine free
 * memory so we have to return some fixed value.
 */
#define ALCATEL_FREE_MEMORY		100
/**
 * Maximum location, that will driver attempt to read. Because phone can have
 * up to 2^32 locations, we want to limit this a bit.
 */
/* There COULD be 0xffffffff on next line, but this is IMHO enough */
#define ALCATEL_MAX_LOCATION		0xffff
/**
 * Maximum category count. Used for static cache size.
 */
#define ALCATEL_MAX_CATEGORIES		100

/**
 * Alcatel driver private data.
 */
typedef struct {
	/***********************************/
	/* Communication state information */
	/***********************************/
	/**
	 * Mode of current communication.
	 */
	GSM_Alcatel_Mode	Mode;
	/**
	 * State of current communication if phone is in binary mode.
	 */
	GSM_Alcatel_BinaryState	BinaryState;
	/**
	 * Type of current communication if phone is in session or edit state,
	 * zero otherwise.
	 */
	GSM_Alcatel_BinaryType	BinaryType;
	/**
	 * Currently edited item when phone is in edit state, zero otherwise.
	 */
	int			BinaryItem;
	/**
	 * Protocol version being used.
	 */
	GSM_Alcatel_ProtocolVersion	ProtocolVersion;

	/*****************/
	/* Return values */
	/*****************/
	/**
	 * Return value for commited record position.
	 */
	int			CommitedRecord;
	/**
	 * Used for detecting end of large data data, that don't fit in one
	 * message.
	 */
	bool			TransferCompleted;
	/**
	 * Type of currently received field.
	 */
	GSM_Alcatel_FieldType	ReturnType;
	/**
	 * Value of currently returned field (if it can be saved in DateTime).
	 */
	GSM_DateTime		ReturnDateTime;
	/**
	 * Value of currently returned field (if it can be saved in int).
	 */
	unsigned int		ReturnInt;
	/**
	 * Value of currently returned field (if it can be saved in string).
	 */
	unsigned char		ReturnString[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2];

	/***********/
	/* Caches: */
	/***********/
	/* Listings of available items for each type */
	/**
	 * Pointer to list of active items.
	 */
	int			**CurrentList;
	/**
	 * Pointer to currently count of active items.
	 */
	int			*CurrentCount;
	/**
	 * Items locations in calendar.
	 */
	int			*CalendarItems;
	/**
	 * Items locations in to do list.
	 */
	int			*ToDoItems;
	/**
	 * Items locations in contacts.
	 */
	int			*ContactsItems;
	/**
	 * Count of calendar items stored in @ref CalendarItems.
	 */
	int			CalendarItemsCount;
	/**
	 * Count of todo items stored in @ref ToDoItems.
	 */
	int			ToDoItemsCount;
	/**
	 * Count of contacts items stored in @ref ContactsItems.
	 */
	int			ContactsItemsCount;
	/**
	 * Fields of currently active item.
	 */
	int			CurrentFields[GSM_PHONEBOOK_ENTRIES+1];
	/**
	 * Count of fields listed in @ref CurrentFields.
	 */
	int			CurrentFieldsCount;
	/**
	 * Location of current (eg. which identifies @ref CurrentFieldsCount
	 * and @ref CurrentFields) item.
	 */
	int			CurrentFieldsItem;
	/**
	 * Type of current (eg. which identifies @ref CurrentFieldsCount
	 * and @ref CurrentFields) item.
	 */
	GSM_Alcatel_BinaryType	CurrentFieldsType;

	/**
	 * Listing of categories of current type.
	 */
	int			CurrentCategories[ALCATEL_MAX_CATEGORIES+1];
	/**
	 * Cache for category names of current type. The index here is not
	 * same as in @ref CurrentCategories, it is id of category here.
	 */
	char			CurrentCategoriesCache[ALCATEL_MAX_CATEGORIES+1][(GSM_MAX_CATEGORY_NAME_LENGTH + 1)*2];
	/**
	 * Count of entries in @ref CurrentCategories.
	 */
	int			CurrentCategoriesCount;
	/**
	 * Type of current categories in @ref CurrentCategories etc.
	 */
	GSM_Alcatel_BinaryType	CurrentCategoriesType;

} GSM_Phone_ALCATELData;
#endif

/* How should editor hadle tabs in this file? Add editor commands here.
 * vim: noexpandtab sw=8 ts=8 sts=8:
 */