author | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 17:24:40 (UTC) |
commit | 88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22 (patch) (unidiff) | |
tree | 6331418973714243beb674abc87692277b83869d /gammu/emb/common/phone/nokia/dct4/n3320.c | |
parent | ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf (diff) | |
download | kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.zip kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.gz kdepimpi-88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22.tar.bz2 |
Initial revision
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct4/n3320.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/phone/nokia/dct4/n3320.c | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c new file mode 100644 index 0000000..51e6f18 --- a/dev/null +++ b/gammu/emb/common/phone/nokia/dct4/n3320.c | |||
@@ -0,0 +1,271 @@ | |||
1 | /* (c) 2004 by Marcin Wiacek */ | ||
2 | |||
3 | #include "../../../gsmstate.h" | ||
4 | |||
5 | #ifdef GSM_ENABLE_NOKIA3320 | ||
6 | |||
7 | #include <string.h> | ||
8 | #include <time.h> | ||
9 | |||
10 | #include "../../../gsmcomon.h" | ||
11 | #include "../../../misc/coding/coding.h" | ||
12 | #include "../../../service/gsmlogo.h" | ||
13 | #include "../nfunc.h" | ||
14 | #include "../nfuncold.h" | ||
15 | #include "../../pfunc.h" | ||
16 | #include "n3320.h" | ||
17 | |||
18 | static GSM_Error N3320_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) | ||
19 | { | ||
20 | smprintf(s, "Phonebook entry received\n"); | ||
21 | switch (msg.Buffer[6]) { | ||
22 | case 0x0f: | ||
23 | return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); | ||
24 | default: | ||
25 | return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,true); | ||
26 | } | ||
27 | return ERR_UNKNOWN; | ||
28 | } | ||
29 | |||
30 | static GSM_Error N3320_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) | ||
31 | { | ||
32 | unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, | ||
33 | 0xfe, 0x10, /* memory type */ | ||
34 | 0x00, 0x00, 0x00, 0x00, | ||
35 | 0x00, 0x01, /* location */ | ||
36 | 0x00, 0x00, 0x01}; | ||
37 | |||
38 | req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); | ||
39 | if (entry->MemoryType == MEM_SM) return ERR_NOTSUPPORTED; | ||
40 | if (req[9]==0xff) return ERR_NOTSUPPORTED; | ||
41 | |||
42 | if (entry->Location==0x00) return ERR_INVALIDLOCATION; | ||
43 | |||
44 | req[14] = entry->Location / 256; | ||
45 | req[15] = entry->Location % 256; | ||
46 | |||
47 | s->Phone.Data.Memory=entry; | ||
48 | smprintf(s, "Getting phonebook entry\n"); | ||
49 | return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory); | ||
50 | } | ||
51 | |||
52 | static GSM_Error N3320_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) | ||
53 | { | ||
54 | GSM_Phone_Data *Data = &s->Phone.Data; | ||
55 | |||
56 | smprintf(s, "Memory status received\n"); | ||
57 | /* Quess ;-)) */ | ||
58 | if (msg.Buffer[14]==0x10) { | ||
59 | Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19]; | ||
60 | } else { | ||
61 | Data->MemoryStatus->MemoryFree = msg.Buffer[17]; | ||
62 | } | ||
63 | smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree); | ||
64 | Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; | ||
65 | smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed); | ||
66 | Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; | ||
67 | smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree); | ||
68 | return ERR_NONE; | ||
69 | } | ||
70 | |||
71 | static GSM_Error N3320_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) | ||
72 | { | ||
73 | unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, | ||
74 | 0x00, /* memory type */ | ||
75 | 0x55, 0x55, 0x55, 0x00}; | ||
76 | |||
77 | req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); | ||
78 | if (Status->MemoryType == MEM_SM) return ERR_NOTSUPPORTED; | ||
79 | if (req[5]==0xff) return ERR_NOTSUPPORTED; | ||
80 | |||
81 | s->Phone.Data.MemoryStatus=Status; | ||
82 | smprintf(s, "Getting memory status\n"); | ||
83 | return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus); | ||
84 | } | ||
85 | |||
86 | static GSM_Error N3320_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) | ||
87 | { | ||
88 | smprintf(s, "Date & time received\n"); | ||
89 | if (msg.Buffer[4]==0x01) { | ||
90 | NOKIA_DecodeDateTime(s, msg.Buffer+10, s->Phone.Data.DateTime); | ||
91 | return ERR_NONE; | ||
92 | } | ||
93 | smprintf(s, "Not set in phone\n"); | ||
94 | return ERR_EMPTY; | ||
95 | } | ||
96 | |||
97 | static GSM_Error N3320_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) | ||
98 | { | ||
99 | unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00}; | ||
100 | |||
101 | s->Phone.Data.DateTime=date_time; | ||
102 | smprintf(s, "Getting date & time\n"); | ||
103 | return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime); | ||
104 | } | ||
105 | |||
106 | static GSM_Error N3320_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) | ||
107 | { | ||
108 | return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N3320.LastCalendar,&s->Phone.Data.Priv.N3320.LastCalendarYear,&s->Phone.Data.Priv.N3320.LastCalendarPos); | ||
109 | } | ||
110 | |||
111 | static GSM_Error N3320_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) | ||
112 | { | ||
113 | GSM_Error error; | ||
114 | |||
115 | /* Method 1 */ | ||
116 | error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N3320.LastCalendar); | ||
117 | if (error!=ERR_NONE) return error; | ||
118 | Status->Used = s->Phone.Data.Priv.N3320.LastCalendar.Number; | ||
119 | return ERR_NONE; | ||
120 | } | ||
121 | |||
122 | static GSM_Error N3320_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) | ||
123 | { | ||
124 | return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N3320.LastCalendar); | ||
125 | } | ||
126 | |||
127 | static GSM_Reply_Function N3320ReplyFunctions[] = { | ||
128 | {N3320_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, | ||
129 | {N3320_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, | ||
130 | |||
131 | {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ | ||
132 | {N3320_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ | ||
133 | |||
134 | {N3320_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime }, | ||
135 | |||
136 | {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, | ||
137 | {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, | ||
138 | |||
139 | {NULL, "\x00",0x00,0x00,ID_None } | ||
140 | }; | ||
141 | |||
142 | GSM_Phone_Functions N3320Phone = { | ||
143 | "3320", | ||
144 | N3320ReplyFunctions, | ||
145 | NONEFUNCTION, /* Initialise */ | ||
146 | NONEFUNCTION, /* Terminate */ | ||
147 | GSM_DispatchMessage, | ||
148 | NOTSUPPORTED, /* ShowStartInfo */ | ||
149 | NOKIA_GetManufacturer, | ||
150 | DCT3DCT4_GetModel, | ||
151 | DCT3DCT4_GetFirmware, | ||
152 | NOTSUPPORTED, /* GetIMEI */ | ||
153 | NOTSUPPORTED, /* GetOriginalIMEI */ | ||
154 | NOTSUPPORTED, /* GetManufactureMonth*/ | ||
155 | NOTSUPPORTED, /* GetProductCode */ | ||
156 | NOTSUPPORTED, /* GetHardware */ | ||
157 | NOTSUPPORTED, /* GetPPM */ | ||
158 | NOTSUPPORTED, /* GetSIMIMSI */ | ||
159 | N3320_GetDateTime, | ||
160 | NOTSUPPORTED, /* SetDateTime */ | ||
161 | NOTSUPPORTED, /* GetAlarm */ | ||
162 | NOTSUPPORTED, /* SetAlarm */ | ||
163 | NOTSUPPORTED, /* GetLocale */ | ||
164 | NOTSUPPORTED, /* SetLocale */ | ||
165 | NOTSUPPORTED, /* PressKey */ | ||
166 | NOTSUPPORTED, /* Reset */ | ||
167 | NOTSUPPORTED, /* ResetPhoneSettings*/ | ||
168 | NOTSUPPORTED, /* EnterSecurityCode*/ | ||
169 | NOTSUPPORTED, /* GetSecurityStatus*/ | ||
170 | NOTSUPPORTED, /* GetDisplayStatus*/ | ||
171 | NOTSUPPORTED, /* SetAutoNetworkLogin*/ | ||
172 | NOTSUPPORTED, /* GetBatteryCharge*/ | ||
173 | NOTSUPPORTED, /* GetSignalQuality*/ | ||
174 | NOTSUPPORTED, /* GetNetworkInfo */ | ||
175 | NOTSUPPORTED, /* GetCategory */ | ||
176 | NOTSUPPORTED, /* AddCategory */ | ||
177 | NOTSUPPORTED, /* GetCategoryStatus */ | ||
178 | N3320_GetMemoryStatus, | ||
179 | N3320_GetMemory, | ||
180 | NOTSUPPORTED, /* GetNextMemory */ | ||
181 | NOTSUPPORTED, /* SetMemory */ | ||
182 | NOTSUPPORTED, /* AddMemory */ | ||
183 | NOTSUPPORTED, /* DeleteMemory */ | ||
184 | NOTIMPLEMENTED, /* DeleteAllMemory */ | ||
185 | NOTSUPPORTED, /* GetSpeedDial */ | ||
186 | NOTSUPPORTED, /* SetSpeedDial */ | ||
187 | NOTSUPPORTED, /* GetSMSC */ | ||
188 | NOTSUPPORTED, /* SetSMSC */ | ||
189 | NOTSUPPORTED, /* GetSMSStatus */ | ||
190 | NOTSUPPORTED, /* GetSMS */ | ||
191 | NOTSUPPORTED, /* GetNextSMS */ | ||
192 | NOTSUPPORTED, /* SetSMS */ | ||
193 | NOTSUPPORTED, /* AddSMS */ | ||
194 | NOTSUPPORTED, /* DeleteSMS */ | ||
195 | NOTSUPPORTED, /* SendSMS */ | ||
196 | NOTSUPPORTED, /* SendSavedSMS */ | ||
197 | NOTSUPPORTED, /* SetIncomingSMS */ | ||
198 | NOTSUPPORTED, /* SetIncomingCB */ | ||
199 | NOTSUPPORTED, /* GetSMSFolders */ | ||
200 | NOTSUPPORTED, /* AddSMSFolder */ | ||
201 | NOTSUPPORTED, /* DeleteSMSFolder */ | ||
202 | NOTIMPLEMENTED, /* DialVoice */ | ||
203 | NOTIMPLEMENTED, /* AnswerCall */ | ||
204 | NOTIMPLEMENTED, /* CancelCall */ | ||
205 | NOTIMPLEMENTED, /* HoldCall */ | ||
206 | NOTIMPLEMENTED, /* UnholdCall */ | ||
207 | NOTIMPLEMENTED, /* ConferenceCall */ | ||
208 | NOTIMPLEMENTED, /* SplitCall */ | ||
209 | NOTIMPLEMENTED, /* TransferCall */ | ||
210 | NOTIMPLEMENTED, /* SwitchCall */ | ||
211 | NOTSUPPORTED, /* GetCallDivert */ | ||
212 | NOTSUPPORTED, /* SetCallDivert */ | ||
213 | NOTSUPPORTED, /* CancelAllDiverts*/ | ||
214 | NOTIMPLEMENTED, /* SetIncomingCall */ | ||
215 | NOTIMPLEMENTED, /* SetIncomingUSSD */ | ||
216 | NOTSUPPORTED, /* SendDTMF */ | ||
217 | NOTSUPPORTED, /* GetRingtone */ | ||
218 | NOTSUPPORTED, /* SetRingtone */ | ||
219 | NOTSUPPORTED, /* GetRingtonesInfo*/ | ||
220 | NOTIMPLEMENTED, /* DeleteUserRingtones*/ | ||
221 | NOTSUPPORTED, /* PlayTone */ | ||
222 | NOTSUPPORTED, /* GetWAPBookmark */ | ||
223 | NOTSUPPORTED, /* SetWAPBookmark */ | ||
224 | NOTSUPPORTED, /* DeleteWAPBookmark */ | ||
225 | NOTSUPPORTED, /* GetWAPSettings */ | ||
226 | NOTSUPPORTED, /* SetWAPSettings */ | ||
227 | NOTSUPPORTED, /* GetMMSSettings */ | ||
228 | NOTSUPPORTED, /* SetMMSSettings */ | ||
229 | NOTSUPPORTED, /* GetSyncMLSettings*/ | ||
230 | NOTSUPPORTED, /* SetSyncMLSettings*/ | ||
231 | NOTSUPPORTED, /* GetChatSettings */ | ||
232 | NOTSUPPORTED, /* SetChatSettings */ | ||
233 | NOTSUPPORTED, /* GetBitmap */ | ||
234 | NOTSUPPORTED, /* SetBitmap */ | ||
235 | NOTSUPPORTED, /* GetToDoStatus */ | ||
236 | NOTSUPPORTED, /* GetToDo */ | ||
237 | NOTSUPPORTED, /* GetNextToDo */ | ||
238 | NOTSUPPORTED, /* SetToDo */ | ||
239 | NOTSUPPORTED, /* AddToDo */ | ||
240 | NOTSUPPORTED, /* DeleteToDo */ | ||
241 | NOTSUPPORTED, /* DeleteAllToDo */ | ||
242 | N3320_GetCalendarStatus, | ||
243 | NOTIMPLEMENTED, /* GetCalendar */ | ||
244 | N3320_GetNextCalendar, | ||
245 | NOTIMPLEMENTED, /* SetCalendar */ | ||
246 | NOTSUPPORTED, /* AddCalendar */ | ||
247 | NOTSUPPORTED, /* DeleteCalendar */ | ||
248 | NOTIMPLEMENTED, /* DeleteAllCalendar*/ | ||
249 | NOTSUPPORTED, /* GetCalendarSettings*/ | ||
250 | NOTSUPPORTED, /* SetCalendarSettings*/ | ||
251 | NOTSUPPORTED, /* GetNote */ | ||
252 | NOTSUPPORTED, /* GetProfile */ | ||
253 | NOTSUPPORTED, /* SetProfile */ | ||
254 | NOTSUPPORTED, /* GetFMStation */ | ||
255 | NOTSUPPORTED, /* SetFMStation */ | ||
256 | NOTSUPPORTED, /* ClearFMStations */ | ||
257 | NOTSUPPORTED, /* GetNextFileFolder*/ | ||
258 | NOTSUPPORTED, /* GetFilePart */ | ||
259 | NOTIMPLEMENTED, /* AddFilePart */ | ||
260 | NOTSUPPORTED, /* GetFileSystemStatus*/ | ||
261 | NOTIMPLEMENTED, /* DeleteFile */ | ||
262 | NOTIMPLEMENTED, /* AddFolder */ | ||
263 | NOTSUPPORTED, /* GetGPRSAccessPoint*/ | ||
264 | NOTSUPPORTED /* SetGPRSAccessPoint*/ | ||
265 | }; | ||
266 | |||
267 | #endif | ||
268 | |||
269 | /* How should editor hadle tabs in this file? Add editor commands here. | ||
270 | * vim: noexpandtab sw=8 ts=8 sts=8: | ||
271 | */ | ||