summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3.c801
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3.h26
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/nhm5_587.txt2055
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/type-cc.h43
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/type-mm.h30
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/type-rr.h100
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/type-sms.h6
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/type-ss.h8
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.c416
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.h41
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.c137
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.h28
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.c239
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.h13
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.c46
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.h11
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx.c480
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3trac/wmx.h5
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.c1341
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.h95
-rw-r--r--gammu/emb/gammu/depend/siemens/chiffre.c223
-rw-r--r--gammu/emb/gammu/depend/siemens/chiffre.h3
-rw-r--r--gammu/emb/gammu/depend/siemens/dsiemens.c363
-rw-r--r--gammu/emb/gammu/depend/siemens/dsiemens.h34
-rw-r--r--gammu/emb/gammu/gammu.c8356
-rw-r--r--gammu/emb/gammu/gammu.h74
-rw-r--r--gammu/emb/gammu/gammu.pro52
-rw-r--r--gammu/emb/gammu/gammuE.pro55
-rw-r--r--gammu/emb/gammu/smsd/s_files.c313
-rw-r--r--gammu/emb/gammu/smsd/s_files.h7
-rw-r--r--gammu/emb/gammu/smsd/s_mysql.c414
-rw-r--r--gammu/emb/gammu/smsd/s_mysql.h11
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.c507
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.h61
-rw-r--r--gammu/emb/gammu/sniff.c405
-rw-r--r--gammu/emb/gammu/sniff.h8
36 files changed, 16807 insertions, 0 deletions
diff --git a/gammu/emb/gammu/depend/nokia/dct3.c b/gammu/emb/gammu/depend/nokia/dct3.c
new file mode 100644
index 0000000..d4a55da
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3.c
@@ -0,0 +1,801 @@
+/* (c) 2002-2004 by Marcin Wiacek */
+/* MSID by Walek */
+
+#include "../../../common/gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+
+#include <string.h>
+#include <signal.h>
+
+#include "../../../common/misc/coding/coding.h"
+#include "../../../common/gsmcomon.h"
+#include "../../../common/service/gsmpbk.h"
+#include "../../../common/phone/nokia/dct3/dct3func.h"
+#include "../../../common/phone/pfunc.h"
+#include "../../gammu.h"
+
+extern GSM_Reply_Function UserReplyFunctions3[];
+
+/* ------- some usefull functions ----------------------------------------- */
+
+GSM_Error CheckDCT3Only()
+{
+ bool found = false;
+
+ /* Checking if phone is DCT3 */
+#ifdef GSM_ENABLE_NOKIA6110
+ if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+#ifdef GSM_ENABLE_NOKIA9210
+ if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+ if (!found) return ERR_NOTSUPPORTED;
+
+ if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 &&
+ s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_FBUS2BLUE &&
+ s.ConnectionType!=GCT_FBUS2IRDA && s.ConnectionType!=GCT_IRDAPHONET &&
+ s.ConnectionType!=GCT_BLUEFBUS2) {
+ return ERR_OTHERCONNECTIONREQUIRED;
+ }
+ return ERR_NONE;
+}
+
+static void CheckDCT3()
+{
+ GSM_Error error;
+
+ error = CheckDCT3Only();
+ switch (error) {
+ case ERR_NOTSUPPORTED:
+ Print_Error(ERR_NOTSUPPORTED);
+ break;
+ case ERR_OTHERCONNECTIONREQUIRED:
+ printf("Can't do it with current phone protocol\n");
+ GSM_TerminateConnection(&s);
+ exit(-1);
+ default:
+ break;
+ }
+}
+
+static bool answer_yes3(char *text)
+{
+ int len;
+ char ans[99];
+
+ while (1) {
+ printf("%s (yes/no) ? ",text);
+ len=GetLine(stdin, ans, 99);
+ if (len==-1) exit(-1);
+ if (mystrncasecmp(ans, "yes",0)) return true;
+ if (mystrncasecmp(ans, "no" ,0)) return false;
+ }
+}
+
+/* ------------------- functions ------------------------------------------- */
+
+static FILE *DCT3T9File;
+
+static GSM_Error DCT3_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int DCT3T9Size;
+
+ DCT3T9Size = msg.Length - 6;
+ fwrite(msg.Buffer+6,1,DCT3T9Size,DCT3T9File);
+ return ERR_NONE;
+}
+
+void DCT3GetT9(int argc, char *argv[])
+{
+ int i;
+ unsigned char req[] = {0x00, 0x01, 0xAE, 0x02, 0x00,
+ 0x00}; /* Part number */
+
+//"00 01 AE 00" gets some control values
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ DCT3T9File = fopen("T9", "w");
+ if (DCT3T9File == NULL) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ for (i=0;i<5;i++) {
+ req[5] = i;
+ error=GSM_WaitFor (&s, req, 6, 0x40, 4, ID_User3);
+ Print_Error(error);
+ }
+
+ fclose(DCT3T9File);
+}
+
+void DCT3VibraTest(int argc, char *argv[])
+{
+ unsigned char ans[200];
+ unsigned char SetLevel[4] = {0x00, 0x01, 0xA3,
+ 0xff}; /* Level */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3);
+ Print_Error(error);
+
+ printf("Press any key to continue...\n");
+ GetLine(stdin, ans, 99);
+
+ SetLevel[3] = 0x00;
+ error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3);
+}
+
+static GSM_Error DCT3_ReplyPhoneTests(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+
+ for (i=0;i<msg.Buffer[3];i++) {
+ switch (i) {
+ case 0: printf("Unknown(%02i) ",i);break;
+ case 1: printf("MCU ROM checksum (startup)"); break;
+ case 2: printf("MCU RAM interface (startup)"); break;
+ case 3: printf("MCU RAM component "); break;
+ case 4: printf("MCU EEPROM interface (startup)"); break;
+ case 5: printf("MCU EEPROM component "); break;
+ case 6: printf("Real Time Clock battery (startup)"); break;
+ case 7: printf("CCONT interface (startup)"); break;
+ case 8: printf("AD converter (startup)"); break;
+ case 9: printf("SW Reset "); break;
+ case 10:printf("Power Off "); break;
+ case 11:printf("Security Data "); break;
+ case 12:printf("EEPROM Tune checksum (startup)"); break;
+ case 13:printf("PPM checksum (startup)"); break;
+ case 14:printf("MCU download DSP (startup)"); break;
+ case 15:printf("DSP alive (startup)"); break;
+ case 16:printf("COBBA serial (startup)"); break;
+ case 17:printf("COBBA paraller (startup)"); break;
+ case 18:printf("EEPROM security checksum (startup)"); break;
+ case 19:printf("PPM validity (startup)"); break;
+ case 20:printf("Warranty state (startup)"); break;
+ case 21:printf("Simlock check/SW version (startup)"); break;
+ case 22:printf("IMEI check? "); break;/*from PC-Locals1.3.is OK?*/
+ default:printf("Unknown(%02i) ",i);break;
+ }
+ switch (msg.Buffer[4+i]) {
+ case 0: printf(" : passed"); break;
+ case 0xff:printf(" : not executed"); break;
+ case 254: printf(" : fail"); break;
+ default: printf(" : result unknown(%i)",msg.Buffer[4+i]); break;
+ }
+ printf("\n");
+ }
+
+ return ERR_NONE;
+}
+
+void DCT3SelfTests(int argc, char *argv[])
+{
+ unsigned char buffer[3] = {0x00,0x01,0xcf};
+ unsigned char buffer3[8] = {0x00,0x01,0xce,0x1d,0xfe,0x23,0x00,0x00};
+ int i;
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ if (answer_yes3("Run all tests now ?")) {
+ /* make almost all tests */
+ error = s.Protocol.Functions->WriteMessage(&s, buffer3, 8, 0x40);
+ Print_Error(error);
+
+ GSM_Terminate();
+
+ while (!false) {
+ GSM_Init(false);
+ if (error==ERR_NONE) break;
+ GSM_Terminate();
+ }
+
+ my_sleep(400);
+ }
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ for (i=0;i<10;i++) {
+ error=GSM_WaitFor (&s, buffer, 3, 0x40, 4, ID_User1);
+ if (error == ERR_NONE) break;
+ }
+}
+
+struct DCT3ADCInfo {
+ char *name;
+ char *unit;
+ int x;
+ int pos1;
+ int pos2;
+};
+
+static struct DCT3ADCInfo DCT3ADC[] = {
+ {"Battery voltage:", "mV", 1, 3, 2},
+// {"Charger voltage:", "mV", 1, -1, 7},
+// {"Charger current:", "mA", 1, -1, 5},
+ {"Battery type:", "mAh", 1, 4, 3},
+ {"Battery temperature:", "mK", 10, 5, 4},
+// {"Accessory detection:", "mV", 1, -1, -1},
+ {"RSSI:", "", 1, 2, -1},
+// {"VCXO temperature:", "mV", 1, -1, -1},
+// {"Hook information:", "mV", 1, -1, -1},
+
+ {"", "", 1, -1, -1}
+};
+
+unsigned char DCT3ADCBuf[200];
+int DCT3ADCInt;
+
+static GSM_Error DCT3_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[2]) {
+ case 0x68:
+ memcpy(DCT3ADCBuf,msg.Buffer+4,msg.Length-4);
+ return ERR_NONE;
+ case 0x91:
+ DCT3ADCInt = msg.Buffer[4]*256+msg.Buffer[5];
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT3GetADC(int argc, char *argv[])
+{
+ int i = 0;
+ unsigned char GetRaw[] = {0x00, 0x01, 0x68};
+ unsigned char GetUnit[] = {0x00, 0x01, 0x91,
+ 0x02}; /* Test number */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=DCT3_EnableSecurity (&s, 0x02);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, GetRaw, 3, 0x40, 6, ID_User3);
+ Print_Error(error);
+
+ while (1) {
+ printf(" %30s ",DCT3ADC[i].name);
+ if (DCT3ADC[i].pos1 != -1) {
+ printf("raw ");
+ printf("%10i ",
+ DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2]*256+
+ DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2+1]);
+ }
+ if (DCT3ADC[i].pos2 != -1) {
+ printf("unit result ");
+ GetUnit[3] = DCT3ADC[i].pos2;
+ error=GSM_WaitFor (&s, GetUnit, 6, 0x40, 4, ID_User3);
+ Print_Error(error);
+ printf("%10i ",DCT3ADCInt*DCT3ADC[i].x);
+ printf("%s\n",DCT3ADC[i].unit);
+ }
+ i++;
+ if (DCT3ADC[i].name[0] == 0x00) break;
+ }
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+}
+
+void DCT3DisplayTest(int argc, char *argv[])
+{
+ unsigned char ans[200];
+ unsigned char req[] = {0x00, 0x01, 0xD3,
+ 0x03, /* 3=set, 2=clear */
+ 0x03}; /* test number */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ if (atoi(argv[2]) != 1 && atoi(argv[2]) != 2) {
+ printf("Give 1 or 2 as test number\n");
+ }
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ req[4] = atoi(argv[2]);
+ s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40);
+
+ printf("Press any key to continue...\n");
+ GetLine(stdin, ans, 99);
+
+ req[3] = 0x02;
+ req[4] = 0x03;
+ s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40);
+
+ error=DCT3_EnableSecurity (&s, 0x03);
+ Print_Error(error);
+}
+
+void DCT3netmonitor(int argc, char *argv[])
+{
+ char value[100];
+
+ GSM_Init(true);
+
+ CheckDCT3();
+
+ error=DCT3_Netmonitor(&s, atoi(argv[2]), value);
+ Print_Error(error);
+
+ printf("%s\n",value);
+#ifdef GSM_ENABLE_BEEP
+ if (atoi(argv[2]) == 243) GSM_PhoneBeep();
+#endif
+ GSM_Terminate();
+}
+
+static GSM_Error DCT3_ReplyGetMSID(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+
+ printf("MSID : ");
+ for (i=5;i<18;i++) printf("%02x",msg.Buffer[i]);
+ printf("\n");
+ return ERR_NONE;
+}
+
+static GSM_Error DCT3_ReplyGetDSPROM(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("DSP ROM : %c\n",msg.Buffer[5]);
+ return ERR_NONE;
+}
+
+static GSM_Error DCT3_ReplySimlockInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i, j;
+ char uni[100], buffer[50];
+
+ j=0;
+ for (i=0; i < 12; i++) {
+ if (j<24) {
+ uni[j]='0' + (msg.Buffer[9+i] >> 4);
+ j++;
+ }
+ if (j!=15) {
+ if (j<24) {
+ uni[j]='0' + (msg.Buffer[9+i] & 0x0f);
+ j++;
+ }
+ } else j++;
+ }
+
+ strncpy(buffer,uni,5);
+ buffer[5]=0;
+ printf("Simlock 1 : MCC+MNC %10s, %s, %s, counter %i\n",
+ buffer,
+ ((msg.Buffer[6] & 1) == 1)==0?"opened":"CLOSED",
+ ((msg.Buffer[5] & 1) != 1)==0?"user ":"factory",
+ msg.Buffer[21]);
+
+ strncpy(buffer,uni+16,4);
+ buffer[4]=0;
+ printf("Simlock 2 : GID1 %10s, %s, %s, counter %i\n",
+ buffer,
+ ((msg.Buffer[6] & 4) == 4)==0?"opened":"CLOSED",
+ ((msg.Buffer[5] & 4) != 4)==0?"user ":"factory",
+ msg.Buffer[23]);
+
+ strncpy(buffer,uni+20,4);
+ buffer[4]=0;
+ printf("Simlock 3 : GID2 %10s, %s, %s, counter %i\n",
+ buffer,
+ ((msg.Buffer[6] & 8) == 8)==0?"opened":"CLOSED",
+ ((msg.Buffer[5] & 8) != 8)==0?"user ":"factory",
+ msg.Buffer[24]);
+
+ strncpy(buffer,uni+5,10);
+ buffer[10]=0;
+ printf("Simlock 4 : MSIN %10s, %s, %s, counter %i\n",
+ buffer,
+ ((msg.Buffer[6] & 2) == 2)==0?"opened":"CLOSED",
+ ((msg.Buffer[5] & 2) != 2)==0?"user ":"factory",
+ msg.Buffer[22]);
+
+ return ERR_NONE;
+}
+
+static GSM_Error DCT3_ReplyGetMCUchkSum(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+
+ if (msg.Buffer[3] == 0x12) printf("Language Pack: %c\n",msg.Buffer[5]);
+ if (msg.Buffer[3] == 0x02) {
+ printf("MCU checksum : ");
+ for (i=5;i<9;i++) printf("%c",msg.Buffer[i]);
+ printf("\n");
+ }
+ return ERR_NONE;
+}
+
+static unsigned char MSID1;
+
+GSM_Error DCT3_ReplyEnableSecurity2(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "State of security commands set\n");
+ MSID1 = msg.Buffer[5];
+ return ERR_NONE;
+}
+
+void DCT3Info(int argc, char *argv[])
+{
+ unsigned char req[] = {0x00, 0x01, 0x8A, 0x00}; /* Get simlock info */
+ unsigned char req2[] = {0x00, 0x01, 0xb4, 0x00, 0x00}; /* Get MSID */
+ unsigned char req3[] = {0x00, 0x01, 0xc8, 0x02}; /* Get MCU chksum */
+ unsigned char req4[] = {0x00, 0x01, 0xc8, 0x09}; /* Get DSP ROM */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User3);
+ Print_Error(error);
+
+ req2[3] = MSID1;
+ req2[4] = req2[2] + req2[3];
+ error=GSM_WaitFor (&s, req2, 5, 0x40, 4, ID_User8);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, req3, 4, 0x40, 4, ID_User9);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, req4, 4, 0x40, 4, ID_User10);
+ Print_Error(error);
+}
+
+static GSM_Error DCT3_ReplyResetTest36(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Netmonitor test 36 cleaned OK\n");
+ return ERR_NONE;
+}
+
+void DCT3ResetTest36(int argc, char *argv[])
+{
+ unsigned char req[] = {0x00, 0x01, 0x65, 0x40, 0x00}; /* Reset test 36 in netmon */
+
+ GSM_Init(true);
+
+ CheckDCT3();
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=GSM_WaitFor (&s, req, 5, 0x40, 4, ID_User2);
+ Print_Error(error);
+
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+ GSM_Terminate();
+}
+
+static unsigned char PPS[32]; /* Product Profile Settings */
+
+static GSM_Error DCT3_ReplyGetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i,j,z;
+
+#ifdef DEBUG
+ dbgprintf("Product Profile Settings received -");
+ for (i=0;i<4;i++) dbgprintf(" %02x",msg.Buffer[3+i]);
+ dbgprintf("\n");
+#endif
+ j=128;z=0;
+ for (i=0;i<32;i++) {
+ PPS[i]='0';
+ if (msg.Buffer[z+3]&j) PPS[i]='1';
+ if (j==1) {
+ j=128;
+ z++;
+ } else j=j/2;
+ }
+#ifdef DEBUG
+ dbgprintf("After decoding: ");
+ for (i=0;i<32;i++) dbgprintf("%c",PPS[i]);
+ dbgprintf("\n");
+#endif
+ return ERR_NONE;
+}
+
+static GSM_Error DCT3_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Setting done OK\n");
+ return ERR_NONE;
+}
+
+void DCT3SetPhoneMenus(int argc, char *argv[])
+{
+ char value[100];
+ int i,j,z;
+ unsigned char reqGet[] = {0x00, 0x01, 0x6a};
+ unsigned char reqSet[] = {
+ 0x00, 0x01, 0x6b,
+ 0x00, 0x00, 0x00, 0x00 }; /* bytes with Product Profile Setings */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=GSM_WaitFor (&s, reqGet, 3, 0x40, 4, ID_User4);
+ Print_Error(error);
+
+ printf("ALS : enabling menu\n");
+ PPS[10] = '1';
+
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.87) {
+ printf("3310: enabling control of SMS charsets\n");
+ PPS[11] = '0';//0 = ON, 1 = OFF
+ }
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"6150")) {
+ printf("6150: enabling WellMate menu\n");
+ PPS[18] = '1';
+ }
+ /* FIXME */
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"3210")) {
+ printf("3210: enabling vibra menu\n");
+ PPS[24] = '1';
+ }
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.13) {
+ printf("3310: enabling 3315 features\n");
+ PPS[25] = '1';
+ }
+ /* FIXME */
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"3210") && s.Phone.Data.VerNum>=5.31) {
+ printf("3210: enabling React and Logic game\n");
+ PPS[26] = '1';
+ }
+
+#ifdef DEBUG
+ dbgprintf("After settings: ");
+ for (i=0;i<32;i++) dbgprintf("%c",PPS[i]);
+ dbgprintf("\n");
+#endif
+
+ j=128;z=0;
+ for (i=0;i<32;i++) {
+ if (PPS[i]=='1') reqSet[z+3]=reqSet[z+3]+j;
+ if (j==1) {
+ j=128;
+ z++;
+ } else j=j/2;
+ }
+
+// reqSet[3]=0xe7;
+// reqSet[4]=0x25;
+// reqSet[5]=0x00;
+// reqSet[6]=0xe0;
+
+ error=GSM_WaitFor (&s, reqSet, 7, 0x40, 4, ID_User4);
+ Print_Error(error);
+
+ printf("Enabling netmonitor\n");
+ error=DCT3_Netmonitor(&s, 243, value);
+ Print_Error(error);
+}
+
+static GSM_Error DCT3_Reply61GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Security Code is \"%s\"\n",msg.Buffer+5);
+ return ERR_NONE;
+}
+
+static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Security Code is \"%s\"\n",msg.Buffer+6);
+ return ERR_NONE;
+}
+
+void DCT3GetSecurityCode(int argc, char *argv[])
+{
+ unsigned char req6110[] = {0x00, 0x01, 0x6e,
+ 0x01}; /* Code type */
+ unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee,
+ 0x1c}; /* Setting */
+
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+#ifdef GSM_ENABLE_NOKIA6110
+ if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
+ error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6);
+ }
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
+ error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6);
+ }
+#endif
+#ifdef GSM_ENABLE_NOKIA9210
+ if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
+ error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6);
+ }
+#endif
+ Print_Error(error);
+}
+
+#ifdef GSM_ENABLE_NOKIA6110
+
+static GSM_Error DCT3_ReplyGetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned char buffer[10];
+
+ NOKIA_DecodeNetworkCode(msg.Buffer+5, buffer);
+ buffer[6] = 0;
+ printf("Network : %s (%s ", buffer,DecodeUnicodeString(GSM_GetNetworkName(buffer)));
+ printf(", %s)\n", DecodeUnicodeString(GSM_GetCountryName(buffer)));
+ printf("Name : \"%s\"\n",msg.Buffer+8);
+
+ return ERR_NONE;
+}
+
+void DCT3GetOperatorName(int argc, char *argv[])
+{
+ unsigned char req[] = {0x00,0x01,0x8c,0x00};
+
+ GSM_Init(true);
+
+ if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED);
+ CheckDCT3();
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User5);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static GSM_Error DCT3_ReplySetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Operator name set OK\n");
+ return ERR_NONE;
+}
+
+void DCT3SetOperatorName(int argc, char *argv[])
+{
+ int i = 0;
+ unsigned char req[256] = {0x00,0x01,0x8b,0x00,
+ 0x00,0x00, /* MCC */
+ 0x00}; /* MNC */
+
+ GSM_Init(true);
+
+ if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED);
+ CheckDCT3();
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ switch (argc) {
+ case 2:
+ case 3: NOKIA_EncodeNetworkCode(req+4,"000 00");
+ req[7] = 0x00;
+ i = 1;
+ break;
+ case 4: NOKIA_EncodeNetworkCode(req+4,argv[2]);
+ strncpy(req+7,argv[3],200);
+ i = strlen(argv[3]);
+ }
+
+ error=GSM_WaitFor (&s, req, 8+i, 0x40, 4, ID_User7);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static GSM_Error DCT3_ReplyDisplayOutput(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned char buf[100];
+
+ switch (msg.Buffer[3]) {
+ case 0x50:
+ dbgprintf("Display string received\n");
+ memcpy(buf,msg.Buffer+8,msg.Buffer[7]*2);
+ buf[msg.Buffer[7]*2] = 0;
+ buf[msg.Buffer[7]*2+1] = 0;
+ printf("X=%i, Y=%i, Text=\"%s\"\n",msg.Buffer[6],msg.Buffer[5],DecodeUnicodeString(buf));
+ return ERR_NONE;
+ case 0x54:
+ dbgprintf("Display output set\n");
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT3DisplayOutput(int argc, char *argv[])
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x53,
+ 0x01}; //1 = enable, 2 = disable
+
+ GSM_Init(true);
+
+ if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED);
+ CheckDCT3();
+
+ s.User.UserReplyFunctions=UserReplyFunctions3;
+
+ error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7);
+ Print_Error(error);
+
+ signal(SIGINT, interrupt);
+ printf("Press Ctrl+C to break...\n");
+ printf("Entering monitor mode...\n\n");
+
+ while (!gshutdown) {
+ GSM_ReadDevice(&s,true);
+ my_sleep(10);
+ }
+
+ req[4] = 0x02;
+ error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+#endif
+
+static GSM_Reply_Function UserReplyFunctions3[] = {
+ {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame },
+ {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 },
+
+ {DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity },
+ {DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 },
+ {DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 },
+ {DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 },
+ {DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 },
+ {DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 },
+ {DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 },
+#ifdef GSM_ENABLE_NOKIA6110
+ {DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 },
+ {DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 },
+#endif
+ {DCT3_ReplyGetADC, "\x40",0x02,0x91,ID_User3 },
+ {NoneReply, "\x40",0x02,0xA3,ID_User3 },
+ {DCT3_ReplyGetT9, "\x40",0x02,0xAE,ID_User3 },
+ {DCT3_ReplyGetMSID, "\x40",0x02,0xb5,ID_User8 },
+ {DCT3_ReplyGetDSPROM, "\x40",0x02,0xC8,ID_User10 },
+ {DCT3_ReplyGetMCUchkSum, "\x40",0x02,0xC8,ID_User9 },
+ {DCT3_ReplyPhoneTests, "\x40",0x02,0xCF,ID_User1 },
+
+ {DCT3_Reply7191GetSecurityCode, "\x7a",0x04,0x1C,ID_User6 },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3.h b/gammu/emb/gammu/depend/nokia/dct3.h
new file mode 100644
index 0000000..721222d
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3.h
@@ -0,0 +1,26 @@
+/* (c) 2002-2004 by Marcin Wiacek */
+
+void DCT3SelfTests (int argc, char *argv[]);
+void DCT3netmonitor (int argc, char *argv[]);
+void DCT3Info (int argc, char *argv[]);
+void DCT3ResetTest36 (int argc, char *argv[]);
+void DCT3SetPhoneMenus (int argc, char *argv[]);
+void DCT3GetSecurityCode (int argc, char *argv[]);
+void DCT3GetADC (int argc, char *argv[]);
+void DCT3DisplayTest (int argc, char *argv[]);
+void DCT3VibraTest (int argc, char *argv[]);
+void DCT3GetT9 (int argc, char *argv[]);
+
+GSM_Error CheckDCT3Only();
+
+#include "../../../common/gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA6110
+void DCT3GetOperatorName (int argc, char *argv[]);
+void DCT3SetOperatorName (int argc, char *argv[]);
+void DCT3DisplayOutput (int argc, char *argv[]);
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/nhm5_587.txt b/gammu/emb/gammu/depend/nokia/dct3trac/nhm5_587.txt
new file mode 100644
index 0000000..a68d9d2
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/nhm5_587.txt
@@ -0,0 +1,2055 @@
+09XX CS:err/CS_ERROR_TRA
+0900 CS:err/INVALID_PRIMITIVE
+0901 CS:err/UNKNOWN_PRIMITIVE
+0902 CS:err/UNDEFINED_PRIMITIVE
+0903 CS:err/L1_UNKNOWN_MDI_MSG_SEND
+0904 CS:err/HPLMN_READ_FAIL
+0905 CS:err/L1_M82_UNKNOWN_TIMING_OFFSET
+0906 CS:err/UNKNOWN_SSUPL_CM_RET_VALUE
+0907 CS:err/UNKNOWN_MODE
+0908 CS:err/UNKNOWN_PDU
+0909 CS:err/UNDEFINED_PDU
+090A CS:err/UNDEFINED_TIMER
+090B CS:err/FATAL_ERROR_IN_L2_PDU
+090C CS:err/UNKNOWN_INFO_ELEMENT
+090D CS:err/TRAN_ID_CONFLICT
+090E CS:err/UNKNOWN_ERROR_CODE
+090F CS:err/L2_ERROR
+0910 CS:err/RR_ERROR
+0911 CS:err/MM_ERROR
+0912 CS:err/CC_ERROR
+0913 CS:err/SS_ERROR
+0914 CS:err/CS_ERROR
+0915 CS:err/RM_ERROR
+0916 CS:err/LAPDM_CONT_RS_FAIL(22/061C)
+0917 CS:err/LAPDM_INVALID_RESP(22/060D)
+0918 CS:err/LAPDM_SEQUENCE_ERROR(22/05FD)
+0919 CS:err/LAPDM_TIMEOUT_ERROR(22/05FE)
+091A CS:err/LAPDM_AWAIT_EST_ERROR(22/061F)
+091B CS:err/LAPDM_UNSOL_DM_IN_MF_EST(22/0602)
+10XX Const/CONSTANT_WINDOW_TRA
+1000 Const/CHANNEL_CONFIG
+1001 Const/DSF
+1002 Const/RLT
+1003 Const/PWR_TA
+1004 Const/PWR
+1005 Const/TIM_ADV
+1006 Const/MEAS_RESULTS
+1007 Const/OWN_SYSPAR
+1008 Const/NBOUR_SYSPAR
+11XX L1:timer/L1_TIMER_TRA
+1100 L1:timer/BCCH_TIMEOUT-start(4/008B)
+1101 L1:timer/BCCH_TIMEOUT-stop
+1102 L1:timer/BCCH_TIMEOUT-timeout(4/0087)
+1103 L1:timer/RESEL_TIME-start
+1104 L1:timer/RESEL_TIME-stop(4/008A)
+1105 L1:timer/RESEL_TIME-timeout
+1106 L1:timer/IMM_ASS_DELAY-start(4/0089)
+1107 L1:timer/IMM_ASS_DELAY-stop
+1108 L1:timer/IMM_ASS_DELAY-timeout(4/008D)
+1109 L1:timer/EXT_PAGE_MODE-start
+110A L1:timer/EXT_PAGE_MODE-stop(4/0088)
+110B L1:timer/EXT_PAGE_MODE-timeout
+110C L1:timer/SYNC_PERIOD-start(4/008C)
+110D L1:timer/SYNC_PERIOD-stop
+110E L1:timer/SYNC_PERIOD-timeout(4/008E)
+110F L1:timer/SC1_NEG-start
+1110 L1:timer/SC1_NEG-stop
+1111 L1:timer/SC1_NEG-timeout
+1112 L1:timer/NCX_GREAT-start
+1113 L1:timer/NCX_GREAT-stop
+1114 L1:timer/NCX_GREAT-timeout
+1115 L1:timer/LAST_RESEL-start
+1116 L1:timer/LAST_RESEL-stop
+1117 L1:timer/LAST_RESEL-timeout
+1118 L1:timer/FORBIDDEN_CELLS-start
+1119 L1:timer/FORBIDDEN_CELLS-stop
+111A L1:timer/FORBIDDEN_CELLS-timeout
+111B L1:timer/CS_SCANN-start
+111C L1:timer/CS_SCANN-stop
+111D L1:timer/CS_SCANN-timeout
+111E L1:timer/WEAK_NEIGH-start
+111F L1:timer/WEAK_NEIGH-stop
+1120 L1:timer/WEAK_NEIGH-timeout
+1121 L1:timer/MEAS_REQ-start
+1122 L1:timer/MEAS_REQ-stop
+1123 L1:timer/MEAS_REQ-timeout
+1124 L1:timer/OWN_BCCH_PER-start
+1125 L1:timer/OWN_BCCH_PER-stop
+1126 L1:timer/OWN_BCCH_PER-timeout
+1127 L1:timer/OLD_SCELL-start
+1128 L1:timer/OLD_SCELL-stop
+1129 L1:timer/OLD_SCELL-timeout
+112A L1:timer/PLMN_SEARCH-start
+112B L1:timer/PLMN_SEARCH-stop
+112C L1:timer/PLMN_SEARCH-timeout
+18XX MDI:m2d/MDI_M2D_MSG_TRA
+1800 MDI:m2d/INVALID_MDI_MSG 0
+1801 MDI:m2d/INVALID_MDI_MSG 1
+1802 MDI:m2d/CHANNEL_CONFIGURE
+1803 MDI:m2d/DEACTIVATE
+1804 MDI:m2d/CBCH
+1805 MDI:m2d/FROM_MCU_TO_FBUS
+1806 MDI:m2d/CIPHER_KEY
+1807 MDI:m2d/MEAS_PLMN_RSSI
+1808 MDI:m2d/TYPE_TEST_ENABLED
+1809 MDI:m2d/PSW_SEARCH_LIST
+180A MDI:m2d/INVALID_MDI_MSG 10
+180B MDI:m2d/HOPPING_PARAMETERS
+180C MDI:m2d/IDLE_RA
+180D MDI:m2d/MODULATOR_TABLE
+180E MDI:m2d/MODULATOR_DC_OFFSET
+180F MDI:m2d/NEIGHBOUR_LIST
+1810 MDI:m2d/NEXT_BCCH
+1811 MDI:m2d/NMEAS_INSTRUCTIONS
+1812 MDI:m2d/INVALID_MDI_MSG 18
+1813 MDI:m2d/ON_OFF_CIPHER
+1814 MDI:m2d/CIPHER_PARAMETERS
+1815 MDI:m2d/INVALID_MDI_MSG 21
+1816 MDI:m2d/INVALID_MDI_MSG 22
+1817 MDI:m2d/INVALID_MDI_MSG 23
+1818 MDI:m2d/INVALID_MDI_MSG 24
+1819 MDI:m2d/INVALID_MDI_MSG 25
+181A MDI:m2d/SEARCH_LIST
+181B MDI:m2d/SEND_BLOCK
+181C MDI:m2d/INVALID_MDI_MSG 28
+181D MDI:m2d/INVALID_MDI_MSG 29
+181E MDI:m2d/INVALID_MDI_MSG 30
+181F MDI:m2d/TX_CONTROL
+1820 MDI:m2d/INVALID_MDI_MSG 32
+1821 MDI:m2d/INVALID_MDI_MSG 33
+1822 MDI:m2d/INVALID_MDI_MSG 34
+1823 MDI:m2d/INVALID_MDI_MSG 35
+1824 MDI:m2d/INVALID_MDI_MSG 36
+1825 MDI:m2d/INVALID_MDI_MSG 37
+1826 MDI:m2d/INVALID_MDI_MSG 38
+1827 MDI:m2d/INVALID_MDI_MSG 39
+1828 MDI:m2d/IR_LINK_STATUS
+1829 MDI:m2d/INVALID_MDI_MSG 41
+182A MDI:m2d/INVALID_MDI_MSG 42
+182B MDI:m2d/INVALID_MDI_MSG 43
+182C MDI:m2d/DSP_CONSTANTS
+182D MDI:m2d/INVALID_MDI_MSG 45
+182E MDI:m2d/INVALID_MDI_MSG 46
+182F MDI:m2d/INVALID_MDI_MSG 47
+1830 MDI:m2d/TX_ENABLE
+1831 MDI:m2d/MEAS_REQ_ON
+1832 MDI:m2d/INVALID_MDI_MSG 50
+1833 MDI:m2d/INVALID_MDI_MSG 51
+1834 MDI:m2d/INVALID_MDI_MSG 52
+1835 MDI:m2d/INVALID_MDI_MSG 53
+1836 MDI:m2d/DISCHARGE
+1837 MDI:m2d/INVALID_MDI_MSG 55
+1838 MDI:m2d/TYPE_LOOP_BACK
+1839 MDI:m2d/PARAMETER_UPDATE
+183A MDI:m2d/RX_TX_CONTROL
+183B MDI:m2d/TEMPERATURE
+183C MDI:m2d/DSP_PARAMETERS
+183D MDI:m2d/INVALID_MDI_MSG 61
+183E MDI:m2d/DTX_CONTROL
+183F MDI:m2d/POWER_LEVEL_RAMP
+1840 MDI:m2d/INVALID_MDI_MSG 64
+1841 MDI:m2d/IGNORE_CBCH_MESSAGE
+1842 MDI:m2d/CBCH_BITMAP
+1843 MDI:m2d/INVALID_MDI_MSG 67
+1844 MDI:m2d/INVALID_MDI_MSG 68
+1845 MDI:m2d/OWN_BCCH
+1846 MDI:m2d/MSI
+1847 MDI:m2d/LOOP_BACK
+1848 MDI:m2d/LOOP_BACK_SHORT
+1849 MDI:m2d/RTC_CALIBRATION_REQUEST
+184A MDI:m2d/TXC_BIAS_RESULT
+184B MDI:m2d/MORE_RSSI
+184C MDI:m2d/FBUS_MODE
+184D MDI:m2d/SEND_DTE_DATA_BLOCK
+184E MDI:m2d/SEND_IRLAP_DATA_BLOCK
+184F MDI:m2d/DATA_CODING_MODE
+1850 MDI:m2d/SEND_TCH_DATA_BLOCK
+1851 MDI:m2d/INVALID_MDI_MSG 81
+1852 MDI:m2d/INVALID_MDI_MSG 82
+1853 MDI:m2d/INVALID_MDI_MSG 83
+1854 MDI:m2d/INVALID_MDI_MSG 84
+1855 MDI:m2d/INVALID_MDI_MSG 85
+1856 MDI:m2d/INVALID_MDI_MSG 86
+1857 MDI:m2d/INVALID_MDI_MSG 87
+1858 MDI:m2d/INVALID_MDI_MSG 88
+1859 MDI:m2d/INVALID_MDI_MSG 89
+185A MDI:m2d/INVALID_MDI_MSG 90
+185B MDI:m2d/INVALID_MDI_MSG 91
+185C MDI:m2d/INVALID_MDI_MSG 92
+185D MDI:m2d/INVALID_MDI_MSG 93
+185E MDI:m2d/INVALID_MDI_MSG 94
+185F MDI:m2d/INVALID_MDI_MSG 95
+1860 MDI:m2d/INVALID_MDI_MSG 96
+1861 MDI:m2d/INVALID_MDI_MSG 97
+1862 MDI:m2d/INVALID_MDI_MSG 98
+1863 MDI:m2d/INVALID_MDI_MSG 99
+1864 MDI:m2d/INVALID_MDI_MSG 100
+1865 MDI:m2d/INVALID_MDI_MSG 101
+1866 MDI:m2d/INVALID_MDI_MSG 102
+1867 MDI:m2d/INVALID_MDI_MSG 103
+1868 MDI:m2d/INVALID_MDI_MSG 104
+1869 MDI:m2d/INVALID_MDI_MSG 105
+186A MDI:m2d/INVALID_MDI_MSG 106
+186B MDI:m2d/INVALID_MDI_MSG 107
+186C MDI:m2d/INVALID_MDI_MSG 108
+186D MDI:m2d/INVALID_MDI_MSG 109
+186E MDI:m2d/INVALID_MDI_MSG 110
+186F MDI:m2d/INVALID_MDI_MSG 111
+1870 MDI:m2d/COMMAND_LOCAL
+1871 MDI:m2d/INVALID_MDI_MSG 113
+1872 MDI:m2d/INVALID_MDI_MSG 114
+1873 MDI:m2d/INVALID_MDI_MSG 115
+1874 MDI:m2d/RESPONSE_LOCAL
+1875 MDI:m2d/INVALID_MDI_MSG 117
+1876 MDI:m2d/INVALID_MDI_MSG 118
+1877 MDI:m2d/INVALID_MDI_MSG 119
+1878 MDI:m2d/INVALID_MDI_MSG 120
+1879 MDI:m2d/INVALID_MDI_MSG 121
+187A MDI:m2d/INVALID_MDI_MSG 122
+187B MDI:m2d/INVALID_MDI_MSG 123
+187C MDI:m2d/INVALID_MDI_MSG 124
+187D MDI:m2d/INVALID_MDI_MSG 125
+187E MDI:m2d/INVALID_MDI_MSG 126
+187F MDI:m2d/INVALID_MDI_MSG 127
+1880 MDI:m2d/RECEIVED_BLOCK
+1881 MDI:m2d/MEAS_REQUEST
+1882 MDI:m2d/INVALID_MDI_MSG 130
+1883 MDI:m2d/RSSI_RESULTS
+1884 MDI:m2d/RA_INFO
+1885 MDI:m2d/INVALID_MDI_MSG 133
+1886 MDI:m2d/BLOCK_REQUEST
+1887 MDI:m2d/NO_BCCH_LEFT
+1888 MDI:m2d/NEIGHBOUR_TIMING_OFFSET
+1889 MDI:m2d/CHANNEL_CHANGED_CNF
+188A MDI:m2d/NO_PSW_FOUND
+188B MDI:m2d/ALL_RSSI_RESULTS
+188C MDI:m2d/DOWNLINK_SIGNALLING_FAIL
+188D MDI:m2d/FBUS_DISCONNECTED
+188E MDI:m2d/FROM_FBUS_TO_MCU
+188F MDI:m2d/NO_PSW_LEFT
+1890 MDI:m2d/INVALID_MDI_MSG 144
+1891 MDI:m2d/INVALID_MDI_MSG 145
+1892 MDI:m2d/INVALID_MDI_MSG 146
+1893 MDI:m2d/INVALID_MDI_MSG 147
+1894 MDI:m2d/FBUS_ERROR
+1895 MDI:m2d/IR_DISABLED
+1896 MDI:m2d/LOOP_BACK_REPLY
+1897 MDI:m2d/LOOP_BACK_SHORT_REPLY
+1898 MDI:m2d/RTC_CALIBRATION_VALUE
+1899 MDI:m2d/TXC_BIAS_MEAS
+189A MDI:m2d/RECEIVED_DTE_DATA_BLOCK
+189B MDI:m2d/RECEIVED_IRLAP_DATA_BLOCK
+189C MDI:m2d/RECEIVED_TCH_DATA_BLOCK
+189D MDI:m2d/INVALID_MDI_MSG 157
+189E MDI:m2d/INVALID_MDI_MSG 158
+189F MDI:m2d/INVALID_MDI_MSG 159
+18A0 MDI:m2d/INVALID_MDI_MSG 160
+18A1 MDI:m2d/INVALID_MDI_MSG 161
+18A2 MDI:m2d/INVALID_MDI_MSG 162
+18A3 MDI:m2d/INVALID_MDI_MSG 163
+18A4 MDI:m2d/INVALID_MDI_MSG 164
+18A5 MDI:m2d/INVALID_MDI_MSG 165
+18A6 MDI:m2d/INVALID_MDI_MSG 166
+18A7 MDI:m2d/INVALID_MDI_MSG 167
+18A8 MDI:m2d/INVALID_MDI_MSG 168
+18A9 MDI:m2d/INVALID_MDI_MSG 169
+18AA MDI:m2d/INVALID_MDI_MSG 170
+18AB MDI:m2d/UNKNOWN_MDI_MSG
+19XX MDI:d2m/MDI_D2M_MSG_TRA
+1900 MDI:d2m/INVALID_MDI_MSG 0
+1901 MDI:d2m/INVALID_MDI_MSG 1
+1902 MDI:d2m/CHANNEL_CONFIGURE
+1903 MDI:d2m/DEACTIVATE
+1904 MDI:d2m/CBCH
+1905 MDI:d2m/FROM_MCU_TO_FBUS
+1906 MDI:d2m/CIPHER_KEY
+1907 MDI:d2m/MEAS_PLMN_RSSI
+1908 MDI:d2m/TYPE_TEST_ENABLED
+1909 MDI:d2m/PSW_SEARCH_LIST
+190A MDI:d2m/INVALID_MDI_MSG 10
+190B MDI:d2m/HOPPING_PARAMETERS
+190C MDI:d2m/IDLE_RA
+190D MDI:d2m/MODULATOR_TABLE
+190E MDI:d2m/MODULATOR_DC_OFFSET
+190F MDI:d2m/NEIGHBOUR_LIST
+1910 MDI:d2m/NEXT_BCCH
+1911 MDI:d2m/NMEAS_INSTRUCTIONS
+1912 MDI:d2m/INVALID_MDI_MSG 18
+1913 MDI:d2m/ON_OFF_CIPHER
+1914 MDI:d2m/CIPHER_PARAMETERS
+1915 MDI:d2m/INVALID_MDI_MSG 21
+1916 MDI:d2m/INVALID_MDI_MSG 22
+1917 MDI:d2m/INVALID_MDI_MSG 23
+1918 MDI:d2m/INVALID_MDI_MSG 24
+1919 MDI:d2m/INVALID_MDI_MSG 25
+191A MDI:d2m/SEARCH_LIST
+191B MDI:d2m/SEND_BLOCK
+191C MDI:d2m/INVALID_MDI_MSG 28
+191D MDI:d2m/INVALID_MDI_MSG 29
+191E MDI:d2m/INVALID_MDI_MSG 30
+191F MDI:d2m/TX_CONTROL
+1920 MDI:d2m/INVALID_MDI_MSG 32
+1921 MDI:d2m/INVALID_MDI_MSG 33
+1922 MDI:d2m/INVALID_MDI_MSG 34
+1923 MDI:d2m/INVALID_MDI_MSG 35
+1924 MDI:d2m/INVALID_MDI_MSG 36
+1925 MDI:d2m/INVALID_MDI_MSG 37
+1926 MDI:d2m/INVALID_MDI_MSG 38
+1927 MDI:d2m/INVALID_MDI_MSG 39
+1928 MDI:d2m/IR_LINK_STATUS
+1929 MDI:d2m/INVALID_MDI_MSG 41
+192A MDI:d2m/INVALID_MDI_MSG 42
+192B MDI:d2m/INVALID_MDI_MSG 43
+192C MDI:d2m/DSP_CONSTANTS
+192D MDI:d2m/INVALID_MDI_MSG 45
+192E MDI:d2m/INVALID_MDI_MSG 46
+192F MDI:d2m/INVALID_MDI_MSG 47
+1930 MDI:d2m/TX_ENABLE
+1931 MDI:d2m/MEAS_REQ_ON
+1932 MDI:d2m/INVALID_MDI_MSG 50
+1933 MDI:d2m/INVALID_MDI_MSG 51
+1934 MDI:d2m/INVALID_MDI_MSG 52
+1935 MDI:d2m/INVALID_MDI_MSG 53
+1936 MDI:d2m/DISCHARGE
+1937 MDI:d2m/INVALID_MDI_MSG 55
+1938 MDI:d2m/TYPE_LOOP_BACK
+1939 MDI:d2m/PARAMETER_UPDATE
+193A MDI:d2m/RX_TX_CONTROL
+193B MDI:d2m/TEMPERATURE
+193C MDI:d2m/DSP_PARAMETERS
+193D MDI:d2m/INVALID_MDI_MSG 61
+193E MDI:d2m/DTX_CONTROL
+193F MDI:d2m/POWER_LEVEL_RAMP
+1940 MDI:d2m/INVALID_MDI_MSG 64
+1941 MDI:d2m/IGNORE_CBCH_MESSAGE
+1942 MDI:d2m/CBCH_BITMAP
+1943 MDI:d2m/INVALID_MDI_MSG 67
+1944 MDI:d2m/INVALID_MDI_MSG 68
+1945 MDI:d2m/OWN_BCCH
+1946 MDI:d2m/MSI
+1947 MDI:d2m/LOOP_BACK
+1948 MDI:d2m/LOOP_BACK_SHORT
+1949 MDI:d2m/RTC_CALIBRATION_REQUEST
+194A MDI:d2m/TXC_BIAS_RESULT
+194B MDI:d2m/MORE_RSSI
+194C MDI:d2m/FBUS_MODE
+194D MDI:d2m/SEND_DTE_DATA_BLOCK
+194E MDI:d2m/SEND_IRLAP_DATA_BLOCK
+194F MDI:d2m/DATA_CODING_MODE
+1950 MDI:d2m/SEND_TCH_DATA_BLOCK
+1951 MDI:d2m/INVALID_MDI_MSG 81
+1952 MDI:d2m/INVALID_MDI_MSG 82
+1953 MDI:d2m/INVALID_MDI_MSG 83
+1954 MDI:d2m/INVALID_MDI_MSG 84
+1955 MDI:d2m/INVALID_MDI_MSG 85
+1956 MDI:d2m/INVALID_MDI_MSG 86
+1957 MDI:d2m/INVALID_MDI_MSG 87
+1958 MDI:d2m/INVALID_MDI_MSG 88
+1959 MDI:d2m/INVALID_MDI_MSG 89
+195A MDI:d2m/INVALID_MDI_MSG 90
+195B MDI:d2m/INVALID_MDI_MSG 91
+195C MDI:d2m/INVALID_MDI_MSG 92
+195D MDI:d2m/INVALID_MDI_MSG 93
+195E MDI:d2m/INVALID_MDI_MSG 94
+195F MDI:d2m/INVALID_MDI_MSG 95
+1960 MDI:d2m/INVALID_MDI_MSG 96
+1961 MDI:d2m/INVALID_MDI_MSG 97
+1962 MDI:d2m/INVALID_MDI_MSG 98
+1963 MDI:d2m/INVALID_MDI_MSG 99
+1964 MDI:d2m/INVALID_MDI_MSG 100
+1965 MDI:d2m/INVALID_MDI_MSG 101
+1966 MDI:d2m/INVALID_MDI_MSG 102
+1967 MDI:d2m/INVALID_MDI_MSG 103
+1968 MDI:d2m/INVALID_MDI_MSG 104
+1969 MDI:d2m/INVALID_MDI_MSG 105
+196A MDI:d2m/INVALID_MDI_MSG 106
+196B MDI:d2m/INVALID_MDI_MSG 107
+196C MDI:d2m/INVALID_MDI_MSG 108
+196D MDI:d2m/INVALID_MDI_MSG 109
+196E MDI:d2m/INVALID_MDI_MSG 110
+196F MDI:d2m/INVALID_MDI_MSG 111
+1970 MDI:d2m/COMMAND_LOCAL
+1971 MDI:d2m/INVALID_MDI_MSG 113
+1972 MDI:d2m/INVALID_MDI_MSG 114
+1973 MDI:d2m/INVALID_MDI_MSG 115
+1974 MDI:d2m/RESPONSE_LOCAL
+1975 MDI:d2m/INVALID_MDI_MSG 117
+1976 MDI:d2m/INVALID_MDI_MSG 118
+1977 MDI:d2m/INVALID_MDI_MSG 119
+1978 MDI:d2m/INVALID_MDI_MSG 120
+1979 MDI:d2m/INVALID_MDI_MSG 121
+197A MDI:d2m/INVALID_MDI_MSG 122
+197B MDI:d2m/INVALID_MDI_MSG 123
+197C MDI:d2m/INVALID_MDI_MSG 124
+197D MDI:d2m/INVALID_MDI_MSG 125
+197E MDI:d2m/INVALID_MDI_MSG 126
+197F MDI:d2m/INVALID_MDI_MSG 127
+1980 MDI:d2m/RECEIVED_BLOCK
+1981 MDI:d2m/MEAS_REQUEST
+1982 MDI:d2m/INVALID_MDI_MSG 130
+1983 MDI:d2m/RSSI_RESULTS
+1984 MDI:d2m/RA_INFO
+1985 MDI:d2m/INVALID_MDI_MSG 133
+1986 MDI:d2m/BLOCK_REQUEST
+1987 MDI:d2m/NO_BCCH_LEFT
+1988 MDI:d2m/NEIGHBOUR_TIMING_OFFSET
+1989 MDI:d2m/CHANNEL_CHANGED_CNF
+198A MDI:d2m/NO_PSW_FOUND
+198B MDI:d2m/ALL_RSSI_RESULTS
+198C MDI:d2m/DOWNLINK_SIGNALLING_FAIL
+198D MDI:d2m/FBUS_DISCONNECTED
+198E MDI:d2m/FROM_FBUS_TO_MCU
+198F MDI:d2m/NO_PSW_LEFT
+1990 MDI:d2m/INVALID_MDI_MSG 144
+1991 MDI:d2m/INVALID_MDI_MSG 145
+1992 MDI:d2m/INVALID_MDI_MSG 146
+1993 MDI:d2m/INVALID_MDI_MSG 147
+1994 MDI:d2m/FBUS_ERROR
+1995 MDI:d2m/IR_DISABLED
+1996 MDI:d2m/LOOP_BACK_REPLY
+1997 MDI:d2m/LOOP_BACK_SHORT_REPLY
+1998 MDI:d2m/RTC_CALIBRATION_VALUE
+1999 MDI:d2m/TXC_BIAS_MEAS
+199A MDI:d2m/RECEIVED_DTE_DATA_BLOCK
+199B MDI:d2m/RECEIVED_IRLAP_DATA_BLOCK
+199C MDI:d2m/RECEIVED_TCH_DATA_BLOCK
+199D MDI:d2m/INVALID_MDI_MSG 157
+199E MDI:d2m/INVALID_MDI_MSG 158
+199F MDI:d2m/INVALID_MDI_MSG 159
+19A0 MDI:d2m/INVALID_MDI_MSG 160
+19A1 MDI:d2m/INVALID_MDI_MSG 161
+19A2 MDI:d2m/INVALID_MDI_MSG 162
+19A3 MDI:d2m/INVALID_MDI_MSG 163
+19A4 MDI:d2m/INVALID_MDI_MSG 164
+19A5 MDI:d2m/INVALID_MDI_MSG 165
+19A6 MDI:d2m/INVALID_MDI_MSG 166
+19A7 MDI:d2m/INVALID_MDI_MSG 167
+19A8 MDI:d2m/INVALID_MDI_MSG 168
+19A9 MDI:d2m/INVALID_MDI_MSG 169
+19AA MDI:d2m/INVALID_MDI_MSG 170
+19AB MDI:d2m/UNKNOWN_MDI_MSG
+1CXX L1:ph_rr/L1_PH_RR_MSG_TRA
+1C00 L1:ph_rr/RR->:ACTIVATE_CNF(1/0002)
+1C01 L1:ph_rr/RR<-:ACTIVATE_REQ(1/03E9)
+1C02 L1:ph_rr/RR<-:DEACTIVATE_REQ(1/03EA)
+1C03 L1:ph_rr/RR<-:START_AG_LISTEN_REQ(1/03EB)
+1C04 L1:ph_rr/RR<-:STOP_AG_LISTEN_REQ(1/03EC)
+1C05 L1:ph_rr/RR<-:ASSIGN_REQ(1/03ED)
+1C06 L1:ph_rr/HANDOVER_REQ(1/03EE)
+1C07 L1:ph_rr/RR<-:FREQUENCY_REDEF_REQ(1/03EF)
+1C08 L1:ph_rr/RR<-:BACK_TO_PREV_CH_REQ(1/03F0)
+1C09 L1:ph_rr/RR<-:DECONFIG_REQ(1/03F1)
+1C0A L1:ph_rr/RR<-:CH_MODE_MODIFY_REQ(1/03F2)
+1C0B L1:ph_rr/RR<-:PHYS_INFO_REQ(1/03F3)
+1C0C L1:ph_rr/RR<-:CIPHER_START_REQ(1/03F4)
+1C0D L1:ph_rr/RR<-:CIPHER_STOP_REQ(1/03F5)
+1C0E L1:ph_rr/RR<-:PAGE_MODE_REQ(1/03F6)
+1C0F L1:ph_rr/RR->:AG_LISTEN_REJ(1/03F7)
+1C10 L1:ph_rr/RR<-:CONFIG_CNF(1/03F8)
+1C11 L1:ph_rr/RR->:ERROR_IND(1/03F9)
+1C12 L1:ph_rr/RR->:RANDOM_ACCESS_IND(1/03FA)
+1C13 L1:ph_rr/RR->:AG_TIMEOUT_IND(1/03FB)
+1C14 L1:ph_rr/RR->:RESEL_NEEDED_IND(1/03FC)
+1C15 L1:ph_rr/RR->:RESEL_FAIL_IND(1/03FD)
+1C16 L1:ph_rr/RR->:RESEL_IMPOSSIBLE_IND
+1C17 L1:ph_rr/RR<-:STOP_RA_SENDING_REQ
+1C18 L1:ph_rr/RR<-:LIMITED_SERVICE_REQ
+1C19 L1:ph_rr/MDI->:TX_INIT
+1C1A L1:ph_rr/RR<-:CONFIG_CHANGE_REQ
+1C24 (1/040D)
+1C25 (1/040E)
+1C26 (1/040F)
+1C27 (1/0410)
+1C28 (1/0411)
+1C29 (1/0412)
+1C2A (1/0413)
+1C2B (1/0414)
+1C2C (1/0415)
+1C2D (1/0416)
+1C2E (1/0417)
+1C2F (1/0418)
+1C30 (1/0419)
+1C31 (1/041A)
+1C32 (1/041B)
+1C33 (1/0420)
+1C34 (1/0425)
+20XX SIM:fil_msg/SIM_FIL_MSG_TRA
+2000 SIM:fil_msg/UNKNOWN_CMD
+2001 SIM:fil_msg/UPDATE_RECORD
+2002 SIM:fil_msg/RESET_SIM
+2003 SIM:fil_msg/DEACTIVATE_SIM
+2004 SIM:fil_msg/UNBLOCK_GSM_APPLICATION
+2005 SIM:fil_msg/SLEEP
+2006 SIM:fil_msg/STATUS
+2007 SIM:fil_msg/SELECT
+2008 SIM:fil_msg/SEEK
+2009 SIM:fil_msg/VERIFY_PIN
+200A SIM:fil_msg/CHANGE_PIN
+200B SIM:fil_msg/DISABLE_PIN
+200C SIM:fil_msg/RENABLE_PIN
+200D SIM:fil_msg/RUN_SIM_ALGORITHM
+200E SIM:fil_msg/READ_BINARY
+200F SIM:fil_msg/READ_RECORD
+2010 SIM:fil_msg/GET_RESPONSE
+2011 SIM:fil_msg/UPDATE_BINARY
+2012 SIM:fil_msg/INVALIDATE
+2013 SIM:fil_msg/REHABILITATE
+2014 SIM:fil_msg/INCREASE
+2015 SIM:fil_msg/RESET
+2016 SIM:fil_msg/DEACTIVATE
+2017 SIM:fil_msg/TERMINAL_PROFILE
+2018 SIM:fil_msg/ENVELOPE
+2019 SIM:fil_msg/FETCH
+201A SIM:fil_msg/TERMINAL_RESPONSE
+201B SIM:fil_msg/AUTHENTICATE
+201C SIM:fil_msg/AKEY_VALIDATE
+201D SIM:fil_msg/ASK_RANDOM
+201E SIM:fil_msg/UPDATE_SSD
+201F SIM:fil_msg/CONFIRM_SSD
+2020 SIM:fil_msg/CMEA_ENCRYPT
+2021 SIM:fil_msg/SWITCH_TO_5V
+2022 SIM:fil_msg/VOLTAGE_SET
+2023 SIM:fil_msg/SEND_ADM_CODE
+21XX SIM_L2:msg/SIM_L2_MSG_TRA
+2100 SIM_L2:msg/MSG_DATA
+22XX SIM_L2:data/SIM_L2_DATA_TRA
+2200 SIM_L2:data/RECEIVED_DATA
+2201 SIM_L2:data/SENT_DATA
+23XX SIM_L2:resp/SIM_L2_RESP_TRA
+2300 SIM_L2:resp/UNKNOWN_PRIMITIVE
+2301 SIM_L2:resp/CARD_NOT_OK
+2302 SIM_L2:resp/BINARY_DATA_AVAIL
+2303 SIM_L2:resp/FORMATTED_DATA_AVAIL
+2304 SIM_L2:resp/SRES_KC_DATA_AVAIL
+2305 SIM_L2:resp/DFIELD_INFO_AVAIL
+2306 SIM_L2:resp/DIR_INFO_AVAIL
+2307 SIM_L2:resp/ATR_TRACE
+2308 SIM_L2:resp/MEMORY_PROBLEM
+2309 SIM_L2:resp/OK
+230A SIM_L2:resp/DFIELD_NOT_SELECTED
+230B SIM_L2:resp/PATTERN_NOT_FOUND
+230C SIM_L2:resp/OUT_OF_RANGE
+230D SIM_L2:resp/ILLEGAL_OPERATION
+230E SIM_L2:resp/NO_PIN
+230F SIM_L2:resp/SECURITY_VIOLATION
+2310 SIM_L2:resp/PIN_STATUS_MISMATCH
+2311 SIM_L2:resp/CARD_BLOCKED
+2312 SIM_L2:resp/TECH_PROB_NO_DIAG
+2313 SIM_L2:resp/CARD_DISCONNECTED
+2314 SIM_L2:resp/ICC_INSERTED
+2315 SIM_L2:resp/MAX_VALUE_REACHED
+2316 SIM_L2:resp/DUALMODE_DATA_AVAIL
+2317 SIM_L2:resp/3V_SIM
+2318 SIM_L2:resp/5V_SIM
+2319 SIM_L2:resp/ENHANCED_PTS
+231A SIM_L2:resp/ATR_FAILED
+231B SIM_L2:resp/ERROR_IN_ATR
+231C SIM_L2:resp/SEND_FAILED
+231D SIM_L2:resp/PARITY_ERROR
+231E SIM_L2:resp/TIMEOUT_ERROR
+231F SIM_L2:resp/COMM_ERROR
+2320 SIM_L2:resp/OVERFLOW_ERROR
+2321 SIM_L2:resp/RESP_NOT_OK
+2322 SIM_L2:resp/FETCH_REQUEST
+2323 SIM_L2:resp/PROACTIVE_CMD
+2324 SIM_L2:resp/INCREASE_INFO
+2325 SIM_L2:resp/ENVELOPE_RESP
+2326 SIM_L2:resp/INVALIDATION_STATUS_MISMATCH
+2327 SIM_L2:resp/DUALMODE_SIM_SSD_IS_INCORRECT
+2328 SIM_L2:resp/CARD_NOT_OK
+2329 SIM_L2:resp/ENVELOPE_RESP_AVAILABLE
+232A SIM_L2:resp/ATR_RECIEVED
+232B SIM_L2:resp/CARD_BUSY
+24XX L2:prim/L2_PRIMITIVE_TRA
+2400 L2:prim/RR->:EST_REQ(0/05DD)
+2401 L2:prim/RR->:RELEASE_REQ(0/05DE)
+2402 L2:prim/RR->:ABORT_REQ(0/05DF)
+2403 L2:prim/RR->:DATA_REQ(0/05E0)
+2404 L2:prim/RR->:UNIT_DATA_REQ(0/05E1)
+2405 L2:prim/RR->:SUSPEND_REQ(0/05E2)
+2406 L2:prim/RR->:RESUME_REQ(0/05E3)
+2407 L2:prim/RR->:RESUME_COMPLETE_REQ(0/060A)
+2408 L2:prim/RR->:LOCAL_RELEASE_REQ(0/060B)
+2409 L2:prim/RR<-:EST_CNF(0/05E6)
+240A L2:prim/RR<-:EST_IND(0/05E7)
+240B L2:prim/RR<-:RELEASE_CNF(0/05E8)
+240C L2:prim/RR<-:RELEASE_IND(0/05E9)
+240D L2:prim/RR<-:DATA_IND(0/05EA)
+240E L2:prim/RR<-:UNIT_DATA_IND(0/05EB)
+240F L2:prim/RR<-:SUSPEND_CNF(0/05EC)
+2410 L2:prim/RR<-:RESUME_CNF(0/05ED)
+2411 L2:prim/RR<-:ERROR_IND(0/05EE)
+2412 L2:prim/RR<-:ABORT_IND(0/05EF)
+2413 (0/0623)
+2414 (0/0624)
+2415 (0/0622)
+2416 L2:prim/RR->:T200:TIMEOUT(0/05FB)
+2417 L2:prim/RR->:T203:TIMEOUT(0/05FA)
+2419 L2:prim/SMS->SAPI3_SACCH_REL_IND(0/0620)
+241A L2:prim/SMS->SAPI3_NON_SACCH_REL_IND(0/0621)
+25XX RR:prim/RR_PRIMITIVE_TRA
+2500 RR:prim/L2<-:DL_EST_REQ(1/05DD)
+2501 RR:prim/L2<-:DL_RELEASE_REQ(1/05DE)
+2502 RR:prim/L2<-:DL_ABORT_REQ(1/05DF)
+2503 RR:prim/L2<-:DL_DATA_REQ(1/05E0)
+2504 RR:prim/L2<-DL_UNIT_DATA_REQ(1/05E1)
+2505 RR:prim/L2<-:DL_SUSPEND_REQ(1/05E2)
+2506 RR:prim/L2<-:DL_RESUME_REQ(1/05E3)
+2507 RR:prim/L2<-:DL_RESUME_COMPLETE_REQ(1/060A)
+2508 RR:prim/L2<-:DL_LOCAL_RELEASE_REQ(1/060B)
+2509 RR:prim/L2->:DL_EST_CNF(1/05E6)
+250A RR:prim/L2<-:DL_EST_IND(1/05E7)
+250B RR:prim/L2->:DL_RELEASE_CNF(1/05E8)
+250C RR:prim/L2->:DL_RELEASE_IND(1/05E9)
+250D RR:prim/L2->:DL_DATA_IND(1/05EA)
+250E RR:prim/L2->:DL_UNIT_DATA_IND(1/05EB)
+250F RR:prim/L2->:DL_SUSPEND_CNF(1/05EC)
+2510 RR:prim/L2->:DL_RESUME_CNF(1/05ED)
+2511 RR:prim/L2->:DL_ERROR_IND(1/05EE)
+2512 RR:prim/L2->:DL_ABORT_IND(1/05EF)
+2513 RR:prim/MM->:REL_IND(1/07DB)
+2514 RR:prim/MM->:SYNC_IND(1/07DC)
+2515 RR:prim/MM->:TCH_NOT_ALLOC_IND(1/07E2)
+2516 (1/07E3)
+2517 RR:prim/MM->:DATA_IND(1/07DD)
+2518 RR:prim/MM<-:ABORT_REQ(1/07D5)
+2519 RR:prim/MM<-:ACTIVATE_REQ(1/07D6)
+251A (1/0824)
+251B (1/0A03)
+251C (1/0A04)
+251D (1/0A05)
+251E (1/0A06)
+251F (1/0A07)
+2521 (1/0A09)
+2523 (1/0825)
+2524 (1/0826)
+2525 (1/0A0A)
+2527 RR:prim/MM->:UNIT_DATA_IND(1/07DE)
+2528 (1/0A0B)
+2529 RR:prim/MM<-:DEACTIVATE_REQ(1/07D7)
+252A RR:prim/MM<-:CLASSMARK_CHANGE_REQ(1/07D8)
+252B (1/09FD)
+2531 RR:prim/MM->:TCH_SPEECH_ALLOC_IND(1/07E1)
+2533 (1/040D)
+2534 (1/03FE)
+2535 RR:prim/L1->:RANDOM_ACCESS_IND(1/0400)
+2536 RR:prim/L1->:RESEL_NEEDED_IND(1/0402)
+2537 (1/0405)
+2538 RR:prim/L1->:RESEL_IMPOSSIBLE_IND(1/0404)
+2539 RR:prim/L1->:AG_TIMEOUT_IND(1/0401)
+253A (1/0409)
+253B RR:prim/L1->:RESEL_FAIL_IND(1/0403)
+253C (1/0406)
+253D (1/040C)
+253E (1/040B)
+253F RR:prim/L1->:CIPHER_START_REQ(1/03F4)
+2540 (1/0804)
+2542 (1/07FE)
+2543 (1/0800)
+2544 (1/0803)
+2545 (1/0802)
+2546 (1/0801)
+2547 RR:prim/L1->:ERROR_IND(1/03FF)
+2548 RR:prim/L1->:HANDOVER_REQ(1/03EE)
+2556 RR:prim/L1->:CIPHER_STOP_REQ(1/03F5)
+2557 RR:prim/L1->:PAGE_MODE_REQ(1/03F6)
+2558 (1/07FD)
+255D (1/09FF)
+255E RR:prim/MM<-:EST_REQ(1/07D1)
+255F RR:prim/MM<-:REL_REQ(1/07D2)
+2560 RR:prim/MM<-:DATA_REQ(1/07D3)
+2561 RR:prim/MM<-:UNIT_DATA_REQ(1/07D4)
+2562 RR:prim/MM->:EST_CNF(1/07D9)
+2563 RR:prim/MM->:EST_IND(1/07DA)
+2564 RR:prim/MM->:ABORT_IND(1/07DF)
+2565 RR:prim/MM->:ACTIVATE_IND(1/07E0)
+2566 RR:prim/MM->:T3122_TIMEOUT_IND(1/07E4)
+2567 RR:prim/MM<-:PREACTIVATE_REQ(1/07E5)
+2568 RR:prim/MM->:PREACTIVATE_CNF(1/07E6)
+2569 (1/07E7)
+256A (1/09F7)
+256B (1/09F8)
+256C (1/09F9)
+256D (1/09FA)
+256E (1/09FB)
+256F (1/09FC)
+2570 (1/09FE)
+2571 (1/0A02)
+2572 (1/0A0C)
+26XX MM:prim/MM_PRIMITIVE_TRA
+2600 MM:prim/RM->:NREG_IND_LA_ON_REG_LIST(2/0A29)
+2601 MM:prim/RM->:CONN_COMPL_IND(2/0A2A)
+2602 MM:prim/RM->:CONN_REL_IND(2/0A2B)
+2603 (2/0A2C)
+2604 (2/0A2D)
+2605 MM:prim/RR->:LIMITED_SERVICE_STATE_REQ(2/0A2E)
+2606 MM:prim/RM->:PLMN_SEARCH_TERM_IND(2/0A2F)
+2607 MM:prim/RM<-:PLMN_SEARCH_START_REQ(2/0A30)
+2608 (2/0A36)
+2609 (2/0A37)
+260A (2/0A38)
+260B (2/0A39)
+260C (2/0A3B)
+260D (2/0A3C)
+260E (2/0A3E)
+260F (2/0A40)
+2610 (2/0A42)
+2611 (2/0A43)
+2612 (2/0A45)
+2613 (2/0A46)
+2614 (2/0A48)
+2615 (2/0A49)
+2616 (2/0A4B)
+2617 (2/0A4D)
+2618 (2/0A4F)
+261A (2/158C)
+261C (2/0A50)
+261D (2/158D)
+261E (2/1580)
+2620 (2/1581)
+2621 (2/1582)
+2623 (2/0A64)
+2624 (2/0A65)
+2625 (2/0A66)
+2626 (2/0A67)
+2627 (2/0A68)
+2628 (2/0A69)
+2629 (2/0A6A)
+262A (2/0A6C)
+262B (2/0A6D)
+262C (2/0A6E)
+262D (2/0A55)
+262E (2/0A56)
+262F (2/0A57)
+2630 (2/0A58)
+2631 (2/0A59)
+2632 (2/0A5A)
+2633 (2/0A62)
+2634 (2/0A63)
+2635 (2/0A85)
+2636 (2/0A87)
+2637 (2/0A8C)
+2638 (2/0A88)
+2639 (2/0A8D)
+263C (2/0DDF)
+263D MM:prim/RR<-:REL_IND(2/07DB)
+263E MM:prim/RR<-:SYNC_IND(2/07DC)
+263F (2/07E2)
+2640 MM:prim/RR<-:DATA_IND(2/07DD)
+2641 MM:prim/RR->:ABORT_REQ(2/07D5)
+2642 MM:prim/RR->:ACTIVATE_REQ(2/07D6)
+2643 MM:prim/CM<-:EST_REQ_EMERGENCY(2/0A03)
+2644 MM:prim/CM<-:REEST_REQ(2/0A04)
+2645 MM:prim/CM<-:REL_REQ(2/0A05)
+2646 MM:prim/CM<-:DATA_REQ(2/0A06)
+2647 MM:prim/MM<-:LAI_LISTS_TIMEOUT(2/0A07)
+2649 MM:prim/CM->:EST_CNF(2/0A09)
+264B MM:prim/CM->:ERROR_IND(2/0A0A)
+264C (2/0A0B)
+264D MM:prim/RR->:DEACTIVATE_REQ(2/07D7)
+264E (2/07D8)
+264F MM:prim/MM<-:T3240_TIMEOUT(2/09FD)
+2653 MM:prim/RR<-:UNIT_DATA_IND(2/07DE)
+2654 (2/07E1)
+2655 (2/0A5B)
+2656 (2/0A5C)
+2657 (2/0A5D)
+2658 (2/0A5E)
+2659 (2/0A5F)
+265A (2/0A60)
+265B (2/0A61)
+265C (2/0A81)
+265D (2/0A6B)
+265E MM:prim/SMS<-:DATA_REQ(2/09C9)
+265F MM:prim/SMS->:ERROR_IND(2/09CA)
+2660 (2/158A)
+2668 (2/0AA0)
+2669 (2/0AA1)
+266A MM:prim/SMS->:REL_IND(2/09CB)
+2675 (2/1584)
+2676 (2/1585)
+2677 (2/1586)
+2678 (2/1587)
+2679 (2/1588)
+267A (2/158E)
+267B MM:prim/RR->:EST_REQ(2/07D1)
+267C MM:prim/RR->:REL_REQ(2/07D2)
+267D MM:prim/RR->:DATA_REQ(2/07D3)
+267E (2/07D4)
+267F MM:prim/RR<-:EST_CNF(2/07D9)
+2680 MM:prim/RR<-:EST_IND(2/07DA)
+2681 MM:prim/RR<-:ABORT_IND(2/07DF)
+2682 MM:prim/RR<-:ACTIVATE_IND(2/07E0)
+2683 MM:prim/RR<-:T3122_TIMEOUT_IND(2/07E4)
+2684 MM:prim/RR->:PREACTIVATE_REQ(2/07E5)
+2685 MM:prim/RR->:PREACTIVATE_CNF(2/07E6)
+2686 (2/07E7)
+2687 MM:prim/MM<-:T3210_TIMEOUT(2/09F7)
+2688 MM:prim/MM<-:T3211_TIMEOUT(2/09F8)
+2689 MM:prim/MM<-:T3212_TIMEOUT(2/09F9)
+268A MM:prim/MM<-:T3213_TIMEOUT(2/09FA)
+268B MM:prim/MM<-:T3220_TIMEOUT(2/09FB)
+268C MM:prim/MM<-:T3230_TIMEOUT(2/09FC)
+268D MM:prim/RM->:NREG_IND_NO_IMSI(2/09FE)
+268E MM:prim/CM<-:EST_REQ_NORMAL(2/0A02)
+268F (2/0A0C)
+27XX CC:prim/CC_PRIMITIVE_TRA
+2700 (3/0FA2)
+2701 CC:prim/CS->:SETUP_REQ(3/0FA3)
+2702 CC:prim/CS->:EMERGENCY_SETUP_REQ(3/0FA4)
+2703 CC:prim/CS->:SETUP_RES(3/0FA5)
+2704 CC:prim/CS->:SETUP_REJ_REQ(3/0FA6)
+2705 CC:prim/CS->:CALL_CONF_REQ(3/0FA7)
+2706 CC:prim/CS->:MODIFY_REQ(3/0FA8)
+2707 CC:prim/CS->:NOTIFY_REQ(3/0FA9)
+2708 CC:prim/CS->:DISC_REQ(3/0FAA)
+2709 CC:prim/CS->:REL_REQ(3/0FAB)
+270A CC:prim/CS->:ALERTING_REQ(3/0FAC)
+270C CC:prim/CS->:STATUS_ENQ_REQ(3/0FAE)
+270E CC:prim/CS->:MODIFY_RES(3/0FB0)
+270F CC:prim/CS->:MODIFY_REJ_REQ(3/0FB1)
+2710 CC:prim/CS->:SS_REQ(3/0FB2)
+2711 CC:prim/CS->:REJ_REQ(3/0FB3)
+2712 CC:prim/CS<-:SETUP_IND(3/0FB4)
+2713 CC:prim/CS<-:SETUP_CNF(3/0FB5)
+2714 CC:prim/CS<-:SETUP_COMPL_IND(3/0FB6)
+2715 CC:prim/CS<-:CALL_PROC_IND(3/0FB7)
+2716 CC:prim/CS<-:PROGRESS_IND(3/0FB8)
+2717 CC:prim/CS<-:ALERT_IND(3/0FB9)
+271A CC:prim/CS<-:MODIFY_REJ_IND(3/0FBC)
+271B CC:prim/CS<-:NOTIFY_IND(3/0FBD)
+271C CC:prim/CS<-:DISC_IND(3/0FBE)
+271D CC:prim/CS->:REJ_IND(3/0FBF)
+271E CC:prim/CS->:REL_IND(3/0FC0)
+271F CC:prim/CS<-:START_DTMF_CNF(3/0FC1)
+2720 CC:prim/CS<-:START_DTMF_REJ_IND(3/0FC2)
+2721 CC:prim/CS<-:STATE_UPDATE_IND(3/0FC3)
+2722 CC:prim/CS<-:STATUS_IND(3/0FC4)
+2723 CC:prim/CS<-:STOP_DTMF_IND(3/0FC5)
+2724 CC:prim/CS<-:STOP_DTMF_CNF(3/0FC6)
+2725 CC:prim/CS<-:ERROR_IND(3/0FC7)
+2726 CC:prim/CS<-:SS_IND(3/0FC8)
+2727 CC:prim/CS<-:REL_CNF(3/0FC9)
+2728 CC:prim/CS<-:REL_COMPL_IND(3/0FCA)
+2729 CC:prim/MM<-:MM_CONN_COMPL_IND(3/0FCB)
+272A (3/100F)
+272B (3/1010)
+272C (3/1011)
+272D (3/1012)
+272E (3/1013)
+272F (3/1014)
+2730 (3/100D)
+2731 (3/100E)
+2732 (3/1020)
+2733 (3/101C)
+2734 (3/0A36)
+2735 (3/0A37)
+2736 (3/0A38)
+2737 (3/0A39)
+273E CC:prim/CS->:RESET_REQ(3/0FA1)
+28XX CS:prim/CS_PRIMITIVE_TRA
+2800 (5/15B4)
+2802 CS:prim/PLMN_SELECT(5/157D)
+2806 (5/15AE)
+2807 (5/15AF)
+280A (5/157E)
+280B (5/15B2)
+280C (5/15B3)
+280E (5/15B5)
+280F (5/15A4)
+2810 (5/15A5)
+2811 (5/15A6)
+2812 (5/15A7)
+2815 (5/15A8)
+2816 (5/15A9)
+2819 CS:prim/CC->:ALERT_IND(5/0FB9)
+281A CS:prim/CC<-ALERTING_REQ(5/0FAC)
+281B CS:prim/CC<-:CALL_CONF_REQ(5/0FA7)
+281D CS:prim/CC->:DISC_IND(5/0FBE)
+281E CS:prim/CC<-:DISC_REQ(5/0FAA)
+2820 (5/1010)
+2821 (5/100F)
+2822 (5/1011)
+2823 CS:prim/MM->:CONN_COMPL_IND(5/0FCB)
+2826 CS:prim/CC<-:MODIFY_REQ(5/0FA8)
+2827 CS:prim/CC->:MODIFY_RES(5/0FB0)
+2828 CS:prim/CC<-:MODIFY_REJ_REQ(5/0FB1)
+2829 CS:prim/CC->:MODIFY_REJ_IND(5/0FBC)
+282B CS:prim/CC->:PROGRESS_IND(5/0FB8)
+282C (5/100D)
+282D (5/100E)
+2830 CS:prim/CC<-:REL_IND(5/0FC0)
+2831 CS:prim/CC<-:REL_REQ(5/0FAB)
+2832 CS:prim/CC->:REL_COMPL_IND(5/0FCA)
+2833 (5/1013)
+2834 (5/1012)
+2835 (5/1014)
+2836 CS:prim/CC->:SETUP_CNF(5/0FB5)
+2837 CS:prim/CC->:SETUP_COMPL_IND(5/0FB6)
+2838 CS:prim/CC->:SETUP_IND(5/0FB4)
+2839 CS:prim/CC<-:SETUP_REQ(5/0FA3)
+283A CS:prim/CC->:SETUP_RES(5/0FA5)
+283B CS:prim/CC<-:SETUP_REJ_REQ(5/0FA6)
+283C CS:prim/CC->:SS_IND(5/0FC8)
+283D CS:prim/CC<-:SS_REQ(5/0FB2)
+283E CS:prim/CC<-:START_DTMF_REQ(5/0FAD)
+2841 CS:prim/CC<-:STOP_DTMF_REQ(5/0FAF)
+2843 (5/1015)
+2844 (5/1016)
+2845 (5/101C)
+2846 (5/101D)
+2847 (5/101E)
+2848 (5/1020)
+2849 (5/0A36)
+284A (5/0A37)
+284B (5/0A38)
+284C (5/0A39)
+284E (5/0A65)
+284F (5/0A64)
+2854 CS:prim/PLMN_SEARCH(5/1589)
+285B (5/0826)
+285C (5/0825)
+2861 (5/15B6)
+29XX SSCL:prim/SSCL_PRIMITIVE_TRA
+2900 SSCL:prim/SS_UPL->:BEGIN_IND(6/1771)
+2901 SSCL:prim/SS_UPL->:END_IND(6/1773)
+2902 SSCL:prim/SS_UPL->:ERROR_IND(6/1774)
+2903 SSCL:prim/MM<-:FACILITY_IND(7/177A)
+2904 SSCL:prim/SS_UPL->:PARA_CONN_IND(6/177D)
+2905 SSCL:prim/SS_UPL->:REL_IND(6/1775)
+2906 SSCL:prim/MM->:PARA_MM_SS_REL_REQ(6/177F)
+2907 SSCL:prim/MM->:PARA_MM_SS_DATA_REQ(6/179B)
+2908 SSCL:prim/MM->:SS_DATA_REQ(6/0A46)
+2909 SSCL:prim/MM->:SS_EST_REQ(6/0A43)
+290A SSCL:prim/MM->:SS_REL_REQ(6/0A45)
+290B SSCL:prim/UNKNOWN_SSCL_PRIMITIVE
+2AXX SMS:prim/SMS_PRIMITIVE_TRA
+2A00 SMS:prim/SMTL<-:SMRL_MEM_CAP_AVAIL_REQ(8/0BBF)
+2A01 SMS:prim/SMTL<-:SMRL_DATA_REQ(8/0BB9)
+2A02 SMS:prim/SMTL->:SMRL_REPORT_IND(8/0BBA)
+2A03 SMS:prim/SMTL->:SMRL_DATA_IND(8/0BBC)
+2A04 SMS:prim/SMTL->:SMRL_DATA_RSP(8/0BBD)
+2A05 SMS:prim/SMTL<-:SMRL_INIT_STD_REQ(8/0BBE)
+2A06 SMS:prim/SMTL<-:CB_ACTIVATE_REQ(8/0BC0)
+2A07 SMS:prim/SMTL<-:CB_DEACTIVATE_REQ(8/0BC1)
+2A08 SMS:prim/SMTL<-:MEM_CAP_AVAIL_REQ(8/0BBF)
+2A09 SMS:prim/SMTL<-:SMTL_TPDU(8/0BEB)
+2A0A SMS:prim/SMRL<-:SMCL_DATA_REQ(8/0DAD)
+2A0B SMS:prim/SMRL->:SMCL_DATA_IND(8/0DAE)
+2A0C SMS:prim/SMRL<-:SMCL_ABORT_REQ(8/0DAF)
+2A0D SMS:prim/SMRL->:SMCL_EST_IND(8/0DB0)
+2A0E SMS:prim/SMRL<-:SMCL_EST_REQ(8/0DB1)
+2A0F SMS:prim/SMRL->:SMCL_ERROR_IND(8/0DB2)
+2A10 SMS:prim/SMRL<-:SMCL_REL_REQ(8/0DB3)
+2A11 SMS:prim/SMRL<-:SMCL_INIT_STD_REQ(8/0DB4)
+2A12 SMS:prim/UNKNOWN_SMS_PRIMITIVE
+2A13 SMS:prim/MM<-:SMSCB_ZONE_CHANGED_IND
+2A14 SMS:prim/MM<-:EST_IND(8/0A29)
+2A15 SMS:prim/MM->:EST_REQ(8/0A2A)
+2A16 SMS:prim/MM<-:EST_CNF(8/0A2B)
+2A17 SMS:prim/MM<-:DATA_IND(8/0A2C)
+2A18 SMS:prim/MM->:DATA_REQ(8/0A2D)
+2A19 SMS:prim/MM<-:ERROR_IND(8/0A2E)
+2A1A SMS:prim/MM<-:REL_IND(8/0A2F)
+2A1B SMS:prim/MM->:REL_REQ(8/0A30)
+2A1C SMS:prim/L2<-SAPI3_SACCH_REL_IND(8/0620)
+2A1D SMS:prim/L2<-SAPI3_NON_SACCH_REL_IND(8/0621)
+2BXX SIM:prim/SIM_PRIMITIVE_TRA
+2B00 SIM:prim/PIN_VERIFY_START
+2B01 SIM:prim/PIN_CHANGE_START
+2B02 SIM:prim/PIN_DISABLE_START
+2B03 SIM:prim/PIN_ENABLE_START
+2B04 SIM:prim/UNBLOCK_START
+2B05 SIM:prim/INIT
+2B06 SIM:prim/DEACTIVATE
+2B07 SIM:prim/UPDATE
+2B08 SIM:prim/COMPUTE_GSM_ALGORITHMS
+2B09 SIM:prim/STORE_SCM_NBR
+2B0A SIM:prim/SCM_NBR_TO_BE_STORED
+2B0B SIM:prim/RECALL_SCM_NBR
+2B0C SIM:prim/PIN2_VERIFY_START
+2B0D SIM:prim/PIN2_CHANGE_START
+2B0E SIM:prim/PIN2_UNBLOCK_START
+2B0F SIM:prim/ACM_INCREMENT
+2B10 SIM:prim/ACM_SET
+2B11 SIM:prim/ACM_MAX_VALUE_SET
+2B12 SIM:prim/PUCT_SET
+2B13 SIM:prim/PUCT_READ
+2B14 SIM:prim/STORE_MSISDN_NBR
+2B15 SIM:prim/READ_MSISDN_NBR
+2B16 SIM:prim/STORE_SMS_PARAM
+2B17 SIM:prim/READ_SMS_PARAM
+2B18 SIM:prim/STORE_FIXDIAL_NUMBER
+2B19 SIM:prim/READ_FIXDIAL_NUMBER
+2B1A SIM:prim/ACTIVATE_FIXDIAL
+2B1B SIM:prim/DEACTIVATE_FIXDIAL
+2B1C SIM:prim/FDN_NBR_TO_BE_STORED
+2B1D SIM:prim/MSISDN_TO_BE_STORED
+2B1E SIM:prim/STO_SCM_NBR
+2B1F SIM:prim/RCL_SCM_NBR
+2B20 SIM:prim/SMS_PARAM_TO_BE_STORED
+2B21 SIM:prim/RECALL_SCM_NBR_SIF
+2B22 SIM:prim/TEST_SYNC_MSG
+2B23 SIM:prim/ACM_FROM_CARD
+2B24 SIM:prim/MAILBOX_NBR_STORE_MSG
+2B25 SIM:prim/MAILBOX_NBR_READ_MSG
+2B26 SIM:prim/OPERATOR_NAME_READ_MSG
+2B27 SIM:prim/MICROTEL_PARAMS_READ_MSG
+2B28 SIM:prim/CSP_READ_MSG
+2B29 SIM:prim/MAILBOX_NBR_TO_BE_STORED
+2B2A SIM:prim/SMS_READ_MSG
+2B2B SIM:prim/SMS_STORE_MO_MSG
+2B2C SIM:prim/SMS_CLEAR_MSG
+2B2D SIM:prim/SMS_UPDATE_MSG
+2B2E SIM:prim/SMS_STORE_MT_MSG
+2B2F SIM:prim/SMS_MSG_TO_BE_STORED
+2B30 SIM:prim/SMS_STORE_MSG
+2B31 SIM:prim/SMS_INIT
+2B32 SIM:prim/SCM_INIT
+2B33 SIM:prim/FDN_INIT
+2B34 SIM:prim/UNDEFINED_SIM_PRIMITIVE
+2B35 SIM:prim/PIN_CHECK_START
+2B36 SIM:prim/SIM_REFRESH
+2B37 SIM:prim/SMS_STORE_AND_CLEAR
+2B38 SIM:prim/WELCOME_MSG_READ
+2B39 SIM:prim/FIRST_PLMN_WRITE
+2B3A SIM:prim/UPDATE_MSG_REF
+2B3B SIM:prim/PLUG_IN_CARD_DISCONNECTED
+2B3C SIM:prim/READ_INF_NBR_MSG
+2B3D SIM:prim/READ_JACOB_ID_MSG
+2B3E SIM:prim/SIMP_WARM_INIT
+2B3F SIM:prim/SIMP_REFRESH_RSP
+2B40 SIM:prim/SIMP_UI_REFRESH_RSP
+2B41 SIM:prim/SIMP_SMS_PP_STORE_MSG
+2B42 SIM:prim/READ_SID_LIST
+2B43 SIM:prim/READ_CALL_COUNT
+2B44 SIM:prim/INC_CALL_COUNT
+2B45 SIM:prim/WRITE_CALL_COUNT
+2B46 SIM:prim/AUTH_SIGN_CALC
+2B47 SIM:prim/AUTH_RANDBS_GET
+2B48 SIM:prim/AKEY_VALIDATE
+2B49 SIM:prim/SSD_GENERATE
+2B4A SIM:prim/SSD_CONFIRM
+2B4B SIM:prim/CMEA_ENCRYPT
+2B4C SIM:prim/AUTH_CHECK
+2CXX RM:prim/RM_PRIMITIVE_TRA
+2C00 RM:prim/CC->:EMERGENCY_SETUP_REQ(4/0FA4)
+2C01 RM:prim/MM->:LIMITED_SERVICE_STATE_REQ(4/09CF)
+2C02 RM:prim/MM->:REG_REQ(4/09CD)
+2C03 RM:prim/MM->:NREG_REQ(4/09CE)
+2C04 RM:prim/MM->:SIM_INFO_READ_ALL_REQ(4/09D2)
+2C05 RM:prim/MM->:SIM_INSERTED_REQ(4/09D3)
+2C06 RM:prim/MM->:PLMN_SEARCH_START_REQ(4/09C9)
+2C07 RM:prim/MM->:PLMN_SEARCH_STOP_REQ(4/09CA)
+2C08 RM:prim/MM->:PLMN_REL_SEARCH_INFO(4/09CB)
+2C09 RM:prim/MM->:PH_UPL_PLMN_SEARCH_START_REQ(4/09C8)
+2C0A RM:prim/MM->PH_UPL_PLMN_SEARCH_STOP_REQ(4/09C7)
+2C0B RM:prim/MM->:NSPS_MON_START_REQ(4/09C5)
+2C0C RM:prim/MM->:NSPS_MON_STOP_REQ(4/09C6)
+2C0D RM:prim/UNKNOWN_RM_PRIMITIVE(4/09CC)
+2C0E (4/09D0)
+2C0F (4/09D1)
+2C10 (4/09D6)
+2DXX L2:pdu/L2_PDU_TRA
+2D00 L2:pdu/->:DISC(9/060F)
+2D01 L2:pdu/->:DM(9/0610)
+2D02 L2:pdu/->:EMPTY(9/0611)
+2D03 L2:pdu/->:RRE(9/0612)
+2D04 L2:pdu/->:SABM(9/0613)
+2D05 L2:pdu/->:UA(9/0614)
+2D06 (9/1025)
+2D07 L2:pdu/->:I_CMD(9/0616)
+2D08 L2:pdu/->:RNR(9/0617)
+2D09 L2:pdu/->:REJ(9/0618)
+2D0A L2:pdu/->:UNNUMBERED_INFO(9/061A)
+2D0B L2:pdu/->:PDU_ERROR(9/061B)
+2D0C L2:pdu/<-:DISC(10/060F)
+2D0D L2:pdu/<-:DM(10/0610)
+2D0E L2:pdu/<-:EMPTY(10/0611)
+2D0F L2:pdu/<-:RRE(10/0612)
+2D10 L2:pdu/<-:SABM(10/0613)
+2D11 L2:pdu/<-:UA(10/0614)
+2D12 (10/1025)
+2D13 L2:pdu/<-:I_CMD(10/0616)
+2D14 L2:pdu/<-:RNR(10/0617)
+2D15 L2:pdu/<-:REJ(10/0618)
+2D16 L2:pdu/<-:UNNUMBERED_INFO(10/061A)
+2D17 L2:pdu/<-:PDU_ERROR(10/061B)
+2EXX RR:pdu/RR_PDU_TRA
+2E00 RR:pdu/->:CH_REQ
+2E01 RR:pdu/->:ASSIGN_COM(11/08A6)
+2E02 RR:pdu/->:ASSIGN_FAILURE(11/08A7)
+2E03 RR:pdu/->:CH_MODE_MODIFY_ACK(11/08A8)
+2E04 RR:pdu/->:HANDOVER_COM(11/08A9)
+2E05 RR:pdu/->:HANDOVER_FAILURE(11/08AA)
+2E06 RR:pdu/->:RR_STATUS(11/08AB)
+2E07 RR:pdu/->:PAGING_RESP(11/08AC)
+2E08 RR:pdu/->:CIPH_MODE_COM(11/08AD)
+2E09 RR:pdu/->:CLASSMARK_CHANGE(11/08AE)
+2E0A RR:pdu/<-:PDU_IGNORE(12/0000)
+2E0B RR:pdu/<-:ASSIGN_CMD(12/0898)
+2E0C RR:pdu/<-:IMM_ASSIGN(12/0899)
+2E0D RR:pdu/<-:IMM_ASSIGN_REJ(12/089A)
+2E0E RR:pdu/<-:CH_MODE_MODIFY(12/089B)
+2E0F RR:pdu/<-:HANDOVER_CMD(12/089C)
+2E10 RR:pdu/<-:PHYS_INFO(12/089D)
+2E11 RR:pdu/<-:CH_REL(12/089E)
+2E12 RR:pdu/<-:CLASSMARK_ENQ(12/089F)
+2E13 RR:pdu/<-:FREQ_REDEF(12/08A0)
+2E14 RR:pdu/<-:CIPH_MODE_CMD(12/08A1)
+2E15 RR:pdu/<-:PAG_REQ_1(12/08A2)
+2E16 RR:pdu/<-:PAG_REQ_2(12/08A3)
+2E17 RR:pdu/<-:PAG_REQ_3(12/08A4)
+2E18 RR:pdu/<-:CLASSMARK_CHANGE(12/08AE)
+2E19 RR:pdu/<-:OWN_PAGE_MODE(12/08AF)
+2E1A RR:pdu/<-:MESSAGE_TYPE_ERROR(12/08B0)
+2E1B RR:pdu/<-:IE_CONTENT_ERROR(12/08B1)
+2E1C RR:pdu/<-:ASSIGN_CMD_MISSING_CA(12/08B2)
+2E1D RR:pdu/<-:ASSIGN_CMD_CH_MODE_ERR(12/08B3)
+2E1E RR:pdu/<-:ASSIGN_CMD_FREQ_ERR(12/08B4)
+2E1F RR:pdu/<-:HANDOVER_CMD_CH_MODE_ERR(12/08B5)
+2E20 RR:pdu/<-:HANDOVER_CMD_CIPH_MSG_ERR(12/08C2)
+2E21 RR:pdu/<-:HANDOVER_CMD_FREQ_ERR(12/08B6)
+2E22 RR:pdu/<-:HANDOVER_CMD_TA_RANGE_ERR(12/08C4)
+2E23 RR:pdu/<-:ASSIGN_FREQLIST_ID_ERROR(12/08BA)
+2E24 RR:pdu/<-:HO_FREQLIST_ID_ERROR(12/08BB)
+2E25 RR:pdu/<-:HO_FREQLIST_SHORT_ERROR(12/08BC)
+2E26 RR:pdu/<-:UNSPEC_PROTOCOL_ERROR(12/08BD)
+2E27 RR:pdu/<-:MESSAGE_MAND_INFO_ERROR(12/08BE)
+2E28 RR:pdu/<-:MESSAGE_PROTOCOL_STATE_ERROR(12/08BF)
+2E29 RR:pdu/<-:MESSAGE_SEMANTICAL_ERROR(12/08C0)
+2E2A RR:pdu/<-:MESSAGE_COND_INFO_ERROR(12/08C1)
+2E2B RR:pdu/<-:ASSIGN_CMD_CIPH_MSG_ERR(12/08C3)
+2E2C RR:pdu/<-:IMM_ASS_SEMANTIC_ERROR(12/08C5)
+2E2D RR:pdu/UNKNOWNPDU
+2E2E RR:pdu/->:CONFIG_CHANGE_ACK
+2E2F RR:pdu/->:CONFIG_CHANGE_REJ
+2E30 RR:pdu/<-:CONFIG_CHANGE
+2FXX MM:pdu/MM_PDU_TRA
+2F00 MM:pdu/->:CM_SERV_ABORT(13/0062)
+2F01 MM:pdu/->:IMSI_DETACH_IND(13/0047)
+2F02 MM:pdu/->:LOC_UPD_REQ(13/004A)
+2F03 MM:pdu/->:AUT_RESPONSE(13/004D)
+2F04 MM:pdu/->:TMSI_REAL_COM(13/004F)
+2F05 MM:pdu/->:ID_RESPONSE(13/0051)
+2F06 MM:pdu/->:CM_SERV_REQ(13/0054)
+2F07 MM:pdu/->:PDU_CM_REEST_REQ(13/0055)
+2F08 MM:pdu/->:MM_STATUS(13/0056)
+2F09 MM:pdu/<-:LOC_UPD_ACCEPT(14/0048)
+2F0A MM:pdu/<-:LOC_UPD_REJECT(14/0049)
+2F0B MM:pdu/<-:AUT_REJ_CMD(14/004B)
+2F0C MM:pdu/<-:AUT_REQ(14/004C)
+2F0D MM:pdu/<-:TMSI_REAL_CMD(14/004E)
+2F0E MM:pdu/<-:ID_REQ(14/0050)
+2F0F MM:pdu/<-:CM_SERV_ACCEPT(14/0052)
+2F10 MM:pdu/<-:CM_SERV_REJECT(14/0053)
+2F11 MM:pdu/<-:MM_STATUS(14/0056)
+2F12 MM:pdu/<-:RR_CM_DATA_IND(14/0057)
+2F13 MM:pdu/<-:ILLEGAL_PDU(14/0063)
+2F14 MM:pdu/<-:EMMI_PDU(14/0065)
+2F15 MM:pdu/<-:ABORT(14/0061)
+2F16 MM:pdu/<-:MM_INFORMATION(14/006B)
+2F17 MM:pdu/<-:PDU_IGNORED(14/0064)
+2F18 MM:pdu/UNKNOWNPDU
+30XX CC:pdu/CC_PDU_TRA
+3000 CC:pdu/->:ALERT(15/1022)
+3001 CC:pdu/->:CALL_CONF(15/1023)
+3002 CC:pdu/->:CONN(15/1025)
+3003 CC:pdu/->:CONN_ACK(15/1026)
+3004 CC:pdu/->:EMERGENCY_SETUP(15/1027)
+3005 CC:pdu/->:SETUP(15/1029)
+3006 CC:pdu/->:MODIFY
+3007 CC:pdu/->:MODIFY_COM(15/102B)
+3008 CC:pdu/->:MODIFY_REJ(15/102C)
+3009 CC:pdu/->:DISC(15/102D)
+300A CC:pdu/->:REL(15/102E)
+300B CC:pdu/->:REL_COM(15/102F)
+300C CC:pdu/->:CONG(15/1030)
+300D CC:pdu/->:NOTIFY(15/1031)
+300E CC:pdu/->:START_DTMF(15/1032)
+300F CC:pdu/->:START_DTMF_ACK
+3010 CC:pdu/->:START_DTMF_REJ
+3011 CC:pdu/->:STATUS(15/1035)
+3012 CC:pdu/->:STATUS_ENQ(15/1036)
+3013 CC:pdu/->:STOP_DTMF(15/1037)
+3014 CC:pdu/->:STOP_DTMF_ACK
+3015 CC:pdu/->:HOLD(15/1039)
+3016 CC:pdu/->:FACILITY(15/103A)
+3017 CC:pdu/->:HOLD_REJ
+3018 CC:pdu/->:RETRIEVE(15/103F)
+3019 CC:pdu/->:USER_INFO(15/1040)
+301A CC:pdu/->:UNKNOWN_PDU
+301B CC:pdu/<-:ALERT(16/1022)
+301C CC:pdu/<-:CALL_PROC(16/1024)
+301D CC:pdu/<-:CONN(16/1025)
+301E CC:pdu/<-:CONN_ACK(16/1026)
+301F CC:pdu/<-:PROG(16/1028)
+3020 CC:pdu/<-:SETUP(16/1029)
+3021 CC:pdu/<-:MODIFY(16/102A)
+3022 CC:pdu/<-:MODIFY_COM
+3023 CC:pdu/<-:MODIFY_REJ
+3024 CC:pdu/<-:DISC(16/102D)
+3025 CC:pdu/<-:REL(16/102E)
+3026 CC:pdu/<-:REL_COM(16/102F)
+3027 CC:pdu/<-:CONG(16/1030)
+3028 CC:pdu/<-:NOTIFY(16/1031)
+3029 CC:pdu/<-:START_DTMF_ACK(16/1033)
+302A CC:pdu/<-:START_DTMF_REJ(16/1034)
+302B CC:pdu/<-:STATUS(16/1035)
+302C CC:pdu/<-:STATUS_ENQ(16/1036)
+302D CC:pdu/<-:STOP_DTMF_ACK(16/1038)
+302E CC:pdu/<-:FACILITY(16/103A)
+302F CC:pdu/<-:HOLD_REJ(16/103B)
+3030 CC:pdu/<-:HOLD_ACK(16/103C)
+3031 CC:pdu/<-:RETRIEVE_ACK(16/103D)
+3032 CC:pdu/<-:RETRIEVE_REJ(16/103E)
+3033 CC:pdu/<-:USER_INFO(16/1040)
+3034 CC:pdu/<-:PDU_IGNORE
+3035 CC:pdu/<-:UNKNOWN_PDU
+3036 CC:pdu/UNKNOWN_PDU
+3037 CC:pdu/Err/INVALID_TRAN_ID(16/1041)
+3038 CC:pdu/Err/MESSAGE_MAND(16/1043)
+3039 CC:pdu/Err/MESSAGE_COND(16/1049)
+303A CC:pdu/Err/MESSAGE_PROTOCOL(16/104B)
+303B CC:pdu/Err/MESSAGE_SEMANTICAL(16/104A)
+303C CC:pdu/Err/MESSAGE_TYPE(16/1042)
+303D CC:pdu/Err/DISC_MAND(16/1044)
+303E CC:pdu/Err/DISC_OPT(16/1045)
+303F CC:pdu/Err/PDU_IGNORE(16/0000)
+3040 CC:pdu/Err/REL_MAND(16/1046)
+3041 CC:pdu/Err/REL_OPT(16/1047)
+3042 CC:pdu/Err/SETUP(16/1048)
+31XX SSCL:pdu/SSCL_PDU_TRA
+3100 SSCL:pdu/->:RELEASE_COMPLETE(17/002A)
+3101 SSCL:pdu/->:FACILITY(17/003A)
+3102 SSCL:pdu/->:REGISTER(17/003B)
+3103 SSCL:pdu/<-:RELEASE_COMPLETE(18/002A)
+3104 SSCL:pdu/<-:FACILITY(18/003A)
+3105 SSCL:pdu/<-:REGISTER(18/003B)
+3106 SSCL:pdu/UNKNOWN_PDU
+32XX SMS:pdu/SMS_PDU_TRA
+3200 SMS:pdu/->:RP_DATA(19/0BCD)
+3201 SMS:pdu/->:RP_ACK(19/0BCE)
+3202 SMS:pdu/->:RP_ERROR(19/0BCF)
+3203 SMS:pdu/->:RP_SMMA(19/0BD0)
+3204 SMS:pdu/->:TR1M_TIMEOUT(19/0BD7)
+3205 SMS:pdu/->:TRAM_TIMEOUT(19/0BD8)
+3206 SMS:pdu/->:TR99_TIMEOUT(19/0BD9)
+3207 SMS:pdu/->:TR2M_TIMEOUT(19/0BDA)
+3208 SMS:pdu/->:CP_WAIT_TIMEOUT(19/0DCD)
+3209 SMS:pdu/->:CB_SCHEDULE_TIMEOUT(19/0DCE)
+320A SMS:pdu/->:TC1M_TIMEOUT(19/0DCB)
+320B SMS:pdu/->:TC2M_TIMEOUT(19/0DCC)
+320C SMS:pdu/->:CP_DATA(19/0DC1)
+320D SMS:pdu/->:CP_ACK(19/0DC2)
+320E SMS:pdu/->:CP_ERROR(19/0DC3)
+320F SMS:pdu/<-:RP_DATA(20/0BCD)
+3210 SMS:pdu/<-:RP_ACK(20/0BCE)
+3211 SMS:pdu/<-:RP_ERROR(20/0BCF)
+3212 SMS:pdu/<-:CP_DATA(20/0DC1)
+3213 SMS:pdu/<-:CP_ACK(20/0DC2)
+3214 SMS:pdu/<-:CP_ERROR(20/0DC3)
+3215 SMS:pdu/<-:CP_PDU_ERROR(20/0DC4)
+3216 SMS:pdu/<-:CP_PDU_NEW_TRAN_ID(20/0DC5)
+3217 SMS:pdu/UNKNOWN_PDU
+33XX CS:trans/CS_TRANSITION_TRA
+3300 CS:trans/TRANSITION_TO
+34XX L2:trans/L2_TRANSITION_TRA
+3400 L2:trans/TRANSITION_TO
+35XX RR:trans/RR_TRANSITION_TRA
+3500 RR:trans/TRANSITION_TO
+36XX CC:trans/CC_TRANSITION_TRA
+3600 CC:trans/TRANSITION_TO
+37XX RM_CTRL:trans/RM_CTRL_TRANSITION_TRA
+3700 RM_CTRL:trans/TRANSITION_TO
+38XX MM:trans/MM_TRANSITION_TRA
+3800 MM:trans/TRANSITION_TO
+39XX SSCL:trans/SSCL_TRANSITION_TRA
+3900 SSCL:trans/TRANSITION_TO
+3AXX SSCL_MO:trans/SMCL_MO_TRANSITION_TRA
+3A00 SSCL_MO:trans/unused
+3BXX SSCL_MT:trans/SMCL_MT_TRANSITION_TRA
+3B00 SSCL_MT:trans/unused
+3CXX SMRL:trans/SMRL_TRANSITION_TRA
+3C00 SMRL:trans/unused
+47XX L1:PLMN_info/PLMN_INFO_TRA
+4700 L1:PLMN_info/PLMN_PTR
+4701 L1:PLMN_info/M88_PLMN_MEAS_PLMN_OK
+4702 L1:PLMN_info/M105_PLMN_MEAS_PLMN_OK
+4703 L1:PLMN_info/M92_PLMN_C1
+4704 L1:PLMN_info/M94_SEL_PLMN_FOUND
+4705 L1:PLMN_info/M88_PLMN_MEAS_SYSPAR_OK
+4706 L1:PLMN_info/M94_PLMN_MEAS_SYSPAR_OK
+4707 L1:PLMN_info/M86_PLMN_MEAS_NO_PSW
+4708 L1:PLMN_info/M86_PLMN_MEAS_BCCH_DONE
+4709 L1:PLMN_info/M87_PLMN_MEAS_BCCH_DONE
+470A L1:PLMN_info/M88_PLMN_MEAS_BCCH_DONE
+470B L1:PLMN_info/M93_PLMN_MEAS_BCCH_DONE
+470C L1:PLMN_info/I_L1_M94_SEL_PLMN_FOUND
+470D L1:PLMN_info/M102_PLMN_MEAS_BCCH_DONE
+470E L1:PLMN_info/M105_PLMN_MEAS_BCCH_DONE
+470F L1:PLMN_info/M_EEPROM_PLMN_SELECTED
+4710 L1:PLMN_info/M82_PSW_RESULT_RECEIVED
+4711 L1:PLMN_info/M83_SORTED_RSSIS
+4712 L1:PLMN_info/M83_SORTED_CARR_LIST
+4713 L1:PLMN_info/M86_SAVED_CARRIERS_UPDATED
+4714 L1:PLMN_info/M88_NSYSPARS_RECEIVED
+4715 L1:PLMN_info/M88_CORRUPTED_SYSPAR
+4716 L1:PLMN_info/M105_NSYSPARS_RECEIVED
+4717 L1:PLMN_info/E_L1_M82_UNKNOWN_TIMING_OFFSET
+48XX L1:NMEAS_info/NMEAS_INFO_TRA
+4800 L1:NMEAS_info/MEAS_INSTR_SENDED
+4801 L1:NMEAS_info/MEAS_REQ_STATE_UPDATED
+4802 L1:NMEAS_info/M27_MEAS_REQ_DISCARDED
+4803 L1:NMEAS_info/M28_MEAS_INITED_FOR_NEIGH
+4804 L1:NMEAS_info/M29_MEAS_INITED_FOR_NEIGH
+4805 L1:NMEAS_info/M9_NSYSPARS_RECEIVED
+4806 L1:NMEAS_info/M9_NSYSPARS_RERECEIVED
+4807 L1:NMEAS_info/M18_NLIST_CHANGED
+4808 L1:NMEAS_info/M25_SYNC_PERIOD_STARTED
+4809 L1:NMEAS_info/M26_SYSPAR_PERIOD_STARTED
+480A L1:NMEAS_info/M27_NO_NEIGHBOURS
+480B L1:NMEAS_info/M28_SYNC_CARRIER_SELECTED
+480C L1:NMEAS_info/M29_SYNC_CARRIER_SELECTED
+480D L1:NMEAS_info/M29_NO_SYNC_NEIGH_FOUND
+480E L1:NMEAS_info/M2_PSW_RESULT_RECEIVED
+480F L1:NMEAS_info/M30_PSW_CARRIER_SELECTED
+4810 L1:NMEAS_info/M30_NO_PSW_NEIGH_FOUND
+4811 L1:NMEAS_info/M10_SYNC_RECEIVED
+4812 L1:NMEAS_info/M10_SYNC_RERECEIVED
+4813 L1:NMEAS_info/M10_UNKNOWN_BSIC
+4814 L1:NMEAS_info/M10_UNPERMITTED_PLMN
+4815 L1:NMEAS_info/M31_SYNC_REREC_SELECTED
+4816 L1:NMEAS_info/M31_NO_SYNC_REREC_SELECT
+4817 L1:NMEAS_info/M32_SYSPAR_CARRIER_SELECT
+4818 L1:NMEAS_info/M32_SYS_MEAS_TYPE_NOT_FOUN
+4AXX SSCL:input/SSCL_INPUT_TRA
+4A00 SSCL:input/MM<-:SSCL_BEGIN_REQ(7/1776)
+4A01 SSCL:input/MM<-:SSCL_END_REQ(7/1778)
+4A02 SSCL:input/MM<-:FACILITY_IND
+4A03 SSCL:input/MM<-:SSCL_FACILITY_REQ(7/1777)
+4A04 SSCL:input/NO_EVENT(7/0000)
+4A05 SSCL:input/MM<-:SSCL_PARA_REL_COM(7/177E)
+4A06 SSCL:input/RELEASE_COMPLETE_IND(7/177B)
+4A07 SSCL:input/MM<-:SSCL_PDU_ERROR_IND(7/177C)
+4A08 SSCL:input/MM<-:REGISTER_IND(7/1779)
+4A09 SSCL:input/MM<-:SS_EST_IND(7/0A49)
+4A0A SSCL:input/MM<-:SS_EST_CNF(7/0A48)
+4A0B SSCL:input/MM<-:SS_REL_IND(7/0A4B)
+4A0C SSCL:input/MM<-:SS_ERROR_IND(7/0A4F)
+4A0D SSCL:input/MM<-:SS_DATA_IND
+4A0E SSCL:input/UNKNOWN_SSCL_INPUT_PRIMITIVE
+4BXX CS:func/CS_FUNCTION_TRA
+4B00 CS:func/DTMF_START
+4B01 CS:func/DTMF_STOP
+4B02 CS:func/DTMF_DIGIT_START
+4B03 CS:func/DTMF_DIGIT_STOP
+4B04 CS:func/DATA_IF_ACTIVATE
+4B05 CS:func/DATA_IF_DEACTIVATE
+4B06 CS:func/SPEECH_BC_DEFAULT_SET
+4B07 CS:func/DATA_BC_DEFAULT_SET
+4B08 CS:func/SIM_INIT_STATUS
+4B09 CS:func/SIM_SRES_KC_UPDATE
+4B0A CS:func/FACILITY_RECEIVED
+4B0B CS:func/CURRENT_BC_READ
+4B0C CS:func/CALLING_PARTY_NUMBER_RECEIVED
+4B0D CS:func/CALLING_PARTY_NUMBER_READ
+4B0E CS:func/MS_PAR_READ_NEIGH_BCCH_LIST
+4B0F CS:func/CCM_NEW_TRANS_ACT_ID_IN_USE
+4B10 CS:func/CCM_MO_CALL_ESTAB_CHECK
+4B11 CS:func/CCM_MO_CALL_ESTAB_CHECK_RETURN
+4B12 CS:func/MPARTY_HOLD
+4B13 CS:func/MPARTY_RETRIEVE
+4B14 CS:func/MPARTY_SWAP
+4B15 CS:func/MPARTY_SPLIT_CNF
+4B16 CS:func/MPARTY_BUILD_CNF
+4B17 CS:func/MPARTY_HOLD_CNF
+4B18 CS:func/MPARTY_RETRIEVE_CNF
+4B19 CS:func/FACILITY_OPER_FAIL_CHECK
+4B1A CS:func/CALL_TRANSFER
+4B1B CS:func/MS_PAR_WRITE_NEIGH_BCCH_LIST
+4B1C CS:func/CALL_TRANSFER_CNF
+4B1D CS:func/MM_PAGING_ALLOWED
+4B1E CS:func/L1_INFO_READ_CA_VALID
+4B1F CS:func/MS_PAR_SET_LAI_LISTS_IGNORE
+4B20 CS:func/CS_ICM_MO_ACTIVATE
+4B21 CS:func/CS_FCF_DUMMY_0_1
+4B22 CS:func/CS_FCN_DUMMY_0_2
+4B23 CS:func/CS_FCN_DUMMY_0_3
+4B24 CS:func/CS_FCN_DUMMY_0_4
+4B25 CS:func/CS_FCN_DUMMY_0_5
+4B26 CS:func/CS_FCN_DUMMY_0_6
+4B27 CS:func/CS_FCN_DUMMY_0_7
+4B28 CS:func/CS_FCN_DUMMY_0_8
+4B29 CS:func/CS_FCN_DUMMY_0_9
+4B2A CS:func/
+4B2B CS:func/CS_CALL_HOLD
+4B2C CS:func/CS_CALL_SWAP
+4B2D CS:func/SEND_AOC_ACKNOWLEDGE
+4B2E CS:func/CS_CALL_ANSWER
+4B2F CS:func/CS_BUILD_CONFERENCE
+4B30 CS:func/CS_SPLIT_CONFERENCE
+4B31 CS:func/CS_UPL_CALL_TERMINATE_SIF
+4B32 CS:func/CS_CALL_TERMINATE
+4B33 CS:func/CS_FCN_DUMMY_1_1
+4B34 CS:func/CS_FCN_DUMMY_1_2
+4B35 CS:func/CS_FCN_DUMMY_1_3
+4B36 CS:func/CS_FCN_DUMMY_1_4
+4B37 CS:func/CS_FCN_DUMMY_1_5
+4B38 CS:func/CS_FCN_DUMMY_1_6
+4B39 CS:func/CS_FCN_DUMMY_1_7
+4B3A CS:func/CS_FCN_DUMMY_1_8
+4B3B CS:func/CS_FCN_DUMMY_1_9
+4B3C CS:func/
+4B3D CS:func/CS_CALL_RETRIEVE
+4B3E CS:func/CS_CALL_RELEASE
+4B3F CS:func/MS_PAR_WRITE_BCCH_LIST
+4B40 CS:func/MS_PAR_WRITE_SELECTED_PLMN
+4B41 CS:func/CS_CALL_CREATE
+4B42 CS:func/CCM_CHECK_TCH_CH_MODE
+4B43 CS:func/CS_TASK_INIT_COMPLETE
+4B44 CS:func/CS_DEV_TASK_INIT_COMPLETED
+4B45 CS:func/CCM_HSCSD_CALL_STATE_PARAMS
+4CXX SIM_INFO:func/SIM_INFO_FUNCTION_TRA
+4C00 SIM_INFO:func/READ_SERV_TABLE
+4C01 SIM_INFO:func/READ_ADM_DATA
+4C02 SIM_INFO:func/READ_ID_DATA
+4C03 SIM_INFO:func/READ_TMSI
+4C04 SIM_INFO:func/WRITE_TMSI
+4C05 SIM_INFO:func/READ_LAI
+4C06 SIM_INFO:func/WRITE_LAI
+4C07 SIM_INFO:func/READ_CIPH_KEY
+4C08 SIM_INFO:func/WRITE_CIPH_KEY
+4C09 SIM_INFO:func/READ_CIPH_KEY_SNR
+4C0A SIM_INFO:func/WRITE_CIPH_KEY_SNR
+4C0B SIM_INFO:func/READ_T3212
+4C0C SIM_INFO:func/WRITE_T3212
+4C0D SIM_INFO:func/READ_BCCH_INFO_LIST
+4C0E SIM_INFO:func/WRITE_BCCH_INFO_LIST
+4C0F SIM_INFO:func/SIM_INFO_DUMMY_0_0
+4C10 SIM_INFO:func/ADD_FORBIDDEN_PLMN
+4C11 SIM_INFO:func/ERASE_FORBIDDEN_PLMN
+4C12 SIM_INFO:func/CHECK_FORBIDDEN_PLMN
+4C13 SIM_INFO:func/READ_LOC_UPD_STATUS
+4C14 SIM_INFO:func/WRITE_LOC_UPD_STATUS
+4C15 SIM_INFO:func/FIRST_PLMN_SELECTOR
+4C16 SIM_INFO:func/NEXT_PLMN_SELECTOR
+4C17 SIM_INFO:func/WRITE_PLMN_LIST
+4C18 SIM_INFO:func/DISABLE_IMSI
+4C19 SIM_INFO:func/READ_HPLMN
+4C1A SIM_INFO:func/SIM_INFO_AVAILABLE
+4C1B SIM_INFO:func/READ_MOBILE_IDENTITY
+4C1C SIM_INFO:func/CLEAR_SIM_INFO
+4C1D SIM_INFO:func/READ_PLMN_LIST
+4C1E SIM_INFO:func/READ_BCCH_BIT_MAP
+4C1F SIM_INFO:func/PIN_STATUS
+4C20 SIM_INFO:func/WRITE_LANGUAGE_PREF
+4C21 SIM_INFO:func/READ_LANGUAGE_PREF
+4C22 SIM_INFO:func/WRITE_SMS_STATUS
+4C23 SIM_INFO:func/READ_SMS_STATUS
+4C24 SIM_INFO:func/READ_DATA_SIZES
+4C25 SIM_INFO:func/READ_FIRST_MSISDN_NBR
+4C26 SIM_INFO:func/PIN2_STATUS
+4C27 SIM_INFO:func/FIXDIAL_STATUS
+4C28 SIM_INFO:func/READ_HPLMN_SEARCH
+4C29 SIM_INFO:func/READ_SERV_CONTROL_TBL
+4C2A SIM_INFO:func/WRITE_DYN_FLAGS
+4C2B SIM_INFO:func/READ_DYN_FLAGS
+4C2C SIM_INFO:func/WRITE_VOICE_MSG_FLAGS
+4C2D SIM_INFO:func/READ_VOICE_MSG_FLAGS
+4C2E SIM_INFO:func/WRITE_CALL_FORWARD_FLAGS
+4C2F SIM_INFO:func/READ_CALL_FORWARD_FLAGS
+4C30 SIM_INFO:func/READ_WELCOME_MESSAGE
+4C31 SIM_INFO:func/READ_OPERATOR_NAME
+4C32 SIM_INFO:func/WRITE_DYN2_FLAGS
+4C33 SIM_INFO:func/READ_DYN2_FLAGS
+4C34 SIM_INFO:func/READ_PUCT
+4C35 SIM_INFO:func/READ_CPHS
+4C36 SIM_INFO:func/READ_CELL_BC_MSG_ID
+4C37 SIM_INFO:func/WRITE_CELL_BC_MSG_ID
+4C38 SIM_INFO:func/FIRST_FREE_SMS_LOC
+4C39 SIM_INFO:func/READ_LOCAL_CALL_TEXT
+4C3A SIM_INFO:func/READ_TARIFF_PACKAGE
+4C3B SIM_INFO:func/READ_HOME_ZONE_COORD
+4C3C SIM_INFO:func/READ_AOC_STATUS
+4C3D SIM_INFO:func/READ_FORB_PLMN_LIST
+4C3E SIM_INFO:func/READ_SIM_LOCK_INFO
+4C3F SIM_INFO:func/BCCH_LIST_NOT_VALID
+4C40 SIM_INFO:func/READ_SERV_PROV_NAME
+4C41 SIM_INFO:func/READ_DUALMODE_NAM_DATA
+4C42 SIM_INFO:func/CHECK_EMERG_CALL_CODES
+4C43 SIM_INFO:func/READ_EMERG_CALL_CODES
+4C44 SIM_INFO:func/READ_FDN_INFO
+4C45 SIM_INFO:func/READ_ADN_INFO
+4C46 SIM_INFO:func/READ_DUALMODE_SID_LIST
+4C47 SIM_INFO:func/READ_DUALMODE_NET_FLAG
+4C48 SIM_INFO:func/READ_DUALMODE_FAC_CODE
+4C49 SIM_INFO:func/READ_DUALMODE_SYS_PRIORITY_LIST
+4C4A SIM_INFO:func/CHECK_IF_DUALMODE_SIM
+4C4B SIM_INFO:func/SIM_INFO_DUMMY_0_1
+4C4C SIM_INFO:func/SIM_INFO_DUMMY_0_2
+4C4D SIM_INFO:func/SIM_INFO_DUMMY_0_3
+4C4E SIM_INFO:func/SIM_INFO_DUMMY_0_4
+4C4F SIM_INFO:func/SIM_INFO_DUMMY_0_5
+4C50 SIM_INFO:func/SIM_INFO_DUMMY_0_6
+4C51 SIM_INFO:func/SIM_INFO_DUMMY_0_7
+4C52 SIM_INFO:func/SIM_INFO_DUMMY_0_8
+4C53 SIM_INFO:func/SIM_INFO_DUMMY_0_9
+4C54 SIM_INFO:func/SIM_INFO_DUMMY_0_10
+4C55 SIM_INFO:func/SIM_INFO_DUMMY_0_11
+4C56 SIM_INFO:func/SIM_INFO_DUMMY_0_12
+4C57 SIM_INFO:func/
+4C58 SIM_INFO:func/CHECK_HOME_ZONE
+4C59 SIM_INFO:func/SIM_INFO_DUMMY_1_1
+4C5A SIM_INFO:func/SIM_INFO_DUMMY_1_2
+4C5B SIM_INFO:func/SIM_INFO_DUMMY_1_3
+4C5C SIM_INFO:func/SIM_INFO_DUMMY_1_4
+4C5D SIM_INFO:func/SIM_INFO_DUMMY_1_5
+4C5E SIM_INFO:func/SIM_INFO_DUMMY_1_6
+4C5F SIM_INFO:func/SIM_INFO_DUMMY_1_7
+4C60 SIM_INFO:func/SIM_INFO_DUMMY_1_8
+4C61 SIM_INFO:func/SIM_INFO_DUMMY_1_9
+4C62 SIM_INFO:func/SIM_INFO_DUMMY_1_10
+4C63 SIM_INFO:func/
+4C64 SIM_INFO:func/READ_ACM
+4C65 SIM_INFO:func/READ_ACM_MAX_VALUE
+4C66 SIM_INFO:func/READ_ACM_WARNING_LEVEL
+4C67 SIM_INFO:func/READ_CSP
+4C68 SIM_INFO:func/READ_ZONAL_IND_LABEL
+4C69 SIM_INFO:func/READ_CARD_TYPE
+4C6A SIM_INFO:func/WRITE_BCCH_DESCR
+4C6B SIM_INFO:func/READ_IMSI
+4C6C SIM_INFO:func/READ_ACCESS_CTRL
+4C6D SIM_INFO:func/WRITE_DUALMODE_NAM
+4C6E SIM_INFO:func/READ_SDN_INFO
+5BXX EM_IF:func/CHA_IF_TRA
+5B00 EM_IF:func/INIT
+5B01 EM_IF:func/CHARGER_CONNECTED
+5B02 EM_IF:func/CHARGER_DISCONNECTED
+5B03 EM_IF:func/CHARGER_VOL_LIMITATION_ON
+5B04 EM_IF:func/CHARGER_VOL_LIMITATION_OFF
+5B05 EM_IF:func/CHARGING_ENABLE
+5B06 EM_IF:func/CHARGING_DISABLE
+5B07 EM_IF:func/ACTING_DEAD
+5B08 EM_IF:func/CALL_CONNECTED
+5B09 EM_IF:func/CALL_DISCONNECTED
+5B0A EM_IF:func/POWER_ON
+5B0B EM_IF:func/
+5B0C EM_IF:func/
+5B0D EM_IF:func/CHARGER_TYPE_GET
+5B0E EM_IF:func/CHARGER_CURRENT_GET
+5B0F EM_IF:func/CHARGER_VOL_GET
+5B10 EM_IF:func/CHARGE_STATUS_GET
+5B11 EM_IF:func/BATTERY_TYPE_GET
+5B12 EM_IF:func/BATTERY_SIZE_GET
+5B13 EM_IF:func/BATTERY_TEMP_GET
+5B14 EM_IF:func/BATTERY_VOL_GET
+5B15 EM_IF:func/BATTERY_VOL_READ
+5B16 EM_IF:func/BATTERY_VOL_READ_REQ
+5B17 EM_IF:func/BATTERY_VOL_TX_READ
+5B18 EM_IF:func/BATTERY_VOL_TX_READ_REQ
+5B19 EM_IF:func/CHARGED_CAPACITY_GET
+5CXX EM_INT:func/CHA_INT_FUNCTION_TRA
+5C00 EM_INT:func/I_FAST_CHARGING
+5C01 EM_INT:func/I_LI_BATTERY_CHARGING
+5C02 EM_INT:func/I_COLD_CHARGING
+5C03 EM_INT:func/I_MAINTENANCE_CHARGING
+5C04 EM_INT:func/I_TX_ON_CHARGING
+5C05 EM_INT:func/I_CHARGING_DISABLED
+5C06 EM_INT:func/I_ONE_CELL_BROKEN
+5C07 EM_INT:func/I_START_BATT_BAR_SCROLL_REQ
+5C08 EM_INT:func/I_STOP_BATT_BAR_SCROLL_REQ
+5C09 EM_INT:func/I_CHARGER_DISCONNECTED
+5C0A EM_INT:func/I_CHARGER_CONNECTED
+5C0B EM_INT:func/I_BATTERY_FULL
+5C0C EM_INT:func/I_BATT_HOT
+5C0D EM_INT:func/I_LI_BATT_PWM_OVER_LIMIT
+5C0E EM_INT:func/I_LI_BATT_PWM_BELOW_LIMIT
+5C0F EM_INT:func/E_CHARGER_CURRENT_FAIL
+5C10 EM_INT:func/I_BATTERY_NOT_FULL
+5C11 EM_INT:func/I_CHARGING_COMPLETED
+5C12 EM_INT:func/E_CHARGER_VOLTAGE_FAIL
+5C13 EM_INT:func/E_ILLEGAL_OPERATING_STATE
+5C14 EM_INT:func/
+5C15 EM_INT:func/
+5C16 EM_INT:func/I_PWM_WRITE
+5C17 EM_INT:func/I_CHARGE_CURRENT
+5C18 EM_INT:func/I_CHARGER_CURRENT
+5C19 EM_INT:func/I_CHARGER_TYPE
+5C1A EM_INT:func/I_LI_BATT_EEPROM_DATA_CHECK
+5C1B EM_INT:func/I_OPERATING_MODE
+5C1C EM_INT:func/I_OPERATING_CURRENT
+5EXX EM:volt/CHA_VOLTAGE_TRA
+5E00 EM:volt/I_BATT_TEMP
+5E01 EM:volt/I_BATT_SIZE
+5E02 EM:volt/I_CHARGER_VOL_MAX
+5E03 EM:volt/I_CHARGER_VOL_MIN
+5E04 EM:volt/I_BATT_VOLTAGE
+5E05 EM:volt/I_BATT_MEAN_VALUE
+5E06 EM:volt/I_CHARGER_VOLTAGE
+5E07 EM:volt/I_BFD_MEDIAN_VALUE
+5E08 EM:volt/I_BFD_CHARGEAMOUNT
+5E09 EM:volt/I_BFD_VOLDIFFTOMAX
+5E0A EM:volt/I_BFD_VOLDROPCNT
+5E0B EM:volt/I_BFD_TEMPERATURE
+5E0C EM:volt/I_BFD_VOLTAGE
+5E0D EM:volt/I_BFD_VOLDIFFTIME
+5E0E EM:volt/I_BFD_AVERDIFF
+5E0F EM:volt/I_BFD_DERIVCNT
+5E10 EM:volt/I_BFD_FULL_BELIEF
+5E11 EM:volt/I_CVC_BATT_VOL_DOWN
+5E12 EM:volt/I_CVC_BATT_VOL_UP
+5E13 EM:volt/I_CVC_BATT_VOL_AVER
+5E14 EM:volt/I_CVC_BATT_VOL_ERROR
+5E15 EM:volt/I_CVC_BATT_VOL_CHANGE
+5E16 EM:volt/I_CVC_BATT_GOAL_VOL
+5FXX EM:trans/CHA_TRANSITION_TRA
+5F00 EM:trans/TRANSITION
+60XX EM_PSM/EM_PSM_TRA
+6000 EM_PSM/I_EM_PSM_TIME
+6001 EM_PSM/I_EM_PSM_ITEM
+6002 EM_PSM/I_EM_PSM_STATE
+6003 EM_PSM/I_EM_PSM_MAX_ITEMS
+6004 EM_PSM/I_EM_PSM_AVG_ITEMS
+6005 EM_PSM/I_EM_PSM_CONSUMED
+6006 EM_PSM/I_EM_PSM_AVG_CURRENT
+6007 EM_PSM/I_EM_PSM_TMP_CURRENT
+62XX LOC:timer/LOC_TIMER_TRA
+6200 LOC:timer/EVENT_HANDLE
+64XX LOC_IF:func/LOC_IF_TRA
+6400 LOC_IF:func/MDI_MSG_RECEIVE
+6401 LOC_IF:func/COUNTER_INCREMENT
+6402 LOC_IF:func/COUNTER_READ
+6403 LOC_IF:func/COUNTER_WRITE
+6404 LOC_IF:func/DSP_INIT
+6405 LOC_IF:func/SER_NUM_READ
+6406 LOC_IF:func/SMS_DATA_DELETE_STATUS
+6407 LOC_IF:func/PROD_INFO_READ
+6408 LOC_IF:func/PROD_INFO_WRITE
+6409 LOC_IF:func/SELF_TEST_RUN
+640A LOC_IF:func/SELF_TEST_RESULT_GET
+640B LOC_IF:func/SELF_TEST_PRESET_READ
+640C LOC_IF:func/SELF_TEST_PRESET_WRITE
+640D LOC_IF:func/SELF_TEST_IF_READ
+640E LOC_IF:func/UI_TEST_CONTROL
+640F LOC_IF:func/PROD_FAST_SERV_CH_READ
+6410 LOC_IF:func/PROD_FAST_SERV_CH_WRITE
+6411 LOC_IF:func/VERSION_READ
+6412 LOC_IF:func/VERSION_WRITE
+6413 LOC_IF:func/VERSION_MOVE
+6414 LOC_IF:func/WARR_INFO_READ
+6415 LOC_IF:func/WARR_INFO_WRITE
+6416 LOC_IF:func/TRANSFER_START
+6417 LOC_IF:func/SIM_LOC_CLOSE
+6418 LOC_IF:func/SIM_LOC_OPEN
+6419 LOC_IF:func/SIM_LOC_STATUS_GET
+641A LOC_IF:func/SERIAL_NBR_READ
+641B LOC_IF:func/SEC_CODE_CALC
+641C LOC_IF:func/MASTER_CODE_CALC
+641D LOC_IF:func/MASTER_CODE_CHECK
+641E LOC_IF:func/IMEISV_READ
+641F LOC_IF:func/SIM_STATUS
+6420 LOC_IF:func/SMS_CLEAR
+6421 LOC_IF:func/SCM_STORE_STATUS
+6422 LOC_IF:func/SCM_READ_STATUS
+6423 LOC_IF:func/KEY_PRESS
+6424 LOC_IF:func/KEY_RELEASE
+6425 LOC_IF:func/PP_INIT
+6426 LOC_IF:func/MDI_MSG_RESEIVE
+6427 LOC_IF:func/ADJ_DATA_READ
+6428 LOC_IF:func/FACTORY_SET_STATUS
+6429 LOC_IF:func/PP_READ
+642A LOC_IF:func/PP_WRITE
+65XX LOC_INT:func/LOC_INT_TRA
+6500 LOC_INT:func/TASK_INIT
+6501 LOC_INT:func/MS_TEST_MODE
+6502 LOC_INT:func/MCU_CMD_EXECUTE
+6503 LOC_INT:func/DSP_CMD_EXECUTE
+6504 LOC_INT:func/PHONE_MEMORY_HANDLE
+6505 LOC_INT:func/PAGING_STATE_GET
+6506 LOC_INT:func/RESP_MSG_SEND
+6507 LOC_INT:func/ADDRESS_CHECK
+6508 LOC_INT:func/INT_CHSUM_CALC
+6509 LOC_INT:func/EEP_CHSUM_CALC
+650A LOC_INT:func/ERROR_MSG_SEND
+650B LOC_INT:func/RF_TEMP_READ
+650C LOC_INT:func/AD_CONV_READ
+650D LOC_INT:func/EEP_CHSUM_SAVE
+650E LOC_INT:func/FACTORY_SET_LOC
+650F LOC_INT:func/IMEI_TRANSPORT
+6510 LOC_INT:func/EVENT_TRC_HANDLE
+6511 LOC_INT:func/MDI_RESP_HANDLE
+6512 LOC_INT:func/DSP_MSG_TO_MDI
+6513 LOC_INT:func/REROUTE_MSG
+6514 LOC_INT:func/USER_MEMORY_READ
+6515 LOC_INT:func/USER_MEMORY_WRITE
+6516 LOC_INT:func/VERSION_HANDLE
+6517 LOC_INT:func/IMEI_WRITE
+6518 LOC_INT:func/IMEI_READ
+6519 LOC_INT:func/PROD_INFO_HANDLE
+651A LOC_INT:func/WARR_INFO_HANDLE
+651B LOC_INT:func/TX_CONTROL
+651C LOC_INT:func/RX_CONTROL
+651D LOC_INT:func/PWR_RAMP_SEND
+651E LOC_INT:func/FACTORY_VALUES_SET
+651F LOC_INT:func/CALL_HANDLE
+6520 LOC_INT:func/FTD_READ
+6521 LOC_INT:func/UI_TEST
+6522 LOC_INT:func/ORIG_IMEI_READ
+6523 LOC_INT:func/ORIG_IMEI_WRITE
+6524 LOC_INT:func/ST_RESULTS_READ
+6525 LOC_INT:func/ST_INFO_READ
+6526 LOC_INT:func/ST_PRESET_HANDLE
+6527 LOC_INT:func/UI_CODE_READ
+6528 LOC_INT:func/UI_CODE_WRITE
+6529 LOC_INT:func/COUNTER_HANDLE
+652A LOC_INT:func/STARTUP_RESULT_GET
+652B LOC_INT:func/Tx_IQ_Cal
+652C LOC_INT:func/resp_msg_header_make
+652D LOC_INT:func/warr_data_transfer_handle
+652E LOC_INT:func/ui_settings_handle
+652F LOC_INT:func/ui_setting_read
+6530 LOC_INT:func/ui_setting_write
+6531 LOC_INT:func/int_aud_loop_set
+6532 LOC_INT:func/counter_amount_check
+6533 LOC_INT:func/ad_scaled_value_read
+6534 LOC_INT:func/pp_handle
+6535 LOC_INT:func/tx_pwr_ramp_set
+6536 LOC_INT:func/local_mode_start
+6537 LOC_INT:func/nsps_read
+6538 LOC_INT:func/nsps_write
+6539 LOC_INT:func/graph_display_read
+653A LOC_INT:func/graph_display_write
+653B LOC_INT:func/plmn_name_handle
+653C LOC_INT:func/charging_state
+653D LOC_INT:func/cs_status_get
+653E LOC_INT:func/buzzer_test
+653F LOC_INT:func/ear_volume_sett
+6540 LOC_INT:func/rtc_time_read
+6541 LOC_INT:func/rtc_time_set
+6542 LOC_INT:func/ir_test
+6543 LOC_INT:func/pwm_write
+6544 LOC_INT:func/operator_logo_read
+6545 LOC_INT:func/operator_logo_write
+6546 LOC_INT:func/ring_tone_read
+6547 LOC_INT:func/ring_tone_write
+6548 LOC_INT:func/tx_iq_set
+6549 LOC_INT:func/sec_startup_msg_send
+654A LOC_INT:func/sec_ms_id_store
+654B LOC_INT:func/sec_ms_id_read
+654C LOC_INT:func/sec_ser_num_prg
+654D LOC_INT:func/sec_check_sum_calc
+654E LOC_INT:func/imei_string_get
+654F LOC_INT:func/sec_encrypted_siml_store
+6550 LOC_INT:func/sec_siml_state_chg_send
+6551 LOC_INT:func/sec_master_code_req
+6552 LOC_INT:func/sec_master_code_resp
+6553 LOC_INT:func/sim_lock_close_
+6554 LOC_INT:func/sim_lock_open_
+6555 LOC_INT:func/sim_lock_status_get
+6556 LOC_INT:func/sim_lock_config_data_set
+6557 LOC_INT:func/sim_lock_keypad_close_set
+6558 LOC_INT:func/sim_lock_state_read
+6559 LOC_INT:func/sim_lock_action_resp_send
+69XX LOC_MDI:send/LOC_MDI_MSG_SEND_TRA
+6900 LOC_MDI:send/dsp_init
+6901 LOC_MDI:send/task_init
+6902 LOC_MDI:send/mdi_response_handle
+6903 LOC_MDI:send/dsp_msg_to_mdi
+6904 LOC_MDI:send/int_aud_loop_set
+6905 LOC_MDI:send/reroute
+6906 LOC_MDI:send/tx_power_ramp_send
+6907 LOC_MDI:send/tx_control
+6908 LOC_MDI:send/rx_control
+6909 LOC_MDI:send/tx_pwr_ramp_set
+690A LOC_MDI:send/local_mode_start
+690B LOC_MDI:send/tx_iq_set
+690C LOC_MDI:send/sec_startup_msg_send
+690D LOC_MDI:send/sec_siml_state_chg_send
+690E LOC_MDI:send/sec_master_code_req
+6DXX DEV_IF:func/DEV_IF_TRA
+6D00 DEV_IF:func/PWR_IF_POWER_ON
+6D01 DEV_IF:func/PWR_IF_POWER_ON
+6D02 DEV_IF:func/PWR_IF_POWER_OFF
+6D03 DEV_IF:func/PWR_IF_UI_POWER_DOWN_READY
+6D04 DEV_IF:func/PWR_IF_CS_POWER_DOWN_READY
+6D05 DEV_IF:func/PWR_IF_EM_POWER_DOWN_READY
+6D06 DEV_IF:func/PWR_IF_LOC_POWER_DOWN_READY
+6D07 DEV_IF:func/PWR_IF_DEVTIME_POWER_DOWN_READY
+6D08 DEV_IF:func/PWR_IF_SIM_POWER_DOWN_READY
+6D09 DEV_IF:func/PWR_IF_CHARGER_CONNECTED
+6D0A DEV_IF:func/PWR_IF_CHARGER_DISCONNECTED
+6D0B DEV_IF:func/PWR_IF_CALL_CONN
+6D0C DEV_IF:func/PWR_IF_CALL_DISCONN
+6D0D DEV_IF:func/PWR_IF_CHARGING_COMPLETED
+6D0E DEV_IF:func/PWR_IF_DISCHARGING_COMPLETED
+6D0F DEV_IF:func/PWR_IF_SW_RESET
+6D10 DEV_IF:func/PWR_IF_RESET_REASON_SET
+6D11 DEV_IF:func/DISP_IF_REFRESH
+6D12 DEV_IF:func/DISP_IF_IND_REFRESH
+6D13 DEV_IF:func/DISP_IF_IND_ON
+6D14 DEV_IF:func/DISP_IF_IND_OFF
+6D15 DEV_IF:func/DISP_IF_IND_BLINK
+6D16 DEV_IF:func/DISP_IF_CLEAR
+6D17 DEV_IF:func/DISP_IF_BAR_SCROLL_START
+6D18 DEV_IF:func/DISP_IF_BAR_SCROLL_STOP
+6D19 DEV_IF:func/KBD_IF_KEY_CTRL_SET
+6D1A DEV_IF:func/dev_time_set()
+6D1B DEV_IF:func/dev_time_get()
+6D1C DEV_IF:func/dev_time_alarm_set()
+6D1D DEV_IF:func/dev_time_alarm_get()
+6D1E DEV_IF:func/dev_time_alarm_set_off()
+6D1F DEV_IF:func/dev_time_rtc_on()
+6D20 DEV_IF:func/dev_time_rtc_off()
+6D21 DEV_IF:func/dev_time_notify_mode_set()
+6D22 DEV_IF:func/dev_time_notify_mode_get()
+6D23 DEV_IF:func/dev_time_update()
+6D24 DEV_IF:func/dev_time_alarm_update()
+6D25 DEV_IF:func/dev_time_rtc_status()
+6D26 DEV_IF:func/dev_time_full_days_in_secs()
+6D27 DEV_IF:func/dev_time_alarm_set_check()
+6D28 DEV_IF:func/dev_time_factory_set()
+6D29 DEV_IF:func/dev_time_calib_value_calc()
+6D2A DEV_IF:func/dev_time_date_set()
+6D2B DEV_IF:func/dev_disp_update()
+6D2C DEV_IF:func/dev_disp_indi_update()
+6D2D DEV_IF:func/dev_indicator_on()
+6D2E DEV_IF:func/dev_indicator_off()
+6D2F DEV_IF:func/dev_indicator_blink()
+6D30 DEV_IF:func/dev_disp_clear()
+6D31 DEV_IF:func/dev_grph_area_set()
+6D32 DEV_IF:func/dev_grph_font_info_get()
+6D33 DEV_IF:func/dev_grph_battery_bar_on()
+6D34 DEV_IF:func/dev_grph_battery_bar_off()
+6D35 DEV_IF:func/dev_grph_battery_bar_blink()
+6D36 DEV_IF:func/dev_grph_rf_bar_on()
+6D37 DEV_IF:func/dev_grph_rf_bar_off()
+6D38 DEV_IF:func/dev_grph_rf_bar_blink()
+6D39 DEV_IF:func/dev_grph_bitmap_display()
+6D3A DEV_IF:func/dev_grph_text_draw()
+6D3B DEV_IF:func/dev_grph_pixel_set()
+6D3C DEV_IF:func/dev_grph_line_draw()
+6D3D DEV_IF:func/dev_grph_battery_bar_type_set()
+6D3E DEV_IF:func/dev_grph_rf_bar_type_set
+6D3F DEV_IF:func/dev_disp_blink_disable()
+6D40 DEV_IF:func/dev_disp_batt_bar_write()
+6D41 DEV_IF:func/dev_disp_rf_bar_write
+6D42 DEV_IF:func/dev_disp_test_pattern_on()
+6D43 DEV_IF:func/dev_disp_test_pattern_off()
+6D44 DEV_IF:func/dev_indicator_state_get()
+6D45 DEV_IF:func/dev_disp_acting_dead_bar_set()
+6D46 DEV_IF:func/dev_disp_acting_dead_bar_clear()
+6D47 DEV_IF:func/dev_grph_rectangle_draw()
+6D48 DEV_IF:func/dev_grph_write_string()
+6D49 DEV_IF:func/dev_grph_char_info_get()
+6D4A DEV_IF:func/dev_grph_init()
+6D4B DEV_IF:func/dev_discharge_start()
+6D4C DEV_IF:func/dev_discharge_stop()
+6D4D DEV_IF:func/dev_gsm_power_down()
+6D4E DEV_IF:func/dev_sim_deactivated()
+6D4F DEV_IF:func/dev_recovery_reset()
+6D50 DEV_IF:func/dev_dsp_deactivate()
+6D51 DEV_IF:func/dev_gsm_factory_set()
+6D52 DEV_IF:func/dev_sms_message_clear()
+6D53 DEV_IF:func/dev_sms_message_read_sif()
+6D54 DEV_IF:func/dev_sms_message_store_sif()
+6D55 DEV_IF:func/dev_sms_update_msg_reference()
+6D56 DEV_IF:func/dev_sms_update_msg_status()
+6D57 DEV_IF:func/dev_buzzer_test()
+6D58 DEV_IF:func/dev_gsm_normal_power_up()
+6D59 DEV_IF:func/dev_standby_status_get()
+6D5A DEV_IF:func/dev_rf_bar_get()
+6D5B DEV_IF:func/dev_nsps_status_get()
+6D5C DEV_IF:func/dev_nsps_key_press()
+6D5D DEV_IF:func/dev_nsps_timeout()
+6D5E DEV_IF:func/dev_nsps_serv_off()
+6D5F DEV_IF:func/dev_nsps_serv_on()
+6D60 DEV_IF:func/dev_nsps_charger_status()
+6D61 DEV_IF:func/dev_signal_indicator_set()
+6D62 DEV_IF:func/dev_ccont_int_handler()
+6D63 DEV_IF:func/dev_ccont_charger_exist()
+6D64 DEV_IF:func/dev_ct_timer_start()
+6D65 DEV_IF:func/dev_ct_timer_stop()
+6D66 DEV_IF:func/dev_ct_timer_read()
+6D67 DEV_IF:func/dev_cs_wakeup_needed()
+6D68 DEV_IF:func/
+6D69 DEV_IF:func/
+72XX DEV_PWR:func/DEV_PWR_TRA
+7200 DEV_PWR:func/unused
+7201 DEV_PWR:func/DSP_STARTUP_COMPLETED
+7202 DEV_PWR:func/CS_INIT_COMPLETED
+7203 DEV_PWR:func/UI_INIT_COMPLETED
+7204 DEV_PWR:func/EM_INIT_COMPLETED
+7205 DEV_PWR:func/DETERMINE_WAKEUP_REASON
+7206 DEV_PWR:func/RTC_CALIBRATION_COMPLETED
+7207 DEV_PWR:func/ALARM_WRITE_COMPLETED
+73XX DEV_GRPH:func/DEV_GRPH_TRA
+7300 DEV_GRPH:func/unused
+7301 DEV_GRPH:func/INDI_UPDATE
+7302 DEV_GRPH:func/Indicator set ON
+7303 DEV_GRPH:func/Indicator set OFF
+7304 DEV_GRPH:func/Indicator set BLINKING
+7305 DEV_GRPH:func/HORIZ text_draw()
+7306 DEV_GRPH:func/VERT text_draw()
+7307 DEV_GRPH:func/text_draw() reported to DDI
+7308 DEV_GRPH:func/battery_bar type set to
+7309 DEV_GRPH:func/rf_bar type set to
+730A DEV_GRPH:func/blink_status set to ON
+730B DEV_GRPH:func/blink_status set to OFF
+730C DEV_GRPH:func/blinking ENABLED
+730D DEV_GRPH:func/blinking DISABLED
+730E DEV_GRPH:func/batt_bar_write(), segments
+730F DEV_GRPH:func/rf_bar_write(), segments
+7310 DEV_GRPH:func/PPM fonts found
+7311 DEV_GRPH:func/ROM-fonts used
+74XX DEV_DISP:func/DEV_DISP_TRA
+7400 DEV_DISP:func/unused
+7401 DEV_DISP:func/dev_disp_bars_update()
+7402 DEV_DISP:func/dev_disp_batt_bar_update(), segments
+7403 DEV_DISP:func/dev_disp_rf_bar_update(), segments
+7404 DEV_DISP:func/dev_disp_batt_bar_clear()
+7405 DEV_DISP:func/dev_disp_rf_bar_clear()
+7406 DEV_DISP:func/dev_light_on()
+7407 DEV_DISP:func/dev_light_off()
+7408 DEV_DISP:func/dev_light_blink()
+7409 DEV_DISP:func/dev_disp_light_on()
+740A DEV_DISP:func/dev_disp_light_off()
+740B DEV_DISP:func/dev_disp_light_blink()
+740C DEV_DISP:func/dev_keyboard_light_on()
+740D DEV_DISP:func/dev_keyboard_light_off()
+740E DEV_DISP:func/dev_keyboard_light_blink()
+740F DEV_DISP:func/dev_charge_bar_get()
+7410 DEV_DISP:func/dev_disp_lcd_power_on()
+7411 DEV_DISP:func/dev_disp_lcd_power_off()
+7412 DEV_DISP:func/dev_disp_text_draw_report(), set ON
+7413 DEV_DISP:func/dev_disp_text_draw_report(), set OFF
+75XX DEV_ACC:func/DEV_ACC_TRA
+7500 DEV_ACC:func/unused
+7501 DEV_ACC:func/Use_mode_get
+7502 DEV_ACC:func/Detect_poll
+7503 DEV_ACC:func/Headset_connection_check
+7504 DEV_ACC:func/Audio_control
+7505 DEV_ACC:func/Audio_activate
+7506 DEV_ACC:func/Audio_deactivate
+7507 DEV_ACC:func/Car_speaker_mute_on
+7508 DEV_ACC:func/Car_speaker_mute_off
+7509 DEV_ACC:func/Car_mic_mute_on
+750A DEV_ACC:func/Car_mic_mute_off
+750B DEV_ACC:func/Radio_mute_set_on
+750C DEV_ACC:func/Radio_mute_set_off
+750D DEV_ACC:func/Car IGN
+750E DEV_ACC:func/HFU2: Hook-On
+750F DEV_ACC:func/HFU2: Hook-Off
+7510 DEV_ACC:func/Antenna_motor_set_on
+7511 DEV_ACC:func/Antenna_motor_set_off
+7512 DEV_ACC:func/EAD_get
+7513 DEV_ACC:func/Alive_msg_send
+7514 DEV_ACC:func/Vibration_alert_set_on
+7515 DEV_ACC:func/Vibration_alert_set_off
+7516 DEV_ACC:func/New Mode
+7517 DEV_ACC:func/Headset Button State
+7518 DEV_ACC:func/Unknown HFU2 func
+7519 DEV_ACC:func/Unk HFU2 IND sub_func
+751A DEV_ACC:func/Unk HFU2 ACC sub_func
+751B DEV_ACC:func/Bad HFU-2 Connection!
+751C DEV_ACC:func/HFU-2 Selftest fail!
+751D DEV_ACC:func/HFU-2 Port Read Resp
+751E DEV_ACC:func/HFU-2 ADC Value
+751F DEV_ACC:func/HFU-2 Model Message
+7520 DEV_ACC:func/HFU-2 Audio Path
+7521 DEV_ACC:func/HFU-2 Audio Path Resp
+7522 DEV_ACC:func/Unk PN Obj Router Func
+7523 DEV_ACC:func/Unk PN Router Sub Func
+7524 DEV_ACC:func/dev_acc_power_off()
+7525 DEV_ACC:func/dev_acc_power_off_ok()
+76XX DEV_TIME:func/DEV_TIME_TRA
+7600 DEV_TIME:func/unused
+7601 DEV_TIME:func/TIME_SET
+7602 DEV_TIME:func/TIME_GET
+7603 DEV_TIME:func/ALARM_SET
+7604 DEV_TIME:func/ALARM_GET
+7605 DEV_TIME:func/NOTIFY_MODE_SET
+7606 DEV_TIME:func/NOTIFY_MODE_GET
+7607 DEV_TIME:func/TIME_NOTIFY
+7608 DEV_TIME:func/ALARM_NOTIFY
+7609 DEV_TIME:func/ALARM_CHK_NOTIFY
+760A DEV_TIME:func/RTC_STATUS
+760B DEV_TIME:func/RTC_STATUS_CHECK
+760C DEV_TIME:func/RTC_STATUS_GET
+760D DEV_TIME:func/FULL_DAYS_IN_SECS
+760E DEV_TIME:func/CALIB_VALUE_CALC
+760F DEV_TIME:func/NEW_CALIB_VALUE
+7610 DEV_TIME:func/SLEEP_CLK_RATIO_SET
+7611 DEV_TIME:func/SLEEP_CLK_CALIB_REQ
+7612 DEV_TIME:func/WAITING_NEW_CALIB
+7613 DEV_TIME:func/WAITING_NEW_ALARM
+7614 DEV_TIME:func/INFORM_ALARM_TO_UI
+7615 DEV_TIME:func/ALARM_TYPE_GET
+7616 DEV_TIME:func/DEV_TIME_CSM_INIT
+7617 DEV_TIME:func/DATE_SET
+7618 DEV_TIME:func/dev_time_rtc_status_check(), comparison results
+78XX DEV_GSM:func/DEV_GSM_TRA
+7800 DEV_GSM:func/unused
+7801 DEV_GSM:func/FAST discharge started
+7802 DEV_GSM:func/SLOW discharge started
+7803 DEV_GSM:func/Discharging stopped
+7804 DEV_GSM:func/Last power-up was normal
+7805 DEV_GSM:func/Last power-up was NOT normal
+7806 DEV_GSM:func/dev_standby_status_get(), OK
+7807 DEV_GSM:func/dev_standby_status_get(), FAIL
+79XX DEV_CCNT:func/DEV_CCNT_TRA
+7900 DEV_CCNT:func/unused
+7901 DEV_CCNT:func/dev_ccont_int_handler(), CCONT intr. ID register
+7902 DEV_CCNT:func/dev_ccont_int_handler(), RTC-DAY interrupt!
+7903 DEV_CCNT:func/dev_ccont_int_handler(), RTC-MIN interrupt!
+7904 DEV_CCNT:func/dev_ccont_int_handler(), RTC-SEC interrupt!
+7905 DEV_CCNT:func/dev_ccont_int_handler(), RTC-ALR interrupt!
+7906 DEV_CCNT:func/dev_ccont_int_handler(), CHARGER interrupt!
+7907 DEV_CCNT:func/dev_ccont_charger_exist(), charger CONNECTION!
+7908 DEV_CCNT:func/dev_ccont_charger_exist(), charger DISCONNECTION!
+7DXX AUD:func/AUD_FUNCTION_TRA
+7D00 AUD:func/aud_init
+7D01 AUD:func/aud_acc_active
+7D02 AUD:func/aud_path_on
+7D03 AUD:func/aud_path_off
+7D04 AUD:func/aud_mode
+7D05 AUD:func/aud_mic_cs_on
+7D06 AUD:func/aud_mic_cs_off
+7D07 AUD:func/aud_mic_ui_on
+7D08 AUD:func/aud_mic_ui_off
+7D09 AUD:func/aud_mic_user_on
+7D0A AUD:func/aud_mic_user_off
+7D0B AUD:func/aud_ear_cs_on
+7D0C AUD:func/aud_ear_cs_off
+7D0D AUD:func/aud_ear_ui_on
+7D0E AUD:func/aud_ear_ui_off
+7D0F AUD:func/aud_ear_vol_set
+7D10 AUD:func/aud_ear_vol_get
+7D11 AUD:func/aud_ear_vol_inc
+7D12 AUD:func/aud_ear_vol_dec
+7D13 AUD:func/aud_request
+7D14 AUD:func/audio dsp params chunk
+7D15 AUD:func/mic/ear state
+7EXX TONE:func/TONE_FUNCTION_TRA
+7E00 TONE:func/aud_tone_start
+7E01 TONE:func/aud_tone_stop
+7E02 TONE:func/aud_dtmf_start
+7E03 TONE:func/aud_tone_buzzer
+7E04 TONE:func/aud_tone_ear
+7E05 TONE:func/aud_tone_buzzer_ear
+7FXX AUD:msg/AUD_MSG_TRA
+7F00 AUD:msg/aud_api_write
+7F01 AUD:msg/aud_api_error
+80XX AUD:tim/AUD_TIMER_TRA
+8000 AUD:tim/aud_ear_timer_start
+8001 AUD:tim/aud_mic_timer_start
+8002 AUD:tim/aud_param_timer_start
+8003 AUD:tim/aud_refresh_timer_start
+8004 AUD:tim/aud_test_timer_start
+8005 AUD:tim/aud_ear_timeout
+8006 AUD:tim/aud_mic_timeout
+8007 AUD:tim/aud_param_timeout
+8008 AUD:tim/aud_refresh_timeout
+8009 AUD:tim/aud_test_timeout
+800A AUD:tim/aud_message_error
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/type-cc.h b/gammu/emb/gammu/depend/nokia/dct3trac/type-cc.h
new file mode 100644
index 0000000..6c07ca2
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/type-cc.h
@@ -0,0 +1,43 @@
+{0x00, "", "Escape to nationally specific message types"},
+/* Call establishment messages: */
+{0x01, "9.3.1", "ALERTING"},
+{0x08, "9.3.2", "CALL CONFIRMED"},
+{0x02, "9.3.3", "CALL PROCEEDING"},
+{0x07, "9.3.5", "CONNECT"},
+{0x0F, "9.3.6", "CONNECT ACKNOWLEDGE"},
+{0x0E, "9.3.8", "EMERGENCY SETUP"},
+{0x03, "9.3.17", "PROGRESS"},
+{0x04, "9.3.17a", "CC-ESTABLISHMENT"},
+{0x06, "9.3.17b", "CC-ESTABLISHMENT CONFIRMED"},
+{0x0B, "9.3.18a", "RECALL"},
+{0x09, "9.3.23a", "START CC"},
+{0x05, "9.3.23", "SETUP"},
+/* Call information phase messages: */
+{0x17, "9.3.13", "MODIFY"},
+{0x1F, "9.3.14", "MODIFY COMPLETE"},
+{0x13, "9.3.15", "MODIFY REJECT"},
+{0x10, "9.3.31", "USER INFORMATION"},
+{0x18, "9.3.10", "HOLD"},
+{0x19, "9.3.11", "HOLD ACKNOWLEDGE"},
+{0x1A, "9.3.12", "HOLD REJECT"},
+{0x1C, "9.3.20", "RETRIEVE"},
+{0x1D, "9.3.21", "RETRIEVE ACKNOWLEDGE"},
+{0x1E, "9.3.22", "RETRIEVE REJECT"},
+/* Call clearing messages: */
+{0x25, "9.3.7", "DISCONNECT"},
+{0x2D, "9.3.18", "RELEASE"},
+{0x2A, "9.3.19", "RELEASE COMPLETE"},
+/* Miscellaneous messages: */
+{0x39, "9.3.4", "CONGESTION CONTROL"},
+{0x3E, "9.3.16", "NOTIFY"},
+{0x3D, "9.3.27", "STATUS"},
+{0x34, "9.3.28", "STATUS ENQUIRY"},
+{0x35, "9.3.24", "START DTMF"},
+{0x31, "9.3.29", "STOP DTMF"},
+{0x32, "9.3.30", "STOP DTMF ACKNOWLEDGE"},
+{0x36, "9.3.25", "START DTMF ACKNOWLEDGE"},
+{0x37, "9.3.26", "START DTMF REJECT"},
+{0x3A, "9.3.9", "FACILITY"},
+{-1, NULL, NULL}
+/* Unused sections
+*/
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/type-mm.h b/gammu/emb/gammu/depend/nokia/dct3trac/type-mm.h
new file mode 100644
index 0000000..8ba36b2
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/type-mm.h
@@ -0,0 +1,30 @@
+/* Registration messages: */
+{0x01, "9.2.12", "IMSI DETACH INDICATION"},
+{0x02, "9.2.13", "LOCATION UPDATING ACCEPT"},
+{0x04, "9.2.14", "LOCATION UPDATING REJECT"},
+{0x08, "9.2.15", "LOCATION UPDATING REQUEST"},
+/* Security messages: */
+{0x11, "9.2.1", "AUTHENTICATION REJECT"},
+{0x12, "9.2.2", "AUTHENTICATION REQUEST"},
+{0x14, "9.2.3", "AUTHENTICATION RESPONSE"},
+{0x1C, "9.2.3a", "CS AUTHENTICATION FAILURE"},
+{0x18, "9.2.10", "IDENTITY REQUEST"},
+{0x19, "9.2.11", "IDENTITY RESPONSE"},
+{0x1A, "9.2.17", "TMSI REALLOCATION COMMAND"},
+{0x1B, "9.2.18", "TMSI REALLOCATION COMPLETE"},
+/* Connection management messages: */
+{0x21, "9.2.5", "CM SERVICE ACCEPT"},
+{0x22, "9.2.6", "CM SERVICE REJECT"},
+{0x23, "9.2.7", "CM SERVICE ABORT"},
+{0x24, "9.2.9", "CM SERVICE REQUEST"},
+{0x25, "9.2.5a", "CM SERVICE PROMPT"},
+{0x26, "9.2.20", "NOTIFICATION RESPONSE"},
+{0x28, "9.2.4", "CM RE-ESTABLISHMENT REQUEST"},
+{0x29, "9.2.8", "ABORT"},
+/* Miscellaneous messages: */
+{0x30, "9.2.19", "MM NULL"},
+{0x31, "9.2.16", "MM STATUS"},
+{0x32, "9.2.15a", "MM INFORMATION"},
+{-1, NULL, NULL}
+/* Unused sections
+*/
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/type-rr.h b/gammu/emb/gammu/depend/nokia/dct3trac/type-rr.h
new file mode 100644
index 0000000..31adee4
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/type-rr.h
@@ -0,0 +1,100 @@
+/* Channel establishment messages: */
+{0x3C, "9.1.28a", "RR INITIALISATION REQUEST"},
+{0x3B, "9.1.1", "ADDITIONAL ASSIGNMENT"},
+{0x3F, "9.1.18", "IMMEDIATE ASSIGNMENT"},
+{0x39, "9.1.19", "IMMEDIATE ASSIGNMENT EXTENDED"},
+{0x3A, "9.1.20", "IMMEDIATE ASSIGNMENT REJECT"},
+{0x48, "9.1.12f", "DTM ASSIGNMENT FAILURE"},
+{0x49, "9.1.12h", "DTM REJECT"},
+{0x4A, "9.1.12i", "DTM REQUEST"},
+{0x4B, "9.1.21f", "PACKET ASSIGNMENT"},
+/* Ciphering messages: */
+{0x35, "9.1.9", "CIPHERING MODE COMMAND"},
+{0x32, "9.1.10", "CIPHERING MODE COMPLETE"},
+/* Configuration change messages: */
+{0x30, "9.1.12b", "CONFIGURATION CHANGE COMMAND"},
+{0x31, "9.1.12c", "CONFIGURATION CHANGE ACKNOWLEDGE"},
+{0x33, "9.1.12d", "CONFIGURATION CHANGE REJECT"},
+/* Handover messages: */
+{0x2E, "9.1.2", "ASSIGNMENT COMMAND"},
+{0x29, "9.1.3", "ASSIGNMENT COMPLETE"},
+{0x2F, "9.1.4", "ASSIGNMENT FAILURE"},
+{0x2B, "9.1.15", "HANDOVER COMMAND"},
+{0x2C, "9.1.16", "HANDOVER COMPLETE"},
+{0x28, "9.1.17", "HANDOVER FAILURE"},
+{0x2D, "9.1.28", "PHYSICAL INFORMATION"},
+{0x4C, "9.1.12e", "DTM ASSIGNMENT COMMAND"},
+{0x08, "9.1.21e", "RR-CELL CHANGE ORDER"},
+{0x23, "9.1.13a", "PDCH ASSIGNMENT COMMAND"},
+/* Channel release messages: */
+{0x0D, "9.1.7", "CHANNEL RELEASE"},
+{0x0A, "9.1.26", "PARTIAL RELEASE"},
+{0x0F, "9.1.27", "PARTIAL RELEASE COMPLETE"},
+/* Paging and Notification messages: */
+{0x21, "9.1.22", "PAGING REQUEST TYPE 1"},
+{0x22, "9.1.23", "PAGING REQUEST TYPE 2"},
+{0x24, "9.1.24", "PAGING REQUEST TYPE 3"},
+{0x27, "9.1.25", "PAGING RESPONSE"},
+{0x20, "9.1.21b", "NOTIFICATION/NCH"},
+{0x25, "", "Reserved"},
+{0x26, "9.1.21d", "NOTIFICATION RESPONSE"},
+{0x0B, "", "Reserved"},
+{0x4E, "9.1.21g", "PACKET NOTIFICATION"},
+/* 3G Specific messages */
+{0x60, "9.1.11a", "UTRAN CLASSMARK CHANGE"},
+{0x62, "9.1.11b", "cdma2000 CLASSMARK CHANGE"},
+{0x63, "9.1.15a", "INTER SYSTEM TO UTRAN HANDOVER COMMAND"},
+{0x64, "9.1.15b", "INTER SYSTEM TO CDMA2000 HANDOVER COMMAND"},
+/* System information messages: */
+{0x18, "9.1.42", "SYSTEM INFORMATION TYPE 8"},
+{0x19, "9.1.31", "SYSTEM INFORMATION TYPE 1"},
+{0x1A, "9.1.32", "SYSTEM INFORMATION TYPE 2"},
+{0x1B, "9.1.35", "SYSTEM INFORMATION TYPE 3"},
+{0x1C, "9.1.36", "SYSTEM INFORMATION TYPE 4"},
+{0x1D, "9.1.37", "SYSTEM INFORMATION TYPE 5"},
+{0x1E, "9.1.40", "SYSTEM INFORMATION TYPE 6"},
+{0x1F, "9.1.41", "SYSTEM INFORMATION TYPE 7"},
+/* System information messages: */
+{0x02, "9.1.33", "SYSTEM INFORMATION TYPE 2bis"},
+{0x03, "9.1.34", "SYSTEM INFORMATION TYPE 2ter"},
+{0x07, "9.1.34a", "SYSTEM INFORMATION TYPE 2quater"},
+{0x05, "9.1.38", "SYSTEM INFORMATION TYPE 5bis"},
+{0x06, "9.1.39", "SYSTEM INFORMATION TYPE 5ter"},
+{0x04, "9.1.43", "SYSTEM INFORMATION TYPE 9"},
+{0x00, "9.1.43a", "SYSTEM INFORMATION TYPE 13"},
+/* System information messages: */
+{0x3D, "9.1.43d", "SYSTEM INFORMATION TYPE 16"},
+{0x3E, "9.1.43e", "SYSTEM INFORMATION TYPE 17"},
+/* System information messages: */
+{0x40, "9.1.43.g", "SYSTEM INFORMATION TYPE 18"},
+{0x41, "9.1.43f", "SYSTEM INFORMATION TYPE 19"},
+{0x42, "9.1.43.h", "SYSTEM INFORMATION TYPE 20"},
+/* Miscellaneous messages: */
+{0x10, "9.1.5", "CHANNEL MODE MODIFY"},
+{0x12, "9.1.29", "RR STATUS"},
+{0x17, "9.1.6", "CHANNEL MODE MODIFY ACKNOWLEDGE"},
+{0x14, "9.1.13", "FREQUENCY REDEFINITION"},
+{0x15, "9.1.21", "MEASUREMENT REPORT"},
+{0x16, "9.1.11", "CLASSMARK CHANGE"},
+{0x13, "9.1.12", "CLASSMARK ENQUIRY"},
+{0x36, "9.1.52", "EXTENDED MEASUREMENT REPORT"},
+{0x37, "9.1.51", "EXTENDED MEASUREMENT ORDER"},
+{0x34, "9.1.13b", "GPRS SUSPENSION REQUEST"},
+{0x4D, "9.1.12g", "DTM INFORMATION"},
+{0x09, "9.1.49", "VGCS UPLINK GRANT"},
+{0x0E, "9.1.48", "UPLINK RELEASE"},
+{0x0C, "", "Reserved"},
+{0x2A, "9.1.46", "UPLINK BUSY"},
+{0x11, "9.1.44", "TALKER INDICATION"},
+{0x38, "9.1.53", "APPLICATION INFORMATION"},
+{-1, NULL, NULL}
+/* Unused sections
+ NOTIFICATION/FACCH [9.1.21a]
+ HANDOVER ACCESS [9.1.14]
+ SYNCHRONIZATION CHANNEL INFORMATION [9.1.30]
+ UPLINK FREE [9.1.47]
+ UPLINK ACCESS [9.1.45]
+ ENHANCED MEASUREMENT REPORT [9.1.55]
+ CHANNEL REQUEST [9.1.8]
+ MEASUREMENT INFORMATION [9.1.54]
+*/
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/type-sms.h b/gammu/emb/gammu/depend/nokia/dct3trac/type-sms.h
new file mode 100644
index 0000000..54b9ec3
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/type-sms.h
@@ -0,0 +1,6 @@
+{0x01, "7.2.1", "CP-DATA"},
+{0x04, "7.2.2", "CP-ACK"},
+{0x10, "7.2.3", "CP-ERROR"},
+{-1, NULL, NULL}
+/* Unused sections
+*/
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/type-ss.h b/gammu/emb/gammu/depend/nokia/dct3trac/type-ss.h
new file mode 100644
index 0000000..d258892
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/type-ss.h
@@ -0,0 +1,8 @@
+/* Clearing messages: */
+{0x2A, "2.5", "RELEASE COMPLETE"},
+/* Miscellaneous message group: */
+{0x3A, "2.3", "FACILITY"},
+{0x3B, "2.4", "REGISTER"},
+{-1, NULL, NULL}
+/* Unused sections
+*/
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.c
new file mode 100644
index 0000000..44db64b
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.c
@@ -0,0 +1,416 @@
+/**
+ * Simple GSM frame decoder
+ * wumpus 2003 -- www.blacksphere.tk
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include "wmx-util.h"
+#include "wmx-gsm.h"
+
+/* Administrative */
+GSMDecoder *GSMDecoder_new()
+{
+ GSMDecoder *self;
+
+ self = malloc(sizeof(GSMDecoder));
+ self->xmlout = NULL;
+
+ return self;
+}
+
+/**
+ * Set 'sniffer' XML output stream
+ */
+void GSMDecoder_xmlout(GSMDecoder *self, FILE *f)
+{
+ self->xmlout = f;
+ if(self->xmlout) {
+ /* Open XML doc */
+ fprintf(self->xmlout,"<?xml version=\"1.0\"?>\n");
+ fprintf(self->xmlout,"<dump>\n");
+ }
+}
+
+void GSMDecoder_free(GSMDecoder *self)
+{
+ if(self->xmlout) {
+ fprintf(self->xmlout,"</dump>\n");
+ fclose(self->xmlout);
+ }
+ free(self);
+}
+
+char *GSM_protocols[]={
+/*0*/ "Group call control",
+/*1*/ "Broadcast call control",
+/*2*/ "PDSS1",
+/*3*/ "Call Control; call related SS messages (TS 24.008)",
+/*4*/ "PDSS2",
+/*5*/ "Mobility Management messages (TS 24.008)",
+/*6*/ "Radio Resources management messages (GSM 04.18)",
+/*7*/ "RFU",
+/*8*/ "GPRS mobility management messages",
+/*9*/ "SMS messages (GSM 04.11)",
+/*A*/ "GPRS session management messages",
+/*B*/ "Non call related SS messages (GSM 04.80)",
+/*C*/ "Location services",
+/*D*/ "RFU",
+/*E*/ "Reserved for extension of the PD to one octet length",
+/*F*/ "Reserved for tests procedures described in GSM 11.10"
+};
+
+typedef struct GSMpackettypestruct {
+ int id;
+ char *section;
+ char *description;
+} GSMpackettype;
+
+/* Include the data */
+GSMpackettype GSM_RR_packettypes[] = {
+#include "type-rr.h"
+};
+GSMpackettype GSM_MM_packettypes[] = {
+#include "type-mm.h"
+};
+GSMpackettype GSM_CC_packettypes[] = {
+#include "type-cc.h"
+};
+GSMpackettype GSM_SS_packettypes[] = {
+#include "type-ss.h"
+};
+GSMpackettype GSM_SMS_packettypes[] = {
+#include "type-sms.h"
+};
+
+GSMpackettype *GSMpackettype_lookup(GSMpackettype list[], int id)
+{
+ GSMpackettype *ptr = list;
+
+ while(ptr->id != -1 && ptr->id != id) ptr++;
+ if(ptr->id == -1) {
+ return NULL;
+ } else {
+ return ptr;
+ }
+}
+
+/* disassemble L3 packet -- GSM 04.06
+tx=0 Network to MS
+tx=1 MS to Network
+*/
+void GSMDecoder_L3packet(GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length)
+{
+ int proto,type;
+ GSMpackettype *ptype;
+
+ dumpraw("Inform", buffer, length);
+ printf(" ");
+ if(length < 2) return;
+
+ /* Attempt at decoding first byte
+ -- protocol discriminator
+ */
+ proto = buffer[0]&0xF;
+ printf("\n %s ", GSM_protocols[proto]);
+
+ switch(proto) {
+ case 0x3: /* CC */
+ type = buffer[1]&0x3F;
+ ptype = GSMpackettype_lookup(GSM_CC_packettypes, type);
+ if (ptype == NULL) {
+ printf("\n Unknown %02X", type);
+ } else {
+ printf("\n %s (%s)", ptype->description, ptype->section);
+ }
+ break;
+ case 0x5: /* MM */
+ type = buffer[1]&0x3F;
+ ptype = GSMpackettype_lookup(GSM_MM_packettypes, type);
+ if (ptype == NULL) {
+ printf("\n Unknown %02X", type);
+ } else {
+ printf("\n %s (%s)", ptype->description, ptype->section);
+ }
+ break;
+ case 0x6: /* RR */
+ if (buffer[0]>>4) {
+ printf("\n RR:Invalid Skip Indicator");
+ return;
+ }
+ type = buffer[1];
+ ptype = GSMpackettype_lookup(GSM_RR_packettypes, type);
+ if (ptype == NULL) {
+ printf("\n Unknown %02X", type);
+ } else {
+ printf("\n %s (%s)", ptype->description, ptype->section);
+ }
+ break;
+ case 0x9: /* SMS */
+ type = buffer[1]&0x3F;
+ ptype = GSMpackettype_lookup(GSM_SMS_packettypes, type);
+ if (ptype == NULL) {
+ printf("\n Unknown %02X", type);
+ } else {
+ printf("\n %s (%s)", ptype->description, ptype->section);
+ }
+ break;
+ case 0xB: /* SS */
+ if (buffer[1]&0x80) {
+ printf("\n SS:Invalid Message Type");
+ return;
+ }
+ type = buffer[1]&0x3F;
+ ptype = GSMpackettype_lookup(GSM_SS_packettypes, type);
+ if (ptype == NULL) {
+ printf("\n Unknown %02X", type);
+ } else {
+ printf("\n %s (%s)", ptype->description, ptype->section);
+ }
+ break;
+ }
+}
+
+static void GSMDecoder_l1xml_open(GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length)
+{
+ unsigned int x;
+
+ if(self->xmlout) {
+ fprintf(self->xmlout, "<l1 ");
+ fprintf(self->xmlout, "direction=\"%s\" ", l1->tx==GSMDECODER_SEND?"up":"down");
+ fprintf(self->xmlout, "logicalchannel=\"%i\" ", l1->ch);
+ if(l1->tx == GSMDECODER_RECEIVE) {
+ fprintf(self->xmlout, "physicalchannel=\"%i\" ", l1->arfcn);
+ fprintf(self->xmlout, "sequence=\"%u\" ", l1->seq);
+ fprintf(self->xmlout, "error=\"%i\" ", l1->err);
+ fprintf(self->xmlout, "timeshift=\"%i\" ", l1->timeshift);
+ fprintf(self->xmlout, "bsic=\"%i\" ", l1->bsic);
+ fprintf(self->xmlout, "data=\"");
+ for(x=0; x<length; x++) {
+ fprintf(self->xmlout, "%02X", buffer[x]);
+ }
+ fprintf(self->xmlout, "\" ");
+ }
+ fprintf(self->xmlout, ">\n");
+ }
+}
+
+static void GSMDecoder_l1xml_close(GSMDecoder *self)
+{
+ if(self->xmlout) fprintf(self->xmlout, "</l1>\n");
+}
+
+/* disassemble L2 pseudo length header packet -- GSM 04.06
+ tx=0 Network to MS
+ tx=1 MS to Network
+ write XML stream
+*/
+void GSMDecoder_L2short_packet(GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length)
+{
+ size_t ptr,usedlength, x;
+
+ GSMDecoder_l1xml_open(self, l1, buffer, length);
+
+ if(length<1) {
+ /* too small to contain 1 header byte */
+ printf("L2 packet too small\n");
+ GSMDecoder_l1xml_close(self);
+ return;
+ }
+ ptr = 0;
+ //printf("L2 packet\n");
+
+ /* dump Length Indicator field */
+ usedlength = buffer[ptr]>>2;
+ if((buffer[ptr]&3) != 1) {
+ dumpraw("ErrPacket", buffer, length);
+ printf(" Invalid pseudo length byte\n");
+ GSMDecoder_l1xml_close(self);
+ return;
+ }
+ printf("Length : used=%i ID=%i\n",
+ usedlength,
+ (buffer[ptr]>>0)&3);
+ ptr++;
+ /* dump Information */
+ printf("Inform : ");
+ if((ptr+usedlength) > length) {
+ printf("Invalid used length\n");
+ }
+ if(self->xmlout) {
+ fprintf(self->xmlout, "<l2 ");
+ fprintf(self->xmlout, "data=\"");
+ for(x=0; x<usedlength; x++) fprintf(self->xmlout, "%02X", buffer[ptr+x]);
+ fprintf(self->xmlout, "\" ");
+ /* Rest octets */
+ fprintf(self->xmlout, "rest=\"");
+ for(x=(ptr+usedlength); x<length; x++) fprintf(self->xmlout, "%02X", buffer[x]);
+ fprintf(self->xmlout, "\" ");
+ fprintf(self->xmlout, ">\n");
+ }
+ GSMDecoder_L3packet(self, l1, &buffer[ptr], usedlength);
+ if(self->xmlout) fprintf(self->xmlout, "</l2>\n");
+ //dumpraw("Inform", &buffer[ptr], usedlength);
+ //printf("\n");
+ GSMDecoder_l1xml_close(self);
+}
+
+#define TYPE_I 0x01 /* Information */
+#define TYPE_S 0x02 /* Supervisory */
+#define TYPE_U 0x03 /* Unnumbered */
+
+/* disassemble L2 packet -- GSM 04.06
+tx=0 Network to MS
+tx=1 MS to Network
+*/
+void GSMDecoder_L2packet(GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length)
+{
+ size_t ptr,usedlength,x;
+ int more;
+ int type;
+ char temp[80];
+
+ GSMDecoder_l1xml_open(self, l1, buffer, length);
+
+ if(length<5) {
+ /* too small to contain 3 header bytes plus 20 data bytes */
+ printf("L2 packet too small\n");
+ GSMDecoder_l1xml_close(self);
+ return;
+ }
+ ptr = 0;
+ //printf("L2 packet\n");
+ /* dump Address field */
+ printf("Address: LPD=%i SAPI=%i C/R=%i EA=%i\n",
+ (buffer[ptr]>>5)&3,
+ (buffer[ptr]>>2)&7,
+ (buffer[ptr]>>1)&1,
+ (buffer[ptr]>>0)&1);
+ /* skip next address field bytes */
+ while((buffer[ptr]&1)==0) ptr++;
+ ptr++;
+ /* dump Control field */
+
+ type = TYPE_I;
+ // if(!(buffer[ptr]&1)) type = TYPE_I;
+ if((buffer[ptr]&1) && !(buffer[ptr]&2)) type = TYPE_S;
+ if((buffer[ptr]&1) && (buffer[ptr]&2)) type = TYPE_U;
+ switch(type) {
+ case TYPE_I:
+ printf("Control: I TXSeq=%i P=%i RXSeq=%i\n",
+ (buffer[ptr]>>5)&7,
+ (buffer[ptr]>>4)&1,
+ (buffer[ptr]>>1)&7);
+ break;
+ case TYPE_S: {
+ char *desc = "Unknown";
+ x = (buffer[ptr]>>2)&3;
+ switch(x) {
+ case 0: /* 00 */ desc="RR (Receive Ready)"; break; /* ALSO acknowledgement */
+ case 1: /* 01 */ desc="RNR (Receive Not Ready)"; break;
+ case 2: /* 10 */ desc="REJ (Reject)"; break;
+ }
+ printf("Control: S TXSeq=%i P/F=%i S=%i %s\n",
+ (buffer[ptr]>>5)&7,
+ (buffer[ptr]>>4)&1,
+ x, desc);
+ } break;
+ case TYPE_U: {
+ char *desc = "Unknown";
+ x = (((buffer[ptr]>>5)&7)<<2) | ((buffer[ptr]>>2)&3);
+ binstr(temp, x, 5);
+ switch(x) {
+ case 0: /* 00000 */ desc = "UI (Unnumbered information)"; break;
+ case 3: /* 00011 */ desc = "DM (Disconnect mode)"; break;
+ case 7: /* 00111 */ desc = "SABM (Set asynchronous balanced mode)"; break;
+ case 8: /* 01000 */ desc = "DISC (Disconnect)"; break;
+ case 12:/* 01100 */ desc = "UA (Unnumbered acknowledge)"; break;
+ }
+
+ printf("Control: U U=%s %s P/F=%i\n",
+ temp, desc,
+ (buffer[ptr]>>4)&1);
+ } break;
+ }
+ ptr++;
+ /* dump Length Indicator field */
+ usedlength = buffer[ptr]>>2;
+ more = (buffer[ptr]>>1)&1; /* more to go */
+ printf("Length : used=%i M=%i EL=%i\n",
+ usedlength, more,
+ (buffer[ptr]>>0)&1);
+ while((buffer[ptr]&1)==0) ptr++;
+ ptr++;
+ /* dump Information */
+ printf("Inform : ");
+ if((ptr+usedlength) > length) {
+ printf("Invalid used length\n");
+ }
+ /*
+ for(x=0; x<usedlength; x++) {
+ printf("%02x ",buffer[ptr]);
+ ptr++;
+ }
+ */
+ if(self->xmlout) {
+ char *desc;
+ fprintf(self->xmlout, "<l2 ");
+ switch(type) {
+ case TYPE_I:
+ fprintf(self->xmlout, "type=\"I\" ");
+ fprintf(self->xmlout, "txseq=\"%i\" p=\"%i\" rxseq=\"%i\" ",
+ (buffer[ptr]>>5)&7,
+ (buffer[ptr]>>4)&1,
+ (buffer[ptr]>>1)&7);
+ break;
+ case TYPE_S:
+ fprintf(self->xmlout, "type=\"S\" ");
+ desc = "Unknown";
+ x = (buffer[ptr]>>2)&3;
+ switch(x) {
+ case 0: /* 00 */ desc="RR"; break; /* ALSO acknowledgement */
+ case 1: /* 01 */ desc="RNR"; break;
+ case 2: /* 10 */ desc="REJ"; break;
+ }
+ fprintf(self->xmlout, "subtype=\"%s\" rxseq=\"%i\" p=\"%i\" ",
+ desc,
+ (buffer[ptr]>>5)&7,
+ (buffer[ptr]>>4)&1);
+ break;
+ case TYPE_U:
+ fprintf(self->xmlout, "type=\"U\" ");
+ desc = "Unknown";
+ x = (((buffer[ptr]>>5)&7)<<2) | ((buffer[ptr]>>2)&3);
+ switch(x) {
+ case 0: /* 00000 */ desc = "UI"; break;
+ case 3: /* 00011 */ desc = "DM"; break;
+ case 7: /* 00111 */ desc = "SABM"; break;
+ case 8: /* 01000 */ desc = "DISC"; break;
+ case 12:/* 01100 */ desc = "UA"; break;
+ }
+
+ fprintf(self->xmlout, "subtype=\"%s\" p=\"%i\" ",
+ desc,
+ (buffer[ptr]>>4)&1);
+ break;
+ default:
+ fprintf(self->xmlout, "type=\"Unknown\" ");
+ }
+ fprintf(self->xmlout, "data=\"");
+ for(x=0; x<usedlength; x++) fprintf(self->xmlout, "%02X", buffer[ptr+x]);
+ fprintf(self->xmlout, "\" ");
+ fprintf(self->xmlout, ">\n");
+ }
+ GSMDecoder_L3packet(self, l1, &buffer[ptr], usedlength);
+ if(self->xmlout) fprintf(self->xmlout, "</l2>\n");
+ GSMDecoder_l1xml_close(self);
+ //dumpraw("Inform", );
+ //printf("\n");
+}
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.h b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.h
new file mode 100644
index 0000000..13b9ed8
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-gsm.h
@@ -0,0 +1,41 @@
+#ifndef WMX_GSM_INCLUDED
+#define WMX_GSM_INCLUDED
+
+typedef struct GSMDecoder_struct {
+ FILE *xmlout;
+} GSMDecoder;
+
+typedef struct GSMDecoder_l1l2data_struct {
+ /* 0 receive
+ 1 send
+ */
+ int tx;
+
+ #define GSMDECODER_RECEIVE 0
+ #define GSMDECODER_SEND 1
+
+ /* send and receive */
+ int ch; /* logical channel */
+
+ /* receive only: */
+ int bsic; /* base station identity code */
+ int arfcn; /* physical channel */
+ int seq; /* sequence number */
+ short timeshift; /* diff time with sequence number */
+ int err; /* error flag */
+} GSMDecoder_l1l2data;
+
+GSMDecoder *GSMDecoder_new();
+
+void GSMDecoder_free (GSMDecoder *self);
+void GSMDecoder_xmlout (GSMDecoder *self, FILE *f);
+
+void GSMDecoder_L3packet (GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length);
+void GSMDecoder_L2short_packet (GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length);
+void GSMDecoder_L2packet (GSMDecoder *self, GSMDecoder_l1l2data *l1, unsigned char *buffer, size_t length);
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.c
new file mode 100644
index 0000000..9af4b48
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.c
@@ -0,0 +1,137 @@
+/**
+ * Decode trace type using text file
+ * wumpus 2003 -- www.blacksphere.tk
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include "wmx-util.h"
+#include "wmx-list.h"
+
+static void wmx_tracelist_init(struct wmx_tracelist *tl)
+{
+ tl->entries = 0;
+ tl->max = 10;
+ tl->records = malloc(tl->max * sizeof(struct wmx_tracetype));
+}
+
+static void wmx_tracelist_add(struct wmx_tracelist *tl, int type, char *desc)
+{
+ /* Possibly expand list */
+ if(tl->entries == tl->max) {
+ tl->max *= 2;
+ tl->records = realloc(tl->records, tl->max * sizeof(struct wmx_tracetype));
+ }
+ /* Add record */
+ tl->records[tl->entries].type = type;
+ tl->records[tl->entries].desc = strdup(desc);
+ /* Increase number of entries */
+ tl->entries++;
+ //printf("%04x %04x\n", tl->entries, tl->max);
+}
+
+static void wmx_tracelist_free(struct wmx_tracelist *tl)
+{
+ int x;
+
+ for(x=0; x<tl->entries; x++) free(tl->records[x].desc);
+ free(tl->records);
+ tl->entries = tl->max = 0;
+ tl->records = NULL;
+}
+
+/** Comparision function for bsearch */
+static int compar(const void *a, const void *b)
+{
+ int typea = ((struct wmx_tracetype*)a)->type;
+ int typeb = ((struct wmx_tracetype*)b)->type;
+ if(typea < typeb) return -1;
+ if(typea > typeb) return 1;
+ return 0;
+}
+
+/**
+ * Look up debug trace type
+ */
+static struct wmx_tracetype *wmx_tracelist_search(struct wmx_tracelist *tl, int type)
+{
+ /*
+ int x;
+ for(x=0; x<tl->entries; x++)
+ if(tl->records[x].type == type)
+ return &tl->records[x];
+ return NULL;
+ */
+
+ struct wmx_tracetype key;
+
+ key.type = type;
+ return bsearch(&key, tl->records, tl->entries, sizeof(struct wmx_tracetype), &compar);
+}
+
+struct wmx_tracestruct *wmx_tracestruct_load(char *listfile)
+{
+ char data[256];
+ FILE *f;
+ struct wmx_tracestruct *tl;
+ int tpe;
+
+ f = fopen(listfile, "r");
+
+ if(f == NULL) return NULL;
+ printf("Loading\n");
+
+ tl = malloc(sizeof(struct wmx_tracestruct));
+ wmx_tracelist_init(&tl->minors);
+ wmx_tracelist_init(&tl->majors);
+
+ while(fgets(data, sizeof(data), f)) {
+ int l = strlen(data);
+ if(l > 0 && data[l-1]=='\n') l--;
+ data[l] = 0;
+ if(l < 6)
+ /* Empty/invalid line */
+ continue;
+ if(data[2] == 'X' && data[3] == 'X') {
+ sscanf(data, "%02X", &tpe);
+ wmx_tracelist_add(&tl->majors, tpe, &data[5]);
+ } else {
+ sscanf(data, "%04X", &tpe);
+ wmx_tracelist_add(&tl->minors, tpe, &data[5]);
+ }
+ }
+ fclose(f);
+ return tl;
+}
+
+
+struct wmx_tracetype *wmx_tracestruct_querymajor(struct wmx_tracestruct * ts, int type) {
+ return wmx_tracelist_search(&ts->majors, type);
+}
+
+struct wmx_tracetype *wmx_tracestruct_queryminor(struct wmx_tracestruct * ts, int type) {
+ return wmx_tracelist_search(&ts->minors, type);
+}
+
+void wmx_tracestruct_free(struct wmx_tracestruct * ts) {
+ wmx_tracelist_free(&ts->minors);
+ wmx_tracelist_free(&ts->majors);
+ free(ts);
+}
+
+/*
+main() {
+ int x;
+ struct wmx_tracestruct * tstruct= wmx_tracestruct_load(
+ "/home/orion/projects/blacksphere/tables/nhm5_587.txt");
+
+ printf("%s\n", wmx_tracestruct_queryminor(tstruct, 0x1802)->desc);
+}
+*/
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.h b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.h
new file mode 100644
index 0000000..1e76af9
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-list.h
@@ -0,0 +1,28 @@
+#ifndef WMX_TRACELIST_INCLUDED
+#define WMX_TRACELIST_INCLUDED
+
+struct wmx_tracetype {
+ int type;
+ char *desc;
+};
+
+struct wmx_tracelist {
+ int max, entries;
+ struct wmx_tracetype *records;
+};
+
+struct wmx_tracestruct {
+ struct wmx_tracelist majors, minors;
+};
+
+struct wmx_tracestruct *wmx_tracestruct_load(char *listfile);
+struct wmx_tracetype *wmx_tracestruct_querymajor(struct wmx_tracestruct * ts, int type);
+struct wmx_tracetype *wmx_tracestruct_queryminor(struct wmx_tracestruct * ts, int type);
+
+void wmx_tracestruct_free(struct wmx_tracestruct * ts);
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.c
new file mode 100644
index 0000000..039d9e9
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.c
@@ -0,0 +1,239 @@
+/**
+ * SIM packet disassembly functions
+ * The Monty <monty@technojunkie.gr>
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include "wmx-util.h"
+#include "wmx-sim.h"
+
+/* Disassemble SIM Command packet (0x25)
+ * -- GSM 11.11 v6.2.0 (1999)
+ */
+/* vars:
+ * ins = sim cmd instruction
+ * type = 0x25 debug subtype
+ * buffer = sim cmd's parameter 1 (P1) + P2 + P3 + additional data if exist
+ * (ie select file, additional data is file id)
+ */
+void simCommand_data(unsigned char ins, unsigned char type, unsigned char *buffer, size_t length)
+{
+ size_t x;
+ int v=1; // v = verbose (to use or not to use ?)
+
+ printf("[a0 %02x ", ins);
+ for(x=0;x<length;x++) printf("%02x ", buffer[x]);
+ printf("]\nSim ");
+
+ /* This switches type. The below types are known/valid. Since I don't
+ * know all the types, i've created a switch based on instruction.
+ */
+/* switch(type) {
+ case 0x06:
+ printf("Request Status");
+ break;
+ case 0x07:
+ printf("Select Command");
+ break;
+ case 0x10:
+ printf("GetResponse Command\n");
+ break;
+ default:
+ printf("Unknown Command\n");
+ break;
+ }
+*/
+
+ /* A switch case based on sim command's instruction */
+ switch(ins) {
+ case 0xa4:
+ printf("Select Command");
+ break;
+ case 0xf2:
+ printf("Request Status");
+ break;
+ case 0xb0:
+ printf("Read Binary");
+ break;
+ case 0xd6:
+ printf("Update Binary");
+ break;
+ case 0xb2:
+ printf("Read Record");
+ break;
+ case 0xdc:
+ printf("Update Record");
+ break;
+ case 0xa2:
+ printf("Seek cmd");
+ break;
+ case 0x32:
+ printf("Increase cmd");
+ break;
+ case 0x20:
+ printf("Verify CHV");
+ break;
+ case 0x24:
+ printf("Change CHV");
+ break;
+ case 0x26:
+ printf("Disable CHV");
+ break;
+ case 0x28:
+ printf("Enable CHV");
+ break;
+ case 0x2c:
+ printf("Unblock CHV");
+ break;
+ case 0x04:
+ printf("Invalidate");
+ break;
+ case 0x44:
+ printf("Rehabilitate");
+ break;
+ case 0x88:
+ printf("Run GSM Algorithm");
+ break;
+ case 0xfa:
+ printf("Sleep");
+ break;
+ case 0xc0:
+ printf("GetResponse Command");
+ break;
+ case 0x10:
+ printf("Terminal Profile");
+ break;
+ case 0xc2:
+ printf("Envelope");
+ break;
+ case 0x12:
+ printf("Fetch");
+ break;
+ case 0x14:
+ printf("Terminal Response");
+ break;
+ default:
+ printf("Unknown SIM command ");
+ printf(" : INS=%02x P1=%02x P2=%02x P3=%02x ", buffer[0], buffer[1], buffer[2], buffer[3]);
+ printf("\nCommand=");
+ for(x=0; x<length; x++) printf("%02x ",buffer[x]&0xFF);
+ printf("\n");
+ break;
+ }
+
+ if(v) {
+ printf(" : INS=%02x P1=%02x P2=%02x P3=%02x ", ins, buffer[0], buffer[1], buffer[2]);
+ if (ins==0xa4) {
+ printf(" FileID=%02x%02x",buffer[3], buffer[4]);
+ } else {
+ //printf("\n");
+ }
+ }
+}
+
+void simResponse_Process(unsigned char type, unsigned char *buffer, size_t length)
+{
+ size_t x;
+// for status process :
+ int RFU1,mem,fileID,fileT;
+ int lofd; //length of following data
+
+/* SIM responses to these commands:
+ - select (for MF/DF files: fileID,memory space available, CHV (en/)disable
+ indicator, CHV status, GSM specific data.
+ for EF files: fileID,fileSize,access conditions, valid/invalid
+ indicator, structure of EF and length of
+ records if they exist)
+ - status (fileID,memory space available, CHV en/disable indicator,
+ CHV status, GSM specific data like select command)
+ - read binary (string of bytes)
+ - read record (contents of the record)
+ - seek (only for seek type 2 response = 1 byte, the record number)
+ - increase ( etc.. etc.. described in GSM 11.11)
+ - run gsm algorithm
+ - get response
+ - envelope
+ - fetch
+*/
+ switch(type) {
+ case 0x02:
+ printf("(Read Binary) Binary's Data: ");
+ for(x=0; x<length; x++) printf("%02x ",buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ case 0x03:
+ printf("(Read Record) Record's Data:\n");
+ for(x=0; x<length; x++) printf("%02x ",buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ case 0x05:
+ printf("Get Response Data: ");
+ for(x=0; x<length; x++) printf("%02x ",buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ case 0x06:
+ printf("Status Response : ");
+ RFU1 = ((buffer[0]&0xFF)<<8)|(buffer[1]&0xFF);
+ mem = ((buffer[2]&0xFF)<<8)|(buffer[3]&0xFF);
+ fileID = ((buffer[4]&0xFF)<<8)|(buffer[5]&0xFF);
+ fileT = (buffer[6]&0xFF);
+ //RFU2 = (((buffer[7]&0xFF)<<8)|(buffer[8]&0xFF))<<8|(buffe
+ lofd = (buffer[12]&0xFF);
+ printf("RFU=%04x, mem=%04x, fileID=%04x,\nfileType=%02x, RFU=%02x%02x%02x%02x%02x, ",
+ RFU1, mem, fileID, fileT,
+ buffer[7], buffer[8], buffer[9], buffer[10], buffer[11] // RFU2
+ ); // not the proper way ;)
+ printf("%02x bytes of GSM specific data follows: ", lofd);
+
+ /* we could analyze these too but there is no meaning or time */
+ for(x=0;x<(unsigned int)lofd;x++) printf("%02x ", buffer[13+x]);
+ //printf("\n");
+ break;
+ case 0x09:
+ printf("Select Response");
+ // select response always has 00 bytes length
+ break;
+ default:
+ printf("Unknown SIM Response : ");
+ for(x=0; x<length; x++) printf("%02x ",buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ }
+}
+
+void simAnswer_Process(unsigned char type, unsigned char *buffer, size_t length)
+{
+ size_t x;
+
+ switch(type) {
+ case 0x00:
+ /* in some sim commands (i.e. status or read record) the answer
+ * is more than 2 bytes. we could analyse all the bytes but the
+ * usefull ones are only the last 2 of them.
+ * Should we make a switch() for the answer or would it be
+ * too much??
+ */
+ printf("SIM answer: ");
+ for(x=length-2;x<length;x++) printf("%02x ", buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ case 0x01:
+ /* 0x25XX sim command. I don't know why they re-write/send the command :-\
+ for(x=0;x<length;x++) printf("%02x ", buffer[x]&0xFF);
+ printf("\n");
+ */
+ break;
+ default:
+ printf("Uknown subtype! dumping data: ");
+ for(x=0;x<length;x++) printf("%02x ", buffer[x]&0xFF);
+ //printf("\n");
+ break;
+ }
+}
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.h b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.h
new file mode 100644
index 0000000..c42bd5b
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-sim.h
@@ -0,0 +1,13 @@
+#ifndef WMX_SIM
+
+#define WMX_SIM
+
+void simCommand_data (unsigned char ins, unsigned char type, unsigned char *buffer, size_t length);
+void simResponse_Process(unsigned char type, unsigned char *buffer, size_t length);
+void simAnswer_Process (unsigned char type, unsigned char *buffer, size_t length);
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.c
new file mode 100644
index 0000000..f5e7c9f
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.c
@@ -0,0 +1,46 @@
+/**
+ * Generic utils
+ * wumpus 2003 -- www.blacksphere.tk
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+#include "wmx-util.h"
+
+/**
+ * Dump raw hex
+ */
+void dumpraw(char *str, unsigned char *buffer, size_t length)
+{
+ size_t x;
+
+ printf("[");
+ for(x=0; x<length; x++) {
+ if(x != (length-1)) {
+ printf("%02x ",buffer[x]);
+ } else {
+ printf("%02x",buffer[x]);
+ }
+ }
+ printf("]");
+}
+
+/**
+ * Integer to binary
+ */
+void binstr(char *dest, unsigned int value, int len)
+{
+ int x;
+
+ for(x=len-1; x>=0; x--) {
+ dest[x] = '0' + (value & 1);
+ value >>= 1;
+ }
+ dest[len] = 0;
+}
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.h b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.h
new file mode 100644
index 0000000..8c15df0
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx-util.h
@@ -0,0 +1,11 @@
+#ifndef WMX_UTIL_INCLUDED
+#define WMX_UTIL_INCLUDED
+
+void dumpraw(char *str, unsigned char *buffer, size_t length);
+void binstr(char *dest, unsigned int value, int len);
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c
new file mode 100644
index 0000000..64eda37
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c
@@ -0,0 +1,480 @@
+/**
+ * Nokia DCT3 Firmware Debug Trace Monitor
+ * wumpus 2003 -- www.blacksphere.tk
+ * SIM stuff by The Monty
+ *
+ * Command line arguments:
+ * gammu --nokiadebug v00-0F,20,21
+ * (v=verbose)
+ */
+
+#include "../../../../common/gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+
+#include <string.h>
+#include <signal.h>
+
+#include "../../../../common/misc/coding/coding.h"
+#include "../../../../common/gsmcomon.h"
+#include "../../../../common/gsmstate.h"
+#include "../../../../common/service/gsmpbk.h"
+#include "../../../../common/phone/nokia/dct3/dct3func.h"
+#include "../../../gammu.h"
+#include "../dct3.h"
+#include "wmx.h"
+#include "wmx-util.h"
+#include "wmx-gsm.h"
+#include "wmx-sim.h"
+#include "wmx-list.h"
+
+extern GSM_Reply_Function UserReplyFunctionsX[];
+
+/* Global variables suck */
+GSMDecoder *gsmdec;
+struct wmx_tracestruct *traces;
+
+static GSM_Error DCT3_ReplySwitchDebug(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch(msg.Buffer[2]) {
+ case 0x70:
+ printf("Debug Trace Enabled\n");
+ break;
+ case 0x71:
+ printf("Debug Trace Disabled\n");
+ break;
+ }
+ return ERR_NONE;
+}
+
+/**
+ * RPC confirmation/reply
+ */
+static GSM_Error DCT3_ReplyRPC(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("RPC Reply ");
+ printf("call=%02x rettype=%02x data=", msg.Buffer[2], msg.Buffer[3]);
+ if(msg.Buffer[3] == 3) {
+ /* string */
+ printf("%s", &msg.Buffer[4]);
+ } else {
+ dumpraw("RPC Reply data", &msg.Buffer[4], msg.Length-4);
+ }
+ printf("\n");
+ return ERR_NONE;
+}
+
+/* disassemble mdisnd (0x18xx) packet */
+static void mdisnd_data(unsigned char type, unsigned char *buffer, size_t length)
+{
+ GSMDecoder_l1l2data dat;
+ size_t x;
+ int ch;
+
+ if(type==0x1B && length>2) {
+ /* channel packet */
+ ch = buffer[1];
+ dat.tx = GSMDECODER_SEND;
+ dat.ch = ch;
+ printf("%02X ch=%02X ",buffer[0],ch);
+ if (ch == 0x80 || ch == 0xB0) {
+ printf("\n");
+ GSMDecoder_L2packet(gsmdec, &dat, &buffer[2], length-2);
+ } else if (ch == 0x70) {
+ dumpraw("MDI send ch70 prefix", &buffer[2], 2);
+ printf("\n");
+ GSMDecoder_L2packet(gsmdec, &dat, &buffer[4], length-4);
+ } else {
+ dumpraw("MDI recv 1B packet", &buffer[2], length-2);
+ }
+ } else {
+ /* hex */
+ for(x=0; x<length; x++) {
+ printf("%02x ",buffer[x]&0xFF);
+ }
+ }
+}
+
+/* disassemble mdircv (0x19xx) packet */
+static void mdircv_data(unsigned char type, unsigned char *buffer, size_t length)
+{
+ size_t x;
+ int ch;
+ GSMDecoder_l1l2data dat;
+
+ if (type==0x80 && length>1) {
+ // buffer[0] channel
+ // buffer[1] flag1
+ // buffer[2] flag2
+ // buffer[3..5] timestamp
+ // buffer[6..7] unknown_hw1
+ // buffer[8..9] unknown_hw2
+ ch = buffer[0];
+ dat.tx = GSMDECODER_RECEIVE;
+ dat.ch = ch;
+ dat.bsic = buffer[1];
+ dat.err = buffer[2];
+ dat.seq = (buffer[3]<<16)|(buffer[4]<<8)|(buffer[5]);
+ dat.arfcn = (buffer[6]<<8)|buffer[7];
+ dat.timeshift = (buffer[8]<<8)|buffer[9];
+
+ printf("ch=%02X bsic=%i err=%i t=%06X arfcn=%i shift=%i",
+ ch, buffer[1], buffer[2],
+ dat.seq, dat.arfcn, dat.timeshift
+ );
+
+ //dumpraw("MDI recv 80 header", &buffer[6], 4);
+ printf(" ");
+ if(buffer[2] == 0) { /* unencrypted */
+ if(ch == 0x70) {
+ /* Normal header + 2b prefix */
+ dumpraw("MDI recv ch70 prefix", &buffer[10], 2);
+ printf("\n");
+ GSMDecoder_L2packet(gsmdec, &dat, &buffer[12], length-12);
+ } else if (ch == 0x80 || ch == 0xB0) {
+ /* Normal header */
+ printf("\n");
+ GSMDecoder_L2packet(gsmdec, &dat, &buffer[10], length-10);
+ } else if (ch == 0x50 || ch == 0x60) {
+ /* Short header */
+
+ printf("\n");
+ GSMDecoder_L2short_packet(gsmdec, &dat, &buffer[10], length-10);
+ } else {
+ dumpraw("MDI send 80 packet", &buffer[10], length-10);
+ }
+ } else {
+ /* Encrypted (?) */
+ dumpraw("MDI send err 80", &buffer[10], length-10);
+ }
+ } else {
+ /* hex */
+ for(x=0; x<length; x++) {
+ printf("%02x ",buffer[x]&0xFF);
+ }
+ }
+}
+
+static GSM_Error DCT3_ReplyDebugTrace(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int x;
+ int id,timestamp,number,length;
+ struct wmx_tracetype *minor;
+ char *desc;
+
+ //printf("Debug Trace Received\n");
+ /* parse frame
+ Debug trace packet:
+ packet type 0x00
+ source subsystem 0x01 (LOCAL)
+ verder formaat zie notebook
+ 0x08 ID (payload=offset 0x02 here)
+ 0x0A timestamp
+ 0x0C seq nr
+ 0x0D .. parameters
+ */
+ id = ((msg.Buffer[2]&0xFF)<<8)|(msg.Buffer[3]&0xFF);
+ timestamp = ((msg.Buffer[4]&0xFF)<<8)|(msg.Buffer[5]&0xFF);
+ number = msg.Buffer[6]&0xFF;
+ length = msg.Buffer[7]&0xFF;
+
+ /* filter */
+ //if((id&0xFF00)==0x1900 && id != 0x1980)
+ // return GE_NONE;
+ //printf("%02x\n",msg.Buffer[10]);
+ //if(msg.Buffer[10]!=0x40)
+ // return GE_NONE;
+ /* Query trace type name */
+ desc = "Unknown";
+ if(traces != NULL) {
+ minor = wmx_tracestruct_queryminor(traces, id);
+ if(minor != NULL) desc = minor->desc;
+ }
+ printf("<%04X> %s\n", id, desc);
+ printf("t=%04x nr=%02x: ", timestamp, number);
+
+ /* TODO -- decode debug types on phone type */
+ switch(id>>8) {
+ case 0x33:
+ case 0x34:
+ case 0x35:
+ case 0x37:
+ case 0x38:
+ case 0x39:
+ case 0x3A:
+ case 0x3B:
+ case 0x3C:
+ case 0x5F:
+ /* text */
+ /* skip length byte */
+ printf("\"");
+ for(x=8; x<msg.Length; x++) {
+ printf("%c",msg.Buffer[x]&0xFF);
+ }
+ printf("\"");
+ break;
+ /*
+ case 0x6801:
+ for(x=8; x<msg.Length; x++) {
+ printf("%02x%c ",msg.Buffer[x]&0xFF,msg.Buffer[x]&0xFF);
+ }
+ break;
+ */
+ case 0x18: /* MDISND */
+
+ /* skip these:
+ +00 length
+ +01 type (also xx in 0x18xx)
+ */
+ if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) {
+ printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]);
+ } else {
+ //printf("D %02X: ", id&0xFF);
+ printf("D %02X: ", id&0xFF);
+ mdisnd_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10);
+ }
+ break;
+ case 0x19: /* MDIRCV */
+ if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) {
+ printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]);
+ } else {
+ printf("D %02X: ", id&0xFF);
+ mdircv_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10);
+ //dumpraw((unsigned char*)&msg.Buffer[10], msg.Length-10);
+ }
+ break;
+ case 0x20: /* 0x25 SIM commands */
+ /*
+ for(x=8;x<msg.Length;x++)
+ printf("%02x ", msg.Buffer[x]&0xFF);
+ */
+ printf("SIM command ");
+ if(msg.Buffer[8]==0xa0) { // check if valid (class=a0)
+ simCommand_data(msg.Buffer[9], (unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10);
+ // TODO: pass the msg.Buffer[9] and skip 1rst arg
+ } else {
+ printf("Unknown 0x25 packet (NOT SIM cmd): ");
+ for(x=8;x<msg.Length;x++) printf("%02x ", msg.Buffer[x]&0xFF);
+ printf("\n");
+ }
+ break;
+ case 0x22: /* 0x27 SIM answer to command (error/ok/etc..) */
+ if(msg.Length<10) {
+ // Unknown response
+ for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF);
+ printf(" (Unknown 0x27 packet ? ? )\n");
+ } else {
+ simAnswer_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length);
+ }
+ break;
+ case 0x23: /* 0x28 SIM response data to commands */
+ if(msg.Length<10) {
+ // Unknown response
+ for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF);
+ printf(" (Unknown 0x28 packet)\n");
+ } else {
+ simResponse_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length);
+ }
+ break;
+ default:
+ /* hex */
+ for(x=8; x<msg.Length; x++) {
+ printf("%02x ",msg.Buffer[x]&0xFF);
+ }
+ break;
+ }
+ printf("\n");
+ return ERR_NONE;
+}
+
+
+static GSM_Error DCT3_ReplyMyPacket(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int x;
+
+ printf("MyPacket ");
+ for(x=0; x<msg.Length; x++) {
+ printf("%02x ",msg.Buffer[x]&0xFF);
+ }
+ printf("\n");
+ return ERR_NONE;
+}
+
+#define ID_DebugTrace 0x666
+#define ID_DebugSwitch 0x667
+#define ID_RPC 0x668
+
+void DCT3SetDebug(int argc, char *argv[])
+{
+ int x,count;
+ unsigned int y;
+ unsigned char reqDisable[] = {0x01, 0x01, 0x71};
+// unsigned char reqTest[] = {0x01, 0x01, 0x96, 0xFF, 0xFF};
+
+ /* RPC testing packets: */
+
+ /* RPC: Get version */
+ //unsigned char reqTest2[] = {0x01, 0x01, 0x00, 0x03, 0x00};
+ /* RPC: read I/O 0x6D mask 0xFF */
+ //unsigned char reqTest2[] = {0x01, 0x01, 0x02, 0x01, 0x02, 0x6D, 0xFF}; /* */
+ /* RPC: write I/O 0x03 mask 0xFF value 0x31 */
+ //unsigned char reqTest2[] = {0x01, 0x01, 0x01, 0x01, 0x07, 0x03, 0xFF, 0x31}; /* write I/O */
+
+ /* RPC: write forged FBUS packet to MDISND */
+// unsigned char reqTest2[] = {0x01, 0x01, 0x16, 0x01, 0x06,
+// 0x14, // R0 -- length
+// 0x05, // R1 -- MDI type identifier 0x05(FBUS)
+// 0x1e, 0x0c, 0x00, 0x66,
+// 0x00, 0x0e, 0x01, 0x01,
+// 0x66, 0x55, 0x44, 0x33,
+// 0x0d, 0x01, 0x01, 0x01,
+// 0x1b, 0x58, 0x01, 0x44};
+// 1805 t=cb37 nr=e2 :D 05:
+
+ /* debug enable packet */
+ unsigned char reqEnable[] = {
+ 0x00, 0x01, 0x70,
+ /* Debug bits
+ byte[bit>>3]&(1<<(7-(bit&7)))
+ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */
+ /* Debug verbose bits
+ byte[bit>>3]&(1<<(7-(bit&7)))
+ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+
+ #define ENABLE_BIT(bit,verbose) reqEnable[3 + (bit>>3)] |= 1<<(7-(bit&7)); if(verbose){reqEnable[3 + 32 + (bit>>3)] |= 1<<(7-(bit&7));}
+
+ /* Enable some bit
+ TODO command line or GUI interface
+ */
+ //ENABLE_BIT(0x18, 1); /* Enable MDISND debugging */
+ //ENABLE_BIT(0x19, 1); /* Enable MDIRCV debugging */
+ //ENABLE_BIT(0x31, 1);
+
+ gsmdec = GSMDecoder_new();
+ /* Open XML file .. needs to be argument */
+ {
+ FILE *xout = fopen("out.xml", "w");
+ GSMDecoder_xmlout(gsmdec, xout);
+ }
+ printf("Debug Trace Mode -- wumpus 2003\n");
+ traces = wmx_tracestruct_load(argv[2]);
+ if(traces == NULL)
+ printf("Warning: could not load trace description file %s\n", argv[2]);
+ printf("Activating ranges:\n");
+ count = 0;
+ for(x=3; x<argc; x++) {
+ char *ptr = argv[x];
+ unsigned from,to,verbose;
+
+ while(*ptr) {
+ verbose = 0;
+ if(*ptr == 'v') {
+ verbose = 1;
+ ptr++;
+ }
+ to = from = strtol(ptr, &ptr, 16);
+ if(*ptr == '-') {
+ ptr ++;
+ to = strtol(ptr, &ptr, 16);
+ }
+ if(*ptr != ',' && *ptr != 0) {
+ printf("Invalid parameter '%s'\n", argv[x]);
+ return;
+ }
+ if(*ptr == ',')
+ ptr++;
+ if(from > 0xFF) from=0xFF;
+ if(to > 0xFF) to=0xFF;
+ printf(" %02x-%02x verbose=%i\n",from,to,verbose);
+ for(y=from; y<=to; y++) {
+ ENABLE_BIT(y, verbose);
+ count++;
+ }
+ }
+ }
+ if(count == 0) {
+ printf("Nothing activated -- bailing out\n");
+ return;
+ }
+ //ENABLE_BIT(0x20, 1); /* SIM commands (literal) */
+ //ENABLE_BIT(0x21, 1); /* SIML2 commands (literal) */
+ //ENABLE_BIT(0x22, 1); /* SIM commands (literal) */
+ //ENABLE_BIT(0x3B, 1); /* PHCTRL state */
+
+ GSM_Init(true);
+
+ /* We Need DCT3 */
+ if (CheckDCT3Only()!=ERR_NONE) return;
+
+ error=DCT3_EnableSecurity (&s, 0x01);
+ Print_Error(error);
+
+ s.User.UserReplyFunctions=UserReplyFunctionsX;
+
+ //error=GSM_WaitFor (&s, reqTest, sizeof(reqTest), 0x40, 1, ID_DebugSwitch);
+
+ //error=GSM_WaitFor (&s, reqTest2, sizeof(reqTest2), 0xD1, 4, ID_RPC);
+
+ /* Enable Debug Mode */
+ error=GSM_WaitFor (&s, reqEnable, sizeof(reqEnable), 0x40, 4, ID_DebugSwitch);
+
+ Print_Error(error);
+ signal(SIGINT, interrupt);
+ printf("Press Ctrl+C to interrupt...\n");
+ x=0;
+
+ /*
+ while(x<100) {
+ //printf(": %02x\n",x);
+ s.Phone.Data.RequestID = ID_DebugTrace;
+ res = s.Device.Functions->ReadDevice(&s, buff, 255);
+ if(res) {
+ printf("%02x\n",x);
+ for(y=0;y<res;y++) {
+ //printf("%02x\n",x,buff[y]&0xFF);
+ s.Protocol.Functions->StateMachine(&s,buff[y]);
+ x++;
+ }
+ }
+ }
+ */
+ ;
+
+ /* todo: wait and dump for some time */
+ while (!gshutdown) {
+ GSM_ReadDevice(&s,true);
+ my_sleep(10);
+ }
+ signal(SIGINT, SIG_DFL);
+ printf("Disabling\n");
+ error=GSM_WaitFor (&s, reqDisable, sizeof(reqDisable), 0x40, 10, ID_DebugSwitch);
+ Print_Error(error);
+
+ GSMDecoder_free(gsmdec);
+}
+
+static GSM_Reply_Function UserReplyFunctionsX[] = {
+ {DCT3_ReplySwitchDebug, "\x40",0x02,0x70,ID_DebugSwitch },
+ {DCT3_ReplySwitchDebug, "\x40",0x02,0x71,ID_DebugSwitch },
+ {DCT3_ReplyDebugTrace, "\x00",0x00,0x00,ID_IncomingFrame },
+ {DCT3_ReplyMyPacket, "\x40",0x00,0x00,ID_IncomingFrame },
+
+ {DCT3_ReplyRPC, "\xD2",0x00,0x00,ID_RPC },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx.h b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.h
new file mode 100644
index 0000000..76fb394
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.h
@@ -0,0 +1,5 @@
+void DCT3SetDebug (int argc, char *argv[]);
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct4.c b/gammu/emb/gammu/depend/nokia/dct4.c
new file mode 100644
index 0000000..f4ed305
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct4.c
@@ -0,0 +1,1341 @@
+/* (c) 2002-2004 by Marcin Wiacek */
+
+#include "../../../common/gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA_DCT4
+
+#include <string.h>
+
+#include "dct4.h"
+#include "../../gammu.h"
+#include "../../../common/phone/pfunc.h"
+#include "../../../common/phone/nokia/nfunc.h"
+#include "../../../common/phone/nokia/dct4/dct4func.h"
+#include "../../../common/misc/coding/coding.h"
+
+extern GSM_Reply_Function UserReplyFunctions4[];
+
+/* ------- some usefull functions ----------------------------------------- */
+
+GSM_Error CheckDCT4Only()
+{
+ bool found = false;
+
+ /* Checking if phone is DCT4 */
+#ifdef GSM_ENABLE_NOKIA3650
+ if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+#ifdef GSM_ENABLE_NOKIA6510
+ if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+#ifdef GSM_ENABLE_NOKIA3320
+ if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
+#endif
+ if (!found) return ERR_NOTSUPPORTED;
+
+ if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 &&
+ s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE &&
+ s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET) {
+ return ERR_OTHERCONNECTIONREQUIRED;
+ }
+ return ERR_NONE;
+}
+
+static void CheckDCT4()
+{
+ GSM_Error error;
+
+ error = CheckDCT4Only();
+ switch (error) {
+ case ERR_NOTSUPPORTED:
+ Print_Error(ERR_NOTSUPPORTED);
+ break;
+ case ERR_OTHERCONNECTIONREQUIRED:
+ printf("Can't do it with current phone protocol\n");
+ GSM_TerminateConnection(&s);
+ exit(-1);
+ default:
+ break;
+ }
+}
+
+static bool answer_yes2(char *text)
+{
+ int len;
+ char ans[99];
+
+ while (1) {
+ printf("%s (yes/no) ? ",text);
+ len=GetLine(stdin, ans, 99);
+ if (len==-1) exit(-1);
+ if (mystrncasecmp(ans, "yes",0)) return true;
+ if (mystrncasecmp(ans, "no" ,0)) return false;
+ }
+}
+
+/* ------------------- functions ------------------------------------------- */
+
+static DCT4_Feature DCT4Features[] = {
+ {DCT4_ALWAYS_ONLINE, "GPRS Always Online", {{0,"on (Context)"},{1,"off (Attach)"},{0,""}}},///??
+ {DCT4_GPRS_PCCH, "PCCH support for GPRS", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_GEA1, "GEA1 support indication", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_EOTD, "EOTD support", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_WAP_PUSH, "WAP push", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_USE_PREF_SIM_NET, "Use SIM preffered network list",{{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_JAVA_TCK, "Java TCK support", {{1,"on"},{0,"off"},{0,""}}},
+
+ {DCT4_ALS, "Alternate Line Service (ALS)", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_A52, "Ciphering alghoritm A52", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_CSP, "Customer Service Profile", {{0,"off"},{1,"on"},{0,""}}},
+ {DCT4_EONS, "EONS support", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_3GINDICATOR, "3G indicator", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_DISPLAY_PHONE_NAME, "Display both number and name for incoming calls",{{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_DISPLAY_WAP_PROFILE, "Display selected WAP profile name instead of Home option menu in Services",{{1,"on"},{0,"off"},{0,""}}},
+
+ {DCT4_GAMES_WAP_DOWNLOAD, "Games WAP download", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_GAMES_SCORE_SEND, "Games WAP score send", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_GAMES_URL_CHECK, "Games URL check", {{1,"on"},{0,"off"},{0,""}}},
+
+ {DCT4_BLUETOOTH_MENU, "Bluetooth menu", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_WAP_BOOKMARKS_MENU, "Bookmarks menu in Services", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_WAP_BOOKMARKS_MENU2, "Bookmarks menu in Services", {{3,"bookmarks & download"},{0,"off"},{0,""}}},
+ {DCT4_WAP_GOTO_MENU, "GoTo menu in Services", {{0,"on"},{1,"off"},{0,""}}},
+ {DCT4_WAP_SETTINGS_MENU, "Profiles menu in Services", {{0,"on"},{1,"off"},{0,""}}},
+ {DCT4_SERVICES_GAMES_APP_GALLERY,"Services menu in Games/Apps/Gallery",{{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_JAVA_GAMES_MENU, "Java games menu in Games", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_SAT_CONFIRM_MENU, "Can use confirming SIM service actions", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_INSTANT_MESS_MENU, "Instant Messaging in Messages",{{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_CONFIRM_ALS, "Confirm using ALS", {{1,"on"},{0,"off"},{0,""}}},
+ {DCT4_BOOKMARK_GOTO_MENU, "Bookmarks in GoTo menu", {{1,"on"},{0,"off"},{0,""}}},
+
+ {DCT4_5100_IDENTIFY, "Phone identification", {{1,"NPM-6U"},{0,"NPM-6"},{0,""}}},
+
+#ifdef DEBUG
+ {DCT4_TEST,"",{{1,"1"},{0,"0"}}},
+#endif
+
+ {0, "", {{0,""}}}
+};
+
+static DCT4_Phone_Features DCT4PhoneFeatures[] = {
+/*3100*/ {"RH-19", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {DCT4_EONS,28},{DCT4_3GINDICATOR,30},{DCT4_INSTANT_MESS_MENU,33},
+ {DCT4_CONFIRM_ALS,35},
+ {0,0}}},
+/*3200*/ {"RH-30", {{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14},
+ {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20},
+ {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23},
+ {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28},
+ {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33},
+ {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45},
+ {0,0}}},
+/*3200*/ {"RH-31", {{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14},
+ {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20},
+ {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23},
+ {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28},
+ {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33},
+ {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45},
+ {0,0}}},
+/*3300*/ {"NEM-1", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ /*MORE*/ {0,0}}},
+/*3510*/ {"NHM-8", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},
+ {DCT4_GAMES_WAP_DOWNLOAD,7},{DCT4_GAMES_SCORE_SEND,8},
+ {DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13},
+ {DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}},
+/*3510i*/{"RH-9", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,9},
+ {DCT4_DISPLAY_PHONE_NAME,14},{DCT4_WAP_GOTO_MENU,15},
+ {DCT4_WAP_SETTINGS_MENU,16},{DCT4_SERVICES_GAMES_APP_GALLERY,19},
+ {DCT4_DISPLAY_WAP_PROFILE,25},{0,0}}},
+/*3650*/ {"NHL-8", {{DCT4_ALS,1},{0,0}}},
+/*5100*/ {"NPM-6", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {DCT4_EONS,28},
+ // {DCT4_5100_IDENTIFY,10},
+ {0,0}}},
+/*5100*/ {"NPM-6U", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {DCT4_EONS,28},
+ // {DCT4_5100_IDENTIFY,10},
+ {0,0}}},
+/*6100*/ {"NPL-2", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {0,0}}},
+/*6220*/ {"RH-20", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},
+ {DCT4_GEA1,14},{DCT4_EOTD,17},{DCT4_WAP_SETTINGS_MENU,19},
+ {DCT4_DISPLAY_PHONE_NAME,20},{DCT4_WAP_GOTO_MENU,22},
+ {DCT4_WAP_BOOKMARKS_MENU2,24},{DCT4_SERVICES_GAMES_APP_GALLERY,25},
+ {DCT4_3GINDICATOR,27},{DCT4_DISPLAY_WAP_PROFILE,30},{DCT4_SAT_CONFIRM_MENU,32},
+ {DCT4_CONFIRM_ALS,33},{DCT4_JAVA_TCK,36},{DCT4_BOOKMARK_GOTO_MENU,37},
+ {0,0}}},
+/*6310*/ {"NPE-4", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7},
+ {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_BLUETOOTH_MENU,10},
+ {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}},
+/*6310i*/{"NPL-1", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7},
+ {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},
+ {DCT4_BLUETOOTH_MENU,10},{DCT4_USE_PREF_SIM_NET,11},
+ {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_EOTD,16},
+ {DCT4_ALWAYS_ONLINE,17},{DCT4_JAVA_GAMES_MENU,18},
+ {DCT4_WAP_BOOKMARKS_MENU,20},{DCT4_WAP_SETTINGS_MENU,21},
+ {DCT4_WAP_PUSH,28},{DCT4_WAP_GOTO_MENU,29},{0,0}}},
+/*6510*/ {"NPM-9", {{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7},
+ {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},
+ {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}},
+/*6610*/ {"NHL-4U", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {0,0}}},
+/*6800*/ {"NHL-6", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ /*MORE*/ {0,0}}},
+/*7210*/ {"NHL-4", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {0,0}}},
+/*7250*/ {"NHL-4J", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ {0,0}}},
+/*7250i*/{"NHL-4JX", {{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8},
+ {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12},
+ {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18},
+ {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22},
+ {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27},
+ /*MORE*/ {0,0}}},
+/*8310*/{"NHM-7", {{DCT4_ALS,1},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7},
+ {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13},
+ {DCT4_ALWAYS_ONLINE,18},{0,0}}},
+ {"", {{0,0}}}
+};
+
+static GSM_Error DCT4_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("Setting done OK\n");
+ return ERR_NONE;
+}
+
+void DCT4SetPhoneMenus(int argc, char *argv[])
+{
+ int current = 10,i=0,j,z;
+ unsigned char reqSet[200] = {
+ N7110_FRAME_HEADER,0x04,0x00,0x01,0x47,0x48,0x02,
+ 0x00}; /* Number of changed features */
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ while (DCT4PhoneFeatures[i].Model[0] != 0x00) {
+ if (!strcmp(DCT4PhoneFeatures[i].Model,s.Phone.Data.Model)) {
+ j = 0;
+ while (DCT4PhoneFeatures[i].Features[j].Name != 0x00) {
+ z = 0;
+ while (DCT4Features[z].Name != 0x00) {
+ if (DCT4Features[z].Name == DCT4PhoneFeatures[i].Features[j].Name) {
+ printf("%s : %s\n",DCT4Features[z].Text,DCT4Features[z].Values[0].Text);
+ reqSet[9]++; /* Number of features */
+ reqSet[current++] = DCT4PhoneFeatures[i].Features[j].Number; /* Feature number */
+ reqSet[current++] = DCT4Features[z].Values[0].Value; /* Value */
+ break;
+ }
+ z++;
+ }
+ j++;
+ }
+ }
+ i++;
+ }
+
+ if (current == 10) {
+ printf("Sorry, but configuration matrix for this model is not added yet. Please report\n");
+ return;
+ }
+
+ reqSet[current++] = 0x00;
+ reqSet[current++] = 0x00;
+
+ error=GSM_WaitFor (&s, reqSet, current, 0x1b, 4, ID_User1);
+ Print_Error(error);
+}
+
+DCT4_Phone_Tests DCT4Tests;
+
+static GSM_Error DCT4_ReplyTestsNames(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i,pos;
+
+ DCT4Tests.Num = msg.Buffer[5];
+ pos = 6;
+
+ smprintf(s,"%i names for phone tests received\n",msg.Buffer[5]);
+ for (i=0;i<msg.Buffer[5];i++) {
+ strcpy(DCT4Tests.Tests[i].Name,msg.Buffer+pos+4);
+ DCT4Tests.Tests[i].ID = msg.Buffer[pos+2];
+ smprintf(s,"%x.\"%s\"\n",DCT4Tests.Tests[i].ID,DCT4Tests.Tests[i].Name);
+ pos+=msg.Buffer[pos+1];
+ }
+
+ return ERR_NONE;
+}
+
+static GSM_Error DCT4_ReplyTestsStartup(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i,pos,j;
+ bool found;
+
+ pos = 10;
+
+ for (i=0;i<msg.Buffer[8];i++) {
+ found = false;
+ for (j=0;j<DCT4Tests.Num;j++) {
+ if (DCT4Tests.Tests[j].ID == msg.Buffer[pos]) {
+ DCT4Tests.Tests[j].Startup = true;
+ found = true;
+ break;
+ }
+ }
+ if (!found) printf("%x ",msg.Buffer[pos]);
+ pos++;
+ }
+
+ return ERR_NONE;
+}
+
+static GSM_Error DCT4_ReplyTestsStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i,pos,j;
+
+ pos = 6;
+
+ smprintf(s,"%i status entries for phone tests received\n",msg.Buffer[5]);
+ for (i=0;i<msg.Buffer[5];i++) {
+ for (j=0;j<DCT4Tests.Num;j++) {
+ if (DCT4Tests.Tests[j].ID == msg.Buffer[pos+2]) {
+ printf("\"%40s\" : ",DCT4Tests.Tests[j].Name);
+ switch(msg.Buffer[pos+3]) {
+ case 0x00: printf("Passed"); break;
+ case 0x01: printf("Fail"); break;
+ case 0x03: printf("Not executed"); break;
+ case 0x06: printf("No signal"); break;
+ case 0x0D: printf("Timeout"); break;
+ default : printf("Unknown (%x)",msg.Buffer[pos+3]);
+ }
+ if (DCT4Tests.Tests[j].Startup) printf(" (startup)");
+ printf("\n");
+ break;
+ }
+ }
+ pos+=msg.Buffer[pos+1];
+ }
+
+ return ERR_NONE;
+}
+
+void DCT4SelfTests(int argc, char *argv[])
+{
+ int j;
+ unsigned char GetDoneST[6] = {0x00, 0x08, 0x01, 0x04, 0x01, 0x00};
+ unsigned char GetDoneST2[6] = {0x00, 0x08, 0x02, 0x04, 0x02, 0x00};
+ unsigned char GetNames[6] = {0x00, 0x08, 0x03, 0x06, 0x03, 0x00};
+ unsigned char GetStatus[6] = {0x00, 0x08, 0x04, 0x02, 0x03, 0x00};
+
+ unsigned char RunALL[6] = {0x00, 0x06, 0x04, 0x00, 0x03, 0x00};
+
+// unsigned char GetID[6] = {0x00, 0x08, 0x00, 0x04, 0x03, 0x00};//tests ID
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ if (answer_yes2("Run all tests now ?")) {
+ error=GSM_WaitFor (&s, RunALL, 6, 0x35, 4, ID_User1);
+ Print_Error(error);
+ }
+
+ error=GSM_WaitFor (&s, GetNames, 6, 0x35, 4, ID_User1);
+ Print_Error(error);
+
+ for (j=0;j<DCT4Tests.Num;j++) DCT4Tests.Tests[j].Startup = false;
+
+ error=GSM_WaitFor (&s, GetDoneST, 6, 0x35, 4, ID_User3);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, GetDoneST2, 6, 0x35, 4, ID_User3);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, GetStatus, 6, 0x35, 4, ID_User2);
+ Print_Error(error);
+}
+
+static GSM_Error DCT4_ReplyVibra(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+#ifdef DEBUG
+ switch (msg.Buffer[3]) {
+ case 0x0D : dbgprintf("Vibra state set OK\n"); break;
+ case 0x0F : dbgprintf("Vibra power set OK\n"); break;
+ }
+#endif
+ return ERR_NONE;
+}
+
+static GSM_Error DCT4EnableVibra(GSM_StateMachine *s, bool enable)
+{
+ /* Enables or disables vibra */
+ unsigned char Control[6] = {N7110_FRAME_HEADER,0x0C,
+ 0x01, /* 0x01 = On, 0x00 = Off */
+ 0x00};
+
+ if (!enable) Control[4] = 0x00;
+ return GSM_WaitFor (s, Control, 6, 0x1C, 4, ID_User3);
+}
+
+void DCT4SetVibraLevel(int argc, char *argv[])
+{
+ GSM_DateTime Date;
+ unsigned int i,j;
+
+ /* Set vibra level */
+ unsigned char SetLevel[6] = {N7110_FRAME_HEADER,0x0E,
+ 0x64, /* Vibra power (in percent) */
+ 0x00};
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ SetLevel[4] = atoi(argv[2]);
+ error=GSM_WaitFor (&s, SetLevel, 6, 0x1C, 4, ID_User3);
+ Print_Error(error);
+
+ error=DCT4EnableVibra(&s, true);
+ Print_Error(error);
+
+ for (i=0;i<3;i++) {
+ GSM_GetCurrentDateTime (&Date);
+ j=Date.Second;
+ while (j==Date.Second) {
+ my_sleep(10);
+ GSM_GetCurrentDateTime(&Date);
+ }
+ }
+
+ error=DCT4EnableVibra(&s, false);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+void DCT4VibraTest(int argc, char *argv[])
+{
+ unsigned char ans[200];
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ error=DCT4EnableVibra(&s, true);
+ Print_Error(error);
+
+ printf("Press any key to continue...\n");
+ GetLine(stdin, ans, 99);
+
+ error=DCT4EnableVibra(&s, false);
+ Print_Error(error);
+}
+
+#ifdef DEBUG
+static GSM_Error DCT4_ReplyResetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x05:
+ printf("Security code set to \"12345\"\n");
+ return ERR_NONE;
+ case 0x06:
+ printf("Unknown reason. Can't reset your security code\n");
+ return ERR_UNKNOWN;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT4ResetSecurityCode(int argc, char *argv[])
+{
+ unsigned int i;
+ unsigned char ResetCode[30] = {0x00,0x06,0x03,0x04,0x01,
+ '1','2','3','4','5','6','7','8','9','0', /* Old code */
+ 0x00,
+ '1','2','3','4','5',0x00,0x00,0x00,0x00,0x00, /* New code */
+ 0x00};
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2);
+ if (error == ERR_UNKNOWN) {
+ if (answer_yes2("Try brutal force ?")) {
+ for (i=10000;i<9999999;i++) {
+ printf("Trying %i\n",i);
+ memset(ResetCode+6,0,22);
+ sprintf(ResetCode+5,"%i",i);
+ sprintf(ResetCode+16,"12345");
+ error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2);
+ if (error == ERR_NONE) break;
+ }
+ }
+ } else Print_Error(error);
+}
+#endif
+
+char SecLength;
+
+static GSM_Error DCT4_ReplyGetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ if (msg.Length > 12) {
+ SecLength = msg.Buffer[13];
+ if ((msg.Buffer[17]+18) == msg.Length) {
+ printf("Security code is %s\n",msg.Buffer+18);
+// DumpMessage(stdout, msg.Buffer, msg.Length);
+ }
+ }
+ return ERR_NONE;
+}
+
+void DCT4GetSecurityCode(int argc, char *argv[])
+{
+ GSM_Error error;
+ unsigned char getlen[]={0x00, 0x08, 0x01, 0x0C,
+ 0x00, 0x23, //ID
+ 0x00, 0x00, //Index
+ 0x00, 0x00};
+ unsigned char read[]={0x00, 0x08, 0x02, 0x04,
+ 0x00, 0x23, //ID
+ 0x00, 0x00, //Index
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00}; //Length
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ SecLength = 0;
+ error=GSM_WaitFor (&s, getlen, sizeof(getlen), 0x23, 1, ID_User1);
+ Print_Error(error);
+ if (SecLength != 0) {
+ read[17] = SecLength;
+ error=GSM_WaitFor (&s, read, sizeof(read), 0x23, 5, ID_User1);
+ Print_Error(error);
+ }
+}
+
+static GSM_Error DCT4_ReplyGetVoiceRecord(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i=18,j;
+ unsigned char Buffer[100];
+
+ switch (msg.Buffer[3]) {
+ case 0x05:
+ dbgprintf("Part of voice record received\n");
+ if (msg.Length == 6) {
+ dbgprintf("Empty\n");
+ return ERR_EMPTY;
+ }
+ *s->Phone.Data.VoiceRecord = 0;
+ while (i<msg.Length) {
+ s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i+1];
+ s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i];
+ i += 2;
+ }
+ return ERR_NONE;
+ case 0x0D:
+ dbgprintf("Last part of voice record is %02x %02x\n",msg.Buffer[11],msg.Buffer[12]);
+ dbgprintf("Token is %02x\n",msg.Buffer[13]);
+ s->Phone.Data.PhoneString[0] = msg.Buffer[11];
+ s->Phone.Data.PhoneString[1] = msg.Buffer[12];
+ s->Phone.Data.PhoneString[2] = msg.Buffer[13];
+ return ERR_NONE;
+ break;
+ case 0x31:
+ dbgprintf("Names of voice records received\n");
+ j = 33;
+ for (i=0;i<msg.Buffer[9];i++) {
+ memcpy(Buffer,msg.Buffer+(j+1),msg.Buffer[j]);
+ Buffer[msg.Buffer[j]] = 0;
+ Buffer[msg.Buffer[j]+1] = 0;
+ dbgprintf("%i. \"%s\"\n",i+1,DecodeUnicodeString(Buffer));
+ if (i==*s->Phone.Data.VoiceRecord) {
+ sprintf(s->Phone.Data.PhoneString,"%s.wav",DecodeUnicodeString(Buffer));
+ return ERR_NONE;
+ }
+ if (i != msg.Buffer[9] - 1) {
+ j+=msg.Buffer[j] + 1;
+ if (msg.Buffer[j] == 0x00 && msg.Buffer[j+1]==0x00) j+=2;
+ j+=23;
+ }
+ }
+ return ERR_EMPTY;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT4GetVoiceRecord(int argc, char *argv[])
+{
+ /* Voice records names */
+ unsigned char ReqNames[200] = {
+ N7110_FRAME_HEADER,
+ 0x30,0x01,0x55,0x00,0x00,0xFF,0xFF,0x01,0x01,0x55,0x55};
+ /* Voice record token */
+ unsigned char ReqToken[200] = {
+ N7110_FRAME_HEADER,0x0C,0x00,0x44,0x00,
+ 0x00, /* Location: 0, 1, ... */
+ 0x55,0x55};
+ /* Voice record part */
+ unsigned char ReqGet[200] = {
+ N7110_FRAME_HEADER,0x04,0x00,0x44,
+ 0x00,0x00, /* Location: 0, 1, ... */
+ 0x55,0x55,0x00,
+
+ 0x00,0x00, /* Part Location */
+ 0x00,0x00,0x00,
+
+ 0x04, /* ??? */
+
+ 0x00}; /* Token */
+
+ /* WAV file headers */
+ unsigned char WAV_Header[] = {
+ 'R','I','F','F',
+ 0x00,0x00,0x00,0x00, /* Length */
+ 'W','A','V','E'};
+ unsigned char FMT_Header[] = {'f','m','t',' ',
+ 0x14,0x00,0x00,0x00,0x31,0x00,0x01,0x00,0x40,0x1f,
+ 0x00,0x00,0x59,0x06,0x00,0x00,0x41,0x00,0x00,0x00,
+ 0x02,0x00,0x40,0x01,'f', 'a', 'c', 't', 0x04,0x00,
+ 0x00,0x00,
+ 0x00,0x73,0x00,0x00}; /* Seems to be some length */
+ unsigned char DATA_Header[] = {
+ 'd','a','t','a',
+ 0x00,0x00,0x00,0x00}; /* Length */
+
+ long wavfilesize=0;
+ unsigned char FileName[100], Buffer[10000], Token;
+ unsigned int Location, size=0, CurrentLocation = 0, TokenLocation;
+ int i;
+ FILE *WAVFile;
+
+ Location = atoi(argv[2]);
+ if (Location == 0x00) {
+ printf("Please numerate locations from 1\n");
+ return;
+ }
+ Location--;
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ s.Phone.Data.VoiceRecord = &Location;
+ s.Phone.Data.PhoneString = FileName;
+ dbgprintf("Getting voice record name\n");
+ error=GSM_WaitFor (&s, ReqNames, 14, 0x4A, 4, ID_User4);
+ Print_Error(error);
+
+ s.Phone.Data.PhoneString = Buffer;
+ ReqToken[7] = Location;
+ dbgprintf("Getting voice record token\n");
+ error=GSM_WaitFor (&s, ReqToken, 10, 0x23, 4, ID_User4);
+ Print_Error(error);
+ TokenLocation = Buffer[0] * 256 + Buffer[1];
+ Token = Buffer[2];
+
+ WAVFile = fopen(FileName, "wb");
+
+ fwrite(&WAV_Header, 1, sizeof(WAV_Header), WAVFile);
+ fwrite(&FMT_Header, 1, sizeof(FMT_Header), WAVFile);
+ fwrite(&DATA_Header, 1, sizeof(DATA_Header), WAVFile);
+
+ s.Phone.Data.VoiceRecord = &size;
+ s.Phone.Data.PhoneString = Buffer;
+ ReqGet[7] = Location;
+ fprintf(stderr,"Getting voice record and saving to \"%s\": ",FileName);
+ while (1) {
+ dbgprintf("Getting next part of voice record\n");
+ fprintf(stderr,".");
+ error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4);
+ if (error == ERR_NONE) {
+ wavfilesize += size;
+ fwrite(Buffer,1,size,WAVFile);
+ }
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ CurrentLocation += 4;
+ ReqGet[11] = CurrentLocation / 256;
+ ReqGet[12] = CurrentLocation % 256;
+ if (CurrentLocation+4 > TokenLocation) break;
+ }
+ dbgprintf("Getting first part in last sequence of voice record\n");
+ for (i=255;i>=0;i--) {
+ ReqGet[16] = i;
+ ReqGet[17] = Token;
+ fprintf(stderr,".");
+ error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4);
+ if (error == ERR_NONE) {
+ wavfilesize += size;
+ fwrite(Buffer,1,size,WAVFile);
+ break;
+ }
+ if (error != ERR_EMPTY) Print_Error(error);
+ }
+ while (1) {
+ dbgprintf("Getting next part of last sequence in voice record\n");
+ CurrentLocation += 4;
+ ReqGet[11] = CurrentLocation / 256;
+ ReqGet[12] = CurrentLocation % 256;
+ fprintf(stderr,".");
+ error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4);
+ if (error == ERR_NONE) {
+ wavfilesize += size;
+ fwrite(Buffer,1,size,WAVFile);
+ }
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ }
+ fprintf(stderr,"\n");
+
+ wavfilesize += sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header);
+ WAV_Header[4] = (unsigned char)(wavfilesize % 256);
+ WAV_Header[5] = (unsigned char)(wavfilesize / 256);
+ WAV_Header[6] = (unsigned char)(wavfilesize / (256*256));
+ WAV_Header[7] = (unsigned char)(wavfilesize / (256*256*256));
+
+ /* FIXME */
+ FMT_Header[36] = (unsigned char)(((wavfilesize - 238) * 5 ) % 256);
+ FMT_Header[37] = (unsigned char)(((wavfilesize - 238) * 5 ) / 256);
+ FMT_Header[38] = (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256));
+ FMT_Header[39] = (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256*256));
+
+ wavfilesize = wavfilesize - 54 - 6;
+ DATA_Header[4] = (unsigned char)(wavfilesize % 256);
+ DATA_Header[5] = (unsigned char)(wavfilesize / 256);
+ DATA_Header[6] = (unsigned char)(wavfilesize / (256*256));
+ DATA_Header[7] = (unsigned char)(wavfilesize / (256*256*256));
+
+ fseek( WAVFile, 0, SEEK_SET);
+ fwrite(&WAV_Header, 1, sizeof(WAV_Header), WAVFile);
+ fwrite(&FMT_Header, 1, sizeof(FMT_Header), WAVFile);
+ fwrite(&DATA_Header, 1, sizeof(DATA_Header), WAVFile);
+
+ fclose(WAVFile);
+
+ GSM_Terminate();
+}
+
+static GSM_Error DCT4_ReplyGetBTInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ printf("device address %02x%02x%02x%02x%02x%02x\n",
+ msg.Buffer[9],msg.Buffer[10],msg.Buffer[11],
+ msg.Buffer[12],msg.Buffer[13],msg.Buffer[14]);
+ return ERR_NONE;
+}
+
+static GSM_Error DCT4_ReplyGetSimlock(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+
+ switch (msg.Buffer[3]) {
+ case 0x0D:
+ dbgprintf("Simlock info received\n");
+ dbgprintf("Config_Data: ");
+ for (i=14;i<22;i++) {
+ dbgprintf("%02x",msg.Buffer[i]);
+ }
+ dbgprintf("\n");
+ dbgprintf("Profile_Bits: ");
+ for (i=22;i<30;i++) {
+ dbgprintf("%02x",msg.Buffer[i]);
+ }
+ dbgprintf("\n");
+ return ERR_NONE;
+ case 0x13:
+ dbgprintf("Simlock info received\n");
+ if (msg.Buffer[58] == 0x05 && msg.Buffer[59] == 0x02) {
+ dbgprintf("SIM_PATH: ");
+ for (i=44;i<52;i++) {
+ dbgprintf("%02x",msg.Buffer[i]);
+ }
+ dbgprintf("\n");
+ printf("Simlock data : ");
+ for (i=60;i<63;i++) {
+ printf("%02x",msg.Buffer[i]);
+ }
+ printf("\n");
+ }
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT4Info(int argc, char *argv[])
+{
+ unsigned char GetBTAddress[8] = {N6110_FRAME_HEADER, 0x09, 0x19, 0x01, 0x03, 0x06};
+ unsigned char GetSimlock[5] = {N6110_FRAME_HEADER, 0x12, 0x0D};
+ unsigned char value[10];
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ if (IsPhoneFeatureAvailable(s.Phone.Data.ModelInfo, F_BLUETOOTH)) {
+ printf("Bluetooth : ");
+
+ error=GSM_WaitFor (&s, GetBTAddress, 8, 0xD7, 4, ID_User6);
+ Print_Error(error);
+ }
+
+ error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6);
+ Print_Error(error);
+ GetSimlock[4] = 0x0E;
+ error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6);
+ Print_Error(error);
+ GetSimlock[3] = 0x0C;
+ error=GSM_WaitFor (&s, GetSimlock, 4, 0x53, 4, ID_User6);
+ Print_Error(error);
+ error=NOKIA_GetPhoneString(&s,"\x00\x03\x02\x07\x00\x08",6,0x1b,value,ID_User6,10);
+ Print_Error(error);
+ printf("UEM : %s\n",value);
+}
+
+static FILE *T9File;
+int T9Size;
+int T9FullSize;
+
+static GSM_Error DCT4_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ T9FullSize = msg.Buffer[18] * 256 + msg.Buffer[19];
+ T9Size = msg.Length - 18;
+ fwrite(msg.Buffer+18,1,T9Size,T9File);
+ return ERR_NONE;
+}
+
+void DCT4GetT9(int argc, char *argv[])
+{
+ int i,T9Dictionary=0;
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x04, 0x00, 0x5B,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, /* Start position */
+ 0x00, 0x00,
+ 0x02, 0xBC}; /* How many bytes to read */
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ T9File = fopen("T9", "w");
+ if (T9File == NULL) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ i = 0;
+ while (1) {
+ req[12] = i / 256;
+ req[13] = i % 256;
+ if (i != 0) {
+ if (T9Dictionary - i < req[16]*256+req[17]) {
+ req[16] = (T9Dictionary - i) / 256;
+ req[17] = (T9Dictionary - i) % 256;
+ }
+ if (T9Dictionary - i == 0) break;
+ }
+ error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3);
+ Print_Error(error);
+ if (i==0) {
+ T9Dictionary = T9FullSize;
+ dbgprintf("T9 dictionary size is %i\n",T9Dictionary);
+ }
+ i+=T9Size;
+ }
+
+ fclose(T9File);
+}
+
+extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable);
+
+void DCT4SetLight(int argc, char *argv[])
+{
+ int i;
+ N6510_PHONE_LIGHTS type;
+ bool enable;
+
+ if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY;
+ } else if (mystrncasecmp(argv[2],"keypad",0)) { type = N6510_LIGHT_KEYPAD;
+ } else if (mystrncasecmp(argv[2],"torch",0)) { type = N6510_LIGHT_TORCH;
+ } else {
+ printf("What lights should I enable (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ if (mystrncasecmp(argv[3],"on",0)) { enable = true;
+ } else if (mystrncasecmp(argv[3],"off",0)) { enable = false;
+ } else {
+ printf("What should I do (\"%s\") ?\n",argv[3]);
+ exit(-1);
+ }
+
+ for (i=0;i<s.ConfigNum;i++) {
+ s.Config[i].StartInfo = "false";
+ }
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ error=N6510_SetLight(&s, type, enable);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+void DCT4DisplayTest(int argc, char *argv[])
+{
+ unsigned char ans[200];
+ unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00};
+ unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04,
+ 0x09, /* test number */
+ 0x00};
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ DCT4_SetPhoneMode(&s, DCT4_MODE_TEST);
+
+ s.Protocol.Functions->WriteMessage(&s, req0, 6, 0x40);
+
+ req[8] = atoi(argv[2]);
+ s.Protocol.Functions->WriteMessage(&s, req, 10, 0x40);
+
+ printf("Press any key to continue...\n");
+ GetLine(stdin, ans, 99);
+
+ DCT4_SetPhoneMode(&s, DCT4_MODE_NORMAL);
+}
+
+int ADC;
+
+static GSM_Error DCT4_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ if (msg.Buffer[6] == 0xff && msg.Buffer[7] == 0xff) return ERR_NONE;
+ switch (msg.Buffer[3]) {
+ case 0x10:
+ printf("raw ");
+ printf("%10i ",msg.Buffer[8]*256+msg.Buffer[9]);
+ break;
+ case 0x12:
+ printf("unit result ");
+ printf("%10i ",(msg.Buffer[8]*256+msg.Buffer[9])*ADC);
+ break;
+ }
+ return ERR_NONE;
+}
+
+struct DCT4ADCInfo {
+ char *name;
+ char *unit;
+ int x;
+};
+
+static struct DCT4ADCInfo DCT4ADC[] = {
+ {"Battery voltage, divided:", "mV", 1},
+ {"Battery voltage, scaled:", "mV", 1},
+ {"Charger voltage:", "mV", 1},
+ {"Charger current:", "mA", 1},
+ {"Battery size indicator:", "Ohms",100},
+ {"Battery temperature:", "K", 1},
+ {"Headset interconnection:", "mV", 1},
+ {"Hook interconnection:", "mV", 1},
+ {"Light sensor:", "mV", 1},
+ {"Power amplifier temperature:", "K", 1},
+ {"VCXO temperature:", "K", 1},
+ {"Resistive keyboard 1/headint2:", "mV", 1},
+ {"Resistive keyboard 1/auxdet:", "mV", 1},
+ {"Initial battery voltage:", "mV", 1},
+ {"Battery Current:", "mA", 1},
+ {"Battery Current Fast:", "mA", 1},
+
+ {"", "", 1}
+};
+
+void DCT4GetADC(int argc, char *argv[])
+{
+ int i = 0;
+ unsigned char GetRaw[] = {N6110_FRAME_HEADER, 0x0F,
+ 0x00, /* Test number */
+ 0x01};
+ unsigned char GetUnit[] = {N6110_FRAME_HEADER, 0x11,
+ 0x00, /* Test number */
+ 0x01};
+
+ if (CheckDCT4Only()!=ERR_NONE) return;
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ while (1) {
+ printf(" %30s ",DCT4ADC[i].name);
+ GetRaw[4] = i;
+ error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3);
+ Print_Error(error);
+ GetUnit[4] = i;
+ ADC = DCT4ADC[i].x;
+ error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3);
+ Print_Error(error);
+ printf("%s\n",DCT4ADC[i].unit);
+ i++;
+ if (DCT4ADC[i].name[0] == 0x00) break;
+ }
+}
+
+static double RadioFreq;
+static unsigned char RadioName[100];
+
+static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int length;
+ unsigned char name[100];
+
+ switch (msg.Buffer[3]) {
+ case 0x09:
+ N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16);
+
+ length = msg.Buffer[8];
+ memcpy(name,msg.Buffer+18,length*2);
+ name[length*2] = 0x00;
+ name[length*2+1] = 0x00;
+ CopyUnicodeString(RadioName,name);
+ smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName));
+ return ERR_NONE;
+ case 0x15:
+ case 0x16:
+ smprintf(s,"Response for enabling radio/headset status received\n");
+ if (msg.Buffer[5] == 0) {
+ smprintf(s,"Connected\n");
+ return ERR_NONE;
+ }
+ smprintf(s,"Probably not connected\n");
+ return ERR_PERMISSION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+void DCT4TuneRadio(int argc, char *argv[])
+{
+ double Freq, diff;
+ GSM_FMStation FMStation[50],FMStat;
+ int i, j, num;
+ bool found;
+
+ unsigned char Enable[] = {N6110_FRAME_HEADER, 0x00, 0x00, 0x00};
+ unsigned char Disable[] = {N6110_FRAME_HEADER, 0x01, 0x0E, 0x00};
+// unsigned char SetVolume[] = {N6110_FRAME_HEADER, 0x14,
+// 0x00, /* Volume level */
+// 0x00};
+// unsigned char MuteUnMute[] = {N6110_FRAME_HEADER, 0x0F,
+// 0x0C, /* 0x0B = mute, 0x0C = unmute */
+// 0x00};
+ unsigned char SetFreq[] = {N6110_FRAME_HEADER, 0x08,
+ 0x08, 0x14, 0x00, 0x01,
+ 0x9A, 0x28}; /* Frequency */
+// unsigned char Find1[] = {N6110_FRAME_HEADER, 0x08,
+// 0x04, 0x14, 0x00, 0x00, 0x00, 0x00};
+ unsigned char Find2[] = {N6110_FRAME_HEADER, 0x08,
+ 0x05, 0x14, 0x00, 0x00, 0x00, 0x00};
+// unsigned char SetStereo[] = {N6110_FRAME_HEADER, 0x19,
+// 0x0A, 0x00, 0x15};
+// unsigned char SetMono[] = {N6110_FRAME_HEADER, 0x19,
+// 0x09, 0x00, 0x96};
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ FMStat.Location = 1;
+ error = Phone->GetFMStation(&s,&FMStat);
+ if (error != ERR_NONE && error != ERR_EMPTY) {
+ printf("Phone seems not to support radio\n");
+ GSM_Terminate();
+ exit(-1);
+ }
+
+ error=GSM_WaitFor (&s, Enable, 6, 0x3E, 4, ID_User3);
+ if (error == ERR_PERMISSION) {
+ printf("Please connect headset. Required as antenna\n");
+ GSM_Terminate();
+ exit(-1);
+ }
+ Print_Error(error);
+
+ num=0;
+ for (i=88;i<108;i++) {
+ fprintf(stderr,"%cSearching: %i percent",13,(i-88)*100/(108-88));
+ Freq = i;
+ N6510_EncodeFMFrequency(Freq, SetFreq+8);
+ error=GSM_WaitFor (&s, SetFreq, 10, 0x3E, 4, ID_User3);
+ Print_Error(error);
+
+ error=GSM_WaitFor (&s, Find2, 10, 0x3E, 4, ID_User3);
+ Print_Error(error);
+ found = false;
+ for (j=0;j<num;j++) {
+ if (FMStation[j].Frequency > RadioFreq) {
+ diff = FMStation[j].Frequency - RadioFreq;
+ } else {
+ diff = RadioFreq - FMStation[j].Frequency;
+ }
+ if (diff <= 0.2) {
+ dbgprintf("diff is %f\n",diff);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ dbgprintf("Adding %f, num %i\n",RadioFreq,num);
+ FMStation[num].Frequency = RadioFreq;
+ CopyUnicodeString(FMStation[num].StationName,RadioName);
+ num++;
+ }
+ }
+ fprintf(stderr,"%cSearching: %i percent",13,100);
+ fprintf(stderr,"\n\n");
+
+ i=0;
+ while(1) {
+ if (i==num || i==num-1) break;
+ if (FMStation[i].Frequency > FMStation[i+1].Frequency) {
+ memcpy(&FMStat,&FMStation[i],sizeof(GSM_FMStation));
+ memcpy(&FMStation[i],&FMStation[i+1],sizeof(GSM_FMStation));
+ memcpy(&FMStation[i+1],&FMStat,sizeof(GSM_FMStation));
+ i = 0;
+ continue;
+ }
+ i++;
+ }
+ for (i=0;i<num;i++) {
+ fprintf(stderr,"%02i.",i+1);
+ if (FMStation[i].Frequency < 100) fprintf(stderr," ");
+ fprintf(stderr,"%.1f MHz - \"%s\" \n",
+ FMStation[i].Frequency,
+ DecodeUnicodeString(FMStation[i].StationName));
+ }
+
+ if (answer_yes2("Do you want to save found stations")) {
+ fprintf(stderr,"Deleting old FM stations: ");
+ error=Phone->ClearFMStations(&s);
+ Print_Error(error);
+ fprintf(stderr,"Done\n");
+ for (i=0;i<num;i++) {
+ FMStation[i].Location = i+1;
+ error=Phone->SetFMStation(&s,&FMStation[i]);
+ Print_Error(error);
+ fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num);
+ }
+ fprintf(stderr,"\n");
+ }
+
+ error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+void DCT4PlaySavedRingtone(int argc, char *argv[])
+{
+ unsigned char req[] = {N6110_FRAME_HEADER,
+ 0x01,
+ 0x00,0x64, //id
+ 0x01, //group
+ 0x01,0x00,0x00,
+ 0x0A, //volume
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+ GSM_AllRingtonesInfo Info;
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ error=Phone->GetRingtonesInfo(&s,&Info);
+ Print_Error(error);
+
+ if (atoi(argv[2]) > Info.Number-1) {
+ GSM_Terminate();
+ return;
+ }
+ req[4] = Info.Ringtone[atoi(argv[2])].ID / 256;
+ req[5] = Info.Ringtone[atoi(argv[2])].ID % 256;
+ req[6] = Info.Ringtone[atoi(argv[2])].Group;
+
+ error=GSM_WaitFor (&s, req, 18, 0x1F, 4, ID_User3);
+ Print_Error(error);
+
+// for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
+
+ GSM_Terminate();
+}
+
+static GSM_Error DCT4_ReplyMakeCameraShoot(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return ERR_NONE;
+}
+
+void DCT4MakeCameraShoot(int argc, char *argv[])
+{
+ unsigned char SetCamera[] = {N6110_FRAME_HEADER, 0x09, 0x01, 0x02};
+ unsigned char CameraON[] = {N6110_FRAME_HEADER, 0x02, 0x01, 0x00, 0x00, 0x00 , 0x00, 0x00};
+ unsigned char CameraON2[] = {N6110_FRAME_HEADER, 0xF0, 0x02, 0x00};
+ unsigned char MakeShot[200] = {N6110_FRAME_HEADER, 0x06, 0x01, 0x06,
+ 0x01, 0x00, 0x00, 0x02, 0x00, 0x04, 0x32, 0x00, 0x01,
+ 0x1D, //length of rest
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x02, //master folder id
+ 0x00, 0x14}; //length
+ unsigned char CameraOFF[] = {N6110_FRAME_HEADER, 0x04, 0x01, 0x00};
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3);
+ Print_Error(error);
+ error=GSM_WaitFor (&s, CameraON, 10, 0x61, 4, ID_User3);
+ Print_Error(error);
+ error=GSM_WaitFor (&s, CameraON2, 6, 0x61, 4, ID_User3);
+ Print_Error(error);
+ EncodeUnicode(MakeShot+24,"GammuShot",9);
+ MakeShot[15] = 9+9*2;
+ MakeShot[23] = 9*2;
+ error=GSM_WaitFor (&s, MakeShot, 24+MakeShot[23], 0x61, 4, ID_User3);
+ Print_Error(error);
+ error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3);
+ Print_Error(error);
+ error=GSM_WaitFor (&s, CameraOFF, 6, 0x61, 4, ID_User3);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+int len;
+
+static GSM_Error DCT4_ReplyGetScreenDump(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ if (msg.Buffer[7] == 0x0C) len = 1;
+ return ERR_NONE;
+}
+
+void DCT4GetScreenDump(int argc, char *argv[])
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x00};
+ //n6110_frameheader 06//screen info
+
+ GSM_Init(true);
+
+ CheckDCT4();
+
+ s.User.UserReplyFunctions=UserReplyFunctions4;
+
+ error=GSM_WaitFor (&s, req, 6, 0x0E, 4, ID_User3);
+ Print_Error(error);
+ len = 2000;
+ while (len >= 200) GSM_ReadDevice(&s,true);
+
+ GSM_Terminate();
+}
+
+static GSM_Reply_Function UserReplyFunctions4[] = {
+
+#ifdef DEBUG
+ {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x05,ID_User2 },
+ {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x06,ID_User2 },
+#endif
+
+ {DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_User3 },
+ {DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_IncomingFrame},
+
+ {DCT4_ReplyGetADC, "\x17",0x03,0x10,ID_User3 },
+ {DCT4_ReplyGetADC, "\x17",0x03,0x12,ID_User3 },
+
+ {DCT4_ReplySetPPS, "\x1b",0x03,0x05,ID_User1 },
+ {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_User6 },
+
+ {DCT4_ReplyVibra, "\x1C",0x03,0x0D,ID_User3 },
+ {DCT4_ReplyVibra, "\x1C",0x03,0x0F,ID_User3 },
+
+ {NoneReply, "\x1F",0x03,0x02,ID_User3 },
+
+ {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1 },
+ {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3 },
+ {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4 },
+ {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4 },
+ {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1 },
+
+ {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3 },
+ {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3 },
+ {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1 },
+ {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2 },
+
+ {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3 },
+ {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3 },
+ {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation},
+ {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3 },
+
+ {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4 },
+
+ {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6 },
+ {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6 },
+
+ {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3 },
+ {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3 },
+ {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3 },
+ {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3 },
+ {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3 },
+
+ {DCT4_ReplyGetBTInfo, "\xD7",0x03,0x0A,ID_User6 },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/nokia/dct4.h b/gammu/emb/gammu/depend/nokia/dct4.h
new file mode 100644
index 0000000..fde5b08
--- a/dev/null
+++ b/gammu/emb/gammu/depend/nokia/dct4.h
@@ -0,0 +1,95 @@
+/* (c) 2002-2004 by Marcin Wiacek */
+
+#include "../../../common/gsmstate.h"
+
+void DCT4SetPhoneMenus (int argc, char *argv[]);
+void DCT4SelfTests (int argc, char *argv[]);
+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[]);
+void DCT4Info (int argc, char *argv[]);
+void DCT4GetT9 (int argc, char *argv[]);
+void DCT4SetLight (int argc, char *argv[]);
+void DCT4DisplayTest (int argc, char *argv[]);
+void DCT4GetADC (int argc, char *argv[]);
+void DCT4VibraTest (int argc, char *argv[]);
+void DCT4TuneRadio (int argc, char *argv[]);
+void DCT4PlaySavedRingtone (int argc, char *argv[]);
+void DCT4MakeCameraShoot (int argc, char *argv[]);
+void DCT4GetScreenDump (int argc, char *argv[]);
+
+/* ------------------- features matrix ------------------------------------- */
+
+typedef enum {
+ DCT4_ALWAYS_ONLINE = 1,
+ DCT4_GPRS_PCCH,
+ DCT4_GEA1,
+ DCT4_EOTD,
+ DCT4_WAP_PUSH,
+ DCT4_USE_PREF_SIM_NET,
+ DCT4_JAVA_TCK,
+
+ DCT4_ALS,
+ DCT4_A52,
+ DCT4_CSP,
+ DCT4_EONS,
+ DCT4_3GINDICATOR,
+ DCT4_DISPLAY_PHONE_NAME,
+ DCT4_DISPLAY_WAP_PROFILE,
+
+ DCT4_GAMES_WAP_DOWNLOAD,
+ DCT4_GAMES_SCORE_SEND,
+ DCT4_GAMES_URL_CHECK,
+
+ DCT4_BLUETOOTH_MENU,
+ DCT4_WAP_BOOKMARKS_MENU,
+ DCT4_WAP_BOOKMARKS_MENU2,
+ DCT4_WAP_GOTO_MENU,
+ DCT4_WAP_SETTINGS_MENU,
+ DCT4_SERVICES_GAMES_APP_GALLERY,
+ DCT4_JAVA_GAMES_MENU,
+ DCT4_SAT_CONFIRM_MENU,
+ DCT4_INSTANT_MESS_MENU,
+ DCT4_CONFIRM_ALS,
+ DCT4_BOOKMARK_GOTO_MENU,
+
+ DCT4_5100_IDENTIFY,
+
+ DCT4_TEST
+} DCT4_Feature_Name;
+
+typedef struct {
+ DCT4_Feature_Name Name;
+ unsigned char *Text;
+ struct {
+ unsigned char Value;
+ unsigned char *Text;
+ } Values[10];
+} DCT4_Feature;
+
+typedef struct {
+ char *Model;
+ struct {
+ DCT4_Feature_Name Name;
+ int Number;
+ } Features[25];
+} DCT4_Phone_Features;
+
+typedef struct {
+ struct {
+ char Name[100];
+ unsigned char ID;
+ unsigned char Value;
+ bool Startup;
+ } Tests[50];
+ int Num;
+} DCT4_Phone_Tests;
+
+/* ------------------------------------------------------------------------- */
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/siemens/chiffre.c b/gammu/emb/gammu/depend/siemens/chiffre.c
new file mode 100644
index 0000000..65a06ba
--- a/dev/null
+++ b/gammu/emb/gammu/depend/siemens/chiffre.c
@@ -0,0 +1,223 @@
+/* xsiemens.c */
+/* Siemens service code generator */
+/* (C) Ivan Gorinov, 30.09.2002 */
+
+#include "chiffre.h"
+
+unsigned char key1[4] = {0x57, 0xF9, 0x3A, 0xC1}; /* Level 1 key */
+unsigned char key2[4] = {0xA4, 0xD3, 0x67, 0x9C}; /* Level 2 key */
+
+/* 4-bit substitution boxes */
+unsigned char sbox_h[0x10] =
+{0x09, 0x02, 0x04, 0x06, 0x08, 0x07, 0x05, 0x03, 0x01, 0x00,
+ 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+unsigned char sbox_l[0x10] =
+{0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
+ 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+
+unsigned char sbox[0x100]; /* 8-bit substitution box */
+
+char digit[] = "0123456789ABCDEF";
+
+/* Convert hex digit to binary value */
+int from_hex(int c)
+{
+ int i;
+
+ for(i = 0; i < 0x10; i++) if(c == digit[i]) break;
+ if (i >= 0x10) i = -1;
+ return i;
+}
+
+/* Convert binary value to string (decimal) */
+int bin2dec(char *s, int n, unsigned long l)
+{
+ int c, i, j;
+
+ j = n;
+ s[j] = 0;
+ for(i = 0; i < n; i++) {
+ c = l % 10;
+ l /= 10;
+ c = digit[c];
+ s[--j] = c;
+ }
+ return j;
+}
+
+/* Convert two 4-bit boxes to one 8-bit */
+int initbox(void)
+{
+ int i, j, k, x;
+
+ k = 0;
+ for(i = 0; i < 0x10; i++) {
+ x = sbox_h[i] << 4;
+ for(j = 0; j < 0x10; j++) {
+ sbox[k] = sbox_l[j] | x;
+ k++;
+ }
+ }
+ return 0;
+}
+
+/* Substitution */
+void subst(unsigned char *b, unsigned char *a, int n)
+{
+ int i;
+
+ for(i = 0; i < n; i++) b[i] = sbox[a[i]];
+}
+
+/* Xor N bytes with Z, inverting every odd byte */
+void xxstr(unsigned char *b, unsigned char *a, int n, int z)
+{
+ int i;
+
+ for(i = 0; i < n; i++) {
+ if(i & 1) {
+ b[i] = (~a[i]) ^ z;
+ } else {
+ b[i] = a[i] ^ z;
+ }
+ }
+}
+
+/* Encryption (1 iteration) */
+void ec_f(unsigned char *a, int n, int z)
+{
+ unsigned char bc[0x20], bs[0x10], bx[0x10];
+ int n2, i;
+
+ for(i = 0; i < n; i++) bc[i] = a[i];
+ n2 = n >> 1;
+ subst(bs, a, n2);
+ xxstr(bx, bs, n2, z);
+ for(i = 0; i < n2; i++) {
+ a[i] = bx[i] ^ bc[i+n2];
+ a[i+n2] = bc[i];
+ }
+}
+
+void ec_f_bak(unsigned char *a, int n, int z)
+{
+ unsigned char bc[0x20], bs[0x10], bx[0x10];
+ int n2, i;
+
+ n2 = n >> 1;
+ for(i = 0; i < n2; i++) bc[i+n2] = a[i];
+ subst(bs, bc + n2, n2);
+ xxstr(bx, bs, n2, z);
+ for(i = 0; i < n2; i++) bc[i] = bx[i] ^ a[i+n2];
+ for(i = 0; i < n; i++) a[i] = bc[i];
+}
+
+/* Decryption (1 iteration) */
+void dc_f(unsigned char *a, int n, int z)
+{
+ unsigned char bc[0x20], bs[0x10], bx[0x10];
+ int n2, i;
+
+ for(i = 0; i < n; i++) bc[i] = a[i];
+ n2 = n >> 1;
+ subst(bs, a + n2, n2);
+ xxstr(bx, bs, n2, z);
+ for(i = 0; i < n2; i++) {
+ a[i] = bc[i+n2];
+ a[i+n2] = bx[i] ^ bc[i];
+ }
+}
+
+/* Encryption (IMSI -> code) */
+void ss_encrypt(unsigned char *a, int n, unsigned char *key)
+{
+ int i;
+
+ for(i = 0; i < 4; i++) ec_f_bak(a, n, key[i]);
+}
+
+/* Decryption (code -> IMSI) */
+void ss_decrypt(unsigned char *a, int n, unsigned char *key)
+{
+ int i;
+
+ for(i = 0; i < 4; i++) dc_f(a, n, key[3-i]);
+}
+
+int siemens_code(char *str_imsi, char *str_code, int level)
+{
+ unsigned char array[8];
+ unsigned char xcode[8];
+ unsigned char test[8];
+ unsigned long l0, l1;
+ unsigned char *key;
+ int x, c, i, j;
+
+ if(!str_code) return -1;
+ str_code[0] = 0;
+
+ initbox();
+
+ switch(level) {
+ case 1: key = key1; break;
+ case 2: key = key2; break;
+ default: return -1;
+ }
+
+ /* Check the length of IMSI */
+ for(i = 0; i < 32; i++) if(!str_imsi[i]) break;
+ if(i == 0) return -1;
+ if(i >= 32) return -1;
+
+ /* Convert last 12 digits to 6 bytes [2-7] */
+ for(j = 7; j >= 2; j--) {
+ if (i == 0) {
+ c = 0x0F;
+ } else {
+ c = str_imsi[--i];
+ c = from_hex(c);
+ if(c < 0) return -1;
+ }
+ x = c;
+ if(i == 0) {
+ c = 0x0F;
+ } else {
+ c = str_imsi[--i];
+ c = from_hex(c);
+ if(c < 0) return -1;
+ }
+ x = (x << 4) | c;
+ array[j] = x;
+ }
+
+ /* This byte is never checked by firmware */
+ array[1] = 0;
+
+ /* Byte [0] <- checksum */
+ x = 0;
+ for(i = 1; i < 8; i++) x ^= array[i];
+ array[0] = x;
+
+ for(i = 0; i < 8; i++) xcode[i] = array[i];
+
+ /* Make the code */
+ ss_encrypt(xcode, 8, key);
+
+ /* The test */
+ for(i = 0; i < 8; i++) test[i] = xcode[i];
+ ss_decrypt(test, 8, key);
+ for(i = 0; i < 8; i++) if(test[i] != array[i]) break;
+ if(i < 8) return -1;
+
+ /* Convert to strings */
+ l0 = 0;
+ for(i = 3; i >= 0; i--) l0 = (l0 << 8) | xcode[i];
+
+ l1 = 0;
+ for(i = 7; i >= 4; i--) l1 = (l1 << 8) | xcode[i];
+
+ bin2dec(str_code, 10, l0);
+ bin2dec(str_code + 10, 10, l1);
+
+ return 0;
+}
diff --git a/gammu/emb/gammu/depend/siemens/chiffre.h b/gammu/emb/gammu/depend/siemens/chiffre.h
new file mode 100644
index 0000000..840157a
--- a/dev/null
+++ b/gammu/emb/gammu/depend/siemens/chiffre.h
@@ -0,0 +1,3 @@
+/* xsiemens.h */
+
+int siemens_code(char*, char*, int);
diff --git a/gammu/emb/gammu/depend/siemens/dsiemens.c b/gammu/emb/gammu/depend/siemens/dsiemens.c
new file mode 100644
index 0000000..dc54102
--- a/dev/null
+++ b/gammu/emb/gammu/depend/siemens/dsiemens.c
@@ -0,0 +1,363 @@
+/* (c) by Walek */
+
+#include "../../../common/gsmstate.h"
+
+#ifdef GSM_ENABLE_ATGEN
+
+#include <string.h>
+
+#include "../../../common/misc/coding/coding.h"
+#include "../../../common/gsmcomon.h"
+#include "../../../common/service/gsmnet.h"
+#include "../../../common/phone/at/atgen.h"
+#include "../../gammu.h"
+#include "dsiemens.h"
+#include "chiffre.h"
+
+extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI);
+extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *status);
+extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *pbk);
+extern GSM_Reply_Function UserReplyFunctionsAtS[];
+
+bool new_variable;
+GSM_Error CheckSiemens()
+{
+ if (s.Phone.Data.Priv.ATGEN.Manufacturer != AT_Siemens) return ERR_NOTSUPPORTED;
+ return ERR_NONE;
+}
+
+GSM_Error ATSIEMENS_Reply_GetSAT(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ GSM_SAT_Measure_results MeasureResult;
+ unsigned char buf[256];
+ int length,i,rep,ChNo=1,j=0,result=0,origARFCN=0;
+ int freq_tmp,frequency[24];
+ GSM_NetworkInfo Network;
+
+ if (Priv->ReplyState!=AT_Reply_OK) return ERR_UNKNOWN;
+ if (s->Protocol.Data.AT.EditMode) s->Protocol.Data.AT.EditMode = false;
+ if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"SSTK")) {
+ length = strlen(GetLineString(msg.Buffer,Priv->Lines,2))-7;
+ DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,2)+7,length);
+ if (buf[0]==0x7f) {
+ new_variable=true;
+ return ERR_NONE;
+ }
+ else return ERR_UNKNOWN;
+ }
+ if (!strstr(GetLineString(msg.Buffer,Priv->Lines,3),"SSTK")) return ERR_UNKNOWN;
+
+ length = strlen(GetLineString(msg.Buffer,Priv->Lines,3))-7;
+ DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,3)+7,length);
+
+ if (buf[3]!=0x26) return ERR_UNKNOWN;
+
+#ifdef DEBUG
+ dbgprintf ("SAT command: Provide Local Information\nFunction: ");
+ switch (buf[4]) {
+ case 00: dbgprintf ("Loc Info\n"); break;
+ case 01: dbgprintf ("IMEI\n"); break;
+ case 02: dbgprintf ("Network Measure\n"); break;
+ case 03: dbgprintf ("Date time and timezone\n"); break;
+ case 04: dbgprintf ("Language setting\n"); break;
+ case 05: dbgprintf ("Timing advance\n"); break;
+ }
+#endif
+ /* Loc Info (MCC, MNC, LAC, Cell ID) */
+ if (buf[4]==00) {
+ DecodeBCD (Network.NetworkCode,buf+14,2);
+ Network.NetworkCode[3] = ' ';
+ DecodeBCD (Network.NetworkCode+4,buf+16,1);
+ EncodeHexBin (Network.LAC,buf+17,2);
+ EncodeHexBin (Network.CID,buf+19,2);
+
+ printf(" Network code : %s\n",Network.NetworkCode);
+ printf(" Network name for Gammu : %s\n",
+ DecodeUnicodeString(GSM_GetNetworkName(Network.NetworkCode)));
+ printf(" CID : %s\n",Network.CID);
+ printf(" LAC : %s\n",Network.LAC);
+ }
+
+ /* Network Measure */
+ if (buf[4]==02) {
+
+ for (i=0;i<24;i++) frequency[i]=0;
+ if (!new_variable) {
+ GetBufferI(buf+32,&j,&result,7);
+ result &= 0x67;
+ if (result !=0x47) return ERR_NOTSUPPORTED;
+ }
+#ifdef DEBUG
+ if (new_variable) dbgprintf ("New variable Bitmap format\n");
+ else dbgprintf ("Old variable Bitmap format\n");
+#endif
+ GetBufferI(buf+32,&j,&origARFCN,10);
+ /* 10 bit origin ARFCN or first frequency (new variable format) */
+#ifdef DEBUG
+ dbgprintf("Origin BCCH = %i\n",origARFCN);
+#endif
+ rep = buf[31]*8;
+ if (!new_variable ){
+ for (i=0;i<rep;i++){
+ result = 0;
+ GetBufferI(buf+32,&j,&result,1);
+ if (result) {
+ frequency[ChNo]=i+origARFCN+1;
+ ChNo++;
+ }
+ }
+ }
+ else {
+ frequency[ChNo++]=origARFCN;
+ for (i=0; i<rep; i+=10){
+ result = 0;
+ GetBufferI(buf+32,&j,&result,10);
+ if (!result) break;
+ frequency[ChNo++]=result;
+ }
+ j=1;
+ while (j) {
+ j=0;
+ for (i=0; i<ChNo-1; i++){
+ if (frequency[i] > frequency[i+1]){
+ freq_tmp=frequency[i];
+ frequency[i]=frequency[i+1];
+ frequency[i+1]=freq_tmp;
+ j=1;
+ }
+ }
+ }
+ };
+#ifdef DEBUG
+ dbgprintf("Neighbor BCCH list: ");
+ for (i=1;i<ChNo;i++) dbgprintf ("%d ",frequency[i]);
+ dbgprintf ("\n");
+#endif
+ j = 0;
+ result = 0;
+ GetBufferI(buf+14,&j,&result,1);
+ if (result) MeasureResult.BA_used=true;
+ else MeasureResult.BA_used=false;
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,1);
+ if (result) MeasureResult.DTX_used=true;
+ else MeasureResult.DTX_used=false;
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,6);
+ MeasureResult.RXLEV_FullServicingCell=result-110;
+
+ j++; //skip spare bit
+ result = 0;
+ GetBufferI(buf+14,&j,&result,1);
+ if (result) MeasureResult.MeasValid=true;
+ else MeasureResult.MeasValid=false;
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,6);
+ MeasureResult.RXLEV_SubServicingCell=result-110;
+
+ j++; //skip spare bit
+ result = 0;
+ GetBufferI(buf+14,&j,&result,3);
+ MeasureResult.RXQUAL_FullServicingCell=result;
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,3);
+ MeasureResult.RXQUAL_SubServicingCell=result;
+
+ printf ("RX Level FULL Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell);
+ printf ("RX Level Sub Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell);
+
+ printf ("RX Quality Full Servicing Cell = %i\n",MeasureResult.RXQUAL_FullServicingCell);
+ printf ("RX Quality Sub Servicing Cell = %i\n",MeasureResult.RXQUAL_SubServicingCell);
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,3);
+ MeasureResult.NO_NCELL_M=result;
+
+ rep=MeasureResult.NO_NCELL_M;
+
+ for (i=0;i<MeasureResult.NO_NCELL_M;i++) {
+ result = 0;
+ GetBufferI(buf+14,&j,&result,6);
+ MeasureResult.NeighbourCell[i].RxLev = result-110;
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,5);
+ if (new_variable)
+ MeasureResult.NeighbourCell[i].ChFreq = frequency[result+1];
+ else MeasureResult.NeighbourCell[i].ChFreq = frequency[result];
+
+ result = 0;
+ GetBufferI(buf+14,&j,&result,3);
+ MeasureResult.NeighbourCell[i].NB = 10 * result;
+ result = 0;
+ GetBufferI(buf+14,&j,&result,3);
+ MeasureResult.NeighbourCell[i].NB += result;
+
+ if (MeasureResult.NeighbourCell[i].ChFreq)
+ printf("CH = %i,\t",MeasureResult.NeighbourCell[i].ChFreq);
+ else
+ printf("CH = Unknown\t");
+ printf("RX Lev = %i dBm\t",MeasureResult.NeighbourCell[i].RxLev);
+ printf("BSIC CELL = %i\n",MeasureResult.NeighbourCell[i].NB);
+ }
+ }
+#ifdef DEBUG
+ if (buf[4]==05) { //Timing Advance
+ if (buf[11]) dbgprintf ("Unknown Timing Advance\n");
+ else dbgprintf ("Timing Advance = %i\n",buf[14] & 0x3f);
+ }
+#endif
+ return ERR_NONE;
+}
+
+GSM_Error ATSIEMENS_Reply_GetNetmon(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ int i=2;
+
+ if (!strstr(GetLineString(msg.Buffer,Priv->Lines,1),"AT^S^MI")) return ERR_UNKNOWN;
+ while (strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)))
+ printf("%s\n",GetLineString(msg.Buffer,Priv->Lines,i++));
+ printf("\n");
+ return ERR_NONE;
+}
+
+GSM_Error ATSIEMENS_GetSAT(GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ GSM_Error error;
+ unsigned char *reqSAT[]= {"D009810301260082028182",
+ "D009810301260282028182",
+ "D009810301260582028182"},req[32];
+ int i,len;
+
+ if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
+
+ sprintf(req, "AT^SSTK=?\r");
+ error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1);
+
+ for (i=0;i<3;i++){
+ len = strlen(reqSAT[i]);
+ s->Protocol.Data.AT.EditMode = true;
+ sprintf(req, "AT^SSTK=%i,1\r",len/2);
+ error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1);
+ s->Phone.Data.DispatchError = ERR_TIMEOUT;
+ s->Phone.Data.RequestID = ID_User1;
+ error = s->Protocol.Functions->WriteMessage(s, reqSAT[i], len, 0x00);
+ if (error!=ERR_NONE) return error;
+ error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00);
+ if (error!=ERR_NONE) return error;
+ error = GSM_WaitForOnce (s, NULL,0x00, 0x00, 4);
+ if (error!=ERR_NONE) return error;
+ }
+ return ERR_NONE;
+}
+
+GSM_Error ATSIEMENS_GetNetmon(GSM_StateMachine *s,int test_no)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char req[32];
+
+ if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
+ sprintf(req, "AT^S^MI=%d\r",test_no);
+ printf ("Siemens NetMonitor test #%i\n",test_no);
+ return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2);
+}
+
+GSM_Error ATSIEMENS_ActivateNetmon (GSM_StateMachine *s,int netmon_type)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char req[32];
+
+ if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
+
+ sprintf(req, "AT\r");
+ printf ("Activate Siemens NetMonitor\n");
+ siemens_code (req,req,2);
+
+ return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2);
+}
+
+void ATSIEMENSActivateNetmon(int argc, char *argv[])
+{
+ GSM_MemoryStatus status;
+ GSM_MemoryEntry pbk;
+ int netmon_type, pbk_maxlocation;
+ char imsi[15], NetMonCode[32];
+
+ GSM_Init(true);
+ if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED);
+ s.User.UserReplyFunctions=UserReplyFunctionsAtS;
+
+ printf ("Activate NetMonitor...\n");
+ netmon_type = atoi(argv[2]);
+
+ if ((netmon_type==1) || (netmon_type==2)) {
+ error = ATGEN_GetSIMIMSI (&s,imsi);
+ Print_Error(error);
+ siemens_code(imsi,NetMonCode,netmon_type);
+
+ status.MemoryType = MEM_SM;
+ error = ATGEN_GetMemoryStatus (&s,&status);
+ Print_Error(error);
+
+ pbk_maxlocation = status.MemoryUsed+status.MemoryFree;
+ pbk.MemoryType = MEM_SM;
+ pbk.Location = pbk_maxlocation;
+ pbk.EntriesNum = 2;
+ pbk.Entries[0].EntryType = PBK_Number_General;
+ EncodeUnicode (pbk.Entries[0].Text,NetMonCode,strlen(NetMonCode));
+ pbk.Entries[1].EntryType = PBK_Text_Name;
+ sprintf (NetMonCode,"Net Monitor");
+ EncodeUnicode (pbk.Entries[1].Text,NetMonCode,strlen(NetMonCode));
+ error = ATGEN_SetMemory (&s, &pbk);
+ Print_Error(error);
+ }
+ else printf ("NetMonitor type should be:\n1 - full Netmon\n2 - simple NetMon\n");
+
+ GSM_Terminate();
+}
+
+void ATSIEMENSSATNetmon(int argc, char *argv[])
+{
+ GSM_Init(true);
+ if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED);
+ s.User.UserReplyFunctions=UserReplyFunctionsAtS;
+
+ printf ("Getting Siemens Sim Aplication Toolkit NetMonitor...\n");
+
+ error=ATSIEMENS_GetSAT(&s);
+ Print_Error(error);
+ GSM_Terminate();
+}
+
+void ATSIEMENSNetmonitor(int argc, char *argv[])
+{
+ int test_no;
+
+ GSM_Init(true);
+ if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED);
+ s.User.UserReplyFunctions=UserReplyFunctionsAtS;
+
+ printf ("Getting Siemens NetMonitor...\n");
+ test_no = atoi(argv[2]);
+ error = ATSIEMENS_GetNetmon (&s,test_no+1);
+ Print_Error(error);
+ GSM_Terminate();
+}
+
+static GSM_Reply_Function UserReplyFunctionsAtS[] = {
+ {ATSIEMENS_Reply_GetSAT, "AT^SSTK", 0x00,0x00,ID_User1 },
+ {ATSIEMENS_Reply_GetNetmon, "AT^S^MI", 0x00,0x00,ID_User2 },
+ {NULL, "\x00", 0x00,0x00,ID_None }
+};
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/depend/siemens/dsiemens.h b/gammu/emb/gammu/depend/siemens/dsiemens.h
new file mode 100644
index 0000000..3db1c30
--- a/dev/null
+++ b/gammu/emb/gammu/depend/siemens/dsiemens.h
@@ -0,0 +1,34 @@
+/* (c) by Walek */
+
+#ifndef at_siemens_h
+#define at_siemens_h
+
+typedef struct {
+ int ChFreq;
+ int RxLev;
+ int NB;
+} GSM_SAT_ChInfo;
+
+typedef struct {
+ bool BA_used;
+ bool DTX_used;
+ bool MeasValid;
+ int RXLEV_FullServicingCell;
+ int RXLEV_SubServicingCell;
+ unsigned char RXQUAL_FullServicingCell;
+ unsigned char RXQUAL_SubServicingCell;
+ unsigned char NO_NCELL_M;
+ GSM_SAT_ChInfo NeighbourCell[8];
+} GSM_SAT_Measure_results;
+
+void ATSIEMENSSATNetmon(int argc, char *argv[]);
+void ATSIEMENSNetmonitor(int argc, char *argv[]);
+void ATSIEMENSActivateNetmon(int argc, char *argv[]);
+
+#include "../../../common/gsmstate.h"
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
new file mode 100644
index 0000000..1d53fb0
--- a/dev/null
+++ b/gammu/emb/gammu/gammu.c
@@ -0,0 +1,8356 @@
+/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
+/* FM stuff by Walek */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <locale.h>
+#include <signal.h>
+#include <ctype.h>
+#include <wchar.h>
+#undef HAVE_MYSQL_MYSQL_H
+#ifdef WIN32
+# include <windows.h>
+# include <process.h>
+# ifdef _MSC_VER
+# include <sys/utime.h>
+# else
+# include <utime.h>
+# endif
+#else
+# include <utime.h>
+#endif
+
+#include "../common/gammu.h"
+#include "gammu.h"
+#include "smsd/smsdcore.h"
+#ifdef DEBUG
+# include "sniff.h"
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT3
+# include "depend/nokia/dct3.h"
+# include "depend/nokia/dct3trac/wmx.h"
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+# include "depend/nokia/dct4.h"
+#endif
+#ifdef GSM_ENABLE_ATGEN
+# include "depend/siemens/dsiemens.h"
+#endif
+
+#ifdef HAVE_PTHREAD
+# include <pthread.h>
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+
+//static GSM_StateMachine s;
+//static GSM_Phone_Functions *Phone;
+static INI_Section *cfg = NULL;
+
+//static GSM_Error error = ERR_NONE;
+ static int i;
+
+//static bool gshutdown = false;
+typedef struct {
+ unsigned char Connection[50];
+} OneConnectionInfo;
+
+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)
+{
+ signal(sign, SIG_IGN);
+ gshutdown = true;
+}
+
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
+int printmsg(char *format, ...)
+{
+ va_list argp;
+ int result;
+
+ va_start(argp, format);
+ result = vfprintf(stdout,GetMsg(s.msg,format),argp);
+ va_end(argp);
+ return result;
+}
+
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
+int printmsgerr(char *format, ...)
+{
+ va_list argp;
+ int result;
+
+ va_start(argp, format);
+ result = vfprintf(stderr,GetMsg(s.msg,format), argp);
+ va_end(argp);
+ return result;
+}
+
+static void PrintSecurityStatus()
+{
+ GSM_SecurityCodeType Status;
+
+ error=Phone->GetSecurityStatus(&s,&Status);
+ Print_Error(error);
+ switch(Status) {
+ case SEC_SecurityCode:
+ printmsg("Waiting for Security Code.\n");
+ break;
+ case SEC_Pin:
+ printmsg("Waiting for PIN.\n");
+ break;
+ case SEC_Pin2:
+ printmsg("Waiting for PIN2.\n");
+ break;
+ case SEC_Puk:
+ printmsg("Waiting for PUK.\n");
+ break;
+ case SEC_Puk2:
+ printmsg("Waiting for PUK2.\n");
+ break;
+ case SEC_None:
+ printmsg("Nothing to enter.\n");
+ break;
+ default:
+ printmsg("Unknown\n");
+ }
+}
+
+void Print_Error(GSM_Error error)
+{
+ if (error != ERR_NONE) {
+ printf("%s\n",print_error(error,s.di.df,s.msg));
+ if (error == ERR_SECURITYERROR) {
+ printmsg("Security status: ");
+ PrintSecurityStatus();
+ }
+ if (s.opened) GSM_TerminateConnection(&s);
+ exit (-1);
+ }
+}
+
+void GSM_Init(bool checkerror)
+{
+ error=GSM_InitConnection(&s,3);
+ if (checkerror) Print_Error(error);
+
+ Phone=s.Phone.Functions;
+}
+
+void GSM_Terminate(void)
+{
+ error=GSM_TerminateConnection(&s);
+ Print_Error(error);
+}
+
+static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
+{
+ *start=atoi(argv[num]);
+ if (*start==0) {
+ printmsg("ERROR: enumerate locations from 1\n");
+ exit (-1);
+ }
+
+ if (stop!=NULL) {
+ *stop=*start;
+ if (argc>=num+2) *stop=atoi(argv[num+1]);
+ if (*stop==0) {
+ printmsg("ERROR: enumerate locations from 1\n");
+ exit (-1);
+ }
+ }
+}
+
+bool always_answer_yes = false;
+bool always_answer_no = false;
+
+static bool answer_yes(char *text)
+{
+ int len;
+ char ans[99];
+
+ while (1) {
+ printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text);
+ if (always_answer_yes) {
+ printmsgerr("YES (always)\n");
+ return true;
+ }
+ if (always_answer_no) {
+ printmsgerr("NO (always)\n");
+ return false;
+ }
+ len=GetLine(stdin, ans, 99);
+ if (len==-1) exit(-1);
+ if (!strcmp(ans, "NONE")) {
+ always_answer_no = true;
+ return false;
+ }
+ if (!strcmp(ans, "ONLY")) {
+ always_answer_no = true;
+ return true;
+ }
+ if (!strcmp(ans, "ALL")) {
+ always_answer_yes = true;
+ return true;
+ }
+ if (mystrncasecmp(ans, "yes",0)) return true;
+ if (mystrncasecmp(ans, "no" ,0)) return false;
+ }
+}
+
+#ifdef GSM_ENABLE_BEEP
+void GSM_PhoneBeep(void)
+{
+ error = PHONE_Beep(&s);
+ if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error);
+}
+#endif
+
+static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
+{
+ int i;
+ bool first=true;
+ GSM_Error error;
+
+ signal(SIGINT, interrupt);
+ printmsg("Press Ctrl+C to break...\n");
+
+ for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
+ if (gshutdown) break;
+ if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
+ error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
+ if (error!=ERR_NONE) return error;
+ first = false;
+ }
+
+ /* Disables buzzer */
+ return s.Phone.Functions->PlayTone(&s,255*255,0,false);
+}
+static void PlayRingtone(int argc, char *argv[])
+{
+ GSM_Ringtone ringtone,ringtone2;
+
+ ringtone.Format = 0;
+ error=GSM_ReadRingtoneFile(argv[2],&ringtone);
+ Print_Error(error);
+
+ error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
+ Print_Error(error);
+
+ GSM_Init(true);
+
+ error=GSM_PlayRingtone(ringtone2);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void Identify(int argc, char *argv[])
+{
+ unsigned char buffer[100];
+
+ GSM_Init(true);
+
+ error=Phone->GetManufacturer(&s);
+ Print_Error(error);
+ printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer);
+ error=Phone->GetModel(&s);
+ Print_Error(error);
+ printmsg("Model : %s (%s)\n",
+ s.Phone.Data.ModelInfo->model,
+ s.Phone.Data.Model);
+
+ error=Phone->GetFirmware(&s);
+ Print_Error(error);
+ printmsg("Firmware : %s",s.Phone.Data.Version);
+ error=Phone->GetPPM(&s, buffer);
+ if (error != ERR_NOTSUPPORTED) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg(" %s",buffer);
+ }
+ if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate);
+ printf("\n");
+
+ error=Phone->GetHardware(&s, buffer);
+ if (error != ERR_NOTSUPPORTED) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer);
+ }
+
+ error=Phone->GetIMEI(&s);
+ if (error != ERR_NOTSUPPORTED) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI);
+
+ error=Phone->GetOriginalIMEI(&s, buffer);
+ if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer);
+ }
+ }
+
+ error=Phone->GetManufactureMonth(&s, buffer);
+ if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer);
+ }
+
+ error=Phone->GetProductCode(&s, buffer);
+ if (error != ERR_NOTSUPPORTED) {
+ if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
+ if (error == ERR_NONE) printmsg("Product code : %s\n",buffer);
+ }
+
+ error=Phone->GetSIMIMSI(&s, buffer);
+ switch (error) {
+ case ERR_SECURITYERROR:
+ case ERR_NOTSUPPORTED:
+ case ERR_NOTIMPLEMENTED:
+ break;
+ case ERR_NONE:
+ printmsg("SIM IMSI : %s\n",buffer);
+ break;
+ default:
+ Print_Error(error);
+ }
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3Info(argc, argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4Info(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+//#if 0
+static void GetDateTime(int argc, char *argv[])
+{
+ GSM_DateTime date_time;
+ GSM_Locale locale;
+
+ GSM_Init(true);
+
+ error=Phone->GetDateTime(&s, &date_time);
+ switch (error) {
+ case ERR_EMPTY:
+ printmsg("Date and time not set in phone\n");
+ break;
+ case ERR_NONE:
+ printmsg("Phone time is %s\n",OSDateTime(date_time,false));
+ break;
+ default:
+ Print_Error(error);
+ }
+
+ error=Phone->GetLocale(&s, &locale);
+ switch (error) {
+ case ERR_NOTSUPPORTED:
+ case ERR_NOTIMPLEMENTED:
+ break;
+ default:
+ Print_Error(error);
+ printmsg("Time format is ");
+ if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
+ printmsg("Date format is ");
+ switch (locale.DateFormat) {
+ case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
+ case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
+ case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
+ }
+ printmsg(", date separator is %c\n",locale.DateSeparator);
+ }
+
+ GSM_Terminate();
+}
+
+static void SetDateTime(int argc, char *argv[])
+{
+ GSM_DateTime date_time;
+
+ GSM_GetCurrentDateTime(&date_time);
+
+ GSM_Init(true);
+
+ error=Phone->SetDateTime(&s, &date_time);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void GetAlarm(int argc, char *argv[])
+{
+ GSM_Alarm alarm;
+
+ GSM_Init(true);
+
+ alarm.Location = 1;
+ error=Phone->GetAlarm(&s, &alarm);
+ switch (error) {
+ case ERR_EMPTY:
+ printmsg("Alarm not set in phone\n");
+ break;
+ case ERR_NONE:
+ if (alarm.Repeating) {
+ printmsg("Date: %s\n","Every day");
+ } else {
+ printmsg("Date: %s\n",OSDate(alarm.DateTime));
+ }
+ printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute);
+ if (alarm.Text[0] != 0 || alarm.Text[1] != 0) {
+ printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text));
+ }
+ break;
+ default:
+ Print_Error(error);
+ }
+
+ GSM_Terminate();
+}
+
+static void SetAlarm(int argc, char *argv[])
+{
+ GSM_Alarm alarm;
+
+ alarm.DateTime.Hour = atoi(argv[2]);
+ alarm.DateTime.Minute = atoi(argv[3]);
+ alarm.DateTime.Second = 0;
+ alarm.Location = 1;
+ alarm.Repeating = true;
+ alarm.Text[0] = 0;
+ alarm.Text[1] = 0;
+
+ GSM_Init(true);
+
+ error=Phone->SetAlarm(&s, &alarm);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+GSM_Bitmap caller[5];
+GSM_AllRingtonesInfo Info;
+bool callerinit[5] = {false, false, false, false, false};
+bool ringinit = false;
+
+static void PrintMemoryEntry(GSM_MemoryEntry *entry)
+{
+ GSM_Category Category;
+ bool unknown;
+ int z;
+
+ for (i=0;i<entry->EntriesNum;i++) {
+ unknown = false;
+ switch (entry->Entries[i].EntryType) {
+ case PBK_Date:
+ printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false));
+ continue;
+ case PBK_Category:
+ Category.Location = entry->Entries[i].Number;
+ Category.Type = Category_Phonebook;
+ error=Phone->GetCategory(&s, &Category);
+ if (error == ERR_NONE) {
+ printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number);
+ } else {
+ printmsg("Category : %i\n", entry->Entries[i].Number);
+ }
+ continue;
+ case PBK_Private:
+ printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No");
+ continue;
+ case PBK_Number_General : printmsg("General number "); break;
+ case PBK_Number_Mobile : printmsg("Mobile number "); break;
+ case PBK_Number_Work : printmsg("Work number "); break;
+ case PBK_Number_Fax : printmsg("Fax number "); break;
+ case PBK_Number_Home : printmsg("Home number "); break;
+ case PBK_Number_Pager : printmsg("Pager number "); break;
+ case PBK_Number_Other : printmsg("Other number "); break;
+ case PBK_Text_Note : printmsg("Text "); break;
+ case PBK_Text_Postal : printmsg("Snail address "); break;
+ case PBK_Text_Email : printmsg("Email address 1 "); break;
+ case PBK_Text_Email2 : printmsg("Email address 2 "); break;
+ case PBK_Text_URL : printmsg("URL address "); break;
+ case PBK_Text_Name : printmsg("Name "); break;
+ case PBK_Text_LastName : printmsg("Last name "); break;
+ case PBK_Text_FirstName : printmsg("First name "); break;
+ case PBK_Text_Company : printmsg("Company "); break;
+ case PBK_Text_JobTitle : printmsg("Job title "); break;
+ case PBK_Text_StreetAddress : printmsg("Street address "); break;
+ case PBK_Text_City : printmsg("City "); break;
+ case PBK_Text_State : printmsg("State "); break;
+ case PBK_Text_Zip : printmsg("Zip code "); break;
+ case PBK_Text_Country : printmsg("Country "); break;
+ case PBK_Text_Custom1 : printmsg("Custom text 1 "); break;
+ case PBK_Text_Custom2 : printmsg("Custom text 2 "); break;
+ case PBK_Text_Custom3 : printmsg("Custom text 3 "); break;
+ case PBK_Text_Custom4 : printmsg("Custom text 4 "); break;
+ case PBK_Caller_Group :
+ unknown = true;
+ if (!callerinit[entry->Entries[i].Number]) {
+ caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo;
+ caller[entry->Entries[i].Number].Location = entry->Entries[i].Number;
+ error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]);
+ Print_Error(error);
+ if (caller[entry->Entries[i].Number].DefaultName) {
+ NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]);
+ }
+ callerinit[entry->Entries[i].Number]=true;
+ }
+ printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text));
+ break;
+ case PBK_RingtoneID :
+ unknown = true;
+ if (!ringinit) {
+ error=Phone->GetRingtonesInfo(&s,&Info);
+ if (error != ERR_NOTSUPPORTED) Print_Error(error);
+ if (error == ERR_NONE) ringinit = true;
+ }
+ if (ringinit) {
+ for (z=0;z<Info.Number;z++) {
+ if (Info.Ringtone[z].ID == entry->Entries[i].Number) {
+ printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name));
+ break;
+ }
+ }
+ } else {
+ printmsg("Ringtone ID : %i\n",entry->Entries[i].Number);
+ }
+ break;
+ case PBK_PictureID :
+ unknown = true;
+ printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number);
+ break;
+ default :
+ printmsg("UNKNOWN\n");
+ unknown = true;
+ break;
+ }
+ if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text));
+ }
+ printf("\n");
+}
+
+static void GetAllMemory(int argc, char *argv[])
+{
+ GSM_MemoryEntry Entry;
+ bool start = true;
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ Entry.MemoryType = 0;
+
+ if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC;
+ if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON;
+ if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC;
+ if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC;
+ if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME;
+ if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM;
+ if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM;
+ if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD;
+ if (Entry.MemoryType==0) {
+ printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
+ exit (-1);
+ }
+
+ GSM_Init(true);
+
+ while (!gshutdown) {
+ error = Phone->GetNextMemory(&s, &Entry, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
+ PrintMemoryEntry(&Entry);
+ start = false;
+ }
+
+ GSM_Terminate();
+}
+
+static void GetMemory(int argc, char *argv[])
+{
+ int j, start, stop;
+ GSM_MemoryEntry entry;
+
+ entry.MemoryType=0;
+
+ if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
+ if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
+ if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
+ if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
+ if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
+ if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
+ if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
+ if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
+ if (entry.MemoryType==0) {
+ printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
+ exit (-1);
+ }
+
+ GetStartStop(&start, &stop, 3, argc, argv);
+
+ GSM_Init(true);
+
+ if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
+ if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n");
+ }
+
+ for (j=start;j<=stop;j++) {
+ printmsg("Memory %s, Location %i\n",argv[2],j);
+
+ entry.Location=j;
+
+ error=Phone->GetMemory(&s, &entry);
+ if (error != ERR_EMPTY) Print_Error(error);
+
+ if (error == ERR_EMPTY) {
+ printmsg("Entry is empty\n");
+ printf("\n");
+ } else {
+ PrintMemoryEntry(&entry);
+ }
+ }
+
+ GSM_Terminate();
+}
+
+#define MemoryLocationToString(x) ( \
+ x == MEM_ON ? "ON" : \
+ x == MEM_RC ? "RC" : \
+ x == MEM_MC ? "MC" : \
+ x == MEM_ME ? "ME" : \
+ x == MEM_SM ? "SM" : \
+ x == MEM_VM ? "VM" : \
+ x == MEM_FD ? "FD" : "XX")
+
+static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
+{
+ int i;
+
+ for (i=0;i<Entry->EntriesNum;i++) {
+ switch (Entry->Entries[i].EntryType) {
+ case PBK_Number_General :
+ case PBK_Number_Mobile :
+ case PBK_Number_Work :
+ case PBK_Number_Fax :
+ case PBK_Number_Home :
+ case PBK_Number_Pager :
+ case PBK_Number_Other :
+ case PBK_Text_Note :
+ case PBK_Text_Postal :
+ case PBK_Text_Email :
+ case PBK_Text_Email2 :
+ case PBK_Text_URL :
+ case PBK_Text_Name :
+ case PBK_Text_LastName :
+ case PBK_Text_FirstName :
+ case PBK_Text_Company :
+ case PBK_Text_JobTitle :
+ case PBK_Text_StreetAddress :
+ case PBK_Text_City :
+ case PBK_Text_State :
+ case PBK_Text_Zip :
+ case PBK_Text_Country :
+ case PBK_Text_Custom1 :
+ case PBK_Text_Custom2 :
+ case PBK_Text_Custom3 :
+ case PBK_Text_Custom4 :
+ case PBK_Caller_Group :
+ if (mystrstr(Entry->Entries[i].Text, Text) != NULL) {
+ fprintf(stderr,"\n");
+ printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
+ PrintMemoryEntry(Entry);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text)
+{
+ GSM_MemoryEntry Entry;
+ GSM_MemoryStatus Status;
+ int i = 0, l = 1;
+ bool start = true;
+
+ Status.MemoryType = MemoryType;
+ Entry.MemoryType = MemoryType;
+
+ if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) {
+ fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
+ if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) {
+ while (i < Status.MemoryUsed) {
+ if (gshutdown) return;
+ i++;
+ fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1));
+ error = Phone->GetNextMemory(&s, &Entry, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ SearchOneEntry(&Entry, Text);
+ start = false;
+ }
+ } else {
+ while (i < Status.MemoryUsed) {
+ Entry.Location = l;
+ error = Phone->GetMemory(&s, &Entry);
+ if (error != ERR_EMPTY) {
+ Print_Error(error);
+ i++;
+ SearchOneEntry(&Entry, Text);
+ }
+ fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
+ l++;
+ }
+ }
+ fprintf(stderr,"\n");
+ }
+}
+
+static void SearchMemory(int argc, char *argv[])
+{
+ unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2];
+ int Length;
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ Length = strlen(argv[2]);
+ if (Length > GSM_PHONEBOOK_TEXT_LENGTH) {
+ printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH);
+ Length = GSM_PHONEBOOK_TEXT_LENGTH;
+ }
+ EncodeUnicode(Text, argv[2], Length);
+
+ GSM_Init(true);
+
+ if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text);
+ if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text);
+ if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text);
+ if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text);
+ if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text);
+ if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text);
+ if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text);
+ if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text);
+
+ GSM_Terminate();
+}
+
+static void ListMemoryCategoryEntries(int Category)
+{
+ GSM_MemoryEntry Entry;
+ bool start = true;
+ int j;
+
+ /* Category can be only for ME stored entries */
+ Entry.MemoryType = MEM_ME;
+
+ while (!gshutdown) {
+ error = Phone->GetNextMemory(&s, &Entry, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ for (j=0;j<Entry.EntriesNum;j++) {
+ if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) {
+ printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location);
+ PrintMemoryEntry(&Entry);
+ }
+ }
+ start = false;
+ }
+}
+
+static void ListMemoryCategory(int argc, char *argv[])
+{
+ GSM_Category Category;
+ GSM_CategoryStatus Status;
+ int j, count;
+
+ unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
+ int Length;
+ bool Number = true;;
+
+ GSM_Init(true);
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ Length = strlen(argv[2]);
+ for (j = 0; j < Length; j++) {
+ if (!isdigit(argv[2][j])) {
+ Number = false;
+ break;
+ }
+ }
+
+ if (Number) {
+ j = atoi(argv[2]);
+ if (j > 0) {
+ ListMemoryCategoryEntries(j);
+ }
+ } else {
+ if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
+ printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
+ Length = GSM_MAX_CATEGORY_NAME_LENGTH;
+ }
+ EncodeUnicode(Text, argv[2], Length);
+
+ Category.Type = Category_Phonebook;
+ Status.Type = Category_Phonebook;
+
+ if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
+ for (count=0,j=1;count<Status.Used;j++) {
+ Category.Location=j;
+ error=Phone->GetCategory(&s, &Category);
+
+ if (error != ERR_EMPTY) {
+ count++;
+ if (mystrstr(Category.Name, Text) != NULL) {
+ ListMemoryCategoryEntries(j);
+ }
+ }
+ }
+ }
+ }
+ GSM_Terminate();
+}
+
+static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
+{
+ switch (sms.PDU) {
+ case SMS_Status_Report:
+ printmsg("SMS status report\n");
+ 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;
+ }
+ printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
+ printmsg("Reference number: 0x%02X\n",sms.MessageReference);
+ printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
+ printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
+ printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
+ printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
+ printmsg("Details : ");
+ if (sms.DeliveryStatus & 0x40) {
+ if (sms.DeliveryStatus & 0x20) {
+ printmsg("Temporary error, ");
+ } else {
+ printmsg("Permanent error, ");
+ }
+ } else if (sms.DeliveryStatus & 0x20) {
+ printmsg("Temporary error, ");
+ }
+ switch (sms.DeliveryStatus) {
+ case 0x00: printmsg("SM received by the SME"); break;
+ case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
+ case 0x02: printmsg("SM replaced by the SC"); break;
+ case 0x20: printmsg("Congestion"); break;
+ case 0x21: printmsg("SME busy"); break;
+ case 0x22: printmsg("No response from SME"); break;
+ case 0x23: printmsg("Service rejected"); break;
+ case 0x24: printmsg("Quality of service not aviable"); break;
+ case 0x25: printmsg("Error in SME"); break;
+ case 0x40: printmsg("Remote procedure error"); break;
+ case 0x41: printmsg("Incompatibile destination"); break;
+ case 0x42: printmsg("Connection rejected by SME"); break;
+ case 0x43: printmsg("Not obtainable"); break;
+ case 0x44: printmsg("Quality of service not available"); break;
+ case 0x45: printmsg("No internetworking available"); break;
+ case 0x46: printmsg("SM Validity Period Expired"); break;
+ case 0x47: printmsg("SM deleted by originating SME"); break;
+ case 0x48: printmsg("SM Deleted by SC Administration"); break;
+ case 0x49: printmsg("SM does not exist"); break;
+ case 0x60: printmsg("Congestion"); break;
+ case 0x61: printmsg("SME busy"); break;
+ case 0x62: printmsg("No response from SME"); break;
+ case 0x63: printmsg("Service rejected"); break;
+ case 0x64: printmsg("Quality of service not available"); break;
+ case 0x65: printmsg("Error in SME"); break;
+ default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus); break;
+ }
+ printf("\n");
+ break;
+ case SMS_Deliver:
+ 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));
+ /* No break. The only difference for SMS_Deliver and SMS_Submit is,
+ * that SMS_Deliver contains additional data. We wrote them and then go
+ * for data shared with SMS_Submit
+ */
+ case SMS_Submit:
+ if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
+ /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
+ if (sms.PDU==SMS_Submit) {
+ printmsg("SMS message\n");
+ printmsg("Reference number : 0x%02X\n",sms.MessageReference);
+ }
+ if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
+ printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
+ }
+ if (sms.Class != -1) {
+ printmsg("Class : %i\n",sms.Class);
+ }
+ printmsg("Coding : ");
+ switch (sms.Coding) {
+ case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
+ case SMS_Coding_Default : printmsg("Default GSM alphabet\n"); break;
+ case SMS_Coding_8bit : printmsg("8 bit\n"); break;
+ }
+ 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;
+ }
+ printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
+ if (sms.UDH.Type != UDH_NoUDH) {
+ printmsg("User Data Header : ");
+ switch (sms.UDH.Type) {
+ case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
+ case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
+ case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
+ case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
+ case UDH_DisableFax : printmsg("Disables fax indicator"); break;
+ case UDH_EnableFax : printmsg("Enables fax indicator"); break;
+ case UDH_DisableEmail : printmsg("Disables email indicator"); break;
+ case UDH_EnableEmail : printmsg("Enables email indicator"); break;
+ case UDH_VoidSMS : printmsg("Void SMS"); break;
+ case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break;
+ case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break;
+ case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
+ case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break;
+ case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break;
+ case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break;
+ case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break;
+ case UDH_NokiaProfileLong : printmsg("Nokia profile"); break;
+ case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break;
+ case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break;
+ case UDH_UserUDH : printmsg("User UDH"); break;
+ case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break;
+ case UDH_NoUDH: break;
+ }
+ if (sms.UDH.Type != UDH_NoUDH) {
+ if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit);
+ if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit);
+ if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) {
+ if (displayudh) {
+ printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts);
+ } else {
+ printmsg(", %i parts",sms.UDH.AllParts);
+ }
+ }
+ }
+ printf("\n");
+ }
+ if (displaytext) {
+ printf("\n");
+ if (sms.Coding!=SMS_Coding_8bit) {
+ printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
+ } else {
+ printmsg("8 bit SMS, cannot be displayed here\n");
+ }
+ }
+ break;
+ }
+}
+//#if 0
+static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
+{
+ GSM_MultiPartSMSInfo SMSInfo;
+ bool RetVal,udhinfo=true;
+ int j;
+
+ /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
+ RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
+
+ if (eachsms) {
+ if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
+ if (RetVal && !udhinfo) {
+ displaysinglesmsinfo(sms.SMS[0],false,false);
+ printf("\n");
+ } else {
+ for (j=0;j<sms.Number;j++) {
+ displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo);
+ printf("\n");
+ }
+ }
+ } else {
+ for (j=0;j<sms.Number;j++) {
+ displaysinglesmsinfo(sms.SMS[j],!RetVal,true);
+ printf("\n");
+ }
+ }
+ if (!RetVal) {
+ GSM_FreeMultiPartSMSInfo(&SMSInfo);
+ return;
+ }
+
+ if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n");
+
+ for (i=0;i<SMSInfo.EntriesNum;i++) {
+ switch (SMSInfo.Entries[i].ID) {
+ case SMS_NokiaRingtone:
+ printmsg("Ringtone \"%s\"\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Ringtone->Name));
+ saverttl(stdout,SMSInfo.Entries[i].Ringtone);
+ printf("\n");
+ if (s.Phone.Functions->PlayTone!=NOTSUPPORTED &&
+ s.Phone.Functions->PlayTone!=NOTIMPLEMENTED) {
+ if (answer_yes("Do you want to play it")) GSM_PlayRingtone(*SMSInfo.Entries[i].Ringtone);
+ }
+ break;
+ case SMS_NokiaCallerLogo:
+ printmsg("Caller logo\n\n");
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_NokiaOperatorLogo:
+ printmsg("Operator logo for %s network (%s, %s)\n\n",
+ SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode,
+ DecodeUnicodeConsole(GSM_GetNetworkName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)),
+ DecodeUnicodeConsole(GSM_GetCountryName(SMSInfo.Entries[i].Bitmap->Bitmap[0].NetworkCode)));
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_NokiaScreenSaverLong:
+ printmsg("Screen saver\n");
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_NokiaPictureImageLong:
+ printmsg("Picture Image\n");
+ if (UnicodeLength(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text)!=0) printmsg("Text: \"%s\"\n\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Bitmap->Bitmap[0].Text));
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_NokiaProfileLong:
+ printmsg("Profile\n");
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_ConcatenatedTextLong:
+ case SMS_ConcatenatedAutoTextLong:
+ case SMS_ConcatenatedTextLong16bit:
+ case SMS_ConcatenatedAutoTextLong16bit:
+ printmsg("%s\n",DecodeUnicodeConsole(SMSInfo.Entries[i].Buffer));
+ break;
+ case SMS_EMSFixedBitmap:
+ case SMS_EMSVariableBitmap:
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_EMSAnimation:
+ /* Can't show animation, we show first frame */
+ GSM_PrintBitmap(stdout,&SMSInfo.Entries[i].Bitmap->Bitmap[0]);
+ break;
+ case SMS_EMSPredefinedSound:
+ printmsg("\nEMS sound ID: %i\n",SMSInfo.Entries[i].Number);
+ break;
+ case SMS_EMSPredefinedAnimation:
+ printmsg("\nEMS animation ID: %i\n",SMSInfo.Entries[i].Number);
+ break;
+ default:
+ printf("Error\n");
+ break;
+ }
+ }
+ printf("\n");
+ GSM_FreeMultiPartSMSInfo(&SMSInfo);
+}
+
+static void NetworkInfo(int argc, char *argv[])
+{
+ GSM_NetworkInfo NetInfo;
+
+ GSM_Init(true);
+
+ if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
+ printmsg("Network state : ");
+ switch (NetInfo.State) {
+ case GSM_HomeNetwork : printmsg("home network\n"); break;
+ case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
+ case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
+ case GSM_NoNetwork : printmsg("not logged into network\n"); break;
+ case GSM_RegistrationDenied : printmsg("registration to network denied\n"); break;
+ case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
+ default : printmsg("unknown\n");
+ }
+ if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
+ printmsg("Network : %s (%s", NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
+ printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
+ printmsg(", LAC %s, CellID %s\n", NetInfo.LAC,NetInfo.CID);
+ if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
+ printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
+ }
+ }
+ }
+ GSM_Terminate();
+}
+
+static void IncomingSMS(char *Device, GSM_SMSMessage sms)
+{
+ GSM_MultiSMSMessage SMS;
+
+ printmsg("SMS message received\n");
+ SMS.Number = 1;
+ memcpy(&SMS.SMS[0],&sms,sizeof(GSM_SMSMessage));
+ displaymultismsinfo(SMS,false,false);
+}
+
+static void IncomingCB(char *Device, GSM_CBMessage CB)
+{
+ printmsg("CB message received\n");
+ printmsg("Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeConsole(CB.Text));
+}
+
+static void IncomingCall(char *Device, GSM_Call call)
+{
+ printmsg("Call info : ");
+ if (call.CallIDAvailable) printmsg("ID %i, ",call.CallID);
+ switch(call.Status) {
+ case GSM_CALL_IncomingCall : printmsg("incoming call from \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
+ case GSM_CALL_OutgoingCall : printmsg("outgoing call to \"%s\"\n",DecodeUnicodeConsole(call.PhoneNumber)); break;
+ case GSM_CALL_CallStart : printmsg("call started\n"); break;
+ case GSM_CALL_CallEnd : printmsg("end of call (unknown side)\n"); break;
+ case GSM_CALL_CallLocalEnd : printmsg("call end from our side\n"); break;
+ case GSM_CALL_CallRemoteEnd : printmsg("call end from remote side (code %i)\n",call.StatusCode); break;
+ case GSM_CALL_CallEstablished : printmsg("call established. Waiting for answer\n"); break;
+ case GSM_CALL_CallHeld : printmsg("call held\n"); break;
+ case GSM_CALL_CallResumed : printmsg("call resumed\n"); break;
+ case GSM_CALL_CallSwitched : printmsg("call switched\n"); break;
+ }
+}
+
+static void IncomingUSSD(char *Device, char *Buffer)
+{
+ printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
+}
+
+#define CHECKMEMORYSTATUS(x, m, a1, b1) { \
+ x.MemoryType=m; \
+ if (Phone->GetMemoryStatus(&s, &x) == ERR_NONE) \
+ printmsg("%s %03d, %s %03d\n", a1, x.MemoryUsed, b1, x.MemoryFree); \
+}
+
+static void Monitor(int argc, char *argv[])
+{
+ GSM_MemoryStatus MemStatus;
+ GSM_SMSMemoryStatus SMSStatus;
+ GSM_ToDoStatus ToDoStatus;
+ GSM_CalendarStatus CalendarStatus;
+ GSM_NetworkInfo NetInfo;
+ GSM_BatteryCharge BatteryCharge;
+ GSM_SignalQuality SignalQuality;
+ int count = -1;
+
+ if (argc >= 3) {
+ count = atoi(argv[2]);
+ if (count <= 0) count = -1;
+ }
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+ printmsg("Entering monitor mode...\n\n");
+
+ GSM_Init(true);
+
+ s.User.IncomingSMS = IncomingSMS;
+ s.User.IncomingCB = IncomingCB;
+ s.User.IncomingCall = IncomingCall;
+ s.User.IncomingUSSD = IncomingUSSD;
+
+ error=Phone->SetIncomingSMS (&s,true);
+ printmsg("Enabling info about incoming SMS : %s\n",print_error(error,NULL,s.msg));
+ error=Phone->SetIncomingCB (&s,true);
+ printmsg("Enabling info about incoming CB : %s\n",print_error(error,NULL,s.msg));
+ error=Phone->SetIncomingCall (&s,true);
+ printmsg("Enabling info about calls : %s\n",print_error(error,NULL,s.msg));
+ error=Phone->SetIncomingUSSD (&s,true);
+ printmsg("Enabling info about USSD : %s\n\n",print_error(error,NULL,s.msg));
+
+ while (!gshutdown && count != 0) {
+ if (count > 0) count--;
+ CHECKMEMORYSTATUS(MemStatus,MEM_SM,"SIM phonebook : Used","Free");
+ if (gshutdown) break;
+ CHECKMEMORYSTATUS(MemStatus,MEM_DC,"Dialled numbers : Used","Free");
+ if (gshutdown) break;
+ CHECKMEMORYSTATUS(MemStatus,MEM_RC,"Received numbers : Used","Free");
+ if (gshutdown) break;
+ CHECKMEMORYSTATUS(MemStatus,MEM_MC,"Missed numbers : Used","Free");
+ if (gshutdown) break;
+ CHECKMEMORYSTATUS(MemStatus,MEM_ON,"Own numbers : Used","Free");
+ if (gshutdown) break;
+ CHECKMEMORYSTATUS(MemStatus,MEM_ME,"Phone phonebook : Used","Free");
+ if (gshutdown) break;
+ if (Phone->GetToDoStatus(&s, &ToDoStatus) == ERR_NONE) {
+ printmsg("ToDos : Used %d\n", ToDoStatus.Used);
+ }
+ if (gshutdown) break;
+ if (Phone->GetCalendarStatus(&s, &CalendarStatus) == ERR_NONE) {
+ printmsg("Calendar : Used %d\n", CalendarStatus.Used);
+ }
+ if (gshutdown) break;
+ if (Phone->GetBatteryCharge(&s,&BatteryCharge)==ERR_NONE) {
+ if (BatteryCharge.BatteryPercent != -1) printmsg("Battery level : %i percent\n", BatteryCharge.BatteryPercent);
+ if (BatteryCharge.ChargeState != 0) {
+ printmsg("Charge state : ");
+ switch (BatteryCharge.ChargeState) {
+ case GSM_BatteryPowered:
+ printmsg("powered from battery");
+ break;
+ case GSM_BatteryConnected:
+ printmsg("battery connected, but not powered from battery");
+ break;
+ case GSM_BatteryNotConnected:
+ printmsg("battery not connected");
+ break;
+ case GSM_PowerFault:
+ printmsg("detected power failure");
+ break;
+ default:
+ printmsg("unknown");
+ break;
+ }
+ printf("\n");
+ }
+ }
+ if (gshutdown) break;
+ if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) {
+ if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength);
+ if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent);
+ if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate);
+ }
+ if (gshutdown) break;
+ if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) {
+ if (SMSStatus.SIMSize > 0) {
+ printmsg("SIM SMS status : %i used, %i unread, %i locations\n",
+ SMSStatus.SIMUsed,
+ SMSStatus.SIMUnRead,
+ SMSStatus.SIMSize);
+ }
+
+ if (SMSStatus.PhoneSize > 0) {
+ printmsg("Phone SMS status : %i used, %i unread, %i locations",
+ SMSStatus.PhoneUsed,
+ SMSStatus.PhoneUnRead,
+ SMSStatus.PhoneSize);
+ if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed);
+ printf("\n");
+ }
+ }
+ if (gshutdown) break;
+ if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
+ printmsg("Network state : ");
+ switch (NetInfo.State) {
+ case GSM_HomeNetwork : printmsg("home network\n"); break;
+ case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
+ case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
+ case GSM_NoNetwork : printmsg("not logged into network\n"); break;
+ case GSM_RegistrationDenied : printmsg("registration to network denied\n"); break;
+ case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
+ default : printmsg("unknown\n");
+ }
+ if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
+ printmsg("Network : %s (%s", NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
+ printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
+ printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID);
+ if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
+ printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
+ }
+ }
+ }
+ printf("\n");
+ }
+
+ printmsg("Leaving monitor mode...\n");
+
+ GSM_Terminate();
+}
+
+static void GetUSSD(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ s.User.IncomingUSSD = IncomingUSSD;
+
+ error=Phone->SetIncomingUSSD(&s,true);
+ Print_Error(error);
+
+ error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
+ Print_Error(error);
+
+ while (!gshutdown) GSM_ReadDevice(&s,true);
+
+ GSM_Terminate();
+}
+
+static void GetSMSC(int argc, char *argv[])
+{
+ GSM_SMSC smsc;
+ int start, stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ smsc.Location=i;
+
+ error=Phone->GetSMSC(&s, &smsc);
+ Print_Error(error);
+
+ if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) {
+ printmsg("%i. Set %i\n",smsc.Location, smsc.Location);
+ } else {
+ printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name));
+ }
+ printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number));
+ printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber));
+
+ printmsg("Format : ");
+ switch (smsc.Format) {
+ case SMS_FORMAT_Text : printmsg("Text"); break;
+ case SMS_FORMAT_Fax : printmsg("Fax"); break;
+ case SMS_FORMAT_Email : printmsg("Email"); break;
+ case SMS_FORMAT_Pager : printmsg("Pager"); break;
+ }
+ printf("\n");
+
+ printmsg("Validity : ");
+ switch (smsc.Validity.Relative) {
+ case SMS_VALID_1_Hour : printmsg("1 hour"); break;
+ case SMS_VALID_6_Hours : printmsg("6 hours"); break;
+ case SMS_VALID_1_Day : printmsg("24 hours"); break;
+ case SMS_VALID_3_Days : printmsg("72 hours"); break;
+ case SMS_VALID_1_Week : printmsg("1 week"); break;
+ case SMS_VALID_Max_Time : printmsg("Maximum time"); break;
+ default : printmsg("Unknown");
+ }
+ printf("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void GetSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage sms;
+ GSM_SMSFolders folders;
+ int start, stop;
+ int j;
+
+ GetStartStop(&start, &stop, 3, argc, argv);
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ for (j = start; j <= stop; j++) {
+ sms.SMS[0].Folder = atoi(argv[2]);
+ sms.SMS[0].Location = j;
+ error=Phone->GetSMS(&s, &sms);
+ switch (error) {
+ case ERR_EMPTY:
+ printmsg("Location %i\n",sms.SMS[0].Location);
+ printmsg("Empty\n");
+ break;
+ default:
+ Print_Error(error);
+ printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
+ switch(sms.SMS[0].Memory) {
+ case MEM_SM: printmsg(", SIM memory"); break;
+ case MEM_ME: printmsg(", phone memory"); break;
+ case MEM_MT: printmsg(", phone or SIM memory"); break;
+ default : break;
+ }
+ if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
+ printf("\n");
+ displaymultismsinfo(sms,false,false);
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void DeleteSMS(int argc, char *argv[])
+{
+ GSM_SMSMessage sms;
+ int start, stop;
+
+ sms.Folder=atoi(argv[2]);
+
+ GetStartStop(&start, &stop, 3, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ sms.Folder = 0;
+ sms.Location = i;
+ error=Phone->DeleteSMS(&s, &sms);
+ Print_Error(error);
+ }
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+ GSM_Terminate();
+}
+
+static void GetAllSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage sms;
+ GSM_SMSFolders folders;
+ bool start = true;
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ fprintf(stderr,"Reading: ");
+ while (error == ERR_NONE) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->GetNextSMS(&s, &sms, start);
+ switch (error) {
+ case ERR_EMPTY:
+ break;
+ default:
+ Print_Error(error);
+ printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
+ switch(sms.SMS[0].Memory) {
+ case MEM_SM: printmsg(", SIM memory"); break;
+ case MEM_ME: printmsg(", phone memory"); break;
+ case MEM_MT: printmsg(", phone or SIM memory"); break;
+ default : break;
+ }
+ if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
+ printf("\n");
+ displaymultismsinfo(sms,false,false);
+ }
+ fprintf(stderr,"*");
+ start=false;
+ }
+ fprintf(stderr,"\n");
+
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+ GSM_Terminate();
+}
+
+static void GetEachSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage *GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms;
+ int GetSMSNumber = 0,i,j;
+ GSM_SMSFolders folders;
+ bool start = true, ems = true;
+
+ GetSMS[0] = NULL;
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ fprintf(stderr,"Reading: ");
+ while (error == ERR_NONE) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->GetNextSMS(&s, &sms, start);
+ switch (error) {
+ case ERR_EMPTY:
+ break;
+ default:
+ Print_Error(error);
+ GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage));
+ if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY);
+ GetSMS[GetSMSNumber+1] = NULL;
+ memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage));
+ GetSMSNumber++;
+ if (GetSMSNumber==PHONE_MAXSMSINFOLDER) {
+ fprintf(stderr,"SMS counter overflow\n");
+ return;
+ }
+ }
+ fprintf(stderr,"*");
+ start=false;
+ }
+ fprintf(stderr,"\n");
+
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+
+ error = GSM_LinkSMS(GetSMS, SortedSMS, ems);
+ Print_Error(error);
+
+ i=0;
+ while(GetSMS[i] != NULL) {
+ free(GetSMS[i]);
+ GetSMS[i] = NULL;
+ i++;
+ }
+
+ i=0;
+ while(SortedSMS[i] != NULL) {
+ for (j=0;j<SortedSMS[i]->Number;j++) {
+ if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) {
+ printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name));
+ switch(SortedSMS[i]->SMS[j].Memory) {
+ case MEM_SM: printmsg(", SIM memory"); break;
+ case MEM_ME: printmsg(", phone memory"); break;
+ case MEM_MT: printmsg(", phone or SIM memory"); break;
+ default : break;
+ }
+ if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder");
+ printf("\n");
+ }
+ }
+ displaymultismsinfo(*SortedSMS[i],true,ems);
+
+ free(SortedSMS[i]);
+ SortedSMS[i] = NULL;
+ i++;
+ }
+
+ GSM_Terminate();
+}
+
+static void GetSMSFolders(int argc, char *argv[])
+{
+ GSM_SMSFolders folders;
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s,&folders);
+ Print_Error(error);
+
+ for (i=0;i<folders.Number;i++) {
+ printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name));
+ switch(folders.Folder[i].Memory) {
+ case MEM_SM: printmsg(", SIM memory"); break;
+ case MEM_ME: printmsg(", phone memory"); break;
+ case MEM_MT: printmsg(", phone or SIM memory"); break;
+ default : break;
+ }
+ if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder");
+ printf("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void GetRingtone(int argc, char *argv[])
+{
+ GSM_Ringtone ringtone;
+ bool PhoneRingtone = false;
+
+ if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true;
+
+ GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
+
+ GSM_Init(true);
+
+ ringtone.Format=0;
+
+ error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
+ Print_Error(error);
+
+ switch (ringtone.Format) {
+ case RING_NOTETONE : printmsg("Smart Messaging"); break;
+ case RING_NOKIABINARY : printmsg("Nokia binary"); break;
+ case RING_MIDI : printmsg("Midi format"); break;
+ }
+ printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
+
+ if (argc==4) {
+ error=GSM_SaveRingtoneFile(argv[3], &ringtone);
+ Print_Error(error);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetRingtonesList(int argc, char *argv[])
+{
+ GSM_AllRingtonesInfo Info;
+ int i;
+
+ GSM_Init(true);
+
+ error=Phone->GetRingtonesInfo(&s,&Info);
+ Print_Error(error);
+
+ GSM_Terminate();
+
+ for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
+}
+
+static void DialVoice(int argc, char *argv[])
+{
+ GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence;
+
+ if (argc > 3) {
+ if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber;
+ } else if (mystrncasecmp(argv[3],"hide",0)) { ShowNumber = GSM_CALL_HideNumber;
+ } else {
+ printmsg("Unknown parameter (\"%s\")\n",argv[3]);
+ exit(-1);
+ }
+ }
+
+ GSM_Init(true);
+
+ error=Phone->DialVoice(&s, argv[2], ShowNumber);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void CancelCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ if (argc>2) {
+ error=Phone->CancelCall(&s,atoi(argv[2]),false);
+ } else {
+ error=Phone->CancelCall(&s,0,true);
+ }
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void AnswerCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ if (argc>2) {
+ error=Phone->AnswerCall(&s,atoi(argv[2]),false);
+ } else {
+ error=Phone->AnswerCall(&s,0,true);
+ }
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void UnholdCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->UnholdCall(&s,atoi(argv[2]));
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void HoldCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->HoldCall(&s,atoi(argv[2]));
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void ConferenceCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->ConferenceCall(&s,atoi(argv[2]));
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void SplitCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->SplitCall(&s,atoi(argv[2]));
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void SwitchCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ if (argc > 2) {
+ error=Phone->SwitchCall(&s,atoi(argv[2]),false);
+ } else {
+ error=Phone->SwitchCall(&s,0,true);
+ }
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void TransferCall(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ if (argc > 2) {
+ error=Phone->TransferCall(&s,atoi(argv[2]),false);
+ } else {
+ error=Phone->TransferCall(&s,0,true);
+ }
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void AddSMSFolder(int argc, char *argv[])
+{
+ unsigned char buffer[200];
+
+ GSM_Init(true);
+
+ EncodeUnicode(buffer,argv[2],strlen(argv[2]));
+ error=Phone->AddSMSFolder(&s,buffer);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void Reset(int argc, char *argv[])
+{
+ bool hard;
+
+ if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false;
+ } else if (mystrncasecmp(argv[2],"HARD",0)) { hard=true;
+ } else {
+ printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ error=Phone->Reset(&s, hard);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void PrintCalendar(GSM_CalendarEntry *Note)
+{
+ int i_age = 0,i;
+ GSM_DateTime Alarm,DateTime;
+ GSM_MemoryEntry entry;
+ unsigned char *name;
+
+ bool repeating = false;
+ int repeat_dayofweek = -1;
+ int repeat_day = -1;
+ int repeat_weekofmonth = -1;
+ int repeat_month = -1;
+ int repeat_frequency = -1;
+ GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
+ GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
+
+ printmsg("Location : %d\n", Note->Location);
+ printmsg("Note type : ");
+ switch (Note->Type) {
+ case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break;
+ case GSM_CAL_CALL : printmsg("Call\n"); break;
+ case GSM_CAL_MEETING : printmsg("Meeting\n"); break;
+ case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break;
+ case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break;
+ case GSM_CAL_TRAVEL : printmsg("Travel\n"); break;
+ case GSM_CAL_VACATION : printmsg("Vacation\n"); break;
+ case GSM_CAL_ALARM : printmsg("Alarm\n"); break;
+ case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break;
+ case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break;
+ case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break;
+ case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break;
+ case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break;
+ case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break;
+ case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break;
+ case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break;
+ case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break;
+ case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break;
+ case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break;
+ case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break;
+ case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break;
+ case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break;
+ case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break;
+ case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break;
+ case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break;
+ case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break;
+ case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break;
+ case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break;
+ default : printmsg("UNKNOWN\n");
+ }
+ Alarm.Year = 0;
+
+ repeating = false;
+ repeat_dayofweek = -1;
+ repeat_day = -1;
+ repeat_weekofmonth = -1;
+ repeat_month = -1;
+ repeat_frequency = -1;
+ repeat_startdate.Day = 0;
+ repeat_stopdate.Day = 0;
+
+ for (i=0;i<Note->EntriesNum;i++) {
+ switch (Note->Entries[i].EntryType) {
+ case CAL_START_DATETIME:
+ printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
+ memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
+ break;
+ case CAL_END_DATETIME:
+ printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
+ memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
+ break;
+ case CAL_ALARM_DATETIME:
+ printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
+ memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
+ break;
+ case CAL_SILENT_ALARM_DATETIME:
+ printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
+ memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
+ break;
+ case CAL_RECURRANCE:
+ printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,
+ ((Note->Entries[i].Number/24)>1) ? "s":"" );
+ break;
+ case CAL_TEXT:
+ printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
+ break;
+ case CAL_LOCATION:
+ printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
+ break;
+ case CAL_PHONE:
+ printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
+ break;
+ case CAL_PRIVATE:
+ printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
+ break;
+ case CAL_CONTACTID:
+ entry.Location = Note->Entries[i].Number;
+ entry.MemoryType = MEM_ME;
+ error=Phone->GetMemory(&s, &entry);
+ if (error == ERR_NONE) {
+ name = GSM_PhonebookGetEntryName(&entry);
+ if (name != NULL) {
+ printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
+ } else {
+ printmsg("Contact ID : %d\n",Note->Entries[i].Number);
+ }
+ } else {
+ printmsg("Contact ID : %d\n",Note->Entries[i].Number);
+ }
+ break;
+ case CAL_REPEAT_DAYOFWEEK:
+ repeat_dayofweek = Note->Entries[i].Number;
+ repeating = true;
+ break;
+ case CAL_REPEAT_DAY:
+ repeat_day = Note->Entries[i].Number;
+ repeating = true;
+ break;
+ case CAL_REPEAT_WEEKOFMONTH:
+ repeat_weekofmonth = Note->Entries[i].Number;
+ repeating = true;
+ break;
+ case CAL_REPEAT_MONTH:
+ repeat_month = Note->Entries[i].Number;
+ repeating = true;
+ break;
+ case CAL_REPEAT_FREQUENCY:
+ repeat_frequency = Note->Entries[i].Number;
+ repeating = true;
+ break;
+ case CAL_REPEAT_STARTDATE:
+ repeat_startdate = Note->Entries[i].Date;
+ repeating = true;
+ break;
+ case CAL_REPEAT_STOPDATE:
+ repeat_stopdate = Note->Entries[i].Date;
+ repeating = true;
+ break;
+ }
+ }
+ if (repeating) {
+ printmsg("Repeating : ");
+ if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) {
+ printmsg("Forever");
+ } else if (repeat_startdate.Day == 0) {
+ printmsg("Till %s", OSDate(repeat_stopdate));
+ } else if (repeat_stopdate.Day == 0) {
+ printmsg("Since %s", OSDate(repeat_startdate));
+ } else {
+ printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate));
+ }
+ if (repeat_frequency != -1) {
+ if (repeat_frequency == 1) {
+ printmsg (" on each ");
+ } else {
+ printmsg(" on each %d. ", repeat_frequency);
+ }
+ if (repeat_dayofweek > 0) {
+ switch (repeat_dayofweek) {
+ case 1 : printmsg("Monday"); break;
+ case 2 : printmsg("Tuesday"); break;
+ case 3 : printmsg("Wednesday"); break;
+ case 4 : printmsg("Thursday"); break;
+ case 5 : printmsg("Friday"); break;
+ case 6 : printmsg("Saturday"); break;
+ case 7 : printmsg("Sunday"); break;
+ default: printmsg("Bad day!"); break;
+ }
+ if (repeat_weekofmonth > 0) {
+ printmsg(" in %d. week of ", repeat_weekofmonth);
+ } else {
+ printmsg(" in ");
+ }
+ if (repeat_month > 0) {
+ switch(repeat_month) {
+ case 1 : printmsg("January"); break;
+ case 2 : printmsg("February"); break;
+ case 3 : printmsg("March"); break;
+ case 4 : printmsg("April"); break;
+ case 5 : printmsg("May"); break;
+ case 6 : printmsg("June"); break;
+ case 7 : printmsg("July"); break;
+ case 8 : printmsg("August"); break;
+ case 9 : printmsg("September"); break;
+ case 10: printmsg("October"); break;
+ case 11: printmsg("November"); break;
+ case 12: printmsg("December"); break;
+ default: printmsg("Bad month!"); break;
+ }
+ } else {
+ printmsg("each month");
+ }
+ } else if (repeat_day > 0) {
+ printmsg("%d. day of ", repeat_day);
+ if (repeat_month > 0) {
+ switch(repeat_month) {
+ case 1 : printmsg("January"); break;
+ case 2 : printmsg("February"); break;
+ case 3 : printmsg("March"); break;
+ case 4 : printmsg("April"); break;
+ case 5 : printmsg("May"); break;
+ case 6 : printmsg("June"); break;
+ case 7 : printmsg("July"); break;
+ case 8 : printmsg("August"); break;
+ case 9 : printmsg("September"); break;
+ case 10: printmsg("October"); break;
+ case 11: printmsg("November"); break;
+ case 12: printmsg("December"); break;
+ default: printmsg("Bad month!");break;
+ }
+ } else {
+ printmsg("each month");
+ }
+ } else {
+ printmsg("day");
+ }
+ }
+ printf("\n");
+ }
+ if (Note->Type == GSM_CAL_BIRTHDAY) {
+ if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm);
+ if (DateTime.Year != 0) {
+ i_age = Alarm.Year - DateTime.Year;
+ if (DateTime.Month < Alarm.Month) i_age++;
+ if (DateTime.Month == Alarm.Month &&
+ DateTime.Day < Alarm.Day) {
+ i_age++;
+ }
+ printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years");
+ }
+ }
+ printf("\n");
+}
+
+static void GetCalendar(int argc, char *argv[])
+{
+ GSM_CalendarEntry Note;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ Note.Location=i;
+ error = Phone->GetCalendar(&s, &Note);
+ if (error == ERR_EMPTY) continue;
+ Print_Error(error);
+ PrintCalendar(&Note);
+ }
+
+ GSM_Terminate();
+}
+
+static void DeleteCalendar(int argc, char *argv[])
+{
+ GSM_CalendarEntry Note;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ Note.Location=i;
+ error = Phone->DeleteCalendar(&s, &Note);
+ if (error == ERR_EMPTY) continue;
+ Print_Error(error);
+ PrintCalendar(&Note);
+ }
+
+ GSM_Terminate();
+}
+
+
+static void GetAllCalendar(int argc, char *argv[])
+{
+ GSM_CalendarEntry Note;
+ bool refresh = true;
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ GSM_Init(true);
+
+ while (!gshutdown) {
+ error=Phone->GetNextCalendar(&s,&Note,refresh);
+ if (error == ERR_EMPTY) break;
+ PrintCalendar(&Note);
+ Print_Error(error);
+ refresh=false;
+ }
+
+ GSM_Terminate();
+}
+
+static void GetCalendarSettings(int argc, char *argv[])
+{
+ GSM_CalendarSettings settings;
+
+ GSM_Init(true);
+
+ error=Phone->GetCalendarSettings(&s,&settings);
+ Print_Error(error);
+
+ if (settings.AutoDelete == 0) {
+ printmsg("Auto deleting disabled");
+ } else {
+ printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete);
+ }
+ printmsg("\nWeek start on ");
+ switch(settings.StartDay) {
+ case 1: printmsg("Monday"); break;
+ case 6: printmsg("Saturday"); break;
+ case 7: printmsg("Sunday"); break;
+ }
+ printf("\n");
+
+ GSM_Terminate();
+}
+
+static void GetWAPBookmark(int argc, char *argv[])
+{
+ GSM_WAPBookmark bookmark;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ bookmark.Location=i;
+ error=Phone->GetWAPBookmark(&s,&bookmark);
+ Print_Error(error);
+ printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title));
+ printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address));
+ }
+
+ GSM_Terminate();
+}
+
+static void DeleteWAPBookmark(int argc, char *argv[])
+{
+ GSM_WAPBookmark bookmark;
+ int start, stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ bookmark.Location=i;
+ error=Phone->DeleteWAPBookmark(&s, &bookmark);
+ Print_Error(error);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetGPRSPoint(int argc, char *argv[])
+{
+ GSM_GPRSAccessPoint point;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ point.Location=i;
+ error=Phone->GetGPRSAccessPoint(&s,&point);
+ if (error != ERR_EMPTY) {
+ Print_Error(error);
+ printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name));
+ } else {
+ printmsg("%i. Access point %i",point.Location,point.Location);
+ }
+ if (point.Active) printmsg(" (active)");
+ if (error != ERR_EMPTY) {
+ printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL));
+ } else {
+ printmsg("\n\n");
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void GetBitmap(int argc, char *argv[])
+{
+ GSM_File File;
+ GSM_MultiBitmap MultiBitmap;
+ int location=0;
+ GSM_AllRingtonesInfo Info;
+
+ if (mystrncasecmp(argv[2],"STARTUP",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
+ } else if (mystrncasecmp(argv[2],"CALLER",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo;
+ GetStartStop(&location, NULL, 3, argc, argv);
+ if (location>5) {
+ printmsg("Maximal location for caller logo can be 5\n");
+ exit (-1);
+ }
+ } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_PictureImage;
+ GetStartStop(&location, NULL, 3, argc, argv);
+ } else if (mystrncasecmp(argv[2],"TEXT",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text;
+ } else if (mystrncasecmp(argv[2],"DEALER",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text;
+ } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo;
+ } else {
+ printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+ MultiBitmap.Bitmap[0].Location=location;
+
+ GSM_Init(true);
+
+ error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]);
+ Print_Error(error);
+
+ MultiBitmap.Number = 1;
+
+ error=ERR_NONE;
+ switch (MultiBitmap.Bitmap[0].Type) {
+ case GSM_CallerGroupLogo:
+ if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
+ printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
+ if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)");
+ printf("\n");
+ if (MultiBitmap.Bitmap[0].DefaultRingtone) {
+ printmsg("Ringtone : default\n");
+ } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) {
+ sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID);
+
+ File.Buffer = NULL;
+ File.Used = 0;
+
+ error = ERR_NONE;
+// while (error == ERR_NONE) {
+ error = Phone->GetFilePart(&s,&File);
+// }
+ if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
+ error = ERR_NONE;
+
+ printmsg("Ringtone : \"%s\" (file with ID %i)\n",
+ DecodeUnicodeString(File.Name),
+ MultiBitmap.Bitmap[0].RingtoneID);
+ } else {
+ error = Phone->GetRingtonesInfo(&s,&Info);
+ if (error != ERR_NONE) Info.Number = 0;
+ error = ERR_NONE;
+
+ printmsg("Ringtone : ");
+ if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) {
+ printmsg("\"%s\" (ID %i)\n",
+ DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)),
+ MultiBitmap.Bitmap[0].RingtoneID);
+ } else {
+ printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
+ }
+ }
+ if (MultiBitmap.Bitmap[0].BitmapEnabled) {
+ printmsg("Bitmap : enabled\n");
+ } else {
+ printmsg("Bitmap : disabled\n");
+ }
+ if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
+ break;
+ case GSM_StartupLogo:
+ GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
+ if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
+ break;
+ case GSM_OperatorLogo:
+ if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
+ GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
+ if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
+ } else {
+ printmsg("No operator logo in phone\n");
+ }
+ break;
+ case GSM_PictureImage:
+ GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
+ printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
+ printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
+ if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
+ break;
+ case GSM_WelcomeNote_Text:
+ printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
+ break;
+ case GSM_DealerNote_Text:
+ printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
+ break;
+ default:
+ break;
+ }
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void SetBitmap(int argc, char *argv[])
+{
+ GSM_Bitmap Bitmap, NewBitmap;
+ GSM_MultiBitmap MultiBitmap;
+ GSM_NetworkInfo NetInfo;
+ bool init = true;
+
+ if (mystrncasecmp(argv[2],"STARTUP",0)) {
+ if (argc<4) {
+ printmsg("More arguments required\n");
+ exit(-1);
+ }
+ MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
+ MultiBitmap.Bitmap[0].Location=1;
+ if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2;
+ if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3;
+ if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4;
+ if (MultiBitmap.Bitmap[0].Location == 1) {
+ error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
+ Print_Error(error);
+ }
+ memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
+ } else if (mystrncasecmp(argv[2],"TEXT",0)) {
+ if (argc<4) {
+ printmsg("More arguments required\n");
+ exit(-1);
+ }
+ Bitmap.Type=GSM_WelcomeNote_Text;
+ EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
+ } else if (mystrncasecmp(argv[2],"DEALER",0)) {
+ if (argc<4) {
+ printmsg("More arguments required\n");
+ exit(-1);
+ }
+ Bitmap.Type=GSM_DealerNote_Text;
+ EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
+ } else if (mystrncasecmp(argv[2],"CALLER",0)) {
+ if (argc<4) {
+ printmsg("More arguments required\n");
+ exit(-1);
+ }
+ GetStartStop(&i, NULL, 3, argc, argv);
+ if (i>5 && i!=255) {
+ printmsg("Maximal location for caller logo can be 5\n");
+ exit (-1);
+ }
+ MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo;
+ MultiBitmap.Bitmap[0].Location = i;
+ if (argc>4) {
+ error=GSM_ReadBitmapFile(argv[4],&MultiBitmap);
+ Print_Error(error);
+ }
+ memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
+ if (i!=255) {
+ GSM_Init(true);
+ init = false;
+ NewBitmap.Type = GSM_CallerGroupLogo;
+ NewBitmap.Location = i;
+ error=Phone->GetBitmap(&s,&NewBitmap);
+ Print_Error(error);
+ Bitmap.RingtoneID = NewBitmap.RingtoneID;
+ Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone;
+ Bitmap.FileSystemRingtone = false;
+ CopyUnicodeString(Bitmap.Text, NewBitmap.Text);
+ Bitmap.DefaultName = NewBitmap.DefaultName;
+ }
+ } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
+ if (argc<5) {
+ printmsg("More arguments required\n");
+ exit(-1);
+ }
+ MultiBitmap.Bitmap[0].Type = GSM_PictureImage;
+ MultiBitmap.Bitmap[0].Location = atoi(argv[4]);
+ error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
+ Print_Error(error);
+ memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
+ Bitmap.Text[0]=0;
+ Bitmap.Text[1]=0;
+ if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5]));
+ Bitmap.Sender[0]=0;
+ Bitmap.Sender[1]=0;
+ } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) {
+ Bitmap.Type = GSM_ColourOperatorLogo_ID;
+ strcpy(Bitmap.NetworkCode,"000 00");
+ if (argc > 3) {
+ Bitmap.ID = atoi(argv[3]);
+ if (argc>4) {
+ strncpy(Bitmap.NetworkCode,argv[4],6);
+ } else {
+ GSM_Init(true);
+ init = false;
+ error=Phone->GetNetworkInfo(&s,&NetInfo);
+ Print_Error(error);
+ strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode);
+ }
+ }
+ } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) {
+ Bitmap.Type = GSM_ColourStartupLogo_ID;
+ Bitmap.Location = 0;
+ if (argc > 3) {
+ Bitmap.Location = 1;
+ Bitmap.ID = atoi(argv[3]);
+ }
+ } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) {
+ Bitmap.Type = GSM_ColourWallPaper_ID;
+ Bitmap.ID = 0;
+ if (argc > 3) Bitmap.ID = atoi(argv[3]);
+ } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ MultiBitmap.Bitmap[0].Type = GSM_OperatorLogo;
+ MultiBitmap.Bitmap[0].Location = 1;
+ strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00");
+ if (argc>3) {
+ error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
+ Print_Error(error);
+ if (argc>4) {
+ strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6);
+ } else {
+ GSM_Init(true);
+ init = false;
+ error=Phone->GetNetworkInfo(&s,&NetInfo);
+ Print_Error(error);
+ strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode);
+ }
+ }
+ memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
+ } else {
+ printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ if (init) GSM_Init(true);
+
+ error=Phone->SetBitmap(&s,&Bitmap);
+ Print_Error(error);
+
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+
+ GSM_Terminate();
+}
+
+static void SetRingtone(int argc, char *argv[])
+{
+ GSM_Ringtone ringtone;
+ int i,nextlong=0;
+
+ ringtone.Format = 0;
+ error=GSM_ReadRingtoneFile(argv[2],&ringtone);
+ Print_Error(error);
+ ringtone.Location = 255;
+ for (i=3;i<argc;i++) {
+ switch (nextlong) {
+ case 0:
+ if (mystrncasecmp(argv[i],"-scale",0)) {
+ ringtone.NoteTone.AllNotesScale = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-location",0)) {
+ nextlong = 1;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-name",0)) {
+ nextlong = 2;
+ break;
+ }
+ printmsg("Unknown parameter \"%s\"",argv[i]);
+ exit(-1);
+ case 1:
+ ringtone.Location=atoi(argv[i]);
+ nextlong = 0;
+ break;
+ case 2:
+ EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ }
+ }
+ if (nextlong!=0) {
+ printmsg("Parameter missed...\n");
+ exit(-1);
+ }
+ if (ringtone.Location==0) {
+ printmsg("ERROR: enumerate locations from 1\n");
+ exit (-1);
+ }
+
+ GSM_Init(true);
+ error=Phone->SetRingtone(&s, &ringtone, &i);
+ Print_Error(error);
+#ifdef GSM_ENABLE_BEEP
+ GSM_PhoneBeep();
+#endif
+ GSM_Terminate();
+}
+
+static void DisplaySMSFrame(GSM_SMSMessage *SMS)
+{
+ GSM_Error error;
+ int i, length, current = 0;
+ unsigned char req[1000], buffer[1000], hexreq[1000];
+#ifdef OSCAR
+ unsigned char hexmsg[1000], hexudh[1000];
+#endif
+ error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true);
+ if (error != ERR_NONE) {
+ printmsg("Error\n");
+ exit(-1);
+ }
+ length = length - PHONE_SMSSubmit.Text;
+#ifdef OSCAR
+ for(i=SMS->UDH.Length;i<length;i++) {
+ req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i];
+ }
+ EncodeHexBin(hexmsg, req, length-SMS->UDH.Length);
+
+ for(i=0;i<SMS->UDH.Length;i++) {
+ req[i]=buffer[PHONE_SMSSubmit.Text+i];
+ }
+ EncodeHexBin(hexudh, req, SMS->UDH.Length);
+
+ printf("msg:%s nb:%i udh:%s\n",
+ hexmsg,
+ (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8,
+ hexudh);
+#else
+ for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) {
+ req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i];
+ }
+ req[current++]=buffer[PHONE_SMSSubmit.firstbyte];
+ req[current++]=buffer[PHONE_SMSSubmit.TPMR];
+ for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) {
+ req[current++]=buffer[PHONE_SMSSubmit.Number+i];
+ }
+ req[current++]=buffer[PHONE_SMSSubmit.TPPID];
+ req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
+ req[current++]=buffer[PHONE_SMSSubmit.TPVP];
+ req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
+ for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
+ EncodeHexBin(hexreq, req, current);
+ printmsg("%s\n\n",hexreq);
+#endif
+}
+
+#define SEND_SAVE_SMS_BUFFER_SIZE 10000
+
+static GSM_Error SMSStatus;
+//#if 0
+static void SendSMSStatus (char *Device, int status, int MessageReference)
+{
+ dbgprintf("Sent SMS on device: \"%s\"\n",Device);
+ if (status==0) {
+ printmsg("..OK");
+ SMSStatus = ERR_NONE;
+ } else {
+ printmsg("..error %i",status);
+ SMSStatus = ERR_UNKNOWN;
+ }
+ printmsg(", message reference=%02x\n",MessageReference);
+}
+
+static void SendSaveDisplaySMS(int argc, char *argv[])
+{
+#ifdef GSM_ENABLE_BACKUP
+ GSM_Backup Backup;
+#endif
+ int i,j,z,FramesNum = 0;
+ int Protected = 0;
+ GSM_SMSFolders folders;
+ GSM_MultiSMSMessage sms;
+ GSM_Ringtone ringtone[MAX_MULTI_SMS];
+ GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
+ GSM_MultiPartSMSInfo SMSInfo;
+ GSM_NetworkInfo NetInfo;
+ GSM_MMSIndicator MMSInfo;
+ FILE *ReplaceFile,*f;
+ char ReplaceBuffer2 [200],ReplaceBuffer[200];
+ char InputBuffer [SEND_SAVE_SMS_BUFFER_SIZE/2+1];
+ char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
+ char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
+ char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
+ char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
+ int startarg = 0;
+ int chars_read = 0;
+ int nextlong = 0;
+ bool ReplyViaSameSMSC = false;
+ int SMSCSet = 1;
+ int MaxSMS = -1;
+ bool EMS16Bit = false;
+ bool SendSaved = false;
+
+ /* Parameters required only during saving */
+ int Folder = 1; /*Inbox by default */
+ GSM_SMS_State State = SMS_Sent;
+
+ /* Required only during sending */
+ GSM_SMSValidity Validity;
+ GSM_SMSC PhoneSMSC;
+ bool DeliveryReport = false;
+
+ ReplaceBuffer[0] = 0;
+ ReplaceBuffer[1] = 0;
+ GSM_ClearMultiPartSMSInfo(&SMSInfo);
+ SMSInfo.ReplaceMessage = 0;
+ SMSInfo.EntriesNum = 1;
+
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender,"Gammu",5);
+ Name[0] = 0;
+ Name[1] = 0;
+ startarg = 0;
+ } else {
+ EncodeUnicode(Sender,argv[3],strlen(argv[3]));
+ startarg = 1;
+ Validity.Format = 0;
+ }
+ if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2;
+
+ if (mystrncasecmp(argv[2],"TEXT",0)) {
+ chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
+ if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
+ InputBuffer[chars_read] = 0x00;
+ InputBuffer[chars_read+1] = 0x00;
+ EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
+ SMSInfo.Entries[0].Buffer = Buffer[0];
+ SMSInfo.Entries[0].ID = SMS_Text;
+ SMSInfo.UnicodeCoding = false;
+ startarg += 3;
+ } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
+ SMSInfo.UnicodeCoding = false;
+ SMSInfo.EntriesNum = 1;
+ Buffer[0][0] = 0x00;
+ Buffer[0][1] = 0x00;
+ SMSInfo.Entries[0].Buffer = Buffer[0];
+ SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
+ startarg += 3;
+ } else if (mystrncasecmp(argv[2],"EMS",0)) {
+ SMSInfo.UnicodeCoding = false;
+ SMSInfo.EntriesNum = 0;
+ startarg += 3;
+ } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) {
+ if (argc<6+startarg) {
+ printmsg("Where is ringtone filename ?\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong;
+ SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender,"MMS Info",8);
+ }
+ strcpy(MMSInfo.Address, argv[3+startarg]);
+ strcpy(MMSInfo.Title, argv[4+startarg]);
+ strcpy(MMSInfo.Sender, argv[5+startarg]);
+ startarg += 6;
+ } else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
+ if (argc<4+startarg) {
+ printmsg("Where is ringtone filename ?\n");
+ exit(-1);
+ }
+ ringtone[0].Format=RING_NOTETONE;
+ error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]);
+ Print_Error(error);
+ SMSInfo.Entries[0].ID = SMS_NokiaRingtone;
+ SMSInfo.Entries[0].Ringtone = &ringtone[0];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ CopyUnicodeString(Sender, ringtone[0].Name);
+ EncodeUnicode(Name,"Ringtone ",9);
+ CopyUnicodeString(Name+9*2, ringtone[0].Name);
+ }
+ startarg += 4;
+ } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ if (argc<4+startarg) {
+ printmsg("Where is logo filename ?\n");
+ exit(-1);
+ }
+ bitmap[0].Bitmap[0].Type=GSM_OperatorLogo;
+ error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
+ Print_Error(error);
+ strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00");
+ SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo;
+ SMSInfo.Entries[0].Bitmap = &bitmap[0];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "OpLogo",6);
+ EncodeUnicode(Name,"OpLogo ",7);
+ }
+ startarg += 4;
+ } else if (mystrncasecmp(argv[2],"CALLER",0)) {
+ if (argc<4+startarg) {
+ printmsg("Where is logo filename ?\n");
+ exit(-1);
+ }
+ bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo;
+ error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
+ Print_Error(error);
+ SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo;
+ SMSInfo.Entries[0].Bitmap = &bitmap[0];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Caller",6);
+ }
+ startarg += 4;
+ } else if (mystrncasecmp(argv[2],"ANIMATION",0)) {
+ SMSInfo.UnicodeCoding = false;
+ SMSInfo.EntriesNum = 1;
+ if (argc<4+startarg) {
+ printmsg("Where is number of frames ?\n");
+ exit(-1);
+ }
+ bitmap[0].Number = 0;
+ i = 1;
+ while (1) {
+ bitmap2.Bitmap[0].Type=GSM_StartupLogo;
+ error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2);
+ Print_Error(error);
+ for (j=0;j<bitmap2.Number;j++) {
+ if (bitmap[0].Number == atoi(argv[3+startarg])) break;
+ memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
+ bitmap[0].Number++;
+ }
+ if (bitmap[0].Number == atoi(argv[3+startarg])) break;
+ i++;
+ }
+ SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong;
+ SMSInfo.Entries[0].Bitmap = &bitmap[0];
+ bitmap[0].Bitmap[0].Text[0] = 0;
+ bitmap[0].Bitmap[0].Text[1] = 0;
+ startarg += 4 + atoi(argv[3+startarg]);
+ } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
+ if (argc<4+startarg) {
+ printmsg("Where is logo filename ?\n");
+ exit(-1);
+ }
+ bitmap[0].Bitmap[0].Type=GSM_PictureImage;
+ error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
+ printmsg("File \"%s\"\n",argv[3+startarg]);
+ Print_Error(error);
+ SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong;
+ SMSInfo.Entries[0].Bitmap = &bitmap[0];
+ SMSInfo.UnicodeCoding = false;
+ bitmap[0].Bitmap[0].Text[0] = 0;
+ bitmap[0].Bitmap[0].Text[1] = 0;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Picture",7);
+ EncodeUnicode(Name,"Picture Image",13);
+ }
+ startarg += 4;
+#ifdef GSM_ENABLE_BACKUP
+ } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.WAPBookmark[i]!=NULL) {
+ if (i == atoi(argv[4+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[4+startarg])-1) {
+ printmsg("Bookmark not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
+ SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Bookmark",8);
+ EncodeUnicode(Name,"WAP Bookmark",12);
+ }
+ startarg += 5;
+ } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) {
+ if (argc<6+startarg) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.WAPSettings[i]!=NULL) {
+ if (i == atoi(argv[4+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[4+startarg])-1) {
+ printmsg("WAP settings not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].Settings = NULL;
+ for (j=0;j<Backup.WAPSettings[i]->Number;j++) {
+ switch (Backup.WAPSettings[i]->Settings[j].Bearer) {
+ case WAPSETTINGS_BEARER_GPRS:
+ if (mystrncasecmp(argv[5+startarg],"GPRS",0)) {
+ SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
+ break;
+ }
+ case WAPSETTINGS_BEARER_DATA:
+ if (mystrncasecmp(argv[5+startarg],"DATA",0)) {
+ SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ if (SMSInfo.Entries[0].Settings == NULL) {
+ printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Settings",8);
+ EncodeUnicode(Name,"WAP Settings",12);
+ }
+ startarg += 6;
+ } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.MMSSettings[i]!=NULL) {
+ if (i == atoi(argv[4+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[4+startarg])-1) {
+ printmsg("MMS settings not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].Settings = NULL;
+ for (j=0;j<Backup.MMSSettings[i]->Number;j++) {
+ switch (Backup.MMSSettings[i]->Settings[j].Bearer) {
+ case WAPSETTINGS_BEARER_GPRS:
+ SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j];
+ break;
+ default:
+ break;
+ }
+ }
+ if (SMSInfo.Entries[0].Settings == NULL) {
+ printmsg("Sorry. No GPRS bearer found in MMS settings\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Settings",8);
+ EncodeUnicode(Name,"MMS Settings",12);
+ }
+ startarg += 5;
+ } else if (mystrncasecmp(argv[2],"CALENDAR",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.Calendar[i]!=NULL) {
+ if (i == atoi(argv[4+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[4+startarg])-1) {
+ printmsg("Calendar note not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long;
+ SMSInfo.Entries[0].Calendar = Backup.Calendar[i];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Calendar",8);
+ }
+ startarg += 5;
+ } else if (mystrncasecmp(argv[2],"TODO",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.ToDo[i]!=NULL) {
+ if (i == atoi(argv[4+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[4+startarg])-1) {
+ printmsg("ToDo note not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong;
+ SMSInfo.Entries[0].ToDo = Backup.ToDo[i];
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "ToDo",8);
+ }
+ startarg += 5;
+ } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
+ if (argc<6+startarg) {
+ printmsg("Where is backup filename and location and memory type ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
+ Print_Error(error);
+ i = 0;
+ if (mystrncasecmp(argv[4+startarg],"SM",0)) {
+ while (Backup.SIMPhonebook[i]!=NULL) {
+ if (i == atoi(argv[5+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5+startarg])-1) {
+ printmsg("Phonebook entry not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i];
+ } else if (mystrncasecmp(argv[4+startarg],"ME",0)) {
+ while (Backup.PhonePhonebook[i]!=NULL) {
+ if (i == atoi(argv[5+startarg])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5+startarg])-1) {
+ printmsg("Phonebook entry not found in file\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i];
+ } else {
+ printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]);
+ exit(-1);
+ }
+ if (mystrncasecmp(argv[2],"VCARD10",0)) {
+ SMSInfo.Entries[0].ID = SMS_VCARD10Long;
+ } else {
+ SMSInfo.Entries[0].ID = SMS_VCARD21Long;
+ }
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "VCARD",5);
+ EncodeUnicode(Name, "Phonebook entry",15);
+ }
+ startarg += 6;
+#endif
+ } else if (mystrncasecmp(argv[2],"PROFILE",0)) {
+ SMSInfo.Entries[0].ID = SMS_NokiaProfileLong;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "Profile",7);
+ }
+ startarg += 3;
+ } else {
+ printmsg("What format of sms (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ for (i=startarg;i<argc;i++) {
+ switch (nextlong) {
+ case 0:
+ if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
+ if (mystrncasecmp(argv[i],"-folder",0)) {
+ nextlong=1;
+ continue;
+ }
+ }
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ if (mystrncasecmp(argv[i],"-unread",0)) {
+ State = SMS_UnRead;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-read",0)) {
+ State = SMS_Read;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-unsent",0)) {
+ State = SMS_UnSent;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-sent",0)) {
+ State = SMS_Sent;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-sender",0)) {
+ nextlong=2;
+ continue;
+ }
+ } else {
+ if (mystrncasecmp(argv[i],"-save",0)) {
+ SendSaved=true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-report",0)) {
+ DeliveryReport=true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-validity",0)) {
+ nextlong=10;
+ continue;
+ }
+ }
+ if (mystrncasecmp(argv[i],"-smscset",0)) {
+ nextlong=3;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-smscnumber",0)) {
+ nextlong=4;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-protected",0)) {
+ nextlong=19;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-reply",0)) {
+ ReplyViaSameSMSC=true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-maxsms",0)) {
+ nextlong=21;
+ continue;
+ }
+ if (mystrncasecmp(argv[2],"RINGTONE",0)) {
+ if (mystrncasecmp(argv[i],"-long",0)) {
+ SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-scale",0)) {
+ ringtone[0].NoteTone.AllNotesScale=true;
+ break;
+ }
+ }
+ if (mystrncasecmp(argv[2],"TEXT",0)) {
+ if (mystrncasecmp(argv[i],"-inputunicode",0)) {
+ ReadUnicodeFile(Buffer[0],InputBuffer);
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-16bit",0)) {
+ if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit;
+ if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-flash",0)) {
+ SMSInfo.Class = 0;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-len",0)) {
+ nextlong = 5;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-autolen",0)) {
+ nextlong = 5;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-unicode",0)) {
+ SMSInfo.UnicodeCoding = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-enablevoice",0)) {
+ SMSInfo.Entries[0].ID = SMS_EnableVoice;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-disablevoice",0)) {
+ SMSInfo.Entries[0].ID = SMS_DisableVoice;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-enablefax",0)) {
+ SMSInfo.Entries[0].ID = SMS_EnableFax;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-disablefax",0)) {
+ SMSInfo.Entries[0].ID = SMS_DisableFax;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-enableemail",0)) {
+ SMSInfo.Entries[0].ID = SMS_EnableEmail;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-disableemail",0)) {
+ SMSInfo.Entries[0].ID = SMS_DisableEmail;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-voidsms",0)) {
+ SMSInfo.Entries[0].ID = SMS_VoidSMS;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-replacemessages",0) &&
+ SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) {
+ nextlong = 8;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-replacefile",0)) {
+ nextlong = 9;
+ continue;
+ }
+ }
+ if (mystrncasecmp(argv[2],"PICTURE",0)) {
+ if (mystrncasecmp(argv[i],"-text",0)) {
+ nextlong = 6;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-unicode",0)) {
+ SMSInfo.UnicodeCoding = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) {
+ bitmap[0].Bitmap[0].Type=GSM_StartupLogo;
+ error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]);
+ Print_Error(error);
+ SMSInfo.UnicodeCoding = true;
+ SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong;
+ break;
+ }
+ break;
+ }
+ if (mystrncasecmp(argv[2],"VCARD10",0)) {
+ if (mystrncasecmp(argv[i],"-nokia",0)) {
+ SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long;
+ break;
+ }
+ break;
+ }
+ if (mystrncasecmp(argv[2],"VCARD21",0)) {
+ if (mystrncasecmp(argv[i],"-nokia",0)) {
+ SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long;
+ break;
+ }
+ break;
+ }
+ if (mystrncasecmp(argv[2],"PROFILE",0)) {
+ if (mystrncasecmp(argv[i],"-name",0)) {
+ nextlong = 22;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-ringtone",0)) {
+ nextlong = 23;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-bitmap",0)) {
+ nextlong = 24;
+ break;
+ }
+ }
+ if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
+ if (mystrncasecmp(argv[i],"-unicode",0)) {
+ SMSInfo.UnicodeCoding = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-text",0)) {
+ nextlong = 11;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
+ nextlong = 18;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-defsound",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
+ nextlong = 12;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-defanimation",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
+ nextlong = 12;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone10",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone10long",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone12",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone12long",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-toneSE",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-toneSElong",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 15;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 15;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-animation",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ bitmap[SMSInfo.EntriesNum].Number = 0;
+ nextlong = 16;
+ break;
+ }
+ }
+ if (mystrncasecmp(argv[2],"EMS",0)) {
+ if (mystrncasecmp(argv[i],"-unicode",0)) {
+ SMSInfo.UnicodeCoding = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-16bit",0)) {
+ EMS16Bit = true;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-format",0)) {
+ nextlong = 20;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-text",0)) {
+ nextlong = 11;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-unicodefiletext",0)) {
+ nextlong = 18;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-defsound",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound;
+ nextlong = 12;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-defanimation",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation;
+ nextlong = 12;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone10",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone10long",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone12",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-tone12long",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-toneSE",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-toneSElong",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 14;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-fixedbitmap",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 15;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-variablebitmap",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 15;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ nextlong = 15;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-animation",0)) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation;
+ if (Protected != 0) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true;
+ Protected --;
+ }
+ bitmap[SMSInfo.EntriesNum].Number = 0;
+ nextlong = 16;
+ break;
+ }
+ }
+ if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ if (mystrncasecmp(argv[i],"-netcode",0)) {
+ nextlong = 7;
+ break;
+ }
+ if (mystrncasecmp(argv[i],"-biglogo",0)) {
+ SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong;
+ break;
+ }
+ break;
+ }
+ printmsg("Unknown parameter (\"%s\")\n",argv[i]);
+ exit(-1);
+ break;
+ case 1: /* SMS folder - only during saving SMS */
+ Folder = atoi(argv[i]);
+ nextlong = 0;
+ break;
+ case 2: /* Sender number - only during saving SMS */
+ EncodeUnicode(Sender,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ case 3: /* SMSC set number */
+ SMSCSet = atoi(argv[i]);
+ nextlong = 0;
+ break;
+ case 4: /* Number of SMSC */
+ EncodeUnicode(SMSC,argv[i],strlen(argv[i]));
+ SMSCSet = 0;
+ nextlong = 0;
+ break;
+ case 5: /* Length of text SMS */
+ if (atoi(argv[i])<chars_read)
+ {
+ Buffer[0][atoi(argv[i])*2] = 0x00;
+ Buffer[0][atoi(argv[i])*2+1] = 0x00;
+ }
+ SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
+ if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
+ nextlong = 0;
+ break;
+ case 6: /* Picture Images - text */
+ EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ case 7: /* Operator Logo - network code */
+ strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7);
+ if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) {
+ printmsg("Unknown GSM network code (\"%s\")\n",argv[i]);
+ exit(-1);
+ }
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "OpLogo",6);
+ EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
+ EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
+ if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
+ EncodeUnicode(Name,"OpLogo ",7);
+ CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
+ } else {
+ CopyUnicodeString(Name,Sender);
+ }
+ }
+ nextlong = 0;
+ break;
+ case 8:/* Reject duplicates ID */
+ SMSInfo.ReplaceMessage = atoi(argv[i]);
+ if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) {
+ printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]);
+ exit(-1);
+ }
+ nextlong = 0;
+ break;
+ case 9:/* Replace file for text SMS */
+ ReplaceFile = fopen(argv[i], "rb");
+ if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE);
+ memset(ReplaceBuffer,0,sizeof(ReplaceBuffer));
+ fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile);
+ fclose(ReplaceFile);
+ ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer);
+ for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) {
+ for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) {
+ if (ReplaceBuffer2[z*4] == Buffer[0][j] &&
+ ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) {
+ Buffer[0][j] = ReplaceBuffer2[z*4+2];
+ Buffer[0][j+1] = ReplaceBuffer2[z*4+3];
+ break;
+ }
+ }
+ }
+ nextlong = 0;
+ break;
+ case 10:
+ Validity.Format = SMS_Validity_RelativeFormat;
+ if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour;
+ else if (mystrncasecmp(argv[i],"6HOURS",0)) Validity.Relative = SMS_VALID_6_Hours;
+ else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day;
+ else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days;
+ else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week;
+ else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time;
+ else {
+ printmsg("Unknown validity string (\"%s\")\n",argv[i]);
+ exit(-1);
+ }
+ nextlong = 0;
+ break;
+ case 11:/* EMS text from parameter */
+ EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i]));
+ dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
+ SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 12:/* EMS predefined sound/animation number */
+ SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]);
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 14: /* EMS ringtone - IMelody */
+ ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE;
+ error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]);
+ Print_Error(error);
+ SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum];
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 15:/* EMS bitmap file */
+ bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo;
+ error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]);
+ Print_Error(error);
+ SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 16:/* Number of frames for EMS animation */
+ FramesNum = atoi(argv[i]);
+ if (FramesNum < 1 || FramesNum > 4) {
+ printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]);
+ exit(-1);
+ }
+ bitmap[SMSInfo.EntriesNum].Number = 0;
+ nextlong = 17;
+ break;
+ case 17:/*File for EMS animation */
+ bitmap2.Bitmap[0].Type=GSM_StartupLogo;
+ error=GSM_ReadBitmapFile(argv[i],&bitmap2);
+ for (j=0;j<bitmap2.Number;j++) {
+ if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break;
+ memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap));
+ bitmap[SMSInfo.EntriesNum].Number++;
+ }
+ if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) {
+ SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum];
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ }
+ break;
+ case 18:/* EMS text from Unicode file */
+ f = fopen(argv[i],"rb");
+ if (f == NULL) {
+ printmsg("Can't open file \"%s\"\n",argv[i]);
+ exit(-1);
+ }
+ z=fread(InputBuffer,1,2000,f);
+ InputBuffer[z] = 0;
+ InputBuffer[z+1] = 0;
+ fclose(f);
+ ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer);
+ dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum]));
+ SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong;
+ SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum];
+ SMSInfo.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 19:/* Number of protected items */
+ Protected = atoi(argv[i]);
+ nextlong = 0;
+ break;
+ case 20:/* Formatting text for EMS */
+ if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) {
+ for(j=0;j<(int)strlen(argv[i]);j++) {
+ switch(argv[i][j]) {
+ case 'l': case 'L':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true;
+ break;
+ case 'c': case 'C':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true;
+ break;
+ case 'r': case 'R':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true;
+ break;
+ case 'a': case 'A':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true;
+ break;
+ case 's': case 'S':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true;
+ break;
+ case 'b': case 'B':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true;
+ break;
+ case 'i': case 'I':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true;
+ break;
+ case 'u': case 'U':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true;
+ break;
+ case 't': case 'T':
+ SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true;
+ break;
+ default:
+ printmsg("Unknown parameter \"%c\"\n",argv[i][j]);
+ exit(-1);
+ }
+ }
+ } else {
+ printmsg("Last parameter wasn't text\n");
+ exit(-1);
+ }
+ nextlong = 0;
+ break;
+ case 21:/*MaxSMS*/
+ MaxSMS = atoi(argv[i]);
+ nextlong = 0;
+ break;
+ case 22:/* profile name */
+ EncodeUnicode(Buffer[0],argv[i],strlen(argv[i]));
+ SMSInfo.Entries[0].Buffer = Buffer[0];
+ nextlong = 0;
+ break;
+ case 23:/* profile ringtone */
+ ringtone[0].Format = RING_NOTETONE;
+ error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]);
+ Print_Error(error);
+ SMSInfo.Entries[0].Ringtone = &ringtone[0];
+ nextlong = 0;
+ break;
+ case 24:/* profile bitmap */
+ bitmap[0].Bitmap[0].Type = GSM_PictureImage;
+ error=GSM_ReadBitmapFile(argv[i],&bitmap[0]);
+ Print_Error(error);
+ bitmap[0].Bitmap[0].Text[0] = 0;
+ bitmap[0].Bitmap[0].Text[1] = 0;
+ SMSInfo.Entries[0].Bitmap = &bitmap[0];
+ nextlong = 0;
+ break;
+ }
+ }
+ if (nextlong!=0) {
+ printmsg("Parameter missed...\n");
+ exit(-1);
+ }
+
+ if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) {
+ for (i=0;i<SMSInfo.EntriesNum;i++) {
+ switch (SMSInfo.Entries[i].ID) {
+ case SMS_ConcatenatedTextLong:
+ SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit;
+ default:
+ break;
+
+ }
+ }
+
+ }
+ if (mystrncasecmp(argv[2],"TEXT",0)) {
+ chars_read = UnicodeLength(Buffer[0]);
+ if (chars_read != 0) {
+ /* Trim \n at the end of string */
+ if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0)
+ {
+ Buffer[0][chars_read*2-1] = 0;
+ }
+ }
+ }
+
+ if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
+ if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
+ printmsg("No network code\n");
+ exit(-1);
+ }
+ }
+ } else {
+ GSM_Init(true);
+
+ if (mystrncasecmp(argv[2],"OPERATOR",0)) {
+ if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) {
+ error=Phone->GetNetworkInfo(&s,&NetInfo);
+ Print_Error(error);
+ strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode);
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender, "OpLogo",6);
+ EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3);
+ EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2);
+ if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) {
+ EncodeUnicode(Name,"OpLogo ",7);
+ CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode));
+ } else {
+ CopyUnicodeString(Name,Sender);
+ }
+ }
+ }
+ }
+ }
+
+ error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms);
+ Print_Error(error);
+
+ for (i=0;i<SMSInfo.EntriesNum;i++) {
+ switch (SMSInfo.Entries[i].ID) {
+ case SMS_NokiaRingtone:
+ case SMS_NokiaRingtoneLong:
+ case SMS_NokiaProfileLong:
+ case SMS_EMSSound10:
+ case SMS_EMSSound12:
+ case SMS_EMSSonyEricssonSound:
+ case SMS_EMSSound10Long:
+ case SMS_EMSSound12Long:
+ case SMS_EMSSonyEricssonSoundLong:
+ if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) {
+ printmsg("Warning: ringtone too long. %i percent part cut\n",
+ (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands);
+ }
+ default:
+ break;
+
+ }
+ }
+ if (MaxSMS != -1 && sms.Number > MaxSMS) {
+ printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS);
+ if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate();
+ exit(-1);
+ }
+
+ if (mystrncasecmp(argv[1],"--displaysms",0)) {
+ if (SMSCSet != 0) {
+ printmsg("Use -smscnumber option to give SMSC number\n");
+ exit(-1);
+ }
+
+ for (i=0;i<sms.Number;i++) {
+ sms.SMS[i].Location = 0;
+ sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
+ sms.SMS[i].SMSC.Location = 0;
+ sms.SMS[i].PDU = SMS_Submit;
+ if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
+ CopyUnicodeString(sms.SMS[i].Number, Sender);
+ CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
+ if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
+ DisplaySMSFrame(&sms.SMS[i]);
+ }
+
+ printmsg("\nNumber of SMS: %i\n",sms.Number);
+ exit(sms.Number);
+ }
+ if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
+ if (SMSCSet != 0) {
+ printmsg("Use -smscnumber option to give SMSC number\n");
+ exit(-1);
+ }
+
+ for (i=0;i<sms.Number;i++) {
+ sms.SMS[i].Location = 0;
+ sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
+ sms.SMS[i].SMSC.Location = 0;
+ sms.SMS[i].PDU = SMS_Submit;
+ if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
+ CopyUnicodeString(sms.SMS[i].Number, Sender);
+ CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
+ if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
+ }
+ SMSDaemonSendSMS(argv[4],argv[5],&sms);
+ exit(0);
+ }
+ if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) {
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ if (SendSaved) {
+ if (Validity.Format != 0 && SMSCSet != 0) {
+ PhoneSMSC.Location = SMSCSet;
+ error=Phone->GetSMSC(&s,&PhoneSMSC);
+ Print_Error(error);
+ CopyUnicodeString(SMSC,PhoneSMSC.Number);
+ SMSCSet = 0;
+ }
+
+ s.User.SendSMSStatus = SendSMSStatus;
+
+ signal(SIGINT, interrupt);
+ printmsgerr("If you want break, press Ctrl+C...\n");
+ }
+
+ for (i=0;i<sms.Number;i++) {
+ printmsg("Saving SMS %i/%i\n",i+1,sms.Number);
+// sms.SMS[i].Location = 0;
+ sms.SMS[i].Folder = Folder;
+ sms.SMS[i].State = State;
+ sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
+ sms.SMS[i].SMSC.Location = SMSCSet;
+
+ if (SendSaved) {
+ sms.SMS[i].PDU = SMS_Submit;
+ if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
+ if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity;
+ } else {
+ sms.SMS[i].PDU = SMS_Deliver;
+ }
+
+ CopyUnicodeString(sms.SMS[i].Number, Sender);
+ CopyUnicodeString(sms.SMS[i].Name, Name);
+ if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
+ error=Phone->AddSMS(&s, &sms.SMS[i]);
+ Print_Error(error);
+ printmsg("Saved in folder \"%s\", location %i\n",
+ DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
+
+ if (SendSaved) {
+ printmsg("Sending sms from folder \"%s\", location %i\n",
+ DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
+ SMSStatus = ERR_TIMEOUT;
+ error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location);
+ Print_Error(error);
+ printmsg("....waiting for network answer");
+ while (!gshutdown) {
+ GSM_ReadDevice(&s,true);
+ if (SMSStatus == ERR_UNKNOWN) {
+ GSM_Terminate();
+ exit(-1);
+ }
+ if (SMSStatus == ERR_NONE) break;
+ }
+ }
+ }
+ } else {
+ if (Validity.Format != 0 && SMSCSet != 0) {
+ PhoneSMSC.Location = SMSCSet;
+ error=Phone->GetSMSC(&s,&PhoneSMSC);
+ Print_Error(error);
+ CopyUnicodeString(SMSC,PhoneSMSC.Number);
+ SMSCSet = 0;
+ }
+
+ signal(SIGINT, interrupt);
+ printmsgerr("If you want break, press Ctrl+C...\n");
+
+ s.User.SendSMSStatus = SendSMSStatus;
+
+ for (i=0;i<sms.Number;i++) {
+ printmsg("Sending SMS %i/%i",i+1,sms.Number);
+ sms.SMS[i].Location = 0;
+ sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC;
+ sms.SMS[i].SMSC.Location = SMSCSet;
+ sms.SMS[i].PDU = SMS_Submit;
+ if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report;
+ CopyUnicodeString(sms.SMS[i].Number, Sender);
+ if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC);
+ if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity));
+ SMSStatus = ERR_TIMEOUT;
+ error=Phone->SendSMS(&s, &sms.SMS[i]);
+ Print_Error(error);
+ printmsg("....waiting for network answer");
+ while (!gshutdown) {
+ GSM_ReadDevice(&s,true);
+ if (SMSStatus == ERR_UNKNOWN) {
+ GSM_Terminate();
+ exit(-1);
+ }
+ if (SMSStatus == ERR_NONE) break;
+ }
+ }
+ }
+
+ GSM_Terminate();
+}
+
+#ifdef GSM_ENABLE_BACKUP
+static void SaveFile(int argc, char *argv[])
+{
+ GSM_Backup Backup;
+ int i,j;
+ FILE *file;
+ unsigned char Buffer[10000];
+ GSM_MemoryEntry *pbk;
+
+ if (mystrncasecmp(argv[2],"CALENDAR",0)) {
+ if (argc<5) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[4],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.Calendar[i]!=NULL) {
+ if (i == atoi(argv[5])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5])-1) {
+ printmsg("Calendar note not found in file\n");
+ exit(-1);
+ }
+ j = 0;
+ GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar);
+ } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
+ if (argc<5) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[4],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.WAPBookmark[i]!=NULL) {
+ if (i == atoi(argv[5])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5])-1) {
+ printmsg("WAP bookmark not found in file\n");
+ exit(-1);
+ }
+ j = 0;
+ GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
+ } else if (mystrncasecmp(argv[2],"NOTE",0)) {
+ if (argc<5) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[4],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.Note[i]!=NULL) {
+ if (i == atoi(argv[5])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5])-1) {
+ printmsg("Note not found in file\n");
+ exit(-1);
+ }
+ j = 0;
+ GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]);
+ } else if (mystrncasecmp(argv[2],"TODO",0)) {
+ if (argc<5) {
+ printmsg("Where is backup filename and location ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[4],&Backup);
+ Print_Error(error);
+ i = 0;
+ while (Backup.ToDo[i]!=NULL) {
+ if (i == atoi(argv[5])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[5])-1) {
+ printmsg("ToDo note not found in file\n");
+ exit(-1);
+ }
+ j = 0;
+ GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo);
+ } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
+ if (argc<6) {
+ printmsg("Where is backup filename and location and memory type ?\n");
+ exit(-1);
+ }
+ error=GSM_ReadBackupFile(argv[4],&Backup);
+ Print_Error(error);
+ i = 0;
+ if (mystrncasecmp(argv[5],"SM",0)) {
+ while (Backup.SIMPhonebook[i]!=NULL) {
+ if (i == atoi(argv[6])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[6])-1) {
+ printmsg("Phonebook entry not found in file\n");
+ exit(-1);
+ }
+ pbk = Backup.SIMPhonebook[i];
+ } else if (mystrncasecmp(argv[5],"ME",0)) {
+ while (Backup.PhonePhonebook[i]!=NULL) {
+ if (i == atoi(argv[6])-1) break;
+ i++;
+ }
+ if (i != atoi(argv[6])-1) {
+ printmsg("Phonebook entry not found in file\n");
+ exit(-1);
+ }
+ pbk = Backup.PhonePhonebook[i];
+ } else {
+ printmsg("Unknown memory type: \"%s\"\n",argv[5]);
+ exit(-1);
+ }
+ j = 0;
+ if (mystrncasecmp(argv[2],"VCARD10",0)) {
+ GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10);
+ } else {
+ GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21);
+ }
+ } else {
+ printmsg("What format of file (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ file = fopen(argv[3],"wb");
+ fwrite(Buffer,1,j,file);
+ fclose(file);
+}
+
+static void Backup(int argc, char *argv[])
+{
+ int i, used;
+ GSM_MemoryStatus MemStatus;
+ GSM_ToDoEntry ToDo;
+ GSM_ToDoStatus ToDoStatus;
+ GSM_MemoryEntry Pbk;
+ GSM_CalendarEntry Note;
+ GSM_Bitmap Bitmap;
+ GSM_WAPBookmark Bookmark;
+ GSM_Profile Profile;
+ GSM_MultiWAPSettings Settings;
+ GSM_Ringtone Ringtone;
+ GSM_SMSC SMSC;
+ GSM_Backup Backup;
+ GSM_Backup_Info Info;
+ GSM_FMStation FMStation;
+ GSM_GPRSAccessPoint GPRSPoint;
+ bool DoBackup;
+
+ if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true;
+
+ GSM_ClearBackup(&Backup);
+ GSM_GetBackupFormatFeatures(argv[2],&Info);
+
+ sprintf(Backup.Creator,"Gammu %s",VERSION);
+ if (strlen(GetOS()) != 0) {
+ strcat(Backup.Creator+strlen(Backup.Creator),", ");
+ strcat(Backup.Creator+strlen(Backup.Creator),GetOS());
+ }
+ if (strlen(GetCompiler()) != 0) {
+ strcat(Backup.Creator+strlen(Backup.Creator),", ");
+ strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler());
+ }
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ GSM_Init(true);
+
+ if (Info.UseUnicode) {
+ Info.UseUnicode=answer_yes("Use Unicode subformat of backup file");
+ }
+ if (Info.DateTime) {
+ GSM_GetCurrentDateTime (&Backup.DateTime);
+ Backup.DateTimeAvailable=true;
+ }
+ if (Info.Model) {
+ error=Phone->GetManufacturer(&s);
+ Print_Error(error);
+ sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer);
+ if (s.Phone.Data.ModelInfo->model[0]!=0) {
+ strcat(Backup.Model,s.Phone.Data.ModelInfo->model);
+ } else {
+ strcat(Backup.Model,s.Phone.Data.Model);
+ }
+ strcat(Backup.Model," ");
+ strcat(Backup.Model,s.Phone.Data.Version);
+ }
+ if (Info.IMEI) {
+ error=Phone->GetIMEI(&s);
+ if (error != ERR_NOTSUPPORTED) {
+ strcpy(Backup.IMEI, s.Phone.Data.IMEI);
+ Print_Error(error);
+ } else {
+ Backup.IMEI[0] = 0;
+ }
+ }
+ printf("\n");
+
+ DoBackup = false;
+ if (Info.PhonePhonebook) {
+ printmsg("Checking phone phonebook\n");
+ MemStatus.MemoryType = MEM_ME;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
+ if (answer_yes(" Backup phone phonebook")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ Pbk.MemoryType = MEM_ME;
+ i = 1;
+ used = 0;
+ while (used != MemStatus.MemoryUsed) {
+ Pbk.Location = i;
+ error=Phone->GetMemory(&s, &Pbk);
+ if (error != ERR_EMPTY) {
+ Print_Error(error);
+ if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) {
+ Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
+ if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.PhonePhonebook[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.PhonePhonebook[used]=Pbk;
+ used++;
+ }
+ printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
+ i++;
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.SIMPhonebook) {
+ printmsg("Checking SIM phonebook\n");
+ MemStatus.MemoryType = MEM_SM;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
+ if (answer_yes(" Backup SIM phonebook")) DoBackup=true;
+ }
+ }
+ if (DoBackup) {
+ Pbk.MemoryType = MEM_SM;
+ i = 1;
+ used = 0;
+ while (used != MemStatus.MemoryUsed) {
+ Pbk.Location = i;
+ error=Phone->GetMemory(&s, &Pbk);
+ if (error != ERR_EMPTY) {
+ Print_Error(error);
+ if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) {
+ Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
+ if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.SIMPhonebook[used + 1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.SIMPhonebook[used]=Pbk;
+ used++;
+ }
+ printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
+ i++;
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.Calendar) {
+ printmsg("Checking calendar\n");
+ error=Phone->GetNextCalendar(&s,&Note,true);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup calendar notes")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_MAXCALENDARTODONOTES) {
+ Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry));
+ if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.Calendar[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.Calendar[used]=Note;
+ used ++;
+ error=Phone->GetNextCalendar(&s,&Note,false);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.ToDo) {
+ printmsg("Checking ToDo\n");
+ error=Phone->GetToDoStatus(&s,&ToDoStatus);
+ if (error == ERR_NONE && ToDoStatus.Used != 0) {
+ if (answer_yes(" Backup ToDo")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ error=Phone->GetNextToDo(&s,&ToDo,true);
+ while (error == ERR_NONE) {
+ if (used < GSM_MAXCALENDARTODONOTES) {
+ Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry));
+ if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.ToDo[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.ToDo[used]=ToDo;
+ used ++;
+ error=Phone->GetNextToDo(&s,&ToDo,false);
+ printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.CallerLogos) {
+ printmsg("Checking caller logos\n");
+ Bitmap.Type = GSM_CallerGroupLogo;
+ Bitmap.Location = 1;
+ error=Phone->GetBitmap(&s,&Bitmap);
+ if (error == ERR_NONE) {
+ if (answer_yes(" Backup caller groups and logos")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ printmsgerr(" Reading : ");
+ error = ERR_NONE;
+ used = 0;
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_CALLER) {
+ Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap));
+ if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.CallerLogos[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.CallerLogos[used] = Bitmap;
+ used ++;
+ Bitmap.Location = used + 1;
+ error=Phone->GetBitmap(&s,&Bitmap);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.SMSC) {
+ printmsg("Checking SMS profiles\n");
+ if (answer_yes(" Backup SMS profiles")) DoBackup = true;
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading: ");
+ while (true) {
+ SMSC.Location = used + 1;
+ error = Phone->GetSMSC(&s,&SMSC);
+ if (error != ERR_NONE) break;
+ if (used < GSM_BACKUP_MAX_SMSC) {
+ Backup.SMSC[used] = malloc(sizeof(GSM_SMSC));
+ if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.SMSC[used + 1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.SMSC[used]=SMSC;
+ used++;
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.StartupLogo) {
+ printmsg("Checking startup text\n");
+ Bitmap.Type = GSM_WelcomeNote_Text;
+ error = Phone->GetBitmap(&s,&Bitmap);
+ if (error == ERR_NONE) {
+ if (answer_yes(" Backup startup logo/text")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ Backup.StartupLogo = malloc(sizeof(GSM_Bitmap));
+ if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY);
+ *Backup.StartupLogo = Bitmap;
+ if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) {
+ Bitmap.Type = GSM_StartupLogo;
+ error = Phone->GetBitmap(&s,&Bitmap);
+ if (error == ERR_NONE) *Backup.StartupLogo = Bitmap;
+ }
+ }
+ DoBackup = false;
+ if (Info.OperatorLogo) {
+ printmsg("Checking operator logo\n");
+ Bitmap.Type = GSM_OperatorLogo;
+ error=Phone->GetBitmap(&s,&Bitmap);
+ if (error == ERR_NONE) {
+ if (strcmp(Bitmap.NetworkCode,"000 00")!=0) {
+ if (answer_yes(" Backup operator logo")) DoBackup = true;
+ }
+ }
+ }
+ if (DoBackup) {
+ Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap));
+ if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY);
+ *Backup.OperatorLogo = Bitmap;
+ }
+ DoBackup = false;
+ if (Info.MMSSettings) {
+ printmsg("Checking MMS settings\n");
+ Settings.Location = 1;
+ error=Phone->GetMMSSettings(&s,&Settings);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup MMS settings")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_MMSSETTINGS) {
+ Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
+ if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.MMSSettings[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.MMSSettings[used]=Settings;
+ used ++;
+ Settings.Location = used+1;
+ error=Phone->GetMMSSettings(&s,&Settings);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ 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.Ringtone) {
+ printmsg("Checking user ringtones\n");
+ Ringtone.Location = 1;
+ Ringtone.Format = 0;
+ error=Phone->GetRingtone(&s,&Ringtone,false);
+ if (error==ERR_EMPTY || error == ERR_NONE) {
+ if (answer_yes(" Backup user ringtones")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ i = 1;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE || error == ERR_EMPTY) {
+ if (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_RINGTONES) {
+ Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone));
+ if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.Ringtone[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.Ringtone[used]=Ringtone;
+ used ++;
+ }
+ i++;
+ Ringtone.Location = i;
+ Ringtone.Format = 0;
+ error=Phone->GetRingtone(&s,&Ringtone,false);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.Profiles) {
+ printmsg("Checking phone profiles\n");
+ Profile.Location = 1;
+ error = Phone->GetProfile(&s,&Profile);
+ if (error == ERR_NONE) {
+ if (answer_yes(" Backup phone profiles")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading: ");
+ while (true) {
+ Profile.Location = used + 1;
+ error = Phone->GetProfile(&s,&Profile);
+ if (error != ERR_NONE) break;
+ if (used < GSM_BACKUP_MAX_PROFILES) {
+ Backup.Profiles[used] = malloc(sizeof(GSM_Profile));
+ if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.Profiles[used + 1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.Profiles[used]=Profile;
+ used++;
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.FMStation) {
+ printmsg("Checking FM stations\n");
+ FMStation.Location = 1;
+ error = Phone->GetFMStation(&s,&FMStation);
+ if (error == ERR_NONE || error == ERR_EMPTY) {
+ if (answer_yes(" Backup phone FM stations")) DoBackup=true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ i = 1;
+ printmsgerr(" Reading: ");
+ while (error == ERR_NONE || error == ERR_EMPTY) {
+ error = Phone->GetFMStation(&s,&FMStation);
+ if (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_FMSTATIONS) {
+ Backup.FMStation[used] = malloc(sizeof(GSM_FMStation));
+ if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.FMStation[used + 1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.FMStation[used]=FMStation;
+ used++;
+ }
+ i++;
+ FMStation.Location = i;
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.GPRSPoint) {
+ printmsg("Checking GPRS access points\n");
+ GPRSPoint.Location = 1;
+ error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
+ if (error == ERR_NONE || error == ERR_EMPTY) {
+ if (answer_yes(" Backup GPRS access points")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ i = 1;
+ printmsgerr(" Reading: ");
+ while (error == ERR_NONE || error == ERR_EMPTY) {
+ error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
+ if (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_GPRSPOINT) {
+ Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint));
+ if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.GPRSPoint[used + 1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.GPRSPoint[used]=GPRSPoint;
+ used++;
+ }
+ i++;
+ GPRSPoint.Location = i;
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ }
+
+ GSM_Terminate();
+
+ GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode);
+ GSM_FreeBackup(&Backup);
+}
+
+static void Restore(int argc, char *argv[])
+{
+ GSM_Backup Backup;
+ GSM_FMStation FMStation;
+ GSM_DateTime date_time;
+ GSM_CalendarEntry Calendar;
+ GSM_Bitmap Bitmap;
+ GSM_Ringtone Ringtone;
+ GSM_MemoryEntry Pbk;
+ GSM_MemoryStatus MemStatus;
+ GSM_ToDoEntry ToDo;
+ GSM_ToDoStatus ToDoStatus;
+ GSM_Profile Profile;
+ GSM_MultiWAPSettings Settings;
+ GSM_GPRSAccessPoint GPRSPoint;
+ GSM_WAPBookmark Bookmark;
+ int i, used, max = 0;
+ bool Past = true;
+ bool Found, DoRestore;
+
+ error=GSM_ReadBackupFile(argv[2],&Backup);
+ Print_Error(error);
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ 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.MD5Calculated[0]!=0) {
+ dbgprintf("\"%s\"\n",Backup.MD5Original);
+ dbgprintf("\"%s\"\n",Backup.MD5Calculated);
+ if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
+ if (!answer_yes("Checksum in backup file do not match. Continue")) return;
+ }
+ }
+
+ GSM_Init(true);
+
+ DoRestore = false;
+ if (Backup.PhonePhonebook[0] != NULL) {
+ MemStatus.MemoryType = MEM_ME;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE) {
+ max = 0;
+ while (Backup.PhonePhonebook[max]!=NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+ if (answer_yes("Restore phone phonebook")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ used = 0;
+ for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
+ Pbk.MemoryType = MEM_ME;
+ Pbk.Location = i + 1;
+ Pbk.EntriesNum = 0;
+ if (used<max) {
+ if (Backup.PhonePhonebook[used]->Location == Pbk.Location) {
+ Pbk = *Backup.PhonePhonebook[used];
+ used++;
+ dbgprintf("Location %i\n",Pbk.Location);
+ if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
+ }
+ }
+ if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ DoRestore = false;
+ if (Backup.SIMPhonebook[0] != NULL) {
+ MemStatus.MemoryType = MEM_SM;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE) {
+ max = 0;
+ while (Backup.SIMPhonebook[max]!=NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+ if (answer_yes("Restore SIM phonebook")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ used = 0;
+ for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
+ Pbk.MemoryType = MEM_SM;
+ Pbk.Location = i + 1;
+ Pbk.EntriesNum = 0;
+ if (used<max) {
+ if (Backup.SIMPhonebook[used]->Location == Pbk.Location) {
+ Pbk = *Backup.SIMPhonebook[used];
+ used++;
+ dbgprintf("Location %i\n",Pbk.Location);
+ if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
+ }
+ }
+ if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ DoRestore = false;
+ if (Backup.CallerLogos[0] != NULL) {
+ Bitmap.Type = GSM_CallerGroupLogo;
+ Bitmap.Location = 1;
+ error=Phone->GetBitmap(&s,&Bitmap);
+ if (error == ERR_NONE) {
+ if (answer_yes("Restore caller groups and logos")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ max = 0;
+ while (Backup.CallerLogos[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ 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 ) {
+ GSM_GetCurrentDateTime(&date_time);
+
+ error=Phone->SetDateTime(&s, &date_time);
+ Print_Error(error);
+ }
+ }
+ DoRestore = false;
+ if (Backup.Calendar[0] != NULL) {
+ /* N6110 doesn't support getting calendar status */
+ error = Phone->GetNextCalendar(&s,&Calendar,true);
+ if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
+ max = 0;
+ while (Backup.Calendar[max] != NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+ DoRestore = true;
+ /*
+ if (answer_yes("Restore calendar notes")) {
+ Past = answer_yes("Restore notes from the past");
+ DoRestore = true;
+ }
+ */
+ }
+ }
+ if (DoRestore) {
+ printmsgerr("Deleting old notes: ");
+ error = Phone->DeleteAllCalendar(&s);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ while (1) {
+ error = Phone->GetNextCalendar(&s,&Calendar,true);
+ if (error != ERR_NONE) break;
+ error = Phone->DeleteCalendar(&s,&Calendar);
+ Print_Error(error);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+
+ for (i=0;i<max;i++) {
+ if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue;
+
+ Calendar = *Backup.Calendar[i];
+ error=Phone->AddCalendar(&s,&Calendar);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ DoRestore = false;
+ if (Backup.ToDo[0] != NULL) {
+ error = Phone->GetToDoStatus(&s,&ToDoStatus);
+ if (error == ERR_NONE) {
+ max = 0;
+ while (Backup.ToDo[max]!=NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+
+ /*if (answer_yes("Restore ToDo")) */DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ ToDo = *Backup.ToDo[0];
+ error = Phone->SetToDo(&s,&ToDo);
+ }
+ if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
+ printmsgerr("Deleting old ToDo: ");
+ error=Phone->DeleteAllToDo(&s);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ while (1) {
+ error = Phone->GetNextToDo(&s,&ToDo,true);
+ if (error != ERR_NONE) break;
+ error = Phone->DeleteToDo(&s,&ToDo);
+ Print_Error(error);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+
+ for (i=0;i<max;i++) {
+ ToDo = *Backup.ToDo[i];
+ ToDo.Location = 0;
+ error=Phone->AddToDo(&s,&ToDo);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ } else if (DoRestore) {
+ /* At first delete entries, that were deleted */
+ used = 0;
+ error = Phone->GetNextToDo(&s,&ToDo,true);
+ while (error == ERR_NONE) {
+ used++;
+ Found = false;
+ for (i=0;i<max;i++) {
+ if (Backup.ToDo[i]->Location == ToDo.Location) {
+ Found = true;
+ break;
+ }
+ }
+ if (!Found) {
+ error=Phone->DeleteToDo(&s,&ToDo);
+ Print_Error(error);
+ }
+ error = Phone->GetNextToDo(&s,&ToDo,false);
+ printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+
+ /* Now write modified/new entries */
+ for (i=0;i<max;i++) {
+ ToDo = *Backup.ToDo[i];
+ error = Phone->SetToDo(&s,&ToDo);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) {
+ max = 0;
+ while (Backup.SMSC[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=Phone->SetSMSC(&s,Backup.SMSC[i]);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) {
+ error=Phone->SetBitmap(&s,Backup.StartupLogo);
+ Print_Error(error);
+ }
+ if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) {
+ error=Phone->SetBitmap(&s,Backup.OperatorLogo);
+ Print_Error(error);
+ }
+ DoRestore = false;
+ if (Backup.WAPBookmark[0] != NULL) {
+ Bookmark.Location = 1;
+ error = Phone->GetWAPBookmark(&s,&Bookmark);
+ if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
+ if (answer_yes("Restore WAP bookmarks")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ printmsgerr("Deleting old bookmarks: ");
+ /* One thing to explain: DCT4 phones seems to have bug here.
+ * When delete for example first bookmark, phone change
+ * numeration for getting frame, not for deleting. So, we try to
+ * get 1'st bookmark. Inside frame is "correct" location. We use
+ * it later
+ */
+ while (error==ERR_NONE) {
+ error = Phone->DeleteWAPBookmark(&s,&Bookmark);
+ Bookmark.Location = 1;
+ error = Phone->GetWAPBookmark(&s,&Bookmark);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ max = 0;
+ while (Backup.WAPBookmark[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ Bookmark = *Backup.WAPBookmark[i];
+ Bookmark.Location = 0;
+ error=Phone->SetWAPBookmark(&s,&Bookmark);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.WAPSettings[0] != NULL) {
+ Settings.Location = 1;
+ error = Phone->GetWAPSettings(&s,&Settings);
+ if (error == ERR_NONE) {
+ if (answer_yes("Restore WAP settings")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ max = 0;
+ while (Backup.WAPSettings[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.MMSSettings[0] != NULL) {
+ Settings.Location = 1;
+ error = Phone->GetMMSSettings(&s,&Settings);
+ if (error == ERR_NONE) {
+ if (answer_yes("Restore MMS settings")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ max = 0;
+ while (Backup.MMSSettings[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.Ringtone[0] != NULL) {
+ Ringtone.Location = 1;
+ Ringtone.Format = 0;
+ error = Phone->GetRingtone(&s,&Ringtone,false);
+ if (error == ERR_NONE || error ==ERR_EMPTY) {
+ if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
+ if (answer_yes("Delete all user ringtones")) DoRestore = true;
+ }
+ }
+ }
+ if (DoRestore) {
+ printmsgerr("Deleting: ");
+ error=Phone->DeleteUserRingtones(&s);
+ Print_Error(error);
+ printmsgerr("Done\n");
+ DoRestore = false;
+ if (answer_yes("Restore user ringtones")) DoRestore = true;
+ }
+ if (DoRestore) {
+ max = 0;
+ while (Backup.Ringtone[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format);
+ Print_Error(error);
+ error=Phone->SetRingtone(&s,&Ringtone,&i);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.Profiles[0] != NULL) {
+ Profile.Location = 1;
+ error = Phone->GetProfile(&s,&Profile);
+ if (error == ERR_NONE) {
+ if (answer_yes("Restore profiles")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ Profile.Location= 0;
+ max = 0;
+ while (Backup.Profiles[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ Profile = *Backup.Profiles[i];
+ error=Phone->SetProfile(&s,&Profile);
+ Print_Error(error);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.FMStation[0] != NULL) {
+ FMStation.Location = 1;
+ error = Phone->GetFMStation(&s,&FMStation);
+ if (error == ERR_NONE || error == ERR_EMPTY) {
+ if (answer_yes("Restore FM stations")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ printmsgerr("Deleting old FM stations: ");
+ error=Phone->ClearFMStations(&s);
+ Print_Error(error);
+ printmsgerr("Done\n");
+ max = 0;
+ while (Backup.FMStation[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ FMStation = *Backup.FMStation[i];
+ error=Phone->SetFMStation(&s,&FMStation);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoRestore = false;
+ if (Backup.GPRSPoint[0] != NULL) {
+ GPRSPoint.Location = 1;
+ error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
+ if (error == ERR_NONE || error == ERR_EMPTY) {
+ if (answer_yes("Restore GPRS Points")) DoRestore = true;
+ }
+ }
+ if (DoRestore) {
+ max = 0;
+ while (Backup.GPRSPoint[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void AddNew(int argc, char *argv[])
+{
+ GSM_Backup Backup;
+ GSM_DateTime date_time;
+ GSM_MemoryEntry Pbk;
+ GSM_MemoryStatus MemStatus;
+ GSM_ToDoEntry ToDo;
+ GSM_ToDoStatus ToDoStatus;
+ GSM_CalendarEntry Calendar;
+ GSM_WAPBookmark Bookmark;
+ int i, max, j;
+
+ error=GSM_ReadBackupFile(argv[2],&Backup);
+ Print_Error(error);
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ 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);
+
+ GSM_Init(true);
+
+ if (Backup.PhonePhonebook[0] != NULL) {
+ MemStatus.MemoryType = MEM_ME;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE) {
+ max = 0;
+ while (Backup.PhonePhonebook[max]!=NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+ if (MemStatus.MemoryFree < max) {
+ printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
+ } else if (answer_yes("Add phone phonebook entries")) {
+ for (i=0;i<max;i++) {
+ Pbk = *Backup.PhonePhonebook[i];
+ Pbk.MemoryType = MEM_ME;
+ error=Phone->AddMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ }
+ }
+ if (Backup.SIMPhonebook[0] != NULL) {
+ MemStatus.MemoryType = MEM_SM;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE) {
+ max = 0;
+ while (Backup.SIMPhonebook[max]!=NULL) max++;
+ printmsgerr("%i entries in backup file\n",max);
+ if (MemStatus.MemoryFree < max) {
+ printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
+ } else if (answer_yes("Add SIM phonebook entries")) {
+ j = 1;
+ for (i=0;i<max;i++) {
+ Pbk = *Backup.SIMPhonebook[i];
+ Pbk.MemoryType = MEM_SM;
+ error=Phone->AddMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ }
+ }
+
+ 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)")) {
+ GSM_GetCurrentDateTime(&date_time);
+
+ error=Phone->SetDateTime(&s, &date_time);
+ Print_Error(error);
+ }
+ }
+ if (Backup.Calendar[0] != NULL) {
+ error = Phone->GetNextCalendar(&s,&Calendar,true);
+ if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
+ if (answer_yes("Add calendar notes")) {
+ max = 0;
+ while (Backup.Calendar[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ Calendar = *Backup.Calendar[i];
+ error=Phone->AddCalendar(&s,&Calendar);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ }
+ }
+ if (Backup.ToDo[0] != NULL) {
+ ToDo.Location = 1;
+ error=Phone->GetToDoStatus(&s,&ToDoStatus);
+ if (error == ERR_NONE) {
+ if (answer_yes("Add ToDo")) {
+ max = 0;
+ while (Backup.ToDo[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ ToDo = *Backup.ToDo[i];
+ error = Phone->AddToDo(&s,&ToDo);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ }
+ }
+ if (Backup.WAPBookmark[0] != NULL) {
+ Bookmark.Location = 1;
+ error = Phone->GetWAPBookmark(&s,&Bookmark);
+ if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
+ if (answer_yes("Add WAP bookmarks")) {
+ max = 0;
+ while (Backup.WAPBookmark[max]!=NULL) max++;
+ for (i=0;i<max;i++) {
+ Bookmark = *Backup.WAPBookmark[i];
+ Bookmark.Location = 0;
+ error=Phone->SetWAPBookmark(&s,&Bookmark);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ }
+ }
+
+ GSM_Terminate();
+}
+#endif
+
+static void ClearAll(int argc, char *argv[])
+{
+ GSM_MemoryStatus MemStatus;
+ GSM_ToDoStatus ToDoStatus;
+ GSM_CalendarEntry Calendar;
+ GSM_ToDoEntry ToDo;
+ GSM_WAPBookmark Bookmark;
+ GSM_FMStation Station;
+ GSM_MemoryEntry Pbk;
+ bool DoClear;
+
+ GSM_Init(true);
+
+ DoClear = false;
+ MemStatus.MemoryType = MEM_ME;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
+ if (answer_yes("Delete phone phonebook")) DoClear = true;
+ }
+ if (DoClear) {
+ error = Phone->DeleteAllMemory(&s,MEM_ME);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
+ Pbk.MemoryType = MEM_ME;
+ Pbk.Location = i + 1;
+ Pbk.EntriesNum = 0;
+ error=Phone->DeleteMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+ }
+
+ DoClear = false;
+ MemStatus.MemoryType = MEM_SM;
+ error=Phone->GetMemoryStatus(&s, &MemStatus);
+ if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
+ if (answer_yes("Delete SIM phonebook")) DoClear = true;
+ }
+ if (DoClear) {
+ error = Phone->DeleteAllMemory(&s,MEM_SM);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
+ Pbk.MemoryType = MEM_SM;
+ Pbk.Location = i + 1;
+ Pbk.EntriesNum = 0;
+ error=Phone->DeleteMemory(&s, &Pbk);
+ Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+ }
+
+ DoClear = false;
+ error = Phone->GetNextCalendar(&s,&Calendar,true);
+ if (error == ERR_NONE) {
+ if (answer_yes("Delete calendar notes")) DoClear = true;
+ }
+ if (DoClear) {
+ printmsgerr("Deleting: ");
+ error=Phone->DeleteAllCalendar(&s);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ while (1) {
+ error = Phone->GetNextCalendar(&s,&Calendar,true);
+ if (error != ERR_NONE) break;
+ error = Phone->DeleteCalendar(&s,&Calendar);
+ Print_Error(error);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+ }
+
+ DoClear = false;
+ error = Phone->GetToDoStatus(&s,&ToDoStatus);
+ if (error == ERR_NONE && ToDoStatus.Used != 0) {
+ if (answer_yes("Delete ToDo")) DoClear = true;
+ }
+ if (DoClear) {
+ printmsgerr("Deleting: ");
+ error=Phone->DeleteAllToDo(&s);
+ if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
+ while (1) {
+ error = Phone->GetNextToDo(&s,&ToDo,true);
+ if (error != ERR_NONE) break;
+ error = Phone->DeleteToDo(&s,&ToDo);
+ Print_Error(error);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ } else {
+ printmsgerr("Done\n");
+ Print_Error(error);
+ }
+ }
+
+ Bookmark.Location = 1;
+ error = Phone->GetWAPBookmark(&s,&Bookmark);
+ if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
+ if (answer_yes("Delete WAP bookmarks")) {
+ printmsgerr("Deleting: ");
+ /* One thing to explain: DCT4 phones seems to have bug here.
+ * When delete for example first bookmark, phone change
+ * numeration for getting frame, not for deleting. So, we try to
+ * get 1'st bookmark. Inside frame is "correct" location. We use
+ * it later
+ */
+ while (error==ERR_NONE) {
+ error = Phone->DeleteWAPBookmark(&s,&Bookmark);
+ Bookmark.Location = 1;
+ error = Phone->GetWAPBookmark(&s,&Bookmark);
+ printmsgerr("*");
+ }
+ printmsgerr("\n");
+ }
+ }
+ if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
+ if (answer_yes("Delete all user ringtones")) {
+ printmsgerr("Deleting: ");
+ error=Phone->DeleteUserRingtones(&s);
+ Print_Error(error);
+ printmsgerr("Done\n");
+ }
+ }
+ Station.Location=i;
+ error=Phone->GetFMStation(&s,&Station);
+ if (error == ERR_NONE || error == ERR_EMPTY) {
+ if (answer_yes("Delete all FM station")) {
+ error=Phone->ClearFMStations(&s);
+ Print_Error(error);
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j)
+{
+ if (settings->Settings[j].IsContinuous) {
+ printmsg("Connection type : Continuous\n");
+ } else {
+ printmsg("Connection type : Temporary\n");
+ }
+ if (settings->Settings[j].IsSecurity) {
+ printmsg("Connection security : On\n");
+ } else {
+ printmsg("Connection security : Off\n");
+ }
+ printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort);
+ printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port);
+ switch (settings->Settings[j].Bearer) {
+ case WAPSETTINGS_BEARER_SMS:
+ printmsg("Bearer : SMS");
+ if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)");
+ printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server));
+ printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
+ break;
+ case WAPSETTINGS_BEARER_DATA:
+ printmsg("Bearer : Data (CSD)");
+ if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)");
+ printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
+ printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
+ if (settings->Settings[j].ManualLogin) {
+ printmsg("Login Type : Manual\n");
+ } else {
+ printmsg("Login Type : Automatic\n");
+ }
+ if (settings->Settings[j].IsNormalAuthentication) {
+ printmsg("Authentication type : Normal\n");
+ } else {
+ printmsg("Authentication type : Secure\n");
+ }
+ if (settings->Settings[j].IsISDNCall) {
+ printmsg("Data call type : ISDN\n");
+ } else {
+ printmsg("Data call type : Analogue\n");
+ }
+ switch (settings->Settings[j].Speed) {
+ case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break;
+ case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break;
+ case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break;
+ }
+ printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
+ printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
+ break;
+ case WAPSETTINGS_BEARER_USSD:
+ printmsg("Bearer : USSD");
+ if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)");
+ printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code));
+ if (settings->Settings[j].IsIP) {
+ printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
+ } else {
+ printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
+ }
+ break;
+ case WAPSETTINGS_BEARER_GPRS:
+ printmsg("Bearer : GPRS");
+ if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)");
+ if (settings->Settings[j].ManualLogin) {
+ printmsg("\nLogin Type : Manual\n");
+ } else {
+ printmsg("\nLogin Type : Automatic\n");
+ }
+ if (settings->Settings[j].IsNormalAuthentication) {
+ printmsg("Authentication type : Normal\n");
+ } else {
+ printmsg("Authentication type : Secure\n");
+ }
+ printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
+ printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
+ printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
+ printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
+ }
+}
+
+static void GetSyncMLSettings(int argc, char *argv[])
+{
+ GSM_SyncMLSettings settings;
+ int start,stop,j;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ settings.Location=i;
+ error=Phone->GetSyncMLSettings(&s,&settings);
+ Print_Error(error);
+ printmsg("%i. ",i);
+ if (settings.Name[0]==0 && settings.Name[1]==0) {
+ printmsg("Set %i",i);
+ } else {
+ printmsg("%s",DecodeUnicodeConsole(settings.Name));
+ }
+ if (settings.Active) printmsg(" (active)");
+// if (settings.ReadOnly) printmsg("\nRead only : yes");
+ printmsg("\n");
+ printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
+ printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
+ printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase));
+ printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase));
+ printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server));
+ printmsg("Sync. phonebook : ");
+ if (settings.SyncPhonebook) printmsg("yes\n");
+ if (!settings.SyncPhonebook) printmsg("no\n");
+ printmsg("Sync. calendar : ");
+ if (settings.SyncCalendar) printmsg("yes\n");
+ if (!settings.SyncCalendar) printmsg("no\n");
+ printmsg("\n");
+ for (j=0;j<settings.Connection.Number;j++) {
+ if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
+ printmsg("Connection set name : Set %i\n",i);
+ } else {
+ printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
+ }
+ DisplayConnectionSettings(&settings.Connection,j);
+ printf("\n");
+ }
+ }
+ GSM_Terminate();
+}
+
+static void GetChatSettings(int argc, char *argv[])
+{
+ GSM_ChatSettings settings;
+ int start,stop,j;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ settings.Location=i;
+ error=Phone->GetChatSettings(&s,&settings);
+ Print_Error(error);
+ printmsg("%i. ",i);
+ if (settings.Name[0]==0 && settings.Name[1]==0) {
+ printmsg("Set %i",i);
+ } else {
+ printmsg("%s",DecodeUnicodeConsole(settings.Name));
+ }
+ if (settings.Active) printmsg(" (active)");
+// if (settings.ReadOnly) printmsg("\nRead only : yes");
+ printmsg("\n");
+ printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage));
+ printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
+ printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
+ printmsg("\n");
+ for (j=0;j<settings.Connection.Number;j++) {
+ if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
+ printmsg("Connection set name : Set %i\n",i);
+ } else {
+ printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
+ }
+ DisplayConnectionSettings(&settings.Connection,j);
+ printf("\n");
+ }
+ }
+ GSM_Terminate();
+}
+
+static void GetWAPMMSSettings(int argc, char *argv[])
+{
+ GSM_MultiWAPSettings settings;
+ int start,stop,j;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ settings.Location=i;
+ if (mystrncasecmp(argv[1],"--getwapsettings",0)) {
+ error=Phone->GetWAPSettings(&s,&settings);
+ } else {
+ error=Phone->GetMMSSettings(&s,&settings);
+ }
+ Print_Error(error);
+ for (j=0;j<settings.Number;j++) {
+ printmsg("%i. ",i);
+ if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) {
+ printmsg("Set %i",i);
+ } else {
+ printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title));
+ }
+ if (settings.Active) printmsg(" (active)");
+ if (settings.ReadOnly) printmsg("\nRead only : yes");
+ printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage));
+ DisplayConnectionSettings(&settings,j);
+ printf("\n");
+ }
+ }
+ GSM_Terminate();
+}
+
+#ifdef GSM_ENABLE_BACKUP
+static void BackupSMS(int argc, char *argv[])
+{
+ GSM_SMS_Backup Backup;
+ GSM_MultiSMSMessage sms;
+ GSM_SMSFolders folders;
+ bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
+ bool start = true;
+ bool DeleteAfter;
+ int j, smsnum;
+ char buffer[200];
+
+ /* We ignore return code, because (when file doesn't exist) we
+ * will create new later
+ */
+ GSM_ReadSMSBackupFile(argv[2], &Backup);
+ smsnum = 0;
+ while (Backup.SMS[smsnum]!=NULL) smsnum++;
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ DeleteAfter=answer_yes("Delete each sms after backup");
+
+ for (j=0;j<folders.Number;j++) {
+ BackupFromFolder[j] = false;
+ sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
+ if (answer_yes(buffer)) BackupFromFolder[j] = true;
+ }
+
+ while (error == ERR_NONE) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->GetNextSMS(&s, &sms, start);
+ switch (error) {
+ case ERR_EMPTY:
+ break;
+ default:
+ Print_Error(error);
+ for (j=0;j<sms.Number;j++) {
+ if (BackupFromFolder[sms.SMS[j].Folder-1]) {
+ switch (sms.SMS[j].PDU) {
+ case SMS_Status_Report:
+ break;
+ case SMS_Submit:
+ case SMS_Deliver:
+ if (sms.SMS[j].Length == 0) break;
+ if (smsnum < GSM_BACKUP_MAX_SMS) {
+ Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage));
+ if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.SMS[smsnum+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.SMS[smsnum] = sms.SMS[j];
+ smsnum++;
+ break;
+ }
+ }
+ }
+ }
+ start=false;
+ }
+
+ error = GSM_SaveSMSBackupFile(argv[2],&Backup);
+ Print_Error(error);
+
+ if (DeleteAfter) {
+ for (j=0;j<smsnum;j++) {
+ Backup.SMS[j]->Folder = 0;
+ error=Phone->DeleteSMS(&s, Backup.SMS[j]);
+ Print_Error(error);
+ printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum);
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void AddSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage SMS;
+ GSM_SMS_Backup Backup;
+ int smsnum = 0;
+ int folder;
+
+ folder = atoi(argv[2]);
+
+ error = GSM_ReadSMSBackupFile(argv[3], &Backup);
+ Print_Error(error);
+
+ GSM_Init(true);
+
+ while (Backup.SMS[smsnum] != NULL) {
+ Backup.SMS[smsnum]->Folder = folder;
+ Backup.SMS[smsnum]->SMSC.Location = 1;
+ SMS.Number = 1;
+ SMS.SMS[0] = *Backup.SMS[smsnum];
+ displaymultismsinfo(SMS,false,false);
+ if (answer_yes("Restore sms")) {
+ error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
+ Print_Error(error);
+ }
+ smsnum++;
+ }
+
+ GSM_Terminate();
+}
+
+static void RestoreSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage SMS;
+ GSM_SMS_Backup Backup;
+ GSM_SMSFolders folders;
+ int smsnum = 0;
+ char buffer[200];
+
+ error=GSM_ReadSMSBackupFile(argv[2], &Backup);
+ Print_Error(error);
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ while (Backup.SMS[smsnum] != NULL) {
+ SMS.Number = 1;
+ memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
+ displaymultismsinfo(SMS,false,false);
+ sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
+ if (answer_yes(buffer)) {
+ Backup.SMS[smsnum]->Location = 0;
+ error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
+ Print_Error(error);
+ }
+ smsnum++;
+ }
+
+ GSM_Terminate();
+}
+#endif
+
+static void CopyBitmap(int argc, char *argv[])
+{
+ GSM_MultiBitmap Bitmap;
+ int i;
+
+ Bitmap.Bitmap[0].Type = GSM_None;
+
+ error=GSM_ReadBitmapFile(argv[2],&Bitmap);
+ Print_Error(error);
+
+ if (argc==3) {
+ for (i=0;i<Bitmap.Number;i++) {
+ switch (Bitmap.Bitmap[i].Type) {
+ case GSM_StartupLogo : printmsg("Startup logo"); break;
+ case GSM_OperatorLogo: printmsg("Operator logo"); break;
+ case GSM_PictureImage: printmsg("Picture Image"); break;
+ case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
+ default : break;
+ }
+ printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
+ GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
+ }
+ } else {
+ if (argc == 5) {
+ for (i=0;i<Bitmap.Number;i++) {
+ if (mystrncasecmp(argv[4],"PICTURE",0)) {
+ Bitmap.Bitmap[i].Type = GSM_PictureImage;
+ } else if (mystrncasecmp(argv[4],"STARTUP",0)) {
+ Bitmap.Bitmap[i].Type = GSM_StartupLogo;
+ } else if (mystrncasecmp(argv[4],"CALLER",0)) {
+ Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo;
+ } else if (mystrncasecmp(argv[4],"OPERATOR",0)) {
+ Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
+ } else {
+ printmsg("What format of output file logo (\"%s\") ?\n",argv[4]);
+ exit(-1);
+ }
+ }
+ }
+ error=GSM_SaveBitmapFile(argv[3],&Bitmap);
+ Print_Error(error);
+ }
+}
+
+static void NokiaComposer(int argc, char *argv[])
+{
+ GSM_Ringtone ringtone;
+ bool started;
+ int i,j;
+ GSM_RingNote *Note;
+ GSM_RingNoteDuration Duration;
+ GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */
+ unsigned int DefNoteScale = Scale_880;
+
+ ringtone.Format = 0;
+ error=GSM_ReadRingtoneFile(argv[2],&ringtone);
+
+ if (ringtone.Format != RING_NOTETONE) {
+ printmsg("It can be RTTL ringtone only used with this option\n");
+ exit(-1);
+ }
+
+ started = false;
+ j = 0;
+ for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
+ if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
+ Note = &ringtone.NoteTone.Commands[i].Note;
+ if (!started) {
+ if (Note->Note != Note_Pause) {
+ printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo));
+ started = true;
+ }
+ }
+ if (started) j++;
+ }
+ }
+ if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j);
+
+ printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
+ started = false;
+ for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
+ if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
+ Note = &ringtone.NoteTone.Commands[i].Note;
+ if (!started) {
+ if (Note->Note != Note_Pause) started = true;
+ }
+ if (started) {
+ switch (Note->Duration) {
+ case Duration_Full: printmsg("1"); break;
+ case Duration_1_2 : printmsg("2"); break;
+ case Duration_1_4 : printmsg("4"); break;
+ case Duration_1_8 : printmsg("8"); break;
+ case Duration_1_16: printmsg("16");break;
+ case Duration_1_32: printmsg("32");break;
+ }
+ if (Note->DurationSpec == DottedNote) printmsg(".");
+ switch (Note->Note) {
+ case Note_C : printmsg("c"); break;
+ case Note_Cis : printmsg("#c"); break;
+ case Note_D :printmsg("d"); break;
+ case Note_Dis : printmsg("#d"); break;
+ case Note_E : printmsg("e"); break;
+ case Note_F : printmsg("f"); break;
+ case Note_Fis : printmsg("#f"); break;
+ case Note_G : printmsg("g"); break;
+ case Note_Gis : printmsg("#g"); break;
+ case Note_A : printmsg("a"); break;
+ case Note_Ais : printmsg("#a"); break;
+ case Note_H : printmsg("h"); break;
+ case Note_Pause : printmsg("-"); break;
+ }
+ if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4);
+ printmsg(" ");
+ }
+ }
+ }
+
+ printmsg("\n\nTo enter it please press: ");
+ started = false;
+ for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
+ if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
+ Note = &ringtone.NoteTone.Commands[i].Note;
+ if (!started) {
+ if (Note->Note != Note_Pause) started = true;
+ }
+ if (started) {
+ switch (Note->Note) {
+ case Note_C : case Note_Cis: printmsg("1");break;
+ case Note_D : case Note_Dis: printmsg("2");break;
+ case Note_E : printmsg("3");break;
+ case Note_F : case Note_Fis: printmsg("4");break;
+ case Note_G : case Note_Gis: printmsg("5");break;
+ case Note_A : case Note_Ais: printmsg("6");break;
+ case Note_H : printmsg("7");break;
+ default : printmsg("0");break;
+ }
+ if (Note->DurationSpec == DottedNote) printmsg("(longer)");
+ switch (Note->Note) {
+ case Note_Cis: case Note_Dis:
+ case Note_Fis: case Note_Gis:
+ case Note_Ais:
+ printmsg("#");
+ break;
+ default :
+ break;
+ }
+ if (Note->Note != Note_Pause) {
+ if ((unsigned int)Note->Scale != DefNoteScale) {
+ while (DefNoteScale != (unsigned int)Note->Scale) {
+ printmsg("*");
+ DefNoteScale++;
+ if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880;
+ }
+ }
+ }
+ Duration = 0;
+ switch (Note->Duration) {
+ case Duration_Full : Duration = 128; break;
+ case Duration_1_2 : Duration = 64; break;
+ case Duration_1_4 : Duration = 32; break;
+ case Duration_1_8 : Duration = 16; break;
+ case Duration_1_16 : Duration = 8; break;
+ case Duration_1_32 : Duration = 4; break;
+ default : dbgprintf("error\n");break;
+ }
+ if (Duration > DefNoteDuration) {
+ while (DefNoteDuration != Duration) {
+ printmsg("9");
+ DefNoteDuration = DefNoteDuration * 2;
+ }
+ }
+ if (Duration < DefNoteDuration) {
+ while (DefNoteDuration != Duration) {
+ printmsg("8");
+ DefNoteDuration = DefNoteDuration / 2;
+ }
+ }
+ printmsg(" ");
+ }
+ }
+ }
+
+ printf("\n");
+}
+//#if 0
+static void CopyRingtone(int argc, char *argv[])
+{
+ GSM_Ringtone ringtone, ringtone2;
+ GSM_RingtoneFormat Format;
+
+ ringtone.Format = 0;
+ error=GSM_ReadRingtoneFile(argv[2],&ringtone);
+ Print_Error(error);
+
+ Format = ringtone.Format;
+ if (argc == 5) {
+ if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
+ } else if (mystrncasecmp(argv[4],"BINARY",0)) { Format = RING_NOKIABINARY;
+ } else {
+ printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
+ exit(-1);
+ }
+ }
+
+ error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
+ Print_Error(error);
+
+ error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
+ Print_Error(error);
+}
+
+static void PressKeySequence(int argc, char *argv[])
+{
+ int i,Length;
+ GSM_KeyCode KeyCode[500];
+
+ error = MakeKeySequence(argv[2], KeyCode, &Length);
+ if (error == ERR_NOTSUPPORTED) {
+ printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ for (i=0;i<Length;i++) {
+ error=Phone->PressKey(&s, KeyCode[i], true);
+ Print_Error(error);
+ error=Phone->PressKey(&s, KeyCode[i], false);
+ Print_Error(error);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetAllCategories(int argc, char *argv[])
+{
+ GSM_Category Category;
+ GSM_CategoryStatus Status;
+ int j, count;
+
+ if (mystrncasecmp(argv[2],"TODO",0)) {
+ Category.Type = Category_ToDo;
+ Status.Type = Category_ToDo;
+ } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
+ Category.Type = Category_Phonebook;
+ Status.Type = Category_Phonebook;
+ } else {
+ printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ error=Phone->GetCategoryStatus(&s, &Status);
+ Print_Error(error);
+
+ for (count=0,j=1;count<Status.Used;j++)
+ {
+ Category.Location=j;
+ error=Phone->GetCategory(&s, &Category);
+
+ if (error != ERR_EMPTY) {
+ printmsg("Location: %i\n",j);
+
+ Print_Error(error);
+
+ printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
+ count++;
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void GetCategory(int argc, char *argv[])
+{
+ GSM_Category Category;
+ int start,stop,j;
+
+ if (mystrncasecmp(argv[2],"TODO",0)) {
+ Category.Type = Category_ToDo;
+ } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
+ Category.Type = Category_Phonebook;
+ } else {
+ printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
+
+ GSM_Init(true);
+
+ for (j=start;j<=stop;j++)
+ {
+ printmsg("Location: %i\n",j);
+
+ Category.Location=j;
+
+ error=Phone->GetCategory(&s, &Category);
+ if (error != ERR_EMPTY) Print_Error(error);
+
+ if (error == ERR_EMPTY) {
+ printmsg("Entry is empty\n\n");
+ } else {
+ printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void DeleteToDo(int argc, char *argv[])
+{
+ GSM_ToDoEntry ToDo;
+ int i;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ ToDo.Location=i;
+ printmsg("Location : %i\n",i);
+ error=Phone->DeleteToDo(&s,&ToDo);
+ if (error != ERR_EMPTY) Print_Error(error);
+
+ if (error == ERR_EMPTY) {
+ printmsg("Entry was empty\n");
+ } else {
+ printmsg("Entry was deleted\n");
+ }
+ printf("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void PrintToDo(GSM_ToDoEntry *ToDo)
+{
+ int j;
+ GSM_MemoryEntry entry;
+ unsigned char *name;
+ GSM_Category Category;
+
+ printmsg("Location : %i\n",ToDo->Location);
+ printmsg("Priority : ");
+ switch (ToDo->Priority) {
+ case GSM_Priority_Low : printmsg("Low\n"); break;
+ case GSM_Priority_Medium : printmsg("Medium\n"); break;
+ case GSM_Priority_High : printmsg("High\n"); break;
+ default : printmsg("Unknown\n"); break;
+ }
+ for (j=0;j<ToDo->EntriesNum;j++) {
+ switch (ToDo->Entries[j].EntryType) {
+ case TODO_END_DATETIME:
+ printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
+ break;
+ case TODO_COMPLETED:
+ printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
+ break;
+ case TODO_ALARM_DATETIME:
+ printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
+ break;
+ case TODO_SILENT_ALARM_DATETIME:
+ printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
+ break;
+ case TODO_TEXT:
+ printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
+ break;
+ case TODO_PRIVATE:
+ printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
+ break;
+ case TODO_CATEGORY:
+ Category.Location = ToDo->Entries[j].Number;
+ Category.Type = Category_ToDo;
+ error=Phone->GetCategory(&s, &Category);
+ if (error == ERR_NONE) {
+ printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number);
+ } else {
+ printmsg("Category : %i\n", ToDo->Entries[j].Number);
+ }
+ break;
+ case TODO_CONTACTID:
+ entry.Location = ToDo->Entries[j].Number;
+ entry.MemoryType = MEM_ME;
+ error=Phone->GetMemory(&s, &entry);
+ if (error == ERR_NONE) {
+ name = GSM_PhonebookGetEntryName(&entry);
+ if (name != NULL) {
+ printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
+ } else {
+ printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
+ }
+ } else {
+ printmsg("Contact : %d\n",ToDo->Entries[j].Number);
+ }
+ break;
+ case TODO_PHONE:
+ printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
+ break;
+ }
+ }
+ printf("\n");
+}
+
+static void ListToDoCategoryEntries(int Category)
+{
+ GSM_ToDoEntry Entry;
+ bool start = true;
+ int j;
+
+ while (!gshutdown) {
+ error = Phone->GetNextToDo(&s, &Entry, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ for (j=0;j<Entry.EntriesNum;j++) {
+ if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category)
+ PrintToDo(&Entry);
+ }
+ start = false;
+ }
+}
+
+static void ListToDoCategory(int argc, char *argv[])
+{
+ GSM_Category Category;
+ GSM_CategoryStatus Status;
+ int j, count;
+
+ unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
+ int Length;
+ bool Number = true;;
+
+ GSM_Init(true);
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ Length = strlen(argv[2]);
+ for (j = 0; j < Length; j++) {
+ if (!isdigit(argv[2][j])) {
+ Number = false;
+ break;
+ }
+ }
+
+ if (Number) {
+ j = atoi(argv[2]);
+ if (j > 0) {
+ ListToDoCategoryEntries(j);
+ }
+ } else {
+ if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
+ printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
+ Length = GSM_MAX_CATEGORY_NAME_LENGTH;
+ }
+ EncodeUnicode(Text, argv[2], Length);
+
+ Category.Type = Category_ToDo;
+ Status.Type = Category_ToDo;
+
+ if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
+ for (count=0,j=1;count<Status.Used;j++) {
+ Category.Location=j;
+ error=Phone->GetCategory(&s, &Category);
+
+ if (error != ERR_EMPTY) {
+ count++;
+ if (mystrstr(Category.Name, Text) != NULL) {
+ ListToDoCategoryEntries(j);
+ }
+ }
+ }
+ }
+ }
+ GSM_Terminate();
+}
+
+
+static void GetToDo(int argc, char *argv[])
+{
+ GSM_ToDoEntry ToDo;
+ int i;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ ToDo.Location=i;
+ error = Phone->GetToDo(&s,&ToDo);
+ if (error == ERR_EMPTY) continue;
+ Print_Error(error);
+ PrintToDo(&ToDo);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetAllToDo(int argc, char *argv[])
+{
+ GSM_ToDoEntry ToDo;
+ bool start = true;
+
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
+
+ GSM_Init(true);
+
+ while (!gshutdown) {
+ error = Phone->GetNextToDo(&s, &ToDo, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+ PrintToDo(&ToDo);
+ start = false;
+ }
+
+ GSM_Terminate();
+}
+
+static void GetNote(int argc, char *argv[])
+{
+ GSM_NoteEntry Note;
+ int start,stop;
+ bool refresh=true;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ 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;
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void GetSecurityStatus(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ PrintSecurityStatus();
+
+ GSM_Terminate();
+}
+
+static void EnterSecurityCode(int argc, char *argv[])
+{
+ GSM_SecurityCode Code;
+
+ if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
+ } else if (mystrncasecmp(argv[2],"PUK",0)) { Code.Type = SEC_Puk;
+ } else if (mystrncasecmp(argv[2],"PIN2",0)) { Code.Type = SEC_Pin2;
+ } else if (mystrncasecmp(argv[2],"PUK2",0)) { Code.Type = SEC_Puk2;
+ } else {
+ printmsg("What security code (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ strcpy(Code.Code,argv[3]);
+
+ GSM_Init(true);
+
+ error=Phone->EnterSecurityCode(&s,Code);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void GetProfile(int argc, char *argv[])
+{
+ GSM_Profile Profile;
+ int start,stop,j,k;
+ GSM_Bitmap caller[5];
+ bool callerinit[5],special;
+ GSM_AllRingtonesInfo Info;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ for (i=0;i<5;i++) callerinit[i] = false;
+
+ GSM_Init(true);
+
+ error=Phone->GetRingtonesInfo(&s,&Info);
+ if (error != ERR_NONE) Info.Number = 0;
+
+ for (i=start;i<=stop;i++) {
+ Profile.Location=i;
+ error=Phone->GetProfile(&s,&Profile);
+ Print_Error(error);
+
+ printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
+ if (Profile.Active) printmsg(" (active)");
+ if (Profile.DefaultName) printmsg(" (default name)");
+ if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)");
+ if (Profile.CarKitProfile) printmsg(" (CarKit profile)");
+ printf("\n");
+ for (j=0;j<Profile.FeaturesNumber;j++) {
+ special = false;
+ switch (Profile.FeatureID[j]) {
+ case Profile_MessageToneID:
+ case Profile_RingtoneID:
+ special = true;
+ if (Profile.FeatureID[j] == Profile_RingtoneID) {
+ printmsg("Ringtone ID : ");
+ } else {
+ printmsg("Message alert tone ID : ");
+ }
+ if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) {
+ printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j])));
+ } else {
+ printmsg("%i\n",Profile.FeatureValue[j]);
+ }
+ break;
+ case Profile_CallerGroups:
+ special = true;
+ printmsg("Call alert for :");
+ for (k=0;k<5;k++) {
+ if (Profile.CallerGroups[k]) {
+ if (!callerinit[k]) {
+ caller[k].Type = GSM_CallerGroupLogo;
+ caller[k].Location = k + 1;
+ error=Phone->GetBitmap(&s,&caller[k]);
+ if (error == ERR_SECURITYERROR) {
+ NOKIA_GetDefaultCallerGroupName(&s,&caller[k]);
+ } else {
+ Print_Error(error);
+ }
+ callerinit[k] = true;
+ }
+ printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text));
+ }
+ }
+ printf("\n");
+ break;
+ case Profile_ScreenSaverNumber:
+ special = true;
+ printmsg("Screen saver number : ");
+ printmsg("%i\n",Profile.FeatureValue[j]);
+ break;
+ case Profile_CallAlert : printmsg("Incoming call alert : "); break;
+ case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break;
+ case Profile_Vibration : printmsg("Vibrating alert : "); break;
+ case Profile_MessageTone : printmsg("Message alert tone : "); break;
+ case Profile_KeypadTone : printmsg("Keypad tones : "); break;
+ case Profile_WarningTone : printmsg("Warning (games) tones : "); break;
+ case Profile_ScreenSaver : printmsg("Screen saver : "); break;
+ case Profile_ScreenSaverTime : printmsg("Screen saver timeout : "); break;
+ case Profile_AutoAnswer : printmsg("Automatic answer : "); break;
+ case Profile_Lights : printmsg("Lights : "); break;
+ default:
+ printmsg("Unknown\n");
+ special = true;
+ }
+ if (!special) {
+ switch (Profile.FeatureValue[j]) {
+ case PROFILE_VOLUME_LEVEL1 :
+ case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break;
+ case PROFILE_VOLUME_LEVEL2 :
+ case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break;
+ case PROFILE_VOLUME_LEVEL3 :
+ case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break;
+ case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break;
+ case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break;
+ case PROFILE_MESSAGE_NOTONE :
+ case PROFILE_AUTOANSWER_OFF :
+ case PROFILE_LIGHTS_OFF :
+ case PROFILE_SAVER_OFF :
+ case PROFILE_WARNING_OFF :
+ case PROFILE_CALLALERT_OFF :
+ case PROFILE_VIBRATION_OFF :
+ case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break;
+ case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break;
+ case PROFILE_CALLALERT_BEEPONCE :
+ case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break;
+ case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n"); break;
+ case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break;
+ case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n"); break;
+ case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break;
+ case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break;
+ case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break;
+ case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break;
+ case PROFILE_AUTOANSWER_ON :
+ case PROFILE_WARNING_ON :
+ case PROFILE_SAVER_ON :
+ case PROFILE_VIBRATION_ON : printmsg("On\n"); break;
+ case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n"); break;
+ case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break;
+ case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break;
+ case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break;
+ case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break;
+ case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n"); break;
+ case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n"); break;
+ case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n"); break;
+ default : printmsg("UNKNOWN\n");
+ }
+ }
+ }
+ printf("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void GetSpeedDial(int argc, char *argv[])
+{
+ GSM_SpeedDial SpeedDial;
+ GSM_MemoryEntry Phonebook;
+ int start,stop,Name,Number,Group;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ SpeedDial.Location=i;
+ error=Phone->GetSpeedDial(&s,&SpeedDial);
+ printmsg("%i.",i);
+ switch (error) {
+ case ERR_EMPTY:
+ printmsg(" speed dial not assigned\n");
+ break;
+ default:
+ Print_Error(error);
+
+ Phonebook.Location = SpeedDial.MemoryLocation;
+ Phonebook.MemoryType = SpeedDial.MemoryType;
+ error=Phone->GetMemory(&s,&Phonebook);
+
+ GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group);
+
+ if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text));
+ printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text));
+ }
+ printf("\n");
+ }
+
+ GSM_Terminate();
+}
+
+static void ResetPhoneSettings(int argc, char *argv[])
+{
+ GSM_ResetSettingsType Type;
+
+ if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS;
+ } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE;
+ } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS;
+ } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE;
+ } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY;
+ } else {
+ printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ error=Phone->ResetPhoneSettings(&s,Type);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
+static void NokiaSecurityCode(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3GetSecurityCode(argc,argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+// DCT4ResetSecurityCode(argc, argv);
+ DCT4GetSecurityCode(argc,argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static void NokiaSetPhoneMenus(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3SetPhoneMenus (argc, argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4SetPhoneMenus (argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static void NokiaSelfTests(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3SelfTests(argc, argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4SelfTests(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+#endif
+
+static void DeleteAllSMS(int argc, char *argv[])
+{
+ GSM_MultiSMSMessage sms;
+ GSM_SMSFolders folders;
+ int foldernum;
+ bool start = true;
+
+ GSM_Init(true);
+
+ error=Phone->GetSMSFolders(&s, &folders);
+ Print_Error(error);
+
+ GetStartStop(&foldernum, NULL, 2, argc, argv);
+ if (foldernum > folders.Number) {
+ printmsg("Too high folder number (max. %i)\n",folders.Number);
+ GSM_Terminate();
+ exit(-1);
+ }
+
+ printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
+
+ while (error == ERR_NONE) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->GetNextSMS(&s, &sms, start);
+ switch (error) {
+ case ERR_EMPTY:
+ break;
+ default:
+ Print_Error(error);
+ if (sms.SMS[0].Folder == foldernum) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->DeleteSMS(&s, &sms.SMS[0]);
+ Print_Error(error);
+ printmsg("*");
+ }
+ }
+ start=false;
+ }
+
+ printf("\n");
+
+ GSM_Terminate();
+}
+
+static void SendDTMF(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->SendDTMF(&s,argv[2]);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+static void GetDisplayStatus(int argc, char *argv[])
+{
+ GSM_DisplayFeatures Features;
+ int i;
+
+ GSM_Init(true);
+
+ error=Phone->GetDisplayStatus(&s,&Features);
+ Print_Error(error);
+
+ printmsg("Current display features :\n");
+
+ for (i=0;i<Features.Number;i++) {
+ switch(Features.Feature[i]) {
+ case GSM_CallActive : printmsg("Call active\n"); break;
+ case GSM_UnreadSMS : printmsg("Unread SMS\n"); break;
+ case GSM_VoiceCall : printmsg("Voice call\n"); break;
+ case GSM_FaxCall : printmsg("Fax call\n"); break;
+ case GSM_DataCall : printmsg("Data call\n"); break;
+ case GSM_KeypadLocked : printmsg("Keypad locked\n"); break;
+ case GSM_SMSMemoryFull : printmsg("SMS memory full\n");
+ }
+ }
+
+ GSM_Terminate();
+}
+
+static void SetAutoNetworkLogin(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error=Phone->SetAutoNetworkLogin(&s);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+#ifdef DEBUG
+static void MakeConvertTable(int argc, char *argv[])
+{
+ unsigned char InputBuffer[10000], Buffer[10000];
+ FILE *file;
+ int size,i,j=0;
+
+ file = fopen(argv[2], "rb");
+ if (file == NULL) Print_Error(ERR_CANTOPENFILE);
+ size=fread(InputBuffer, 1, 10000-1, file);
+ fclose(file);
+ InputBuffer[size] = 0;
+ InputBuffer[size+1] = 0;
+
+ ReadUnicodeFile(Buffer,InputBuffer);
+
+ for(i=0;i<((int)UnicodeLength(Buffer));i++) {
+ j++;
+ if (j==100) {
+ printf("\"\\\n\"");
+ j=0;
+ }
+ printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
+ }
+ printf("\\x00\\x00");
+}
+#endif
+
+static void ListNetworks(int argc, char *argv[])
+{
+ extern unsigned char *GSM_Networks[];
+ int i=0;
+
+ printmsg("Network Name\n\n");
+ while (GSM_Networks[i*2]!=NULL) {
+ printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ i++;
+ }
+}
+
+static void Version(int argc, char *argv[])
+{
+// unsigned char buff[10];
+// int len;
+
+ printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
+
+#ifdef DEBUG
+ printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
+ printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
+ printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
+ printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
+ printf("bool - %i\n",sizeof(bool));
+ printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
+ printf("int - %i\n",sizeof(int));
+ printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
+#endif
+
+// len=DecodeBASE64("AXw", buff, 3);
+// DumpMessage(stdout, buff, len);
+}
+
+static void GetFMStation(int argc, char *argv[])
+{
+ GSM_FMStation Station;
+ int start,stop;
+
+ GetStartStop(&start, &stop, 2, argc, argv);
+
+ GSM_Init(true);
+
+ for (i=start;i<=stop;i++) {
+ Station.Location=i;
+ error=Phone->GetFMStation(&s,&Station);
+ switch (error) {
+ case ERR_EMPTY:
+ printmsg("Entry number %i is empty\n",i);
+ break;
+ case ERR_NONE:
+ printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
+ i,DecodeUnicodeConsole(Station.StationName),
+ Station.Frequency);
+ break;
+ default:
+ Print_Error(error);
+ }
+ }
+ GSM_Terminate();
+}
+
+static void GetFileSystemStatus(int argc, char *argv[])
+{
+ GSM_FileSystemStatus Status;
+
+ GSM_Init(true);
+
+ error = Phone->GetFileSystemStatus(&s,&Status);
+ if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
+ Print_Error(error);
+ printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetFileSystem(int argc, char *argv[])
+{
+ bool Start = true;
+ GSM_File Files;
+ int j;
+ GSM_FileSystemStatus Status;
+ char FolderName[256];
+
+ GSM_Init(true);
+
+ while (1) {
+ error = Phone->GetNextFileFolder(&s,&Files,Start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+
+ if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) {
+ if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) {
+ printf("%5s.",Files.ID_FullName);
+ }
+ if (Files.Protected) {
+ printf("P");
+ } else {
+ printf(" ");
+ }
+ if (Files.ReadOnly) {
+ printf("R");
+ } else {
+ printf(" ");
+ }
+ if (Files.Hidden) {
+ printf("H");
+ } else {
+ printf(" ");
+ }
+ if (Files.System) {
+ printf("S");
+ } else {
+ printf(" ");
+ }
+ if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
+ if (!Files.Folder) {
+ if (mystrncasecmp(argv[2],"-flatall",0)) {
+ if (!Files.ModifiedEmpty) {
+ printf(" %30s",OSDateTime(Files.Modified,false));
+ } else printf(" %30c",0x20);
+ printf(" %9i",Files.Used);
+ printf(" ");
+ } else printf("|-- ");
+ } else printf("Folder ");
+ } else {
+ if (Files.Level != 1) {
+ for (j=0;j<Files.Level-2;j++) printf(" | ");
+ printf(" |-- ");
+ }
+ if (Files.Folder) printf("Folder ");
+ }
+ printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
+ printf("\n");
+
+ Start = false;
+ } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
+ /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
+ * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
+ if (!Files.Folder) {
+ printf("%s;File;",Files.ID_FullName);
+ printf("\"%s\";",FolderName);
+ printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
+ if (!Files.ModifiedEmpty) {
+ printf("\"%s\";",OSDateTime(Files.Modified,false));
+ } else printf("\"%c\";",0x20);
+ printf("%i;",Files.Used);
+ } else {
+ printf("%s;Folder;",Files.ID_FullName);
+ printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
+ strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
+ }
+
+ if (Files.Protected) printf("P");
+ if (Files.ReadOnly) printf("R");
+ if (Files.Hidden) printf("H");
+ if (Files.System) printf("S");
+
+ printf("\n");
+
+ Start = false;
+ }
+ }
+
+ error = Phone->GetFileSystemStatus(&s,&Status);
+ if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
+ Print_Error(error);
+ printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
+ }
+
+ GSM_Terminate();
+}
+
+static void GetOneFile(GSM_File *File, bool newtime, int i)
+{
+ FILE *file;
+ bool start;
+ unsigned char buffer[5000];
+ struct utimbuf filedate;
+
+ if (File->Buffer != NULL) {
+ free(File->Buffer);
+ File->Buffer = NULL;
+ }
+ File->Used = 0;
+ start = true;
+
+ error = ERR_NONE;
+ while (error == ERR_NONE) {
+ error = Phone->GetFilePart(&s,File);
+ if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) {
+ if (start) {
+ printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name));
+ start = false;
+ }
+ if (File->Folder) {
+ free(File->Buffer);
+ GSM_Terminate();
+ printmsg("it's folder. Please give only file names\n");
+ exit(-1);
+ }
+ printmsg("*");
+ if (error == ERR_EMPTY) break;
+ if (error == ERR_WRONGCRC) {
+ printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
+ break;
+ }
+ }
+ Print_Error(error);
+ }
+ printf("\n");
+ if (File->Used != 0) {
+ sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name));
+ file = fopen(buffer,"wb");
+ if (file == NULL) {
+ sprintf(buffer,"file%s",File->ID_FullName);
+ file = fopen(buffer,"wb");
+ }
+ if (file == NULL) {
+ sprintf(buffer,"file%i",i);
+ file = fopen(buffer,"wb");
+ }
+ printmsg(" Saving to %s\n",buffer);
+ if (!file) Print_Error(ERR_CANTOPENFILE);
+ fwrite(File->Buffer,1,File->Used,file);
+ fclose(file);
+ if (!newtime && !File->ModifiedEmpty) {
+ /* access time */
+ filedate.actime = Fill_Time_T(File->Modified, 8);
+ /* modification time */
+ filedate.modtime = Fill_Time_T(File->Modified, 8);
+ dbgprintf("Setting date of %s\n",buffer);
+ utime(buffer,&filedate);
+ }
+ }
+}
+
+static void GetFiles(int argc, char *argv[])
+{
+ GSM_File File;
+ int i;
+ bool newtime = false;
+
+ File.Buffer = NULL;
+
+ GSM_Init(true);
+
+ for (i=2;i<argc;i++) {
+ if (mystrncasecmp(argv[i],"-newtime",0)) {
+ newtime = true;
+ continue;
+ }
+
+ strcpy(File.ID_FullName,argv[i]);
+ GetOneFile(&File, newtime, i);
+ }
+
+ free(File.Buffer);
+ GSM_Terminate();
+}
+
+static void GetFileFolder(int argc, char *argv[])
+{
+ bool Start = true;
+ GSM_File File;
+ int level=0,allnum=0,num=0,filelevel=0;
+ bool newtime = false, found;
+
+ File.Buffer = NULL;
+
+ GSM_Init(true);
+
+ for (i=2;i<argc;i++) {
+ if (mystrncasecmp(argv[i],"-newtime",0)) {
+ newtime = true;
+ continue;
+ }
+ allnum++;
+ }
+
+ while (allnum != num) {
+ error = Phone->GetNextFileFolder(&s,&File,Start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+
+ if (level == 0) {
+ /* We search for file or folder */
+ found = false;
+ for (i=2;i<argc;i++) {
+ if (mystrncasecmp(argv[i],"-newtime",0)) {
+ continue;
+ }
+ if (!strcmp(File.ID_FullName,argv[i])) {
+ found = true;
+ if (File.Folder) {
+ level = 1;
+ filelevel = File.Level + 1;
+ Start = false;
+ } else {
+ level = 2;
+ }
+ break;
+ }
+ }
+ if (found && File.Folder) continue;
+ }
+ if (level == 1) {
+ /* We have folder */
+ dbgprintf("%i %i\n",File.Level,filelevel);
+ if (File.Level != filelevel) {
+ level = 0;
+ num++;
+ }
+ }
+
+ if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num);
+
+ if (level == 2) {
+ level = 0;
+ num++;
+ }
+
+ Start = false;
+ }
+
+ free(File.Buffer);
+ GSM_Terminate();
+}
+
+static void AddFile(int argc, char *argv[])
+{
+ GSM_File File;
+ int Pos = 0,i,nextlong;
+
+ File.Buffer = NULL;
+ strcpy(File.ID_FullName,argv[2]);
+ error = GSM_ReadFile(argv[3], &File);
+ Print_Error(error);
+ EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
+ GSM_IdentifyFileFormat(&File);
+
+ File.Protected = false;
+ File.ReadOnly = false;
+ File.Hidden = false;
+ File.System = false;
+
+ if (argc > 4) {
+ nextlong = 0;
+ for (i=4;i<argc;i++) {
+ switch(nextlong) {
+ case 0:
+ if (mystrncasecmp(argv[i],"-type",0)) {
+ nextlong = 1;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-protected",0)) {
+ File.Protected = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-readonly",0)) {
+ File.ReadOnly = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-hidden",0)) {
+ File.Hidden = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-system",0)) {
+ File.System = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-newtime",0)) {
+ File.ModifiedEmpty = true;
+ continue;
+ }
+ printmsg("Parameter \"%s\" unknown\n",argv[i]);
+ exit(-1);
+ case 1:
+ if (mystrncasecmp(argv[i],"JAR",0)) {
+ File.Type = GSM_File_Java_JAR;
+ } else if (mystrncasecmp(argv[i],"JPG",0)) {
+ File.Type = GSM_File_Image_JPG;
+ } else if (mystrncasecmp(argv[i],"BMP",0)) {
+ File.Type = GSM_File_Image_BMP;
+ } else if (mystrncasecmp(argv[i],"WBMP",0)) {
+ File.Type = GSM_File_Image_WBMP;
+ } else if (mystrncasecmp(argv[i],"GIF",0)) {
+ File.Type = GSM_File_Image_GIF;
+ } else if (mystrncasecmp(argv[i],"PNG",0)) {
+ File.Type = GSM_File_Image_PNG;
+ } else if (mystrncasecmp(argv[i],"MIDI",0)) {
+ File.Type = GSM_File_Sound_MIDI;
+ } else if (mystrncasecmp(argv[i],"AMR",0)) {
+ File.Type = GSM_File_Sound_AMR;
+ } else if (mystrncasecmp(argv[i],"NRT",0)) {
+ File.Type = GSM_File_Sound_NRT;
+ } else if (mystrncasecmp(argv[i],"3GP",0)) {
+ File.Type = GSM_File_Video_3GP;
+ } else {
+ printmsg("What file type (\"%s\") ?\n",argv[i]);
+ exit(-1);
+ }
+ nextlong = 0;
+ break;
+ }
+ }
+ if (nextlong!=0) {
+ printmsg("Parameter missed...\n");
+ exit(-1);
+ }
+ }
+
+ GSM_Init(true);
+
+ error = ERR_NONE;
+ while (error == ERR_NONE) {
+ error = Phone->AddFilePart(&s,&File,&Pos);
+ if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
+ printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used);
+ }
+ printmsgerr("\n");
+ if (error == ERR_WRONGCRC) {
+ printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
+ }
+
+ free(File.Buffer);
+ GSM_Terminate();
+}
+
+static void AddFolder(int argc, char *argv[])
+{
+ GSM_File File;
+
+ strcpy(File.ID_FullName,argv[2]);
+ EncodeUnicode(File.Name,argv[3],strlen(argv[3]));
+ File.ReadOnly = false;
+
+ GSM_Init(true);
+
+ error = Phone->AddFolder(&s,&File);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+struct NokiaFolderInfo {
+ char *model;
+ char *parameter;
+ char *folder;
+ char *level;
+};
+
+static struct NokiaFolderInfo Folder[] = {
+ /* Language indepedent in DCT4 */
+ {"", "MMSUnreadInbox", "INBOX", "3"},
+ {"", "MMSReadInbox", "INBOX", "3"},
+ {"", "MMSOutbox", "OUTBOX", "3"},
+ {"", "MMSSent", "SENT", "3"},
+ {"", "MMSDrafts", "DRAFTS", "3"},
+ {"", "Application", "applications", "3"},
+ {"", "Game", "games", "3"},
+ /* Language depedent in DCT4 */
+ {"", "Gallery", "Pictures", "2"}, /* 3510 */
+ {"", "Gallery", "Graphics", "3"}, /* 3510i */
+ {"", "Gallery", "Images", "3"}, /* 6610 */
+ {"3510", "Gallery", "", "8"},
+ {"3510i","Gallery", "", "3"},
+ {"5100", "Gallery", "", "3"},
+ {"6220", "Gallery", "", "5"},
+ {"", "Tones", "Tones", "3"},
+ {"3510i","Tones", "", "4"},
+ {"5100", "Tones", "", "4"},
+ {"6220", "Tones", "", "6"},
+ /* Language indepedent in OBEX */
+ {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX" },
+ {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX" },
+ {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX" },
+ {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
+ {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS" },
+// {"obex", "Application, "", "predefjava\\predefapplications"},
+// {"obex", "Game", "", "predefjava\\predefgames" },
+ {"obex", "Gallery", "", "predefgallery\\predefgraphics" },
+ {"obex", "Tones", "", "predefgallery\\predeftones" },
+
+ /* End of list */
+ {"", "", "", ""}
+};
+
+static void NokiaAddFile(int argc, char *argv[])
+{
+ GSM_File File, Files;
+ FILE *file;
+ GSM_DateTime DT,DT2;
+ time_t t_time1,t_time2;
+ unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400];
+ bool Start = true, Found = false, wasclr;
+ bool ModEmpty = false;
+ int i = 0, Pos, Size, Size2, nextlong;
+
+ while (Folder[i].level[0] != 0) {
+ if (mystrncasecmp(argv[2],Folder[i].parameter,0)) {
+ Found = true;
+ break;
+ }
+ i++;
+ }
+ if (!Found) {
+ printmsg("What folder type (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) {
+ Found = false;
+ i = 0;
+ while (Folder[i].level[0] != 0) {
+ if (!strcmp("obex",Folder[i].model) &&
+ mystrncasecmp(argv[2],Folder[i].parameter,0)) {
+ strcpy(Files.ID_FullName,Folder[i].level);
+ Found = true;
+ break;
+ }
+ i++;
+ }
+ } else {
+ printmsgerr("Searching for phone folder: ");
+ while (1) {
+ error = Phone->GetNextFileFolder(&s,&Files,Start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
+
+ if (Files.Folder) {
+ dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level);
+ Found = false;
+ i = 0;
+ while (Folder[i].level[0] != 0) {
+ EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder));
+ dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level);
+ if (mystrncasecmp(argv[2],Folder[i].parameter,0) &&
+ mywstrncasecmp(Files.Name,buffer,0) &&
+ Files.Level == atoi(Folder[i].level)) {
+ Found = true;
+ break;
+ }
+ if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) &&
+ mystrncasecmp(argv[2],Folder[i].parameter,0) &&
+ !strcmp(Files.ID_FullName,Folder[i].level)) {
+ Found = true;
+ break;
+ }
+ i++;
+ }
+ if (Found) break;
+ }
+ printmsgerr("*");
+
+ Start = false;
+ }
+ printmsgerr("\n");
+ }
+ if (!Found) {
+ printmsg("Folder not found. Probably function not supported !\n");
+ GSM_Terminate();
+ exit(-1);
+ }
+ File.Buffer = NULL;
+ File.Protected = false;
+ File.ReadOnly = false;
+ File.Hidden = false;
+ File.System = false;
+
+ if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) {
+ sprintf(buffer,"%s.jad",argv[3]);
+ file = fopen(buffer,"rb");
+ if (file == NULL) Print_Error(ERR_CANTOPENFILE);
+ fclose(file);
+ sprintf(buffer,"%s.jar",argv[3]);
+ file = fopen(buffer,"rb");
+ if (file == NULL) Print_Error(ERR_CANTOPENFILE);
+ fclose(file);
+
+ /* reading jar file */
+ sprintf(buffer,"%s.jar",argv[3]);
+ error = GSM_ReadFile(buffer, &File);
+ Print_Error(error);
+ Size2 = File.Used;
+
+ /* reading jad file */
+ sprintf(buffer,"%s.jad",argv[3]);
+ error = GSM_ReadFile(buffer, &File);
+ Print_Error(error);
+
+ /* Getting values from JAD file */
+ error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size);
+ if (error == ERR_FILENOTSUPPORTED) {
+ if (Vendor[0] == 0x00) {
+ printmsgerr("No vendor info in JAD file\n");
+ GSM_Terminate();
+ return;
+ }
+ if (Name[0] == 0x00) {
+ printmsgerr("No name info in JAD file\n");
+ GSM_Terminate();
+ return;
+ }
+ if (JAR[0] == 0x00) {
+ printmsgerr("No JAR URL info in JAD file\n");
+ GSM_Terminate();
+ return;
+ }
+ if (Size == -1) {
+ printmsgerr("No JAR size info in JAD file\n");
+ GSM_Terminate();
+ return;
+ }
+ }
+ if (Size != Size2) {
+ printmsgerr("Declared JAR file size is different than real\n");
+ GSM_Terminate();
+ return;
+ }
+ printmsgerr("Adding \"%s\"",Name);
+ if (Version[0] != 0x00) printmsgerr(" version %s",Version);
+ printmsgerr(" created by %s\n",Vendor);
+
+ /* Bostjan Muller 3200 RH-30 3.08 */
+ if (strstr(JAR,"http://") != NULL) {
+ i = strlen(JAR)-1;
+ while (JAR[i] != '/') i--;
+ strcpy(buffer,JAR+i+1);
+ strcpy(JAR,buffer);
+ dbgprintf("New file name is \"%s\"\n",JAR);
+ }
+
+ /* Changing all #13 or #10 to #13#10 in JAD */
+ Pos = 0;
+ wasclr = false;
+ for (i=0;i<File.Used;i++) {
+ switch (File.Buffer[i]) {
+ case 0x0D:
+ case 0x0A:
+ if (!wasclr) {
+ buffer[Pos++] = 0x0D;
+ buffer[Pos++] = 0x0A;
+ wasclr = true;
+ } else wasclr = false;
+ break;
+ default:
+ buffer[Pos++] = File.Buffer[i];
+ wasclr = false;
+ }
+ }
+ File.Buffer = realloc(File.Buffer, Pos);
+ File.Used = Pos;
+ memcpy(File.Buffer,buffer,Pos);
+
+ /* adding folder */
+ strcpy(buffer,Vendor);
+ strcat(buffer,Name);
+ EncodeUnicode(File.Name,buffer,strlen(buffer));
+ strcpy(File.ID_FullName,Files.ID_FullName);
+ error = Phone->AddFolder(&s,&File);
+ Print_Error(error);
+ strcpy(FileID,File.ID_FullName);
+
+ /* adding jad file */
+ strcpy(buffer,JAR);
+ buffer[strlen(buffer) - 1] = 'd';
+ EncodeUnicode(File.Name,buffer,strlen(buffer));
+ File.Type = GSM_File_Other;
+ File.ModifiedEmpty = true;
+ error = ERR_NONE;
+ Pos = 0;
+ while (error == ERR_NONE) {
+ error = Phone->AddFilePart(&s,&File,&Pos);
+ if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
+ printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used);
+ }
+ printmsgerr("\n");
+ if (error == ERR_WRONGCRC) {
+ printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
+ }
+
+ if (argc > 4) {
+ if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true;
+ }
+
+ /* reading jar file */
+ sprintf(buffer,"%s.jar",argv[3]);
+ error = GSM_ReadFile(buffer, &File);
+ Print_Error(error);
+
+ /* adding jar file */
+ strcpy(File.ID_FullName,FileID);
+ strcpy(buffer,JAR);
+ EncodeUnicode(File.Name,buffer,strlen(buffer));
+ File.Type = GSM_File_Java_JAR;
+ File.ModifiedEmpty = true;
+ error = ERR_NONE;
+ Pos = 0;
+ while (error == ERR_NONE) {
+ error = Phone->AddFilePart(&s,&File,&Pos);
+ if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
+ printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used);
+ }
+ printmsgerr("\n");
+ if (error == ERR_WRONGCRC) {
+ printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
+ }
+
+ free(File.Buffer);
+ GSM_Terminate();
+ return;
+ }
+
+ if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
+ strcpy(buffer,argv[3]);
+ if (argc > 4) {
+ nextlong = 0;
+ for (i=4;i<argc;i++) {
+ switch(nextlong) {
+ case 0:
+ if (mystrncasecmp(argv[i],"-name",0)) {
+ nextlong = 1;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-protected",0)) {
+ File.Protected = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-readonly",0)) {
+ File.ReadOnly = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-hidden",0)) {
+ File.Hidden = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-system",0)) {
+ File.System = true;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-newtime",0)) {
+ ModEmpty = true;
+ continue;
+ }
+ printmsg("Parameter \"%s\" unknown\n",argv[i]);
+ exit(-1);
+ case 1:
+ strcpy(buffer,argv[i]);
+ nextlong = 0;
+ break;
+ }
+ }
+ if (nextlong!=0) {
+ printmsg("Parameter missed...\n");
+ exit(-1);
+ }
+ }
+ } else { /* MMS things */
+ DT2.Year = 2001;
+ DT2.Month = 12;
+ DT2.Day = 31;
+ DT2.Hour = 14;
+ DT2.Minute = 00;
+ DT2.Second = 00;
+ t_time2 = Fill_Time_T(DT2,8);
+
+ GSM_GetCurrentDateTime(&DT);
+ t_time1 = Fill_Time_T(DT,8);
+
+ sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40));
+#ifdef DEVELOP
+ sprintf(buffer,"2A947BD 2A947DB ");
+#endif
+ /* 40 = inbox "multimedia message received" message */
+ /* 30 = outbox sending failed */
+ if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 ");
+ else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 ");
+ else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 ");
+ else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 ");
+ else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 ");
+ if (argc > 4) {
+ if (!mystrncasecmp(argv[2],"MMSOutbox",0) &&
+ !mystrncasecmp(argv[2],"MMSSent",0)) {
+ sprintf(Name,"%s",argv[4]);
+ strcat(buffer,Name);
+ }
+ if (argc > 5) {
+ sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]);
+ strcat(buffer,Name);
+ }
+ }
+ ModEmpty = true;
+ }
+
+ error = GSM_ReadFile(argv[3], &File);
+ Print_Error(error);
+ if (ModEmpty) File.ModifiedEmpty = true;
+
+ strcpy(File.ID_FullName,Files.ID_FullName);
+ EncodeUnicode(File.Name,buffer,strlen(buffer));
+ GSM_IdentifyFileFormat(&File);
+#ifdef DEVELOP
+ if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) {
+ } else { /* MMS things */
+ File.Type = GSM_File_MMS;
+ }
+#endif
+
+ dbgprintf("Adding file to filesystem now\n");
+ error = ERR_NONE;
+ Pos = 0;
+ while (error == ERR_NONE) {
+ error = Phone->AddFilePart(&s,&File,&Pos);
+ if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
+ if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used);
+ }
+ printmsgerr("\n");
+ if (error == ERR_WRONGCRC) {
+ printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n");
+ }
+
+ free(File.Buffer);
+ GSM_Terminate();
+}
+
+static void DeleteFiles(int argc, char *argv[])
+{
+ int i;
+
+ GSM_Init(true);
+
+ for (i=2;i<argc;i++) {
+ error = Phone->DeleteFile(&s,argv[i]);
+ Print_Error(error);
+ }
+
+ GSM_Terminate();
+}
+
+static void SaveMMSFile(int argc, char *argv[])
+{
+ FILE *file;
+ unsigned char Buffer[50000],Buffer2[20][2010];
+ int i,nextlong = 0,len = 0;
+ GSM_EncodeMultiPartMMSInfo Info;
+
+ GSM_ClearMultiPartMMSInfo(&Info);
+
+ for (i=3;i<argc;i++) {
+ switch (nextlong) {
+ case 0:
+ if (mystrncasecmp(argv[i],"-subject",0)) {
+ nextlong=1;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-text",0)) {
+ nextlong=2;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-from",0)) {
+ nextlong=3;
+ continue;
+ }
+ if (mystrncasecmp(argv[i],"-to",0)) {
+ nextlong=4;
+ continue;
+ }
+ printmsg("Unknown parameter (\"%s\")\n",argv[i]);
+ exit(-1);
+ break;
+ case 1: /* Subject */
+ EncodeUnicode(Info.Subject,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ case 2: /* Text */
+ EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i]));
+ Info.Entries[Info.EntriesNum].ID = MMS_Text;
+ Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum];
+ Info.EntriesNum++;
+ nextlong = 0;
+ break;
+ case 3: /* From */
+ EncodeUnicode(Info.Source,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ case 4: /* To */
+ EncodeUnicode(Info.Destination,argv[i],strlen(argv[i]));
+ nextlong = 0;
+ break;
+ }
+ }
+ if (nextlong!=0) {
+ printmsg("Parameter missed...\n");
+ exit(-1);
+ }
+
+ GSM_EncodeMMSFile(&Info,Buffer,&len);
+
+ file = fopen(argv[2],"wb");
+ if (file == NULL) Print_Error(ERR_CANTOPENFILE);
+ fwrite(Buffer,1,len,file);
+ fclose(file);
+}
+
+static void CallDivert(int argc, char *argv[])
+{
+ GSM_MultiCallDivert cd;
+
+ if (mystrncasecmp("get", argv[2],0)) {}
+ else if (mystrncasecmp("set", argv[2],0)) {}
+ else {
+ printmsg("Unknown divert action (\"%s\")\n",argv[2]);
+ exit(-1);
+ }
+
+ if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
+ else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;}
+ else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;}
+ else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
+ else {
+ printmsg("Unknown divert type (\"%s\")\n",argv[3]);
+ exit(-1);
+ }
+
+ if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
+ else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;}
+ else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;}
+ else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
+ else {
+ printmsg("Unknown call type (\"%s\")\n",argv[4]);
+ exit(-1);
+ }
+
+ GSM_Init(true);
+
+ if (mystrncasecmp("get", argv[2],0)) {
+ error = Phone->GetCallDivert(&s,&cd);
+ Print_Error(error);
+ printmsg("Query:\n Divert type: ");
+ } else {
+ cd.Request.Number[0] = 0;
+ cd.Request.Number[1] = 0;
+ if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5]));
+
+ cd.Request.Timeout = 0;
+ if (argc > 6) cd.Request.Timeout = atoi(argv[6]);
+
+ error = Phone->SetCallDivert(&s,&cd);
+ Print_Error(error);
+ printmsg("Changed:\n Divert type: ");
+ }
+
+ switch (cd.Request.DivertType) {
+ case GSM_DIVERT_Busy : printmsg("when busy"); break;
+ case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
+ case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage"); break;
+ case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
+ default : printmsg("unknown %i",cd.Request.DivertType); break;
+ }
+ printmsg("\n Calls type : ");
+ switch (cd.Request.CallType) {
+ case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
+ case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
+ case GSM_DIVERT_DataCalls : printmsg("data"); break;
+ case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
+ default : printmsg("unknown %i",cd.Request.CallType); break;
+ }
+ printmsg("\nResponse:");
+
+ for (i=0;i<cd.Response.EntriesNum;i++) {
+ printmsg("\n Calls type : ");
+ switch (cd.Response.Entries[i].CallType) {
+ case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
+ case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
+ case GSM_DIVERT_DataCalls : printmsg("data"); break;
+ default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
+ }
+ printf("\n");
+ printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
+ printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
+ }
+ printf("\n");
+
+ GSM_Terminate();
+}
+
+
+//#if 0
+static void CancelAllDiverts(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+ error = Phone->CancelAllDiverts(&s);
+ Print_Error(error);
+
+ GSM_Terminate();
+}
+
+
+
+void SearchPhoneThread(OneDeviceInfo *Info)
+{
+ int j;
+ GSM_Error error;
+ fprintf(stderr,"*********************************** \n");
+ fprintf(stderr,"*********************************** \n");
+ fprintf(stderr,"*********************************** \n");
+ fprintf(stderr,"*********************************** \n");
+ fprintf(stderr,"*********************************** \n");
+#if 0
+ 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);
+ 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);
+ if (error == ERR_NONE) {
+ error=Info->s.Phone.Functions->GetModel(&Info->s);
+ if (error == ERR_NONE) {
+ if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
+ printmsg(" Manufacturer : %s\n",
+ Info->s.Phone.Data.Manufacturer);
+ printmsg(" Model : %s (%s)\n",
+ Info->s.Phone.Data.ModelInfo->model,
+ Info->s.Phone.Data.Model);
+ } else {
+ if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ }
+ } else {
+ if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ }
+ } else {
+ if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ }
+ if (error != ERR_DEVICEOPENERROR) {
+ GSM_TerminateConnection(&Info->s);
+ dbgprintf("Closing done\n");
+ }
+ if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break;
+ j++;
+ }
+ num--;
+#endif
+}
+
+//#undef HAVE_PTHREAD
+//#if 0
+#if defined(WIN32) || defined(HAVE_PTHREAD)
+#ifdef HAVE_PTHREAD
+ pthread_t Thread[100];
+#endif
+
+void MakeSearchThread(int i)
+{
+ num++;
+#ifdef HAVE_PTHREAD
+ if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
+ dbgprintf("Error creating thread\n");
+ }
+#else
+ if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
+ (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
+ 0,NULL)==NULL) {
+ dbgprintf("Error creating thread\n");
+ }
+#endif
+}
+
+static void SearchPhone(int argc, char *argv[])
+{
+ int i,dev = 0, dev2 = 0;
+
+ SearchOutput = false;
+ if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
+
+ num = 0;
+#ifdef WIN32
+# ifdef GSM_ENABLE_IRDADEVICE
+ sprintf(SearchDevices[dev].Device,"");
+ sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
+ SearchDevices[dev].Connections[1].Connection[0] = 0;
+ dev++;
+# endif
+# ifdef GSM_ENABLE_SERIALDEVICE
+ dev2 = dev;
+ for(i=0;i<10;i++) {
+ sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
+ sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
+ sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
+ sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
+ sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
+ SearchDevices[dev2].Connections[4].Connection[0] = 0;
+ dev2++;
+ }
+# endif
+#endif
+#ifdef __linux__
+# ifdef GSM_ENABLE_IRDADEVICE
+ for(i=0;i<6;i++) {
+ sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i);
+ sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
+ sprintf(SearchDevices[dev].Connections[1].Connection,"at19200");
+ SearchDevices[dev].Connections[2].Connection[0] = 0;
+ dev++;
+ }
+# endif
+# ifdef GSM_ENABLE_SERIALDEVICE
+ dev2 = dev;
+ for(i=0;i<10;i++) {
+ sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i);
+ sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
+ sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
+ sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
+ sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
+ SearchDevices[dev2].Connections[4].Connection[0] = 0;
+ dev2++;
+ }
+ for(i=0;i<8;i++) {
+ sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i);
+ sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
+ sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
+ sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
+ sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
+ SearchDevices[dev2].Connections[4].Connection[0] = 0;
+ dev2++;
+ }
+ for(i=0;i<4;i++) {
+ sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i);
+ sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
+ sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
+ sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
+ sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
+ SearchDevices[dev2].Connections[4].Connection[0] = 0;
+ dev2++;
+ }
+# endif
+#endif
+ for(i=0;i<dev;i++) MakeSearchThread(i);
+ while (num != 0) my_sleep(5);
+ for(i=dev;i<dev2;i++) MakeSearchThread(i);
+ while (num != 0) my_sleep(5);
+}
+#endif /*Support for threads */
+// #if 0
+static void NokiaGetADC(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3GetADC(argc,argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4GetADC(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static void NokiaDisplayTest(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3DisplayTest(argc,argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4DisplayTest(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static void NokiaGetT9(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3GetT9(argc,argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4GetT9(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static void NokiaVibraTest(int argc, char *argv[])
+{
+ GSM_Init(true);
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ DCT3VibraTest(argc,argv);
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ DCT4VibraTest(argc, argv);
+#endif
+
+ GSM_Terminate();
+}
+
+static GSM_Parameters Parameters[] = {
+ {"--identify", 0, 0, Identify, {H_Info,0}, ""},
+ {"--version", 0, 0, Version, {H_Other,0}, ""},
+ {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
+ {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0}, "[times]"},
+ {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
+ {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""},
+ {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
+ {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
+ {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
+ {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
+ {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
+ {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
+ {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"},
+ {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
+ {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Application|Game file [-readonly]"},
+ {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
+ {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
+ {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
+ {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""},
+ {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
+ {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
+ {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
+ {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
+ {"--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"},
+ {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
+ {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0}, "text|number"},
+ {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
+ {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
+ {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
+ {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
+ {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
+ {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
+ {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
+ {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
+
+#define SMS_TEXT_OPTIONS "[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
+#define SMS_PICTURE_OPTIONS "[-text text][-unicode][-alcatelbmmi]"
+#define SMS_PROFILE_OPTIONS "[-name name][-bitmap bitmap][-ringtone ringtone]"
+#define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]"
+#define SMS_SMSTEMPLATE_OPTIONS "[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]"
+#define SMS_ANIMATION_OPTIONS ""
+#define SMS_OPERATOR_OPTIONS "[-netcode netcode][-biglogo]"
+#define SMS_SAVE_OPTIONS "[-folder id][-unread][-read][-unsent][-sent][-sender number]"
+#define SMS_SEND_OPTIONS "[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
+#define SMS_COMMON_OPTIONS "[-smscset number][-smscnumber number][-reply][-maxsms num]"
+
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+#ifdef GSM_ENABLE_BACKUP
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+#endif
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
+
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+#ifdef GSM_ENABLE_BACKUP
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+#endif
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
+
+ {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"},
+
+ {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"},
+#ifdef HAVE_MYSQL_MYSQL_H
+ {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"},
+#endif
+ {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"},
+ {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"},
+ {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
+ {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
+ {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""},
+ {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"},
+ {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"},
+ {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"},
+ {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"},
+ {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"},
+ {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"},
+ {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"},
+ {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"},
+ {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"},
+ {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"},
+ {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
+ {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
+ {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
+ {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
+ {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
+ {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
+ {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
+ {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0}, ""},
+ {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
+ {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
+ {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
+ {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
+ {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"},
+ {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
+ {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
+ {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
+ {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK start [stop]"},
+ {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK"},
+ {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
+ {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
+ {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
+ {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
+ {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
+ {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
+ {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
+ {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"},
+ {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"},
+ {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"},
+ {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"},
+ {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"},
+ {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"},
+ {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
+ {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"},
+#if defined(WIN32) || defined(HAVE_PTHREAD)
+ {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"},
+#endif
+#ifdef GSM_ENABLE_BACKUP
+ {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0}, "CALENDAR target.vcs file location"},
+ {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"},
+ {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
+ {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"},
+ {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"},
+ {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"},
+ {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
+ {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
+ {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"},
+ {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"},
+#endif
+ {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, ""},
+ {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""},
+#ifdef GSM_ENABLE_AT
+ {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0}, ""},
+ {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"},
+ {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0}, "test"},
+#endif
+#ifdef GSM_ENABLE_NOKIA6110
+ {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
+ {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
+ {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT3
+ {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
+ {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
+ {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
+#endif
+#ifdef GSM_ENABLE_NOKIA_DCT4
+ {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
+ {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
+ {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
+ {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
+ {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
+ {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
+#endif
+#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
+ {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
+ {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
+ {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
+ {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
+ {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
+ {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
+ {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
+#endif
+#ifdef DEBUG
+ {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"},
+ {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"},
+ {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"},
+#endif
+ {"", 0, 0, NULL }
+};
+
+static HelpCategoryDescriptions HelpDescriptions[] = {
+ {H_Call, "call", "Calls",},
+ {H_SMS, "sms", "SMS and EMS"},
+ {H_Memory, "memory", "Memory (phonebooks and calls)"},
+ {H_Filesystem, "filesystem", "Filesystem"},
+ {H_Logo, "logo", "Logo and pictures"},
+ {H_Ringtone, "ringtone", "Ringtones"},
+ {H_Calendar, "calendar", "Calendar notes"},
+ {H_ToDo, "todo", "To do lists"},
+ {H_Note, "note", "Notes"},
+ {H_DateTime, "datetime", "Date, time and alarms"},
+ {H_Category, "category", "Categories"},
+#ifdef GSM_ENABLE_BACKUP
+ {H_Backup, "backup", "Backing up and restoring"},
+#endif
+#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
+ {H_Nokia, "nokia", "Nokia specific"},
+#endif
+#ifdef GSM_ENABLE_AT
+ {H_Siemens, "siemens", "Siemens specific"},
+#endif
+ {H_Network, "network", "Network"},
+ {H_WAP, "wap", "WAP settings and bookmarks"},
+ {H_MMS, "mms", "MMS and MMS settings"},
+ {H_Tests, "tests", "Phone tests"},
+ {H_FM, "fm", "FM radio"},
+ {H_Info, "info", "Phone information"},
+ {H_Settings, "settings", "Phone settings"},
+#ifdef DEBUG
+ {H_Decode, "decode", "Dumps decoding"},
+#endif
+ {H_Other, "other", "Functions that don't fit elsewhere"},
+ {0, NULL, NULL}
+};
+
+
+void HelpHeader(void)
+{
+ printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
+}
+
+static void HelpGeneral(void)
+{
+ int i=0;
+
+ HelpHeader();
+
+ 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");
+
+ /* 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");
+
+ while (HelpDescriptions[i].category != 0) {
+ printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
+ i++;
+ }
+ printf("\n");
+}
+
+static void HelpSplit(int cols, int len, unsigned char *buff)
+{
+ int l, len2, pos, split;
+ bool in_opt,first=true;
+ char *remain, spaces[50], buffer[500];
+
+ if (cols == 0) {
+ printf(" %s\n", buff);
+ } else {
+ printf(" ");
+ spaces[0] = 0;
+ len2 = strlen(buff);
+ if (len + len2 < cols) {
+ printf("%s\n", buff);
+ } else {
+ for(l = 0; l < len; l++) strcat(spaces, " ");
+
+ remain = buff;
+
+ while (strlen(remain) > 0) {
+ split = 0;
+ pos = 0;
+ in_opt = false;
+ if (!first) printf(spaces);
+ while (pos < cols - len && remain[pos] != 0) {
+ if (in_opt && remain[pos] == ']') {
+ in_opt = false;
+ split = pos;
+ } else if (remain[pos] == '[') {
+ in_opt = true;
+ } else if (!in_opt && remain[pos] == ' ') {
+ split = pos - 1;
+ }
+ pos++;
+ }
+ /* Can not be split */
+ if (split == 0) {
+ printf("%s\n", remain);
+ remain += strlen(remain);
+ } else {
+ first = false;
+ split++;
+ strncpy(buffer, remain, split);
+ buffer[split] = 0;
+ printf("%s\n", buffer);
+ remain += split;
+ if (remain[0] == ' ') remain++;
+ }
+ }
+ }
+ }
+}
+
+static void Help(int argc, char *argv[])
+{
+ int i = 0, j = 0, k, cols;
+ bool disp;
+#ifdef TIOCGWINSZ
+ struct winsize w;
+#endif
+#if defined(WIN32) || defined(DJGPP)
+#else
+ char *columns;
+#endif
+
+ /* Just --help */
+ if (argc == 2) {
+ HelpGeneral();
+ return;
+ }
+
+ if (!strcmp(argv[2],"all")) {
+ HelpHeader();
+ } else {
+ while (HelpDescriptions[i].category != 0) {
+ if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break;
+ i++;
+ }
+ if (HelpDescriptions[i].category == 0) {
+ HelpGeneral();
+ printmsg("Unknown help topic specified!\n");
+ return;
+ }
+ HelpHeader();
+ printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
+ }
+
+#if defined(WIN32) || defined(DJGPP)
+ cols = 80;
+#else
+ cols = 0;
+ /* If stdout is a tty, we will wrap to columns it has */
+ if (isatty(1)) {
+#ifdef TIOCGWINSZ
+ if (ioctl(2, TIOCGWINSZ, &w) == 0) {
+ if (w.ws_col > 0) cols = w.ws_col;
+ }
+#endif
+ if (cols == 0) {
+ columns = getenv("COLUMNS");
+ if (columns != NULL) {
+ cols = atoi(columns);
+ if (cols <= 0) cols = 0;
+ }
+ }
+
+ if (cols == 0) {
+ /* Fallback */
+ cols = 80;
+ }
+ }
+#endif
+
+ while (Parameters[j].Function != NULL) {
+ k = 0;
+ disp = false;
+ if (!strcmp(argv[2],"all")) {
+ if (j==0) disp = true;
+ if (j!=0) {
+ if (strcmp(Parameters[j].help,Parameters[j-1].help)) {
+ disp = true;
+ } else {
+ if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) {
+ disp = true;
+ }
+ }
+ }
+ } else {
+ while (Parameters[j].help_cat[k] != 0) {
+ if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) {
+ disp = true;
+ break;
+ }
+ k++;
+ }
+ }
+ if (disp) {
+ printf("%s", Parameters[j].parameter);
+ if (Parameters[j].help[0] == 0) {
+ printf("\n");
+ } else {
+ HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help);
+ }
+ }
+ j++;
+ }
+}
+#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];
+#endif
+ static char *cp;
+ static bool count_failed;
+ z = 0;
+ start=0;only_config = -1;count_failed = false;
+ s.opened = false;
+ s.msg = NULL;
+ s.ConfigNum = 0;
+
+ setlocale(LC_ALL, "");
+#ifdef DEBUG
+ di.dl = DL_TEXTALL;
+ di.df = stdout;
+#endif
+ //#if 0
+ /* Any parameters? */
+ if (argc == 1) {
+ HelpGeneral();
+ printmsg("Too few parameters!\n");
+ exit(1);
+ }
+
+ /* Help? */
+ if (strncmp(argv[1 + start], "--help", 6) == 0) {
+ Help(argc - start, argv + start);
+ exit(1);
+ }
+
+ /* 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;
+ }
+
+ cfg=GSM_FindGammuRC();
+ for (i = 0; i <= MAX_CONFIG_NUM; i++) {
+ if (cfg!=NULL) {
+ cp = INI_GetValue(cfg, "gammu", "gammucoding", false);
+ if (cp) di.coding = cp;
+
+ s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false);
+ if (s.Config[i].Localize) {
+ s.msg=INI_ReadFile(s.Config[i].Localize, true);
+ } else {
+#if !defined(WIN32) && defined(LOCALE_PATH)
+ locale = setlocale(LC_MESSAGES, NULL);
+ if (locale != NULL) {
+ snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
+ LOCALE_PATH,
+ tolower(locale[0]),
+ tolower(locale[1]));
+ s.msg = INI_ReadFile(locale_file, true);
+ }
+#endif
+ }
+ }
+
+ /* Wanted user specific configuration? */
+ if (only_config != -1) {
+ /* Here we get only in first for loop */
+ if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break;
+ } else {
+ if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
+ }
+ s.ConfigNum++;
+
+ /* We want to use only one file descriptor for global and state machine debug output */
+ s.Config[i].UseGlobalDebugFile = true;
+
+ /* It makes no sense to open several debug logs... */
+ if (i != 0) {
+ strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel);
+ free(s.Config[i].DebugFile);
+ s.Config[i].DebugFile = strdup(s.Config[0].DebugFile);
+ } else {
+ /* Just for first config */
+ /* When user gave debug level on command line */
+ if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) {
+ /* Debug level from command line will be used with phone too */
+ strcpy(s.Config[i].DebugLevel,argv[1 + start]);
+ start++;
+ } else {
+ /* Try to set debug level from config file */
+ GSM_SetDebugLevel(s.Config[i].DebugLevel, &di);
+ }
+ /* If user gave debug file in gammurc, we will use it */
+ error=GSM_SetDebugFile(s.Config[i].DebugFile, &di);
+ Print_Error(error);
+ }
+
+ /* We wanted to read just user specified configuration. */
+ if (only_config != -1) {break;}
+ }
+
+ /* Do we have enough parameters? */
+ if (argc == 1 + start) {
+ HelpGeneral();
+ printmsg("Too few parameters!\n");
+ exit(-2);
+ }
+
+ /* Check used version vs. compiled */
+ if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) {
+ printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
+ GetGammuVersion(),VERSION);
+ exit(-1);
+ }
+
+ /* Check parameters */
+ while (Parameters[z].Function != NULL) {
+ if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) {
+ if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
+ Parameters[z].Function(argc - start, argv + start);
+ break;
+ } else {
+ count_failed = true;
+ }
+ }
+ z++;
+ }
+
+ /* Tell user when we did nothing */
+ if (Parameters[z].Function == NULL) {
+ HelpGeneral();
+ if (count_failed) {
+ printmsg("Bad parameter count!\n");
+ } else {
+ printmsg("Bad option!\n");
+ }
+ }
+
+ /* Close debug output if opened */
+ if (di.df!=stdout) fclose(di.df);
+ //#endif // 0
+ fprintf(stderr,"kammu: Success. End. \n");
+ exit(0);
+}
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
+
diff --git a/gammu/emb/gammu/gammu.h b/gammu/emb/gammu/gammu.h
new file mode 100644
index 0000000..d3de31b
--- a/dev/null
+++ b/gammu/emb/gammu/gammu.h
@@ -0,0 +1,74 @@
+/* (c) 2002-2003 by Marcin Wiacek and Michal Cihar */
+
+#include "../common/config.h"
+#include "../common/misc/misc.h"
+#include "../common/gsmstate.h"
+
+typedef enum {
+ H_Call=1,
+ H_SMS,
+ H_Memory,
+ H_Filesystem,
+ H_Logo,
+ H_Ringtone,
+ H_Calendar,
+ H_ToDo,
+ H_Note,
+ H_DateTime,
+ H_Category,
+ H_Tests,
+#ifdef GSM_ENABLE_BACKUP
+ H_Backup,
+#endif
+#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
+ H_Nokia,
+#endif
+#ifdef GSM_ENABLE_AT
+ H_Siemens,
+#endif
+ H_Network,
+ H_WAP,
+ H_MMS,
+ H_FM,
+ H_Info,
+ H_Settings,
+#ifdef DEBUG
+ H_Decode,
+#endif
+ H_Other
+} HelpCategory;
+
+typedef struct {
+ HelpCategory category;
+ char *option;
+ char *description;
+} HelpCategoryDescriptions;
+
+typedef struct {
+ char *parameter;
+ int min_arg;
+ int max_arg;
+ void (*Function) (int argc, char *argv[]);
+ HelpCategory help_cat[10];
+ char *help;
+} GSM_Parameters;
+
+void Print_Error (GSM_Error error);
+void GSM_Init (bool checkerror);
+void GSM_Terminate (void);
+
+static GSM_StateMachine s;
+static GSM_Phone_Functions *Phone;
+static GSM_Error error;
+
+static bool gshutdown;
+
+void interrupt(int sign);
+
+#ifdef GSM_ENABLE_BEEP
+void GSM_PhoneBeep (void);
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/gammu.pro b/gammu/emb/gammu/gammu.pro
new file mode 100644
index 0000000..bd683c4
--- a/dev/null
+++ b/gammu/emb/gammu/gammu.pro
@@ -0,0 +1,52 @@
+######################################################################
+# Automatically generated by qmake (1.07a) Fri Jul 30 22:22:02 2004
+######################################################################
+
+TEMPLATE = app
+DEPENDPATH += msvc06.mak \
+ msvc2003.mak \
+ smsd \
+ depend/nokia \
+ depend/siemens \
+ depend/nokia/dct3trac
+INCLUDEPATH += . smsd depend/nokia depend/nokia/dct3trac depend/siemens
+CONFIG = qt warn_off release
+# Input
+
+HEADERS += gammu.h \
+ sniff.h \
+ smsd/s_files.h \
+ smsd/s_mysql.h \
+ smsd/smsdcore.h \
+ depend/nokia/dct3.h \
+ depend/nokia/dct4.h \
+ depend/siemens/chiffre.h \
+ depend/siemens/dsiemens.h \
+ depend/nokia/dct3trac/type-cc.h \
+ depend/nokia/dct3trac/type-mm.h \
+ depend/nokia/dct3trac/type-rr.h \
+ depend/nokia/dct3trac/type-sms.h \
+ depend/nokia/dct3trac/type-ss.h \
+ depend/nokia/dct3trac/wmx-gsm.h \
+ depend/nokia/dct3trac/wmx-list.h \
+ depend/nokia/dct3trac/wmx-sim.h \
+ depend/nokia/dct3trac/wmx-util.h \
+ depend/nokia/dct3trac/wmx.h
+SOURCES += gammu.c \
+ sniff.c \
+ smsd/s_files.c \
+ smsd/smsdcore.c \
+ depend/nokia/dct3.c \
+ depend/nokia/dct4.c \
+ depend/siemens/chiffre.c \
+ depend/siemens/dsiemens.c \
+ depend/nokia/dct3trac/wmx-gsm.c \
+ depend/nokia/dct3trac/wmx-list.c \
+ depend/nokia/dct3trac/wmx-sim.c \
+ depend/nokia/dct3trac/wmx-util.c \
+ depend/nokia/dct3trac/wmx.c
+
+LIBS += ../../../bin/libmicrogammu.so /usr/lib/libbluetooth.so /usr/lib/libsdp.so /usr/lib/libpthread.so
+DESTDIR = ../../../bin
+OBJECTS_DIR = obj/unix
+TARGET = kammu \ No newline at end of file
diff --git a/gammu/emb/gammu/gammuE.pro b/gammu/emb/gammu/gammuE.pro
new file mode 100644
index 0000000..a1028cb
--- a/dev/null
+++ b/gammu/emb/gammu/gammuE.pro
@@ -0,0 +1,55 @@
+######################################################################
+# Automatically generated by qmake (1.07a) Fri Jul 30 22:22:02 2004
+######################################################################
+
+TEMPLATE = app
+DEPENDPATH += msvc06.mak \
+ msvc2003.mak \
+ smsd \
+ depend/nokia \
+ depend/siemens \
+ depend/nokia/dct3trac
+INCLUDEPATH += . smsd depend/nokia depend/nokia/dct3trac depend/siemens
+CONFIG = qt warn_off release
+# Input
+
+HEADERS += gammu.h \
+ sniff.h \
+ smsd/s_files.h \
+ smsd/s_mysql.h \
+ smsd/smsdcore.h \
+ depend/nokia/dct3.h \
+ depend/nokia/dct4.h \
+ depend/siemens/chiffre.h \
+ depend/siemens/dsiemens.h \
+ depend/nokia/dct3trac/type-cc.h \
+ depend/nokia/dct3trac/type-mm.h \
+ depend/nokia/dct3trac/type-rr.h \
+ depend/nokia/dct3trac/type-sms.h \
+ depend/nokia/dct3trac/type-ss.h \
+ depend/nokia/dct3trac/wmx-gsm.h \
+ depend/nokia/dct3trac/wmx-list.h \
+ depend/nokia/dct3trac/wmx-sim.h \
+ depend/nokia/dct3trac/wmx-util.h \
+ depend/nokia/dct3trac/wmx.h
+SOURCES += gammu.c \
+ sniff.c \
+ smsd/s_files.c \
+ smsd/smsdcore.c \
+ depend/nokia/dct3.c \
+ depend/nokia/dct4.c \
+ depend/siemens/chiffre.c \
+ depend/siemens/dsiemens.c \
+ depend/nokia/dct3trac/wmx-gsm.c \
+ depend/nokia/dct3trac/wmx-list.c \
+ depend/nokia/dct3trac/wmx-sim.c \
+ depend/nokia/dct3trac/wmx-util.c \
+ depend/nokia/dct3trac/wmx.c
+
+LIBS += -lmicrogammu
+LIBS += -lbluetooth
+LIBS += -lsdp
+LIBS += -lpthread
+DESTDIR=$(QPEDIR)/bin
+OBJECTS_DIR = obj/$(PLATFORM)
+TARGET = kammu \ No newline at end of file
diff --git a/gammu/emb/gammu/smsd/s_files.c b/gammu/emb/gammu/smsd/s_files.c
new file mode 100644
index 0000000..dac8d9c
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/s_files.c
@@ -0,0 +1,313 @@
+/* (c) 2002-2003 by Joergen Thomsen */
+
+#include "../../cfg/config.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <time.h>
+#ifdef WIN32
+# include <io.h>
+#endif
+#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT
+# include <dirent.h>
+#endif
+
+#include "../../common/misc/coding/coding.h"
+#include "../../common/service/backup/gsmback.h"
+#include "smsdcore.h"
+
+/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
+static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
+{
+ GSM_Error error = ERR_NONE;
+ int i,j;
+ unsigned char FileName[100], FullName[400], ext[4], buffer[64],buffer2[400];
+ bool done;
+ FILE *file;
+#ifdef GSM_ENABLE_BACKUP
+ GSM_SMS_Backup backup;
+#endif
+
+ j = 0;
+ done = false;
+ for (i=0;i<sms.Number && !done;i++) {
+ strcpy(ext, "txt");
+ if (sms.SMS[i].Coding == SMS_Coding_8bit) strcpy(ext, "bin");
+ DecodeUnicode(sms.SMS[i].Number,buffer2);
+ /* we loop on yy for the first SMS assuming that if xxxx_yy_00.ext is absent,
+ any xxxx_yy_01,02, must be garbage, that can be overwritten */
+ file = NULL;
+ do {
+ sprintf(FileName,
+ "IN%02d%02d%02d_%02d%02d%02d_%02i_%s_%02i.%s",
+ 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,
+ j, buffer2, i, ext);
+ strcpy(FullName, Config->inboxpath);
+ strcat(FullName, FileName);
+ if (file) fclose(file);
+ file = fopen(FullName, "r");
+ } while ((i == 0) && (file && (++j < 100)));
+ if (file) {
+ fclose(file);
+ if (i == 0) {
+ WriteSMSDLog("Cannot save %s. No available file names", FileName);
+ return ERR_CANTOPENFILE;
+ }
+ }
+ errno = 0;
+
+ 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);
+ } else {
+#ifdef GSM_ENABLE_BACKUP
+ if (mystrncasecmp(Config->inboxformat, "detail", 0)) {
+ for (j=0;j<sms.Number;j++) backup.SMS[j] = &sms.SMS[j];
+ backup.SMS[sms.Number] = NULL;
+ error = GSM_SaveSMSBackupFile(FullName, &backup);
+ done = true;
+ }
+#endif
+ if (!mystrncasecmp(Config->inboxformat, "detail", 0)) {
+ file = fopen(FullName, "wb");
+ if (file) {
+ switch (sms.SMS[i].Coding) {
+ case SMS_Coding_Unicode:
+ case SMS_Coding_Default:
+
+ DecodeUnicode(sms.SMS[i].Text,buffer2);
+ if (mystrncasecmp(Config->inboxformat, "unicode", 0)) {
+ buffer[0] = 0xFE;
+ buffer[1] = 0xFF;
+ fwrite(buffer,1,2,file);
+ fwrite(sms.SMS[i].Text,1,strlen(buffer2)*2,file);
+ } else {
+ fwrite(buffer2,1,strlen(buffer2),file);
+ }
+ break;
+ case SMS_Coding_8bit:
+ fwrite(sms.SMS[i].Text,1,sms.SMS[i].Length,file);
+ }
+ fclose(file);
+ } else error = ERR_CANTOPENFILE;
+ }
+ if (error == ERR_NONE) {
+ WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName);
+ } else {
+ WriteSMSDLog("Cannot save %s (%i)", FileName, errno);
+ return ERR_CANTOPENFILE;
+ }
+ }
+ }
+ return ERR_NONE;
+}
+
+/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
+ * There is also set ID for SMS
+ */
+static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
+{
+ GSM_Error error = ERR_NOTSUPPORTED;
+ GSM_MultiPartSMSInfo SMSInfo;
+ unsigned char FileName[100],FullName[400];
+ unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
+ unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
+ FILE *File;
+ int i, len, phlen;
+ char *pos1, *pos2;
+#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT
+ struct dirent **namelist = NULL;
+ int l, m ,n;
+
+ strcpy(FullName, Config->outboxpath);
+ FullName[strlen(Config->outboxpath)-1] = '\0';
+ n = scandir(FullName, &namelist, 0, alphasort);
+ m = 0;
+ while ((m < n) && ((*(namelist[m]->d_name) == '.') ||
+ !mystrncasecmp(namelist[m]->d_name,"out", 3) ||
+ ((strlen(namelist[m]->d_name) >= 4) &&
+ !mystrncasecmp(&namelist[m]->d_name[strlen(namelist[m]->d_name)-4],".txt",4)
+ )
+ )
+ ) m++;
+ if (m < n) strcpy(FileName,namelist[m]->d_name);
+ for (l=0; l < n; l++) free(namelist[l]);
+ free(namelist);
+ namelist = NULL;
+ if (m >= n) return ERR_EMPTY;
+ error = ERR_NONE;
+#else
+#ifdef WIN32
+ struct _finddata_t c_file;
+ long hFile;
+
+ strcpy(FullName, Config->outboxpath);
+ strcat(FullName, "OUT*.txt");
+ if((hFile = _findfirst( FullName, &c_file )) == -1L ) {
+ return ERR_EMPTY;
+ } else {
+ strcpy(FileName,c_file.name);
+ }
+ _findclose( hFile );
+ error = ERR_NONE;
+#endif
+#endif
+ if (error != ERR_NONE) return error;
+
+ strcpy(FullName, Config->outboxpath);
+ strcat(FullName, FileName);
+
+ File = fopen(FullName, "rb");
+ len = fread(Buffer, 1, sizeof(Buffer)-2, File);
+ fclose(File);
+ if (len<2) return ERR_EMPTY;
+
+ if ((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;
+ EncodeUnicode(Buffer2, Buffer, len);
+ len = len*2;
+ memmove(Buffer, Buffer2, len);
+ }
+
+ Buffer[len] = 0;
+ Buffer[len+1] = 0;
+ ReadUnicodeFile(Buffer2,Buffer);
+
+ SMSInfo.ReplaceMessage = 0;
+ SMSInfo.Entries[0].Buffer = Buffer2;
+ SMSInfo.Class = -1;
+ SMSInfo.EntriesNum = 1;
+ if (mystrncasecmp(Config->transmitformat, "unicode", 0)) {
+ SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
+ SMSInfo.UnicodeCoding = true;
+ } else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) {
+ SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
+ SMSInfo.UnicodeCoding = false;
+ } else {
+ /* auto */
+ SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
+ }
+ GSM_EncodeMultiPartSMS(&SMSInfo,sms);
+
+ pos1 = FileName;
+ strcpy(ID,FileName);
+ for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_');
+ if (pos1 != NULL) {
+ /* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */
+ pos2 = strchr(++pos1, '_');
+ if (pos2 != NULL) {
+ phlen = strlen(pos1) - strlen(pos2);
+ } else {
+ /* something wrong */
+ return ERR_UNKNOWN;
+ }
+ } else if (i == 2) {
+ /* OUTxxxxxxx.txt or OUTxxxxxxx */
+ pos1 = &FileName[3];
+ pos2 = strchr(pos1, '.');
+ if (pos2 == NULL) {
+ phlen = strlen(pos1);
+ } else {
+ phlen = strlen(pos1) - strlen(pos2);
+ }
+ } else if (i == 4) {
+ /* OUT<priority>_<phone number>_<serialno>.txt */
+ pos1 = strchr(FileName, '_');
+ pos2 = strchr(++pos1, '_');
+ phlen = strlen(pos1) - strlen(pos2);
+ } else {
+ /* something wrong */
+ return ERR_UNKNOWN;
+ }
+
+ for (len=0;len<sms->Number;len++) {
+ EncodeUnicode(sms->SMS[len].Number, pos1, phlen);
+ }
+
+#ifdef DEBUG
+ if (sms->Number != 0) {
+ 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",
+ sms->Number,
+ Buffer,
+ DecodeUnicodeString(sms->SMS[0].Text),
+ sms->SMS[0].Coding,
+ sms->SMS[0].Length,
+ sms->SMS[0].UDH.Type,
+ sms->SMS[0].UDH.Length);
+ } else dbgprintf("error\n");
+#endif
+
+ return ERR_NONE;
+}
+
+/* After sending SMS is moved to Sent Items or Error Items. */
+static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
+{
+ FILE *oFile,*iFile;
+ int ilen = 0, olen = 0;
+ char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400];
+ char *sourcepath, *destpath;
+
+ sourcepath = Config->outboxpath;
+ if (sent) {
+ destpath = Config->sentsmspath;
+ } else {
+ destpath = Config->errorsmspath;
+ }
+
+ strcpy(ifilename, sourcepath);
+ strcat(ifilename, ID);
+ strcpy(ofilename, destpath);
+ strcat(ofilename, ID);
+
+#ifdef WIN32
+ if (!mystrncasecmp(ifilename, ofilename, strlen(ofilename))) {
+#else
+ if (strcmp(ifilename, ofilename) != 0) {
+#endif
+ iFile = fopen(ifilename, "r");
+ ilen = fread(Buffer, 1, sizeof(Buffer), iFile);
+ fclose(iFile);
+ oFile = fopen(ofilename, "w");
+ olen = fwrite(Buffer, 1, ilen, oFile);
+ fclose(oFile);
+ }
+ if (ilen == olen) {
+ if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) {
+ WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
+ return ERR_UNKNOWN;
+ }
+ return ERR_NONE;
+ } else {
+ WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename);
+ if (alwaysDelete) {
+ if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0))
+ WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
+ }
+ return ERR_UNKNOWN;
+ }
+}
+
+static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+{
+ if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+
+ return ERR_NONE;
+}
+
+GSM_SMSDService SMSDFiles = {
+ NONEFUNCTION, /* Init */
+ SMSDFiles_SaveInboxSMS,
+ SMSDFiles_FindOutboxSMS,
+ SMSDFiles_MoveSMS,
+ NOTSUPPORTED, /* CreateOutboxSMS */
+ SMSDFiles_AddSentSMSInfo
+};
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/smsd/s_files.h b/gammu/emb/gammu/smsd/s_files.h
new file mode 100644
index 0000000..5cfa05f
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/s_files.h
@@ -0,0 +1,7 @@
+/* (c) 2002-2003 by Joergen Thomsen */
+
+extern GSM_SMSDService SMSDFiles;
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/smsd/s_mysql.c b/gammu/emb/gammu/smsd/s_mysql.c
new file mode 100644
index 0000000..dacc256
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/s_mysql.c
@@ -0,0 +1,414 @@
+/* (c) 2004 by Marcin Wiacek */
+
+#include "../../cfg/config.h"
+
+#ifdef HAVE_MYSQL_MYSQL_H
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <time.h>
+#ifdef WIN32
+# include <windows.h>
+# pragma comment(lib, "libmysql.lib")
+#endif
+
+#include "../../common/misc/coding/coding.h"
+#include "../../common/service/backup/gsmback.h"
+#include "smsdcore.h"
+
+/* Connects to database */
+static GSM_Error SMSDMySQL_Init(GSM_SMSDConfig *Config)
+{
+ 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;
+ }
+ return ERR_NONE;
+}
+
+/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
+static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
+{
+ unsigned char buffer[10000],buffer2[200],buffer3[2];
+ int i,j,z;
+
+ 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);
+ continue;
+ }
+ if (sms.SMS[i].PDU != SMS_Deliver) continue;
+ 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','",
+ 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);
+ 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),"','%s','",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),"','%s'",DecodeUnicodeString(sms.SMS[i].SMSC.Number));
+ if (sms.SMS[i].UDH.Type == UDH_NoUDH) {
+ sprintf(buffer+strlen(buffer),",''");
+ } else {
+ sprintf(buffer+strlen(buffer),",'");
+ 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);
+ 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),"')");
+ 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;
+ }
+ }
+
+ return ERR_NONE;
+}
+
+/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
+ * There is also set ID for SMS
+ */
+static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
+{
+ unsigned char buf[400];
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+ int i;
+
+ sprintf(buf, "SELECT ID,DateTime FROM `Outbox` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Row = mysql_fetch_row(Res))) {
+ mysql_free_result(Res);
+ return ERR_EMPTY;
+ }
+ sprintf(ID,"%s",Row[0]);
+ sprintf(Config->DT,"%s",Row[1]);
+ sms->Number = 0;
+ for (i=1;i<10;i++) {
+ GSM_SetDefaultSMSData(&sms->SMS[sms->Number]);
+ if (i==1) {
+ sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,MultiPart 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);
+ }
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Row = mysql_fetch_row(Res))) {
+ mysql_free_result(Res);
+ return ERR_NONE;
+ }
+
+ 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 (strlen(Row[0])==0) {
+ EncodeUnicode(sms->SMS[sms->Number].Text,Row[6],strlen(Row[6]));
+ } else {
+ switch (sms->SMS[sms->Number].Coding) {
+ case SMS_Coding_Unicode:
+ case SMS_Coding_Default:
+ DecodeHexUnicode(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
+ break;
+ case SMS_Coding_8bit:
+ DecodeHexBin(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
+ sms->SMS[sms->Number].Length=strlen(Row[0])/2;
+ }
+ }
+ EncodeUnicode(sms->SMS[sms->Number].Number,Row[1],strlen(Row[1]));
+ sms->SMS[sms->Number].UDH.Type = UDH_NoUDH;
+ if (strlen(Row[3])!=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]));
+ }
+ EncodeUnicode(sms->SMS[sms->Number].SMSC.Number,Row[4],strlen(Row[4]));
+ sms->SMS[sms->Number].Class = atoi(Row[5]);
+ sms->SMS[sms->Number].PDU = SMS_Submit;
+ sms->SMS[sms->Number].SMSC.Location = 0;
+ sms->Number++;
+ if (i == 1 && !strcmp(Row[8],"false")) break;
+ }
+ return ERR_NONE;
+}
+
+/* After sending SMS is moved to Sent Items or Error Items. */
+static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
+{
+ 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);
+ }
+
+ 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);
+ 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_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));
+ return ERR_UNKNOWN;
+ }
+ return ERR_NONE;
+}
+
+/* Adds SMS to Outbox */
+static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config)
+{
+ unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
+ int i,j,z;
+ GSM_DateTime time;
+
+ for (i=0;i<sms->Number;i++) {
+ buffer[0]=0;
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox` (`MultiPart`,`DateTime");
+ } else {
+ sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox_MultiPart` (`SequencePosition");
+ }
+ sprintf(buffer+strlen(buffer),"`,`Text`,`DestinationNumber`,`Coding`,`SMSCNumber`,`UDH`, \
+ `Class`,`TextDecoded`,`ID`) VALUES ('");
+ if (i==0) {
+ if (sms->Number == 1) {
+ sprintf(buffer+strlen(buffer),"false");
+ } else {
+ sprintf(buffer+strlen(buffer),"true");
+ }
+ sprintf(buffer+strlen(buffer),"',NOW()");
+ } else {
+ sprintf(buffer+strlen(buffer),"%i'",i+1);
+ }
+ sprintf(buffer+strlen(buffer),",'");
+
+ 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),"','%s','",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),"','%s'",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
+ if (sms->SMS[i].UDH.Type == UDH_NoUDH) {
+ sprintf(buffer+strlen(buffer),",''");
+ } else {
+ sprintf(buffer+strlen(buffer),",'");
+ 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);
+ 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),"','");
+ if (i==0) {
+ 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);
+ 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));
+ return ERR_UNKNOWN;
+ }
+ break;
+ }
+ } else {
+ strcpy(buffer4,buffer);
+ sprintf(buffer4+strlen(buffer4),"%i')",
+ time.Hour*1000000+
+ time.Minute*10000+
+ time.Second*100+time.Day);
+ 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));
+ return ERR_UNKNOWN;
+ }
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+{
+ unsigned char buffer[10000];
+
+ if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+
+ 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);
+ 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;
+ }
+ return ERR_NONE;
+}
+
+GSM_SMSDService SMSDMySQL = {
+ SMSDMySQL_Init,
+ SMSDMySQL_SaveInboxSMS,
+ SMSDMySQL_FindOutboxSMS,
+ SMSDMySQL_MoveSMS,
+ SMSDMySQL_CreateOutboxSMS,
+ SMSDMySQL_AddSentSMSInfo
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/smsd/s_mysql.h b/gammu/emb/gammu/smsd/s_mysql.h
new file mode 100644
index 0000000..e0928ea
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/s_mysql.h
@@ -0,0 +1,11 @@
+/* (c) 2004 by Marcin Wiacek */
+
+#ifdef HAVE_MYSQL_MYSQL_H
+
+extern GSM_SMSDService SMSDMySQL;
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/smsd/smsdcore.c b/gammu/emb/gammu/smsd/smsdcore.c
new file mode 100644
index 0000000..fbc55d3
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/smsdcore.c
@@ -0,0 +1,507 @@
+/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+
+#include <string.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <time.h>
+
+#include "../../common/misc/coding/coding.h"
+#include "../gammu.h"
+#include "smsdcore.h"
+#include "s_files.h"
+#ifdef HAVE_MYSQL_MYSQL_H
+# include "s_mysql.h"
+#endif
+
+FILE *smsd_log_file = NULL;
+static GSM_Error SendingSMSStatus;
+static void SMSSendingSMSStatus (char *Device, int status, int mr)
+{
+ dbgprintf("Incoming SMS device: \"%s\" status=%d, reference=%d\n",Device, status, mr);
+ if (status==0) {
+ SendingSMSStatus = ERR_NONE;
+ } else {
+ SendingSMSStatus = ERR_UNKNOWN;
+ }
+}
+
+void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc)
+{
+ int ret = ERR_NONE;
+
+ if (s.opened) {
+ WriteSMSDLog("Terminating communication");
+ ret=GSM_TerminateConnection(&s);
+ if (ret!=ERR_NONE) {
+ printf("%s\n",print_error(error,s.di.df,s.msg));
+ if (s.opened) GSM_TerminateConnection(&s);
+ }
+ }
+ if (error != 0) {
+ WriteSMSDLog(msg, error, print_error(error,s.di.df,s.msg));
+ fprintf(stderr, msg, error, print_error(error,s.di.df,s.msg));
+ fprintf(stderr, "\n");
+ }
+ if (exitprogram) {
+ if (smsd_log_file!=NULL) fclose(smsd_log_file);
+ exit(rc);
+ }
+}
+
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
+void WriteSMSDLog(char *format, ...)
+{
+ GSM_DateTime date_time;
+ char Buffer[2000];
+ va_list argp;
+ int result;
+
+ if (smsd_log_file != NULL) {
+ va_start(argp, format);
+ result = vsprintf(Buffer,GetMsg(s.msg,format),argp);
+ va_end(argp);
+
+ GSM_GetCurrentDateTime(&date_time);
+
+ fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n",
+ DayOfWeek(date_time.Year, date_time.Month, date_time.Day),
+ date_time.Year, date_time.Month, date_time.Day,
+ date_time.Hour, date_time.Minute, date_time.Second,Buffer);
+ fflush(smsd_log_file);
+ }
+}
+
+void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
+{
+ INI_Section *smsdcfgfile = NULL;
+ GSM_Config smsdcfg;
+ unsigned char *str;
+ static unsigned char emptyPath[1] = "\0";
+
+ smsdcfgfile=INI_ReadFile(filename, false);
+ if (smsdcfgfile==NULL) {
+ fprintf(stderr,"Can't find file \"%s\"\n",filename);
+ exit(-1);
+ }
+
+ Config->logfilename=INI_GetValue(smsdcfgfile, "smsd", "logfile", false);
+ if (Config->logfilename != NULL) {
+ smsd_log_file=fopen(Config->logfilename,"ab");
+ if (smsd_log_file == NULL) {
+ fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename);
+ exit(-1);
+ }
+ fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename);
+ }
+ if (log) WriteSMSDLog("Start GAMMU smsd");
+
+ /* Include Numbers used, because we don't want create new variable */
+ Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false);
+ if (Config->IncludeNumbers) {
+ GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0);
+ memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config));
+ }
+
+ Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false);
+ if (Config->PINCode == NULL) {
+ if (log) WriteSMSDLog("No PIN code in %s file",filename);
+ fprintf(stderr,"No PIN code in %s file\n",filename);
+ exit(-1);
+ }
+ if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode);
+
+ 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);
+ if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1;
+ str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false);
+ if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10;
+ str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false);
+ 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);
+
+ Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false);
+ if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) {
+ Config->deliveryreport = "no";
+ }
+ if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport);
+
+ Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
+ if (Config->inboxpath == NULL) Config->inboxpath = 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->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
+ if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
+
+ 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->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);
+
+ Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false);
+ Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false);
+ if (Config->IncludeNumbers != NULL) {
+ if (log) WriteSMSDLog("Include numbers available");
+ }
+ if (Config->ExcludeNumbers != NULL) {
+ if (Config->IncludeNumbers == NULL) {
+ if (log) WriteSMSDLog("Exclude numbers available");
+ } else {
+ if (log) WriteSMSDLog("Exclude numbers available, but IGNORED");
+ }
+ }
+
+ Config->retries = 0;
+ Config->prevSMSID[0] = 0;
+}
+
+bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
+{
+ GSM_SecurityCode SecurityCode;
+ GSM_Error error;
+
+ /* Need PIN ? */
+ error=Phone->GetSecurityStatus(&s,&SecurityCode.Type);
+ /* Unknown error */
+ if (error != ERR_NOTSUPPORTED && error != ERR_NONE) {
+ WriteSMSDLog("Error getting security status (%i)", error);
+ return false;
+ }
+ /* No supported - do not check more */
+ if (error == ERR_NOTSUPPORTED) return true;
+ /* If PIN, try to enter */
+ switch (SecurityCode.Type) {
+ case SEC_Pin:
+ WriteSMSDLog("Trying to enter PIN");
+ strcpy(SecurityCode.Code,Config->PINCode);
+ error=Phone->EnterSecurityCode(&s,SecurityCode);
+ if (error == ERR_SECURITYERROR) {
+ GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1);
+ }
+ if (error != ERR_NONE) {
+ WriteSMSDLog("Error entering PIN (%i)", error);
+ return false;
+ }
+ break;
+ case SEC_SecurityCode:
+ case SEC_Pin2:
+ case SEC_Puk:
+ case SEC_Puk2:
+ GSM_Terminate_SMSD("ERROR: phone requires not supported code type", 0, true, -1);
+ case SEC_None:
+ break;
+ }
+ return true;
+}
+
+bool SMSD_ReadDeleteSMS(GSM_SMSDConfig *Config, GSM_SMSDService *Service)
+{
+ bool start,process;
+ GSM_MultiSMSMessage sms;
+ unsigned char buffer[100];
+ GSM_Error error=ERR_NONE;
+ INI_Entry *e;
+ int i;
+
+ start=true;
+ while (error == ERR_NONE && !gshutdown) {
+ sms.SMS[0].Folder=0x00;
+ error=Phone->GetNextSMS(&s, &sms, start);
+ switch (error) {
+ case ERR_EMPTY:
+ break;
+ case ERR_NONE:
+ /* Not Inbox SMS - exit */
+ if (!sms.SMS[0].InboxFolder) break;
+ process=true;
+ DecodeUnicode(sms.SMS[0].Number,buffer);
+ if (Config->IncludeNumbers != NULL) {
+ e=Config->IncludeNumbers;
+ process=false;
+ while (1) {
+ if (e == NULL) break;
+ if (strcmp(buffer,e->EntryValue)==0) {
+ process=true;
+ break;
+ }
+ e = e->Prev;
+ }
+ } else if (Config->ExcludeNumbers != NULL) {
+ e=Config->ExcludeNumbers;
+ process=true;
+ while (1) {
+ if (e == NULL) break;
+ if (strcmp(buffer,e->EntryValue)==0) {
+ process=false;
+ break;
+ }
+ e = e->Prev;
+ }
+ }
+ if (process) {
+ Service->SaveInboxSMS(sms, Config);
+ } else {
+ WriteSMSDLog("Excluded %s", buffer);
+ }
+ break;
+ default:
+ WriteSMSDLog("Error getting SMS (%i)", error);
+ return false;
+ }
+ if (error == ERR_NONE && sms.SMS[0].InboxFolder) {
+ for (i=0;i<sms.Number;i++) {
+ sms.SMS[i].Folder=0;
+ error=Phone->DeleteSMS(&s,&sms.SMS[i]);
+ switch (error) {
+ case ERR_NONE:
+ case ERR_EMPTY:
+ break;
+ default:
+ WriteSMSDLog("Error deleting SMS (%i)", error);
+ return false;
+ }
+ }
+ }
+ start=false;
+ }
+ return true;
+}
+
+bool SMSD_CheckSMSStatus(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
+{
+ GSM_SMSMemoryStatus SMSStatus;
+ GSM_Error error;
+
+ /* Do we have any SMS in phone ? */
+ error=Phone->GetSMSStatus(&s,&SMSStatus);
+ if (error != ERR_NONE) {
+ WriteSMSDLog("Error getting SMS status (%i)", error);
+ return false;
+ }
+ /* Yes. We have SMS in phone */
+ if (SMSStatus.SIMUsed+SMSStatus.PhoneUsed != 0) {
+ return SMSD_ReadDeleteSMS(Config,Service);
+ }
+ return true;
+}
+
+bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
+{
+ GSM_MultiSMSMessage sms;
+ GSM_DateTime Date;
+ GSM_Error error;
+ unsigned int i, j, z;
+
+ error = Service->FindOutboxSMS(&sms, Config, Config->SMSID);
+
+ if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) {
+ /* No outbox sms - wait few seconds and escape */
+ for (j=0;j<Config->commtimeout && !gshutdown;j++) {
+ GSM_GetCurrentDateTime (&Date);
+ i=Date.Second;
+ while (i==Date.Second && !gshutdown) {
+ my_sleep(10);
+ GSM_GetCurrentDateTime(&Date);
+ }
+ }
+ return true;
+ }
+ if (error != ERR_NONE) {
+ /* Unknown error - escape */
+ WriteSMSDLog("Error in outbox on %s", Config->SMSID);
+ for (i=0;i<sms.Number;i++) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ }
+ Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
+ return false;
+ }
+ if (!gshutdown) {
+ if (strcmp(Config->prevSMSID, Config->SMSID) == 0) {
+ Config->retries++;
+ if (Config->retries > MAX_RETRIES) {
+ Config->retries = 0;
+ strcpy(Config->prevSMSID, "");
+ WriteSMSDLog("Moved to errorbox: %s", Config->SMSID);
+ for (i=0;i<sms.Number;i++) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ }
+ Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
+ return false;
+ }
+ } else {
+ Config->retries = 0;
+ strcpy(Config->prevSMSID, Config->SMSID);
+ }
+ for (i=0;i<sms.Number;i++) {
+ if (strcmp(Config->deliveryreport, "no") != 0) sms.SMS[i].PDU = SMS_Status_Report;
+ error=Phone->SendSMS(&s, &sms.SMS[i]);
+ if (error!=ERR_NONE) {
+ WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg));
+ return false;
+ }
+ j=0;
+ SendingSMSStatus = ERR_TIMEOUT;
+ while (!gshutdown) {
+ GSM_GetCurrentDateTime (&Date);
+ z=Date.Second;
+ while (z==Date.Second) {
+ my_sleep(10);
+ GSM_GetCurrentDateTime(&Date);
+ GSM_ReadDevice(&s,true);
+ if (SendingSMSStatus != ERR_TIMEOUT) break;
+ }
+ if (SendingSMSStatus != ERR_TIMEOUT) break;
+ j++;
+ if (j>Config->sendtimeout) break;
+ }
+ if (SendingSMSStatus != ERR_NONE) {
+ WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg));
+ return false;
+ }
+ error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, true);
+ if (error!=ERR_NONE) {
+ return false;
+ }
+ }
+ while ((int)i<sms.Number-1) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ i++;
+ }
+ strcpy(Config->prevSMSID, "");
+ if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) {
+ Service->MoveSMS(&sms,Config, Config->SMSID, true, false);
+ }
+ }
+ return true;
+}
+
+void SMSDaemon(int argc, char *argv[])
+{
+ int errors = 255, initerrors=0;
+ GSM_SMSDService *Service;
+ GSM_Error error;
+ time_t time1;
+ GSM_SMSDConfig Config;
+
+ if (!strcmp(argv[2],"FILES")) {
+ Service = &SMSDFiles;
+#ifdef HAVE_MYSQL_MYSQL_H
+ } else if (!strcmp(argv[2],"MYSQL")) {
+ Service = &SMSDMySQL;
+#endif
+ } else {
+ fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]);
+ exit(-1);
+ }
+
+ SMSD_ReadConfig(argv[3], &Config, true);
+
+ error = Service->Init(&Config);
+ if (error!=ERR_NONE) {
+ GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
+ }
+
+ signal(SIGINT, interrupt);
+ signal(SIGTERM, interrupt);
+ fprintf(stderr,"Press Ctrl+C to stop the program ...\n");
+
+ time1 = time(NULL);
+ SendingSMSStatus = ERR_UNKNOWN;
+
+ while (!gshutdown) {
+ /* There were errors in communication - try to recover */
+ if (errors > 2) {
+ if (errors != 255) {
+ WriteSMSDLog("Terminating communication (%i,%i)", error, errors);
+ error=GSM_TerminateConnection(&s);
+ }
+ if (initerrors++ > 3) my_sleep(30000);
+ WriteSMSDLog("Starting communication");
+ error=GSM_InitConnection(&s,2);
+ switch (error) {
+ case ERR_NONE:
+ s.User.SendSMSStatus = SMSSendingSMSStatus;
+ Phone = s.Phone.Functions;
+ errors = 0;
+ /* Marcin Wiacek: FIXME. To check */
+// di = s.di;
+ break;
+ case ERR_DEVICEOPENERROR:
+ GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1);
+ default:
+ WriteSMSDLog("Error at init connection (%i)", error);
+ errors = 250;
+ }
+ continue;
+ }
+ if ((difftime(time(NULL), time1) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
+ time1 = time(NULL);
+
+ if (!SMSD_CheckSecurity(&Config)) {
+ errors++;
+ initerrors++;
+ continue;
+ } else errors=0;
+
+ initerrors = 0;
+
+ if (!SMSD_CheckSMSStatus(&Config,Service)) {
+ errors++;
+ continue;
+ } else errors=0;
+ }
+ if (!SMSD_SendSMS(&Config,Service)) continue;
+ }
+ GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0);
+}
+
+GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms)
+{
+ GSM_SMSDService *Service;
+ GSM_SMSDConfig Config;
+
+ if (!strcmp(service,"FILES")) {
+ Service = &SMSDFiles;
+#ifdef HAVE_MYSQL_MYSQL_H
+ } else if (!strcmp(service,"MYSQL")) {
+ Service = &SMSDMySQL;
+#endif
+ } else {
+ fprintf(stderr,"Unknown service type (\"%s\")\n",service);
+ exit(-1);
+ }
+
+ SMSD_ReadConfig(filename, &Config, false);
+
+ error = Service->Init(&Config);
+ if (error!=ERR_NONE) return ERR_UNKNOWN;
+
+ return Service->CreateOutboxSMS(sms,&Config);
+}
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/smsd/smsdcore.h b/gammu/emb/gammu/smsd/smsdcore.h
new file mode 100644
index 0000000..23e402e
--- a/dev/null
+++ b/gammu/emb/gammu/smsd/smsdcore.h
@@ -0,0 +1,61 @@
+/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+
+#include "../../cfg/config.h"
+#undef HAVE_MYSQL_MYSQL_H
+#ifdef HAVE_MYSQL_MYSQL_H
+#ifdef WIN32
+# include <mysql.h>
+# include <mysqld_error.h>
+#else
+# include <mysql/mysql.h>
+# include <mysql/mysqld_error.h>
+#endif
+#endif
+
+#include "../../common/service/sms/gsmsms.h"
+#include "../../common/service/sms/gsmmulti.h"
+
+#define MAX_RETRIES 1
+
+void SMSDaemon (int argc, char *argv[]);
+GSM_Error SMSDaemonSendSMS (char *service, char *filename, GSM_MultiSMSMessage *sms);
+
+typedef struct {
+ /* general options */
+ INI_Entry *IncludeNumbers, *ExcludeNumbers;
+ unsigned int commtimeout, sendtimeout, receivefrequency;
+ unsigned char *deliveryreport, *logfilename, *PINCode;
+
+ /* options for FILES */
+ unsigned char *inboxpath, *outboxpath, *sentsmspath;
+ unsigned char *errorsmspath, *inboxformat, *transmitformat;
+
+ /* options for MYSQL */
+ unsigned char *database, *user, *password;
+ unsigned char *PC;
+
+ /* private variables required for work */
+ unsigned int retries;
+ unsigned char SMSID[200], prevSMSID[200];
+#ifdef HAVE_MYSQL_MYSQL_H
+ MYSQL DB; char DT[20];
+#endif
+} GSM_SMSDConfig;
+
+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_SMSDService;
+
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
+void WriteSMSDLog(char *format, ...);
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/sniff.c b/gammu/emb/gammu/sniff.c
new file mode 100644
index 0000000..0e3bc69
--- a/dev/null
+++ b/gammu/emb/gammu/sniff.c
@@ -0,0 +1,405 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#include "../common/gsmstate.h"
+
+#ifdef DEBUG
+
+#include <string.h>
+#include <stdio.h>
+
+#include "../common/protocol/nokia/mbus2.h"
+#include "../common/protocol/nokia/phonet.h"
+#include "../common/phone/nokia/nfunc.h"
+#include "../common/misc/misc.h"
+#include "../common/gsmcomon.h"
+#include "../common/service/gsmcal.h"
+#include "gammu.h"
+
+static GSM_Protocol_MBUS2Data MBUS2Data;
+static GSM_Protocol_PHONETData PHONETData;
+
+#define MBUS2_DEVICE_PC1 0x1D
+
+static void DecodeInputMBUS2(unsigned char rx_byte)
+{
+ GSM_Protocol_MBUS2Data *d = &MBUS2Data;
+
+ d->Msg.CheckSum[0] = d->Msg.CheckSum[1];
+ d->Msg.CheckSum[1] ^= rx_byte;
+
+ if (d->MsgRXState == RX_GetMessage) {
+ d->Msg.Buffer[d->Msg.Count] = rx_byte;
+ d->Msg.Count++;
+
+ if (d->Msg.Count != d->Msg.Length+2) return;
+
+ if (d->Msg.CheckSum[0] != rx_byte) {
+ printf("[ERROR: checksum]\n");
+ printf(" 0x%02x / 0x%04x", d->Msg.Type, d->Msg.Length);
+ DumpMessage(stdout, DL_TEXTALL, d->Msg.Buffer, d->Msg.Length);
+ d->MsgRXState = RX_Sync;
+ return;
+ }
+
+ if (d->Msg.Destination != MBUS2_DEVICE_PHONE) {
+ printf("Received frame");
+ } else {
+ printf("Sending frame");
+ }
+ printf(" 0x%02x / 0x%04x", d->Msg.Type, d->Msg.Length);
+ DumpMessage(stdout, DL_TEXTALL, d->Msg.Buffer, d->Msg.Length);
+ if (d->Msg.Destination != MBUS2_DEVICE_PHONE) {
+ if (s.Phone.Functions != NULL) {
+ s.Phone.Data.RequestMsg = &d->Msg;
+ s.Phone.Functions->DispatchMessage(&s);
+ }
+ }
+ d->MsgRXState = RX_Sync;
+ return;
+ }
+ if (d->MsgRXState == RX_GetLength2) {
+ if (d->Msg.Type == MBUS2_ACK_BYTE) {
+ d->MsgRXState = RX_Sync;
+ } else {
+ d->Msg.Length = d->Msg.Length + rx_byte;
+ d->MsgRXState = RX_GetMessage;
+ }
+ return;
+ }
+ if (d->MsgRXState == RX_GetLength1) {
+ d->Msg.Length = rx_byte * 256;
+ d->MsgRXState = RX_GetLength2;
+ return;
+ }
+ if (d->MsgRXState == RX_GetType) {
+ d->Msg.Type = rx_byte;
+ d->MsgRXState = RX_GetLength1;
+ return;
+ }
+ if (d->MsgRXState == RX_GetSource) {
+ if (rx_byte != MBUS2_DEVICE_PC && rx_byte != MBUS2_DEVICE_PHONE && rx_byte != MBUS2_DEVICE_PC1) {
+ d->MsgRXState = RX_Sync;
+ printf("[ERROR: incorrect char - %02x, not %02x and %02x and %02x]\n",
+ rx_byte, MBUS2_DEVICE_PHONE, MBUS2_DEVICE_PC, MBUS2_DEVICE_PC1);
+ } else {
+ d->Msg.Source = rx_byte;
+ d->MsgRXState = RX_GetType;
+ }
+ return;
+ }
+ if (d->MsgRXState == RX_GetDestination) {
+ if (rx_byte != MBUS2_DEVICE_PC && rx_byte != MBUS2_DEVICE_PHONE && rx_byte != MBUS2_DEVICE_PC1) {
+ d->MsgRXState = RX_Sync;
+ printf("[ERROR: incorrect char - %02x, not %02x and %02x and %02x]\n",
+ rx_byte, MBUS2_DEVICE_PHONE, MBUS2_DEVICE_PC, MBUS2_DEVICE_PC1);
+ } else {
+ d->Msg.Destination = rx_byte;
+ d->MsgRXState = RX_GetSource;
+ }
+ return;
+ }
+ if (d->MsgRXState == RX_Sync) {
+ if (rx_byte == MBUS2_FRAME_ID) {
+ d->Msg.CheckSum[1] = MBUS2_FRAME_ID;
+ d->Msg.Count = 0;
+ d->MsgRXState = RX_GetDestination;
+ } else {
+ printf("[ERROR: incorrect char - %02x, not %02x]\n", rx_byte, MBUS2_FRAME_ID);
+ }
+ }
+}
+
+#define PHONETIRDA_DEVICE_PC1 0x10
+
+static void DecodeInputIRDA(unsigned char rx_byte)
+{
+ GSM_Protocol_PHONETData *d = &PHONETData;
+
+ if (d->MsgRXState == RX_GetMessage) {
+ d->Msg.Buffer[d->Msg.Count] = rx_byte;
+ d->Msg.Count++;
+
+ if (d->Msg.Count != d->Msg.Length) return;
+
+ if (d->Msg.Destination != PHONET_DEVICE_PHONE) {
+ printf("Received frame");
+ } else {
+ printf("Sending frame");
+ }
+ printf(" 0x%02x / 0x%04x", d->Msg.Type, d->Msg.Length);
+ DumpMessage(stdout, DL_TEXTALL, d->Msg.Buffer, d->Msg.Length);
+ if (d->Msg.Destination != PHONET_DEVICE_PHONE) {
+ if (s.Phone.Functions != NULL) {
+ s.Phone.Data.RequestMsg = &d->Msg;
+ s.Phone.Functions->DispatchMessage(&s);
+ }
+ }
+ d->MsgRXState = RX_Sync;
+ return;
+ }
+ if (d->MsgRXState == RX_GetLength2) {
+ d->Msg.Length = d->Msg.Length + rx_byte;
+ d->MsgRXState = RX_GetMessage;
+ return;
+ }
+ if (d->MsgRXState == RX_GetLength1) {
+ d->Msg.Length = rx_byte * 256;
+ d->MsgRXState = RX_GetLength2;
+ return;
+ }
+ if (d->MsgRXState == RX_GetType) {
+ d->Msg.Type = rx_byte;
+ d->MsgRXState = RX_GetLength1;
+ return;
+ }
+ if (d->MsgRXState == RX_GetSource) {
+ if (rx_byte != PHONET_DEVICE_PHONE && rx_byte != PHONETIRDA_DEVICE_PC1) {
+ d->MsgRXState = RX_Sync;
+ } else {
+ d->Msg.Source = rx_byte;
+ d->MsgRXState = RX_GetType;
+ }
+ return;
+ }
+ if (d->MsgRXState == RX_GetDestination) {
+ if (rx_byte != PHONETIRDA_DEVICE_PC1 && rx_byte != PHONET_DEVICE_PHONE) {
+ d->MsgRXState = RX_Sync;
+ } else {
+ d->Msg.Destination = rx_byte;
+ d->MsgRXState = RX_GetSource;
+ }
+ return;
+ }
+ if (d->MsgRXState == RX_Sync) {
+ if (rx_byte == PHONET_FRAME_ID) {
+ d->Msg.Count = 0;
+ d->MsgRXState = RX_GetDestination;
+ }
+ }
+}
+
+static char IMEI[50];
+static GSM_DateTime DateTime;
+static GSM_Alarm Alarm;
+static GSM_MemoryEntry Memory;
+static GSM_MemoryStatus MemoryStatus;
+static GSM_SMSC SMSC;
+static GSM_MultiSMSMessage GetSMSMessage;
+static GSM_SMSMessage SaveSMSMessage;
+static GSM_SMSMemoryStatus SMSStatus;
+static GSM_SMSFolders SMSFolders;
+static GSM_SignalQuality SignalQuality;
+static GSM_BatteryCharge BatteryCharge;
+static GSM_NetworkInfo NetworkInfo;
+static GSM_Ringtone Ringtone;
+static GSM_CalendarEntry Calendar;
+static char SecurityCode;
+static GSM_WAPBookmark WAPBookmark;
+static GSM_Bitmap Bitmap;
+static char PhoneString[500];
+
+static char Model[50];
+static char Version[50];
+static double VersionNum;
+
+static void prepareStateMachine()
+{
+ GSM_Phone_Data *Phone = &s.Phone.Data;
+
+ strcpy(Phone->IMEI, IMEI);
+ strcpy(Phone->Model, Model);
+ strcpy(Phone->Version, Version);
+ Phone->DateTime = &DateTime;
+ Phone->Alarm = &Alarm;
+ Phone->Memory = &Memory;
+ Phone->Memory->MemoryType = MEM7110_CG;
+ Phone->MemoryStatus = &MemoryStatus;
+ Phone->SMSC = &SMSC;
+ Phone->GetSMSMessage = &GetSMSMessage;
+ Phone->SaveSMSMessage = &SaveSMSMessage;
+ Phone->SMSStatus = &SMSStatus;
+ Phone->SMSFolders = &SMSFolders;
+ Phone->SignalQuality = &SignalQuality;
+ Phone->BatteryCharge = &BatteryCharge;
+ Phone->NetworkInfo = &NetworkInfo;
+ Phone->Ringtone = &Ringtone;
+ Phone->Ringtone->Format = RING_NOKIABINARY;
+ Phone->Cal = &Calendar;
+ Phone->SecurityCode = &SecurityCode;
+ Phone->WAPBookmark = &WAPBookmark;
+ Phone->Bitmap = &Bitmap;
+ Phone->PhoneString = PhoneString;
+ Phone->StartPhoneString = 0;
+
+ Phone->EnableIncomingSMS = false;
+ Phone->EnableIncomingCB = false;
+ Model[0] = 0;
+ Phone->VerNum = VersionNum;
+ Version[0] = 0;
+ VersionNum = 0;
+
+ s.Phone.Functions = NULL;
+ s.User.UserReplyFunctions = NULL;
+ Phone->RequestID = ID_EachFrame;
+}
+
+void decodesniff(int argc, char *argv[])
+{
+ GSM_ConnectionType Protocol = GCT_MBUS2;
+ unsigned char Buffer[50000];
+ unsigned char Buffer2[50000];
+ FILE *file;
+ int len, len2, pos, state, i;
+ unsigned char mybyte1 = 0,mybyte2;
+
+ if (!strcmp(argv[2],"MBUS2")) {
+ Protocol = GCT_MBUS2;
+ } else if (!strcmp(argv[2],"IRDA")) {
+ Protocol = GCT_IRDAPHONET;
+ } else {
+ printf("What protocol (\"%s\") ?\n",argv[2]);
+ exit(-1);
+ }
+ file = fopen(argv[3], "rb");
+ if (!file) {
+ printf("Can not open file \"%s\"\n",argv[3]);
+ exit(-1);
+ }
+ prepareStateMachine();
+ if (argc > 4) {
+ strcpy(s.CurrentConfig->Model,argv[4]);
+ error=GSM_RegisterAllPhoneModules(&s);
+ if (error!=ERR_NONE) Print_Error(error);
+ }
+ /* Irda uses simple "raw" format */
+ if (Protocol == GCT_IRDAPHONET) {
+ PHONETData.MsgRXState=RX_Sync;
+ len2=30000;
+ while (len2==30000) {
+ len2=fread(Buffer, 1, 30000, file);
+ for (i=0;i<len2;i++) {
+ DecodeInputIRDA(Buffer[i]);
+ }
+ }
+ }
+ /* MBUS2 uses PortMon format */
+ if (Protocol == GCT_MBUS2) {
+ MBUS2Data.MsgRXState=RX_Sync;
+ len2=30000;
+ state=0;
+ while (len2==30000) {
+ len2=fread(Buffer, 1, 30000, file);
+ pos=0;
+ len=0;
+ while (pos!=len2) {
+ switch (state) {
+ case 0:
+ if (Buffer[pos]==' ') state = 1;
+ break;
+ case 1:
+ state = 2;
+ if (Buffer[pos]=='0') state = 0;
+ break;
+ case 2:
+ if (Buffer[pos]>='0' && Buffer[pos]<='9') {
+ state = 2;
+ } else {
+ if (Buffer[pos]==':') state = 3;
+ }
+ break;
+ case 3:
+ if (Buffer[pos]==' ') state = 4;
+ break;
+ case 4:
+ if (Buffer[pos]==13) {
+ state = 0;
+ break;
+ }
+ mybyte1=Buffer[pos]-'0';
+ if (Buffer[pos]>'9') mybyte1=Buffer[pos]-'A'+10;
+ state = 5;
+ break;
+ case 5:
+ mybyte2=Buffer[pos]-'0';
+ if (Buffer[pos]>'9') mybyte2=Buffer[pos]-'A'+10;
+ Buffer2[len++]=mybyte1*16+mybyte2;
+ state = 6;
+ break;
+ case 6:
+ state = 4;
+ if (Buffer[pos]!=' ') state = 0;
+ break;
+ }
+ pos++;
+ }
+ for (i=0;i<len;i++) {
+ DecodeInputMBUS2(Buffer2[i]);
+ }
+ }
+ }
+ fclose(file);
+}
+
+void decodebinarydump(int argc, char *argv[])
+{
+ unsigned char Buffer[50000];
+ FILE *file;
+ int len, len2, i;
+ unsigned char type;
+ bool sent;
+ GSM_Protocol_Message msg;
+
+ prepareStateMachine();
+ if (argc > 3) {
+ strcpy(s.CurrentConfig->Model,argv[3]);
+ error=GSM_RegisterAllPhoneModules(&s);
+ if (error!=ERR_NONE) Print_Error(error);
+ }
+ file = fopen(argv[2], "rb");
+ if (!file) {
+ printf("Can not open file \"%s\"\n",argv[2]);
+ exit(-1);
+ }
+// len2=fread(Buffer, 1, 1, file);
+// len2=Buffer[0];
+// len =fread(Buffer, 1, len2, file);
+// Buffer[len2]=0;
+// dbgprintf("[Gammu - version %s]\n",Buffer);
+ len2=30000;
+ msg.Buffer = NULL;
+ while (len2==30000) {
+ len2=fread(Buffer, 1, 30000, file);
+ i=0;
+ while (i!=len2) {
+ if (Buffer[i++]==0x01) {
+ dbgprintf("Sending frame ");
+ sent = true;
+ } else {
+ dbgprintf("Receiving frame ");
+ sent = false;
+ }
+ type = Buffer[i++];
+ len = Buffer[i++] * 256;
+ len = len + Buffer[i++];
+ dbgprintf("0x%02x / 0x%04x", type, len);
+ DumpMessage(stdout, DL_TEXTALL, Buffer+i, len);
+ fflush(stdout);
+ if (s.Phone.Functions != NULL && !sent) {
+ msg.Buffer = (unsigned char *)realloc(msg.Buffer,len);
+ memcpy(msg.Buffer,Buffer+i,len);
+ msg.Type = type;
+ msg.Length = len;
+ s.Phone.Data.RequestMsg = &msg;
+ s.Phone.Functions->DispatchMessage(&s);
+ }
+ i = i + len;
+ }
+ }
+
+}
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/gammu/sniff.h b/gammu/emb/gammu/sniff.h
new file mode 100644
index 0000000..104f8f1
--- a/dev/null
+++ b/gammu/emb/gammu/sniff.h
@@ -0,0 +1,8 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+void decodesniff (int argc, char *argv[]);
+void decodebinarydump (int argc, char *argv[]);
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */