summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/at
Side-by-side diff
Diffstat (limited to 'gammu/emb/common/phone/at') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/phone/at/atgen.c8
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c19
2 files changed, 17 insertions, 10 deletions
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index ba23eb2..a875f0a 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -651,97 +651,97 @@ GSM_Error ATGEN_Initialise(GSM_StateMachine *s)
if (s->ConnectionType != GCT_IRDAAT && s->ConnectionType != GCT_BLUEAT) {
/* We try to escape AT+CMGS mode, at least Siemens M20
* then needs to get some rest
*/
smprintf(s, "Escaping SMS mode\n");
error = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00);
if (error!=ERR_NONE) return error;
/* Grab any possible garbage */
while (s->Device.Functions->ReadDevice(s, buff, 2) > 0) my_sleep(10);
}
/* When some phones (Alcatel BE5) is first time connected, it needs extra
* time to react, sending just AT wakes up the phone and it then can react
* to ATE1. We don't need to check whether this fails as it is just to
* wake up the phone and does nothing.
*/
smprintf(s, "Sending simple AT command to wake up some devices\n");
GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame);
smprintf(s, "Enabling echo\n");
error = GSM_WaitFor (s, "ATE1\r", 5, 0x00, 3, ID_EnableEcho);
if (error != ERR_NONE) return error;
smprintf(s, "Enabling CME errors\n");
/* Try numeric errors */
if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
/* Try textual errors */
if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n");
}
}
error = ATGEN_GetModel(s);
if (error != ERR_NONE) return error;
if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) {
s->Protocol.Data.AT.FastWrite = true;
}
return error;
}
GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
{
unsigned char req[50];
- if (smsc->Location!=1) return ERR_NOTSUPPORTED;
+ if (smsc->Location!=1) return ERR_INVALIDLOCATION;
sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number));
smprintf(s, "Setting SMSC\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC);
}
GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
/* Reply here is:
* (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
* each memory is in quotes,
* Example: ("SM"), ("SM"), ("SM")
*
* We need to get from this supported memories. For this case
* we assume, that just appearence of memory makes it
* available for everything. Then we need to find out whether
* phone supports writing to memory. This is done by searching
* for "), (", which will appear between lists.
*/
s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
}
if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE;
else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE;
else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
smprintf(s, "\n");
return ERR_NONE;
case AT_Reply_Error:
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
case AT_Reply_CMEError:
return ATGEN_HandleCMEError(s);
default:
return ERR_UNKNOWNRESPONSE;
}
}
GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s)
@@ -3794,69 +3794,75 @@ GSM_Phone_Functions ATGENPhone = {
ATGEN_AnswerCall,
ATGEN_CancelCall,
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NONEFUNCTION, /* SetIncomingCall */
ATGEN_SetIncomingUSSD,
ATGEN_SendDTMF,
ATGEN_GetRingtone,
ATGEN_SetRingtone,
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
ATGEN_GetBitmap, /* GetBitmap */
ATGEN_SetBitmap, /* SetBitmap */
SONYERIC_GetToDoStatus,
NOTSUPPORTED, /* GetToDo */
SONYERIC_GetNextToDo,
NOTSUPPORTED, /* SetToDo */
SONYERIC_AddToDo,
NOTSUPPORTED, /* DeleteToDo */
SONYERIC_DeleteAllToDo,
SONYERIC_GetCalendarStatus,
NOTIMPLEMENTED, /* GetCalendar */
ATGEN_GetNextCalendar,
NOTIMPLEMENTED, /* SetCalendar */
ATGEN_AddCalendarNote,
ATGEN_DelCalendarNote,
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
+ NOTSUPPORTED, /* GetNoteStatus */
+ NOTSUPPORTED, /* GetNote */
NOTSUPPORTED, /* GetNextNote */
+ NOTSUPPORTED, /* SetNote */
+ NOTSUPPORTED, /* AddNote */
+ NOTSUPPORTED, /* DeleteNote */
+ NOTSUPPORTED, /* DeleteAllNotes */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFile */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 8eeb39b..363e043 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -1,68 +1,69 @@
/* (c) 2003 by Marcin Wiacek */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_ATGEN
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "../../gsmcomon.h"
#include "../../misc/coding/coding.h"
#include "atgen.h"
#include "sonyeric.h"
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
#include "../obex/obexgen.h"
+extern GSM_Protocol_Functions OBEXProtocol;
extern GSM_Reply_Function OBEXGENReplyFunctions[];
extern GSM_Reply_Function ATGENReplyFunctions[];
static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
if (Priv->OBEX) return ERR_NONE;
dbgprintf ("Changing to OBEX\n");
error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
if (error != ERR_NONE) return error;
error = s->Protocol.Functions->Terminate(s);
if (error != ERR_NONE) return error;
s->Protocol.Functions = &OBEXProtocol;
error = s->Protocol.Functions->Initialise(s);
if (error != ERR_NONE) {
s->Protocol.Functions = &ATProtocol;
return error;
}
strcpy(s->CurrentConfig->Model,"seobex");
s->Phone.Data.Priv.OBEXGEN.Service = 0;
s->Phone.Functions->DispatchMessage = GSM_DispatchMessage;
s->Phone.Functions->ReplyFunctions = OBEXGENReplyFunctions;
Priv->OBEX = true;
return ERR_NONE;
}
static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
if (!Priv->OBEX) return ERR_NONE;
dbgprintf ("Changing to AT\n");
error = OBEXGEN_Disconnect(s);
if (error != ERR_NONE) return error;
error = s->Protocol.Functions->Terminate(s);
if (error != ERR_NONE) return error;
s->Protocol.Functions = &ATProtocol;
@@ -79,345 +80,345 @@ static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
}
static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName)
{
GSM_Error error;
strcpy(File->ID_FullName,FileName);
File->Used = 0;
if (File->Buffer != NULL) free(File->Buffer);
File->Buffer = NULL;
error = SONYERIC_SetOBEXMode(s);
if (error != ERR_NONE) return error;
error = ERR_NONE;
while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File);
if (error != ERR_EMPTY) return error;
return SONYERIC_SetATMode(s);
}
static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length)
{
GSM_Error error;
GSM_File File;
int Pos = 0;
error = SONYERIC_SetOBEXMode(s);
if (error != ERR_NONE) return error;
strcpy(File.ID_FullName,FileName);
EncodeUnicode(File.Name,FileName,strlen(FileName));
File.Used = Length;
File.Buffer = malloc(Length);
memcpy(File.Buffer,Buffer,Length);
error = ERR_NONE;
while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
free(File.Buffer);
if (error != ERR_EMPTY) return error;
return SONYERIC_SetATMode(s);
}
#endif
GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
GSM_ToDoEntry ToDo;
int Pos, num, Loc;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (start) {
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Note->Location = 1;
} else {
Note->Location++;
}
smprintf(s, "Getting calendar note %i\n",Note->Location);
Loc = Note->Location;
Pos = 0;
num = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (Note->EntriesNum != 0) {
num++;
if (num == Loc) return ERR_NONE;
}
}
return ERR_EMPTY;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
GSM_CalendarEntry Calendar;
int Pos, num, Loc;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
if (start) {
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
ToDo->Location = 1;
} else {
ToDo->Location++;
}
smprintf(s,"Getting ToDo %i\n",ToDo->Location);
Loc = ToDo->Location;
Pos = 0;
num = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (ToDo->EntriesNum != 0) {
num++;
if (num == Loc) return ERR_NONE;
}
}
return ERR_EMPTY;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
GSM_ToDoEntry ToDo;
GSM_CalendarEntry Calendar;
int Pos;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Getting ToDo status\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
status->Used = 0;
Pos = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (ToDo.EntriesNum != 0) status->Used++;
}
return ERR_NONE;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
unsigned char req[5000];
int size=0;
smprintf(s,"Adding calendar note\n");
GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char req[5000];
int size=0;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Adding ToDo\n");
GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
int Pos,Level = 0,Used;
unsigned char *Buf;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char Line[2000];
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Deleting all ToDo\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Pos = 0;
Buf = NULL;
Used = 0;
while (1) {
MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
if (strlen(Line) == 0) break;
dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
switch (Level) {
case 0:
if (strstr(Line,"BEGIN:VTODO")) {
Level = 2;
break;
}
Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
strcpy(Buf+Used,Line);
Used=Used+strlen(Line)+3;
Buf[Used-3] = 13;
Buf[Used-2] = 10;
Buf[Used-1] = 0x00;
break;
case 2: /* ToDo note */
if (strstr(Line,"END:VTODO")) {
Level = 0;
}
break;
}
}
error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
// if (Buf != NULL) free(Buf);
return error;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
int Pos,Level = 0,Loc=0,Used;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char Line[2000];
unsigned char *Buf;
smprintf(s, "Deleting calendar note %i\n",Note->Location);
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Pos = 0;
Buf = NULL;
Used = 0;
while (1) {
MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
if (strlen(Line) == 0) break;
dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
switch (Level) {
case 0:
if (strstr(Line,"BEGIN:VEVENT")) {
Loc++;
if (Loc == Note->Location) {
Level = 1;
break;
}
}
Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
strcpy(Buf+Used,Line);
Used=Used+strlen(Line)+3;
Buf[Used-3] = 13;
Buf[Used-2] = 10;
Buf[Used-1] = 0x00;
break;
case 1: /* Calendar note */
if (strstr(Line,"END:VEVENT")) {
Level = 0;
}
break;
}
}
DumpMessage(s->di.df, s->di.dl, Buf, Used);
error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
if (Buf != NULL) free(Buf);
return error;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
{
-#ifdef GSM_ENABLE_OBEXGEN
+#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
GSM_Error error;
GSM_ToDoEntry ToDo;
GSM_CalendarEntry Calendar;
int Pos;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s, "Getting calendar status\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Status->Used = 0;
Pos = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (Calendar.EntriesNum != 0) Status->Used++;
}
return ERR_NONE;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
{ /* Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar
License: Whatever the current maintainer of gammulib chooses, as long as there
is an easy way to obtain the source under GPL, otherwise the author's parts
of this function are GPL 2.0.
*/
GSM_Locale *locale = s->Phone.Data.Locale;
char format;
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
smprintf(s, "Date settings received\n");
format=atoi(msg.Buffer);
switch (format) {
case 0: locale->DateFormat = GSM_Date_OFF;
locale->DateSeparator = 0;
break;
case 1: locale->DateFormat = GSM_Date_DDMMMYY;
locale->DateSeparator = '-';
break;