Gammu internals  1.38.0
n3320.c
Go to the documentation of this file.
1 /* (c) 2004 by Marcin Wiacek */
2 
3 #include <gammu-config.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  if (msg->Buffer[6] == 0x0f)
22  return N71_65_ReplyGetMemoryError(msg->Buffer[10], s);
23 
24  return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg->Buffer+22, msg->Length-22,TRUE);
25 }
26 
27 static GSM_Error N3320_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
28 {
29  unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
30  0xfe, 0x10, /* memory type */
31  0x00, 0x00, 0x00, 0x00,
32  0x00, 0x01, /* location */
33  0x00, 0x00, 0x01};
34 
36  if (entry->MemoryType == MEM_SM) return ERR_NOTSUPPORTED;
37  if (req[9]==0xff) return ERR_NOTSUPPORTED;
38 
39  if (entry->Location==0x00) return ERR_INVALIDLOCATION;
40 
41  req[14] = entry->Location / 256;
42  req[15] = entry->Location % 256;
43 
44  s->Phone.Data.Memory=entry;
45  smprintf(s, "Getting phonebook entry\n");
46  return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory);
47 }
48 
49 static GSM_Error N3320_ReplyGetMemoryStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
50 {
51  GSM_Phone_Data *Data = &s->Phone.Data;
52 
53  smprintf(s, "Memory status received\n");
54  /* Quess ;-)) */
55  if (msg->Buffer[14]==0x10) {
56  Data->MemoryStatus->MemoryFree = msg->Buffer[18]*256 + msg->Buffer[19];
57  } else {
58  Data->MemoryStatus->MemoryFree = msg->Buffer[17];
59  }
60  smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree);
61  Data->MemoryStatus->MemoryUsed = msg->Buffer[20]*256 + msg->Buffer[21];
62  smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed);
64  smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree);
65  return ERR_NONE;
66 }
67 
68 static GSM_Error N3320_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
69 {
70  unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
71  0x00, /* memory type */
72  0x55, 0x55, 0x55, 0x00};
73 
75  if (Status->MemoryType == MEM_SM) return ERR_NOTSUPPORTED;
76  if (req[5]==0xff) return ERR_NOTSUPPORTED;
77 
78  s->Phone.Data.MemoryStatus=Status;
79  smprintf(s, "Getting memory status\n");
80  return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus);
81 }
82 
83 static GSM_Error N3320_ReplyGetDateTime(GSM_Protocol_Message *msg, GSM_StateMachine *s)
84 {
85  smprintf(s, "Date & time received\n");
86  if (msg->Buffer[4]==0x01) {
88  return ERR_NONE;
89  }
90  smprintf(s, "Not set in phone\n");
91  return ERR_EMPTY;
92 }
93 
94 static GSM_Error N3320_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
95 {
96  unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00};
97 
98  s->Phone.Data.DateTime=date_time;
99  smprintf(s, "Getting date & time\n");
100  return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime);
101 }
102 
103 static GSM_Error N3320_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start)
104 {
105  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);
106 }
107 
108 static GSM_Error N3320_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
109 {
110  GSM_Error error;
111 
112  /* Method 1 */
113  error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N3320.LastCalendar);
114  if (error!=ERR_NONE) return error;
115 
119  Status->Free = 100;
120  Status->Used = s->Phone.Data.Priv.N3320.LastCalendar.Number;
121  return ERR_NONE;
122 }
123 
124 static GSM_Error N3320_ReplyGetCalendarInfo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
125 {
126  return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N3320.LastCalendar);
127 }
128 
129 static GSM_Reply_Function N3320ReplyFunctions[] = {
130  {N3320_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
131  {N3320_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
132 
133  {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
134  {N3320_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
135 
136  {N3320_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime },
137 
138  {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
139  {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
140 
141  {NULL, "\x00",0x00,0x00,ID_None }
142 };
143 
144 GSM_Phone_Functions N3320Phone = {
145  "3320",
146  N3320ReplyFunctions,
147  NOTSUPPORTED, /* Install */
148  NONEFUNCTION, /* Initialise */
149  NONEFUNCTION, /* Terminate */
151  NOTSUPPORTED, /* ShowStartInfo */
155  NOTSUPPORTED, /* GetIMEI */
156  NOTSUPPORTED, /* GetOriginalIMEI */
157  NOTSUPPORTED, /* GetManufactureMonth */
158  NOTSUPPORTED, /* GetProductCode */
159  NOTSUPPORTED, /* GetHardware */
160  NOTSUPPORTED, /* GetPPM */
161  NOTSUPPORTED, /* GetSIMIMSI */
162  N3320_GetDateTime,
163  NOTSUPPORTED, /* SetDateTime */
164  NOTSUPPORTED, /* GetAlarm */
165  NOTSUPPORTED, /* SetAlarm */
166  NOTSUPPORTED, /* GetLocale */
167  NOTSUPPORTED, /* SetLocale */
168  NOTSUPPORTED, /* PressKey */
169  NOTSUPPORTED, /* Reset */
170  NOTSUPPORTED, /* ResetPhoneSettings */
171  NOTSUPPORTED, /* EnterSecurityCode */
172  NOTSUPPORTED, /* GetSecurityStatus */
173  NOTSUPPORTED, /* GetDisplayStatus */
174  NOTSUPPORTED, /* SetAutoNetworkLogin */
175  NOTSUPPORTED, /* GetBatteryCharge */
176  NOTSUPPORTED, /* GetSignalQuality */
177  NOTSUPPORTED, /* GetNetworkInfo */
178  NOTSUPPORTED, /* GetCategory */
179  NOTSUPPORTED, /* AddCategory */
180  NOTSUPPORTED, /* GetCategoryStatus */
181  N3320_GetMemoryStatus,
182  N3320_GetMemory,
183  NOTSUPPORTED, /* GetNextMemory */
184  NOTSUPPORTED, /* SetMemory */
185  NOTSUPPORTED, /* AddMemory */
186  NOTSUPPORTED, /* DeleteMemory */
187  NOTIMPLEMENTED, /* DeleteAllMemory */
188  NOTSUPPORTED, /* GetSpeedDial */
189  NOTSUPPORTED, /* SetSpeedDial */
190  NOTSUPPORTED, /* GetSMSC */
191  NOTSUPPORTED, /* SetSMSC */
192  NOTSUPPORTED, /* GetSMSStatus */
193  NOTSUPPORTED, /* GetSMS */
194  NOTSUPPORTED, /* GetNextSMS */
195  NOTSUPPORTED, /* SetSMS */
196  NOTSUPPORTED, /* AddSMS */
197  NOTSUPPORTED, /* DeleteSMS */
198  NOTSUPPORTED, /* SendSMS */
199  NOTSUPPORTED, /* SendSavedSMS */
200  NOTSUPPORTED, /* SetFastSMSSending */
201  NOTSUPPORTED, /* SetIncomingSMS */
202  NOTSUPPORTED, /* SetIncomingCB */
203  NOTSUPPORTED, /* GetSMSFolders */
204  NOTSUPPORTED, /* AddSMSFolder */
205  NOTSUPPORTED, /* DeleteSMSFolder */
206  NOTIMPLEMENTED, /* DialVoice */
207  NOTIMPLEMENTED, /* DialService */
208  NOTIMPLEMENTED, /* AnswerCall */
209  NOTIMPLEMENTED, /* CancelCall */
210  NOTIMPLEMENTED, /* HoldCall */
211  NOTIMPLEMENTED, /* UnholdCall */
212  NOTIMPLEMENTED, /* ConferenceCall */
213  NOTIMPLEMENTED, /* SplitCall */
214  NOTIMPLEMENTED, /* TransferCall */
215  NOTIMPLEMENTED, /* SwitchCall */
216  NOTSUPPORTED, /* GetCallDivert */
217  NOTSUPPORTED, /* SetCallDivert */
218  NOTSUPPORTED, /* CancelAllDiverts */
219  NOTIMPLEMENTED, /* SetIncomingCall */
220  NOTIMPLEMENTED, /* SetIncomingUSSD */
221  NOTSUPPORTED, /* SendDTMF */
222  NOTSUPPORTED, /* GetRingtone */
223  NOTSUPPORTED, /* SetRingtone */
224  NOTSUPPORTED, /* GetRingtonesInfo */
225  NOTIMPLEMENTED, /* DeleteUserRingtones */
226  NOTSUPPORTED, /* PlayTone */
227  NOTSUPPORTED, /* GetWAPBookmark */
228  NOTSUPPORTED, /* SetWAPBookmark */
229  NOTSUPPORTED, /* DeleteWAPBookmark */
230  NOTSUPPORTED, /* GetWAPSettings */
231  NOTSUPPORTED, /* SetWAPSettings */
232  NOTSUPPORTED, /* GetSyncMLSettings */
233  NOTSUPPORTED, /* SetSyncMLSettings */
234  NOTSUPPORTED, /* GetChatSettings */
235  NOTSUPPORTED, /* SetChatSettings */
236  NOTSUPPORTED, /* GetMMSSettings */
237  NOTSUPPORTED, /* SetMMSSettings */
238  NOTSUPPORTED, /* GetMMSFolders */
239  NOTSUPPORTED, /* GetNextMMSFile */
240  NOTSUPPORTED, /* GetBitmap */
241  NOTSUPPORTED, /* SetBitmap */
242  NOTSUPPORTED, /* GetToDoStatus */
243  NOTSUPPORTED, /* GetToDo */
244  NOTSUPPORTED, /* GetNextToDo */
245  NOTSUPPORTED, /* SetToDo */
246  NOTSUPPORTED, /* AddToDo */
247  NOTSUPPORTED, /* DeleteToDo */
248  NOTSUPPORTED, /* DeleteAllToDo */
249  N3320_GetCalendarStatus,
250  NOTIMPLEMENTED, /* GetCalendar */
251  N3320_GetNextCalendar,
252  NOTIMPLEMENTED, /* SetCalendar */
253  NOTSUPPORTED, /* AddCalendar */
254  NOTSUPPORTED, /* DeleteCalendar */
255  NOTIMPLEMENTED, /* DeleteAllCalendar */
256  NOTSUPPORTED, /* GetCalendarSettings */
257  NOTSUPPORTED, /* SetCalendarSettings */
258  NOTSUPPORTED, /* GetNoteStatus */
259  NOTSUPPORTED, /* GetNote */
260  NOTSUPPORTED, /* GetNextNote */
261  NOTSUPPORTED, /* SetNote */
262  NOTSUPPORTED, /* AddNote */
263  NOTSUPPORTED, /* DeleteNote */
264  NOTSUPPORTED, /* DeleteAllNotes */
265  NOTSUPPORTED, /* GetProfile */
266  NOTSUPPORTED, /* SetProfile */
267  NOTSUPPORTED, /* GetFMStation */
268  NOTSUPPORTED, /* SetFMStation */
269  NOTSUPPORTED, /* ClearFMStations */
270  NOTSUPPORTED, /* GetNextFileFolder */
271  NOTSUPPORTED, /* GetFolderListing */
272  NOTSUPPORTED, /* GetNextRootFolder */
273  NOTSUPPORTED, /* SetFileAttributes */
274  NOTSUPPORTED, /* GetFilePart */
275  NOTIMPLEMENTED, /* AddFilePart */
276  NOTSUPPORTED, /* SendFilePart */
277  NOTSUPPORTED, /* GetFileSystemStatus */
278  NOTIMPLEMENTED, /* DeleteFile */
279  NOTIMPLEMENTED, /* AddFolder */
280  NOTSUPPORTED, /* DeleteFolder */
281  NOTSUPPORTED, /* GetGPRSAccessPoint */
282  NOTSUPPORTED, /* SetGPRSAccessPoint */
283  NOTSUPPORTED, /* GetScreenshot */
284  NOTSUPPORTED, /* SetPower */
285  NOTSUPPORTED, /* PostConnect */
286  NONEFUNCTION /* PreAPICall */
287 };
288 
289 #endif
290 
291 /* How should editor hadle tabs in this file? Add editor commands here.
292  * vim: noexpandtab sw=8 ts=8 sts=8:
293  */
GSM_Error DCT3DCT4_GetModel(GSM_StateMachine *s)
GSM_MemoryType MemoryType
Definition: gammu-memory.h:415
#define NOTSUPPORTED
Definition: gsmcomon.h:14
GSM_MemoryEntry * Memory
Definition: gsmstate.h:497
#define N6110_FRAME_HEADER
Definition: ncommon.h:8
GSM_MemoryType NOKIA_GetMemoryType(GSM_StateMachine *s, GSM_MemoryType memory_type, unsigned char *ID)
GSM_Error N71_65_GetCalendarInfo1(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *LastCalendar)
GSM_Error GSM_DispatchMessage(GSM_StateMachine *s)
Definition: gsmstate.c:1131
#define NONEFUNCTION
Definition: gsmcomon.h:12
GSM_Error
Definition: gammu-error.h:23
GSM_Bitmap * Bitmap
Definition: gsmstate.h:573
GSM_Error DCT3DCT4_GetFirmware(GSM_StateMachine *s)
int gboolean
Definition: gammu-types.h:23
GSM_DateTime * DateTime
Definition: gsmstate.h:489
GSM_Phone Phone
Definition: gsmstate.h:1431
#define FALSE
Definition: gammu-types.h:25
struct GSM_Phone_Data::@2 Priv
GSM_Error N71_65_ReplyGetNextCalendar1(GSM_Protocol_Message *msg, GSM_StateMachine *s)
unsigned char N71_65_MEMORY_TYPES[]
Definition: nfunc.c:21
GSM_Error GSM_WaitFor(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type, int timeout, GSM_Phone_RequestID request)
Definition: gsmstate.c:1029
GSM_Error N71_65_GetNextCalendar1(GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos)
GSM_Error N71_65_DecodePhonebook(GSM_StateMachine *s, GSM_MemoryEntry *entry, GSM_Bitmap *bitmap, GSM_SpeedDial *speed, unsigned char *MessageBuffer, int MessageLength, gboolean DayMonthReverse)
Definition: nfunc.c:364
#define NOTIMPLEMENTED
Definition: gsmcomon.h:13
GSM_Error N71_65_ReplyGetCalendarInfo1(GSM_Protocol_Message *msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *LastCalendar)
GSM_Phone_Data Data
Definition: gsmstate.h:1369
GSM_Error DCT3DCT4_ReplyGetModelFirmware(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_MemoryType MemoryType
Definition: gammu-memory.h:131
GSM_Error N71_65_ReplyGetMemoryError(unsigned char error, GSM_StateMachine *s)
GSM_Error NOKIA_GetManufacturer(GSM_StateMachine *s)
#define TRUE
Definition: gammu-types.h:28
GSM_MemoryStatus * MemoryStatus
Definition: gsmstate.h:501
void NOKIA_DecodeDateTime(GSM_StateMachine *s, unsigned char *buffer, GSM_DateTime *datetime, gboolean seconds, gboolean DayMonthReverse)
Definition: nfunc.c:976
unsigned char * Buffer
Definition: protocol.h:22
GSM_SpeedDial * SpeedDial
Definition: gsmstate.h:485
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261