Diffstat (limited to 'gammu/emb/common/phone/at/siemens.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/phone/at/siemens.c | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/gammu/emb/common/phone/at/siemens.c b/gammu/emb/common/phone/at/siemens.c index ab7dd2c..7f66cf8 100644 --- a/gammu/emb/common/phone/at/siemens.c +++ b/gammu/emb/common/phone/at/siemens.c | |||
@@ -1,310 +1,306 @@ | |||
1 | /* (c) 2002-2003 by Walek */ | 1 | /* (c) 2002-2003 by Walek */ |
2 | 2 | ||
3 | #include "../../gsmstate.h" | 3 | #include "../../gsmstate.h" |
4 | 4 | ||
5 | #ifdef GSM_ENABLE_ATGEN | 5 | #ifdef GSM_ENABLE_ATGEN |
6 | 6 | ||
7 | #include <string.h> | 7 | #include <string.h> |
8 | #include <time.h> | 8 | #include <time.h> |
9 | #include <ctype.h> | 9 | #include <ctype.h> |
10 | 10 | ||
11 | #include "../../misc/coding/coding.h" | 11 | #include "../../misc/coding/coding.h" |
12 | #include "../../gsmcomon.h" | 12 | #include "../../gsmcomon.h" |
13 | #include "../../service/sms/gsmsms.h" | 13 | #include "../../service/sms/gsmsms.h" |
14 | #include "../pfunc.h" | 14 | #include "../pfunc.h" |
15 | 15 | ||
16 | extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s); | 16 | #include "atgen.h" |
17 | #include "siemens.h" | ||
17 | 18 | ||
18 | GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function) | ||
19 | { | ||
20 | if (s->Protocol.Data.AT.EditMode) { | ||
21 | s->Protocol.Data.AT.EditMode = false; | ||
22 | return ERR_NONE; | ||
23 | } | ||
24 | dbgprintf ("Written %s",function); | ||
25 | if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){ | ||
26 | dbgprintf (" - OK\n"); | ||
27 | return ERR_NONE; | ||
28 | } else { | ||
29 | dbgprintf (" - error\n"); | ||
30 | return ERR_UNKNOWN; | ||
31 | } | ||
32 | } | ||
33 | 19 | ||
34 | GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, | 20 | static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, |
35 | unsigned char *buffer, int *len) | 21 | unsigned char *buffer, int *len) |
36 | { | 22 | { |
37 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; | 23 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; |
38 | int i=2, pos=0, length=0; | 24 | int i=2, pos=0, length=0; |
39 | unsigned char buf[512]; | 25 | unsigned char buf[512]; |
40 | 26 | ||
41 | if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY; | 27 | if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY; |
42 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN; | 28 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN; |
43 | 29 | ||
44 | while (1) { | 30 | while (1) { |
45 | if (Priv->Lines.numbers[i*2+1]==0) break; | 31 | if (Priv->Lines.numbers[i*2+1]==0) break; |
46 | if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) && | 32 | if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) && |
47 | (strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){ | 33 | (strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){ |
48 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)); | 34 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)); |
49 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length); | 35 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length); |
50 | length = length/2; | 36 | length = length/2; |
51 | memcpy (buffer+pos,buf,length); | 37 | memcpy (buffer+pos,buf,length); |
52 | pos+=length; | 38 | pos+=length; |
53 | } | 39 | } |
54 | i++; | 40 | i++; |
55 | } | 41 | } |
56 | *len = pos; | 42 | *len = pos; |
57 | return ERR_NONE; | 43 | return ERR_NONE; |
58 | } | 44 | } |
59 | 45 | ||
60 | GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, | 46 | static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, |
61 | int Location, GSM_Phone_RequestID RequestID, int len) | 47 | int Location, GSM_Phone_RequestID RequestID, int len) |
62 | { | 48 | { |
63 | GSM_Phone_Data *Phone = &s->Phone.Data; | 49 | GSM_Phone_Data *Phone = &s->Phone.Data; |
64 | GSM_Error error; | 50 | GSM_Error error; |
65 | unsigned char req[20],req1[512],hexreq[2096]; | 51 | unsigned char req[20],req1[512],hexreq[2096]; |
66 | int MaxFrame,CurrentFrame,size,sz,pos=0; | 52 | int MaxFrame,CurrentFrame,size,sz,pos=0; |
67 | 53 | ||
68 | EncodeHexBin(hexreq,buff,len); | 54 | EncodeHexBin(hexreq,buff,len); |
69 | size = len * 2; | 55 | size = len * 2; |
70 | MaxFrame = size / 352; | 56 | MaxFrame = size / 352; |
71 | if (size % 352) MaxFrame++; | 57 | if (size % 352) MaxFrame++; |
72 | 58 | ||
73 | for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) { | 59 | for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) { |
74 | pos=CurrentFrame*352; | 60 | pos=CurrentFrame*352; |
75 | if (pos+352 < size) sz = 352; else sz = size - pos; | 61 | if (pos+352 < size) sz = 352; else sz = size - pos; |
76 | sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame); | 62 | sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame); |
77 | s->Protocol.Data.AT.EditMode = true; | 63 | s->Protocol.Data.AT.EditMode = true; |
78 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID); | 64 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID); |
79 | s->Phone.Data.DispatchError=ERR_TIMEOUT; | 65 | s->Phone.Data.DispatchError=ERR_TIMEOUT; |
80 | s->Phone.Data.RequestID=RequestID; | 66 | s->Phone.Data.RequestID=RequestID; |
81 | if (error!=ERR_NONE) return error; | 67 | if (error!=ERR_NONE) return error; |
82 | memcpy (req1,hexreq+pos,sz); | 68 | memcpy (req1,hexreq+pos,sz); |
83 | error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00); | 69 | error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00); |
84 | if (error!=ERR_NONE) return error; | 70 | if (error!=ERR_NONE) return error; |
85 | error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00); | 71 | error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00); |
86 | if (error!=ERR_NONE) return error; | 72 | if (error!=ERR_NONE) return error; |
87 | error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); | 73 | error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); |
88 | if (error == ERR_TIMEOUT) return error; | 74 | if (error == ERR_TIMEOUT) return error; |
89 | } | 75 | } |
90 | return Phone->DispatchError; | 76 | return Phone->DispatchError; |
91 | } | 77 | } |
92 | 78 | ||
93 | GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) | 79 | GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) |
94 | { | 80 | { |
95 | unsigned char buffer[4096]; | 81 | unsigned char buffer[4096]; |
96 | int length; | 82 | int length; |
97 | GSM_Error error; | 83 | GSM_Error error; |
98 | 84 | ||
99 | error = GetSiemensFrame(msg,s,"bmp",buffer,&length); | 85 | error = GetSiemensFrame(msg,s,"bmp",buffer,&length); |
100 | if (error!=ERR_NONE) return error; | 86 | if (error!=ERR_NONE) return error; |
101 | dbgprintf ("Operator logo received lenght=%i\n",length); | 87 | dbgprintf ("Operator logo received lenght=%i\n",length); |
102 | error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap); | 88 | error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap); |
103 | if (error==ERR_NONE) return error; | 89 | if (error==ERR_NONE) return error; |
104 | else return ERR_UNKNOWN; | 90 | else return ERR_UNKNOWN; |
105 | } | 91 | } |
106 | 92 | ||
107 | GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) | 93 | GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function) |
108 | { | 94 | { |
109 | return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo"); | 95 | if (s->Protocol.Data.AT.EditMode) { |
96 | s->Protocol.Data.AT.EditMode = false; | ||
97 | return ERR_NONE; | ||
98 | } | ||
99 | dbgprintf ("Written %s",function); | ||
100 | if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){ | ||
101 | dbgprintf (" - OK\n"); | ||
102 | return ERR_NONE; | ||
103 | } else { | ||
104 | dbgprintf (" - error\n"); | ||
105 | return ERR_UNKNOWN; | ||
106 | } | ||
110 | } | 107 | } |
111 | 108 | ||
112 | GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) | 109 | GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) |
110 | { | ||
111 | return SIEMENS_ReplySetFunction (msg, s, "Operator Logo"); | ||
112 | } | ||
113 | |||
114 | GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) | ||
113 | { | 115 | { |
114 | unsigned char req[32]; | 116 | unsigned char req[32]; |
115 | 117 | ||
116 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | ||
117 | if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; | 118 | if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; |
118 | if (Bitmap->Location-1 < 0) Bitmap->Location++; | 119 | if (Bitmap->Location-1 < 0) Bitmap->Location++; |
119 | s->Phone.Data.Bitmap=Bitmap; | 120 | s->Phone.Data.Bitmap=Bitmap; |
120 | sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1); | 121 | sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1); |
121 | smprintf(s, "Getting Bitmap\n"); | 122 | smprintf(s, "Getting Bitmap\n"); |
122 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); | 123 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); |
123 | } | 124 | } |
124 | 125 | ||
125 | GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) | 126 | GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) |
126 | { | 127 | { |
127 | unsigned char buffer[4096]; | 128 | unsigned char buffer[4096]; |
128 | int length; | 129 | int length; |
129 | GSM_Errorerror; | 130 | GSM_Errorerror; |
130 | 131 | ||
131 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | ||
132 | if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; | 132 | if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; |
133 | 133 | ||
134 | error = Bitmap2BMP (buffer,NULL,Bitmap); | 134 | error = Bitmap2BMP (buffer,NULL,Bitmap); |
135 | if (error!=ERR_NONE) return error; | 135 | if (error!=ERR_NONE) return error; |
136 | length = 0x100 * buffer[3] + buffer[2]; | 136 | length = 0x100 * buffer[3] + buffer[2]; |
137 | buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff; | 137 | buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff; |
138 | if (Bitmap->Location-1 < 0) Bitmap->Location++; | 138 | if (Bitmap->Location-1 < 0) Bitmap->Location++; |
139 | s->Phone.Data.Bitmap=Bitmap; | 139 | s->Phone.Data.Bitmap=Bitmap; |
140 | return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1, | 140 | return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1, |
141 | ID_SetBitmap,length); | 141 | ID_SetBitmap,length); |
142 | } | 142 | } |
143 | 143 | ||
144 | GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) | 144 | GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) |
145 | { | 145 | { |
146 | unsigned char buffer[32]; | 146 | unsigned char buffer[32]; |
147 | int length; | 147 | int length; |
148 | GSM_Error error; | 148 | GSM_Error error; |
149 | 149 | ||
150 | error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length); | 150 | error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length); |
151 | if (error!=ERR_NONE) return error; | 151 | if (error!=ERR_NONE) return error; |
152 | dbgprintf ("Midi ringtone received\n"); | 152 | dbgprintf ("Midi ringtone received\n"); |
153 | 153 | ||
154 | s->Phone.Data.Ringtone->Format = RING_MIDI; | 154 | s->Phone.Data.Ringtone->Format = RING_MIDI; |
155 | s->Phone.Data.Ringtone->NokiaBinary.Length= length; | 155 | s->Phone.Data.Ringtone->NokiaBinary.Length= length; |
156 | sprintf(buffer,"Individual"); | 156 | sprintf(buffer,"Individual"); |
157 | EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); | 157 | EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); |
158 | return ERR_NONE; | 158 | return ERR_NONE; |
159 | } | 159 | } |
160 | 160 | ||
161 | GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) | 161 | GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) |
162 | { | 162 | { |
163 | unsigned char req[32]; | 163 | unsigned char req[32]; |
164 | 164 | ||
165 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | ||
166 | |||
167 | s->Phone.Data.Ringtone=Ringtone; | 165 | s->Phone.Data.Ringtone=Ringtone; |
168 | sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1); | 166 | sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1); |
169 | smprintf(s, "Getting RingTone\n"); | 167 | smprintf(s, "Getting RingTone\n"); |
170 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); | 168 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); |
171 | } | 169 | } |
172 | 170 | ||
173 | GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) | 171 | GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) |
174 | { | 172 | { |
175 | return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone"); | 173 | return SIEMENS_ReplySetFunction (msg, s, "Ringtone"); |
176 | } | 174 | } |
177 | 175 | ||
178 | GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) | 176 | GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) |
179 | { | 177 | { |
180 | GSM_Phone_Data *Phone = &s->Phone.Data; | 178 | GSM_Phone_Data *Phone = &s->Phone.Data; |
181 | 179 | ||
182 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | ||
183 | |||
184 | if (Ringtone->Location==255) Ringtone->Location=1; | 180 | if (Ringtone->Location==255) Ringtone->Location=1; |
185 | if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION; | 181 | if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION; |
186 | 182 | ||
187 | s->Phone.Data.Ringtone= Ringtone; | 183 | s->Phone.Data.Ringtone= Ringtone; |
188 | Phone->Ringtone = Ringtone; | 184 | Phone->Ringtone = Ringtone; |
189 | return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1, | 185 | return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1, |
190 | ID_SetRingtone,Ringtone->NokiaBinary.Length); | 186 | ID_SetRingtone,Ringtone->NokiaBinary.Length); |
191 | } | 187 | } |
192 | 188 | ||
193 | GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s) | 189 | GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) |
194 | { | 190 | { |
195 | GSM_Phone_Data *Data = &s->Phone.Data; | 191 | GSM_Phone_Data *Data = &s->Phone.Data; |
196 | GSM_CalendarEntry*Calendar = Data->Cal; | 192 | GSM_CalendarEntry*Calendar = Data->Cal; |
197 | GSM_ToDoEntry ToDo; | 193 | GSM_ToDoEntry ToDo; |
198 | GSM_Error error; | 194 | GSM_Error error; |
199 | unsigned char buffer[354]; | 195 | unsigned char buffer[354]; |
200 | int len, pos=0; | 196 | int len, pos=0; |
201 | 197 | ||
202 | if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN; | 198 | if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN; |
203 | 199 | ||
204 | error = GetSiemensFrame(msg,s,"vcs",buffer,&len); | 200 | error = GetSiemensFrame(msg,s,"vcs",buffer,&len); |
205 | if (error!=ERR_NONE) return error; | 201 | if (error!=ERR_NONE) return error; |
206 | error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0); | 202 | error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0); |
207 | 203 | ||
208 | return error; | 204 | return error; |
209 | } | 205 | } |
210 | 206 | ||
211 | GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) | 207 | GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) |
212 | { | 208 | { |
213 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 209 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
214 | GSM_Error error; | 210 | GSM_Error error; |
215 | unsigned char req[32]; | 211 | unsigned char req[32]; |
216 | int Location; | 212 | int Location; |
217 | 213 | ||
218 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 214 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
219 | 215 | ||
220 | if (start) Note->Location=Priv->FirstCalendarPos; | 216 | if (start) Note->Location=Priv->FirstCalendarPos; |
221 | s->Phone.Data.Cal = Note; | 217 | s->Phone.Data.Cal = Note; |
222 | Note->EntriesNum = 0; | 218 | Note->EntriesNum = 0; |
223 | smprintf(s, "Getting VCALENDAR\n"); | 219 | smprintf(s, "Getting VCALENDAR\n"); |
224 | Location = Note->Location; | 220 | Location = Note->Location; |
225 | while (1){ | 221 | while (1){ |
226 | Location++; | 222 | Location++; |
227 | sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location); | 223 | sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location); |
228 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote); | 224 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote); |
229 | if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION; | 225 | if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION; |
230 | Note->Location = Location; | 226 | Note->Location = Location; |
231 | Priv->FirstCalendarPos = Location; | 227 | Priv->FirstCalendarPos = Location; |
232 | if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY; | 228 | if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY; |
233 | if (error==ERR_NONE) return error; | 229 | if (error==ERR_NONE) return error; |
234 | } | 230 | } |
235 | return error; | 231 | return error; |
236 | } | 232 | } |
237 | 233 | ||
238 | GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) | 234 | GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s) |
239 | { | 235 | { |
240 | return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note"); | 236 | return SIEMENS_ReplySetFunction (msg, s, "Calendar Note"); |
241 | } | 237 | } |
242 | 238 | ||
243 | GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) | 239 | GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s) |
244 | { | 240 | { |
245 | GSM_Phone_Data *Data = &s->Phone.Data; | 241 | GSM_Phone_Data *Data = &s->Phone.Data; |
246 | 242 | ||
247 | if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN; | 243 | if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN; |
248 | 244 | ||
249 | if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) { | 245 | if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) { |
250 | smprintf(s, "Calendar note deleted\n"); | 246 | smprintf(s, "Calendar note deleted\n"); |
251 | return ERR_NONE; | 247 | return ERR_NONE; |
252 | } else { | 248 | } else { |
253 | smprintf(s, "Can't delete calendar note\n"); | 249 | smprintf(s, "Can't delete calendar note\n"); |
254 | return ERR_UNKNOWN; | 250 | return ERR_UNKNOWN; |
255 | } | 251 | } |
256 | } | 252 | } |
257 | 253 | ||
258 | GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 254 | GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
259 | { | 255 | { |
260 | unsigned char req[32]; | 256 | unsigned char req[32]; |
261 | 257 | ||
262 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 258 | if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
263 | s->Phone.Data.Cal = Note; | 259 | s->Phone.Data.Cal = Note; |
264 | sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location); | 260 | sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location); |
265 | smprintf(s, "Deleting calendar note\n"); | 261 | smprintf(s, "Deleting calendar note\n"); |
266 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote); | 262 | return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote); |
267 | } | 263 | } |
268 | 264 | ||
269 | GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 265 | GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
270 | { | 266 | { |
271 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 267 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
272 | GSM_Error error; | 268 | GSM_Error error; |
273 | unsigned char req[500]; | 269 | unsigned char req[500]; |
274 | int size=0; | 270 | int size=0; |
275 | 271 | ||
276 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 272 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
277 | // if (Note->Location==0x00) return ERR_INVALIDLOCATION; | 273 | // if (Note->Location==0x00) return ERR_INVALIDLOCATION; |
278 | 274 | ||
279 | s->Phone.Data.Cal = Note; | 275 | s->Phone.Data.Cal = Note; |
280 | error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar); | 276 | error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar); |
281 | 277 | ||
282 | return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size); | 278 | return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size); |
283 | } | 279 | } |
284 | 280 | ||
285 | /* (c) by Timo Teras */ | 281 | /* (c) by Timo Teras */ |
286 | GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) | 282 | GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) |
287 | { | 283 | { |
288 | #ifndef ENABLE_LGPL | 284 | #ifndef ENABLE_LGPL |
289 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; | 285 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; |
290 | GSM_MemoryEntry *Memory = s->Phone.Data.Memory; | 286 | GSM_MemoryEntry *Memory = s->Phone.Data.Memory; |
291 | unsigned char buffer[500],buffer2[500]; | 287 | unsigned char buffer[500],buffer2[500]; |
292 | 288 | ||
293 | switch (Priv->ReplyState) { | 289 | switch (Priv->ReplyState) { |
294 | case AT_Reply_OK: | 290 | case AT_Reply_OK: |
295 | smprintf(s, "Phonebook entry received\n"); | 291 | smprintf(s, "Phonebook entry received\n"); |
296 | CopyLineString(buffer, msg.Buffer, Priv->Lines, 3); | 292 | CopyLineString(buffer, msg.Buffer, Priv->Lines, 3); |
297 | DecodeHexBin(buffer2,buffer,strlen(buffer)); | 293 | DecodeHexBin(buffer2,buffer,strlen(buffer)); |
298 | Memory->EntriesNum = 0; | 294 | Memory->EntriesNum = 0; |
299 | DecodeVCARD21Text(buffer2, Memory); | 295 | DecodeVCARD21Text(buffer2, Memory); |
300 | if (Memory->EntriesNum == 0) return ERR_EMPTY; | 296 | if (Memory->EntriesNum == 0) return ERR_EMPTY; |
301 | return ERR_NONE; | 297 | return ERR_NONE; |
302 | case AT_Reply_Error: | 298 | case AT_Reply_Error: |
303 | smprintf(s, "Error - too high location ?\n"); | 299 | smprintf(s, "Error - too high location ?\n"); |
304 | return ERR_INVALIDLOCATION; | 300 | return ERR_INVALIDLOCATION; |
305 | case AT_Reply_CMSError: | 301 | case AT_Reply_CMSError: |
306 | return ATGEN_HandleCMSError(s); | 302 | return ATGEN_HandleCMSError(s); |
307 | default: | 303 | default: |
308 | break; | 304 | break; |
309 | } | 305 | } |
310 | return ERR_UNKNOWNRESPONSE; | 306 | return ERR_UNKNOWNRESPONSE; |