summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/at/sonyeric.c
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/phone/at/sonyeric.c
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/phone/at/sonyeric.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c141
1 files changed, 125 insertions, 16 deletions
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 4b2670a..8eeb39b 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -11,17 +11,15 @@
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13 13
14 extern GSM_Reply_Function ATGENReplyFunctions[]; 14#include "atgen.h"
15 extern GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s); 15#include "sonyeric.h"
16 16
17#ifdef GSM_ENABLE_OBEXGEN 17#ifdef GSM_ENABLE_OBEXGEN
18 18
19 extern GSM_Reply_Function OBEXGENReplyFunctions[]; 19#include "../obex/obexgen.h"
20 extern GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File);
21 extern GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos);
22 extern GSM_Error OBEXGEN_Disconnect(GSM_StateMachine *s);
23 20
24#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 21 extern GSM_Reply_FunctionOBEXGENReplyFunctions[];
22 extern GSM_Reply_FunctionATGENReplyFunctions[];
25 23
26static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) 24static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
27{ 25{
@@ -126,7 +124,7 @@ static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName,
126 124
127GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 125GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
128{ 126{
129#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 127#ifdef GSM_ENABLE_OBEXGEN
130 GSM_Error error; 128 GSM_Error error;
131 GSM_ToDoEntry ToDo; 129 GSM_ToDoEntry ToDo;
132 int Pos, num, Loc; 130 int Pos, num, Loc;
@@ -162,7 +160,7 @@ GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
162 160
163GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 161GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
164{ 162{
165#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 163#ifdef GSM_ENABLE_OBEXGEN
166 GSM_Error error; 164 GSM_Error error;
167 GSM_CalendarEntryCalendar; 165 GSM_CalendarEntryCalendar;
168 int Pos, num, Loc; 166 int Pos, num, Loc;
@@ -201,7 +199,7 @@ GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool st
201 199
202GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 200GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
203{ 201{
204#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 202#ifdef GSM_ENABLE_OBEXGEN
205 GSM_Error error; 203 GSM_Error error;
206 GSM_ToDoEntry ToDo; 204 GSM_ToDoEntry ToDo;
207 GSM_CalendarEntry Calendar; 205 GSM_CalendarEntry Calendar;
@@ -232,7 +230,7 @@ GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
232 230
233GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 231GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
234{ 232{
235#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 233#ifdef GSM_ENABLE_OBEXGEN
236 unsigned char req[5000]; 234 unsigned char req[5000];
237 int size=0; 235 int size=0;
238 236
@@ -248,7 +246,7 @@ GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
248 246
249GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 247GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
250{ 248{
251#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 249#ifdef GSM_ENABLE_OBEXGEN
252 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 250 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
253 unsigned char req[5000]; 251 unsigned char req[5000];
254 int size=0; 252 int size=0;
@@ -267,7 +265,7 @@ GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
267 265
268GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 266GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
269{ 267{
270#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 268#ifdef GSM_ENABLE_OBEXGEN
271 GSM_Error error; 269 GSM_Error error;
272 int Pos,Level = 0,Used; 270 int Pos,Level = 0,Used;
273 unsigned char *Buf; 271 unsigned char *Buf;
@@ -319,7 +317,7 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
319 317
320GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 318GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
321{ 319{
322#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 320#ifdef GSM_ENABLE_OBEXGEN
323 GSM_Error error; 321 GSM_Error error;
324 int Pos,Level = 0,Loc=0,Used; 322 int Pos,Level = 0,Loc=0,Used;
325 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 323 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
@@ -374,7 +372,7 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
374 372
375GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 373GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
376{ 374{
377#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 375#ifdef GSM_ENABLE_OBEXGEN
378 GSM_Error error; 376 GSM_Error error;
379 GSM_ToDoEntry ToDo; 377 GSM_ToDoEntry ToDo;
380 GSM_CalendarEntry Calendar; 378 GSM_CalendarEntry Calendar;
@@ -403,7 +401,118 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
403#endif 401#endif
404} 402}
405 403
406#endif 404GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
405 { /*Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar
406 License: Whatever the current maintainer of gammulib chooses, as long as there
407 is an easy way to obtain the source under GPL, otherwise the author's parts
408 of this function are GPL 2.0.
409 */
410 GSM_Locale*locale = s->Phone.Data.Locale;
411 char format;
412
413 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
414 case AT_Reply_OK:
415 smprintf(s, "Date settings received\n");
416 format=atoi(msg.Buffer);
417 switch (format) {
418 case 0: locale->DateFormat = GSM_Date_OFF;
419 locale->DateSeparator = 0;
420 break;
421 case 1: locale->DateFormat = GSM_Date_DDMMMYY;
422 locale->DateSeparator = '-';
423 break;
424 case 2: locale->DateFormat = GSM_Date_DDMMYY;
425 locale->DateSeparator = '-';
426 break;
427 case 3: locale->DateFormat = GSM_Date_MMDDYY;
428 locale->DateSeparator = '/';
429 break;
430 case 4: locale->DateFormat = GSM_Date_DDMMYY;
431 locale->DateSeparator = '/';
432 break;
433 case 5: locale->DateFormat = GSM_Date_DDMMYY;
434 locale->DateSeparator = '.';
435 break;
436 case 6: locale->DateFormat = GSM_Date_YYMMDD;
437 locale->DateSeparator = 0;
438 break;
439 case 7: locale->DateFormat = GSM_Date_YYMMDD;
440 locale->DateSeparator = '-';
441 break;
442 default:return ERR_UNKNOWNRESPONSE;
443 }
444 default:
445 return ERR_NOTSUPPORTED;
446 }
447}
448
449GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
450 { /*Author: Peter Ondraska
451 License: Whatever the current maintainer of gammulib chooses, as long as there
452 is an easy way to obtain the source under GPL, otherwise the author's parts
453 of this function are GPL 2.0.
454 */
455 char format;
456
457 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
458 case AT_Reply_OK:
459 smprintf(s, "Time settings received\n");
460 format=atoi(msg.Buffer);
461 switch (format) {
462 case 1:
463 case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
464 return ERR_NONE;
465 default:return ERR_UNKNOWNRESPONSE;
466 }
467 default: return ERR_NOTSUPPORTED;
468 }
469}
470
471GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
472{
473 GSM_Error error;
474
475 s->Phone.Data.Locale = locale;
476
477 smprintf(s, "Getting date format\n");
478 error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
479 if (error!=ERR_NONE) return error;
480
481 smprintf(s, "Getting time format\n");
482 return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
483}
484
485
486GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
487 { /*Author: Peter Ondraska
488 License: Whatever the current maintainer of gammulib chooses, as long as there
489 is an easy way to obtain the source under GPL, otherwise the author's parts
490 of this function are GPL 2.0.
491 */
492 /* this is not yet supported by gammu.c */
493 intformat=0;
494 charreq[12];
495
496 if (locale->DateFormat==GSM_Date_OFF) { format=0; } else
497 if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else
498 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
499 if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else
500 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else
501 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else
502 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
503 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
504 else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
505
506 sprintf(req,"AT+ESDF=%i\r",format);
507 smprintf(s, "Setting date format\n");
508 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
509
510 if (locale->AMPMTime) { format=2; } else { format=1; }
511 sprintf(req,"AT+ESTF=%i\r",format);
512 smprintf(s, "Setting time format\n");
513 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
514}
515
407#endif 516#endif
408 517
409/* How should editor hadle tabs in this file? Add editor commands here. 518/* How should editor hadle tabs in this file? Add editor commands here.