summaryrefslogtreecommitdiffabout
path: root/gammu/emb
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (side-by-side diff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/cfg/config.h2
-rw-r--r--gammu/emb/common/common.pro1
-rw-r--r--gammu/emb/common/commonE.pro1
-rw-r--r--gammu/emb/common/device/bluetoth/bluez.c29
-rw-r--r--gammu/emb/common/device/devfunc.c12
-rw-r--r--gammu/emb/common/device/irda/irda.c8
-rw-r--r--gammu/emb/common/device/irda/irda_unx.h2
-rw-r--r--gammu/emb/common/device/serial/ser_djg.c10
-rw-r--r--gammu/emb/common/device/serial/ser_unx.c38
-rw-r--r--gammu/emb/common/device/serial/ser_w32.c6
-rw-r--r--gammu/emb/common/gsmcomon.c21
-rw-r--r--gammu/emb/common/gsmcomon.h3
-rw-r--r--gammu/emb/common/gsmstate.c74
-rw-r--r--gammu/emb/common/gsmstate.h31
-rw-r--r--gammu/emb/common/misc/coding/coding.c177
-rw-r--r--gammu/emb/common/misc/coding/coding.h27
-rw-r--r--gammu/emb/common/misc/coding/md5.c2
-rw-r--r--gammu/emb/common/misc/misc.c19
-rw-r--r--gammu/emb/common/misc/misc.h8
-rw-r--r--gammu/emb/common/phone/alcatel/alcatel.c298
-rw-r--r--gammu/emb/common/phone/at/atgen.c295
-rw-r--r--gammu/emb/common/phone/at/atgen.h8
-rw-r--r--gammu/emb/common/phone/at/samsung.c447
-rw-r--r--gammu/emb/common/phone/at/samsung.h16
-rw-r--r--gammu/emb/common/phone/at/siemens.c74
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c141
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.c16
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.h2
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.c17
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c9
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3320.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3650.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.c168
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.h2
-rw-r--r--gammu/emb/common/phone/nokia/nauto.c2
-rw-r--r--gammu/emb/common/phone/nokia/nfunc.c14
-rw-r--r--gammu/emb/common/phone/obex/obexgen.c3
-rw-r--r--gammu/emb/common/phone/obex/obexgen.h4
-rw-r--r--gammu/emb/common/phone/symbian/mroutgen.c3
-rw-r--r--gammu/emb/common/protocol/at/at.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.h6
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.c2
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.h2
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.c5
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.h5
-rw-r--r--gammu/emb/common/service/backup/backgen.h4
-rw-r--r--gammu/emb/common/service/backup/backtext.c229
-rw-r--r--gammu/emb/common/service/backup/gsmback.c36
-rw-r--r--gammu/emb/common/service/backup/gsmback.h2
-rw-r--r--gammu/emb/common/service/gsmcal.h2
-rw-r--r--gammu/emb/common/service/gsmdata.c124
-rw-r--r--gammu/emb/common/service/gsmdata.h2
-rw-r--r--gammu/emb/common/service/gsmlogo.c47
-rw-r--r--gammu/emb/common/service/gsmlogo.h28
-rw-r--r--gammu/emb/common/service/gsmmisc.h7
-rw-r--r--gammu/emb/common/service/gsmring.c45
-rw-r--r--gammu/emb/common/service/gsmring.h8
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.c5
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.h11
-rw-r--r--gammu/emb/common/service/sms/gsmsms.c5
-rw-r--r--gammu/emb/common/service/sms/gsmsms.h5
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3.c6
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.c11
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.h13
-rw-r--r--gammu/emb/gammu/gammu.c662
-rw-r--r--gammu/emb/gammu/gammu.h8
-rw-r--r--gammu/emb/gammu/smsd/s_files.c81
-rw-r--r--gammu/emb/gammu/smsd/s_files.h2
-rw-r--r--gammu/emb/gammu/smsd/s_mysql.c608
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.c180
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.h37
73 files changed, 3208 insertions, 991 deletions
diff --git a/gammu/emb/cfg/config.h b/gammu/emb/cfg/config.h
index 1ba6365..62b4fcf 100644
--- a/gammu/emb/cfg/config.h
+++ b/gammu/emb/cfg/config.h
@@ -149,3 +149,3 @@
# define HAVE_SYS_IOCTL_H 1
-# define HAVE_MYSQL_MYSQL_H 1
+//LR # define HAVE_MYSQL_MYSQL_H 1
#endif
diff --git a/gammu/emb/common/common.pro b/gammu/emb/common/common.pro
index 0e719ee..797199b 100644
--- a/gammu/emb/common/common.pro
+++ b/gammu/emb/common/common.pro
@@ -158,2 +158,3 @@ phone/at/atgen.c \
phone/at/siemens.c \
+phone/at/samsung.c \
phone/at/sonyeric.c \
diff --git a/gammu/emb/common/commonE.pro b/gammu/emb/common/commonE.pro
index a36947b..f5b559d 100644
--- a/gammu/emb/common/commonE.pro
+++ b/gammu/emb/common/commonE.pro
@@ -159,2 +159,3 @@ phone/at/atgen.c \
phone/at/siemens.c \
+phone/at/samsung.c \
phone/at/sonyeric.c \
diff --git a/gammu/emb/common/device/bluetoth/bluez.c b/gammu/emb/common/device/bluetoth/bluez.c
index 8a4807e..e7e8adf 100644
--- a/gammu/emb/common/device/bluetoth/bluez.c
+++ b/gammu/emb/common/device/bluetoth/bluez.c
@@ -1,2 +1,11 @@
-/* Based on work by Marcel Holtmann and other authors of Bluez */
+/* Based on some work from Bluez (www.bluez.org)
+ * (C) 2000-2001 Qualcomm Incorporated
+ * (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
+ * (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
+ * GNU GPL version 2
+ */
+/* based on some Marcel Holtmann work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -83,3 +92,3 @@ static void print_service_desc(void *value, void *user)
case SDP_UUID128:
- proto = 1;//sdp_uuid_to_proto(&p->val.uuid);
+ proto = sdp_uuid_to_proto(&p->val.uuid);
break;
@@ -106,9 +115,9 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
sdp_session_t *sess;
- sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
- uint32_t range = 0x0000ffff;
- char str[20];
sdp_record_t *rec;
+ sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
sdp_data_t *d;
bdaddr_t interface;
+ uint32_t range = 0x0000ffff;
struct search_context subcontext;
+ char str[20];
int channel,channel2;
@@ -144,6 +153,6 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
- if (false) {
+ if (sdp_get_access_protos(rec,&proto) == 0) {
channel = -1;
sdp_list_foreach(proto,print_access_protos,&channel);
- //sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
+ sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
}
@@ -164,3 +173,3 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
free(seq);
- //sdp_record_free(rec);
+ sdp_record_free(rec);
}
@@ -170,3 +179,3 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
- return ERR_UNKNOWN;
+ return ERR_NOTSUPPORTED;
}
@@ -182,3 +191,3 @@ GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
memset(&context, '\0', sizeof(struct search_context));
- //sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
+ sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
diff --git a/gammu/emb/common/device/devfunc.c b/gammu/emb/common/device/devfunc.c
index d31ebbf..c58a01f 100644
--- a/gammu/emb/common/device/devfunc.c
+++ b/gammu/emb/common/device/devfunc.c
@@ -1 +1,9 @@
+/* Some source from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
+/* Some source from Minicom (http://alioth.debian.org/projects/minicom)
+ * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg
+ * GNU GPL version 2
+ */
@@ -107,3 +115,3 @@ GSM_Error lock_device(const char* port, char **lock_device)
{
-#ifndef WIN32
+#if !defined(WIN32) && !defined(DJGPP)
char *lock_file = NULL;
@@ -220,3 +228,3 @@ bool unlock_device(char **lock_file)
{
-#ifndef WIN32
+#if !defined(WIN32) && !defined(DJGPP)
int err;
diff --git a/gammu/emb/common/device/irda/irda.c b/gammu/emb/common/device/irda/irda.c
index fef50ac..e680377 100644
--- a/gammu/emb/common/device/irda/irda.c
+++ b/gammu/emb/common/device/irda/irda.c
@@ -1,4 +1,8 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Ralf Thelen and MyGnokii */
-/* based on some work from Gnokii and MSDN */
+/* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */
+/* based on some work from MSDN */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/device/irda/irda_unx.h b/gammu/emb/common/device/irda/irda_unx.h
index 8dbcb97..7a55273 100644
--- a/gammu/emb/common/device/irda/irda_unx.h
+++ b/gammu/emb/common/device/irda/irda_unx.h
@@ -1,2 +1,2 @@
-/* part of irda.h available in Linux kernel source */
+/* part of irda.h available in Linux kernel source (www.kernel.org) */
diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c
index ac9d7c8..2524187 100644
--- a/gammu/emb/common/device/serial/ser_djg.c
+++ b/gammu/emb/common/device/serial/ser_djg.c
@@ -13,3 +13,3 @@ static GSM_Error serial_close(GSM_StateMachine *s)
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
@@ -20,3 +20,3 @@ static GSM_Error serial_open (GSM_StateMachine *s)
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
@@ -27,3 +27,3 @@ static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
@@ -34,3 +34,3 @@ static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
@@ -41,3 +41,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
diff --git a/gammu/emb/common/device/serial/ser_unx.c b/gammu/emb/common/device/serial/ser_unx.c
index 2a87b11..69c7515 100644
--- a/gammu/emb/common/device/serial/ser_unx.c
+++ b/gammu/emb/common/device/serial/ser_unx.c
@@ -2,2 +2,6 @@
/* locking device and settings all speeds by Michal Cihar */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -18,2 +22,26 @@
+#ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+#endif
+
+#ifdef __NetBSD__
+# define FNONBLOCK O_NONBLOCK
+
+# define B57600 0010001
+# define B115200 0010002
+# define B230400 0010003
+# define B460800 0010004
+# define B500000 0010005
+# define B576000 0010006
+# define B921600 0010007
+# define B1000000 0010010
+# define B1152000 0010011
+# define B1500000 0010012
+# define B2000000 0010013
+# define B2500000 0010014
+# define B3000000 0010015
+# define B3500000 0010016
+# define B4000000 0010017
+#endif
+
static GSM_Error serial_close(GSM_StateMachine *s)
@@ -31,6 +59,2 @@ static GSM_Error serial_close(GSM_StateMachine *s)
-#ifndef O_NONBLOCK
-# define O_NONBLOCK 0
-#endif
-
static GSM_Error serial_open (GSM_StateMachine *s)
@@ -179,3 +203,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
struct termios t;
- int speed2 = B19200;
+ int speed2 = B19200;
@@ -204,2 +228,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
case 38400: speed2 = B38400; break;
+#ifdef B57600
case 57600: speed2 = B57600; break;
@@ -208,2 +233,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
case 460800: speed2 = B460800; break;
+#ifdef B500000
case 500000: speed2 = B500000; break;
@@ -219,2 +245,4 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
case 4000000: speed2 = B4000000; break;
+#endif
+#endif
}
diff --git a/gammu/emb/common/device/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c
index 9fa0135..7d88fc7 100644
--- a/gammu/emb/common/device/serial/ser_w32.c
+++ b/gammu/emb/common/device/serial/ser_w32.c
@@ -1,3 +1,7 @@
/* (c) 2002-2004 by Marcin Wiacek */
-/* based on some work from Gnokii, MSDN and others */
+/* based on some work from MSDN and others */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/gsmcomon.c b/gammu/emb/common/gsmcomon.c
index d094ef3..445c3a6 100644
--- a/gammu/emb/common/gsmcomon.c
+++ b/gammu/emb/common/gsmcomon.c
@@ -123,3 +123,3 @@ static PrintErrorEntry PrintErrorEntries[] = {
{ERR_DEVICELOCKED, "Error opening device. Device locked."},
- {ERR_DEVICENOTEXIST, "Error opening device. Not exist."},
+ {ERR_DEVICENOTEXIST, "Error opening device. Doesn't exist."},
{ERR_DEVICEBUSY, "Error opening device. Already opened by other application."},
@@ -131,4 +131,4 @@ static PrintErrorEntry PrintErrorEntries[] = {
{ERR_DEVICEWRITEERROR, "Error writing device."},
- {ERR_DEVICEREADERROR, "Error during reading device"},
- {ERR_DEVICEPARITYERROR, "Can't set parity on device"},
+ {ERR_DEVICEREADERROR, "Error during reading device."},
+ {ERR_DEVICEPARITYERROR, "Can't set parity on device."},
{ERR_TIMEOUT, "No response in specified timeout. Probably phone not connected."},
@@ -151,15 +151,16 @@ static PrintErrorEntry PrintErrorEntries[] = {
{ERR_PERMISSION, "Permission to file/device required..."},
- {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber"},
+ {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber."},
{ERR_INSIDEPHONEMENU, "You're inside phone menu (during editing ?). Leave it and try again."},
{ERR_WORKINPROGRESS, "Function is during writing. If want help, please contact with authors."},
- {ERR_PHONEOFF, "Phone is disabled and connected to charger"},
- {ERR_FILENOTSUPPORTED, "File format not supported by Gammu"},
+ {ERR_PHONEOFF, "Phone is disabled and connected to charger."},
+ {ERR_FILENOTSUPPORTED, "File format not supported by Gammu."},
{ERR_BUG, "Nobody is perfect, some bug appeared in protocol implementation. Please contact authors."},
- {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)."},
+ {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)"},
/* Some missed */
{ERR_OTHERCONNECTIONREQUIRED, "Current connection type doesn't support called function."},
- /* Some missed */
+ {ERR_WRONGCRC, "CRC error."},
{ERR_INVALIDDATETIME, "Invalid date or time specified."},
- {ERR_MEMORY, "Phone memory error, maybe it is read only"},
- {ERR_INVALIDDATA, "Invalid data"},
+ {ERR_MEMORY, "Phone memory error, maybe it is read only."},
+ {ERR_INVALIDDATA, "Invalid data."},
+ {ERR_FILEALREADYEXIST, "File with specified name already exist."},
diff --git a/gammu/emb/common/gsmcomon.h b/gammu/emb/common/gsmcomon.h
index cd36708..e067955 100644
--- a/gammu/emb/common/gsmcomon.h
+++ b/gammu/emb/common/gsmcomon.h
@@ -68,3 +68,4 @@ typedef enum {
ERR_MEMORY, /* Phone memory error, maybe it is read only */
- ERR_INVALIDDATA /* Invalid data */
+ ERR_INVALIDDATA, /* Invalid data */
+ ERR_FILEALREADYEXIST /* File with specified name already exist */
} GSM_Error;
diff --git a/gammu/emb/common/gsmstate.c b/gammu/emb/common/gsmstate.c
index b8f5f89..31e365d 100644
--- a/gammu/emb/common/gsmstate.c
+++ b/gammu/emb/common/gsmstate.c
@@ -188,2 +188,5 @@ GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s)
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ GSM_RegisterModule(s,&N650Phone);
+#endif
#ifdef GSM_ENABLE_NOKIA6110
@@ -212,3 +215,2 @@ GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
int i;
- char Buffer[80];
@@ -252,14 +254,12 @@ GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
s->di.dl == DL_TEXTALLDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTERRORDATE) {
- smprintf(s,"[Gammu - version %s built %s %s]\n",VERSION,__TIME__,__DATE__);
- smprintf(s,"[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
+ smprintf(s,"[Gammu - %s built %s %s",VERSION,__TIME__,__DATE__);
+ if (strlen(GetCompiler()) != 0) {
+ smprintf(s," in %s",GetCompiler());
+ }
+ smprintf(s,"]\n[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model);
smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device);
-
- Buffer[0] = 0;
- if (strlen(GetOS()) != 0) sprintf(Buffer,"%s",GetOS());
- if (strlen(GetCompiler()) != 0) {
- if (Buffer[0] != 0) strcat(Buffer+strlen(Buffer),", ");
- strcat(Buffer+strlen(Buffer),GetCompiler());
+ if (strlen(GetOS()) != 0) {
+ smprintf(s,"[Run on - %s]\n",GetOS());
}
- if (Buffer[0] != 0) smprintf(s,"[OS/compiler - %s]\n",Buffer);
}
@@ -556,2 +556,3 @@ static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Re
int i = 0;
+// int j;
@@ -570,4 +571,14 @@ static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Re
} else {
- if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) {
- execute=true;
+// printf("msg length %i %i\n",strlen(Reply[i].msgtype),msg->Length);
+ if ((int)strlen(Reply[i].msgtype)<msg->Length) {
+// printf("Comparing \"%s\" and \"",Reply[i].msgtype);
+// for (j=0;j<strlen(Reply[i].msgtype);j++) {
+// if (msg->Buffer[j]!=13 && msg->Buffer[j]!=10) {
+// printf("%c",msg->Buffer[j]);
+// }
+// }
+// printf("\"\n");
+ if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) {
+ execute=true;
+ }
}
@@ -847,4 +858,7 @@ bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num)
static OnePhoneModel allmodels[] = {
+#ifdef GSM_ENABLE_NOKIA650
+ {"0650" ,"THF-12","", {0}},
+#endif
#ifdef GSM_ENABLE_NOKIA6510
- {"1100", "RH-18" ,"", {0}},
+ {"1100" ,"RH-18" ,"", {0}},
{"1100a","RH-38" ,"", {0}},
@@ -856,7 +870,7 @@ static OnePhoneModel allmodels[] = {
#ifdef GSM_ENABLE_NOKIA6510
- {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},
- {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},
+ {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
+ {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
{"3108", "RH-6", "Nokia 3108", {0}}, //does it have irda ?
- {"3200", "RH-30" ,"Nokia 3200", {F_PBKTONEGAL,0}},
- {"3200a","RH-31" ,"Nokia 3200", {F_PBKTONEGAL,0}},
+ {"3200", "RH-30" ,"Nokia 3200", {F_PBKTONEGAL,0}},//fixme
+ {"3200a","RH-31" ,"Nokia 3200", {F_PBKTONEGAL,0}},//fixme
#endif
@@ -867,4 +881,4 @@ static OnePhoneModel allmodels[] = {
#ifdef GSM_ENABLE_NOKIA6510
- {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},
- {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},
+ {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
+ {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
#endif
@@ -900,2 +914,4 @@ static OnePhoneModel allmodels[] = {
{"5100" ,"NPM-6X","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
+ {"5140" ,"NPL-4" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
+ {"5140" ,"NPL-5" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
#endif
@@ -924,3 +940,3 @@ static OnePhoneModel allmodels[] = {
{"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}},
- {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,0}},
+ {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
#endif
@@ -931,3 +947,3 @@ static OnePhoneModel allmodels[] = {
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
- {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},
+ {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
{"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
@@ -937,4 +953,7 @@ static OnePhoneModel allmodels[] = {
{"6610" ,"NHL-4U","Nokia 6610", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
+ {"6610i","RM-37" ,"Nokia 6610i",{F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
{"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
{"6800" ,"NHL-6" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
+ {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
+ {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
#endif
@@ -945,2 +964,3 @@ static OnePhoneModel allmodels[] = {
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
+ {"7200" ,"RH-23" ,"Nokia 7200", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},//quess
{"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
@@ -977,4 +997,6 @@ static OnePhoneModel allmodels[] = {
{"at" , "at", "", {0}},
+ /* Siemens */
{"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}},
{"MC35" , "MC35", "", {0}},
+ {"TC35" , "TC35", "", {0}},
{"S25", "S25", "SIEMENS S25", {0}},
@@ -993,2 +1015,11 @@ static OnePhoneModel allmodels[] = {
{"S55" , "S55" , "", {0}},
+ /* Samsung */
+ {"S100" , "SGH-S100" , "", {0}},
+ {"S200" , "SGH-S200" , "", {0}},
+ {"S300" , "SGH-S300" , "", {0}},
+ {"S500" , "SGH-S500" , "", {0}},
+ {"V200" , "SGH-V200" , "", {0}},
+ {"T100" , "SGH-T100" , "", {0}},
+ {"E700" , "SGH-E700" , "", {0}},
+ /* Ericsson/Sony Ericsson */
{"T28s", "1101101-BVT28s","", {0}},
@@ -1006,2 +1037,3 @@ static OnePhoneModel allmodels[] = {
{"P800", "7130501-BVP800" ,"", {0}},
+ /* Other */
{"iPAQ" , "iPAQ" , "" , {0}},
diff --git a/gammu/emb/common/gsmstate.h b/gammu/emb/common/gsmstate.h
index cb17623..2b4806c 100644
--- a/gammu/emb/common/gsmstate.h
+++ b/gammu/emb/common/gsmstate.h
@@ -10,2 +10,7 @@
+typedef struct _GSM_StateMachine GSM_StateMachine;
+typedef struct _GSM_User GSM_User;
+typedef struct _OnePhoneModel OnePhoneModel;
+typedef struct _GSM_Reply_Function GSM_Reply_Function;
+
#ifdef GSM_ENABLE_NOKIA3320
@@ -16,2 +21,5 @@
#endif
+#ifdef GSM_ENABLE_NOKIA650
+# include "phone/nokia/dct3/n0650.h"
+#endif
#ifdef GSM_ENABLE_NOKIA6110
@@ -96,3 +104,3 @@
-#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
+#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA650) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
# define GSM_ENABLE_NOKIA_DCT3
@@ -201,5 +209,2 @@
-typedef struct _GSM_StateMachine GSM_StateMachine;
-typedef struct _GSM_User GSM_User;
-typedef struct _OnePhoneModel OnePhoneModel;
@@ -373,2 +378,4 @@ typedef enum {
ID_SetOBEX,
+ ID_SetUSSD,
+ ID_GetNote,
ID_GetSignalQuality,
@@ -440,2 +447,3 @@ typedef enum {
ID_GetLanguage,
+ ID_SetFastSMSSending,
ID_Reset,
@@ -671,2 +679,3 @@ typedef struct {
GSM_ToDoEntry *ToDo;
+ GSM_NoteEntry *Note;
/**
@@ -772,2 +781,5 @@ typedef struct {
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ GSM_Phone_N650Data N650;
+#endif
#ifdef GSM_ENABLE_NOKIA6110
@@ -806,3 +818,3 @@ typedef struct {
*/
-typedef struct {
+struct _GSM_Reply_Function {
/**
@@ -830,3 +842,3 @@ typedef struct {
GSM_Phone_RequestID requestID;
-} GSM_Reply_Function;
+};
@@ -1061,2 +1073,3 @@ typedef struct {
GSM_Error (*SendSavedSMS) (GSM_StateMachine *s, int Folder, int Location);
+ GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, bool enable);
/**
@@ -1281,3 +1294,3 @@ typedef struct {
*/
- GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh);
+ GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh);
/**
@@ -1346,2 +1359,5 @@ typedef struct {
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ extern GSM_Phone_Functions N650Phone;
+#endif
#ifdef GSM_ENABLE_NOKIA6510
@@ -1525,2 +1541,3 @@ typedef enum {
F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */
+ F_NOTES,
diff --git a/gammu/emb/common/misc/coding/coding.c b/gammu/emb/common/misc/coding/coding.c
index 62543ac..b30b645 100644
--- a/gammu/emb/common/misc/coding/coding.c
+++ b/gammu/emb/common/misc/coding/coding.c
@@ -1,3 +1,7 @@
/* (c) 2002-2004 by Marcin Wiacek, Michal Cihar and others */
-/* based on some work from MyGnokii and Gnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -18,2 +22,151 @@
+/* function changes #10 #13 chars to \n \r */
+char *EncodeUnicodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0;
+ static unsigned char Buf[20000];
+
+ while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 10) {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = 'n';
+ Pos2++;
+ } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 13) {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = 'r';
+ Pos2++;
+ } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ } else {
+ Buf[Pos2*2] = buffer[Pos*2];
+ Buf[Pos2*2+1] = buffer[Pos*2+1];
+ Pos2++;
+ }
+ Pos++;
+ }
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 0;
+ return Buf;
+}
+
+/* function changes #10 #13 chars to \n \r */
+char *EncodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos]!=0x00) {
+ switch (buffer[Pos]) {
+ case 10:
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = 'n';
+ break;
+ case 13:
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = 'r';
+ break;
+ case '\\':
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = '\\';
+ break;
+ default:
+ Buf[Pos2++] = buffer[Pos];
+ }
+ Pos++;
+ }
+ Buf[Pos2] = 0;
+ return Buf;
+}
+
+char *DecodeUnicodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0, level=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
+ Buf[Pos2*2] = buffer[Pos*2];
+ Buf[Pos2*2+1] = buffer[Pos*2+1];
+ switch (level) {
+ case 0:
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ level = 1;
+ } else {
+ Pos2++;
+ }
+ break;
+ case 1:
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'n') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 10;
+ }
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'r') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 13;
+ }
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = '\\';
+ }
+ Pos2++;
+ level = 0;
+ }
+ Pos++;
+ }
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 0;
+ return Buf;
+}
+
+char *DecodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0, level=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos]!=0x00) {
+ Buf[Pos2] = buffer[Pos];
+ switch (level) {
+ case 0:
+ if (buffer[Pos] == '\\') {
+ level = 1;
+ } else {
+ Pos2++;
+ }
+ break;
+ case 1:
+ if (buffer[Pos] == 'n') Buf[Pos2] = 10;
+ if (buffer[Pos] == 'r') Buf[Pos2] = 13;
+ if (buffer[Pos] == '\\') Buf[Pos2] = '\\';
+ Pos2++;
+ level = 0;
+ }
+ Pos++;
+ }
+ Buf[Pos2] = 0;
+ return Buf;
+}
+
+char *mystrcasestr(unsigned const char *a, unsigned const char *b)
+{
+ unsigned char A[2000], B[200];
+ int i;
+
+ memset(A,0,sizeof(A));
+ memset(B,0,sizeof(B));
+ for (i=0;i<(int)strlen(a);i++) A[i] = tolower(a[i]);
+ for (i=0;i<(int)strlen(b);i++) B[i] = tolower(b[i]);
+
+ return strstr(A,B);
+}
+
unsigned int UnicodeLength(const unsigned char *str)
@@ -588,4 +741,4 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
- switch (Number[1]) {
- case NUMBER_ALPHANUMERIC:
+ switch ((Number[1] & 112)) {
+ case (NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN & 112):
if (length > 6) length++;
@@ -595,3 +748,3 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
break;
- case NUMBER_INTERNATIONAL:
+ case (NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN & 112):
dbgprintf("International number\n");
@@ -633,3 +786,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
/* Checking for format number */
- format = NUMBER_UNKNOWN;
+ format = NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN;
for (i=0;i<length;i++) {
@@ -637,6 +790,6 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
if (i==0 && buffer[i]=='+') {
- format=NUMBER_INTERNATIONAL;
+ format=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
} else {
/*char is not number. It must be alphanumeric*/
- if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC;
+ if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN;
}
@@ -652,3 +805,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
switch (format) {
- case NUMBER_ALPHANUMERIC:
+ case NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN:
length=GSM_PackSevenBitsToEight(0, buffer, Output+1, strlen(buffer))*2;
@@ -656,3 +809,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
break;
- case NUMBER_INTERNATIONAL:
+ case NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN:
length--;
@@ -921,3 +1074,3 @@ bool mystrncasecmp(unsigned const char *a, unsigned const char *b, int num)
- num--;
+ if (num == 0) num = -1;
@@ -941,3 +1094,3 @@ bool mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num)
- num--;
+ if (num == 0) num = -1;
@@ -1017,3 +1170,3 @@ int mytowlower(wchar_t c)
-unsigned char *mystrstr (const unsigned char *haystack, const unsigned char *needle)
+unsigned char *mywstrstr (const unsigned char *haystack, const unsigned char *needle)
{
diff --git a/gammu/emb/common/misc/coding/coding.h b/gammu/emb/common/misc/coding/coding.h
index d0c334d..4cf0038 100644
--- a/gammu/emb/common/misc/coding/coding.h
+++ b/gammu/emb/common/misc/coding/coding.h
@@ -5,2 +5,6 @@
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include <stdlib.h>
@@ -15,3 +19,3 @@ typedef int wint_t;
bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num);
-unsigned char *mystrstr (unsigned const char *haystack, unsigned const char *needle);
+unsigned char *mywstrstr (unsigned const char *haystack, unsigned const char *needle);
bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num);
@@ -37,2 +41,5 @@ void EncodeUnicodeSpecialNOKIAChars (unsigned char *dest, const unsigned char
+char *EncodeUnicodeSpecialChars (unsigned char *buffer);
+char *DecodeUnicodeSpecialChars (unsigned char *buffer);
+
/* ------------------------------- BCD ------------------------------------- */
@@ -88,3 +95,3 @@ typedef enum {
*/
- NUMBER_UNKNOWN = 0x81,
+ NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN = 0x81,
/**
@@ -92,3 +99,3 @@ typedef enum {
*/
- NUMBER_INTERNATIONAL = 0x91,
+ NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN = 0x91,
/**
@@ -96,3 +103,3 @@ typedef enum {
*/
- NUMBER_ALPHANUMERIC = 0xD0
+ NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN = 0xD0
@@ -124,5 +131,13 @@ void StringToDouble (char *text, double *d);
-bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num);
+bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num);
+char *mystrcasestr (unsigned const char *a, unsigned const char *b);
-void MyGetLine(unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen);
+void MyGetLine (unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen);
+
+char *EncodeSpecialChars(unsigned char *buffer);
+char *DecodeSpecialChars(unsigned char *buffer);
+
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
diff --git a/gammu/emb/common/misc/coding/md5.c b/gammu/emb/common/misc/coding/md5.c
index 30fe33f..abb61be 100644
--- a/gammu/emb/common/misc/coding/md5.c
+++ b/gammu/emb/common/misc/coding/md5.c
@@ -1,2 +1,2 @@
-/* Taken from ReHash (see http://www.reichlsoft.de.vu/) and released
+/* Taken from ReHash (www.reichlsoft.de.vu) and released
* under GPL/LGPL with permission from ReHash author
diff --git a/gammu/emb/common/misc/misc.c b/gammu/emb/common/misc/misc.c
index c2f09e4..7227e7b 100644
--- a/gammu/emb/common/misc/misc.c
+++ b/gammu/emb/common/misc/misc.c
@@ -13,2 +13,5 @@
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+# include <sys/utsname.h>
+#endif
@@ -232,7 +235,9 @@ char *OSDate (GSM_DateTime dt)
bool CheckDate(GSM_DateTime *date)
-{
- /* FIXME: This could also check if day is correct for selected month */
+{
+ const unsigned int days[]={31,29,31,30,31,30,31,31,30,31,30,31};
+
+ /* FIXME: This could also check for leap years */
return date->Year != 0 &&
- date->Month >= 1 && date->Month <= 12 &&
- date->Day >= 1 && date->Day <= 31;
+ date->Month >= 1 && date->Month <= 12 &&
+ date->Day >= 1 && date->Day <= days[date->Month];
}
@@ -453,2 +458,5 @@ char *GetOS(void)
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+ struct utsname Ver;
+#endif
static char Buffer[100] = {0x00};
@@ -522,3 +530,4 @@ char *GetOS(void)
#elif defined(linux) || defined(__linux) || defined(__linux__)
- sprintf(Buffer, "Linux");
+ uname(&Ver);
+ sprintf(Buffer, "Linux, kernel %s",Ver.release);
#elif defined(__FreeBSD__)
diff --git a/gammu/emb/common/misc/misc.h b/gammu/emb/common/misc/misc.h
index 8b46170..c461001 100644
--- a/gammu/emb/common/misc/misc.h
+++ b/gammu/emb/common/misc/misc.h
@@ -5,2 +5,6 @@
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include <stdio.h>
@@ -132,2 +136,6 @@ char *GetOS(void);
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
+
#endif
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c
index f004ad4..3821f13 100644
--- a/gammu/emb/common/phone/alcatel/alcatel.c
+++ b/gammu/emb/common/phone/alcatel/alcatel.c
@@ -11,5 +11,5 @@
* - BH4 series (535/735)
- * For some functions it uses normal AT mode (not implemented here, look at
- * ../at/atgen.[ch]) for others it switches into binary mode and initialises
- * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and
+ * For some functions it uses normal AT mode (not implemented here, look at
+ * ../at/atgen.[ch]) for others it switches into binary mode and initialises
+ * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and
* communicates over it. Don't ask me why Alcatel uses such silly thing...
@@ -103,2 +103,3 @@ extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType typ
extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
+extern GSM_Error ATGEN_SetFastSMSSending (GSM_StateMachine *s, bool enable);
extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable);
@@ -118,3 +119,3 @@ unsigned char GSM_AlcatelAlphabet[] =
0x83, 0x00,0x20, /* empty */
-
+
0x84, 0x00,0xe7, /* c cedilla */
@@ -170,14 +171,14 @@ unsigned char GSM_AlcatelAlphabet[] =
0xb5, 0x00,0x20, /* empty */
-
+
0xb6, 0x01,0x48, /* n caron */
0xb7, 0x01,0x65, /* t caron */
-
+
0xb8, 0x00,0x20, /* empty */
-
+
0xb9, 0x01,0x7e, /* z caron */
0xba, 0x01,0xe7, /* g caron */
-
+
0xbb, 0x00,0x20, /* empty */
0xbc, 0x00,0x20, /* empty */
-
+
0xbd, 0x1e,0x20, /* G macron */
@@ -198,3 +199,3 @@ unsigned char GSM_AlcatelAlphabet[] =
0xcc, 0x01,0x0f, /* d caron */
-
+
0xcd, 0x00,0x20, /* empty */
@@ -204,5 +205,5 @@ unsigned char GSM_AlcatelAlphabet[] =
0xd0, 0x00,0x5e, /* ^ */
-
+
0xd1, 0x00,0x20, /* empty */
-
+
0xd2, 0x00,0x7b, /* { */
@@ -210,7 +211,7 @@ unsigned char GSM_AlcatelAlphabet[] =
0xd4, 0x00,0x7d, /* } */
-
+
0xd5, 0x00,0x20, /* empty */
-
+
0xd6, 0x01,0x63, /* t cedilla */
-
+
0xd7, 0x00,0x20, /* empty */
@@ -225,5 +226,5 @@ unsigned char GSM_AlcatelAlphabet[] =
0xe0, 0x00,0x20, /* empty */
-
+
0xe1, 0x00,0x20, /* two candles */ /* FIXME */
-
+
0xe2, 0x00,0x20, /* empty */
@@ -231,3 +232,3 @@ unsigned char GSM_AlcatelAlphabet[] =
0xe4, 0x00,0x20, /* empty */
-
+
0xe5, 0x01,0xce, /* a caron */
@@ -241,8 +242,8 @@ unsigned char GSM_AlcatelAlphabet[] =
0xed, 0x00,0x20, /* some strange char :-) */ /* FIXME */
-
+
0xee, 0x00,0x20, /* big key stroken */ /* FIXME */
0xef, 0x00,0x20, /* big key */ /* FIXME */
-
+
0xf0, 0x00,0x20, /* empty */
-
+
0xf1, 0x00,0x31, /* 1 */
@@ -253,12 +254,12 @@ unsigned char GSM_AlcatelAlphabet[] =
0xf6, 0x26,0x6a, /* note */
-
+
0xf7, 0x27,0x13, /* okay inv */ /* FIXME */
0xf8, 0x27,0x13, /* okay */
-
+
0xf9, 0x00,0x20, /* empty */
-
+
0xfa, 0x00,0x20, /* key */ /* FIXME */
-
+
0xfb, 0x00,0x20, /* empty */
-
+
0xfc, 0x20,0xac, /* Euro */
@@ -268,3 +269,3 @@ unsigned char GSM_AlcatelAlphabet[] =
0xff, 0x00,0x20, /* empty */
-
+
0x00, 0x00,0x00
@@ -317,3 +318,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
if (error != ERR_NONE) return error;
-
+
error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol);
@@ -326,3 +327,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
}
-
+
if (error == ERR_TIMEOUT && s->Speed != 19200) {
@@ -330,3 +331,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
}
-
+
if (error != ERR_NONE) return error;
@@ -378,3 +379,3 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
unsigned char commit_buffer[] =
- {0x00, 0x04,
+ {0x00, 0x04,
0x00, /*type */
@@ -445,3 +446,3 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
if (error != ERR_NONE) return error;
-
+
switch (Priv->BinaryType) {
@@ -546,2 +547,4 @@ static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s)
Priv->Mode = ModeAT;
+ s->Phone.Data.Priv.ATGEN.PBKCharset = 0;
+ s->Phone.Data.Priv.ATGEN.PBKMemory = 0;
@@ -630,3 +633,3 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
}
-
+
for (i=0; i<*Priv->CurrentCount; i++) {
@@ -634,3 +637,3 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
}
-
+
return ERR_EMPTY;
@@ -848,3 +851,3 @@ static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateM
Priv->ReturnDateTime.Second = buffer[6];
-
+
Priv->ReturnDateTime.Day = 0;
@@ -1098,3 +1101,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
GSM_Error error;
-
+
if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') {
@@ -1103,3 +1106,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
}
-
+
smprintf(s,"Reading category %d\n", id);
@@ -1125,3 +1128,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
if (error != ERR_NONE) return error;
-
+
CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString);
@@ -1215,5 +1218,5 @@ static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_Fi
int len;
-
+
buffer[1] = field & 0xff;
-
+
switch(type) {
@@ -1331,6 +1334,6 @@ static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
if (error != ERR_NONE) return error;
-
+
error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField);
if (error != ERR_NONE) return error;
-
+
return ERR_NONE;
@@ -1344,3 +1347,3 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
0x00, /* type */
- 0x26, 0x01,
+ 0x26, 0x01,
0x00, 0x00, 0x00, 0x00, /* id */
@@ -1352,3 +1355,3 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
smprintf(s,"Updating field (%08x.%02x)\n", id, field);
-
+
buffer[5] = (id >> 24);
@@ -1371,6 +1374,6 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
if (error != ERR_NONE) return error;
-
+
error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField);
if (error != ERR_NONE) return error;
-
+
return ERR_NONE;
@@ -1745,3 +1748,3 @@ static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *ent
if (Priv->ContactsItemsCount == 0) return ERR_EMPTY;
-
+
if (start) entry->Location = 0;
@@ -1770,3 +1773,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
switch (entry->Entries[i].EntryType) {
- case PBK_Number_General:
+ case PBK_Number_General:
if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1779,3 +1782,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
- case PBK_Number_Fax:
+ case PBK_Number_Fax:
if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1811,9 +1814,9 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
- case PBK_Text_JobTitle:
+ case PBK_Text_JobTitle:
if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Category:
+ case PBK_Category:
if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
break;
- case PBK_Private:
+ case PBK_Private:
if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error;
@@ -1842,3 +1845,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
case PBK_Text_Custom3:
- if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
+ if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
@@ -1847,3 +1850,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
- case PBK_PictureID:
+ case PBK_PictureID:
if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
@@ -1908,5 +1911,5 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error;
-
+
for (i = 0; i < 26; i++) { UpdatedFields[i] = false; }
-
+
if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error;
@@ -1914,24 +1917,24 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
switch (entry->Entries[i].EntryType) {
- case PBK_Number_General:
- UpdatedFields[8] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Number_General:
+ UpdatedFields[8] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Number_Mobile:
- UpdatedFields[12] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Number_Mobile:
+ UpdatedFields[12] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Number_Work:
- UpdatedFields[7] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Number_Work:
+ UpdatedFields[7] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Number_Fax:
- UpdatedFields[9] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Number_Fax:
+ UpdatedFields[9] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Number_Home:
- UpdatedFields[13] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Number_Home:
+ UpdatedFields[13] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Number_Pager:
- UpdatedFields[11] = true;
+ case PBK_Number_Pager:
+ UpdatedFields[11] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1940,29 +1943,29 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
UpdatedFields[10] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_Note:
+ case PBK_Text_Note:
UpdatedFields[4] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_Email:
- UpdatedFields[14] = true;
+ case PBK_Text_Email:
+ UpdatedFields[14] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_Email2:
- UpdatedFields[15] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Text_Email2:
+ UpdatedFields[15] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_LastName:
- UpdatedFields[0] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
+ case PBK_Text_LastName:
+ UpdatedFields[0] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
break;
- case PBK_Text_FirstName:
- UpdatedFields[1] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
+ case PBK_Text_FirstName:
+ UpdatedFields[1] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
break;
case PBK_Text_Company:
- UpdatedFields[2] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
+ UpdatedFields[2] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_JobTitle:
+ case PBK_Text_JobTitle:
UpdatedFields[3] = true;
@@ -1971,3 +1974,3 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
case PBK_Category:
- UpdatedFields[5] = true;
+ UpdatedFields[5] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
@@ -1978,17 +1981,17 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
- case PBK_Text_StreetAddress:
+ case PBK_Text_StreetAddress:
UpdatedFields[16] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_City:
- UpdatedFields[17] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Text_City:
+ UpdatedFields[17] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_State:
- UpdatedFields[18] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Text_State:
+ UpdatedFields[18] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
- case PBK_Text_Zip:
- UpdatedFields[19] = true;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
+ case PBK_Text_Zip:
+ UpdatedFields[19] = true;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
break;
@@ -2002,3 +2005,3 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
- case PBK_Text_Custom2:
+ case PBK_Text_Custom2:
UpdatedFields[22] = true;
@@ -2011,6 +2014,6 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
case PBK_Text_Custom4:
- UpdatedFields[24] = true;
+ UpdatedFields[24] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error
; break;
- case PBK_PictureID:
+ case PBK_PictureID:
if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
@@ -2071,3 +2074,3 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr
if (error != ERR_NONE) return error;
-
+
/* Refresh list */
@@ -2075,3 +2078,3 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr
if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
-
+
return ERR_NONE;
@@ -2230,3 +2233,3 @@ static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatur
}
-
+
static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s)
@@ -2339,5 +2342,5 @@ static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStat
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
-
+
status->Used = 0;
-
+
if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
@@ -2729,3 +2732,3 @@ static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry
if (Priv->CalendarItemsCount == 0) return ERR_EMPTY;
-
+
if (start) Note->Location = 0;
@@ -2770,3 +2773,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error;
-
+
for (i = 0; i < Note->EntriesNum; i++) {
@@ -2808,3 +2811,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
phone_set = true;
- break;
+ break;
case CAL_REPEAT_DAYOFWEEK:
@@ -2844,3 +2847,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
}
-
+
switch (Note->Type) {
@@ -2902,3 +2905,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error;
-
+
for (i = 0; i < 22; i++) { UpdatedFields[i] = false; }
@@ -2906,3 +2909,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error;
-
+
for (i = 0; i < Note->EntriesNum; i++) {
@@ -2911,3 +2914,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
if (!date_set) {
- UpdatedFields[0] = true;
+ UpdatedFields[0] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
@@ -2955,3 +2958,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
phone_set = true;
- break;
+ break;
case CAL_REPEAT_DAYOFWEEK:
@@ -2998,3 +3001,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
}
-
+
switch (Note->Type) {
@@ -3074,3 +3077,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
-
+
for (i=0; i<Priv->CalendarItemsCount; i++) {
@@ -3093,3 +3096,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
Note.Location = Priv->CalendarItems[i];
-
+
if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error;
@@ -3101,3 +3104,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
}
-
+
alarm->Text[0] = 0; alarm->Text[1] = 0;
@@ -3148,3 +3151,3 @@ static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm)
}
-
+
if (Found) {
@@ -3186,5 +3189,5 @@ static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *stat
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
-
+
status->Used = 0;
-
+
if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
@@ -3453,3 +3456,3 @@ static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, b
if (Priv->ToDoItemsCount == 0) return ERR_EMPTY;
-
+
if (start) ToDo->Location = 0;
@@ -3492,3 +3495,3 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error;
-
+
switch (ToDo->Priority) {
@@ -3520,3 +3523,3 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
break;
- case TODO_ALARM_DATETIME:
+ case TODO_ALARM_DATETIME:
if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
@@ -3581,5 +3584,5 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error;
-
+
for (i = 0; i < 12; i++) { UpdatedFields[i] = false; }
-
+
if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error;
@@ -3610,3 +3613,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
- UpdatedFields[0] = true;
+ UpdatedFields[0] = true;
break;
@@ -3614,13 +3617,13 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
- UpdatedFields[1] = true;
+ UpdatedFields[1] = true;
break;
- case TODO_ALARM_DATETIME:
+ case TODO_ALARM_DATETIME:
if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
- UpdatedFields[2] = true;
+ UpdatedFields[2] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
- UpdatedFields[3] = true;
+ UpdatedFields[3] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
- UpdatedFields[10] = true;
+ UpdatedFields[10] = true;
if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
- UpdatedFields[11] = true;
+ UpdatedFields[11] = true;
break;
@@ -3628,3 +3631,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error;
- UpdatedFields[4] = true;
+ UpdatedFields[4] = true;
break;
@@ -3632,3 +3635,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
- UpdatedFields[5] = true;
+ UpdatedFields[5] = true;
break;
@@ -3636,3 +3639,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
- UpdatedFields[6] = true;
+ UpdatedFields[6] = true;
break;
@@ -3640,3 +3643,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
- UpdatedFields[8] = true;
+ UpdatedFields[8] = true;
contact_set = true;
@@ -3645,3 +3648,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error;
- UpdatedFields[9] = true;
+ UpdatedFields[9] = true;
phone_set = true;
@@ -3824,2 +3827,10 @@ static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
+static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable)
+{
+ GSM_Error error;
+
+ if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
+ return ATGEN_SetFastSMSSending(s, enable);
+}
+
static GSM_Reply_Function ALCATELReplyFunctions[] = {
@@ -3915,2 +3926,3 @@ GSM_Phone_Functions ALCATELPhone = {
ALCATEL_SendSavedSMS,
+ ALCATEL_SetFastSMSSending,
ALCATEL_SetIncomingSMS,
@@ -3969,3 +3981,3 @@ GSM_Phone_Functions ALCATELPhone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index 1834f15..ba23eb2 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -14,33 +14,13 @@
#include "../pfunc.h"
+
#include "atgen.h"
+#include "samsung.h"
+#include "siemens.h"
+#include "sonyeric.h"
+
#ifdef GSM_ENABLE_ALCATEL
-extern GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *);
#endif
-extern GSM_Error ATGEN_CMS35ReplyGetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyGetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyGetNextCal (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_SL45ReplyGetMemory (GSM_Protocol_Message msg, GSM_StateMachine *s);
-
-extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
-extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
-extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
-extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
-extern GSM_Error SIEMENS_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
-extern GSM_Error SIEMENS_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SIEMENS_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-
-extern GSM_Error SONYERIC_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
-extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
-extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status);
-extern GSM_Error SONYERIC_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
-extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s);
-extern GSM_Error SONYERIC_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SONYERIC_GetCalendarStatus (GSM_StateMachine *s, GSM_CalendarStatus *Status);
@@ -177,2 +157,4 @@ GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
switch (Priv->ErrorCode) {
+ case -1:
+ return ERR_EMPTY;
case 3:
@@ -258,4 +240,12 @@ void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input)
{
- dt->Year=2000+(*input-'0')*10; input++;
+ /* Samsung phones report year as %d instead of %02d */
+ if (input[2] == '/') {
+ dt->Year=(*input-'0')*10;
+ input++;
+ } else {
+ dt->Year=0;
+ }
+
dt->Year=dt->Year+(*input-'0'); input++;
+ dt->Year+=2000;
@@ -324,2 +314,14 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
}
+
+ /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
+ if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
+ err = line + 11;
+ Priv->ErrorCode = atoi(err);
+
+ if (Priv->ErrorCode == -1) {
+ Priv->ErrorText = "[Samsung] Empty location";
+ return GSM_DispatchMessage(s);
+ }
+ }
+
if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
@@ -372,2 +374,38 @@ GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned char buffer[2000],buffer2[4000];
+ int i = 10;
+
+ /* Ugly hack */
+ while (msg.Buffer[i]!=13) i++;
+ i = i - 6;
+ memcpy(buffer,msg.Buffer+10,i-11);
+ buffer[i-11] = 0x00;
+
+ smprintf(s, "USSD reply: \"%s\"\n",buffer);
+
+ if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
+ EncodeUnicode(buffer2,buffer,strlen(buffer));
+ s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
+ }
+
+ return ERR_NONE;
+}
+
+GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
+{
+ GSM_Error error;
+
+ if (enable) {
+ smprintf(s, "Enabling incoming USSD\n");
+ error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
+ } else {
+ smprintf(s, "Disabling incoming USSD\n");
+ error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
+ }
+ if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
+ return error;
+}
+
GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -396,2 +434,3 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens;
+ else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens;
else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
@@ -400,2 +439,3 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35");
+ else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35");
else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
@@ -483,2 +523,7 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
}
+ if (strstr(msg.Buffer,"Samsung")) {
+ smprintf(s, "Samsung\n");
+ strcpy(s->Phone.Data.Manufacturer,"Samsung");
+ Priv->Manufacturer = AT_Samsung;
+ }
return ERR_NONE;
@@ -676,8 +721,16 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
*/
- s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL);
+ 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\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
+
+ 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;
@@ -686,2 +739,4 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
default:
@@ -860,4 +915,5 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL &&
- buffer[1]!=NUMBER_ALPHANUMERIC) {
+ /* we check for the most often visible */
+ if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
+ buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
/* Seems to be Delivery Report */
@@ -896,3 +952,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[current+1]==NUMBER_ALPHANUMERIC) {
+ if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
smprintf(s, "Trying to read alphanumeric number\n");
@@ -927,3 +983,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[current+1]==NUMBER_ALPHANUMERIC) {
+ if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
smprintf(s, "Trying to read alphanumeric number\n");
@@ -951,3 +1007,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
sms->InboxFolder = true;
- smprintf(s, "TPMR is %02x\n",buffer[current]);
+ smprintf(s, "TPMR is %d\n",buffer[current]);
smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
@@ -1642,3 +1698,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
if (s->User.SendSMSStatus!=NULL) {
- start = strstr(msg.Buffer, "+CMGW: ");
+ start = strstr(msg.Buffer, "+CMGS: ");
if (start != NULL) {
@@ -1646,3 +1702,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
} else {
- s->User.SendSMSStatus(s->CurrentConfig->Device,0,0);
+ s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
}
@@ -1652,3 +1708,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
smprintf(s, "Error %i\n",Priv->ErrorCode);
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1);
return ATGEN_HandleCMSError(s);
@@ -1789,2 +1845,15 @@ GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+/* R320 only takes HH:MM. Do other phones understand full date? */
+GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ char req[20];
+
+ if (alarm->Location != 1) return ERR_INVALIDLOCATION;
+
+ sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute);
+
+ smprintf(s, "Setting Alarm\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm);
+}
+
GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -2204,2 +2273,4 @@ GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM
error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus);
+ if (Priv->Manufacturer == AT_Samsung)
+ error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus);
if (error != ERR_NONE) return error;
@@ -2270,2 +2341,8 @@ GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
+ /* Samsung (and Sagem?) phones use only PCCP437? */
+ if (Priv->Manufacturer == AT_Samsung) {
+ Priv->PBKCharset = AT_PBK_PCCP437;
+ return ERR_NONE;
+ }
+
if (PreferUnicode && !Priv->UCS2CharsetFailed) {
@@ -2387,3 +2464,33 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
break;
+ case AT_PBK_PCCP437:
+ /* FIXME: correctly decode PCCP437 */
+ DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
+ break;
+ }
+
+ /* Samsung number type */
+ if (Priv->Manufacturer == AT_Samsung) {
+ int type;
+
+ pos += ATGEN_ExtractOneParameter(pos, buffer);
+ smprintf(s, "Number type: %s\n",buffer);
+ type = strtoul(buffer, NULL, 0);
+ switch (type) {
+ case 0:
+ Memory->Entries[0].EntryType = PBK_Number_Mobile;
+ break;
+ case 1:
+ Memory->Entries[0].EntryType = PBK_Number_Work;
+ break;
+ case 2:
+ Memory->Entries[0].EntryType = PBK_Number_Home;
+ break;
+ case 3:
+ Memory->Entries[0].EntryType = PBK_Text_Email;
+ break;
+ default:
+ Memory->Entries[0].EntryType = PBK_Number_General;
+ }
}
+
return ERR_NONE;
@@ -2564,2 +2671,4 @@ GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachin
return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
default:
@@ -2926,2 +3035,8 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
+ case AT_PBK_PCCP437:
+ /* FIXME: correctly decode PCCP437 */
+ smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
+ len = UnicodeLength(entry->Entries[Name].Text);
+ EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
+ break;
}
@@ -3254,2 +3369,39 @@ GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
+
+GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength);
+ return ERR_NOTSUPPORTED;
+}
+
GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
@@ -3348,2 +3500,13 @@ GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
+GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
+{
+ if (enable) {
+ smprintf(s, "Enabling fast SMS sending\n");
+ return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
+ } else {
+ smprintf(s, "Disabling fast SMS sending\n");
+ return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
+ }
+}
+
GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -3426,2 +3589,14 @@ GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
+GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
+ return ERR_NOTSUPPORTED;
+}
+
GSM_Reply_Function ATGENReplyFunctions[] = {
@@ -3434,2 +3609,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
+{ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
+{ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
+{ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
+{ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
+
#ifdef GSM_ENABLE_CELLBROADCAST
@@ -3464,2 +3644,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters },
+{ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending },
{ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
@@ -3471,2 +3652,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime },
+{ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm },
{ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
@@ -3486,3 +3668,5 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus },
+// /* Samsung phones reply +CPBR: after OK --claudio*/
{ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus },
+{ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus },
{ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
@@ -3491,14 +3675,14 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
-{ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
+{SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
{ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
-{ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
-{ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
+{SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
+{SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
-{ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
-{ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
+{SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
+{SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
-{ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
-{ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
-{ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote },
+{SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
+{SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
+{SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote },
@@ -3513,2 +3697,4 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
+{ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
+{ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
@@ -3523,2 +3709,8 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
+{SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
+{SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
+
+{SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
+{SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
+
#ifdef GSM_ENABLE_ALCATEL
@@ -3540,3 +3732,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
GSM_Phone_Functions ATGENPhone = {
- "A2D|iPAQ|at|M20|S25|MC35|C35i|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210",
+ "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210",
ATGENReplyFunctions,
@@ -3559,5 +3751,5 @@ GSM_Phone_Functions ATGENPhone = {
ATGEN_GetAlarm,
- NOTIMPLEMENTED, /* SetAlarm */
- NOTSUPPORTED, /* GetLocale */
- NOTSUPPORTED, /* SetLocale */
+ ATGEN_SetAlarm,
+ ATGEN_GetLocale,
+ ATGEN_SetLocale,
ATGEN_PressKey,
@@ -3594,2 +3786,3 @@ GSM_Phone_Functions ATGENPhone = {
ATGEN_SendSavedSMS,
+ ATGEN_SetFastSMSSending,
ATGEN_SetIncomingSMS,
@@ -3612,3 +3805,3 @@ GSM_Phone_Functions ATGENPhone = {
NONEFUNCTION, /* SetIncomingCall */
- NOTSUPPORTED, /* SetIncomingUSSD */
+ ATGEN_SetIncomingUSSD,
ATGEN_SendDTMF,
@@ -3648,3 +3841,3 @@ GSM_Phone_Functions ATGENPhone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/at/atgen.h b/gammu/emb/common/phone/at/atgen.h
index 0e08ee4..bb5c559 100644
--- a/gammu/emb/common/phone/at/atgen.h
+++ b/gammu/emb/common/phone/at/atgen.h
@@ -44,2 +44,3 @@ typedef enum {
AT_Sagem,
+ AT_Samsung,
AT_Unknown
@@ -50,3 +51,4 @@ typedef enum {
AT_PBK_GSM,
- AT_PBK_UCS2
+ AT_PBK_UCS2,
+ AT_PBK_PCCP437
} GSM_AT_PBK_Charset;
@@ -105,2 +107,6 @@ typedef struct {
+GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *);
+GSM_Error ATGEN_HandleCMEError (GSM_StateMachine *);
+GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *);
+
#endif
diff --git a/gammu/emb/common/phone/at/samsung.c b/gammu/emb/common/phone/at/samsung.c
new file mode 100644
index 0000000..55a42e5
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.c
@@ -0,0 +1,447 @@
+/* Samsung-specific functions
+ * Copyright (C) 2004 Claudio Matsuoka <cmatsuoka@gmail.com>
+ * Tested with S300 only!
+ */
+
+#include "../../gsmstate.h"
+
+#ifdef GSM_ENABLE_ATGEN
+
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include "../../misc/coding/coding.h"
+#include "../../gsmcomon.h"
+#include "../../service/sms/gsmsms.h"
+#include "../pfunc.h"
+
+#include "atgen.h"
+#include "samsung.h"
+
+/* Binary frame size */
+#define BLKSZ 1024
+
+struct ModelRes {
+ char *model;
+ int width;
+ int height;
+};
+
+static struct ModelRes modres[] = {
+ { "S100", 128, 128 },
+ { "S200", 128, 113 },
+ { "S300", 128, 97 },
+ { "S500", 128, 128 },
+ { "T100", 128, 128 },
+ { "E700", 128, 128 },
+ { NULL, 0, 0 }
+};
+
+/*
+ * CRC functions from the Granch SBNI12 Linux driver by
+ * Denis I. Timofeev <timofeev@granch.ru>
+ */
+static unsigned int crc32tab[] = {
+ 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
+ 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
+ 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
+ 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C,
+ 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53,
+ 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A,
+ 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661,
+ 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278,
+ 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF,
+ 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6,
+ 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD,
+ 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4,
+ 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B,
+ 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82,
+ 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9,
+ 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0,
+ 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7,
+ 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE,
+ 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795,
+ 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C,
+ 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3,
+ 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA,
+ 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1,
+ 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8,
+ 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F,
+ 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76,
+ 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D,
+ 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344,
+ 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B,
+ 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12,
+ 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739,
+ 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320,
+ 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17,
+ 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E,
+ 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525,
+ 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C,
+ 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73,
+ 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A,
+ 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541,
+ 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158,
+ 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF,
+ 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6,
+ 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED,
+ 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4,
+ 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB,
+ 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2,
+ 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589,
+ 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190,
+ 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87,
+ 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E,
+ 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5,
+ 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC,
+ 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3,
+ 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA,
+ 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1,
+ 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8,
+ 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F,
+ 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856,
+ 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D,
+ 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064,
+ 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B,
+ 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832,
+ 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419,
+ 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000
+};
+
+static unsigned int GetCRC(char *data, int size)
+{
+ unsigned int crc = 0;
+
+ while (size--)
+ crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
+
+ return crc;
+}
+
+/*
+ * Frame transfer
+ */
+
+static GSM_Error WaitFor(GSM_StateMachine *s, char *t, int ttl)
+{
+ char readbuf[100];
+ int n;
+ unsigned int sec;
+ GSM_DateTime Date;
+
+ GSM_GetCurrentDateTime (&Date);
+ sec = Date.Second;
+
+ n = s->Device.Functions->ReadDevice(s, readbuf, 80);
+ readbuf[n] = 0;
+ while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.Second) {
+ my_sleep(5000);
+ n = s->Device.Functions->ReadDevice(s, readbuf, 80);
+ readbuf[n] = 0;
+ GSM_GetCurrentDateTime (&Date);
+ }
+
+ return (sec + ttl) >= Date.Second ? ERR_NONE : ERR_TIMEOUT;
+}
+
+static GSM_Error SetSamsungFrame(GSM_StateMachine *s, unsigned char *buff, int size, GSM_Phone_RequestID id)
+{
+ GSM_Phone_Data *Phone = &s->Phone.Data;
+ GSM_Error error;
+ int i, count;
+
+ count = size / BLKSZ;
+
+ for (i = 0; i < count; i++) {
+ error = WaitFor(s, ">", 4);
+ if (error!=ERR_NONE) return error;
+
+ error = s->Protocol.Functions->WriteMessage(s,
+ buff + i * BLKSZ, BLKSZ, 0x00);
+ if (error!=ERR_NONE) return error;
+ }
+
+ error = WaitFor(s, ">", 4);
+ if (error!=ERR_NONE) return error;
+ error = s->Protocol.Functions->WriteMessage(s,
+ buff + i * BLKSZ, size%BLKSZ, 0x00);
+ if (error!=ERR_NONE) return error;
+
+ error = GSM_WaitFor(s, "", 0, 0x00, 4, id);
+ if (error!=ERR_NONE) return error;
+
+ return Phone->DispatchError;
+}
+
+/* Answer format for binary data transfer
+ *
+ * SDNDCRC = 0xa : RECEIVECRC = 0xcbf53a1c : BINSIZE = 5
+ * CRCERR
+ */
+static GSM_Error ReplySetSamsungFrame(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned long txcrc, rxcrc;
+ int binsize;
+ char *pos;
+
+ /* Parse SDNDCRC */
+ pos = strchr(msg.Buffer, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ txcrc = strtoul(pos, NULL, 0);
+ smprintf(s, "Sent CRC : 0x%lx\n", txcrc);
+
+ /* Parse RECEIVECRC */
+ pos = strchr(pos, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ rxcrc = strtoul(pos, NULL, 0);
+ smprintf(s, "Reveived CRC : 0x%lx\n", rxcrc);
+
+ /* Parse BINSIZE */
+ pos = strchr(pos, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ binsize = strtoul(pos, NULL, 0);
+ smprintf(s, "Binary size : %d\n", binsize);
+
+ return txcrc == rxcrc ? ERR_NONE : ERR_WRONGCRC;
+}
+
+/*
+ * Bitmaps
+ */
+
+GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char buffer[32];
+ char *pos;
+ int location, count;
+
+ switch (Priv->ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Bitmap info received\n");
+ /* Parse +IMGR:location,name,0,0,0,0 */
+
+ /* Parse location */
+ pos = strchr(msg.Buffer, ':');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ location = atoi(pos);
+ smprintf(s, "Location : %d\n", location);
+
+ /* Parse name */
+ pos = strchr(pos, '"');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ for (count = 0; count < 31; count++) {
+ if (pos[count] == '"')
+ break;
+ buffer[count] = pos[count];
+ }
+ buffer[count] = 0;
+ smprintf(s, "Name : %s\n", buffer);
+ s->Phone.Data.Bitmap->Name = malloc((strlen(buffer) + 1) * 2);
+ if (s->Phone.Data.Bitmap->Name == NULL)
+ return ERR_MOREMEMORY;
+ EncodeUnicode(s->Phone.Data.Bitmap->Name, buffer, strlen(buffer));
+
+ s->Phone.Data.Bitmap->Location = location;
+
+ return ERR_NONE;
+ case AT_Reply_Error:
+ return ERR_UNKNOWN;
+ case AT_Reply_CMSError:
+ return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Bitmap sent\n");
+ return ReplySetSamsungFrame(msg, s);
+}
+
+GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char req[100];
+
+ s->Phone.Data.Bitmap=Bitmap;
+ smprintf(s, "Getting bitmap\n");
+ sprintf(req, "AT+IMGR=%d\r", Bitmap->Location-1);
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
+}
+
+GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char req[100];
+ unsigned long crc;
+ GSM_Error error;
+ char name[50], *dot, *model;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+ int i;
+
+ s->Phone.Data.Bitmap = Bitmap;
+ smprintf(s, "Setting bitmap\n");
+
+ if (Bitmap->Type != GSM_PictureBinary) {
+ smprintf(s, "Invalid picture type\n");
+ return ERR_INVALIDDATA;
+ }
+
+ if (Bitmap->BinaryPic.Type != PICTURE_GIF) {
+ smprintf(s, "Invalid binary picture type\n");
+ return ERR_INVALIDDATA;
+ }
+
+ /* Check if picture size matches phone model */
+ model = GetModelData(NULL,Data->Model,NULL)->model;
+ smprintf(s, "Checking picture size for %s\n", model);
+ for (i = 0; modres[i].model; i++) {
+ if (!strcmp(model, modres[i].model)) {
+ if (Bitmap->BitmapWidth != modres[i].width ||
+ Bitmap->BitmapHeight != modres[i].height) {
+ smprintf(s, "Model %s must use %d x %d picture size\n",
+ modres[i].model, modres[i].width,
+ modres[i].height);
+ return ERR_INVALIDDATA;
+ }
+ break;
+ }
+ }
+ if (modres[i].model == NULL) {
+ smprintf(s, "Model \"%s\" is not supported.\n", Data->Model);
+ return ERR_NOTSUPPORTED;
+ }
+
+ crc = GetCRC(Bitmap->BinaryPic.Buffer, Bitmap->BinaryPic.Length);
+
+ /* Remove extension from file name */
+ strncpy(name, DecodeUnicodeString(Bitmap->Name), 50);
+ if ((dot = strrchr(name, '.')) != NULL)
+ *dot = 0;
+
+ sprintf(req, "AT+IMGW=0,\"%s\",2,0,0,0,0,100,%d,%u\r", name,
+ Bitmap->BinaryPic.Length, (unsigned int)crc);
+
+ error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
+ if (error!=ERR_NONE) return error;
+
+ return SetSamsungFrame(s, Bitmap->BinaryPic.Buffer,
+ Bitmap->BinaryPic.Length, ID_SetBitmap);
+}
+
+/*
+ * Ringtones
+ */
+
+GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char buffer[32];
+ char *pos;
+ int location, length, count;
+
+ switch (Priv->ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Ringtone info received\n");
+ /* Parse +MELR:location,name,size */
+
+ /* Parse location */
+ pos = strchr(msg.Buffer, ':');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ location = atoi(pos);
+ smprintf(s, "Location : %d\n", location);
+
+ /* Parse name */
+ pos = strchr(pos, '"');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ /* Ringtone.Name size is 20 chars */
+ for (count = 0; count < 19; count++) {
+ if (pos[count] == '"')
+ break;
+ buffer[count] = pos[count];
+ }
+ buffer[count] = 0;
+ smprintf(s, "Name : %s\n", buffer);
+ EncodeUnicode(s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
+
+ /* Parse ringtone length */
+ pos = strchr(pos, ',');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ length = atoi(pos);
+ smprintf(s, "Length : %d\n", length);
+
+ /* S300 ringtones are always MMF */
+ s->Phone.Data.Ringtone->Format = RING_MMF;
+ s->Phone.Data.Ringtone->Location = location;
+ s->Phone.Data.Ringtone->BinaryTone.Length = length;
+
+ return ERR_NONE;
+ case AT_Reply_Error:
+ return ERR_UNKNOWN;
+ case AT_Reply_CMSError:
+ return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ unsigned char req[100];
+
+ s->Phone.Data.Ringtone = Ringtone;
+ smprintf(s, "Getting ringtone\n");
+ sprintf(req, "AT+MELR=%d\r", Ringtone->Location-1);
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
+}
+
+GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Ringtone sent\n");
+ return ReplySetSamsungFrame(msg, s);
+}
+
+GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ unsigned char req[100];
+ unsigned long crc;
+ GSM_Error error;
+ char name[50], *dot;
+
+ s->Phone.Data.Ringtone = Ringtone;
+ smprintf(s, "Setting ringtone\n");
+
+ if (Ringtone->Format != RING_MMF) {
+ smprintf(s, "Not MMF ringtone\n");
+ return ERR_INVALIDDATA;
+ }
+
+ /* Remove extension from file name */
+ strncpy(name, DecodeUnicodeString(Ringtone->Name), 50);
+ if ((dot = strrchr(name, '.')) != NULL) *dot = 0;
+
+ crc = GetCRC(Ringtone->BinaryTone.Buffer, Ringtone->BinaryTone.Length);
+ sprintf(req, "AT+MELW=0,\"%s\",4,%d,%u\r", name,
+ Ringtone->BinaryTone.Length, (unsigned int)crc);
+
+ error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
+ if (error!=ERR_NONE) return error;
+
+ return SetSamsungFrame(s, Ringtone->BinaryTone.Buffer,
+ Ringtone->BinaryTone.Length, ID_SetRingtone);
+}
+
+#endif
diff --git a/gammu/emb/common/phone/at/samsung.h b/gammu/emb/common/phone/at/samsung.h
new file mode 100644
index 0000000..3b2947c
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.h
@@ -0,0 +1,16 @@
+#ifndef samsung_h
+#define samsung_h
+
+#include "../../gsmstate.h"
+
+GSM_Error SAMSUNG_ReplyGetRingtone (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplySetRingtone (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplyGetBitmap (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplySetBitmap (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_GetRingtone (GSM_StateMachine *, GSM_Ringtone *, bool);
+GSM_Error SAMSUNG_SetRingtone (GSM_StateMachine *, GSM_Ringtone *, int *);
+GSM_Error SAMSUNG_GetBitmap (GSM_StateMachine *, GSM_Bitmap *);
+GSM_Error SAMSUNG_SetBitmap (GSM_StateMachine *, GSM_Bitmap *);
+GSM_Error SAMSUNG_GetCallLogs (GSM_StateMachine *, GSM_MemoryEntry *, int);
+
+#endif
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
@@ -15,21 +15,7 @@
-extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s);
+#include "atgen.h"
+#include "siemens.h"
-GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
-{
- if (s->Protocol.Data.AT.EditMode) {
- s->Protocol.Data.AT.EditMode = false;
- return ERR_NONE;
- }
- dbgprintf ("Written %s",function);
- if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
- dbgprintf (" - OK\n");
- return ERR_NONE;
- } else {
- dbgprintf (" - error\n");
- return ERR_UNKNOWN;
- }
-}
-GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
+static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
unsigned char *buffer, int *len)
@@ -59,3 +45,3 @@ GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *t
-GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
+static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
int Location, GSM_Phone_RequestID RequestID, int len)
@@ -92,3 +78,3 @@ GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ
-GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
@@ -106,8 +92,24 @@ GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *
-GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo");
+ if (s->Protocol.Data.AT.EditMode) {
+ s->Protocol.Data.AT.EditMode = false;
+ return ERR_NONE;
+ }
+ dbgprintf ("Written %s",function);
+ if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
+ dbgprintf (" - OK\n");
+ return ERR_NONE;
+ } else {
+ dbgprintf (" - error\n");
+ return ERR_UNKNOWN;
+ }
}
-GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return SIEMENS_ReplySetFunction (msg, s, "Operator Logo");
+}
+
+GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
{
@@ -115,3 +117,2 @@ GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
@@ -124,3 +125,3 @@ GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
-GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
{
@@ -130,3 +131,2 @@ GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
@@ -143,3 +143,3 @@ GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
-GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
@@ -160,3 +160,3 @@ GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine
-GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
{
@@ -164,4 +164,2 @@ GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool Ph
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
-
s->Phone.Data.Ringtone=Ringtone;
@@ -172,8 +170,8 @@ GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool Ph
-GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone");
+ return SIEMENS_ReplySetFunction (msg, s, "Ringtone");
}
-GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
{
@@ -181,4 +179,2 @@ GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *ma
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
-
if (Ringtone->Location==255) Ringtone->Location=1;
@@ -192,3 +188,3 @@ GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *ma
-GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
@@ -237,8 +233,8 @@ GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
-GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note");
+ return SIEMENS_ReplySetFunction (msg, s, "Calendar Note");
}
-GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
@@ -285,3 +281,3 @@ GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
/* (c) by Timo Teras */
-GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
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
@@ -13,4 +13,4 @@
-extern GSM_Reply_Function ATGENReplyFunctions[];
-extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
+#include "atgen.h"
+#include "sonyeric.h"
@@ -18,8 +18,6 @@ extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
-extern GSM_Reply_Function OBEXGENReplyFunctions[];
-extern GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File);
-extern GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos);
-extern GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s);
+#include "../obex/obexgen.h"
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+extern GSM_Reply_Function OBEXGENReplyFunctions[];
+extern GSM_Reply_Function ATGENReplyFunctions[];
@@ -128,3 +126,3 @@ GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -164,3 +162,3 @@ GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool st
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -203,3 +201,3 @@ GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -234,3 +232,3 @@ GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
unsigned char req[5000];
@@ -250,3 +248,3 @@ GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
@@ -269,3 +267,3 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -321,3 +319,3 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -376,3 +374,3 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
@@ -405,3 +403,114 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
-#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;
+ case 2: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '-';
+ break;
+ case 3: locale->DateFormat = GSM_Date_MMDDYY;
+ locale->DateSeparator = '/';
+ break;
+ case 4: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '/';
+ break;
+ case 5: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '.';
+ break;
+ case 6: locale->DateFormat = GSM_Date_YYMMDD;
+ locale->DateSeparator = 0;
+ break;
+ case 7: locale->DateFormat = GSM_Date_YYMMDD;
+ locale->DateSeparator = '-';
+ break;
+ default:return ERR_UNKNOWNRESPONSE;
+ }
+ default:
+ return ERR_NOTSUPPORTED;
+ }
+}
+
+GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{ /* Author: Peter Ondraska
+ 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.
+ */
+ char format;
+
+ switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Time settings received\n");
+ format=atoi(msg.Buffer);
+ switch (format) {
+ case 1:
+ case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
+ return ERR_NONE;
+ default:return ERR_UNKNOWNRESPONSE;
+ }
+ default: return ERR_NOTSUPPORTED;
+ }
+}
+
+GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ GSM_Error error;
+
+ s->Phone.Data.Locale = locale;
+
+ smprintf(s, "Getting date format\n");
+ error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
+ if (error!=ERR_NONE) return error;
+
+ smprintf(s, "Getting time format\n");
+ return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
+}
+
+
+GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{ /* Author: Peter Ondraska
+ 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.
+ */
+ /* this is not yet supported by gammu.c */
+ int format=0;
+ char req[12];
+
+ if (locale->DateFormat==GSM_Date_OFF) { format=0; } else
+ if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
+ if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else
+ if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
+ if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
+ else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
+
+ sprintf(req,"AT+ESDF=%i\r",format);
+ smprintf(s, "Setting date format\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
+
+ if (locale->AMPMTime) { format=2; } else { format=1; }
+ sprintf(req,"AT+ESTF=%i\r",format);
+ smprintf(s, "Setting time format\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
+}
+
#endif
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c
index beef33c..17cd0a4 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.c
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c
@@ -1,4 +1,7 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */
/* resetting DCT4 phones settings (c) by Walek */
+/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -396,2 +399,3 @@ GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
Data->SMSC->Validity.Relative = msg.Buffer[8];
+ if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
@@ -444,3 +448,3 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
smprintf(s, "Network info received\n");
- smprintf(s, " Status : ");
+ smprintf(s, "Status : ");
switch (msg.Buffer[8]) {
@@ -453,3 +457,3 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
smprintf(s, "\n");
- smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
+ smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
if (msg.Buffer[8]<0x03) {
@@ -461,4 +465,4 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
- smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
+ smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
smprintf(s, "Network name for Gammu : %s ",
@@ -1210,3 +1214,3 @@ GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
smprintf(s, "SMS sent OK\n");
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]);
return ERR_NONE;
@@ -1214,3 +1218,3 @@ GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
smprintf(s, "Error %i\n",msg.Buffer[6]);
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1);
return ERR_NONE;
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h
index 66b67ec..18b2026 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.h
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h
@@ -5,2 +5,4 @@
+#include "../ncommon.h"
+
GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s);
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c
index 263d12b..dac6c12 100644
--- a/gammu/emb/common/phone/nokia/dct3/n6110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.c
@@ -1,5 +1,7 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail and Gnokii */
-/* Authentication function (c) 1999 or earlier by Pavel Janik */
/* 5210 calendar IDs by Frederick Ros */
+/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -129,2 +131,3 @@ static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const
+/* Pavel Janik */
/* This function provides Nokia authentication protocol.
@@ -826,2 +829,3 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
@@ -1526,2 +1530,3 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
@@ -1563,2 +1568,3 @@ static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
@@ -2445,4 +2451,4 @@ GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
- tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer);
- msg.Buffer[tmp] = 0;
+ tmp=GSM_UnpackEightBitsToSeven(0, msg.Buffer[7], 82, msg.Buffer+8, buffer);
+ buffer[tmp] = 0;
@@ -2809,2 +2815,3 @@ GSM_Phone_Functions N6110Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOKIA_SetIncomingSMS,
@@ -2863,3 +2870,3 @@ GSM_Phone_Functions N6110Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
N6110_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
index 5a02c9c..b597f9b 100644
--- a/gammu/emb/common/phone/nokia/dct3/n7110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -1,3 +1,6 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail and Gnokii */
+/* based on some Markus Plail work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
@@ -528,2 +531,3 @@ static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
@@ -1649,2 +1653,3 @@ GSM_Phone_Functions N7110Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
N7110_SetIncomingSMS,
@@ -1703,3 +1708,3 @@ GSM_Phone_Functions N7110Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
N7110_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
index e82d530..ff71ad3 100644
--- a/gammu/emb/common/phone/nokia/dct3/n9210.c
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -321,2 +321,3 @@ GSM_Phone_Functions N9210Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
N9210_SetIncomingSMS,
@@ -375,3 +376,3 @@ GSM_Phone_Functions N9210Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTIMPLEMENTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c
index 51e6f18..9b1d6cd 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3320.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3320.c
@@ -196,2 +196,3 @@ GSM_Phone_Functions N3320Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
@@ -250,3 +251,3 @@ GSM_Phone_Functions N3320Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3650.c b/gammu/emb/common/phone/nokia/dct4/n3650.c
index 2da55bf..d4746a7 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3650.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3650.c
@@ -317,2 +317,3 @@ GSM_Phone_Functions N3650Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
@@ -371,3 +372,3 @@ GSM_Phone_Functions N3650Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c
index 67fe492..2208def 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.c
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.c
@@ -1,3 +1,6 @@
/* (c) 2002-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail, Pawel Kot and Gnokii */
+/* based on some Markus Plail, Pawel Kot work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
@@ -121,2 +124,4 @@ static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *
Data->SMSC->Validity.Relative = msg.Buffer[12];
+ if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
+
current = 14;
@@ -267,3 +272,3 @@ static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMa
- smprintf(s, "Network status: ");
+ smprintf(s, "Network status : ");
switch (msg.Buffer[8]) {
@@ -987,2 +992,3 @@ static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateM
smprintf(s, "Operator logo received\n");
+ if (msg.Length == 18) return ERR_EMPTY;
NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode);
@@ -991,3 +997,2 @@ static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateM
Data->Bitmap->BitmapHeight = msg.Buffer[21];
- if (msg.Length == 18) return ERR_EMPTY;
PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap);
@@ -1767,3 +1772,4 @@ static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings
settings->Name[1] = 0;
-// s->Phone.Data.SyncMLSettings = settings;
+ s->Phone.Data.SyncMLSettings = settings;
+
// smprintf(s, "Getting SyncML settings name\n");
@@ -2285,3 +2291,3 @@ static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMa
case 0x00:
- smprintf(s, "SMS sent OK, TPMR for sent sms is %02x\n",msg.Buffer[10]);
+ smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]);
if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]);
@@ -2772,2 +2778,3 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
@@ -2988,2 +2995,5 @@ static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
}
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
+ return ERR_NOTSUPPORTED;
+ }
@@ -3117,5 +3127,17 @@ static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow
{
+ unsigned int pos2 = 15;
unsigned int pos = 4;
+ unsigned char req2[100] = {N6110_FRAME_HEADER,0x01,
+ 0x00,0x02,0x07,0x04,
+ 0x01, // 1 - voice, 2 - data
+ 0x00,0x03,
+ 0x18, // length of rest + 1
+ 0x00,0x00,0x00};
unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
0x0c}; /* Number length */
+ GSM_Error error;
+
+ /* USSD not supported */
+ if (number[0] == '*') return ERR_NOTSUPPORTED;
+ if (number[0] == '#') return ERR_NOTSUPPORTED;
@@ -3142,5 +3164,17 @@ static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow
}
+ smprintf(s, "Making voice call\n");
+ error = GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
+ if (error != ERR_NOTSUPPORTED) return error;
+
+ if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
+
+ req2[11] = strlen(number)*2+6;
+ req2[pos2++] = strlen(number);
+ EncodeUnicode(req2+pos2,number,strlen(number));
+ pos2 += strlen(number)*2;
smprintf(s, "Making voice call\n");
- return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
+ error = GSM_WaitFor (s, req2, pos2, 0x01, 4, ID_DialVoice);
+ if (error == ERR_NOTSUPPORTED) return ERR_NONE;
+ return error;
}
@@ -3176,5 +3210,5 @@ static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_State
/* method 3 */
-static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, bool Calendar)
+static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, char Type)
{
- GSM_Error error;
+ GSM_Error error = ERR_UNKNOWN;
int i;
@@ -3182,3 +3216,3 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
0x00, 0x00, /* First location */
- 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style */
+ 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style, 2 = Notes */
@@ -3187,9 +3221,12 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
- if (Calendar) {
+ req[10] = Type;
+ if (Type == 0) {
smprintf(s, "Getting locations for calendar method 3\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
- } else {
- req[10] = 0x01;
+ } else if (Type == 1) {
smprintf(s, "Getting locations for ToDo method 2\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
+ } else if (Type == 2) {
+ smprintf(s, "Getting locations for Notes\n");
+ error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
}
@@ -3209,8 +3246,11 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
req[9] = Last->Location[i-1] % 256;
- if (Calendar) {
+ if (Type == 0) {
smprintf(s, "Getting locations for calendar method 3\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
- } else {
+ } else if (Type == 1) {
smprintf(s, "Getting locations for todo method 2\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
+ } else if (Type == 2) {
+ smprintf(s, "Getting locations for Notes\n");
+ error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
}
@@ -3352,2 +3392,14 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
+static GSM_Error N6510_PrivGetGenericCalendar3(GSM_StateMachine *s, int Location, GSM_Phone_RequestID ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
+ 0x00,0x99, /* Location */
+ 0xff,0xff,0xff,0xff};
+
+ req[8] = Location / 256;
+ req[9] = Location % 256;
+
+ return GSM_WaitFor (s, req, 14, 0x13, 4, ID);
+}
+
static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear)
@@ -3356,5 +3408,2 @@ static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *
GSM_DateTime date_time;
- unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
- 0x00,0x99, /* Location */
- 0xff,0xff,0xff,0xff,0x01};
@@ -3381,8 +3430,5 @@ static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *
- req[8] = Note->Location / 256;
- req[9] = Note->Location % 256;
-
s->Phone.Data.Cal=Note;
smprintf(s, "Getting calendar note method 3\n");
- return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetCalendarNote);
+ return N6510_PrivGetGenericCalendar3(s, Note->Location, ID_GetCalendarNote);
}
@@ -3396,3 +3442,3 @@ GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, b
if (start) {
- error=N6510_GetCalendarInfo3(s,LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s,LastCalendar,0);
if (error!=ERR_NONE) return error;
@@ -3479,3 +3525,3 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr
- error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
@@ -3496,3 +3542,3 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr
- error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
@@ -3739,3 +3785,3 @@ static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus
/* Method 3 */
- error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0);
if (error!=ERR_NONE) return error;
@@ -3974,2 +4020,38 @@ static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
+static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote);
+}
+
+static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Note received\n");
+ memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2);
+ s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0;
+ s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0;
+ return ERR_NONE;
+}
+
+GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start)
+{
+ GSM_Error error;
+ GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
+
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
+
+ if (start) {
+ error=N6510_GetCalendarInfo3(s,LastNote,2);
+ if (error!=ERR_NONE) return error;
+ Note->Location = 1;
+ } else {
+ Note->Location++;
+ }
+
+ if (Note->Location > LastNote->Number) return ERR_EMPTY;
+
+ s->Phone.Data.Note = Note;
+ smprintf(s, "Getting note\n");
+ return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote);
+}
+
static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
@@ -4057,3 +4139,3 @@ static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_Stat
File->Type = GSM_File_Java_JAR;
-#if DEVELOP
+#ifdef DEVELOP
else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01)
@@ -4400,3 +4482,3 @@ static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos
error = N6510_SearchForFileName(s,File);
- if (error == ERR_NONE) return ERR_INVALIDLOCATION;
+ if (error == ERR_NONE) return ERR_FILEALREADYEXIST;
if (error != ERR_EMPTY) return error;
@@ -4816,3 +4898,3 @@ static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *statu
- error = N6510_GetCalendarInfo3(s,LastToDo,false);
+ error = N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
@@ -4946,4 +5028,3 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
- if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff)
- {
+ if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) {
smprintf(s, "No alarm\n");
@@ -4980,10 +5061,5 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo
GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
- /* The same to getting calendar method 3 */
- unsigned char req[] = {
- N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
- 0x00,0x99, /* Location */
- 0xff,0xff,0xff,0xff,0x01};
if (refresh) {
- error=N6510_GetCalendarInfo3(s,LastToDo,false);
+ error=N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
@@ -4996,8 +5072,5 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo
- req[8] = LastToDo->Location[ToDo->Location-1] / 256;
- req[9] = LastToDo->Location[ToDo->Location-1] % 256;
-
s->Phone.Data.ToDo = ToDo;
smprintf(s, "Getting todo method 2\n");
- return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetToDo);
+ return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo);
}
@@ -5045,3 +5118,3 @@ static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
- error=N6510_GetCalendarInfo3(s,LastToDo,false);
+ error=N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
@@ -5453,2 +5526,5 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
@@ -5460,2 +5536,5 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame },
@@ -5510,2 +5589,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo },
+ {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote },
{N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings },
@@ -5517,2 +5597,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo },
+ {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote },
@@ -5653,3 +5734,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
GSM_Phone_Functions N6510Phone = {
- "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6800|7210|7250|7250i|7600|8310|8390|8910|8910i",
+ "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i",
N6510ReplyFunctions,
@@ -5707,2 +5788,3 @@ GSM_Phone_Functions N6510Phone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOKIA_SetIncomingSMS,
@@ -5761,3 +5843,3 @@ GSM_Phone_Functions N6510Phone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTIMPLEMENTED, /* GetNote */
+ N6510_GetNextNote,
N6510_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.h b/gammu/emb/common/phone/nokia/dct4/n6510.h
index 4717aeb..26623d6 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.h
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.h
@@ -36,2 +36,4 @@ typedef struct {
+ GSM_NOKIACalToDoLocations LastNote;
+
unsigned char RingtoneID; /* When set with preview */
diff --git a/gammu/emb/common/phone/nokia/nauto.c b/gammu/emb/common/phone/nokia/nauto.c
index bf74bc9..3bb53ec 100644
--- a/gammu/emb/common/phone/nokia/nauto.c
+++ b/gammu/emb/common/phone/nokia/nauto.c
@@ -123,3 +123,3 @@ GSM_Phone_Functions NAUTOPhone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/nfunc.c b/gammu/emb/common/phone/nokia/nfunc.c
index 3acfb10..d4d8b03 100644
--- a/gammu/emb/common/phone/nokia/nfunc.c
+++ b/gammu/emb/common/phone/nokia/nfunc.c
@@ -1395,2 +1395,7 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
break;
+ case 0x0f:
+ case 0x10:
+ smprintf(s, "Meaning not known\n");
+ call.CallIDAvailable = false;
+ break;
case 0x23:
@@ -1418,2 +1423,8 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
break;
+ case 0xA6:
+ case 0xD2:
+ case 0xD3:
+ smprintf(s, "Meaning not known\n");
+ call.CallIDAvailable = false;
+ break;
}
@@ -1424,2 +1435,5 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
}
+ if (s->Phone.Data.RequestID == ID_DialVoice) {
+ if (msg.Buffer[3] == 0x10) return ERR_NOTSUPPORTED;
+ }
if (s->Phone.Data.RequestID == ID_CancelCall) {
diff --git a/gammu/emb/common/phone/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c
index dd14f8e..3106369 100644
--- a/gammu/emb/common/phone/obex/obexgen.c
+++ b/gammu/emb/common/phone/obex/obexgen.c
@@ -776,2 +776,3 @@ GSM_Phone_Functions OBEXGENPhone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTIMPLEMENTED, /* SetIncomingSMS */
@@ -830,3 +831,3 @@ GSM_Phone_Functions OBEXGENPhone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTIMPLEMENTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/obex/obexgen.h b/gammu/emb/common/phone/obex/obexgen.h
index 466fef5..b7033de 100644
--- a/gammu/emb/common/phone/obex/obexgen.h
+++ b/gammu/emb/common/phone/obex/obexgen.h
@@ -33,2 +33,6 @@ typedef struct {
+GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File);
+GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos);
+GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s);
+
#endif
diff --git a/gammu/emb/common/phone/symbian/mroutgen.c b/gammu/emb/common/phone/symbian/mroutgen.c
index 2c339be..a7382cf 100644
--- a/gammu/emb/common/phone/symbian/mroutgen.c
+++ b/gammu/emb/common/phone/symbian/mroutgen.c
@@ -145,2 +145,3 @@ GSM_Phone_Functions MROUTERGENPhone = {
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
@@ -199,3 +200,3 @@ GSM_Phone_Functions MROUTERGENPhone = {
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/protocol/at/at.c b/gammu/emb/common/protocol/at/at.c
index f4a75b7..f8ddc06 100644
--- a/gammu/emb/common/protocol/at/at.c
+++ b/gammu/emb/common/protocol/at/at.c
@@ -68,3 +68,3 @@ static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
{"+CMTI:" ,1}, {"+CDS:" ,2},
- {"+CREG:" ,1},
+ {"+CREG:" ,1}, {"+CUSD" ,1},
@@ -74,4 +74,8 @@ static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
+ {"SDNDCRC =" ,1}, /* Samsung binary transfer end */
+
{NULL ,1}};
+//printf("%c",rx_char);
+
/* Ignore leading CR, LF and ESC */
diff --git a/gammu/emb/common/protocol/nokia/fbus2.c b/gammu/emb/common/protocol/nokia/fbus2.c
index 8b3e024..2b41f8b 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.c
+++ b/gammu/emb/common/protocol/nokia/fbus2.c
@@ -1,3 +1,7 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii and MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/protocol/nokia/fbus2.h b/gammu/emb/common/protocol/nokia/fbus2.h
index 5dd45d7..8dbcb07 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.h
+++ b/gammu/emb/common/protocol/nokia/fbus2.h
@@ -1,3 +1,7 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii and MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/protocol/nokia/mbus2.c b/gammu/emb/common/protocol/nokia/mbus2.c
index f07d6c5..8353b46 100644
--- a/gammu/emb/common/protocol/nokia/mbus2.c
+++ b/gammu/emb/common/protocol/nokia/mbus2.c
@@ -1,3 +1,3 @@
/* (c) 2001-2003 by Marcin Wiacek */
-/* based on some work from MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
diff --git a/gammu/emb/common/protocol/nokia/mbus2.h b/gammu/emb/common/protocol/nokia/mbus2.h
index 86fcab6..5dbd8cb 100644
--- a/gammu/emb/common/protocol/nokia/mbus2.h
+++ b/gammu/emb/common/protocol/nokia/mbus2.h
@@ -1,3 +1,3 @@
/* (c) 2001-2003 by Marcin Wiacek */
-/* based on some work from MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
diff --git a/gammu/emb/common/protocol/nokia/phonet.c b/gammu/emb/common/protocol/nokia/phonet.c
index bc5717d..db5bd72 100644
--- a/gammu/emb/common/protocol/nokia/phonet.c
+++ b/gammu/emb/common/protocol/nokia/phonet.c
@@ -1,3 +1,6 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/protocol/nokia/phonet.h b/gammu/emb/common/protocol/nokia/phonet.h
index 2f6e836..e750bbd 100644
--- a/gammu/emb/common/protocol/nokia/phonet.h
+++ b/gammu/emb/common/protocol/nokia/phonet.h
@@ -1,3 +1,6 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h
index 9d7d973..9a930fc 100644
--- a/gammu/emb/common/service/backup/backgen.h
+++ b/gammu/emb/common/service/backup/backgen.h
@@ -23,2 +23,4 @@
#define GSM_BACKUP_MAX_MMSSETTINGS 30
+#define GSM_BACKUP_MAX_SYNCMLSETTINGS 10
+#define GSM_BACKUP_MAX_CHATSETTINGS 10
#define GSM_BACKUP_MAX_RINGTONES 30
@@ -45,2 +47,4 @@ typedef struct {
GSM_MultiWAPSettings *MMSSettings [GSM_BACKUP_MAX_MMSSETTINGS + 1];
+ GSM_SyncMLSettings *SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
+ GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
GSM_Ringtone *Ringtone [GSM_BACKUP_MAX_RINGTONES + 1];
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index fee0f73..4cb1bb7 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -153,3 +153,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
- fwrite(myvalue,1,UnicodeLength(myvalue)*2,file);
+ fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
@@ -159,3 +159,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
} else {
- sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10);
+ sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
fprintf(file,"%s",buffer);
@@ -170,3 +170,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
{
- unsigned char paramname[10000],*readvalue;
+ unsigned char paramname[10000],*readvalue;
@@ -176,5 +176,6 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
if (readvalue!=NULL) {
- CopyUnicodeString(myvalue,readvalue+2);
- myvalue[UnicodeLength(readvalue)*2-4]=0;
- myvalue[UnicodeLength(readvalue)*2-3]=0;
+ CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
+ myvalue[UnicodeLength(myvalue)*2-2]=0;
+ myvalue[UnicodeLength(myvalue)*2-1]=0;
+
dbgprintf("%s\n",DecodeUnicodeString(readvalue));
@@ -199,3 +200,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
if (readvalue!=NULL) {
- EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2);
+ EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
} else {
@@ -420,2 +421,13 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
+static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
+{
+ char buffer[1000];
+
+ sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveBackupText(file, "Text", Note->Text, UseUnicode);
+ sprintf(buffer, "%c%c",13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+}
+
static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
@@ -435,5 +447,5 @@ static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnico
case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
- case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
+ case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
- case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
+ case GSM_CAL_DAILY_ALARM: sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
@@ -659,2 +671,44 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
+static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"HomePage");
+ SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
+static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ sprintf(buffer,"PhonebookDB");
+ SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
+ sprintf(buffer,"CalendarDB");
+ SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
+ sprintf(buffer,"Server");
+ SaveBackupText(file, buffer, settings->Server, UseUnicode);
+ if (settings->SyncPhonebook) {
+ sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ if (settings->SyncCalendar) {
+ sprintf(buffer,"SyncCalendar = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncCalendar = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
@@ -766,4 +820,3 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
{
- unsigned char buffer[45000];
- int i,j;
+ unsigned char buffer[45000];
@@ -774,3 +827,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
case RING_NOKIABINARY:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -779,3 +831,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
case RING_MIDI:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -783,2 +834,6 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
break;
+ case RING_MMF:
+ EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
+ SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
+ break;
case RING_NOTETONE:
@@ -1077,2 +1132,9 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
i=0;
+ while (backup->Note[i]!=NULL) {
+ sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveNoteEntry(file, backup->Note[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->CallerLogos[i]!=NULL) {
@@ -1112,2 +1174,16 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
@@ -2658,3 +2734,128 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
}
-
+ for (h = file_info; h != NULL; h = h->Next) {
+ found = false;
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Backup",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Checksum",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Profile",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"PhonePBK",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SIMPBK",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Calendar",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Caller",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SMSC",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPBookmark",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Bookmark",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPSettings",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Settings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"MMSSettings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Ringtone",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"TODO",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Startup",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Operator",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"FMStation",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"GPRSPoint",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Note",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
+ }
+ if (!found) return ERR_NOTIMPLEMENTED;
+ }
return ERR_NONE;
diff --git a/gammu/emb/common/service/backup/gsmback.c b/gammu/emb/common/service/backup/gsmback.c
index 91ac745..c94a4d2 100644
--- a/gammu/emb/common/service/backup/gsmback.c
+++ b/gammu/emb/common/service/backup/gsmback.c
@@ -75,2 +75,14 @@ void GSM_FreeBackup(GSM_Backup *backup)
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ free(backup->SyncMLSettings[i]);
+ backup->SyncMLSettings[i] = NULL;
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ free(backup->ChatSettings[i]);
+ backup->ChatSettings[i] = NULL;
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
@@ -122,11 +134,11 @@ GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode
{
- if (strstr(FileName,".lmb")) {
+ if (mystrcasestr(FileName,".lmb")) {
return SaveLMB(FileName,backup);
- } else if (strstr(FileName,".vcs")) {
+ } else if (mystrcasestr(FileName,".vcs")) {
return SaveVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return SaveVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return SaveLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return SaveICS(FileName,backup);
@@ -150,9 +162,9 @@ GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
/* Attempt to identify filetype */
- if (strstr(FileName,".vcs")) {
+ if (mystrcasestr(FileName,".vcs")) {
return LoadVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return LoadVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return LoadLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return LoadICS(FileName,backup);
@@ -179,2 +191,4 @@ void GSM_ClearBackup(GSM_Backup *backup)
backup->MMSSettings [0] = NULL;
+ backup->SyncMLSettings [0] = NULL;
+ backup->ChatSettings [0] = NULL;
backup->Ringtone [0] = NULL;
@@ -211,2 +225,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
info->MMSSettings = false;
+ info->SyncMLSettings = false;
+ info->ChatSettings = false;
info->Ringtone = false;
@@ -248,2 +264,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
info->MMSSettings = true;
+ info->SyncMLSettings = true;
+ info->ChatSettings = true;
info->Ringtone = true;
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h
index 1fd99b0..791e81d 100644
--- a/gammu/emb/common/service/backup/gsmback.h
+++ b/gammu/emb/common/service/backup/gsmback.h
@@ -31,2 +31,4 @@ typedef struct {
bool MMSSettings;
+ bool SyncMLSettings;
+ bool ChatSettings;
bool Ringtone;
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h
index 067a4a4..0a41b7b 100644
--- a/gammu/emb/common/service/gsmcal.h
+++ b/gammu/emb/common/service/gsmcal.h
@@ -407,3 +407,3 @@ typedef struct {
int Location;
- char Text[100];
+ char Text[3000*2];
} GSM_NoteEntry;
diff --git a/gammu/emb/common/service/gsmdata.c b/gammu/emb/common/service/gsmdata.c
index 94e9b7b..9303b57 100644
--- a/gammu/emb/common/service/gsmdata.c
+++ b/gammu/emb/common/service/gsmdata.c
@@ -248,2 +248,4 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
/* http://forum.nokia.com: OTA Settings 7.0 */
+/* first it used default/ISO coding */
+/* Joergen Thomsen changed to UTF8 */
void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark)
@@ -251,6 +253,6 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
unsigned char buffer[100];
- bool UnicodeCoding = false;
- EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
- if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
+// bool UnicodeCoding = false;
+// EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
+// if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
@@ -267,11 +269,18 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
+ /* removed by Joergen Thomsen */
/* Block from sniffs. UNKNOWN */
- if (!UnicodeCoding) {
- Buffer[(*Length)++] = 0x00;
- Buffer[(*Length)++] = 0x01;
- } else {
- strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
- (*Length)=(*Length)+4;
- }
- Buffer[(*Length)++] = 0x00;
+// if (!UnicodeCoding) {
+// Buffer[(*Length)++] = 0x00;
+// Buffer[(*Length)++] = 0x01;
+// } else {
+// strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
+// (*Length)=(*Length)+4;
+// }
+// Buffer[(*Length)++] = 0x00;
+
+ /* added by Joergen Thomsen */
+ Buffer[(*Length)++] = 0x01; // Version WBXML 1.1
+ Buffer[(*Length)++] = 0x01; // Unknown public identifier
+ Buffer[(*Length)++] = 0x6A; // charset UTF-8
+ Buffer[(*Length)++] = 0x00; // string table length
@@ -282,15 +291,84 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
Buffer[(*Length)++] = 0x01; //END PARMeter
- if (!UnicodeCoding) {
- /* TITLE */
- AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
- /* URL */
- AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
- } else {
- /* TITLE */
- AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
- /* URL */
- AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
+
+ /* removed by Joergen Thomsen */
+// if (!UnicodeCoding) {
+// /* TITLE */
+// AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
+// /* URL */
+// AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
+// } else {
+// /* TITLE */
+// AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
+// /* URL */
+// AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
+// }
+
+ /* added by Joergen Thomsen */
+ /* TITLE */
+ EncodeUTF8(buffer, bookmark->Title);
+ AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
+ /* URL */
+ EncodeUTF8(buffer, bookmark->Address);
+ AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
+
+ Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC)
+ Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST)
+}
+
+void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL)
+{
+ int i;
+
+ Buffer[(*Length)++] = 0x01; //Push ID
+ Buffer[(*Length)++] = 0x06; //PDU Type (push)
+ Buffer[(*Length)++] = 28; //Headers length (content type + headers)
+ strcpy(Buffer+(*Length),"\x1F\x23");
+ (*Length)=(*Length)+2; //Value length
+ strcpy(Buffer+(*Length),"application/vnd.wap.sic");
+ (*Length)=(*Length)+23; //MIME-Type
+ Buffer[(*Length)++] = 0x00; //end inline string
+ strcpy(Buffer+(*Length),"\x81\xEA");
+ (*Length)=(*Length)+2; //charset UTF-8 short int.
+
+ Buffer[(*Length)++] = 0x02; // WBXML 1.2
+ Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier
+ Buffer[(*Length)++] = 0x6A; // charset UTF-8
+ Buffer[(*Length)++] = 0x00; // string table length
+ Buffer[(*Length)++] = 0x45; // SI with content
+ Buffer[(*Length)++] = 0xC6; // indication with content and attributes
+ Buffer[(*Length)++] = 0x0B; // address
+ Buffer[(*Length)++] = 0x03; // Inline string
+ for (i=0;i<(int)strlen(URL);i++) {
+ Buffer[(*Length)++] = URL[i];//Text
}
- Buffer[(*Length)++] = 0x01; //END PARMeter
- Buffer[(*Length)++] = 0x01; //END PARMeter
+ Buffer[(*Length)++] = 0x00; // END Inline string
+
+#ifdef XXX
+ Buffer[(*Length)++] = 0x0A; // created...
+ Buffer[(*Length)++] = 0xC3; // OPAQUE
+ Buffer[(*Length)++] = 0x07; // length
+ Buffer[(*Length)++] = 0x19; // year
+ Buffer[(*Length)++] = 0x80; // year
+ Buffer[(*Length)++] = 0x21; // month
+ Buffer[(*Length)++] = 0x12; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x10; // expires
+ Buffer[(*Length)++] = 0xC3; // OPAQUE
+ Buffer[(*Length)++] = 0x04; // length
+ Buffer[(*Length)++] = 0x20; // year
+ Buffer[(*Length)++] = 0x10; // year
+ Buffer[(*Length)++] = 0x06; // month
+ Buffer[(*Length)++] = 0x25; // day
+#endif
+
+ Buffer[(*Length)++] = 0x01; // END (indication)
+ Buffer[(*Length)++] = 0x03; // Inline string
+ for (i=0;i<(int)strlen(Text);i++) {
+ Buffer[(*Length)++] = Text[i]; //Text
+ }
+ Buffer[(*Length)++] = 0x00; // END Inline string
+ Buffer[(*Length)++] = 0x01; // END (indication)
+ Buffer[(*Length)++] = 0x01; // END (SI)
}
diff --git a/gammu/emb/common/service/gsmdata.h b/gammu/emb/common/service/gsmdata.h
index f5f8e07..e81589f 100644
--- a/gammu/emb/common/service/gsmdata.h
+++ b/gammu/emb/common/service/gsmdata.h
@@ -90,2 +90,4 @@ void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIn
+void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
+
/* ------------------------------ MMS file --------------------------------- */
diff --git a/gammu/emb/common/service/gsmlogo.c b/gammu/emb/common/service/gsmlogo.c
index c992915..7c19967 100644
--- a/gammu/emb/common/service/gsmlogo.c
+++ b/gammu/emb/common/service/gsmlogo.c
@@ -4,2 +4,3 @@
#include <stdlib.h>
+#include <sys/stat.h>
@@ -163,2 +164,3 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
Bitmap->ID = 0;
+ Bitmap->Name = NULL;
@@ -628,13 +630,13 @@ GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
/* Attempt to identify filetype */
- if (strstr(FileName,".nlm")) {
+ if (mystrcasestr(FileName,".nlm")) {
error=savenlm(file,bitmap);
- } else if (strstr(FileName,".ngg")) {
+ } else if (mystrcasestr(FileName,".ngg")) {
error=savengg(file,bitmap);
- } else if (strstr(FileName,".nol")) {
+ } else if (mystrcasestr(FileName,".nol")) {
error=savenol(file,bitmap);
- } else if (strstr(FileName,".xpm")) {
+ } else if (mystrcasestr(FileName,".xpm")) {
error=savexpm(file,bitmap);
- } else if (strstr(FileName,".nsl")) {
+ } else if (mystrcasestr(FileName,".nsl")) {
error=savensl(file,bitmap);
- } else if (strstr(FileName,".wbmp")) {
+ } else if (mystrcasestr(FileName,".wbmp")) {
error=savewbmp(file,bitmap);
@@ -957,2 +959,29 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
+static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
+{
+ GSM_Bitmap *bmap = &bitmap->Bitmap[0];
+ char *buffer;
+ struct stat st;
+ int length;
+
+ dbgprintf("loading gif file\n");
+ fstat(fileno(file), &st);
+ bmap->BinaryPic.Length = length = st.st_size;
+ bmap->BinaryPic.Buffer = buffer = malloc(length);
+ if (bmap->BinaryPic.Buffer == NULL)
+ return ERR_MOREMEMORY;
+
+ fread(buffer, 1, length, file);
+ dbgprintf("Length %i name \"%s\"\n", length,
+ DecodeUnicodeString(bmap->Name));
+
+ bmap->Type = GSM_PictureBinary;
+ bmap->BinaryPic.Type = PICTURE_GIF;
+ bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
+ bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
+ bitmap->Number = 1;
+
+ return ERR_NONE;
+}
+
GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
@@ -965,2 +994,6 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
+ bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2);
+ if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY;
+ EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName));
+
fread(buffer, 1, 9, file); /* Read the header of the file. */
@@ -983,2 +1016,4 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
return loadnsl(file,bitmap);
+ } else if (memcmp(buffer, "GIF",3)==0) {
+ return loadgif(file,bitmap);
}
diff --git a/gammu/emb/common/service/gsmlogo.h b/gammu/emb/common/service/gsmlogo.h
index b1b579d..6c6e2d8 100644
--- a/gammu/emb/common/service/gsmlogo.h
+++ b/gammu/emb/common/service/gsmlogo.h
@@ -7,2 +7,16 @@
+typedef enum {
+ PICTURE_BMP = 1,
+ PICTURE_GIF,
+ PICTURE_JPG,
+ PICTURE_ICN,
+ PICTURE_PNG
+} GSM_BinaryPicture_Types;
+
+typedef struct {
+ GSM_BinaryPicture_Types Type;
+ unsigned char *Buffer;
+ int Length;
+} GSM_BinaryPicture;
+
/**
@@ -47,3 +61,7 @@ typedef enum {
*/
- GSM_PictureImage
+ GSM_PictureImage,
+ /**
+ * Binary picture (BMP, GIF, etc.)
+ */
+ GSM_PictureBinary
} GSM_Bitmap_Types;
@@ -117,2 +135,10 @@ typedef struct {
unsigned char ID;
+ /**
+ * For binary pictures (GIF, BMP, etc.): frame and length
+ */
+ GSM_BinaryPicture BinaryPic;
+ /**
+ * Bitmap name
+ */
+ char *Name;
} GSM_Bitmap;
diff --git a/gammu/emb/common/service/gsmmisc.h b/gammu/emb/common/service/gsmmisc.h
index 37501ad..793d3d1 100644
--- a/gammu/emb/common/service/gsmmisc.h
+++ b/gammu/emb/common/service/gsmmisc.h
@@ -294,3 +294,8 @@ typedef enum {
GSM_Date_MMDDYYYY,
- GSM_Date_YYYYMMDD
+ GSM_Date_YYYYMMDD,
+ GSM_Date_DDMMMYY,
+ GSM_Date_MMDDYY,
+ GSM_Date_DDMMYY,
+ GSM_Date_YYMMDD,
+ GSM_Date_OFF
} GSM_DateFormat;
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,4 +1,6 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* Based on some work from Ralf Thelen (7110 ringtones),
- * Gnokii (RTTL and SM) and others
+/* Based on some work from Ralf Thelen (7110 ringtones) and others */
+/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
*/
@@ -9,2 +11,3 @@
#include <math.h>
+#include <sys/stat.h>
#ifdef WIN32
@@ -158,2 +161,8 @@ static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
+static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
+ return ERR_NONE;
+}
+
GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
@@ -487,2 +496,5 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
break;
+ case RING_MMF:
+ savemmf(file, ringtone);
+ break;
}
@@ -771,2 +783,22 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
+static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ struct stat st;
+ char *buffer;
+ int length;
+
+ dbgprintf("loading smaf file\n");
+ fstat(fileno(file), &st);
+ ringtone->BinaryTone.Length = length = st.st_size;
+ ringtone->BinaryTone.Buffer = buffer = malloc(length);
+ if (buffer == NULL)
+ return ERR_MOREMEMORY;
+ fread(buffer, 1, length, file);
+
+ dbgprintf("Length %i name \"%s\"\n", length,
+ DecodeUnicodeString(ringtone->Name));
+
+ return ERR_NONE;
+}
+
static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
@@ -818,2 +850,6 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
}
+ if (buffer[0]==0x4D && buffer[1]==0x4D &&
+ buffer[2]==0x4D && buffer[3]==0x44) {
+ ringtone->Format = RING_MMF;
+ }
}
@@ -844,2 +880,7 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
error = loadpuremidi(file,ringtone);
+ break;
+ case RING_MMF:
+ EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
+ error = loadmmf(file,ringtone);
+ break;
}
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
index 207cf31..2d2dd7a 100644
--- a/gammu/emb/common/service/gsmring.h
+++ b/gammu/emb/common/service/gsmring.h
@@ -122,5 +122,6 @@ typedef struct {
+/* FIXME: should use BinaryTone instead? */
/* Structure to hold Nokia binary ringtones. */
typedef struct {
- unsigned char Frame[30000];
+ unsigned char Frame[50000];
int Length;
@@ -129,3 +130,3 @@ typedef struct {
typedef struct {
- unsigned char *Frame;
+ unsigned char *Buffer;
int Length;
@@ -136,3 +137,4 @@ typedef enum {
RING_NOKIABINARY,
- RING_MIDI
+ RING_MIDI,
+ RING_MMF
} GSM_RingtoneFormat;
diff --git a/gammu/emb/common/service/sms/gsmmulti.c b/gammu/emb/common/service/sms/gsmmulti.c
index 6c1cdcd..bdb5ee9 100644
--- a/gammu/emb/common/service/sms/gsmmulti.c
+++ b/gammu/emb/common/service/sms/gsmmulti.c
@@ -489,2 +489,7 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
break;
+ case SMS_WAPIndicatorLong:
+ Class = 1;
+ UDH = UDH_MMSIndicatorLong;
+ GSM_EncodeWAPIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator->Title,Info->Entries[0].MMSIndicator->Address);
+ break;
case SMS_NokiaRingtoneLong:
diff --git a/gammu/emb/common/service/sms/gsmmulti.h b/gammu/emb/common/service/sms/gsmmulti.h
index c672261..3f70d81 100644
--- a/gammu/emb/common/service/sms/gsmmulti.h
+++ b/gammu/emb/common/service/sms/gsmmulti.h
@@ -5,2 +5,6 @@
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include "../../gsmcomon.h"
@@ -174,3 +178,3 @@ typedef enum {
SMS_EMSSound10Long,
- /***
+ /**
* IMelody 1.2 with UPI.
@@ -192,2 +196,3 @@ typedef enum {
SMS_MMSIndicatorLong,
+ SMS_WAPIndicatorLong,
/**
@@ -266,2 +271,6 @@ GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT,
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
+
#endif
diff --git a/gammu/emb/common/service/sms/gsmsms.c b/gammu/emb/common/service/sms/gsmsms.c
index 9920835..feceba4 100644
--- a/gammu/emb/common/service/sms/gsmsms.c
+++ b/gammu/emb/common/service/sms/gsmsms.c
@@ -1,3 +1,6 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Pawel Kot, others and Gnokii */
+/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/common/service/sms/gsmsms.h b/gammu/emb/common/service/sms/gsmsms.h
index d87ff60..0b950d3 100644
--- a/gammu/emb/common/service/sms/gsmsms.h
+++ b/gammu/emb/common/service/sms/gsmsms.h
@@ -1,3 +1,6 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Pawel Kot, others and Gnokii */
+/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3.c b/gammu/emb/gammu/depend/nokia/dct3.c
index d4a55da..b9e47ea 100644
--- a/gammu/emb/gammu/depend/nokia/dct3.c
+++ b/gammu/emb/gammu/depend/nokia/dct3.c
@@ -612,6 +612,10 @@ void DCT3GetSecurityCode(int argc, char *argv[])
{
+#ifdef GSM_ENABLE_NOKIA6110
unsigned char req6110[] = {0x00, 0x01, 0x6e,
0x01}; /* Code type */
+#endif
+#if defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee,
0x1c}; /* Setting */
+#endif
@@ -769,4 +773,6 @@ void DCT3DisplayOutput(int argc, char *argv[])
static GSM_Reply_Function UserReplyFunctions3[] = {
+#ifdef GSM_ENABLE_NOKIA6110
{DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame },
{DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 },
+#endif
diff --git a/gammu/emb/gammu/depend/nokia/dct4.c b/gammu/emb/gammu/depend/nokia/dct4.c
index f4ed305..4bf958d 100644
--- a/gammu/emb/gammu/depend/nokia/dct4.c
+++ b/gammu/emb/gammu/depend/nokia/dct4.c
@@ -37,3 +37,4 @@ GSM_Error CheckDCT4Only()
s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE &&
- s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET) {
+ s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET &&
+ s.ConnectionType!=GCT_FBUS2DKU5) {
return ERR_OTHERCONNECTIONREQUIRED;
@@ -887,2 +888,4 @@ void DCT4GetT9(int argc, char *argv[])
+#ifdef GSM_ENABLE_NOKIA6510
+
extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable);
@@ -923,2 +926,3 @@ void DCT4SetLight(int argc, char *argv[])
}
+#endif
@@ -1023,2 +1027,4 @@ void DCT4GetADC(int argc, char *argv[])
+#ifdef GSM_ENABLE_NOKIA6510
+
static double RadioFreq;
@@ -1176,2 +1182,3 @@ void DCT4TuneRadio(int argc, char *argv[])
}
+#endif
@@ -1315,2 +1322,3 @@ static GSM_Reply_Function UserReplyFunctions4[] = {
+#ifdef GSM_ENABLE_NOKIA6510
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3 },
@@ -1319,2 +1327,3 @@ static GSM_Reply_Function UserReplyFunctions4[] = {
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3 },
+#endif
diff --git a/gammu/emb/gammu/depend/nokia/dct4.h b/gammu/emb/gammu/depend/nokia/dct4.h
index fde5b08..fae809f 100644
--- a/gammu/emb/gammu/depend/nokia/dct4.h
+++ b/gammu/emb/gammu/depend/nokia/dct4.h
@@ -8,5 +8,2 @@ void DCT4SetVibraLevel (int argc, char *argv[]);
void DCT4GetSecurityCode (int argc, char *argv[]);
-#ifdef DEBUG
-void DCT4ResetSecurityCode (int argc, char *argv[]);
-#endif
void DCT4GetVoiceRecord (int argc, char *argv[]);
@@ -14,3 +11,2 @@ void DCT4Info (int argc, char *argv[]);
void DCT4GetT9 (int argc, char *argv[]);
-void DCT4SetLight (int argc, char *argv[]);
void DCT4DisplayTest (int argc, char *argv[]);
@@ -18,3 +14,2 @@ void DCT4GetADC (int argc, char *argv[]);
void DCT4VibraTest (int argc, char *argv[]);
-void DCT4TuneRadio (int argc, char *argv[]);
void DCT4PlaySavedRingtone (int argc, char *argv[]);
@@ -23,2 +18,10 @@ void DCT4GetScreenDump (int argc, char *argv[]);
+#ifdef DEBUG
+ void DCT4ResetSecurityCode (int argc, char *argv[]);
+#endif
+#ifdef GSM_ENABLE_NOKIA6510
+ void DCT4SetLight (int argc, char *argv[]);
+ void DCT4TuneRadio (int argc, char *argv[]);
+#endif
+
/* ------------------- features matrix ------------------------------------- */
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index 997485a..f49ae36 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -11,3 +11,2 @@
#include <wchar.h>
-#undef HAVE_MYSQL_MYSQL_H
#ifdef WIN32
@@ -50,23 +49,11 @@
-//static GSM_StateMachine s;
-//static GSM_Phone_Functions *Phone;
+GSM_StateMachine s;
+GSM_Phone_Functions *Phone;
static INI_Section *cfg = NULL;
-//static GSM_Error error = ERR_NONE;
- static int i;
+GSM_Error error = ERR_NONE;
+static int i;
-//static bool gshutdown = false;
-typedef struct {
- unsigned char Connection[50];
-} OneConnectionInfo;
+volatile bool gshutdown = false;
-typedef struct {
- unsigned char Device[50];
- OneConnectionInfo Connections[6];
- //GSM_StateMachine s;
-} OneDeviceInfo;
-
-static int num;
-static OneDeviceInfo SearchDevices[100];
-static bool SearchOutput;
void interrupt(int sign)
@@ -245,2 +232,3 @@ static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
}
+
static void PlayRingtone(int argc, char *argv[])
@@ -343,3 +331,2 @@ static void Identify(int argc, char *argv[])
-//#if 0
static void GetDateTime(int argc, char *argv[])
@@ -377,2 +364,3 @@ static void GetDateTime(int argc, char *argv[])
case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
+ default :break;
}
@@ -589,4 +577,5 @@ static void GetMemory(int argc, char *argv[])
{
- int j, start, stop;
+ int j, start, stop, emptynum = 0, fillednum = 0;
GSM_MemoryEntry entry;
+ bool empty = true;
@@ -609,2 +598,11 @@ static void GetMemory(int argc, char *argv[])
+ if (argc > 5 && strcmp(argv[5],"")) {
+ if (mystrncasecmp(argv[5],"-nonempty",0)) {
+ empty = false;
+ } else {
+ printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]);
+ exit (-1);
+ }
+ }
+
GSM_Init(true);
@@ -616,3 +614,3 @@ static void GetMemory(int argc, char *argv[])
for (j=start;j<=stop;j++) {
- printmsg("Memory %s, Location %i\n",argv[2],j);
+ if (empty) printmsg("Memory %s, Location %i\n",argv[2],j);
@@ -624,5 +622,10 @@ static void GetMemory(int argc, char *argv[])
if (error == ERR_EMPTY) {
- printmsg("Entry is empty\n");
- printf("\n");
+ emptynum++;
+ if (empty) {
+ printmsg("Entry is empty\n");
+ printf("\n");
+ }
} else {
+ fillednum++;
+ if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j);
PrintMemoryEntry(&entry);
@@ -630,2 +633,4 @@ static void GetMemory(int argc, char *argv[])
}
+
+ printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
@@ -676,3 +681,3 @@ static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
case PBK_Caller_Group :
- if (mystrstr(Entry->Entries[i].Text, Text) != NULL) {
+ if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) {
fprintf(stderr,"\n");
@@ -826,3 +831,3 @@ static void ListMemoryCategory(int argc, char *argv[])
count++;
- if (mystrstr(Category.Name, Text) != NULL) {
+ if (mywstrstr(Category.Name, Text) != NULL) {
ListMemoryCategoryEntries(j);
@@ -849,3 +854,3 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
- printmsg("Reference number: 0x%02X\n",sms.MessageReference);
+ printmsg("Reference number: %d\n",sms.MessageReference);
printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
@@ -896,5 +901,9 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
printmsg("SMS message\n");
- printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
- if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
- printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true));
+ } else {
+ printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
+ if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
+ printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
+ }
/* No break. The only difference for SMS_Deliver and SMS_Submit is,
@@ -908,3 +917,6 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
printmsg("SMS message\n");
- printmsg("Reference number : 0x%02X\n",sms.MessageReference);
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ } else {
+ printmsg("Reference number : %d\n",sms.MessageReference);
+ }
}
@@ -922,10 +934,13 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
}
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ } else {
+ printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
+ }
printmsg("Status : ");
switch (sms.State) {
- case SMS_Sent : printmsg("Sent"); break;
- case SMS_Read : printmsg("Read"); break;
- case SMS_UnRead : printmsg("UnRead"); break;
- case SMS_UnSent : printmsg("UnSent"); break;
+ case SMS_Sent : printmsg("Sent\n"); break;
+ case SMS_Read : printmsg("Read\n"); break;
+ case SMS_UnRead : printmsg("UnRead\n"); break;
+ case SMS_UnSent : printmsg("UnSent\n"); break;
}
- printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
if (sms.UDH.Type != UDH_NoUDH) {
@@ -980,3 +995,3 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
}
-//#if 0
+
static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
@@ -1287,2 +1302,9 @@ static void Monitor(int argc, char *argv[])
+static void IncomingUSSD2(char *Device, char *Buffer)
+{
+ printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
+
+ gshutdown = true;
+}
+
static void GetUSSD(int argc, char *argv[])
@@ -1294,3 +1316,3 @@ static void GetUSSD(int argc, char *argv[])
- s.User.IncomingUSSD = IncomingUSSD;
+ s.User.IncomingUSSD = IncomingUSSD2;
@@ -1347,3 +1369,12 @@ static void GetSMSC(int argc, char *argv[])
case SMS_VALID_Max_Time : printmsg("Maximum time"); break;
- default : printmsg("Unknown");
+ default :
+ if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) {
+ printmsg("%i minutes",(smsc.Validity.Relative+1)*5);
+ } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) {
+ printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30);
+ } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) {
+ printmsg("%i days",smsc.Validity.Relative-166);
+ } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) {
+ printmsg("%i weeks",smsc.Validity.Relative-192);
+ }
}
@@ -1430,3 +1461,2 @@ static void GetAllSMS(int argc, char *argv[])
- fprintf(stderr,"Reading: ");
while (error == ERR_NONE) {
@@ -1450,3 +1480,2 @@ static void GetAllSMS(int argc, char *argv[])
}
- fprintf(stderr,"*");
start=false;
@@ -1581,3 +1610,4 @@ static void GetRingtone(int argc, char *argv[])
case RING_NOKIABINARY : printmsg("Nokia binary"); break;
- case RING_MIDI : printmsg("Midi format"); break;
+ case RING_MIDI : printmsg("MIDI"); break;
+ case RING_MMF : printmsg("SMAF (MMF)"); break;
}
@@ -2044,4 +2074,4 @@ static void GetAllCalendar(int argc, char *argv[])
if (error == ERR_EMPTY) break;
- PrintCalendar(&Note);
Print_Error(error);
+ PrintCalendar(&Note);
refresh=false;
@@ -2244,2 +2274,4 @@ static void GetBitmap(int argc, char *argv[])
printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
+ if (MultiBitmap.Bitmap[0].Name)
+ printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name));
if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
@@ -2507,3 +2539,3 @@ static void DisplaySMSFrame(GSM_SMSMessage *SMS)
static GSM_Error SMSStatus;
-//#if 0
+
static void SendSMSStatus (char *Device, int status, int MessageReference)
@@ -2518,3 +2550,3 @@ static void SendSMSStatus (char *Device, int status, int MessageReference)
}
- printmsg(", message reference=%02x\n",MessageReference);
+ printmsg(", message reference=%d\n",MessageReference);
}
@@ -2532,3 +2564,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
- GSM_MultiPartSMSInfo SMSInfo;
+ GSM_MultiPartSMSInfo SMSInfo;
GSM_NetworkInfo NetInfo;
@@ -2576,3 +2608,7 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
}
- if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2;
+ if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
+ startarg=startarg+2;
+ EncodeUnicode(SMSC,"1234",4);
+ SMSCSet = 0;
+ }
@@ -2602,3 +2638,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
if (argc<6+startarg) {
- printmsg("Where is ringtone filename ?\n");
+ printmsg("Where are parameters ?\n");
exit(-1);
@@ -2614,2 +2650,15 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
startarg += 6;
+ } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where are parameters ?\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong;
+ SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender,"WAP Info",8);
+ }
+ strcpy(MMSInfo.Address, argv[3+startarg]);
+ strcpy(MMSInfo.Title, argv[4+startarg]);
+ startarg += 5;
} else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
@@ -2712,3 +2761,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -2735,3 +2784,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -2778,3 +2827,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -2814,3 +2863,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -2836,3 +2885,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -2858,3 +2907,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3811,3 +3860,3 @@ static void SaveFile(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3829,3 +3878,3 @@ static void SaveFile(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3847,3 +3896,3 @@ static void SaveFile(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3865,3 +3914,3 @@ static void SaveFile(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3883,3 +3932,3 @@ static void SaveFile(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
@@ -3932,3 +3981,3 @@ static void Backup(int argc, char *argv[])
GSM_MemoryEntry Pbk;
- GSM_CalendarEntry Note;
+ GSM_CalendarEntry Calendar;
GSM_Bitmap Bitmap;
@@ -3937,2 +3986,4 @@ static void Backup(int argc, char *argv[])
GSM_MultiWAPSettings Settings;
+ GSM_SyncMLSettings SyncML;
+ GSM_ChatSettings Chat;
GSM_Ringtone Ringtone;
@@ -3940,2 +3991,3 @@ static void Backup(int argc, char *argv[])
GSM_Backup Backup;
+ GSM_NoteEntry Note;
GSM_Backup_Info Info;
@@ -4076,3 +4128,3 @@ static void Backup(int argc, char *argv[])
printmsg("Checking calendar\n");
- error=Phone->GetNextCalendar(&s,&Note,true);
+ error=Phone->GetNextCalendar(&s,&Calendar,true);
if (error==ERR_NONE) {
@@ -4094,5 +4146,5 @@ static void Backup(int argc, char *argv[])
}
- *Backup.Calendar[used]=Note;
+ *Backup.Calendar[used]=Calendar;
used ++;
- error=Phone->GetNextCalendar(&s,&Note,false);
+ error=Phone->GetNextCalendar(&s,&Calendar,false);
printmsgerr("*");
@@ -4138,2 +4190,34 @@ static void Backup(int argc, char *argv[])
DoBackup = false;
+ if (Info.Note) {
+ printmsg("Checking notes\n");
+ error=Phone->GetNextNote(&s,&Note,true);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup notes")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_NOTE) {
+ Backup.Note[used] = malloc(sizeof(GSM_NoteEntry));
+ if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.Note[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.Note[used]=Note;
+ used ++;
+ error=Phone->GetNextNote(&s,&Note,false);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
if (Info.CallerLogos) {
@@ -4236,2 +4320,70 @@ static void Backup(int argc, char *argv[])
DoBackup = false;
+ if (Info.WAPBookmark) {
+ printmsg("Checking WAP bookmarks\n");
+ Bookmark.Location = 1;
+ error=Phone->GetWAPBookmark(&s,&Bookmark);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
+ Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
+ if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.WAPBookmark[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.WAPBookmark[used]=Bookmark;
+ used ++;
+ Bookmark.Location = used+1;
+ error=Phone->GetWAPBookmark(&s,&Bookmark);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.WAPSettings) {
+ printmsg("Checking WAP settings\n");
+ Settings.Location = 1;
+ error=Phone->GetWAPSettings(&s,&Settings);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup WAP settings")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
+ Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
+ if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.WAPSettings[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.WAPSettings[used]=Settings;
+ used ++;
+ Settings.Location = used+1;
+ error=Phone->GetWAPSettings(&s,&Settings);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
if (Info.MMSSettings) {
@@ -4270,8 +4422,8 @@ static void Backup(int argc, char *argv[])
DoBackup = false;
- if (Info.WAPBookmark) {
- printmsg("Checking WAP bookmarks\n");
- Bookmark.Location = 1;
- error=Phone->GetWAPBookmark(&s,&Bookmark);
+ if (Info.ChatSettings) {
+ printmsg("Checking Chat settings\n");
+ Chat.Location = 1;
+ error=Phone->GetChatSettings(&s,&Chat);
if (error==ERR_NONE) {
- if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
+ if (answer_yes(" Backup Chat settings")) DoBackup = true;
}
@@ -4282,8 +4434,8 @@ static void Backup(int argc, char *argv[])
while (error == ERR_NONE) {
- if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
- Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
- if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
- Backup.WAPBookmark[used+1] = NULL;
+ if (used < GSM_BACKUP_MAX_CHATSETTINGS) {
+ Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings));
+ if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.ChatSettings[used+1] = NULL;
} else {
- printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS");
GSM_Terminate();
@@ -4291,6 +4443,6 @@ static void Backup(int argc, char *argv[])
}
- *Backup.WAPBookmark[used]=Bookmark;
+ *Backup.ChatSettings[used]=Chat;
used ++;
- Bookmark.Location = used+1;
- error=Phone->GetWAPBookmark(&s,&Bookmark);
+ Chat.Location = used+1;
+ error=Phone->GetChatSettings(&s,&Chat);
printmsgerr("*");
@@ -4304,8 +4456,8 @@ static void Backup(int argc, char *argv[])
DoBackup = false;
- if (Info.WAPSettings) {
- printmsg("Checking WAP settings\n");
- Settings.Location = 1;
- error=Phone->GetWAPSettings(&s,&Settings);
+ if (Info.SyncMLSettings) {
+ printmsg("Checking SyncML settings\n");
+ SyncML.Location = 1;
+ error=Phone->GetSyncMLSettings(&s,&SyncML);
if (error==ERR_NONE) {
- if (answer_yes(" Backup WAP settings")) DoBackup = true;
+ if (answer_yes(" Backup SyncML settings")) DoBackup = true;
}
@@ -4316,8 +4468,8 @@ static void Backup(int argc, char *argv[])
while (error == ERR_NONE) {
- if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
- Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
- if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
- Backup.WAPSettings[used+1] = NULL;
+ if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) {
+ Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings));
+ if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.SyncMLSettings[used+1] = NULL;
} else {
- printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS");
GSM_Terminate();
@@ -4325,6 +4477,6 @@ static void Backup(int argc, char *argv[])
}
- *Backup.WAPSettings[used]=Settings;
+ *Backup.SyncMLSettings[used]=SyncML;
used ++;
- Settings.Location = used+1;
- error=Phone->GetWAPSettings(&s,&Settings);
+ SyncML.Location = used+1;
+ error=Phone->GetSyncMLSettings(&s,&SyncML);
printmsgerr("*");
@@ -4504,3 +4656,7 @@ static void Restore(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[2],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) {
+ Print_Error(error);
+ } else {
+ printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n");
+ }
@@ -4509,5 +4665,6 @@ static void Restore(int argc, char *argv[])
- if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
- if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
- if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
+ if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
+ if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
+ if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
+ if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator);
@@ -4620,3 +4777,3 @@ static void Restore(int argc, char *argv[])
if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
- if (/*answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/ true ) {
+ if (answer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")) {
GSM_GetCurrentDateTime(&date_time);
@@ -4629,3 +4786,2 @@ static void Restore(int argc, char *argv[])
if (Backup.Calendar[0] != NULL) {
- DoRestore = true;
/* N6110 doesn't support getting calendar status */
@@ -4636,9 +4792,7 @@ static void Restore(int argc, char *argv[])
printmsgerr("%i entries in backup file\n",max);
+ // LR
+ //if (answer_yes("Restore calendar notes")) {
+ //Past = answer_yes("Restore notes from the past");
DoRestore = true;
- /*
- if (answer_yes("Restore calendar notes")) {
- Past = answer_yes("Restore notes from the past");
- DoRestore = true;
- }
- */
+ //}
}
@@ -4681,4 +4835,2 @@ static void Restore(int argc, char *argv[])
if (error == ERR_NONE) {
- error == ERR_NOTSUPPORTED;
- DoRestore = true;
max = 0;
@@ -4687,3 +4839,4 @@ static void Restore(int argc, char *argv[])
- /*if (answer_yes("Restore ToDo")) */DoRestore = true;
+ //LR if (answer_yes("Restore ToDo"))
+ DoRestore = true;
}
@@ -4691,6 +4844,4 @@ static void Restore(int argc, char *argv[])
if (DoRestore) {
- if ( max > 0 ) {
ToDo = *Backup.ToDo[0];
error = Phone->SetToDo(&s,&ToDo);
- }
}
@@ -4993,3 +5144,3 @@ static void AddNew(int argc, char *argv[])
error=GSM_ReadBackupFile(argv[2],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -5620,4 +5771,3 @@ static void RestoreSMS(int argc, char *argv[])
if (answer_yes(buffer)) {
- Backup.SMS[smsnum]->Location = 0;
- error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
+ error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
Print_Error(error);
@@ -5815,3 +5965,3 @@ static void NokiaComposer(int argc, char *argv[])
}
-//#if 0
+
static void CopyRingtone(int argc, char *argv[])
@@ -5976,3 +6126,3 @@ static void PrintToDo(GSM_ToDoEntry *ToDo)
- printmsg("Location : %i\n",ToDo->Location);
+ printmsg("Location : %i\n",ToDo->Location);
printmsg("Priority : ");
@@ -6100,3 +6250,3 @@ static void ListToDoCategory(int argc, char *argv[])
count++;
- if (mystrstr(Category.Name, Text) != NULL) {
+ if (mywstrstr(Category.Name, Text) != NULL) {
ListToDoCategoryEntries(j);
@@ -6153,9 +6303,9 @@ static void GetAllToDo(int argc, char *argv[])
-static void GetNote(int argc, char *argv[])
+static void GetAllNotes(int argc, char *argv[])
{
GSM_NoteEntry Note;
- int start,stop;
- bool refresh=true;
+ bool start = true;
- GetStartStop(&start, &stop, 2, argc, argv);
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
@@ -6163,17 +6313,10 @@ static void GetNote(int argc, char *argv[])
- for (i=start;i<=stop;i++) {
- Note.Location=i;
- printmsg("Location : %i\n",i);
- error=Phone->GetNote(&s,&Note,refresh);
- if (error != ERR_EMPTY) Print_Error(error);
-
- if (error == ERR_EMPTY) {
- printmsg("Entry is empty\n\n");
- } else {
- printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
- printf("\n");
- refresh=false;
- }
+ while (!gshutdown) {
+ error = Phone->GetNextNote(&s, &Note, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
+ printf("\n");
+ start = false;
}
-
GSM_Terminate();
@@ -6573,7 +6716,30 @@ static void ListNetworks(int argc, char *argv[])
extern unsigned char *GSM_Networks[];
+ extern unsigned char *GSM_Countries[];
int i=0;
+ char country[4]="";
- printmsg("Network Name\n\n");
+ if (argc>2) {
+ while (GSM_Countries[i*2]!=NULL) {
+ if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) {
+ strcpy(country,GSM_Countries[i*2]);
+ printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]);
+ break;
+ }
+ i++;
+ }
+ if (!*country) {
+ printmsg("Unknown country name.");
+ exit(-1);
+ }
+ }
+ printmsg("Network Name\n");
+ i=0;
while (GSM_Networks[i*2]!=NULL) {
- printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ if (argc>2) {
+ if (!strncmp(GSM_Networks[i*2],country,strlen(country))) {
+ printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ }
+ } else {
+ printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ }
i++;
@@ -6587,3 +6753,5 @@ static void Version(int argc, char *argv[])
- printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
+ printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__);
+ if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler());
+ printmsg("]\n\n");
@@ -6704,5 +6872,2 @@ static void GetFileSystem(int argc, char *argv[])
printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
- printf("\n");
-
- Start = false;
} else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
@@ -6728,7 +6893,4 @@ static void GetFileSystem(int argc, char *argv[])
if (Files.System) printf("S");
-
- printf("\n");
-
- Start = false;
}
+ Start = false;
}
@@ -7040,2 +7202,4 @@ static struct NokiaFolderInfo Folder[] = {
{"6220", "Gallery", "", "5"},
+ {"6610", "Gallery", "", "2"},
+ {"7210", "Gallery", "", "2"},
{"", "Tones", "Tones", "3"},
@@ -7044,2 +7208,4 @@ static struct NokiaFolderInfo Folder[] = {
{"6220", "Tones", "", "6"},
+ {"6610", "Tones", "", "4"},
+ {"7210", "Tones", "", "4"},
/* Language indepedent in OBEX */
@@ -7560,4 +7726,2 @@ static void CallDivert(int argc, char *argv[])
-
-//#if 0
static void CancelAllDiverts(int argc, char *argv[])
@@ -7572,3 +7736,13 @@ static void CancelAllDiverts(int argc, char *argv[])
+typedef struct {
+ unsigned char Connection[50];
+} OneConnectionInfo;
+typedef struct {
+ unsigned char Device[50];
+ OneConnectionInfo Connections[4];
+} OneDeviceInfo;
+
+int num;
+bool SearchOutput;
@@ -7576,33 +7750,31 @@ void SearchPhoneThread(OneDeviceInfo *Info)
{
+ //LR
+#if 0
int j;
GSM_Error error;
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
-#if 0
+ GSM_StateMachine ss;
+
j = 0;
while(strlen(Info->Connections[j].Connection) != 0) {
- memcpy(&Info->s.di,&s.di,sizeof(Debug_Info));
- Info->s.msg = s.msg;
- Info->s.ConfigNum = 1;
- Info->s.opened = false;
- Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
- Info->s.Config[0].Localize = s.Config[0].Localize;
- Info->s.Config[0].Device = Info->Device;
- Info->s.Config[0].Connection = Info->Connections[j].Connection;
- Info->s.Config[0].SyncTime = "no";
- Info->s.Config[0].DebugFile = s.Config[0].DebugFile;
- Info->s.Config[0].Model[0] = 0;
- strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel);
- Info->s.Config[0].LockDevice = "no";
- Info->s.Config[0].StartInfo = "no";
-
- error = GSM_InitConnection(&Info->s,1);
+ memcpy(&ss.di,&s.di,sizeof(Debug_Info));
+ ss.msg = s.msg;
+ ss.ConfigNum = 1;
+ ss.opened = false;
+ ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
+ ss.Config[0].Localize = s.Config[0].Localize;
+ ss.Config[0].Device = Info->Device;
+ ss.Config[0].Connection = Info->Connections[j].Connection;
+ ss.Config[0].SyncTime = "no";
+ ss.Config[0].DebugFile = s.Config[0].DebugFile;
+ ss.Config[0].Model[0] = 0;
+ strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel);
+ ss.Config[0].LockDevice = "no";
+ ss.Config[0].StartInfo = "no";
+
+ error = GSM_InitConnection(&ss,1);
if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
if (error == ERR_NONE) {
- error=Info->s.Phone.Functions->GetManufacturer(&Info->s);
+ error=ss.Phone.Functions->GetManufacturer(&ss);
if (error == ERR_NONE) {
- error=Info->s.Phone.Functions->GetModel(&Info->s);
+ error=ss.Phone.Functions->GetModel(&ss);
if (error == ERR_NONE) {
@@ -7610,20 +7782,20 @@ void SearchPhoneThread(OneDeviceInfo *Info)
printmsg(" Manufacturer : %s\n",
- Info->s.Phone.Data.Manufacturer);
+ ss.Phone.Data.Manufacturer);
printmsg(" Model : %s (%s)\n",
- Info->s.Phone.Data.ModelInfo->model,
- Info->s.Phone.Data.Model);
+ ss.Phone.Data.ModelInfo->model,
+ ss.Phone.Data.Model);
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
if (error != ERR_DEVICEOPENERROR) {
- GSM_TerminateConnection(&Info->s);
+ GSM_TerminateConnection(&ss);
dbgprintf("Closing done\n");
}
- if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break;
+ if (error == ERR_DEVICEOPENERROR) break;
j++;
@@ -7634,4 +7806,2 @@ void SearchPhoneThread(OneDeviceInfo *Info)
-//#undef HAVE_PTHREAD
-//#if 0
#if defined(WIN32) || defined(HAVE_PTHREAD)
@@ -7641,2 +7811,4 @@ void SearchPhoneThread(OneDeviceInfo *Info)
+OneDeviceInfo SearchDevices[60];
+
void MakeSearchThread(int i)
@@ -7659,3 +7831,3 @@ static void SearchPhone(int argc, char *argv[])
{
- int i,dev = 0, dev2 = 0;
+ int i,dev = 0, dev2 = 0;
@@ -7669,3 +7841,4 @@ static void SearchPhone(int argc, char *argv[])
sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
- SearchDevices[dev].Connections[1].Connection[0] = 0;
+ sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat");
+ SearchDevices[dev].Connections[2].Connection[0] = 0;
dev++;
@@ -7674,3 +7847,3 @@ static void SearchPhone(int argc, char *argv[])
dev2 = dev;
- for(i=0;i<10;i++) {
+ for(i=0;i<20;i++) {
sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
@@ -7732,3 +7905,3 @@ static void SearchPhone(int argc, char *argv[])
#endif /*Support for threads */
-// #if 0
+
static void NokiaGetADC(int argc, char *argv[])
@@ -7795,3 +7968,3 @@ static GSM_Parameters Parameters[] = {
{"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
- {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""},
+ {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"},
{"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
@@ -7814,4 +7987,4 @@ static GSM_Parameters Parameters[] = {
{"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
- {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"},
- {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
+ {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"},
+ {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
{"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
@@ -7845,2 +8018,3 @@ static GSM_Parameters Parameters[] = {
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
#ifdef GSM_ENABLE_BACKUP
@@ -7864,2 +8038,3 @@ static GSM_Parameters Parameters[] = {
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
#ifdef GSM_ENABLE_BACKUP
@@ -7909,3 +8084,3 @@ static GSM_Parameters Parameters[] = {
{"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
- {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"},
+ {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""},
{"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
@@ -7978,4 +8153,6 @@ static GSM_Parameters Parameters[] = {
{"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
+#ifdef GSM_ENABLE_NOKIA6510
{"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
{"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
+#endif
{"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
@@ -8048,7 +8225,7 @@ static void HelpGeneral(void)
printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
- printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n");
- printmsg("Second parameter optionally controls debug level, next specify actions.\n\n");
+ printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n");
+ printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n");
/* We might want to put here some most used commands */
- printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n");
+ printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n");
@@ -8136,3 +8313,3 @@ static void Help(int argc, char *argv[])
while (HelpDescriptions[i].category != 0) {
- if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break;
+ if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break;
i++;
@@ -8208,18 +8385,13 @@ static void Help(int argc, char *argv[])
}
-#if 0
-#endif // 0
+
int main(int argc, char *argv[])
{
-
- //fprintf(stderr,"HIIIIIIIIIIIII \n");
- //#if 0
- static int z ,start,i;
- static int only_config ;
-#if !defined(WIN32) && defined(LOCALE_PATH)
- static char *locale, locale_file[201];
+ int z = 0,start=0,i;
+ int only_config = -1;
+#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
+ char *locale, locale_file[201];
#endif
- static char *cp;
- static bool count_failed;
- z = 0;
- start=0;only_config = -1;count_failed = false;
+ char *cp;
+ bool count_failed = false;
+
s.opened = false;
@@ -8233,3 +8405,3 @@ int main(int argc, char *argv[])
#endif
- //#if 0
+
/* Any parameters? */
@@ -8248,54 +8420,10 @@ int main(int argc, char *argv[])
/* Is first parameter numeric? If so treat it as config that should be loaded. */
- //if (isdigit(argv[1][0])) {
- //only_config = atoi(argv[1]);
- //if (only_config >= 0) start++; else only_config = -1;
- //}
- only_config = 0;;
-#if 0
- GSM_ReadConfig(NULL, &s.Config[0], 0);
- s.ConfigNum = 1;
- GSM_Config *con = &s.Config[0];
-
- char* tempC;
- tempC = argv[argc-1]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using model %s \n",tempC);
- strcpy(con->Model,tempC );
- }
- tempC = argv[argc-2]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using device %s \n",tempC);
- con->Device = strdup(tempC);
- con->DefaultDevice = false;
- }
- tempC = argv[argc-3]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using connection %s \n",tempC);
- con->Connection = strdup(tempC);
- con->DefaultConnection = false;
- }
- argc = argc-3;
- //#if 0
- if ( ! mConnection.isEmpty() ) {
- cfg->Connection = strdup(mConnection.latin1());
- cfg->DefaultConnection = false;
- qDebug("Connection set %s ", cfg->Connection );
-
- }
- if ( ! mDevice.isEmpty() ) {
- cfg->Device = strdup(mDevice.latin1());
- cfg->DefaultDevice = false;
- qDebug("Device set %s ", cfg->Device);
-
- }
- if ( ! mModel.isEmpty() ) {
- strcpy(cfg->Model,mModel.latin1() );
- cfg->DefaultModel = false;
- qDebug("Model set %s ",cfg->Model );
- }
-
-#endif
+ if (isdigit(argv[1][0])) {
+ only_config = atoi(argv[1]);
+ if (only_config >= 0) start++; else only_config = -1;
+ }
+ cfg = GSM_FindGammuRC();
+ if (cfg == NULL) printmsg("Warning: No configuration file found!\n");
- cfg=GSM_FindGammuRC();
for (i = 0; i <= MAX_CONFIG_NUM; i++) {
@@ -8309,3 +8437,3 @@ int main(int argc, char *argv[])
} else {
-#if !defined(WIN32) && defined(LOCALE_PATH)
+#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
locale = setlocale(LC_MESSAGES, NULL);
@@ -8323,3 +8451,2 @@ int main(int argc, char *argv[])
/* Wanted user specific configuration? */
-
if (only_config != -1) {
@@ -8359,26 +8486,3 @@ int main(int argc, char *argv[])
}
-#if 0
- GSM_Config *con = &s.Config[0];
-
- char* tempC;
- tempC = argv[argc-1]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using model %s \n",tempC);
- strcpy(con->Model,tempC );
- }
- tempC = argv[argc-2]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using device %s \n",tempC);
- con->Device = strdup(tempC);
- con->DefaultDevice = false;
- }
- tempC = argv[argc-3]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using connection %s \n",tempC);
- con->Connection = strdup(tempC);
- con->DefaultConnection = false;
- }
-#endif
-
-
+
/* Do we have enough parameters? */
@@ -8401,3 +8505,2 @@ int main(int argc, char *argv[])
if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
- fprintf(stderr,"Executing \n");
Parameters[z].Function(argc - start, argv + start);
@@ -8423,4 +8526,3 @@ int main(int argc, char *argv[])
if (di.df!=stdout) fclose(di.df);
- //#endif // 0
- fprintf(stderr,"kammu: Success. End. \n");
+
exit(0);
diff --git a/gammu/emb/gammu/gammu.h b/gammu/emb/gammu/gammu.h
index d3de31b..ff50c9c 100644
--- a/gammu/emb/gammu/gammu.h
+++ b/gammu/emb/gammu/gammu.h
@@ -59,7 +59,7 @@ void GSM_Terminate (void);
-static GSM_StateMachine s;
-static GSM_Phone_Functions *Phone;
-static GSM_Error error;
+extern GSM_StateMachine s;
+extern GSM_Phone_Functions *Phone;
+extern GSM_Error error;
-static bool gshutdown;
+extern volatile bool gshutdown;
diff --git a/gammu/emb/gammu/smsd/s_files.c b/gammu/emb/gammu/smsd/s_files.c
index dac8d9c..b791e58 100644
--- a/gammu/emb/gammu/smsd/s_files.c
+++ b/gammu/emb/gammu/smsd/s_files.c
@@ -1,2 +1,2 @@
-/* (c) 2002-2003 by Joergen Thomsen */
+/* (c) 2002-2004 by Joergen Thomsen */
@@ -108,2 +108,10 @@ static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
* There is also set ID for SMS
+ * File extension convention:
+ * OUTxxxxx.txt : normal text SMS
+ * Options appended to the extension applying to this SMS only:
+ * d: delivery report requested
+ * f: flash SMS
+ * b: WAP bookmark as name,URL
+ * e.g. OUTG20040620_193810_123_+4512345678_xpq.txtdf
+ * is a flash text SMS requesting delivery reports
*/
@@ -113,2 +121,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
GSM_MultiPartSMSInfo SMSInfo;
+ GSM_WAPBookmark Bookmark;
unsigned char FileName[100],FullName[400];
@@ -118,3 +127,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
int i, len, phlen;
- char *pos1, *pos2;
+ char *pos1, *pos2, *options;
#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT
@@ -127,6 +136,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
m = 0;
- while ((m < n) && ((*(namelist[m]->d_name) == '.') ||
- !mystrncasecmp(namelist[m]->d_name,"out", 3) ||
+ while ((m < n) && ((*(namelist[m]->d_name) == '.') || // directory and UNIX hidden file
+ !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out'
((strlen(namelist[m]->d_name) >= 4) &&
- !mystrncasecmp(&namelist[m]->d_name[strlen(namelist[m]->d_name)-4],".txt",4)
+ !mystrncasecmp(strrchr(namelist[m]->d_name, '.'),".txt",4)
)
@@ -146,3 +155,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
strcpy(FullName, Config->outboxpath);
- strcat(FullName, "OUT*.txt");
+ strcat(FullName, "OUT*.txt*");
if((hFile = _findfirst( FullName, &c_file )) == -1L ) {
@@ -157,3 +166,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
if (error != ERR_NONE) return error;
-
+ options = strrchr(FileName, '.') + 4;
strcpy(FullName, Config->outboxpath);
@@ -164,6 +173,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
fclose(File);
- if (len<2) return ERR_EMPTY;
- if ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
- (Buffer[0] != 0xFE || Buffer[1] != 0xFF)) {
+ if ((len < 2) ||
+ (len >= 2 && ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
+ (Buffer[0] != 0xFE || Buffer[1] != 0xFF)))) {
if (len > GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS) len = GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS;
@@ -178,2 +187,5 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
+ GSM_ClearMultiPartSMSInfo(&SMSInfo);
+ sms->Number = 0;
+
SMSInfo.ReplaceMessage = 0;
@@ -182,2 +194,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
SMSInfo.EntriesNum = 1;
+ Config->currdeliveryreport = -1;
+ if (strchr(options, 'd')) Config->currdeliveryreport = 1;
+ if (strchr(options, 'f')) SMSInfo.Class = 0; /* flash SMS */
+
if (mystrncasecmp(Config->transmitformat, "unicode", 0)) {
@@ -192,2 +208,28 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
}
+
+ if (strchr(options, 'b')) { // WAP bookmark as title,URL
+ SMSInfo.Entries[0].Buffer = NULL;
+ SMSInfo.Entries[0].Bookmark = &Bookmark;
+ SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
+ SMSInfo.Entries[0].Bookmark->Location = 0;
+ pos2 = mywstrstr(Buffer2, "\0,");
+ if (pos2 == NULL) {
+ pos2 = Buffer2;
+ } else {
+ *pos2 = '\0'; pos2++; *pos2 = '\0'; pos2++; // replace comma by zero
+ }
+
+ len = UnicodeLength(Buffer2);
+ if (len > 50) len = 50;
+ memmove(&SMSInfo.Entries[0].Bookmark->Title, Buffer2, len * 2);
+ pos1 = &SMSInfo.Entries[0].Bookmark->Title[0] + len * 2;
+ *pos1 = '\0'; pos1++; *pos1 = '\0';
+
+ len = UnicodeLength(pos2);
+ if (len > 255) len = 255;
+ memmove(&SMSInfo.Entries[0].Bookmark->Address, pos2, len * 2);
+ pos1 = &SMSInfo.Entries[0].Bookmark->Address[0] + len * 2;
+ *pos1 = '\0'; pos1++; *pos1 = '\0';
+ }
+
GSM_EncodeMultiPartSMS(&SMSInfo,sms);
@@ -232,3 +274,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
DecodeUnicode(sms->SMS[0].Number,Buffer);
- dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i\n",
+ dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i dlr: %i fls: %i",
sms->Number,
@@ -239,4 +281,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
sms->SMS[0].UDH.Type,
- sms->SMS[0].UDH.Length);
- } else dbgprintf("error\n");
+ sms->SMS[0].UDH.Length,
+ Config->currdeliveryreport,
+ SMSInfo.Class);
+ } else dbgprintf("error: SMS-count = 0");
#endif
@@ -294,5 +338,5 @@ static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Con
-static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
{
- if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+ if (err == SMSD_SEND_OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
@@ -303,2 +347,3 @@ GSM_SMSDService SMSDFiles = {
NONEFUNCTION, /* Init */
+ NONEFUNCTION, /* InitAfterConnect */
SMSDFiles_SaveInboxSMS,
@@ -307,6 +352,8 @@ GSM_SMSDService SMSDFiles = {
NOTSUPPORTED, /* CreateOutboxSMS */
- SMSDFiles_AddSentSMSInfo
+ SMSDFiles_AddSentSMSInfo,
+ NOTSUPPORTED, /* RefreshSendStatus */
+ NOTSUPPORTED /* RefreshPhoneStatus */
};
-/* How should editor hadle tabs in this file? Add editor commands here.
+/* How should editor handle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
diff --git a/gammu/emb/gammu/smsd/s_files.h b/gammu/emb/gammu/smsd/s_files.h
index 5cfa05f..ed07ef3 100644
--- a/gammu/emb/gammu/smsd/s_files.h
+++ b/gammu/emb/gammu/smsd/s_files.h
@@ -1,2 +1,2 @@
-/* (c) 2002-2003 by Joergen Thomsen */
+/* (c) 2002-2004 by Joergen Thomsen */
diff --git a/gammu/emb/gammu/smsd/s_mysql.c b/gammu/emb/gammu/smsd/s_mysql.c
index dacc256..5df15e9 100644
--- a/gammu/emb/gammu/smsd/s_mysql.c
+++ b/gammu/emb/gammu/smsd/s_mysql.c
@@ -17,2 +17,3 @@
#include "../../common/service/backup/gsmback.h"
+#include "../gammu.h"
#include "smsdcore.h"
@@ -22,7 +23,114 @@ static GSM_Error SMSDMySQL_Init(GSM_SMSDConfig *Config)
{
+ unsigned char buf[400];
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+
mysql_init(&Config->DB);
if (!mysql_real_connect(&Config->DB,Config->PC,Config->user,Config->password,Config->database,0,NULL,0)) {
- WriteSMSDLog("Error connecting to database: %s\n", mysql_error(&Config->DB));
- return ERR_UNKNOWN;
+ WriteSMSDLog("Error connecting to database: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ sprintf(buf, "SELECT ID FROM `outbox` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
}
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `outbox_multipart` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `sentitems` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `inbox` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT Version FROM `gammu` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Row = mysql_fetch_row(Res))) {
+ mysql_free_result(Res);
+ WriteSMSDLog("No version info in Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (atoi(Row[0]) > 4) {
+ mysql_free_result(Res);
+ WriteSMSDLog("DataBase structures are from higher Gammu version");
+ WriteSMSDLog("Please update this client application");
+ return ERR_UNKNOWN;
+ }
+ if (atoi(Row[0]) < 4) {
+ mysql_free_result(Res);
+ WriteSMSDLog("DataBase structures are from older Gammu version");
+ WriteSMSDLog("Please update DataBase, if you want to use this client application");
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+
+ return ERR_NONE;
+}
+
+static GSM_Error SMSDMySQL_InitAfterConnect(GSM_SMSDConfig *Config)
+{
+ unsigned char buf[400],buf2[200];
+
+ sprintf(buf,"DELETE FROM `phones` WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+
+ sprintf(buf2,"Gammu %s",VERSION);
+ if (strlen(GetOS()) != 0) {
+ strcat(buf2+strlen(buf2),", ");
+ strcat(buf2+strlen(buf2),GetOS());
+ }
+ if (strlen(GetCompiler()) != 0) {
+ strcat(buf2+strlen(buf2),", ");
+ strcat(buf2+strlen(buf2),GetCompiler());
+ }
+
+ sprintf(buf,"INSERT INTO `phones` (`IMEI`,`ID`,`Send`,`Receive`,`InsertIntoDB`,`TimeOut`,`Client`) VALUES ('%s','%s','yes','yes',NOW(),(NOW() + INTERVAL 10 SECOND)+0,'%s')",s.Phone.Data.IMEI,Config->PhoneID,buf2);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+
return ERR_NONE;
@@ -33,9 +141,89 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
{
- unsigned char buffer[10000],buffer2[200],buffer3[2];
- int i,j,z;
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+ unsigned char buffer[10000],buffer2[200],buffer3[50];
+ int i,j,z;
+ GSM_DateTime DT;
+ time_t t_time1,t_time2;
+ bool found;
+ long diff;
for (i=0;i<sms.Number;i++) {
- if ((sms.SMS[i].PDU == SMS_Status_Report) && mystrncasecmp(Config->deliveryreport, "log", 3)) {
- strcpy(buffer, DecodeUnicodeString(sms.SMS[i].Number));
- WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer);
+ if (sms.SMS[i].PDU == SMS_Status_Report) {
+ strcpy(buffer2, DecodeUnicodeString(sms.SMS[i].Number));
+ if (mystrncasecmp(Config->deliveryreport, "log", 3)) {
+ WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer2);
+ }
+
+ sprintf(buffer, "SELECT ID,Status,SendingDateTime,DeliveryDateTime,SMSCNumber FROM `sentitems` WHERE \
+ DeliveryDateTime='00000000000000' AND \
+ SenderID='%s' AND TPMR='%i' AND DestinationNumber='%s'",
+ Config->PhoneID, sms.SMS[i].MessageReference, buffer2);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error reading from database (SaveInbox): %s %s\n", buffer, mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (SaveInbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ found = false;
+ while ((Row = mysql_fetch_row(Res))) {
+ if (strcmp(Row[4],DecodeUnicodeString(sms.SMS[i].SMSC.Number))) {
+ if (Config->skipsmscnumber[0] == 0) continue;
+ if (strcmp(Config->skipsmscnumber,Row[4])) continue;
+ }
+ if (!strcmp(Row[1],"SendingOK") || !strcmp(Row[1],"DeliveryPending")) {
+ sprintf(buffer,"%c%c%c%c",Row[2][0],Row[2][1],Row[2][2],Row[2][3]);
+ DT.Year = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][4],Row[2][5]);
+ DT.Month = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][6],Row[2][7]);
+ DT.Day = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][8],Row[2][9]);
+ DT.Hour = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][10],Row[2][11]);
+ DT.Minute = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][12],Row[2][13]);
+ DT.Second = atoi(buffer);
+ t_time1 = Fill_Time_T(DT,0);
+ t_time2 = Fill_Time_T(sms.SMS[i].DateTime,0);
+ diff = t_time2 - t_time1;
+ // fprintf(stderr,"diff is %i, %i-%i-%i-%i-%i and %i-%i-%i-%i-%i-%i\n",diff,
+ // DT.Year,DT.Month,DT.Day,DT.Hour,DT.Minute,DT.Second,
+ // sms.SMS[i].DateTime.Year,sms.SMS[i].DateTime.Month,sms.SMS[i].DateTime.Day,sms.SMS[i].DateTime.Hour,sms.SMS[i].DateTime.Minute,sms.SMS[i].DateTime.Second);
+ if (diff > -10 && diff < 10) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (found) {
+ sprintf(buffer,"UPDATE `sentitems` SET `DeliveryDateTime`='%04i%02i%02i%02i%02i%02i', `Status`='",
+ sms.SMS[i].SMSCTime.Year,sms.SMS[i].SMSCTime.Month,sms.SMS[i].SMSCTime.Day,
+ sms.SMS[i].SMSCTime.Hour,sms.SMS[i].SMSCTime.Minute,sms.SMS[i].SMSCTime.Second);
+ sprintf(buffer3,"%s",DecodeUnicodeString(sms.SMS[i].Text));
+ if (!strcmp(buffer3,"Delivered")) {
+ sprintf(buffer+strlen(buffer),"DeliveryOK");
+ } else if (!strcmp(buffer3,"Failed")) {
+ sprintf(buffer+strlen(buffer),"DeliveryFailed");
+ } else if (!strcmp(buffer3,"Pending")) {
+ sprintf(buffer+strlen(buffer),"DeliveryPending");
+ } else if (!strcmp(buffer3,"Unknown")) {
+ sprintf(buffer+strlen(buffer),"DeliveryUnknown");
+ }
+ sprintf(buffer+strlen(buffer),"', `StatusError` = '%i'",sms.SMS[i].DeliveryStatus);
+ sprintf(buffer+strlen(buffer)," WHERE `ID` = '%s' AND `TPMR` = '%i'",Row[0],sms.SMS[i].MessageReference);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ }
+ mysql_free_result(Res);
continue;
@@ -44,5 +232,5 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
buffer[0]=0;
- sprintf(buffer+strlen(buffer),"INSERT INTO `Inbox` \
- (`DateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \
- `Class`,`TextDecoded`) VALUES ('%04d%02d%02d%02d%02d%02d','",
+ sprintf(buffer+strlen(buffer),"INSERT INTO `inbox` \
+ (`ReceivingDateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \
+ `Class`,`TextDecoded`,`RecipientID`) VALUES ('%04d%02d%02d%02d%02d%02d','",
sms.SMS[i].DateTime.Year,sms.SMS[i].DateTime.Month,sms.SMS[i].DateTime.Day,
@@ -98,5 +286,8 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
}
- sprintf(buffer+strlen(buffer),"')");
+ sprintf(buffer+strlen(buffer),"','%s')",Config->PhoneID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error writing to database (SaveInbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -108,2 +299,18 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
+static GSM_Error SMSDMySQL_RefreshSendStatus(GSM_SMSDConfig *Config, unsigned char *ID)
+{
+ unsigned char buffer[10000];
+
+ sprintf(buffer,"UPDATE `outbox` SET `SendingTimeOut`=(now() + INTERVAL 15 SECOND)+0 WHERE `ID` = '%s' AND `SendingTimeOut` < now()",ID);
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (RefreshSendStatus): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_affected_rows(&Config->DB) == 0) return ERR_UNKNOWN;
+ return ERR_NONE;
+}
+
/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
@@ -113,10 +320,11 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
{
- unsigned char buf[400];
- MYSQL_RES *Res;
- MYSQL_ROW Row;
- int i;
+ unsigned char buf[400];
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+ int i;
+ bool found = false;
- sprintf(buf, "SELECT ID,DateTime FROM `Outbox` WHERE 1");
+ sprintf(buf, "SELECT ID,InsertIntoDB,SendingDateTime,SenderID FROM `outbox` WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW()");
if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -124,6 +332,16 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
if (!(Res = mysql_store_result(&Config->DB))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
- if (!(Row = mysql_fetch_row(Res))) {
+ while ((Row = mysql_fetch_row(Res))) {
+ sprintf(ID,"%s",Row[0]);
+ sprintf(Config->DT,"%s",Row[1]);
+ if (strlen(Row[3]) == 0 || !strcmp(Row[3],Config->PhoneID)) {
+ if (SMSDMySQL_RefreshSendStatus(Config, ID)==ERR_NONE) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found) {
mysql_free_result(Res);
@@ -131,14 +349,20 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
}
- sprintf(ID,"%s",Row[0]);
- sprintf(Config->DT,"%s",Row[1]);
+ mysql_free_result(Res);
sms->Number = 0;
- for (i=1;i<10;i++) {
- GSM_SetDefaultSMSData(&sms->SMS[sms->Number]);
+ for (i=0;i<MAX_MULTI_SMS;i++) {
+ GSM_SetDefaultSMSData(&sms->SMS[i]);
+ sms->SMS[i].SMSC.Number[0] = 0;
+ sms->SMS[i].SMSC.Number[1] = 0;
+ }
+ for (i=1;i<MAX_MULTI_SMS+1;i++) {
if (i==1) {
- sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,MultiPart FROM `Outbox` WHERE ID='%s'",ID);
+ sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,DestinationNumber,MultiPart,RelativeValidity,DeliveryReport FROM `outbox` WHERE ID='%s'",ID);
} else {
- sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,SequencePosition FROM `Outbox_MultiPart` WHERE ID='%s' AND SequencePosition='%i'",ID,i);
+ sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,SequencePosition FROM `outbox_multipart` WHERE ID='%s' AND SequencePosition='%i'",ID,i);
}
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -146,3 +370,3 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
if (!(Res = mysql_store_result(&Config->DB))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -155,7 +379,7 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
sms->SMS[sms->Number].Coding=SMS_Coding_Default;
- if (!strcmp(Row[2],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode;
- if (!strcmp(Row[2],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit;
+ if (!strcmp(Row[1],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode;
+ if (!strcmp(Row[1],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit;
if (strlen(Row[0])==0) {
- EncodeUnicode(sms->SMS[sms->Number].Text,Row[6],strlen(Row[6]));
+ EncodeUnicode(sms->SMS[sms->Number].Text,Row[4],strlen(Row[4]));
} else {
@@ -171,16 +395,31 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
}
- EncodeUnicode(sms->SMS[sms->Number].Number,Row[1],strlen(Row[1]));
+ if (i == 1) {
+ EncodeUnicode(sms->SMS[sms->Number].Number,Row[6],strlen(Row[6]));
+ } else {
+ CopyUnicodeString(sms->SMS[sms->Number].Number,sms->SMS[0].Number);
+ }
sms->SMS[sms->Number].UDH.Type = UDH_NoUDH;
- if (strlen(Row[3])!=0) {
+ if (strlen(Row[2])!=0) {
sms->SMS[sms->Number].UDH.Type = UDH_UserUDH;
- sms->SMS[sms->Number].UDH.Length = strlen(Row[3])/2;
- DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[3],strlen(Row[3]));
+ sms->SMS[sms->Number].UDH.Length = strlen(Row[2])/2;
+ DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[2],strlen(Row[2]));
}
- EncodeUnicode(sms->SMS[sms->Number].SMSC.Number,Row[4],strlen(Row[4]));
- sms->SMS[sms->Number].Class = atoi(Row[5]);
+ sms->SMS[sms->Number].Class = atoi(Row[3]);
sms->SMS[sms->Number].PDU = SMS_Submit;
- sms->SMS[sms->Number].SMSC.Location = 0;
- sms->Number++;
- if (i == 1 && !strcmp(Row[8],"false")) break;
+ sms->Number++;
+ if (i==1) {
+ Config->relativevalidity = atoi(Row[8]);
+
+ Config->currdeliveryreport = -1;
+ if (!strcmp(Row[9],"yes")) {
+ Config->currdeliveryreport = 1;
+ } else if (!strcmp(Row[9],"no")) {
+ Config->currdeliveryreport = 0;
+ }
+
+ if (!strcmp(Row[7],"false")) break;
+
+ }
}
+ mysql_free_result(Res);
return ERR_NONE;
@@ -191,76 +430,12 @@ static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Con
{
- char *status;
- unsigned char buffer[10000],buffer2[200],buffer3[2];
- int i,j,z;
-
- if (sent) status = "OK"; else status = "Error";
-
- for (i=0;i<sms->Number;i++) {
- buffer[0]=0;
- sprintf(buffer+strlen(buffer),"UPDATE `SentItems` SET `Text`='");
-
- switch (sms->SMS[i].Coding) {
- case SMS_Coding_Unicode:
- case SMS_Coding_Default:
- EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text));
- break;
- case SMS_Coding_8bit:
- EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length);
- }
-
- sprintf(buffer+strlen(buffer),"',`DestinationNumber`='%s',`Coding`='",DecodeUnicodeString(sms->SMS[i].Number));
-
- switch (sms->SMS[i].Coding) {
- case SMS_Coding_Unicode:
- sprintf(buffer+strlen(buffer),"Unicode");
- break;
- case SMS_Coding_Default:
- sprintf(buffer+strlen(buffer),"Default");
- break;
- case SMS_Coding_8bit:
- sprintf(buffer+strlen(buffer),"8bit");
- break;
- }
-
- sprintf(buffer+strlen(buffer),"',`SMSCNumber`='%s',`UDH`='",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
- if (sms->SMS[i].UDH.Type != UDH_NoUDH) {
- EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
- }
+ unsigned char buffer[10000];
- sprintf(buffer+strlen(buffer),"',`Class`='%i',`TextDecoded`='",sms->SMS[i].Class);
- switch (sms->SMS[i].Coding) {
- case SMS_Coding_Unicode:
- case SMS_Coding_Default:
- sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text));
- for (j=0;j<(int)strlen(buffer2);j++) {
- sprintf(buffer3,"'");
- z = strlen(buffer);
- if (buffer2[j]==buffer3[0]) {
- buffer[z+2]=0;
- buffer[z+1]=buffer2[j];
- buffer[z] ='\\';
- } else {
- buffer[z+1]=0;
- buffer[z] =buffer2[j];
- }
- }
- break;
- case SMS_Coding_8bit:
- break;
- }
- sprintf(buffer+strlen(buffer),"',`Status`='%s',`DateTime`='%s' ",status,Config->DT);
- sprintf(buffer+strlen(buffer),"WHERE `ID`='%s' AND `SequencePosition`='%i'",ID,i+1);
- if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
- return ERR_UNKNOWN;
- }
- }
- sprintf(buffer,"DELETE FROM `Outbox` WHERE `ID` = '%s'",ID);
+ sprintf(buffer,"DELETE FROM `outbox` WHERE `ID` = '%s'",ID);
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
- sprintf(buffer,"DELETE FROM `Outbox_MultiPart` WHERE `ID` = '%s'",ID);
+ sprintf(buffer,"DELETE FROM `outbox_multipart` WHERE `ID` = '%s'",ID);
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -273,5 +448,23 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
{
- unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
- int i,j,z;
- GSM_DateTime time;
+ unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
+ int i,j,z,ID;
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+
+ sprintf(buffer,"SELECT ID FROM outbox ORDER BY ID DESC LIMIT 1");
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if ((Row = mysql_fetch_row(Res))) {
+ sprintf(buffer,"%s",Row[0]);
+ ID = atoi(buffer);
+ } else {
+ ID = 0;
+ }
+ mysql_free_result(Res);
@@ -280,9 +473,18 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
if (i==0) {
- sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox` (`MultiPart`,`DateTime");
+ sprintf(buffer+strlen(buffer),"INSERT INTO `outbox` (`DeliveryReport`,`MultiPart`,`InsertIntoDB");
} else {
- sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox_MultiPart` (`SequencePosition");
+ sprintf(buffer+strlen(buffer),"INSERT INTO `outbox_multipart` (`SequencePosition");
}
- sprintf(buffer+strlen(buffer),"`,`Text`,`DestinationNumber`,`Coding`,`SMSCNumber`,`UDH`, \
+ sprintf(buffer+strlen(buffer),"`,`Text`,");
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"`DestinationNumber`,`RelativeValidity`,");
+ }
+ sprintf(buffer+strlen(buffer),"`Coding`,`UDH`, \
`Class`,`TextDecoded`,`ID`) VALUES ('");
if (i==0) {
+ if (sms->SMS[i].PDU == SMS_Status_Report) {
+ sprintf(buffer+strlen(buffer),"yes','");
+ } else {
+ sprintf(buffer+strlen(buffer),"default','");
+ }
if (sms->Number == 1) {
@@ -306,3 +508,12 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
}
- sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[i].Number));
+ sprintf(buffer+strlen(buffer),"',");
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"'%s',",DecodeUnicodeString(sms->SMS[i].Number));
+ if (sms->SMS[i].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
+ sprintf(buffer+strlen(buffer),"'%i',",sms->SMS[i].SMSC.Validity.Relative);
+ } else {
+ sprintf(buffer+strlen(buffer),"'-1',");
+ }
+ }
+ sprintf(buffer+strlen(buffer),"'");
switch (sms->SMS[i].Coding) {
@@ -318,11 +529,7 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
}
- sprintf(buffer+strlen(buffer),"','%s'",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
- if (sms->SMS[i].UDH.Type == UDH_NoUDH) {
- sprintf(buffer+strlen(buffer),",''");
- } else {
- sprintf(buffer+strlen(buffer),",'");
+ sprintf(buffer+strlen(buffer),"','");
+ if (sms->SMS[i].UDH.Type != UDH_NoUDH) {
EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
- sprintf(buffer+strlen(buffer),"'");
}
- sprintf(buffer+strlen(buffer),",'%i','",sms->SMS[i].Class);
+ sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[i].Class);
switch (sms->SMS[i].Coding) {
@@ -351,18 +558,34 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
while (true) {
- GSM_GetCurrentDateTime(&time);
- buffer4[0] = 0;
- strcpy(buffer4,buffer);
- sprintf(buffer4+strlen(buffer4),"%i')",
- time.Hour*1000000+
- time.Minute*10000+
- time.Second*100+time.Day);
+ ID++;
+ sprintf(buffer4,"SELECT ID FROM sentitems WHERE ID='%i'",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
- if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) {
- WriteSMSDLog("Duplicated outgoing SMS ID\n");
- continue;
- }
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
- break;
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Row = mysql_fetch_row(Res))) {
+ buffer4[0] = 0;
+ strcpy(buffer4,buffer);
+ sprintf(buffer4+strlen(buffer4),"%i')",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
+ if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
+ if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) {
+ WriteSMSDLog("Duplicated outgoing SMS ID\n");
+ continue;
+ }
+ WriteSMSDLog("Error writing to database (CreateOutbox): %d %s %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB),buffer4);
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ break;
+ }
+ mysql_free_result(Res);
}
@@ -370,8 +593,8 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
strcpy(buffer4,buffer);
- sprintf(buffer4+strlen(buffer4),"%i')",
- time.Hour*1000000+
- time.Minute*10000+
- time.Second*100+time.Day);
+ sprintf(buffer4+strlen(buffer4),"%i')",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error writing to database (CreateOutbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -383,14 +606,82 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
-static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+
+static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
{
- unsigned char buffer[10000];
+ unsigned char buffer[10000],buffer2[200],buffer3[2],buff[50];
+ int j,z;
+
+ if (err == SMSD_SEND_OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
- if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+ buff[0] = 0;
+ if (err == SMSD_SEND_OK) {
+ if (sms->SMS[Part-1].PDU == SMS_Status_Report) {
+ sprintf(buff,"SendingOK");
+ } else {
+ sprintf(buff,"SendingOKNoReport");
+ }
+ }
+ if (err == SMSD_SEND_SENDING_ERROR) sprintf(buff,"SendingError");
+ if (err == SMSD_SEND_ERROR) sprintf(buff,"Error");
buffer[0] = 0;
- sprintf(buffer+strlen(buffer),"INSERT INTO `SentItems` \
- (`ID`,`SequencePosition`,`Status`,`SendingDateTime`) VALUES (");
- sprintf(buffer+strlen(buffer),"'%s','%i','Sending',NOW())",ID,Part);
+ sprintf(buffer+strlen(buffer),"INSERT INTO `sentitems` \
+ (`ID`,`SequencePosition`,`Status`,`SendingDateTime`, `SMSCNumber`, `TPMR`, \
+ `SenderID`,`Text`,`DestinationNumber`,`Coding`,`UDH`,`Class`,`TextDecoded`,`InsertIntoDB`,`RelativeValidity`) VALUES (");
+ sprintf(buffer+strlen(buffer),"'%s','%i','%s',NOW(),'%s','%i','%s','",ID,Part,buff,DecodeUnicodeString(sms->SMS[Part-1].SMSC.Number),TPMR,Config->PhoneID);
+ switch (sms->SMS[Part-1].Coding) {
+ case SMS_Coding_Unicode:
+ case SMS_Coding_Default:
+ EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[Part-1].Text,UnicodeLength(sms->SMS[Part-1].Text));
+ break;
+ case SMS_Coding_8bit:
+ EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].Text,sms->SMS[Part-1].Length);
+ }
+ sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[Part-1].Number));
+ switch (sms->SMS[Part-1].Coding) {
+ case SMS_Coding_Unicode:
+ sprintf(buffer+strlen(buffer),"Unicode");
+ break;
+ case SMS_Coding_Default:
+ sprintf(buffer+strlen(buffer),"Default");
+ break;
+ case SMS_Coding_8bit:
+ sprintf(buffer+strlen(buffer),"8bit");
+ break;
+ }
+ sprintf(buffer+strlen(buffer),"','");
+ if (sms->SMS[Part-1].UDH.Type != UDH_NoUDH) {
+ EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].UDH.Text,sms->SMS[Part-1].UDH.Length);
+ }
+ sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[Part-1].Class);
+ switch (sms->SMS[Part-1].Coding) {
+ case SMS_Coding_Unicode:
+ case SMS_Coding_Default:
+ sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[Part-1].Text));
+ for (j=0;j<(int)strlen(buffer2);j++) {
+ sprintf(buffer3,"'");
+ z = strlen(buffer);
+ if (buffer2[j]==buffer3[0]) {
+ buffer[z+2]=0;
+ buffer[z+1]=buffer2[j];
+ buffer[z] ='\\';
+ } else {
+ buffer[z+1]=0;
+ buffer[z] =buffer2[j];
+ }
+ }
+ break;
+ case SMS_Coding_8bit:
+ break;
+ }
+ sprintf(buffer+strlen(buffer),"','%s','",Config->DT);
+ if (sms->SMS[Part-1].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
+ sprintf(buffer+strlen(buffer),"%i')",sms->SMS[Part-1].SMSC.Validity.Relative);
+ } else {
+ sprintf(buffer+strlen(buffer),"-1')");
+ }
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error writing to database (AddSent): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
@@ -400,4 +691,21 @@ static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConf
+static GSM_Error SMSDMySQL_RefreshPhoneStatus(GSM_SMSDConfig *Config)
+{
+ unsigned char buffer[500];
+
+ sprintf(buffer,"UPDATE `phones` SET `TimeOut`= (NOW() + INTERVAL 10 SECOND)+0");
+ sprintf(buffer+strlen(buffer)," WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ return ERR_NONE;
+}
+
GSM_SMSDService SMSDMySQL = {
SMSDMySQL_Init,
+ SMSDMySQL_InitAfterConnect,
SMSDMySQL_SaveInboxSMS,
@@ -406,3 +714,5 @@ GSM_SMSDService SMSDMySQL = {
SMSDMySQL_CreateOutboxSMS,
- SMSDMySQL_AddSentSMSInfo
+ SMSDMySQL_AddSentSMSInfo,
+ SMSDMySQL_RefreshSendStatus,
+ SMSDMySQL_RefreshPhoneStatus
};
diff --git a/gammu/emb/gammu/smsd/smsdcore.c b/gammu/emb/gammu/smsd/smsdcore.c
index fbc55d3..cc9accc 100644
--- a/gammu/emb/gammu/smsd/smsdcore.c
+++ b/gammu/emb/gammu/smsd/smsdcore.c
@@ -1,2 +1,2 @@
-/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
@@ -16,3 +16,5 @@
FILE *smsd_log_file = NULL;
+static int TPMR;
static GSM_Error SendingSMSStatus;
+
static void SMSSendingSMSStatus (char *Device, int status, int mr)
@@ -20,2 +22,3 @@ static void SMSSendingSMSStatus (char *Device, int status, int mr)
dbgprintf("Incoming SMS device: \"%s\" status=%d, reference=%d\n",Device, status, mr);
+ TPMR = mr;
if (status==0) {
@@ -75,3 +78,3 @@ void WriteSMSDLog(char *format, ...)
-void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
+void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log, char *service)
{
@@ -104,2 +107,3 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config));
+ error=GSM_SetDebugFile(s.Config[0].DebugFile, &di);
}
@@ -114,11 +118,2 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
- Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
- if (Config->user == NULL) Config->user="root";
- Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
- if (Config->password == NULL) Config->password="";
- Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
- if (Config->PC == NULL) Config->PC="localhost";
- Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
- if (Config->database == NULL) Config->database="sms";
-
str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false);
@@ -129,3 +124,6 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0;
- if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i", Config->commtimeout, Config->sendtimeout, Config->receivefrequency);
+ str = INI_GetValue(smsdcfgfile, "smsd", "resetfrequency", false);
+ if (str) Config->resetfrequency=atoi(str); else Config->resetfrequency = 0;
+ if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i, resetfrequency=%i",
+ Config->commtimeout, Config->sendtimeout, Config->receivefrequency, Config->resetfrequency);
@@ -137,27 +135,48 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
- Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
- if (Config->inboxpath == NULL) Config->inboxpath = emptyPath;
+ Config->PhoneID = INI_GetValue(smsdcfgfile, "smsd", "phoneid", false);
+ if (Config->PhoneID == NULL) Config->PhoneID = "";
+ if (log) WriteSMSDLog("phoneid = %s", Config->PhoneID);
- Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false);
- if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) {
- Config->inboxformat = "standard";
- }
- if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
+ if (!strcmp(service,"FILES")) {
+ Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
+ if (Config->inboxpath == NULL) Config->inboxpath = emptyPath;
- Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
- if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
+ Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false);
+ if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) {
+ Config->inboxformat = "standard";
+ }
+ if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
- Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false);
- if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) {
- Config->transmitformat = "7bit";
- }
- if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
+ Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
+ if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
- Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false);
- if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath;
- if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath);
+ Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false);
+ if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) {
+ Config->transmitformat = "7bit";
+ }
+ if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
- Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false);
- if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath;
- if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath);
+ Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false);
+ if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath;
+ if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath);
+
+ Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false);
+ if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath;
+ if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath);
+ }
+
+#ifdef HAVE_MYSQL_MYSQL_H
+ if (!strcmp(service,"MYSQL")) {
+ Config->skipsmscnumber = INI_GetValue(smsdcfgfile, "smsd", "skipsmscnumber", false);
+ if (Config->skipsmscnumber == NULL) Config->skipsmscnumber="";
+ Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
+ if (Config->user == NULL) Config->user="root";
+ Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
+ if (Config->password == NULL) Config->password="";
+ Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
+ if (Config->PC == NULL) Config->PC="localhost";
+ Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
+ if (Config->database == NULL) Config->database="sms";
+ }
+#endif
@@ -176,4 +195,6 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
- Config->retries = 0;
- Config->prevSMSID[0] = 0;
+ Config->retries = 0;
+ Config->prevSMSID[0] = 0;
+ Config->SMSC.Location = 0;
+ Config->relativevalidity = -1;
}
@@ -194,2 +215,3 @@ bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
if (error == ERR_NOTSUPPORTED) return true;
+
/* If PIN, try to enter */
@@ -328,2 +350,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
+ Service->RefreshPhoneStatus(Config);
}
@@ -335,3 +358,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
for (i=0;i<sms.Number;i++) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
}
@@ -340,2 +363,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
+
if (!gshutdown) {
@@ -348,3 +372,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
for (i=0;i<sms.Number;i++) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
}
@@ -357,6 +381,30 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
- for (i=0;i<sms.Number;i++) {
- if (strcmp(Config->deliveryreport, "no") != 0) sms.SMS[i].PDU = SMS_Status_Report;
+ for (i=0;i<sms.Number;i++) {
+ if (sms.SMS[i].SMSC.Location == 1) {
+ if (Config->SMSC.Location == 0) {
+ Config->SMSC.Location = 1;
+ error = Phone->GetSMSC(&s,&Config->SMSC);
+ if (error!=ERR_NONE) {
+ WriteSMSDLog("Error getting SMSC from phone");
+ return false;
+ }
+
+ }
+ memcpy(&sms.SMS[i].SMSC,&Config->SMSC,sizeof(GSM_SMSC));
+ sms.SMS[i].SMSC.Location = 0;
+ if (Config->relativevalidity != -1) {
+ sms.SMS[i].SMSC.Validity.Format = SMS_Validity_RelativeFormat;
+ sms.SMS[i].SMSC.Validity.Relative = Config->relativevalidity;
+ }
+ }
+
+ if (Config->currdeliveryreport == 1) {
+ sms.SMS[i].PDU = SMS_Status_Report;
+ } else {
+ if ((strcmp(Config->deliveryreport, "no") != 0 && (Config->currdeliveryreport == -1))) sms.SMS[i].PDU = SMS_Status_Report;
+ }
+
error=Phone->SendSMS(&s, &sms.SMS[i]);
if (error!=ERR_NONE) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, -1);
WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg));
@@ -364,3 +412,5 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
- j=0;
+ Service->RefreshPhoneStatus(Config);
+ j = 0;
+ TPMR = -1;
SendingSMSStatus = ERR_TIMEOUT;
@@ -375,2 +425,4 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
+ Service->RefreshSendStatus(Config, Config->SMSID);
+ Service->RefreshPhoneStatus(Config);
if (SendingSMSStatus != ERR_TIMEOUT) break;
@@ -380,2 +432,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
if (SendingSMSStatus != ERR_NONE) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, TPMR);
WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg));
@@ -383,3 +436,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
- error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, true);
+ error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_OK, TPMR);
if (error!=ERR_NONE) {
@@ -388,6 +441,2 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
}
- while ((int)i<sms.Number-1) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
- i++;
- }
strcpy(Config->prevSMSID, "");
@@ -405,3 +454,3 @@ void SMSDaemon(int argc, char *argv[])
GSM_Error error;
- time_t time1;
+ time_t lastreceive, lastreset = 0;
GSM_SMSDConfig Config;
@@ -419,3 +468,3 @@ void SMSDaemon(int argc, char *argv[])
- SMSD_ReadConfig(argv[3], &Config, true);
+ SMSD_ReadConfig(argv[3], &Config, true, argv[2]);
@@ -430,3 +479,4 @@ void SMSDaemon(int argc, char *argv[])
- time1 = time(NULL);
+ lastreceive = time(NULL);
+ lastreset = time(NULL);
SendingSMSStatus = ERR_UNKNOWN;
@@ -447,3 +497,23 @@ void SMSDaemon(int argc, char *argv[])
Phone = s.Phone.Functions;
- errors = 0;
+ if (errors == 255) {
+ errors = 0;
+ s.Phone.Data.IMEI[0] = 0;
+ if (!(Phone->GetIMEI(&s))) {
+ errors++;
+ } else {
+ error = Service->InitAfterConnect(&Config);
+ if (error!=ERR_NONE) {
+ GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
+ }
+ Phone->SetFastSMSSending(&s,true);
+ }
+ } else {
+ errors = 0;
+ }
+ if (initerrors > 3 || initerrors < 0) {
+ error=Phone->Reset(&s, false); /* soft reset */
+ WriteSMSDLog("Reset return code: %s (%i) ", error == ERR_NONE? "OK":"ERROR", error);
+ lastreset = time(NULL);
+ my_sleep(5000);
+ }
/* Marcin Wiacek: FIXME. To check */
@@ -459,4 +529,4 @@ void SMSDaemon(int argc, char *argv[])
}
- if ((difftime(time(NULL), time1) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
- time1 = time(NULL);
+ if ((difftime(time(NULL), lastreceive) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
+ lastreceive = time(NULL);
@@ -470,3 +540,3 @@ void SMSDaemon(int argc, char *argv[])
- if (!SMSD_CheckSMSStatus(&Config,Service)) {
+ if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */
errors++;
@@ -474,2 +544,7 @@ void SMSDaemon(int argc, char *argv[])
} else errors=0;
+
+ if (Config.resetfrequency > 0 && difftime(time(NULL), lastreset) >= Config.resetfrequency) { /* time for preventive reset */
+ errors = 254; initerrors = -2;
+ continue;
+ }
}
@@ -477,2 +552,3 @@ void SMSDaemon(int argc, char *argv[])
}
+ Phone->SetFastSMSSending(&s,false);
GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0);
@@ -496,3 +572,3 @@ GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *s
- SMSD_ReadConfig(filename, &Config, false);
+ SMSD_ReadConfig(filename, &Config, false, service);
diff --git a/gammu/emb/gammu/smsd/smsdcore.h b/gammu/emb/gammu/smsd/smsdcore.h
index 23e402e..17ffe58 100644
--- a/gammu/emb/gammu/smsd/smsdcore.h
+++ b/gammu/emb/gammu/smsd/smsdcore.h
@@ -1,5 +1,5 @@
-/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
#include "../../cfg/config.h"
-#undef HAVE_MYSQL_MYSQL_H
+
#ifdef HAVE_MYSQL_MYSQL_H
@@ -26,3 +26,5 @@ typedef struct {
unsigned int commtimeout, sendtimeout, receivefrequency;
+ unsigned int resetfrequency;
unsigned char *deliveryreport, *logfilename, *PINCode;
+ unsigned char *PhoneID;
@@ -34,7 +36,9 @@ typedef struct {
unsigned char *database, *user, *password;
- unsigned char *PC;
+ unsigned char *PC, *skipsmscnumber;
/* private variables required for work */
- unsigned int retries;
+ int relativevalidity;
+ unsigned int retries, currdeliveryreport;
unsigned char SMSID[200], prevSMSID[200];
+ GSM_SMSC SMSC;
#ifdef HAVE_MYSQL_MYSQL_H
@@ -44,9 +48,22 @@ typedef struct {
+typedef enum {
+ SMSD_SEND_OK = 1,
+ SMSD_SEND_SENDING_ERROR,
+ SMSD_SEND_DELIVERY_PENDING,
+ SMSD_SEND_DELIVERY_FAILED,
+ SMSD_SEND_DELIVERY_OK,
+ SMSD_SEND_DELIVERY_UNKNOWN,
+ SMSD_SEND_ERROR
+} GSM_SMSDSendingError;
+
typedef struct {
- GSM_Error (*Init) (GSM_SMSDConfig *Config);
- GSM_Error (*SaveInboxSMS) (GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config);
- GSM_Error (*FindOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID);
- GSM_Error (*MoveSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent);
- GSM_Error (*CreateOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config);
- GSM_Error (*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK);
+ GSM_Error (*Init) (GSM_SMSDConfig *Config);
+ GSM_Error (*InitAfterConnect) (GSM_SMSDConfig *Config);
+ GSM_Error (*SaveInboxSMS) (GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config);
+ GSM_Error (*FindOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID);
+ GSM_Error (*MoveSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent);
+ GSM_Error (*CreateOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config);
+ GSM_Error (*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR);
+ GSM_Error (*RefreshSendStatus) (GSM_SMSDConfig *Config, unsigned char *ID);
+ GSM_Error (*RefreshPhoneStatus) (GSM_SMSDConfig *Config);
} GSM_SMSDService;