summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct3/n9210.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct3/n9210.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c396
1 files changed, 396 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
new file mode 100644
index 0000000..e82d530
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -0,0 +1,396 @@
1/* (c) 2002-2003 by Marcin Wiacek */
2
3#include "../../../gsmstate.h"
4
5#ifdef GSM_ENABLE_NOKIA9210
6
7#include <string.h>
8#include <time.h>
9
10#include "../../../misc/coding/coding.h"
11#include "../../../gsmcomon.h"
12#include "../../../service/gsmlogo.h"
13#include "../../pfunc.h"
14#include "../nfunc.h"
15#include "n9210.h"
16#include "dct3func.h"
17
18static GSM_Error N9210_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
19{
20 unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
21
22 s->Phone.Data.Bitmap=Bitmap;
23 switch (Bitmap->Type) {
24 case GSM_OperatorLogo:
25 smprintf(s, "Getting operator logo\n");
26 /* This is like DCT3_GetNetworkInfo */
27 return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
28 case GSM_StartupLogo:
29 smprintf(s, "Getting startup logo\n");
30 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
31 case GSM_WelcomeNote_Text:
32 smprintf(s, "Getting welcome note\n");
33 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
34 default:
35 break;
36 }
37 return ERR_NOTSUPPORTED;
38}
39
40static GSM_Error N9210_ReplySetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
41{
42 smprintf(s, "Operator logo clear/set\n");
43 return ERR_NONE;
44}
45
46static GSM_Error N9210_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
47{
48 GSM_Error error;
49 GSM_Phone_Bitmap_TypesType;
50 int Width, Height, i,count=3;
51 unsigned char req[600] = { N7110_FRAME_HEADER };
52 unsigned char reqStartup[1000] = {
53 N6110_FRAME_HEADER, 0xec,
54 0x15, /* Startup Logo setting */
55 0x04, 0x00, 0x00, 0x00, 0x30, 0x00,
56 0x02, 0xc0, 0x54, 0x00, 0x03, 0xc0,
57 0xf8, 0xf8, 0x01, 0x04};
58 unsigned char reqStartupText[500] = {
59 N7110_FRAME_HEADER, 0xec,
60 0x02}; /* Startup Text setting */
61 unsigned char reqClrOp[] = {
62 N7110_FRAME_HEADER, 0xAF,
63 0x02}; /* Number of logo = 0 - 0x04 */
64
65 switch (Bitmap->Type) {
66 case GSM_StartupLogo:
67 if (Bitmap->Location!=1) return ERR_NOTSUPPORTED;
68 Type=GSM_NokiaStartupLogo;
69 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
70 PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
71 smprintf(s, "Setting startup logo\n");
72 return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
73 case GSM_WelcomeNote_Text:
74 /* Nokia bug: Unicode text is moved one char to left */
75 CopyUnicodeString(reqStartupText + 4, Bitmap->Text);
76 reqStartupText[4] = 0x02;
77 i = 5 + UnicodeLength(Bitmap->Text) * 2;
78 reqStartupText[i++] = 0;
79 reqStartupText[i++] = 0;
80 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
81 case GSM_OperatorLogo:
82 /* First part for clearing logo */
83 if (!strcmp(Bitmap->NetworkCode,"000 00")) {
84 for (i=0;i<5;i++) {
85 reqClrOp[4] = i;
86 error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
87 if (error != ERR_NONE) return error;
88 }
89 }
90 Type=GSM_NokiaOperatorLogo;
91 req[count++] = 0xA3;
92 req[count++] = 0x01;
93 req[count++] = 0x00; /* Logo removed */
94 NOKIA_EncodeNetworkCode(req+count, "000 00");
95 count = count + 3;
96 req[count++] = 0x00;
97 req[count++] = 0x04;
98 req[count++] = 0x08; /* Length of rest + 2 */
99 memcpy(req+count, "\x00\x00\x00\x00\x00\x00", 6);
100 count += 6;
101 error=GSM_WaitFor (s, req, count, 0x0A, 4, ID_SetBitmap);
102 if (error != ERR_NONE) return error;
103 /* We wanted only clear - now exit */
104 if (!strcmp(Bitmap->NetworkCode,"000 00")) return error;
105
106 /* Now setting logo */
107 count=3;
108 req[count++] = 0xA3;
109 req[count++] = 0x01;
110 req[count++] = 0x01; /* Logo set */
111 NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode);
112 count = count + 3;
113 req[count++] = 0x00;
114 req[count++] = 0x04;
115 req[count++] = PHONE_GetBitmapSize(Type,0,0)+8;
116 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
117 req[count++] = Width;
118 req[count++] = Height;
119 req[count++] = PHONE_GetBitmapSize(Type,0,0);
120 req[count++] = 0x00;
121 req[count++] = 0x00;
122 req[count++] = 0x00;
123 PHONE_EncodeBitmap(Type, req+count, Bitmap);
124 return GSM_WaitFor (s, req, count+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
125 default:
126 break;
127 }
128 return ERR_NOTSUPPORTED;
129}
130
131static GSM_Error N9210_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
132{
133 GSM_SMSMessage sms;
134 GSM_Phone_Data *Data = &s->Phone.Data;
135
136#ifdef DEBUG
137 smprintf(s, "SMS message received\n");
138 sms.State = SMS_UnRead;
139 sms.InboxFolder = true;
140 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
141#endif
142 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
143 sms.State = SMS_UnRead;
144 sms.InboxFolder = true;
145 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
146
147 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
148 }
149 return ERR_NONE;
150}
151
152#ifdef GSM_ENABLE_N71_92INCOMINGINFO
153static GSM_Error N9210_ReplySetIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
154{
155 switch (msg.Buffer[3]) {
156 case 0x0e:
157 s->Phone.Data.EnableIncomingSMS = true;
158 smprintf(s, "Incoming SMS enabled\n");
159 return ERR_NONE;
160 case 0x0f:
161 smprintf(s, "Error enabling incoming SMS\n");
162 switch (msg.Buffer[4]) {
163 case 0x0c:
164 smprintf(s, "No PIN ?\n");
165 return ERR_SECURITYERROR;
166 default:
167 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
168 }
169 }
170 return ERR_UNKNOWNRESPONSE;
171}
172#endif
173
174static GSM_Error N9210_SetIncomingSMS(GSM_StateMachine *s, bool enable)
175{
176#ifdef GSM_ENABLE_N71_92INCOMINGINFO
177 unsigned char req[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02};
178
179 if (enable!=s->Phone.Data.EnableIncomingSMS) {
180 if (enable) {
181 smprintf(s, "Enabling incoming SMS\n");
182 return GSM_WaitFor (s, req, 7, 0x02, 4, ID_SetIncomingSMS);
183 } else {
184 s->Phone.Data.EnableIncomingSMS = false;
185 smprintf(s, "Disabling incoming SMS\n");
186 }
187 }
188 return ERR_NONE;
189#else
190 return ERR_SOURCENOTAVAILABLE;
191#endif
192}
193
194static GSM_Error N9210_Initialise (GSM_StateMachine *s)
195{
196#ifdef DEBUG
197 DCT3_SetIncomingCB(s,true);
198
199#ifdef GSM_ENABLE_N71_92INCOMINGINFO
200 N9210_SetIncomingSMS(s,true);
201#endif
202
203#endif
204 return ERR_NONE;
205}
206
207GSM_Error N9210_AnswerCall(GSM_StateMachine *s, int ID, bool all)
208{
209 if (!all) return DCT3DCT4_AnswerCall(s,ID);
210 return DCT3_AnswerAllCalls(s);
211}
212
213static GSM_Reply_Function N9210ReplyFunctions[] = {
214 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame},
215 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame},
216#ifdef GSM_ENABLE_N71_92INCOMINGINFO
217 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0E,ID_SetIncomingSMS},
218 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0F,ID_SetIncomingSMS},
219#endif
220 {N9210_ReplyIncomingSMS, "\x02",0x03,0x11,ID_IncomingFrame},
221#ifdef GSM_ENABLE_CELLBROADCAST
222 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB},
223 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB},
224 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame},
225#endif
226 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
227 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
228 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
229
230 {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
231 {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
232
233 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo},
234 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame},
235 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality},
236 {N9210_ReplySetOpLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
237 {N9210_ReplySetOpLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
238
239 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge},
240
241 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
242 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
243
244 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity},
245 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
246 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
247 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
248 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
249 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
250 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
251 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
252 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode},
253 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth},
254 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI},
255
256 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
257 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
258 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
259 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
260
261 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel },
262 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware },
263
264 {NULL, "\x00",0x00,0x00,ID_None }
265};
266
267GSM_Phone_Functions N9210Phone = {
268 "9210|9210i",
269 N9210ReplyFunctions,
270 N9210_Initialise,
271 PHONE_Terminate,
272 GSM_DispatchMessage,
273 NOTSUPPORTED, /* ShowStartInfo */
274 NOKIA_GetManufacturer,
275 DCT3DCT4_GetModel,
276 DCT3DCT4_GetFirmware,
277 DCT3_GetIMEI,
278 DCT3_GetOriginalIMEI,
279 DCT3_GetManufactureMonth,
280 DCT3_GetProductCode,
281 DCT3_GetHardware,
282 DCT3_GetPPM,
283 NOTSUPPORTED, /* GetSIMIMSI */
284 N71_92_GetDateTime,
285 N71_92_SetDateTime,
286 NOTIMPLEMENTED, /* GetAlarm */
287 NOTIMPLEMENTED, /* SetAlarm */
288 NOTSUPPORTED, /* GetLocale */
289 NOTSUPPORTED, /* SetLocale */
290 NOTIMPLEMENTED, /* PressKey */
291 NOTIMPLEMENTED, /* Reset */
292 NOTIMPLEMENTED, /* ResetPhoneSettings*/
293 NOTSUPPORTED, /* EnterSecurityCode*/
294 NOTSUPPORTED, /* GetSecurityStatus*/
295 NOTSUPPORTED, /* GetDisplayStatus*/
296 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
297 N71_92_GetBatteryCharge,
298 N71_92_GetSignalQuality,
299 DCT3_GetNetworkInfo,
300 NOTSUPPORTED, /* GetCategory */
301 NOTSUPPORTED, /* AddCategory */
302 NOTSUPPORTED, /* GetCategoryStatus */
303 NOTIMPLEMENTED, /* GetMemoryStatus */
304 NOTIMPLEMENTED, /* GetMemory */
305 NOTIMPLEMENTED, /* GetNextMemory */
306 NOTIMPLEMENTED, /* SetMemory */
307 NOTIMPLEMENTED, /* AddMemory */
308 NOTIMPLEMENTED, /* DeleteMemory */
309 NOTIMPLEMENTED, /* DeleteAllMemory */
310 NOTIMPLEMENTED, /* GetSpeedDial */
311 NOTIMPLEMENTED, /* SetSpeedDial */
312 DCT3_GetSMSC,
313 DCT3_SetSMSC, /* FIXME: test it */
314 NOTIMPLEMENTED, /* GetSMSStatus */
315 NOTIMPLEMENTED, /* GetSMS */
316 NOTIMPLEMENTED, /* GetNextSMS */
317 NOTIMPLEMENTED, /* SetSMS */
318 NOTIMPLEMENTED, /* AddSMS */
319 NOTIMPLEMENTED, /* DeleteSMS */
320 DCT3_SendSMSMessage,
321 NOTSUPPORTED, /* SendSavedSMS */
322 N9210_SetIncomingSMS,
323 DCT3_SetIncomingCB,
324 NOTIMPLEMENTED, /* GetSMSFolders */
325 NOTSUPPORTED, /* AddSMSFolder */
326 NOTSUPPORTED, /* DeleteSMSFolder */
327 DCT3_DialVoice,
328 N9210_AnswerCall,
329 DCT3_CancelCall,
330 NOTSUPPORTED, /* HoldCall */
331 NOTSUPPORTED, /* UnholdCall */
332 NOTSUPPORTED, /* ConferenceCall */
333 NOTSUPPORTED, /* SplitCall */
334 NOTSUPPORTED, /* TransferCall */
335 NOTSUPPORTED, /* SwitchCall */
336 NOTSUPPORTED, /* GetCallDivert */
337 NOTSUPPORTED, /* SetCallDivert */
338 NOTSUPPORTED, /* CancelAllDiverts*/
339 NOTSUPPORTED, /* SetIncomingCall */
340 NOTIMPLEMENTED, /* SetIncomingUSSD */
341 NOTSUPPORTED, /* SendDTMF */
342 NOTIMPLEMENTED, /* GetRingtone */
343 NOTIMPLEMENTED, /* SetRingtone */
344 NOTSUPPORTED, /* GetRingtonesInfo*/
345 NOTSUPPORTED, /* DeleteUserRingtones*/
346 NOTSUPPORTED, /* PlayTone */
347 NOTIMPLEMENTED, /* GetWAPBookmark */
348 NOTIMPLEMENTED, /* SetWAPBookmark */
349 NOTIMPLEMENTED, /* DeleteWAPBookmark */
350 NOTIMPLEMENTED, /* GetWAPSettings */
351 NOTSUPPORTED, /* SetWAPSettings */
352 NOTSUPPORTED, /* GetMMSSettings */
353 NOTSUPPORTED, /* SetMMSSettings */
354 NOTSUPPORTED, /* GetSyncMLSettings*/
355 NOTSUPPORTED, /* SetSyncMLSettings*/
356 NOTSUPPORTED, /* GetChatSettings */
357 NOTSUPPORTED, /* SetChatSettings */
358 N9210_GetBitmap,
359 N9210_SetBitmap,
360 NOTSUPPORTED, /* GetToDoStatus */
361 NOTSUPPORTED, /* GetToDo */
362 NOTSUPPORTED, /* GetNextToDo */
363 NOTSUPPORTED, /* SetToDo */
364 NOTSUPPORTED, /* AddToDo */
365 NOTSUPPORTED, /* DeleteToDo */
366 NOTSUPPORTED, /* DeleteAllToDo */
367 NOTSUPPORTED, /* GetCalendarStatus*/
368 NOTSUPPORTED, /* GetCalendar */
369 NOTSUPPORTED, /* GetNextCalendar */
370 NOTSUPPORTED, /* SetCalendar */
371 NOTSUPPORTED, /* AddCalendar */
372 NOTSUPPORTED, /* DeleteCalendar */
373 NOTSUPPORTED, /* DeleteAllCalendar*/
374 NOTSUPPORTED, /* GetCalendarSettings*/
375 NOTSUPPORTED, /* SetCalendarSettings*/
376 NOTSUPPORTED, /* GetNote */
377 NOTIMPLEMENTED, /* GetProfile */
378 NOTSUPPORTED, /* SetProfile */
379 NOTSUPPORTED, /* GetFMStation */
380 NOTSUPPORTED, /* SetFMStation */
381 NOTSUPPORTED, /* ClearFMStations */
382 NOTSUPPORTED, /* GetNextFileFolder*/
383 NOTSUPPORTED, /* GetFilePart */
384 NOTSUPPORTED, /* AddFile */
385 NOTSUPPORTED, /* GetFileSystemStatus*/
386 NOTSUPPORTED, /* DeleteFile */
387 NOTSUPPORTED, /* AddFolder */
388 NOTSUPPORTED, /* GetGPRSAccessPoint*/
389 NOTSUPPORTED /* SetGPRSAccessPoint*/
390};
391
392#endif
393
394/* How should editor hadle tabs in this file? Add editor commands here.
395 * vim: noexpandtab sw=8 ts=8 sts=8:
396 */