summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct3
Side-by-side diff
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct3') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3comm.h16
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.c1535
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.h78
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.c2884
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.h45
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c1724
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.h45
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c396
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.h17
9 files changed, 6740 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3comm.h b/gammu/emb/common/phone/nokia/dct3/dct3comm.h
new file mode 100644
index 0000000..0b3e42e
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/dct3comm.h
@@ -0,0 +1,16 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#ifndef phone_nokia_dct3common_h
+#define phone_nokia_dct3common_h
+
+typedef struct {
+ int Locations[4];
+ int CurrentLocation;
+ int ID;
+} DCT3_WAPSettings_Locations;
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c
new file mode 100644
index 0000000..beef33c
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c
@@ -0,0 +1,1535 @@
+/* (c) 2001-2004 by Marcin Wiacek */
+/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */
+/* resetting DCT4 phones settings (c) by Walek */
+
+#include <string.h> /* memcpy only */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "../../../gsmstate.h"
+#include "../../../misc/coding/coding.h"
+#include "../../../service/sms/gsmsms.h"
+#include "../../pfunc.h"
+#include "../nfunc.h"
+#include "dct3func.h"
+
+#ifdef GSM_ENABLE_NOKIA_DCT3
+
+GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
+{
+ GSM_Error error;
+
+ /* We have to enable WAP frames in phone */
+ error=DCT3DCT4_EnableWAPFunctions(s);
+ if (error!=ERR_NONE) return error;
+
+ return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
+}
+
+GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
+{
+ GSM_Error error;
+
+ /* We have to enable WAP frames in phone */
+ error=DCT3DCT4_EnableWAPFunctions(s);
+ if (error!=ERR_NONE) return error;
+
+ return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
+}
+
+GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[2]) {
+ case 0x46:
+ smprintf(s, "Pressing key OK\n");
+ if (Data->PressKey) return ERR_NONE;
+ break;
+ case 0x47:
+ smprintf(s, "Releasing key OK\n");
+ if (!Data->PressKey) return ERR_NONE;
+ break;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error DCT3_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
+{
+ unsigned char PressReq[] = {0x00, 0x01, 0x46, 0x00, 0x01,
+ 0x0a}; /* Key code */
+ unsigned char ReleaseReq[] = {0x00, 0x01, 0x47, 0x00, 0x01, 0x0c};
+
+ if (Press) {
+ PressReq[5] = Key;
+ s->Phone.Data.PressKey = true;
+ smprintf(s, "Pressing key\n");
+ return GSM_WaitFor (s, PressReq, 6, 0xd1, 4, ID_PressKey);
+ } else {
+ s->Phone.Data.PressKey = false;
+ smprintf(s, "Releasing key\n");
+ return GSM_WaitFor (s, ReleaseReq, 6, 0xd1, 4, ID_PressKey);
+ }
+}
+
+GSM_Error DCT3_ReplyPlayTone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Tone played\n");
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00,0x01,0x8f,
+ 0x00, /* Volume */
+ 0x00, /* HerzLo */
+ 0x00}; /* HerzHi */
+
+ if (start) {
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+ }
+
+ /* For Herz==255*255 we have silent */
+ if (Herz!=255*255) {
+ req[3]=Volume;
+ req[5]=Herz%256;
+ req[4]=Herz/256;
+ } else {
+ req[3]=0;
+ req[5]=0;
+ req[4]=0;
+ }
+
+ return GSM_WaitFor (s, req, 6, 0x40, 4, ID_PlayTone);
+}
+
+#ifdef GSM_ENABLE_CELLBROADCAST
+
+GSM_Error DCT3_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_CBMessage CB;
+ int i;
+ char Buffer[300];
+
+ smprintf(s, "CB received\n");
+ CB.Channel = msg.Buffer[7];
+ i = GSM_UnpackEightBitsToSeven(0, msg.Buffer[9], msg.Buffer[9], msg.Buffer+10, Buffer);
+ i = msg.Buffer[9] - 1;
+ while (i!=0) {
+ if (Buffer[i] == 13) i = i - 1; else break;
+ }
+ DecodeDefault(CB.Text, Buffer, i + 1, false, NULL);
+ smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text));
+ if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) {
+ s->User.IncomingCB(s->CurrentConfig->Device,CB);
+ }
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x21:
+ smprintf(s, "CB set\n");
+ return ERR_NONE;
+ case 0x22:
+ smprintf(s, "CB not set\n");
+ return ERR_UNKNOWN;
+ case 0xCA:
+ smprintf(s, "No network and no CB\n");
+ return ERR_SECURITYERROR;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+#endif
+
+GSM_Error DCT3_SetIncomingCB(GSM_StateMachine *s, bool enable)
+{
+#ifdef GSM_ENABLE_CELLBROADCAST
+ unsigned char reqOn[] = {N6110_FRAME_HEADER, 0x20, 0x01,
+ 0x01, 0x00, 0x00, 0x01, 0x01};
+ unsigned char reqOff[] = {N6110_FRAME_HEADER, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ if (s->Phone.Data.EnableIncomingCB!=enable) {
+ s->Phone.Data.EnableIncomingCB = enable;
+ if (enable) {
+ smprintf(s, "Enabling incoming CB\n");
+ return GSM_WaitFor(s, reqOn, 10, 0x02, 4, ID_SetIncomingCB);
+ } else {
+ smprintf(s, "Disabling incoming CB\n");
+ return GSM_WaitFor(s, reqOff, 10, 0x02, 4, ID_SetIncomingCB);
+ }
+ }
+ return ERR_NONE;
+#else
+ return ERR_SOURCENOTAVAILABLE;
+#endif
+}
+
+GSM_Error DCT3_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "SMSC set\n");
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
+{
+ unsigned char req[100] = {N6110_FRAME_HEADER, 0x30, 0x64};
+
+ memset(req+6,100-6,0);
+
+ /* SMSC location */
+ req[5] = smsc->Location;
+
+ /* SMSC format */
+ switch (smsc->Format) {
+ case SMS_FORMAT_Text : req[7] = 0x00; break;
+ case SMS_FORMAT_Fax : req[7] = 0x22; break;
+ case SMS_FORMAT_Pager : req[7] = 0x26; break;
+ case SMS_FORMAT_Email : req[7] = 0x32; break;
+ }
+
+ /* SMS validity */
+ req[9] = smsc->Validity.Relative;
+
+ /* Default number for SMS messages */
+ req[10] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+11, true);
+
+ /* SMSC number */
+ req[22] = GSM_PackSemiOctetNumber(smsc->Number, req+23, false);
+
+ /* SMSC name */
+ memcpy(req + 34, DecodeUnicodeString(smsc->Name),UnicodeLength(smsc->Name));
+
+ smprintf(s, "Setting SMSC\n");
+ return GSM_WaitFor (s, req, 35+UnicodeLength(smsc->Name), 0x02, 4, ID_SetSMSC);
+}
+
+GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "State of security commands set\n");
+ return ERR_NONE;
+}
+
+/* If you set make some things (for example, change Security Code from
+ * phone's menu, disable and enable phone), it won't answer for 0x40 frames
+ * and you won't be able to play tones, get netmonitor, etc.
+ * This function do thing called "Enabling extended security commands"
+ * and it enables 0x40 frame functions.
+ * This frame can also some other things - see below
+ */
+GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status)
+{
+ unsigned char req[] = {0x00, 0x01, 0x64,
+ 0x01}; /* 0x00/0x01 - off/on,
+ * 0x03/0x04 - soft/hard reset,
+ * 0x06 - CONTACT SERVICE
+ */
+
+ /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */
+ /* When use 0x03 and had during session changed time & date
+ * some phones (like 6150 or 6210) can ask for time & date after reset
+ * or disable clock on the screen
+ */
+ if (status!=0x06) req[3] = status;
+ smprintf(s, "Setting state of security commands\n");
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_EnableSecurity);
+}
+
+GSM_Error DCT3_ReplyGetIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ memcpy(s->Phone.Data.IMEI,msg.Buffer + 4, 16);
+ smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_GetIMEI (GSM_StateMachine *s)
+{
+ unsigned char req[] = {0x00, 0x01, 0x66, 0x00};
+ GSM_Error error;
+
+ if (strlen(s->Phone.Data.IMEI)!=0) return ERR_NONE;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+
+ smprintf(s, "Getting IMEI\n");
+ return GSM_WaitFor (s, req, 4, 0x40, 2, ID_GetIMEI);
+}
+
+GSM_Error DCT3_ReplySIMLogin(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Login for SIM card\n");
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_ReplySIMLogout(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Logout for SIM card\n");
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Date & time received\n");
+ if (msg.Buffer[4]==0x01) {
+ NOKIA_DecodeDateTime(s, msg.Buffer+8, s->Phone.Data.DateTime);
+ return ERR_NONE;
+ }
+ smprintf(s, "Not set in phone\n");
+ return ERR_EMPTY;
+}
+
+GSM_Error DCT3_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x62};
+
+ s->Phone.Data.DateTime=date_time;
+ smprintf(s, "Getting date & time\n");
+ return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetDateTime);
+}
+
+GSM_Error DCT3_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Alarm: ");
+ if (msg.Buffer[8]==0x02) {
+ smprintf(s, "set to %02i:%02i\n", msg.Buffer[9], msg.Buffer[10]);
+ Data->Alarm->Repeating = true;
+ Data->Alarm->Text[0] = 0;
+ Data->Alarm->Text[1] = 0;
+ Data->Alarm->DateTime.Hour = msg.Buffer[9];
+ Data->Alarm->DateTime.Minute = msg.Buffer[10];
+ Data->Alarm->DateTime.Second = 0;
+ return ERR_NONE;
+ }
+ smprintf(s, "not set\n");
+ return ERR_EMPTY;
+}
+
+GSM_Error DCT3_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x6d};
+
+ if (alarm->Location!=1) return ERR_NOTSUPPORTED;
+
+ s->Phone.Data.Alarm=alarm;
+ smprintf(s, "Getting alarm\n");
+ return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetAlarm);
+}
+
+GSM_Error DCT3_ReplySetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Date & time: ");
+ if (msg.Buffer[4]==0x01) {
+ smprintf(s, "set OK\n");
+ return ERR_NONE;
+ }
+ smprintf(s, "error setting\n");
+ return ERR_UNKNOWN;
+}
+
+GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x60, 0x01, 0x01, 0x07,
+ 0x00, 0x00, /* Year */
+ 0x00, /* Month */
+ 0x00, /* Day */
+ 0x00, /* Hour */
+ 0x00, /* Minute */
+ 0x00}; /* Unknown. Not seconds */
+
+ NOKIA_EncodeDateTime(s, req+7, date_time);
+ smprintf(s, "Setting date & time\n");
+ return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime);
+}
+
+GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Alarm: ");
+ if (msg.Buffer[4]==0x01) {
+ smprintf(s, "set OK\n");
+ return ERR_NONE;
+ }
+ smprintf(s, "error setting\n");
+ return ERR_UNKNOWN;
+}
+
+GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03,
+ 0x02, /* Unknown. Not for enabling/disabling */
+ 0x00, /* Hour */
+ 0x00, /* Minute */
+ 0x00}; /* Unknown. Not seconds */
+
+ if (alarm->Location != 1) return ERR_NOTSUPPORTED;
+
+ req[8] = alarm->DateTime.Hour;
+ req[9] = alarm->DateTime.Minute;
+
+ smprintf(s, "Setting alarm\n");
+ return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm);
+}
+
+GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x34:
+ smprintf(s, "SMSC received\n");
+ Data->SMSC->Format = SMS_FORMAT_Text;
+ switch (msg.Buffer[6]) {
+ case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
+ case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
+ case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager; break;
+ case 0x32: Data->SMSC->Format = SMS_FORMAT_Email; break;
+ }
+ Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
+ Data->SMSC->Validity.Relative = msg.Buffer[8];
+
+ i=33;
+ while (msg.Buffer[i]!=0) {i++;}
+ i=i-33;
+ if (i>GSM_MAX_SMSC_NAME_LENGTH) {
+ smprintf(s, "Too long name\n");
+ return ERR_UNKNOWNRESPONSE;
+ }
+ EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i);
+ smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
+
+ GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true);
+ smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
+
+ GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false);
+ smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
+
+ return ERR_NONE;
+ case 0x35:
+ smprintf(s, "Getting SMSC failed\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64,
+ 0x00}; /* Location */
+
+ if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
+
+ req[5]=smsc->Location;
+
+ s->Phone.Data.SMSC=smsc;
+ smprintf(s, "Getting SMSC\n");
+ return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
+}
+
+GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int count;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+#ifdef DEBUG
+ GSM_NetworkInfo NetInfo;
+ char name[100];
+
+ smprintf(s, "Network info received\n");
+ smprintf(s, " Status : ");
+ switch (msg.Buffer[8]) {
+ case 0x01: smprintf(s, "home network"); break;
+ case 0x02: smprintf(s, "roaming network"); break;
+ case 0x03: smprintf(s, "requesting network"); break;
+ case 0x04: smprintf(s, "not registered in the network"); break;
+ default : smprintf(s, "unknown");
+ }
+ smprintf(s, "\n");
+ smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
+ if (msg.Buffer[8]<0x03) {
+ sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
+ smprintf(s, "CID : %s\n", NetInfo.CID);
+
+ sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
+ smprintf(s, "LAC : %s\n", NetInfo.LAC);
+
+ smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
+ NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
+ smprintf(s, "Network name for Gammu : %s ",
+ DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
+ smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
+
+ if (msg.Length>18) {
+ if (msg.Buffer[18]==0x00) {
+ /* In 6210 name is in "normal" Unicode */
+ memcpy(name,msg.Buffer+18,msg.Buffer[17]*2);
+ name[msg.Buffer[17]*2] =0x00;
+ name[msg.Buffer[17]*2+1]=0x00;
+ smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
+ } else {
+ /* In 9210 first 0x00 is cut from Unicode string */
+ name[0] = 0;
+ memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2);
+ name[msg.Buffer[17]*2+1]=0x00;
+ name[msg.Buffer[17]*2+2]=0x00;
+ smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
+ }
+ }
+ }
+#endif
+ if (Data->RequestID==ID_GetNetworkInfo) {
+ Data->NetworkInfo->NetworkName[0] = 0x00;
+ Data->NetworkInfo->NetworkName[1] = 0x00;
+ Data->NetworkInfo->State = 0;
+ switch (msg.Buffer[8]) {
+ case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break;
+ case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork; break;
+ case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork; break;
+ case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break;
+ }
+ if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) {
+ if (msg.Buffer[18]==0x00) {
+ /* In 6210 name is in "normal" Unicode */
+ memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2);
+ Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00;
+ Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00;
+ } else {
+ /* In 9210 first 0x00 is cut from Unicode string */
+ Data->NetworkInfo->NetworkName[0] = 0;
+ memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2);
+ Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00;
+ Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00;
+ }
+ NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode);
+ sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
+ sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
+ }
+ }
+ /* 6210/6250/7110 */
+ if (Data->RequestID==ID_GetBitmap) {
+ if (msg.Buffer[4]==0x02) {
+ smprintf(s, "Operator logo available\n");
+ count = 7;
+ /* skip network info */
+ count += msg.Buffer[count];
+ count ++;
+ Data->Bitmap->BitmapWidth = msg.Buffer[count++];
+ Data->Bitmap->BitmapHeight = msg.Buffer[count++];
+ count+=4;
+ PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo,msg.Buffer+count,Data->Bitmap);
+ NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->Bitmap->NetworkCode);
+ } else {
+ Data->Bitmap->BitmapWidth = 78;
+ Data->Bitmap->BitmapHeight = 21;
+ GSM_ClearBitmap(Data->Bitmap);
+ strcpy(Data->Bitmap->NetworkCode,"000 00");
+ }
+ }
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x70};
+
+ s->Phone.Data.NetworkInfo=netinfo;
+ smprintf(s, "Getting network info\n");
+ return GSM_WaitFor (s, req, 4, 0x0a, 4, ID_GetNetworkInfo);
+}
+
+GSM_Error DCT3_ReplyDialCommand(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Answer for call commands\n");
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
+{
+ unsigned int i = 0;
+ GSM_Error error;
+ unsigned char req[100] = {0x00, 0x01, 0x7c,
+ 0x01}; /* call command */
+
+ if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+
+ for (i=0; i < strlen(number); i++) req[4+i]=number[i];
+ req[4+i+1]=0;
+
+ smprintf(s, "Making voice call\n");
+ return GSM_WaitFor (s, req, 4+strlen(number)+1, 0x40, 4, ID_DialVoice);
+}
+
+static GSM_Error DCT3_CancelAllCalls(GSM_StateMachine *s)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00, 0x01, 0x7c,
+ 0x03}; /* call command */
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+
+ smprintf(s, "Canceling calls\n");
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_CancelCall);
+}
+
+GSM_Error DCT3_CancelCall(GSM_StateMachine *s, int ID, bool all)
+{
+ if (!all) return DCT3DCT4_CancelCall(s,ID);
+ return DCT3_CancelAllCalls(s);
+}
+
+GSM_Error DCT3_AnswerAllCalls(GSM_StateMachine *s)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00, 0x01, 0x7c,
+ 0x02}; /* call command */
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+
+ smprintf(s, "Answering calls\n");
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_AnswerCall);
+}
+
+GSM_Error DCT3_Reset(GSM_StateMachine *s, bool hard)
+{
+ GSM_Error error;
+
+ if (hard) {
+ error=DCT3_EnableSecurity(s, 0x04);
+ } else {
+ error=DCT3_EnableSecurity(s, 0x03);
+ }
+ if (error == ERR_NONE) {
+ s->Phone.Data.EnableIncomingSMS = false;
+ s->Phone.Data.EnableIncomingCB = false;
+ }
+ return error;
+}
+
+GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return DCT3DCT4_ReplyGetWAPBookmark (msg,s,false);
+}
+
+GSM_Error DCT3_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
+{
+ GSM_Error error;
+ int count = 4, location;
+ unsigned char req[600] = {N6110_FRAME_HEADER, 0x09};
+
+ /* We have to enable WAP frames in phone */
+ error=DCT3DCT4_EnableWAPFunctions(s);
+ if (error!=ERR_NONE) return error;
+
+ location = bookmark->Location - 1;
+ if (bookmark->Location == 0) location = 0xffff;
+ req[count++] = (location & 0xff00) >> 8;
+ req[count++] = location & 0x00ff;
+
+ count += NOKIA_SetUnicodeString(s, req+count, bookmark->Title, false);
+ count += NOKIA_SetUnicodeString(s, req+count, bookmark->Address, false);
+
+ /* unknown */
+ req[count++] = 0x01; req[count++] = 0x80; req[count++] = 0x00;
+ req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00;
+ req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00;
+
+ smprintf(s, "Setting WAP bookmark\n");
+ error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark);
+ if (error != ERR_NONE) {
+ if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) {
+ DCT3DCT4_DisableConnectionFunctions(s);
+ }
+ return error;
+ }
+
+ return DCT3DCT4_DisableConnectionFunctions(s);
+}
+
+GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int tmp,Number;
+// int tmp2;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+#ifdef GSM_ENABLE_NOKIA6110
+ GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110;
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110;
+#endif
+
+ switch(msg.Buffer[3]) {
+ case 0x16:
+ smprintf(s, "WAP settings part 1 received OK\n");
+
+ tmp = 4;
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Title,false);
+ smprintf(s, "Title: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Title));
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].HomePage,false);
+ smprintf(s, "Homepage: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].HomePage));
+#ifdef DEBUG
+ smprintf(s, "Connection type: ");
+ switch (msg.Buffer[tmp]) {
+ case 0x00: smprintf(s, "temporary\n"); break;
+ case 0x01: smprintf(s, "continuous\n"); break;
+ default: smprintf(s, "unknown\n");
+ }
+ smprintf(s, "Connection security: ");
+ switch (msg.Buffer[tmp+13]) {
+ case 0x00: smprintf(s, "off\n"); break;
+ case 0x01: smprintf(s, "on\n"); break;
+ default: smprintf(s, "unknown\n");
+ }
+#endif
+ Data->WAPSettings->Settings[0].IsContinuous = false;
+ if (msg.Buffer[tmp] == 0x01) Data->WAPSettings->Settings[0].IsContinuous = true;
+ Data->WAPSettings->Settings[0].IsSecurity = false;
+ if (msg.Buffer[tmp+13] == 0x01) Data->WAPSettings->Settings[0].IsSecurity = true;
+
+ /* I'm not sure here. Experimental values from 6210 5.56 */
+// tmp2 = DecodeUnicodeLength(Data->WAPSettings->Settings[0].Title);
+// if (tmp2 != 0) tmp2 --;
+// tmp2 += tmp;
+ if (!(UnicodeLength(Data->WAPSettings->Settings[0].Title)) % 2) tmp++;
+ if (UnicodeLength(Data->WAPSettings->Settings[0].HomePage)!=0) tmp++;
+
+ smprintf(s, "ID for writing %i\n",msg.Buffer[tmp+5]);
+
+ smprintf(s, "Current set location in phone %i\n",msg.Buffer[tmp+6]);
+
+ smprintf(s, "1 location %i\n",msg.Buffer[tmp+8]);
+ smprintf(s, "2 location %i\n",msg.Buffer[tmp+9]);
+ smprintf(s, "3 location %i\n",msg.Buffer[tmp+10]);
+ smprintf(s, "4 location %i\n",msg.Buffer[tmp+11]);
+#ifdef GSM_ENABLE_NOKIA7110
+ if (strstr(N7110Phone.models, Data->ModelInfo->model) != NULL) {
+ Priv7110->WAPLocations.ID = msg.Buffer[tmp+5];
+ Priv7110->WAPLocations.CurrentLocation = msg.Buffer[tmp+6];
+ Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp+8];
+ Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp+9];
+ Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp+10];
+ Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp+11];
+
+// Priv7110->WAPLocations.CurrentLocation = msg.Buffer[tmp2+1];
+// Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp2+3];
+// Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp2+4];
+// Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp2+5];
+// Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp2+6];
+ }
+#endif
+#ifdef GSM_ENABLE_NOKIA6110
+ if (strstr(N6110Phone.models, Data->ModelInfo->model) != NULL) {
+ Priv6110->WAPLocations.ID = msg.Buffer[tmp+5];
+ Priv6110->WAPLocations.CurrentLocation = msg.Buffer[tmp+6];
+ Priv6110->WAPLocations.Locations[0] = msg.Buffer[tmp+8];
+ Priv6110->WAPLocations.Locations[1] = msg.Buffer[tmp+9];
+ Priv6110->WAPLocations.Locations[2] = msg.Buffer[tmp+10];
+ Priv6110->WAPLocations.Locations[3] = msg.Buffer[tmp+11];
+ }
+#endif
+ return ERR_NONE;
+ case 0x17:
+ smprintf(s, "WAP settings part 1 receiving error\n");
+ switch (msg.Buffer[4]) {
+ case 0x01:
+ smprintf(s, "Security error. Inside WAP settings menu\n");
+ return ERR_INSIDEPHONEMENU;
+ case 0x02:
+ smprintf(s, "Invalid or empty\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+ break;
+ case 0x1c:
+ smprintf(s, "WAP settings part 2 received OK\n");
+ Number = Data->WAPSettings->Number;
+ switch (msg.Buffer[5]) {
+ case 0x00:
+ Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_SMS;
+ smprintf(s, "Settings for SMS bearer:\n");
+ tmp = 6;
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false);
+ smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Server,false);
+ smprintf(s, "Server number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Server));
+ break;
+ case 0x01:
+ Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_DATA;
+ smprintf(s, "Settings for data bearer:\n");
+ Data->WAPSettings->Settings[Number].ManualLogin = false;
+ tmp = 10;
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].IPAddress,false);
+ smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].IPAddress));
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].DialUp,false);
+ smprintf(s, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].DialUp));
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].User,false);
+ smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].User));
+
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Password,false);
+ smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Password));
+#ifdef DEBUG
+ smprintf(s, "Authentication type: ");
+ switch (msg.Buffer[6]) {
+ case 0x00: smprintf(s, "normal\n"); break;
+ case 0x01: smprintf(s, "secure\n"); break;
+ default: smprintf(s, "unknown\n"); break;
+ }
+ smprintf(s, "Data call type: ");
+ switch (msg.Buffer[7]) {
+ case 0x00: smprintf(s, "analogue\n"); break;
+ case 0x01: smprintf(s, "ISDN\n"); break;
+ default: smprintf(s, "unknown\n"); break;
+ }
+ smprintf(s, "Data call speed: ");
+ switch (msg.Buffer[9]) {
+ case 0x01: smprintf(s, "9600\n"); break;
+ case 0x02: smprintf(s, "14400\n"); break;
+ default: smprintf(s, "unknown\n"); break;
+ }
+#endif
+ Data->WAPSettings->Settings[Number].IsNormalAuthentication=true;
+ if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsNormalAuthentication=false;
+ Data->WAPSettings->Settings[Number].IsISDNCall=false;
+ if (msg.Buffer[7]==0x01) Data->WAPSettings->Settings[Number].IsISDNCall=true;
+ Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_9600;
+ if (msg.Buffer[9]==0x02) Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_14400;
+ break;
+ case 0x02:
+ Data->WAPSettings->Settings[Number].Bearer=WAPSETTINGS_BEARER_USSD;
+ smprintf(s, "Settings for USSD bearer:\n");
+ tmp = 7;
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false);
+#ifdef DEBUG
+ if (msg.Buffer[6]==0x01)
+ smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
+ else
+ smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
+#endif
+ Data->WAPSettings->Settings[Number].IsIP=true;
+ if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsIP=false;
+ NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Code,false);
+ smprintf(s, "Service code: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Code));
+ }
+ Data->WAPSettings->Number++;
+ return ERR_NONE;
+ case 0x1d:
+ smprintf(s, "Incorrect WAP settings location\n");
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error DCT3_GetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
+{
+#ifdef GSM_ENABLE_NOKIA6110
+ GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110;
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110;
+#endif
+ GSM_Error error;
+ int i;
+ unsigned char req[] = {N6110_FRAME_HEADER,0x15,
+ 0x00}; /* Location */
+ unsigned char req2[] = {N6110_FRAME_HEADER,0x1b,
+ 0x00}; /* Location */
+
+ /* We have to enable WAP frames in phone */
+ error=DCT3DCT4_EnableWAPFunctions(s);
+ if (error!=ERR_NONE) return error;
+
+ s->Phone.Data.WAPSettings = settings;
+ settings->Number = 0;
+ settings->ReadOnly = false;
+
+ req[4] = settings->Location-1;
+ smprintf(s, "Getting WAP settings part 1\n");
+ error = GSM_WaitFor (s, req, 5, 0x3f, 4, ID_GetConnectSet);
+ if (error != ERR_NONE) return error;
+
+#ifdef GSM_ENABLE_NOKIA7110
+ if (strstr(N7110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
+ for (i=0;i<4;i++) {
+ req2[4] = Priv7110->WAPLocations.Locations[i];
+ smprintf(s, "Getting WAP settings part 2\n");
+ error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet);
+ if (error != ERR_NONE) return error;
+ if (Priv7110->WAPLocations.Locations[i] == Priv7110->WAPLocations.CurrentLocation) {
+ settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer;
+ }
+ }
+ }
+#endif
+#ifdef GSM_ENABLE_NOKIA6110
+ if (strstr(N6110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
+ for (i=0;i<4;i++) {
+ req2[4] = Priv6110->WAPLocations.Locations[i];
+ smprintf(s, "Getting WAP settings part 2\n");
+ error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet);
+ if (error != ERR_NONE) return error;
+ if (Priv6110->WAPLocations.Locations[i] == Priv6110->WAPLocations.CurrentLocation) {
+ settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer;
+ }
+ }
+ }
+#endif
+ if (error == ERR_NONE) {
+ for (i=1;i<3;i++) {
+ CopyUnicodeString(settings->Settings[i].Title,settings->Settings[0].Title);
+ CopyUnicodeString(settings->Settings[i].HomePage,settings->Settings[0].HomePage);
+ settings->Settings[i].IsContinuous = settings->Settings[0].IsContinuous;
+ settings->Settings[i].IsSecurity = settings->Settings[0].IsSecurity;
+
+ settings->Settings[i].IsContinuous = settings->Settings[0].IsContinuous;
+ settings->Settings[i].IsSecurity = settings->Settings[0].IsSecurity;
+ }
+ error = DCT3DCT4_GetActiveConnectSet(s);
+ }
+ if (error != ERR_NONE) return error;
+
+ settings->Proxy[0] = 0x00;
+ settings->Proxy[1] = 0x00;
+ settings->ProxyPort = 8080;
+
+ settings->Proxy2[0] = 0x00;
+ settings->Proxy2[1] = 0x00;
+ settings->Proxy2Port = 8080;
+
+ return DCT3DCT4_DisableConnectionFunctions(s);
+}
+
+GSM_Error DCT3_ReplySetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch(msg.Buffer[3]) {
+ case 0x19:
+ smprintf(s, "WAP settings part 1 set OK\n");
+ return ERR_NONE;
+ case 0x1a:
+ smprintf(s, "WAP settings part 1 setting error\n");
+ switch (msg.Buffer[4]) {
+ case 0x01:
+ smprintf(s, "Security error. Inside WAP settings menu\n");
+ return ERR_INSIDEPHONEMENU;
+ case 0x02:
+ smprintf(s, "Incorrect data\n");
+ return ERR_UNKNOWN;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+ case 0x1F:
+ smprintf(s, "WAP settings part 2 set OK\n");
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
+{
+#ifdef GSM_ENABLE_NOKIA6110
+ GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110;
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110;
+#endif
+ GSM_Error error;
+ GSM_MultiWAPSettings settings2;
+ int i,pos,phone1=-1,phone2=-1,phone3=-1;
+ int ID=0,locations[4],loc1=-1,loc2=-1,loc3=-1;
+ unsigned char req[] = {N6110_FRAME_HEADER,0x15,
+ 0x00}; /* Location */
+ unsigned char req2[] = {N6110_FRAME_HEADER,0x1b,
+ 0x00}; /* Location */
+ unsigned char SetReq[200] = {N7110_FRAME_HEADER, 0x18,
+ 0x00}; /* Location */
+ unsigned char SetReq2[200] = {N7110_FRAME_HEADER, 0x1e,
+ 0x00}; /* Location */
+
+ /* We have to enable WAP frames in phone */
+ error=DCT3DCT4_EnableWAPFunctions(s);
+ if (error!=ERR_NONE) return error;
+
+ s->Phone.Data.WAPSettings = &settings2;
+ settings2.Number = 0;
+
+ req[4] = settings->Location-1;
+ smprintf(s, "Getting WAP settings part 1\n");
+ error = GSM_WaitFor (s, req, 6, 0x3f, 4, ID_GetConnectSet);
+ if (error != ERR_NONE) return error;
+
+#ifdef GSM_ENABLE_NOKIA6110
+ if (strstr(N6110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
+ for (i=0;i<4;i++) locations[i] = Priv6110->WAPLocations.Locations[i];
+ ID = Priv6110->WAPLocations.ID;
+ }
+#endif
+#ifdef GSM_ENABLE_NOKIA7110
+ if (strstr(N7110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
+ for (i=0;i<4;i++) locations[i] = Priv7110->WAPLocations.Locations[i];
+ ID = Priv7110->WAPLocations.ID;
+ }
+#endif
+
+ /* Now we get info about supported types by phone and their locations */
+ for (i=0;i<4;i++) {
+ settings2.Number = 0;
+ settings2.Settings[0].Bearer = 0;
+ req2[4] = locations[i];
+ smprintf(s, "Getting WAP settings part 2\n");
+ error=GSM_WaitFor (s, req2, 6, 0x3f, 4, ID_GetConnectSet);
+ if (error != ERR_NONE) return error;
+ switch (settings2.Settings[0].Bearer) {
+ case WAPSETTINGS_BEARER_DATA: phone1 = locations[i]; break;
+ case WAPSETTINGS_BEARER_SMS : phone2 = locations[i]; break;
+ case WAPSETTINGS_BEARER_USSD: phone3 = locations[i]; break;
+ default : break;
+ }
+ if (error != ERR_NONE) return error;
+ }
+
+ /* We have some phone locations and some data to set. We try to
+ * find info about locations in phone used to write concrete bearers
+ */
+ for (i=0;i<settings->Number;i++) {
+ if (settings->Settings[i].Bearer == WAPSETTINGS_BEARER_DATA) {
+ if (phone1 != -1) loc1=i;
+ }
+ if (settings->Settings[i].Bearer == WAPSETTINGS_BEARER_SMS) {
+ if (phone2 != -1) loc2=i;
+ }
+ if (settings->Settings[i].Bearer == WAPSETTINGS_BEARER_USSD) {
+ if (phone3 != -1) loc3=i;
+ }
+ }
+
+ pos = 5;
+ memset(SetReq + pos, 0, 200 - pos);
+ SetReq[4] = settings->Location - 1;
+ if (loc1 != -1) {
+ /* Name */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc1].Title, false);
+ /* HomePage */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc1].HomePage, false);
+ if (settings->Settings[loc1].IsContinuous) SetReq[pos] = 0x01;
+ pos++;
+ SetReq[pos++] = ID;
+
+ SetReq[pos] = phone1; /* bearer */
+ switch (settings->ActiveBearer) {
+ case WAPSETTINGS_BEARER_DATA:
+ if (loc1 != -1) SetReq[pos] = phone1;
+ break;
+ case WAPSETTINGS_BEARER_SMS:
+ if (loc2 != -1) SetReq[pos] = phone2;
+ break;
+ case WAPSETTINGS_BEARER_USSD:
+ if (loc3 != -1) SetReq[pos] = phone3;
+ break;
+ default: break;
+ }
+ pos++;
+
+ if (settings->Settings[loc1].IsSecurity) SetReq[pos] = 0x01;
+ pos++;
+ } else if (loc2 != -1) {
+ /* Name */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc2].Title, false);
+ /* HomePage */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc2].HomePage, false);
+ if (settings->Settings[loc2].IsContinuous) SetReq[pos] = 0x01;
+ pos++;
+ SetReq[pos++] = ID;
+
+ SetReq[pos] = phone2; /* bearer */
+ switch (settings->ActiveBearer) {
+ case WAPSETTINGS_BEARER_DATA:
+ if (loc1 != -1) SetReq[pos] = phone1;
+ break;
+ case WAPSETTINGS_BEARER_SMS:
+ if (loc2 != -1) SetReq[pos] = phone2;
+ break;
+ case WAPSETTINGS_BEARER_USSD:
+ if (loc3 != -1) SetReq[pos] = phone3;
+ break;
+ default: break;
+ }
+ pos++;
+
+ if (settings->Settings[loc2].IsSecurity) SetReq[pos] = 0x01;
+ pos++;
+ } else if (loc3 != -1) {
+ /* Name */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc3].Title, false);
+ /* HomePage */
+ pos += NOKIA_SetUnicodeString(s, SetReq + pos, settings->Settings[loc3].HomePage, false);
+ if (settings->Settings[loc3].IsContinuous) SetReq[pos] = 0x01;
+ pos++;
+ SetReq[pos++] = ID;
+
+ SetReq[pos] = phone3; /* bearer */
+ switch (settings->ActiveBearer) {
+ case WAPSETTINGS_BEARER_DATA:
+ if (loc1 != -1) SetReq[pos] = phone1;
+ break;
+ case WAPSETTINGS_BEARER_SMS:
+ if (loc2 != -1) SetReq[pos] = phone2;
+ break;
+ case WAPSETTINGS_BEARER_USSD:
+ if (loc3 != -1) SetReq[pos] = phone3;
+ break;
+ default: break;
+ }
+ pos++;
+
+ if (settings->Settings[loc3].IsSecurity) SetReq[pos] = 0x01;
+ pos++;
+ } else {
+ return ERR_UNKNOWN; /* We have to have write something known */
+ }
+ memcpy(SetReq + pos, "\x01\x80\x00\x00\x00\x00\x00\x00\x00", 9);
+ pos += 9;
+
+ smprintf(s, "Writing WAP settings part 1\n");
+ error=GSM_WaitFor (s, SetReq, pos, 0x3f, 4, ID_SetConnectSet);
+ if (error != ERR_NONE) return error;
+
+ /* Data */
+ if (phone1 != -1) {
+ pos = 4;
+ memset(SetReq2 + pos, 0, 200 - pos);
+ SetReq2[pos++] = phone1;
+ SetReq2[pos++] = 0x02;
+ SetReq2[pos++] = 0x01; /* GSMdata */
+ if (loc1 != -1) {
+ if (!settings->Settings[loc1].IsNormalAuthentication) SetReq2[pos] = 0x01;
+ }
+ pos++;
+ if (loc1 != -1) {
+ if (settings->Settings[loc1].IsISDNCall) SetReq2[pos] = 0x01;
+ }
+ pos++;
+ if (loc1 != -1) {
+ switch (settings->Settings[loc1].Speed) {
+ case WAPSETTINGS_SPEED_9600 : SetReq2[pos++] = 0x01; break;
+ case WAPSETTINGS_SPEED_14400 : SetReq2[pos++] = 0x02; break;
+ default : SetReq2[pos++] = 0x02; break;
+ }
+ switch (settings->Settings[loc1].Speed) {
+ case WAPSETTINGS_SPEED_9600 : SetReq2[pos++] = 0x01; break;
+ case WAPSETTINGS_SPEED_14400 : SetReq2[pos++] = 0x02; break;
+ default : SetReq2[pos++] = 0x02; break;
+ }
+ } else pos+=2;
+ if (loc1 != -1) {
+ /* IP */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc1].IPAddress, false);
+ /* Number */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc1].DialUp, false);
+ /* Username */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc1].User, false);
+ /* Password */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc1].Password, false);
+ } else pos+=5;
+ memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
+ pos += 8;
+ smprintf(s, "Writing WAP settings part 2 (Data bearer)\n");
+ error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
+ if (error != ERR_NONE) return error;
+ }
+ /* SMS */
+ if (phone2 != -1) {
+ pos = 4;
+ memset(SetReq2 + pos, 0, 200 - pos);
+ SetReq2[pos++] = phone2;
+ SetReq2[pos++] = 0x02;
+ SetReq2[pos++] = 0x00; /* SMS */
+ if (loc2 != -1) {
+ /* Service number */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Service, false);
+ /* Server number */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Server, false);
+ } else pos += 2;
+ memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
+ pos += 8;
+ smprintf(s, "Writing WAP settings part 2 (SMS bearer)\n");
+ error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
+ if (error != ERR_NONE) return error;
+ }
+ /* USSD */
+ if (phone3 != -1) {
+ pos = 4;
+ memset(SetReq2 + pos, 0, 200 - pos);
+ SetReq2[pos++] = phone3;
+ SetReq2[pos++] = 0x02;
+ SetReq2[pos++] = 0x02; /* USSD */
+ if (loc3 != -1) {
+ if (!settings->Settings[loc3].IsIP) SetReq2[pos] = 0x01;
+ }
+ pos++;
+ if (loc3 != -1) {
+ /* Service number or IP address */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false);
+ /* Code number */
+ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false);
+ } else pos+=2;
+ memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
+ pos += 8;
+ smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n");
+ error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
+ if (error != ERR_NONE) return error;
+ }
+ error = DCT3DCT4_SetActiveConnectSet(s, settings);
+ if (error != ERR_NONE) return error;
+
+ return DCT3DCT4_DisableConnectionFunctions(s);
+}
+
+GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x02:
+ smprintf(s, "SMS sent OK\n");
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0);
+ return ERR_NONE;
+ case 0x03:
+ smprintf(s, "Error %i\n",msg.Buffer[6]);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0);
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int length;
+ GSM_Error error;
+ unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00};
+
+ error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true);
+ if (error != ERR_NONE) return error;
+
+ smprintf(s, "Sending sms\n");
+ return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02);
+}
+
+GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x00:
+ smprintf(s, "Netmonitor correctly set\n");
+ break;
+ default:
+ smprintf(s, "Menu %i\n",msg.Buffer[3]);
+ smprintf(s, "%s\n",msg.Buffer+4);
+ strcpy(s->Phone.Data.Netmonitor,msg.Buffer+4);
+ break;
+ }
+ return ERR_NONE;
+}
+
+GSM_Error DCT3_Netmonitor(GSM_StateMachine *s, int testnumber, char *value)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00, 0x01, 0x7e,
+ 0x00}; /* Test number */
+
+ value[0] = 0;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+
+ req[3] = testnumber;
+
+ smprintf(s, "Getting netmonitor test\n");
+ s->Phone.Data.Netmonitor = value;
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_Netmonitor);
+}
+
+GSM_Error DCT3_GetManufactureMonth(GSM_StateMachine *s, char *value)
+{
+ GSM_Error error;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+ return NOKIA_GetPhoneString(s,"\x00\x01\xCC\x02",4,0x40,value,ID_GetManufactureMonth,5);
+}
+
+GSM_Error DCT3_GetProductCode(GSM_StateMachine *s, char *value)
+{
+ GSM_Error error;
+
+ if (strlen(s->Phone.Data.ProductCodeCache)!=0) {
+ strcpy(value,s->Phone.Data.ProductCodeCache);
+ return ERR_NONE;
+ }
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+ return NOKIA_GetPhoneString(s,"\x00\x01\xCA\x01",4,0x40,value,ID_GetProductCode,5);
+}
+
+GSM_Error DCT3_GetOriginalIMEI(GSM_StateMachine *s, char *value)
+{
+ GSM_Error error;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+ return NOKIA_GetPhoneString(s,"\x00\x01\xCC\x01",4,0x40,value,ID_GetOriginalIMEI,5);
+}
+
+GSM_Error DCT3_GetHardware(GSM_StateMachine *s, char *value)
+{
+ GSM_Error error;
+
+ if (strlen(s->Phone.Data.HardwareCache)!=0) {
+ strcpy(value,s->Phone.Data.HardwareCache);
+ return ERR_NONE;
+ }
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+ return NOKIA_GetPhoneString(s,"\x00\x01\xC8\x05",4,0x40,value,ID_GetHardware,5);
+}
+
+GSM_Error DCT3_GetPPM(GSM_StateMachine *s, char *value)
+{
+ GSM_Error error;
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+ return NOKIA_GetPhoneString(s,"\x00\x01\xC8\x12",4,0x40,value,ID_GetPPM,5);
+}
+
+GSM_Error DCT3_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x36, 0x64};
+
+ s->Phone.Data.SMSStatus=status;
+ smprintf(s, "Getting SMS status\n");
+ return GSM_WaitFor (s, req, 5, 0x14, 2, ID_GetSMSStatus);
+
+ /* 6210 family doesn't show in frame with SMS status info
+ * about Templates. We get separately info about this SMS folder.
+ */
+}
+
+GSM_Error DCT3_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch(msg.Buffer[3]) {
+ case 0x0b:
+ smprintf(s, "SMS deleted\n");
+ return ERR_NONE;
+ case 0x0c:
+ smprintf(s, "Error deleting SMS\n");
+ switch (msg.Buffer[4]) {
+ case 0x00:
+ /* Not tested on 6210 */
+ smprintf(s, "Unknown meaning, SMS seems to be deleted\n");
+ return ERR_NONE;
+ case 0x02:
+ /* Not tested on 6210 */
+ smprintf(s, "Invalid location\n");
+ return ERR_INVALIDLOCATION;
+ case 0x06:
+ /* Not tested on 6210 */
+ smprintf(s, "Phone is OFF\n");
+ return ERR_PHONEOFF;
+ default:
+ smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error N71_92_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Network level received: %i\n",msg.Buffer[4]);
+ Data->SignalQuality->SignalStrength = -1;
+ Data->SignalQuality->SignalPercent = ((int)msg.Buffer[4]);
+ Data->SignalQuality->BitErrorRate = -1;
+ return ERR_NONE;
+}
+
+GSM_Error N71_92_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x81};
+
+ s->Phone.Data.SignalQuality = sig;
+ smprintf(s, "Getting network level\n");
+ return GSM_WaitFor (s, req, 4, 0x0a, 4, ID_GetSignalQuality);
+}
+
+GSM_Error N71_92_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Battery level received: %i\n",msg.Buffer[5]);
+ Data->BatteryCharge->BatteryPercent = ((int)msg.Buffer[5]);
+ Data->BatteryCharge->ChargeState = 0;
+ return ERR_NONE;
+}
+
+GSM_Error N71_92_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x02};
+
+ s->Phone.Data.BatteryCharge = bat;
+ smprintf(s, "Getting battery level\n");
+ return GSM_WaitFor (s, req, 4, 0x17, 4, ID_GetBatteryCharge);
+}
+
+GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Bitmap_Types BmpType;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[4]) {
+ case 0x02:
+ if (Data->RequestID == ID_GetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Welcome note text received\n");
+ CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6);
+ smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
+ return ERR_NONE;
+ }
+ if (Data->RequestID == ID_SetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Startup text set\n");
+ return ERR_NONE;
+ }
+ case 0x15:
+ if (Data->RequestID == ID_GetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Startup logo received\n");
+ BmpType=GSM_Nokia7110StartupLogo;
+ if (msg.Buffer[17]==0x60) BmpType=GSM_Nokia6210StartupLogo;
+ if (msg.Buffer[17]==0xc0) BmpType=GSM_NokiaStartupLogo;
+ PHONE_DecodeBitmap(BmpType, msg.Buffer+22, Data->Bitmap);
+ return ERR_NONE;
+ }
+ if (Data->RequestID == ID_SetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Startup logo set\n");
+ return ERR_NONE;
+ }
+ case 0x17:
+ if (Data->RequestID == ID_GetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Dealer note text received\n");
+ CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6);
+ smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
+ return ERR_NONE;
+ }
+ if (Data->RequestID == ID_SetBitmap || Data->RequestID == ID_EachFrame) {
+ smprintf(s, "Dealer text set\n");
+ return ERR_NONE;
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error N71_92_GetPhoneSetting(GSM_StateMachine *s, int Request, int Setting)
+{
+ unsigned char req[] = {N7110_FRAME_HEADER, 0xee,
+ 0x1c}; /* Setting */
+
+ req[4]=Setting;
+ return GSM_WaitFor (s, req, 5, 0x7a, 4, Request);
+}
+
+GSM_Error N71_92_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
+{
+ return DCT3_GetDateTime(s, date_time, 0x19);
+}
+
+GSM_Error N71_92_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
+{
+ return DCT3_SetDateTime(s, date_time, 0x19);
+}
+
+GSM_Error DCT3_DecodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer)
+{
+ switch (buffer[12] & 0x03) {
+ case 0x00:
+ smprintf(s, "SMS type - deliver\n");
+ SMS->PDU = SMS_Deliver;
+ return GSM_DecodeSMSFrame(SMS,buffer,PHONE_SMSDeliver);
+ case 0x01:
+ smprintf(s, "SMS type - submit\n");
+ SMS->PDU = SMS_Submit;
+ return GSM_DecodeSMSFrame(SMS,buffer,PHONE_SMSSubmit);
+ case 0x02:
+ smprintf(s, "SMS type - delivery report\n");
+ SMS->PDU = SMS_Status_Report;
+ return GSM_DecodeSMSFrame(SMS,buffer,PHONE_SMSStatusReport);
+ }
+ return ERR_UNKNOWN;
+}
+
+GSM_Error N61_91_ReplySetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x31:
+ smprintf(s, "Operator logo set OK\n");
+ return ERR_NONE;
+ case 0x32:
+ smprintf(s, "Error setting operator logo\n");
+ switch (msg.Buffer[4]) {
+ case 0x7d:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Phone settings cleaned OK\n");
+ return ERR_NONE;
+}
+
+GSM_Error N61_71_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00, 0x01, 0x65,
+ 0x01}; /* Reset type */
+
+ switch (Type) {
+ case GSM_RESET_PHONESETTINGS : req[3] = 0x01; break;
+ case GSM_RESET_DEVICE : req[3] = 0x02; break;
+ case GSM_RESET_USERINTERFACE : req[3] = 0x08; break;
+ case GSM_RESET_USERINTERFACE_PHONESETTINGS : req[3] = 0x38; break;
+ case GSM_RESET_FULLFACTORY : req[3] = 0xff; break;
+ }
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error != ERR_NONE) return error;
+
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_ResetPhoneSettings);
+}
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h
new file mode 100644
index 0000000..66b67ec
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h
@@ -0,0 +1,78 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#ifndef phone_nokia_dct3_h
+#define phone_nokia_dct3_h
+
+GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyEnableSecurity (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetWAPBookmark (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetNetworkInfo (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySendSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyGetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplySetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyNetmonitor (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyDeleteSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error N71_92_ReplyGetSignalQuality (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error N71_92_ReplyGetBatteryCharge (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error N71_92_ReplyPhoneSetting (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error N61_91_ReplySetOpLogo (GSM_Protocol_Message msg, GSM_StateMachine *s);
+#ifdef GSM_ENABLE_CELLBROADCAST
+GSM_Error DCT3_ReplySetIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error DCT3_ReplyIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s);
+#endif
+
+GSM_Error DCT3_DeleteWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
+GSM_Error DCT3_GetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
+GSM_Error DCT3_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
+GSM_Error DCT3_PlayTone (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start);
+GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status );
+GSM_Error DCT3_GetIMEI (GSM_StateMachine *s);
+GSM_Error DCT3_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc );
+GSM_Error DCT3_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo );
+GSM_Error DCT3_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber);
+GSM_Error DCT3_Reset (GSM_StateMachine *s, bool hard );
+GSM_Error DCT3_CancelCall (GSM_StateMachine *s, int ID, bool all);
+GSM_Error DCT3_AnswerAllCalls (GSM_StateMachine *s);
+GSM_Error DCT3_SendSMSMessage (GSM_StateMachine *s, GSM_SMSMessage *sms );
+GSM_Error DCT3_GetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype);
+GSM_Error DCT3_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype );
+GSM_Error DCT3_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype);
+GSM_Error DCT3_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype );
+GSM_Error DCT3_SetIncomingCB (GSM_StateMachine *s, bool enable );
+GSM_Error DCT3_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status );
+GSM_Error DCT3_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc );
+GSM_Error DCT3_GetWAPSettings (GSM_StateMachine *s, GSM_MultiWAPSettings *settings );
+GSM_Error DCT3_SetWAPSettings (GSM_StateMachine *s, GSM_MultiWAPSettings *settings);
+GSM_Error DCT3_SetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
+GSM_Error DCT3_Netmonitor (GSM_StateMachine *s, int testnumber, char *value );
+GSM_Error DCT3_GetManufactureMonth (GSM_StateMachine *s, char *value );
+GSM_Error DCT3_GetProductCode (GSM_StateMachine *s, char *value);
+GSM_Error DCT3_GetOriginalIMEI (GSM_StateMachine *s, char *value);
+GSM_Error DCT3_GetHardware (GSM_StateMachine *s, char *value);
+GSM_Error DCT3_GetPPM (GSM_StateMachine *s, char *value);
+GSM_Error N61_71_ResetPhoneSettings (GSM_StateMachine *s, GSM_ResetSettingsType Type);
+GSM_Error N71_92_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat);
+GSM_Error N71_92_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig);
+GSM_Error N71_92_GetPhoneSetting (GSM_StateMachine *s, int Request, int Setting);
+GSM_Error N71_92_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time );
+GSM_Error N71_92_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time );
+
+GSM_Error DCT3_DecodeSMSFrame (GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer);
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c
new file mode 100644
index 0000000..263d12b
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.c
@@ -0,0 +1,2884 @@
+/* (c) 2001-2004 by Marcin Wiacek */
+/* based on some work from Markus Plail and Gnokii */
+/* Authentication function (c) 1999 or earlier by Pavel Janik */
+/* 5210 calendar IDs by Frederick Ros */
+
+#include "../../../gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA6110
+
+#include <string.h>
+
+#include "../../../../cfg/config.h"
+#include "../../../misc/coding/coding.h"
+#include "../../../service/sms/gsmsms.h"
+#include "../../../gsmcomon.h"
+#include "../../pfunc.h"
+#include "../nfunc.h"
+#include "n6110.h"
+#include "dct3func.h"
+
+static unsigned char N6110_MEMORY_TYPES[] = {
+ MEM_ME, 0x02,
+ MEM_SM, 0x03,
+ MEM_ON, 0x05,
+ MEM_DC, 0x07,
+ MEM_RC, 0x08,
+ MEM_MC, 0x09,
+ MEM_VM, 0x0b,
+ 0x00, 0x00
+};
+
+static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ N6110_Language lang = N6110_Auto;
+
+ if (msg.Buffer[3] == 0x15) return ERR_NONE;
+
+ smprintf(s, "Phone language is %02x\n",msg.Buffer[6]);
+ switch (msg.Buffer[6]) {
+ case 0x21: lang = N6110_Europe; break; //Polish
+ }
+ s->Phone.Data.Priv.N6110.PhoneLanguage = lang;
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s)
+{
+ unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
+ 0x00, /* Profile location */
+ 0x00}; /* Feature number */
+
+ s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto;
+
+ feat_req[5] = 0;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ feat_req[6] = 0x1E;
+ } else {
+ feat_req[6] = 0x21;
+ }
+ smprintf(s, "Getting profile feature\n");
+ return GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetLanguage);
+}
+
+struct N6110_Lang_Char {
+ N6110_Language Lang;
+ unsigned char Phone;
+ unsigned char Unicode1;
+ unsigned char Unicode2;
+};
+
+static struct N6110_Lang_Char N6110_Lang_Table[] = {
+{N6110_Europe,0x13,0x01,0x04},//Latin capital letter a with ogonek
+{N6110_Europe,0x14,0x01,0x05},//Latin small letter a with ogonek
+{N6110_Europe,0x15,0x01,0x06},//Latin capital letter c with acute
+{N6110_Europe,0x17,0x01,0x07},//Latin small letter c with acute
+{N6110_Europe,0x1D,0x01,0x18},//Latin capital letter e with ogonek
+{N6110_Europe,0x1E,0x01,0x19},//Latin small letter e with ogonek
+{N6110_Europe,0x83,0x00,0xD3},//Latin capital letter o with acute
+{N6110_Europe,0x8E,0x01,0x41},//Latin capital letter l with stroke
+{N6110_Europe,0x90,0x01,0x42},//Latin small letter l with stroke
+{N6110_Europe,0x92,0x01,0x43},//Latin capital letter n with acute
+{N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute
+{N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute
+{N6110_Europe,0xB2,0x20,0xAC},//euro
+{N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute
+{N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute
+{N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute
+{N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute
+{N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above
+{N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above
+{0,0,0,0}
+};
+
+static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len)
+{
+ int i_len = 0, o_len, i;
+ wchar_t wc;
+ GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
+ bool found;
+
+ for (o_len = 0; i_len < len; o_len++) {
+ found = false;
+ if (Priv->PhoneLanguage != N6110_Auto) {
+ i = 0;
+ while(1) {
+ if (N6110_Lang_Table[i].Lang == 0) break;
+ if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage &&
+ N6110_Lang_Table[i].Phone == src[i_len]) {
+ dest[o_len*2] = N6110_Lang_Table[i].Unicode1;
+ dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2;
+ i_len++;
+ found = true;
+ break;
+ }
+ i++;
+ }
+ }
+ if (!found) {
+ i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
+ dest[o_len*2] = (wc >> 8) & 0xff;
+ dest[(o_len*2)+1] = wc & 0xff;
+ }
+ }
+ dest[o_len*2] = 0;
+ dest[(o_len*2)+1] = 0;
+}
+
+#ifndef ENABLE_LGPL
+
+/* This function provides Nokia authentication protocol.
+ * Nokia authentication protocol is used in the communication between Nokia
+ * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
+ * commercially sold by Nokia Corp.
+ * The authentication scheme is based on the token send by the phone to the
+ * software. The software does it's magic (see the function
+ * N6110_GetNokiaAuthentication) and returns the result back to the phone.
+ * If the result is correct the phone responds with the message "Accessory
+ * connected!" displayed on the LCD. Otherwise it will display "Accessory not
+ * supported" and some functions will not be available for use (?).
+ * The specification of the protocol is not publicly available, no comment.
+ */
+static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
+{
+ int i, j, CRC=0;
+ unsigned char Temp[16]; /* This is our temporary working area. */
+
+ /* Here we put FAC (Final Assembly Code) and serial number into our area. */
+ Temp[0] = Imei[6]; Temp[1] = Imei[7];
+ Temp[2] = Imei[8]; Temp[3] = Imei[9];
+ Temp[4] = Imei[10]; Temp[5] = Imei[11];
+ Temp[6] = Imei[12]; Temp[7] = Imei[13];
+
+ /* And now the TAC (Type Approval Code). */
+ Temp[8] = Imei[2]; Temp[9] = Imei[3];
+ Temp[10] = Imei[4]; Temp[11] = Imei[5];
+
+ /* And now we pack magic bytes from the phone. */
+ Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1];
+ Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3];
+
+ for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1;
+ switch (Temp[15] & 0x03) {
+ case 1:
+ case 2: j = Temp[13] & 0x07;
+ for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12];
+ break;
+ default: j = Temp[14] & 0x07;
+ for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12];
+ }
+ for (i=0; i<=15; i++) CRC ^= Temp[i];
+ for (i=0; i<=15; i++) {
+ switch (Temp[15 - i] & 0x06) {
+ case 0: j = Temp[i] | CRC; break;
+ case 2:
+ case 4: j = Temp[i] ^ CRC; break;
+ case 6: j = Temp[i] & CRC; break;
+ }
+ if (j == CRC) j = 0x2c;
+ if (Temp[i] == 0) j = 0;
+ MagicResponse[i] = j;
+ }
+}
+
+static GSM_Error N6110_ReplyGetMagicBytes(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ sprintf(Data->IMEI, "%s", msg.Buffer+9);
+ sprintf(Data->HardwareCache, "%s", msg.Buffer+39);
+ sprintf(Data->ProductCodeCache, "%s", msg.Buffer+31);
+
+ smprintf(s, "Message: Mobile phone identification received:\n");
+ smprintf(s, "IMEI : %s\n", msg.Buffer+9);
+ smprintf(s, "Model : %s\n", msg.Buffer+25);
+ smprintf(s, "Production Code : %s\n", msg.Buffer+31);
+ smprintf(s, "HW : %s\n", msg.Buffer+39);
+ smprintf(s, "Firmware : %s\n", msg.Buffer+44);
+
+ /* These bytes are probably the source of the "Accessory not connected"
+ * messages on the phone when trying to emulate NCDS... I hope....
+ * UPDATE: of course, now we have the authentication algorithm.
+ */
+ smprintf(s, " Magic bytes : %02x %02x %02x %02x\n", msg.Buffer[50], msg.Buffer[51], msg.Buffer[52], msg.Buffer[53]);
+
+ Priv->MagicBytes[0]=msg.Buffer[50];
+ Priv->MagicBytes[1]=msg.Buffer[51];
+ Priv->MagicBytes[2]=msg.Buffer[52];
+ Priv->MagicBytes[3]=msg.Buffer[53];
+
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_MakeAuthentication(GSM_StateMachine *s)
+{
+ GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
+ GSM_Error error;
+ unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10};
+ unsigned char magic_connect[] = {
+ N6110_FRAME_HEADER, 0x12,
+ /* The real magic goes here ... These bytes are filled in
+ * with the function N6110_GetNokiaAuthentication. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* NOKIA&GNOKII Accessory */
+ 'N', 'O', 'K', 'I', 'A', '&', 'N', 'O', 'K', 'I', 'A',
+ 'a', 'c', 'c', 'e', 's', 's', 'o', 'r', 'y',
+ 0x00, 0x00, 0x00, 0x00};
+
+ smprintf(s, "Getting magic bytes for authentication\n");
+ error=GSM_WaitFor (s, connect4, 4, 0x64, 4, ID_MakeAuthentication);
+ if (error!=ERR_NONE) return error;
+
+ N6110_GetNokiaAuthentication(s->Phone.Data.IMEI, Priv->MagicBytes, magic_connect+4);
+ smprintf(s, "Sending authentication bytes\n");
+ return s->Protocol.Functions->WriteMessage(s, magic_connect, 45, 0x64);
+}
+
+#endif
+
+static GSM_Error N6110_ShowStartInfo(GSM_StateMachine *s, bool enable)
+{
+#ifdef ENABLE_LGPL
+ return ERR_NONE;
+#else
+ GSM_Error error=ERR_NONE;
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_MAGICBYTES)) {
+ if (s->ConnectionType == GCT_FBUS2 ||
+ s->ConnectionType == GCT_FBUS2IRDA) {
+ error=N6110_MakeAuthentication(s);
+ }
+ }
+ return error;
+#endif
+}
+
+static GSM_Error N6110_Initialise (GSM_StateMachine *s)
+{
+#ifdef DEBUG
+ DCT3_SetIncomingCB(s,true);
+#endif
+ N6110_GetPhoneLanguage(s);
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
+{
+ return DCT3_GetDateTime(s, date_time, 0x11);
+}
+
+static GSM_Error N6110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ return DCT3_GetAlarm(s, alarm, 0x11);
+}
+
+static GSM_Error N6110_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
+{
+ return DCT3_SetDateTime(s, date_time, 0x11);
+}
+
+static GSM_Error N6110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ return DCT3_SetAlarm(s, alarm, 0x11);
+}
+
+static GSM_Error N6110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int count;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Phonebook entry received\n");
+ switch (msg.Buffer[3]) {
+ case 0x02:
+ Data->Memory->EntriesNum = 0;
+ count=5;
+ /* If name is not empty */
+ if (msg.Buffer[count]!=0x00) {
+ if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
+ smprintf(s, "Too long text\n");
+ return ERR_UNKNOWNRESPONSE;
+ }
+ Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Text_Name;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPBKUNICODE)) {
+ if (Data->Memory->MemoryType==MEM_DC ||
+ Data->Memory->MemoryType==MEM_RC ||
+ Data->Memory->MemoryType==MEM_MC ||
+ Data->Memory->MemoryType==MEM_ME) {
+ N6110_EncodeUnicode(s,Data->Memory->Entries[Data->Memory->EntriesNum].Text,
+ msg.Buffer+count+1,msg.Buffer[count]);
+ } else {
+ EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
+ msg.Buffer+count+1,msg.Buffer[count]);
+ }
+ } else {
+ memcpy(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
+ msg.Buffer+count+1,msg.Buffer[count]);
+ Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]]=0x00;
+ Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]+1]=0x00;
+ }
+ smprintf(s, "Name \"%s\"\n",
+ DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text));
+ Data->Memory->EntriesNum++;
+ }
+ count=count+msg.Buffer[count]+1;
+
+ /* If number is empty */
+ if (msg.Buffer[count]==0x00) return ERR_EMPTY;
+
+ if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
+ smprintf(s, "Too long text\n");
+ return ERR_UNKNOWNRESPONSE;
+ }
+ Data->Memory->Entries[Data->Memory->EntriesNum].EntryType = PBK_Number_General;
+ Data->Memory->Entries[Data->Memory->EntriesNum].VoiceTag = 0;
+ Data->Memory->Entries[Data->Memory->EntriesNum].SMSList[0] = 0;
+ EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
+ msg.Buffer+count+1,msg.Buffer[count]);
+ smprintf(s, "Number \"%s\"\n",
+ DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text));
+ Data->Memory->EntriesNum++;
+ count=count+msg.Buffer[count]+1;
+
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALLER)) {
+ if (msg.Buffer[count]<5) {
+ Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Caller_Group;
+ smprintf(s, "Caller group \"%i\"\n",msg.Buffer[count]);
+ Data->Memory->Entries[Data->Memory->EntriesNum].Number=msg.Buffer[count]+1;
+ Data->Memory->EntriesNum++;
+ }
+ }
+ count++;
+
+ if (Data->Memory->MemoryType==MEM_DC ||
+ Data->Memory->MemoryType==MEM_RC ||
+ Data->Memory->MemoryType==MEM_MC) {
+ NOKIA_DecodeDateTime(s, msg.Buffer+count+1,&Data->Memory->Entries[Data->Memory->EntriesNum].Date);
+ Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Date;
+
+ /* These values are set, when date and time unavailable in phone.
+ * Values from 3310 - in other can be different */
+ if (Data->Memory->Entries[2].Date.Day !=20 ||
+ Data->Memory->Entries[2].Date.Month !=1 ||
+ Data->Memory->Entries[2].Date.Year !=2118||
+ Data->Memory->Entries[2].Date.Hour !=3 ||
+ Data->Memory->Entries[2].Date.Minute!=14 ||
+ Data->Memory->Entries[2].Date.Second!=7)
+ Data->Memory->EntriesNum++;
+ }
+
+ return ERR_NONE;
+ default:
+ switch (msg.Buffer[4]) {
+ case 0x6f:
+ smprintf(s, "Phone is OFF\n");
+ return ERR_PHONEOFF;
+ case 0x74:
+ /* TODO: check if not too high */
+ smprintf(s, "ERROR: Empty ????\n");
+ Data->Memory->EntriesNum = 0;
+ return ERR_EMPTY;
+ case 0x7d:
+ smprintf(s, "ERROR: Invalid memory type\n");
+ return ERR_NOTSUPPORTED;
+ case 0x8d:
+ smprintf(s, "ERROR: no PIN\n");
+ return ERR_SECURITYERROR;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x01,
+ 0x00, /* memory type */
+ 0x00, /* location */
+ 0x00};
+
+ req[4] = NOKIA_GetMemoryType(s, entry->MemoryType,N6110_MEMORY_TYPES);
+ if (req[4]==0xff) return ERR_NOTSUPPORTED;
+
+ req[5] = entry->Location;
+ if (entry->MemoryType==MEM_DC || entry->MemoryType==MEM_RC || entry->MemoryType==MEM_MC) req[5]--;
+
+ s->Phone.Data.Memory=entry;
+ smprintf(s, "Getting phonebook entry\n");
+ return GSM_WaitFor (s, req, 7, 0x03, 4, ID_GetMemory);
+}
+
+static GSM_Error N6110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Memory status received\n");
+ switch (msg.Buffer[3]) {
+ case 0x08:
+ smprintf(s, "Memory type: %i\n",msg.Buffer[4]);
+
+ smprintf(s, "Free : %i\n",msg.Buffer[5]);
+ Data->MemoryStatus->MemoryFree=msg.Buffer[5];
+
+ smprintf(s, "Used : %i\n",msg.Buffer[6]);
+ Data->MemoryStatus->MemoryUsed=msg.Buffer[6];
+
+ return ERR_NONE;
+ break;
+ case 0x09:
+ switch (msg.Buffer[4]) {
+ case 0x6f:
+ smprintf(s, "Phone is probably powered off.\n");
+ return ERR_TIMEOUT;
+ case 0x7d:
+ smprintf(s, "Memory type not supported by phone model.\n");
+ return ERR_NOTSUPPORTED;
+ case 0x8d:
+ smprintf(s, "Waiting for security code.\n");
+ return ERR_SECURITYERROR;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+static GSM_Error N6110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
+ 0x00}; /* memory type */
+
+ req[4] = NOKIA_GetMemoryType(s, Status->MemoryType,N6110_MEMORY_TYPES);
+ if (req[4]==0xff) return ERR_NOTSUPPORTED;
+
+ s->Phone.Data.MemoryStatus=Status;
+ smprintf(s, "Getting memory status\n");
+ return GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetMemoryStatus);
+}
+
+static GSM_Error N6110_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "SMS status received\n");
+ switch (msg.Buffer[3]) {
+ case 0x37:
+ smprintf(s, "SIM size : %i\n",msg.Buffer[7]);
+ smprintf(s, "Used in SIM : %i\n",msg.Buffer[10]);
+ smprintf(s, "Unread in SIM : %i\n",msg.Buffer[11]);
+ Data->SMSStatus->SIMUsed = msg.Buffer[10];
+ Data->SMSStatus->SIMUnRead = msg.Buffer[11];
+ Data->SMSStatus->SIMSize = msg.Buffer[7];
+ Data->SMSStatus->PhoneUsed = 0;
+ Data->SMSStatus->PhoneUnRead = 0;
+ Data->SMSStatus->PhoneSize = 0;
+ Data->SMSStatus->TemplatesUsed = 0;
+ return ERR_NONE;
+ case 0x38:
+ smprintf(s, "Error. No PIN ?\n");
+ return ERR_SECURITYERROR;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "SMS Message received\n");
+ switch(msg.Buffer[3]) {
+ case 0x08:
+ Data->GetSMSMessage->Number = 1;
+ Data->GetSMSMessage->SMS[0].Name[0] = 0;
+ Data->GetSMSMessage->SMS[0].Name[1] = 0;
+ Data->GetSMSMessage->SMS[0].Memory = MEM_SM;
+ NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
+ switch (msg.Buffer[7]) {
+ case 0x00: case 0x01: /* Report or SMS_Deliver */
+ Data->GetSMSMessage->SMS[0].Folder = 0x01;
+ Data->GetSMSMessage->SMS[0].InboxFolder = true;
+ break;
+ case 0x02: /* SMS_Submit */
+ Data->GetSMSMessage->SMS[0].Folder = 0x02;
+ Data->GetSMSMessage->SMS[0].InboxFolder = false;
+ break;
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+ DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+8);
+ return ERR_NONE;
+ case 0x09:
+ switch (msg.Buffer[4]) {
+ case 0x00:
+ smprintf(s, "Unknown. Probably phone too busy\n");
+ return ERR_UNKNOWN;
+ case 0x02:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ case 0x06:
+ smprintf(s, "Phone is OFF\n");
+ return ERR_PHONEOFF;
+ case 0x07:
+ smprintf(s, "Empty\n");
+ return ERR_EMPTY;
+ case 0x0c:
+ smprintf(s, "Access error. No PIN ?\n");
+ return ERR_SECURITYERROR;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x02,
+ 0x00, /* Location */
+ 0x01, 0x64};
+
+ if (sms->SMS[0].Folder!=0x00) return ERR_NOTSUPPORTED;
+
+ req[5] = sms->SMS[0].Location;
+
+ s->Phone.Data.GetSMSMessage=sms;
+ smprintf(s, "Getting sms\n");
+ return GSM_WaitFor (s, req, 8, 0x02, 4, ID_GetSMSMessage);
+}
+
+static GSM_Error N6110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
+{
+ GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
+ GSM_Error error;
+
+ if (start) {
+ error=s->Phone.Functions->GetSMSStatus(s,&Priv->LastSMSStatus);
+ if (error!=ERR_NONE) return error;
+ Priv->LastSMSRead=0;
+ sms->SMS[0].Location=0;
+ }
+ while (true) {
+ sms->SMS[0].Location++;
+ if (Priv->LastSMSRead>=(Priv->LastSMSStatus.SIMUsed+Priv->LastSMSStatus.PhoneUsed+Priv->LastSMSStatus.TemplatesUsed)) return ERR_EMPTY;
+ error=s->Phone.Functions->GetSMS(s, sms);
+ if (error==ERR_NONE) {
+ Priv->LastSMSRead++;
+ break;
+ }
+ if (error != ERR_EMPTY) return error;
+ }
+ return error;
+}
+
+static GSM_Error N6110_ReplyGetStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+#ifdef DEBUG
+ smprintf(s, "Phone status received :\n");
+ smprintf(s, "Mode : ");
+ switch (msg.Buffer[4]) {
+ case 0x01: smprintf(s, "registered within the network\n"); break;
+ case 0x02: smprintf(s, "call in progress\n"); break; /* ringing or already answered call */
+ case 0x03: smprintf(s, "waiting for security code\n"); break;
+ case 0x04: smprintf(s, "powered off\n"); break;
+ default : smprintf(s, "unknown\n");
+ }
+ smprintf(s, "Power source : ");
+ switch (msg.Buffer[7]) {
+ case 0x01: smprintf(s, "AC/DC\n"); break;
+ case 0x02: smprintf(s, "battery\n"); break;
+ default : smprintf(s, "unknown\n");
+ }
+ smprintf(s, "Battery Level : %d\n", msg.Buffer[8]);
+ smprintf(s, "Signal strength : %d\n", msg.Buffer[5]);
+#endif
+
+ switch (Data->RequestID) {
+ case ID_GetBatteryCharge:
+ Data->BatteryCharge->BatteryPercent = ((int)msg.Buffer[8])*25;
+ switch (msg.Buffer[7]) {
+ case 0x01: Data->BatteryCharge->ChargeState = GSM_BatteryConnected; break;
+ case 0x02: Data->BatteryCharge->ChargeState = GSM_BatteryPowered; break;
+ default : Data->BatteryCharge->ChargeState = 0;
+ }
+ return ERR_NONE;
+ case ID_GetSignalQuality:
+ Data->SignalQuality->SignalPercent = ((int)msg.Buffer[5])*25;
+ return ERR_NONE;
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+static GSM_Error N6110_GetStatus(GSM_StateMachine *s, int ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x01};
+
+ return GSM_WaitFor (s, req, 4, 0x04, 4, ID);
+}
+
+static GSM_Error N6110_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
+{
+ char value[100];
+ GSM_Error error;
+
+ sig->BitErrorRate = -1;
+ sig->SignalStrength = -1; /* TODO for netmon */
+
+ smprintf(s, "Getting network level\n");
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_POWER_BATT)) {
+ error = DCT3_Netmonitor(s, 1, value);
+ if (error!=ERR_NONE) return error;
+ sig->SignalPercent = 100;
+ if (value[4]!='-') {
+ if (value[5]=='9' && value[6]>'4') sig->SignalPercent = 25;
+ if (value[5]=='9' && value[6]<'5') sig->SignalPercent = 50;
+ if (value[5]=='8' && value[6]>'4') sig->SignalPercent = 75;
+ } else sig->SignalPercent = 0;
+ return ERR_NONE;
+ } else {
+ s->Phone.Data.SignalQuality = sig;
+ return N6110_GetStatus(s, ID_GetSignalQuality);
+ }
+}
+
+static GSM_Error N6110_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
+{
+ char value[100];
+ GSM_Error error;
+
+ smprintf(s, "Getting battery level\n");
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_POWER_BATT)) {
+ error = DCT3_Netmonitor(s, 23, value);
+ if (error!=ERR_NONE) return error;
+ bat->BatteryPercent = 100;
+ bat->ChargeState = 0;
+ if (value[29]=='7') bat->BatteryPercent = 75;
+ if (value[29]=='5') bat->BatteryPercent = 50;
+ if (value[29]=='2') bat->BatteryPercent = 25;
+ return ERR_NONE;
+ } else {
+ s->Phone.Data.BatteryCharge = bat;
+ return N6110_GetStatus(s, ID_GetBatteryCharge);
+ }
+}
+
+static GSM_Error N6110_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "SMS message saving status\n");
+ switch (msg.Buffer[3]) {
+ case 0x05:
+ smprintf(s, "Saved at location %i\n",msg.Buffer[5]);
+ Data->SaveSMSMessage->Location=msg.Buffer[5];
+ return ERR_NONE;
+ case 0x06:
+ switch (msg.Buffer[4]) {
+ case 0x02:
+ smprintf(s, "All locations busy\n");
+ return ERR_FULL;
+ case 0x03:
+ smprintf(s, "Too high ?\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int length;
+ GSM_Error error;
+ unsigned char req[256] = {N6110_FRAME_HEADER, 0x04,
+ 0x00, /* SMS status */
+ 0x02,
+ 0x00, /* SMS location */
+ 0x02}; /* SMS type */
+
+ req[6] = sms->Location;
+ if (sms->Folder==1) { /* Inbox */
+ req[4] = 1; /* SMS status - GSM_Read */
+ req[7] = 0x00; /* SMS type */
+ sms->PDU = SMS_Deliver;
+ error=PHONE_EncodeSMSFrame(s,sms,req+8,PHONE_SMSDeliver,&length,true);
+ } else { /* Outbox */
+ req[4] = 5; /* SMS status - GSM_Sent */
+ req[7] = 0x02; /* SMS type */
+ sms->PDU = SMS_Submit;
+ error=PHONE_EncodeSMSFrame(s,sms,req+8,PHONE_SMSSubmit,&length,true);
+ }
+ if (error != ERR_NONE) return error;
+
+ /* SMS State - GSM_Read -> GSM_Unread and GSM_Sent -> GSM_UnSent */
+ if (sms->State == SMS_UnSent || sms->State == SMS_UnRead) req[4] |= 0x02;
+
+ s->Phone.Data.SaveSMSMessage=sms;
+ smprintf(s, "Saving sms\n");
+ return GSM_WaitFor (s, req, 8+length, 0x14, 4, ID_SaveSMSMessage);
+}
+
+static GSM_Error N6110_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ if (sms->Location == 0) return ERR_INVALIDLOCATION;
+ return N6110_PrivSetSMSMessage(s, sms);
+}
+
+static GSM_Error N6110_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ sms->Location = 0;
+ return N6110_PrivSetSMSMessage(s, sms);
+}
+
+static GSM_Error N6110_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x37:
+ smprintf(s, "Ringtone set OK\n");
+ return ERR_NONE;
+ break;
+ case 0x38:
+ smprintf(s, "Error setting ringtone\n");
+ switch (msg.Buffer[4]) {
+ case 0x7d:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_ReplySetBinRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[4]) {
+ case 0x00:
+ smprintf(s, "Set at location %i\n",msg.Buffer[3]+1);
+ return ERR_NONE;
+ default:
+ smprintf(s, "Invalid location. Too high ?\n");
+ return ERR_INVALIDLOCATION;
+ }
+}
+
+static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ GSM_NetworkInfo NetInfo;
+ GSM_Error error;
+ int size=200,current=8;
+ GSM_UDHHeader UDHHeader;
+ unsigned char req[1000] = {N6110_FRAME_HEADER, 0x36,
+ 0x00, /* Location */
+ 0x00,0x78};
+ unsigned char reqBin[1000] = {0x00,0x01,0xa0,0x00,0x00,0x0c,0x01,0x2c};
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NORING)) return ERR_NOTSUPPORTED;
+ if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
+
+ switch (Ringtone->Format) {
+ case RING_NOTETONE:
+ if (Ringtone->Location==255) {
+ /* Only 6110, 6130 and 6150 support it */
+ if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 ||
+ strcmp(s->Phone.Data.Model,"NSM-1") == 0) {
+ req[0] = 0x0c;
+ req[1] = 0x01;
+ UDHHeader.Type = UDH_NokiaRingtone;
+ GSM_EncodeUDHHeader(&UDHHeader);
+ /* We copy UDH now */
+ memcpy(req+2,UDHHeader.Text,UDHHeader.Length);
+ *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+2+UDHHeader.Length, &size);
+ error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12);
+ if (error!=ERR_NONE) return error;
+ my_sleep(1000);
+ /* We have to make something (not important, what) now */
+ /* no answer from phone*/
+ return DCT3_GetNetworkInfo(s,&NetInfo);
+ } else {
+ return ERR_NOTSUPPORTED;
+ }
+ }
+ *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+7, &size);
+ req[4] = Ringtone->Location - 1;
+ smprintf(s, "Setting ringtone\n");
+ return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone);
+ case RING_NOKIABINARY:
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+ memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name));
+ current += UnicodeLength(Ringtone->Name);
+ reqBin[current++] = 0x00;
+ reqBin[current++] = 0x00;
+ reqBin[current++] = 0x00;/*xxx*/
+ memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
+ current=current+Ringtone->NokiaBinary.Length;
+ reqBin[3]=Ringtone->Location-1;
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10;
+ smprintf(s, "Setting binary ringtone\n");
+ return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone);
+ case RING_MIDI:
+ return ERR_NOTSUPPORTED;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int count=5;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Operator logo received\n");
+ NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode);
+ count = count + 3;
+ smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode);
+ smprintf(s, "Network name for Gammu : %s ",
+ DecodeUnicodeString(GSM_GetNetworkName(Data->Bitmap->NetworkCode)));
+ smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(Data->Bitmap->NetworkCode)));
+
+ count = count + 3; /* We ignore size */
+ Data->Bitmap->BitmapWidth = msg.Buffer[count++];
+ Data->Bitmap->BitmapHeight = msg.Buffer[count++];
+ count++;
+ PHONE_DecodeBitmap(GSM_NokiaOperatorLogo,msg.Buffer+count,Data->Bitmap);
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i, count = 5;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Startup logo & notes received\n");
+ for (i=0;i<msg.Buffer[4];i++) {
+ switch (msg.Buffer[count++]) {
+ case 0x01:
+ smprintf(s, "Startup logo\n");
+ if (Data->Bitmap->Type == GSM_StartupLogo) {
+ Data->Bitmap->BitmapHeight = msg.Buffer[count++];
+ Data->Bitmap->BitmapWidth = msg.Buffer[count++];
+ PHONE_DecodeBitmap(GSM_NokiaStartupLogo, msg.Buffer + count, Data->Bitmap);
+ } else {
+ count = count + 2;
+ }
+ count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0);
+ break;
+ case 0x02:
+ smprintf(s, "Welcome note\n");
+ if (Data->Bitmap->Type == GSM_WelcomeNote_Text) {
+ EncodeUnicode(Data->Bitmap->Text,msg.Buffer+count, msg.Buffer[count]);
+ smprintf(s, "Text is \"%s\"\n",Data->Bitmap->Text);
+ }
+ count = count + msg.Buffer[count] + 1;
+ break;
+ case 0x03:
+ smprintf(s, "Dealer welcome note\n");
+ if (Data->Bitmap->Type == GSM_DealerNote_Text) {
+ EncodeUnicode(Data->Bitmap->Text,msg.Buffer+count, msg.Buffer[count]);
+ smprintf(s, "Text is \"%s\"\n",Data->Bitmap->Text);
+ }
+ count = count + msg.Buffer[count] + 1;
+ break;
+ default:
+ smprintf(s, "Unknown block\n");
+ return ERR_UNKNOWNRESPONSE;
+ break;
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_ReplyGetCallerLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int count;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x11:
+ smprintf(s, "Caller group info received\n");
+ EncodeUnicode(Data->Bitmap->Text,msg.Buffer+6,msg.Buffer[5]);
+ smprintf(s, "Name : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
+ Data->Bitmap->DefaultName = false;
+ if (msg.Buffer[5] == 0x00) Data->Bitmap->DefaultName = true;
+ count = msg.Buffer[5] + 6;
+ Data->Bitmap->RingtoneID = msg.Buffer[count++];
+ Data->Bitmap->DefaultRingtone = false;
+ Data->Bitmap->FileSystemRingtone = false;
+ if (Data->Bitmap->RingtoneID == 16) Data->Bitmap->DefaultRingtone = true;
+ smprintf(s, "Ringtone ID: %02x\n",Data->Bitmap->RingtoneID);
+ Data->Bitmap->BitmapEnabled=(msg.Buffer[count++]==1);
+#ifdef DEBUG
+ smprintf(s, "Caller group logo ");
+ if (Data->Bitmap->BitmapEnabled) {
+ smprintf(s, "enabled\n");
+ } else {
+ smprintf(s, "disabled\n");
+ }
+#endif
+ count = count + 3; /* We ignore size */
+ Data->Bitmap->BitmapWidth = msg.Buffer[count++];
+ Data->Bitmap->BitmapHeight = msg.Buffer[count++];
+ count++;
+ PHONE_DecodeBitmap(GSM_NokiaCallerLogo,msg.Buffer+count,Data->Bitmap);
+ Data->Bitmap->DefaultBitmap = false;
+ return ERR_NONE;
+ case 0x12:
+ smprintf(s, "Error getting caller group info\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_ReplyGetSetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int count = 5, i;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x02:
+ smprintf(s, "Picture Image received\n");
+ if (msg.Buffer[count]!=0) {
+ GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender, msg.Buffer + 5, true);
+ /* Convert number of semioctets to number of chars */
+ i = msg.Buffer[5];
+ if (i % 2) i++;
+ i=i / 2 + 1;
+ count = count + i + 1;
+ } else {
+ Data->Bitmap->Sender[0] = 0x00;
+ Data->Bitmap->Sender[1] = 0x00;
+ count+=2;
+ }
+ smprintf(s, "Sender : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Sender));
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPICTUREUNI) ||
+ (!strcmp(Data->Model,"NHM-5") && Data->VerNum < 5.79)) {
+ count++;
+ EncodeUnicode(Data->Bitmap->Text,msg.Buffer+count+1,msg.Buffer[count]);
+ count += UnicodeLength(Data->Bitmap->Text) + 1;
+ } else {
+ if (!strcmp(Data->Model,"NHM-5")) {
+ i = msg.Buffer[count] * 256 + msg.Buffer[count+1];
+ } else {
+ /* 3410 4.26 */
+ i = msg.Buffer[count] * 256 + msg.Buffer[count+1] - 2;
+ count += 2;
+ }
+ memcpy(Data->Bitmap->Text,msg.Buffer+count+2,i);
+ Data->Bitmap->Text[i] = 0;
+ Data->Bitmap->Text[i+1] = 0;
+ count += i + 2;
+ }
+ smprintf(s, "Text : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
+ Data->Bitmap->BitmapWidth = msg.Buffer[count++];
+ Data->Bitmap->BitmapHeight = msg.Buffer[count++];
+ PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + count + 2, Data->Bitmap);
+#ifdef DEBUG
+ if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) GSM_PrintBitmap(di.df,Data->Bitmap);
+#endif
+ return ERR_NONE;
+ break;
+ case 0x04:
+ smprintf(s, "Picture Image set OK\n");
+ return ERR_NONE;
+ case 0x05:
+ smprintf(s, "Can't set Picture Image - invalid location ?\n");
+ return ERR_INVALIDLOCATION;
+ break;
+ case 0x06:
+ smprintf(s, "Can't get Picture Image - invalid location ?\n");
+ return ERR_INVALIDLOCATION;
+ break;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Error error;
+ unsigned char req[10] = {N6110_FRAME_HEADER};
+
+ s->Phone.Data.Bitmap=Bitmap;
+ switch (Bitmap->Type) {
+ case GSM_StartupLogo:
+ case GSM_WelcomeNote_Text:
+ case GSM_DealerNote_Text:
+ if (Bitmap->Type == GSM_StartupLogo && IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOSTARTUP)) return ERR_NOTSUPPORTED;
+ req[3] = 0x16;
+ return GSM_WaitFor (s, req, 4, 0x05, 4, ID_GetBitmap);
+ case GSM_CallerGroupLogo:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOCALLER)) return ERR_NOTSUPPORTED;
+ req[3] = 0x10;
+ req[4] = Bitmap->Location - 1;
+ error = GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetBitmap);
+ if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s,Bitmap);
+ return error;
+ case GSM_OperatorLogo:
+ req[3] = 0x33;
+ req[4] = 0x01;
+ return GSM_WaitFor (s, req, 5, 0x05, 4, ID_GetBitmap);
+ case GSM_PictureImage:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOPICTURE)) return ERR_NOTSUPPORTED;
+ req[3] = 0x01;
+ req[4] = Bitmap->Location - 1;
+ return GSM_WaitFor (s, req, 5, 0x47, 4, ID_GetBitmap);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N6110_ReplySetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x11:
+ smprintf(s, "Feature of profile set\n");
+ return ERR_NONE;
+ case 0x12:
+ smprintf(s, "Error setting profile feature\n");
+ return ERR_NOTSUPPORTED;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_SetProfileFeature(GSM_StateMachine *s, unsigned char profile, unsigned char feature, unsigned char value)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x10, 0x01,
+ 0x00, /* Profile */
+ 0x00, /* Feature */
+ 0x00}; /* Value */
+
+ req[5]=profile;
+ req[6]=feature;
+ req[7]=value;
+ smprintf(s, "Setting profile feature\n");
+ return GSM_WaitFor (s, req, 8, 0x05, 4, ID_SetProfile);
+}
+
+static GSM_Error N6110_ReplySetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Startup logo set OK\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_ReplySetCallerLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x14:
+ smprintf(s, "Caller group set OK\n");
+ return ERR_NONE;
+ case 0x15:
+ smprintf(s, "Error setting caller group\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char reqPreview[1000] = {0x0c,0x01};
+ unsigned char req[600] = {N6110_FRAME_HEADER};
+ GSM_UDH UDHType = UDH_NokiaOperatorLogo;
+ int count = 0, textlen, Width, Height;
+ GSM_UDHHeader UDHHeader;
+ GSM_NetworkInfo NetInfo;
+ GSM_Error error;
+
+ switch (Bitmap->Type) {
+ case GSM_CallerGroupLogo:
+ case GSM_OperatorLogo:
+ if (Bitmap->Location == 255) {
+ /* Only 6110, 6130 and 6150 support it */
+ if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 ||
+ strcmp(s->Phone.Data.Model,"NSM-1") == 0) {
+ if (Bitmap->Type==GSM_CallerGroupLogo) UDHType = UDH_NokiaCallerLogo;
+ UDHHeader.Type = UDHType;
+ GSM_EncodeUDHHeader(&UDHHeader);
+ /* We copy UDH now */
+ memcpy(reqPreview+2,UDHHeader.Text,UDHHeader.Length);
+ count = count + UDHHeader.Length;
+ if (Bitmap->Type == GSM_OperatorLogo) {
+ NOKIA_EncodeNetworkCode(reqPreview+count,Bitmap->NetworkCode);
+ count = count + 3;
+ } else {
+ if (Bitmap->DefaultBitmap) {
+ Bitmap->BitmapWidth = 72;
+ Bitmap->BitmapHeight = 14;
+ GSM_ClearBitmap(Bitmap);
+ }
+ }
+ NOKIA_CopyBitmap(GSM_NokiaOperatorLogo,Bitmap,reqPreview, &count);
+ reqPreview[count]=0x00;
+ error = s->Protocol.Functions->WriteMessage(s, reqPreview, count + 1, 0x12);
+ if (error!=ERR_NONE) return error;
+ my_sleep(1000);
+ /* We have to make something (not important, what) now */
+ /* no answer from phone*/
+ return DCT3_GetNetworkInfo(s,&NetInfo);
+ } else {
+ smprintf(s, "%s\n",s->Phone.Data.Model);
+ return ERR_NOTSUPPORTED;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ count = 3;
+
+ switch (Bitmap->Type) {
+ case GSM_StartupLogo:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOSTARTUP)) return ERR_NOTSUPPORTED;
+ if (Bitmap->Location != 1) {
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOSTARTANI)) return ERR_NOTSUPPORTED;
+ }
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOSTARTANI)) {
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) {
+ error = N6110_SetProfileFeature(s,0,0x2e,((unsigned char)(Bitmap->Location-1)));
+ } else {
+ error = N6110_SetProfileFeature(s,0,0x29,((unsigned char)(Bitmap->Location-1)));
+ }
+ if (error == ERR_NOTSUPPORTED) error = ERR_SECURITYERROR;
+ if (error != ERR_NONE) return error;
+ if (Bitmap->Location != 1) return ERR_NONE;
+ }
+ req[count++] = 0x18;
+ req[count++] = 0x01; /* One block */
+ req[count++] = 0x01;
+ PHONE_GetBitmapWidthHeight(GSM_NokiaStartupLogo, &Width, &Height);
+ req[count++] = Height;
+ req[count++] = Width;
+ PHONE_EncodeBitmap(GSM_NokiaStartupLogo, req + count, Bitmap);
+ count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0);
+ return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
+ case GSM_WelcomeNote_Text:
+ case GSM_DealerNote_Text:
+ req[count++] = 0x18;
+ req[count++] = 0x01; /* One block */
+ if (Bitmap->Type == GSM_WelcomeNote_Text) {
+ req[count++] = 0x02;
+ } else {
+ req[count++] = 0x03;
+ }
+ textlen = UnicodeLength(Bitmap->Text);
+ req[count++] = textlen;
+ memcpy(req + count,DecodeUnicodeString(Bitmap->Text),textlen);
+ count += textlen;
+ return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
+ case GSM_CallerGroupLogo:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOCALLER)) return ERR_NOTSUPPORTED;
+ req[count++] = 0x13;
+ req[count++] = Bitmap->Location - 1;
+ if (Bitmap->DefaultName) {
+ req[count++] = 0;
+ } else {
+ textlen = UnicodeLength(Bitmap->Text);
+ req[count++] = textlen;
+ memcpy(req+count,DecodeUnicodeString(Bitmap->Text),textlen);
+ count += textlen;
+ }
+ if (Bitmap->DefaultRingtone) {
+ req[count++] = 16;
+ } else {
+ req[count++] = Bitmap->RingtoneID;
+ }
+ /* Value here is number of phone menu connected
+ * with caller logo in Nokia 61x0: 0x00 = Off, 0x01 = On,
+ * 0x02 = View Graphics, 0x03 = Send Graphics,
+ * 0x04 = Send via IR. For higher menu option connected with
+ * caller logo is not displayed
+ */
+ if (Bitmap->DefaultBitmap) {
+ Bitmap->BitmapWidth = 72;
+ Bitmap->BitmapHeight = 14;
+ GSM_ClearBitmap(Bitmap);
+ req[count++] = 0;
+ } else {
+ if (Bitmap->BitmapEnabled) req[count++] = 0x01; else req[count++] = 0x00;
+ }
+ req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) / 256;
+ req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) % 256;
+ NOKIA_CopyBitmap(GSM_NokiaCallerLogo, Bitmap, req, &count);
+ return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
+ case GSM_OperatorLogo:
+ req[count++] = 0x30;
+ req[count++] = 0x01;
+ NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode);
+ count = count + 3;
+ req[count++] = (PHONE_GetBitmapSize(GSM_NokiaOperatorLogo,0,0) + 4) / 256;
+ req[count++] = (PHONE_GetBitmapSize(GSM_NokiaOperatorLogo,0,0) + 4) % 256;
+ NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, Bitmap, req, &count);
+ return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
+ case GSM_PictureImage:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NOPICTURE)) return ERR_NOTSUPPORTED;
+ req[count++] = 0x03;
+ req[count++] = Bitmap->Location - 1;
+ if (Bitmap->Sender[0]!=0 || Bitmap->Sender[1]!=0) {
+ req[count]=GSM_PackSemiOctetNumber(Bitmap->Sender, req+count+1,true);
+ /* Convert number of semioctets to number of chars and add count */
+ textlen = req[count];
+ if (textlen % 2) textlen++;
+ count += textlen / 2 + 1;
+ count++;
+ } else {
+ req[count++] = 0x00;
+ req[count++] = 0x00;
+ }
+ req[count++] = 0x00;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPICTUREUNI) ||
+ (!strcmp(s->Phone.Data.Model,"NHM-5") && s->Phone.Data.VerNum < 5.79)) {
+ textlen = UnicodeLength(Bitmap->Text);
+ req[count++] = textlen;
+ memcpy(req+count,DecodeUnicodeString(Bitmap->Text),textlen);
+ count += textlen;
+ } else {
+ textlen = UnicodeLength(Bitmap->Text)*2;
+ if (!strcmp(s->Phone.Data.Model,"NHM-5")) {
+ req[count++] = textlen;
+ } else {
+ /* 3410 4.26 */
+ req[count++] = textlen+2;
+ req[count++] = 0x00;
+ req[count++] = 0x1e;
+ }
+ memcpy(req+count,Bitmap->Text,textlen);
+ count += textlen;
+ }
+ NOKIA_CopyBitmap(GSM_NokiaPictureImage, Bitmap, req, &count);
+ return GSM_WaitFor (s, req, count, 0x47, 4, ID_SetBitmap);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N6110_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+ int tmp, count;
+ GSM_Call call;
+
+ call.CallIDAvailable = true;
+ call.Status = 0;
+ smprintf(s, "Call info, ");
+ switch (msg.Buffer[3]) {
+ case 0x02:
+ smprintf(s, "Call established, waiting for answer\n");
+ call.Status = GSM_CALL_CallEstablished;
+ break;
+ case 0x03:
+ smprintf(s, "Call started\n");
+ /* no phone number in frame */
+ call.Status = GSM_CALL_CallStart;
+ break;
+ case 0x04:
+ smprintf(s, "Remote end hang up\n");
+ smprintf(s, "CC : %i\n",msg.Buffer[6]);
+ call.Status = GSM_CALL_CallRemoteEnd;
+ call.StatusCode = msg.Buffer[6];
+ break;
+ case 0x05:
+ smprintf(s, "Incoming call\n");
+ smprintf(s, "Number : \"");
+ count=msg.Buffer[6];
+ for (tmp=0; tmp <count; tmp++) smprintf(s, "%c", msg.Buffer[7+tmp]);
+ smprintf(s, "\"\nName : \"");
+ for (tmp=0; tmp<msg.Buffer[7+count]; tmp++) smprintf(s, "%c", msg.Buffer[8+count+tmp]);
+ smprintf(s, "\"\n");
+
+ call.Status = GSM_CALL_IncomingCall;
+ EncodeUnicode(call.PhoneNumber, msg.Buffer+7, msg.Buffer[6]);
+ break;
+ case 0x07:
+ smprintf(s, "Call answer initiated\n");
+ break;
+ case 0x09:
+ smprintf(s, "Call released\n");
+ call.Status = GSM_CALL_CallLocalEnd;
+ break;
+ case 0x0a:
+ smprintf(s, "Call is being released\n");
+ break;
+ case 0x23:
+ smprintf(s, "Call held\n");
+ call.Status = GSM_CALL_CallHeld;
+ break;
+ case 0x25:
+ smprintf(s, "Call resumed\n");
+ call.Status = GSM_CALL_CallResumed;
+ break;
+ case 0x27:
+ smprintf(s, "Call switched\n");
+ /* incorrect call id in frame - 6150 5.22 */
+ call.CallIDAvailable = false;
+ call.Status = GSM_CALL_CallSwitched;
+ break;
+ case 0x29:
+ smprintf(s, "Joining call to the conference (conference)\n");
+ break;
+ case 0x2A:
+ smprintf(s, "Removing call from the conference (split)\n");
+ break;
+ }
+ if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]);
+ if (Data->EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) {
+ if (call.CallIDAvailable) call.CallID = msg.Buffer[4];
+ s->User.IncomingCall(s->CurrentConfig->Device, call);
+ }
+ if (s->Phone.Data.RequestID == ID_CancelCall) {
+ if (msg.Buffer[3] == 0x09) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ /* when we canceled call and see frame about other
+ * call releasing, we don't give ERR_NONE for "our"
+ * call release command
+ */
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ if (s->Phone.Data.RequestID == ID_AnswerCall) {
+ if (msg.Buffer[3] == 0x07) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ if (s->Phone.Data.RequestID == ID_UnholdCall) {
+ if (msg.Buffer[3] == 0x25) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ if (s->Phone.Data.RequestID == ID_HoldCall) {
+ if (msg.Buffer[3] == 0x23) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ if (s->Phone.Data.RequestID == ID_ConferenceCall) {
+ if (msg.Buffer[3] == 0x29) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ if (s->Phone.Data.RequestID == ID_SplitCall) {
+ if (msg.Buffer[3] == 0x2B) {
+ if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
+ return ERR_NEEDANOTHERANSWER;
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x0a, 0x02,
+ 0x00}; /* Location */
+
+ if (sms->Folder!=0x00) return ERR_NOTSUPPORTED;
+
+ req[5]=sms->Location;
+
+ smprintf(s, "Deleting sms\n");
+ return GSM_WaitFor (s, req, 6, 0x14, 4, ID_DeleteSMSMessage);
+}
+
+static GSM_Error N6110_ReplySetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Reply for writing memory\n");
+ switch (msg.Buffer[3]) {
+ case 0x05:
+ smprintf(s, "Done OK\n");
+ return ERR_NONE;
+ case 0x06:
+ smprintf(s, "Error\n");
+ switch (msg.Buffer[4]) {
+ case 0x7d:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ case 0x90:
+ smprintf(s, "Too long name...or other error\n");
+ return ERR_NOTSUPPORTED;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ int current, Group, Name, Number;
+ unsigned char req[128] = {N6110_FRAME_HEADER, 0x04,
+ 0x00, /* memory type */
+ 0x00}; /* location */
+
+ if (entry->Location == 0) return ERR_NOTSUPPORTED;
+
+ GSM_PhonebookFindDefaultNameNumberGroup(entry, &Name, &Number, &Group);
+
+ req[4] = NOKIA_GetMemoryType(s, entry->MemoryType,N6110_MEMORY_TYPES);
+ req[5] = entry->Location;
+
+ current = 7;
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPBKUNICODE)) {
+ if (Name != -1) {
+ req[6] = UnicodeLength(entry->Entries[Name].Text);
+ memcpy(req+current,DecodeUnicodeString(entry->Entries[Name].Text),UnicodeLength(entry->Entries[Name].Text));
+ current += UnicodeLength(entry->Entries[Name].Text);
+ } else req[6] = 0;
+ } else {
+ if (Name != -1) {
+ req[6] = UnicodeLength(entry->Entries[Name].Text)*2+2;
+ memcpy(req+current,entry->Entries[Name].Text,UnicodeLength(entry->Entries[Name].Text)*2);
+ current += UnicodeLength(entry->Entries[Name].Text)*2;
+ } else req[6] = 0;
+ req[current++]=0x00;
+ req[current++]=0x00;
+ }
+
+ if (Number != -1) {
+ req[current++]=UnicodeLength(entry->Entries[Number].Text);
+ memcpy(req+current,DecodeUnicodeString(entry->Entries[Number].Text),UnicodeLength(entry->Entries[Number].Text));
+ current += UnicodeLength(entry->Entries[Number].Text);
+ } else req[current++] = 0;
+
+ /* This allow to save 14 characters name into SIM memory, when
+ * no caller group is selected. */
+ if (Group == -1) {
+ req[current++] = 0xff;
+ } else {
+ req[current++] = entry->Entries[Group].Number-1;
+ }
+
+ smprintf(s, "Writing phonebook entry\n");
+ return GSM_WaitFor (s, req, current, 0x03, 4, ID_SetMemory);
+}
+
+static GSM_Error N6110_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ GSM_MemoryEntry dwa;
+
+ dwa.Location = entry->Location;
+ dwa.MemoryType = entry->MemoryType;
+ dwa.EntriesNum = 0;
+
+ return N6110_SetMemory(s, &dwa);
+}
+
+static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+ char buffer[2000];
+ GSM_Error error;
+ int i,end,start;
+
+ smprintf(s, "Ringtone received\n");
+ switch (msg.Buffer[4]) {
+ case 0x00:
+ switch (Data->Ringtone->Format) {
+ case RING_NOTETONE:
+ memcpy(buffer,msg.Buffer,msg.Length);
+ i=7;
+ if (buffer[9]==0x4a && buffer[10]==0x3a) i=8;
+ buffer[i]=0x02;
+ error=GSM_DecodeNokiaRTTLRingtone(Data->Ringtone, buffer+i, msg.Length-i);
+ if (error!=ERR_NONE) return ERR_EMPTY;
+ return ERR_NONE;
+ case RING_NOKIABINARY:
+ i=8;
+ while (msg.Buffer[i]!=0) {
+ i++;
+ if (i>msg.Length) return ERR_EMPTY;
+ }
+ EncodeUnicode(Data->Ringtone->Name,msg.Buffer+8,i-8);
+ smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
+ /* Looking for start && end */
+ end=0;start=0;i=0;
+ while (true) {
+ if (start!=0) {
+ if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
+ end=i+2; break;
+ }
+ if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
+ end=i+2; break;
+ }
+ } else {
+ if (msg.Buffer[i]==0x02 && msg.Buffer[i+1]==0xfc && msg.Buffer[i+2]==0x09) {
+ start = i;
+ }
+ }
+ i++;
+ if (i==msg.Length-3) return ERR_EMPTY;
+ }
+ /* Copying frame */
+ memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start);
+ Data->Ringtone->NokiaBinary.Length=end-start;
+#ifdef DEBUG
+ if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length);
+#endif
+ return ERR_NONE;
+ case RING_MIDI:
+ return ERR_NOTSUPPORTED;
+ }
+ smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format);
+ break;
+ default:
+ smprintf(s, "Invalid location. Too high ?\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ GSM_Error error;
+ unsigned char req[] = {0x00, 0x01, 0x9e,
+ 0x00}; /* location */
+
+ if (PhoneRingtone) return ERR_NOTSUPPORTED;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NORING)) return ERR_NOTSUPPORTED;
+ if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
+
+ if (Ringtone->Format == 0x00) {
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) {
+ Ringtone->Format = RING_NOTETONE;
+ } else {
+ Ringtone->Format = RING_NOKIABINARY;
+ }
+ }
+
+ switch (Ringtone->Format) {
+ case RING_NOTETONE:
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
+ break;
+ case RING_NOKIABINARY:
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
+ break;
+ case RING_MIDI:
+ return ERR_NOTSUPPORTED;
+ }
+
+ error=DCT3_EnableSecurity (s, 0x01);
+ if (error!=ERR_NONE) return error;
+
+ req[3]=Ringtone->Location-1;
+ s->Phone.Data.Ringtone=Ringtone;
+ smprintf(s, "Getting (binary) ringtone\n");
+ return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone);
+}
+
+static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ *s->Phone.Data.SecurityStatus = msg.Buffer[4];
+
+#ifdef DEBUG
+ smprintf(s, "Security code status\n");
+ switch(msg.Buffer[4]) {
+ case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break;
+ case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break;
+ case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break;
+ case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break;
+ case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break;
+ case SEC_None : smprintf(s, "nothing to enter.\n"); break;
+ default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+#endif
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
+{
+ unsigned char req[4] = {N6110_FRAME_HEADER, 0x07};
+
+ s->Phone.Data.SecurityStatus=Status;
+ smprintf(s, "Getting security code status\n");
+ return GSM_WaitFor (s, req, 4, 0x08, 2, ID_GetSecurityStatus);
+}
+
+static GSM_Error N6110_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x0b:
+ smprintf(s, "Security code OK\n");
+ return ERR_NONE;
+ case 0x0c:
+ switch (msg.Buffer[4]) {
+ case 0x88:
+ smprintf(s, "Wrong code\n");
+ return ERR_SECURITYERROR;
+ case 0x8b:
+ smprintf(s, "Not required\n");
+ return ERR_NONE;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
+{
+ int len = 0;
+ unsigned char req[15] = {N6110_FRAME_HEADER, 0x0a,
+ 0x00}; /* Type of code to enter */
+
+ req[4]=Code.Type;
+
+ len = strlen(Code.Code);
+ memcpy(req+5,Code.Code,len);
+ req[5+len]=0x00;
+ req[6+len]=0x00;
+
+ smprintf(s, "Entering security code\n");
+ return GSM_WaitFor (s, req, 7+len, 0x08, 4, ID_EnterSecurityCode);
+}
+
+static GSM_Error N6110_ReplyGetSpeedDial(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x17:
+ smprintf(s, "Speed dial received\n");
+ switch (msg.Buffer[4]) {
+ case 0x02:
+ Data->SpeedDial->MemoryType = MEM_ME;
+ smprintf(s, "ME ");
+ break;
+ case 0x03:
+ Data->SpeedDial->MemoryType = MEM_SM;
+ smprintf(s, "SIM ");
+ break;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+ Data->SpeedDial->MemoryLocation = msg.Buffer[5];
+ if (msg.Buffer[5] == 0x00) Data->SpeedDial->MemoryLocation = Data->SpeedDial->Location;
+ Data->SpeedDial->MemoryNumberID = 2;
+ smprintf(s, "location %i\n",Data->SpeedDial->MemoryLocation);
+ return ERR_NONE;
+ case 0x18:
+ smprintf(s, "Error getting speed dial. Invalid location\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x16,
+ 0x01}; /* location */
+
+ req[4] = SpeedDial->Location;
+
+ s->Phone.Data.SpeedDial=SpeedDial;
+ smprintf(s, "Getting speed dial\n");
+ return GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetSpeedDial);
+}
+
+static GSM_Error N6110_ReplySendDTMF(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x40:
+ smprintf(s, "During sending DTMF\n");
+ return ERR_NONE;
+ case 0x51:
+ smprintf(s, "DTMF sent OK\n");
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_ReplyGetDisplayStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Display status received\n");
+ if (Data->RequestID == ID_GetDisplayStatus) Data->DisplayFeatures->Number=0;
+ for (i=0;i<msg.Buffer[4];i++) {
+ if (msg.Buffer[2*i+6] == 0x02) {
+#ifdef DEBUG
+ switch (msg.Buffer[2*i+5]) {
+ case 0x01: smprintf(s, "Call in progress\n"); break;
+ case 0x02: smprintf(s, "Unknown\n"); break;
+ case 0x03: smprintf(s, "Unread SMS\n"); break;
+ case 0x04: smprintf(s, "Voice call\n"); break;
+ case 0x05: smprintf(s, "Fax call active\n"); break;
+ case 0x06: smprintf(s, "Data call active\n"); break;
+ case 0x07: smprintf(s, "Keyboard lock\n"); break;
+ case 0x08: smprintf(s, "SMS storage full\n"); break;
+ }
+#endif
+ if (Data->RequestID == ID_GetDisplayStatus) {
+ switch (msg.Buffer[2*i+5]) {
+ case 0x01: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_CallActive;
+ break;
+ case 0x03: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_UnreadSMS;
+ break;
+ case 0x04: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_VoiceCall;
+ break;
+ case 0x05: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_FaxCall;
+ break;
+ case 0x06: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_DataCall;
+ break;
+ case 0x07: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_KeypadLocked;
+ break;
+ case 0x08: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_SMSMemoryFull;
+ break;
+ }
+ if (msg.Buffer[2*i+5]!=0x02) Data->DisplayFeatures->Number++;
+ }
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x51};
+
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_DISPSTATUS)) return ERR_NOTSUPPORTED;
+
+ s->Phone.Data.DisplayFeatures = features;
+ smprintf(s, "Getting display status\n");
+ return GSM_WaitFor (s, req, 4, 0x0d, 4, ID_GetDisplayStatus);
+}
+
+static GSM_Profile_PhoneTableValue Profile6110[] = {
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL1, 0x00,0x00},
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL2, 0x00,0x01},
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL3, 0x00,0x02},
+ {Profile_KeypadTone, PROFILE_KEYPAD_OFF, 0x00,0xff},
+ {Profile_Lights, PROFILE_LIGHTS_OFF, 0x01,0x00},
+ {Profile_Lights, PROFILE_LIGHTS_AUTO, 0x01,0x01},
+ {Profile_CallAlert, PROFILE_CALLALERT_RINGING, 0x02,0x01},
+ {Profile_CallAlert, PROFILE_CALLALERT_BEEPONCE, 0x02,0x02},
+ {Profile_CallAlert, PROFILE_CALLALERT_OFF, 0x02,0x04},
+ {Profile_CallAlert, PROFILE_CALLALERT_RINGONCE, 0x02,0x05},
+ {Profile_CallAlert, PROFILE_CALLALERT_ASCENDING, 0x02,0x06},
+ {Profile_CallAlert, PROFILE_CALLALERT_CALLERGROUPS,0x02,0x07},
+ /* Ringtone ID */
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL1, 0x04,0x06},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL2, 0x04,0x07},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL3, 0x04,0x08},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL4, 0x04,0x09},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL5, 0x04,0x0a},
+ {Profile_MessageTone, PROFILE_MESSAGE_NOTONE, 0x05,0x00},
+ {Profile_MessageTone, PROFILE_MESSAGE_STANDARD, 0x05,0x01},
+ {Profile_MessageTone, PROFILE_MESSAGE_SPECIAL, 0x05,0x02},
+ {Profile_MessageTone, PROFILE_MESSAGE_BEEPONCE, 0x05,0x03},
+ {Profile_MessageTone, PROFILE_MESSAGE_ASCENDING, 0x05,0x04},
+ {Profile_Vibration, PROFILE_VIBRATION_OFF, 0x06,0x00},
+ {Profile_Vibration, PROFILE_VIBRATION_ON, 0x06,0x01},
+ {Profile_WarningTone, PROFILE_WARNING_OFF, 0x07,0xff},
+ {Profile_WarningTone, PROFILE_WARNING_ON, 0x07,0x04},
+ /* Caller groups */
+ {Profile_AutoAnswer, PROFILE_AUTOANSWER_OFF, 0x09,0x00},
+ {Profile_AutoAnswer, PROFILE_AUTOANSWER_ON, 0x09,0x01},
+ {0x00, 0x00, 0x00,0x00}
+};
+
+static GSM_Profile_PhoneTableValue Profile3310[] = {
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL1, 0x00,0x00},
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL2, 0x00,0x01},
+ {Profile_KeypadTone, PROFILE_KEYPAD_LEVEL3, 0x00,0x02},
+ {Profile_KeypadTone, PROFILE_KEYPAD_OFF, 0x00,0xff},
+ {Profile_CallAlert, PROFILE_CALLALERT_RINGING, 0x01,0x01},
+ {Profile_CallAlert, PROFILE_CALLALERT_BEEPONCE, 0x01,0x02},
+ {Profile_CallAlert, PROFILE_CALLALERT_OFF, 0x01,0x04},
+ {Profile_CallAlert, PROFILE_CALLALERT_RINGONCE, 0x01,0x05},
+ {Profile_CallAlert, PROFILE_CALLALERT_ASCENDING, 0x01,0x06},
+ /* Ringtone ID */
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL1, 0x03,0x06},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL2, 0x03,0x07},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL3, 0x03,0x08},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL4, 0x03,0x09},
+ {Profile_RingtoneVolume, PROFILE_VOLUME_LEVEL5, 0x03,0x0a},
+ {Profile_MessageTone, PROFILE_MESSAGE_NOTONE, 0x04,0x00},
+ {Profile_MessageTone, PROFILE_MESSAGE_STANDARD, 0x04,0x01},
+ {Profile_MessageTone, PROFILE_MESSAGE_SPECIAL, 0x04,0x02},
+ {Profile_MessageTone, PROFILE_MESSAGE_BEEPONCE, 0x04,0x03},
+ {Profile_MessageTone, PROFILE_MESSAGE_ASCENDING, 0x04,0x04},
+ {Profile_MessageTone, PROFILE_MESSAGE_PERSONAL, 0x04,0x05},
+ {Profile_Vibration, PROFILE_VIBRATION_OFF, 0x05,0x00},
+ {Profile_Vibration, PROFILE_VIBRATION_ON, 0x05,0x01},
+ {Profile_Vibration, PROFILE_VIBRATION_FIRST, 0x05,0x02},
+ {Profile_WarningTone, PROFILE_WARNING_OFF, 0x06,0xff},
+ {Profile_WarningTone, PROFILE_WARNING_ON, 0x06,0x04},
+ {Profile_ScreenSaver, PROFILE_SAVER_OFF, 0x07,0x00},
+ {Profile_ScreenSaver, PROFILE_SAVER_ON, 0x07,0x01},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_5SEC, 0x08,0x00},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_20SEC, 0x08,0x01},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_1MIN, 0x08,0x02},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_2MIN, 0x08,0x03},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_5MIN, 0x08,0x04},
+ {Profile_ScreenSaverTime,PROFILE_SAVER_TIMEOUT_10MIN, 0x08,0x05},
+ {0x00, 0x00, 0x00,0x00}
+};
+
+static GSM_Error N6110_ReplyGetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x14:
+ smprintf(s, "Profile feature %02x with value %02x\n",msg.Buffer[6],msg.Buffer[8]);
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ switch (msg.Buffer[6]) {
+ case 0x02:
+ smprintf(s, "Ringtone ID\n");
+ Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_RingtoneID;
+ Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg.Buffer[8];
+ Data->Profile->FeaturesNumber++;
+ break;
+ case 0x09 :
+ smprintf(s, "screen saver number\n");
+ Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_ScreenSaverNumber;
+ Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg.Buffer[8] + 1;
+ Data->Profile->FeaturesNumber++;
+ break;
+ case 0x24:
+ smprintf(s, "selected profile\n");
+ if (msg.Buffer[8] + 1 == Data->Profile->Location) Data->Profile->Active = true;
+ break;
+ default:
+ NOKIA_FindFeatureValue(s, Profile3310,msg.Buffer[6],msg.Buffer[8],Data,false);
+ }
+ return ERR_NONE;
+ }
+ switch (msg.Buffer[6]) {
+ case 0x01: /* Lights */
+ if (Data->Profile->CarKitProfile) {
+ NOKIA_FindFeatureValue(s, Profile6110,msg.Buffer[6],msg.Buffer[8],Data,false);
+ }
+ break;
+ case 0x03:
+ smprintf(s, "Ringtone ID\n");
+ Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_RingtoneID;
+ Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg.Buffer[8];
+ Data->Profile->FeaturesNumber++;
+ break;
+ case 0x08: /* Caller groups */
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES51)) {
+ NOKIA_FindFeatureValue(s, Profile6110,msg.Buffer[6],msg.Buffer[8],Data,true);
+ }
+ break;
+ case 0x09: /* Autoanswer */
+ if (Data->Profile->CarKitProfile || Data->Profile->HeadSetProfile) {
+ NOKIA_FindFeatureValue(s, Profile6110,msg.Buffer[6],msg.Buffer[8],Data,false);
+ }
+ break;
+ case 0x2A:
+ smprintf(s, "selected profile\n");
+ if (msg.Buffer[8] + 1 == Data->Profile->Location) Data->Profile->Active = true;
+ break;
+ default:
+ NOKIA_FindFeatureValue(s, Profile6110,msg.Buffer[6],msg.Buffer[8],Data,false);
+ }
+ return ERR_NONE;
+ case 0x15:
+ smprintf(s, "Invalid profile location\n");
+ return ERR_INVALIDLOCATION;
+ case 0x1b:
+ Data->Profile->Name[0] = 0;
+ Data->Profile->Name[1] = 0;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ EncodeUnicode(Data->Profile->Name,msg.Buffer+10,msg.Buffer[9]);
+ } else {
+ if (msg.Length > 0x0A) {
+ CopyUnicodeString(Data->Profile->Name,msg.Buffer+10);
+ }
+ }
+ smprintf(s, "Profile name: \"%s\"\n",Data->Profile->Name);
+ Data->Profile->DefaultName = false;
+ if (msg.Buffer[9]==0x00) Data->Profile->DefaultName = true;
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
+{
+ GSM_Error error;
+ int i,j;
+ unsigned char name_req[] = {N6110_FRAME_HEADER, 0x1a, 0x00};
+ unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
+ 0x00, /* Profile location */
+ 0x00}; /* Feature number */
+
+ s->Phone.Data.Profile=Profile;
+
+ smprintf(s, "Getting profile name\n");
+ error = GSM_WaitFor (s, name_req, 5, 0x05, 4, ID_GetProfile);
+ if (error!=ERR_NONE) return error;
+ if (Profile->DefaultName) {
+ NOKIA_GetDefaultProfileName(s, Profile);
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES51)) {
+ switch(Profile->Location) {
+ case 1: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Personal"),strlen(GetMsg(s->msg,"Personal")));
+ break;
+ case 2: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Car"),strlen(GetMsg(s->msg,"Car")));
+ break;
+ case 3: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Headset"),strlen(GetMsg(s->msg,"Headset")));
+ break;
+ }
+ }
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ switch(Profile->Location) {
+ case 1: EncodeUnicode(Profile->Name,GetMsg(s->msg,"General"),strlen(GetMsg(s->msg,"General")));
+ break;
+ case 2: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Silent"),strlen(GetMsg(s->msg,"Silent")));
+ break;
+ case 3: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Discreet"),strlen(GetMsg(s->msg,"Discreet")));
+ break;
+ case 4: EncodeUnicode(Profile->Name,GetMsg(s->msg,"Loud"),strlen(GetMsg(s->msg,"Loud")));
+ break;
+ case 5: EncodeUnicode(Profile->Name,GetMsg(s->msg,"My style"),strlen(GetMsg(s->msg,"My style")));
+ break;
+ case 6: Profile->Name[0] = 0; Profile->Name[1] = 0;
+ break;
+ }
+ }
+ }
+
+ Profile->FeaturesNumber = 0;
+
+ Profile->CarKitProfile = false;
+ Profile->HeadSetProfile = false;
+ if (Profile->Location == 6) Profile->CarKitProfile = true;
+ if (Profile->Location == 7) Profile->HeadSetProfile = true;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES51)) {
+ if (Profile->Location == 2) Profile->CarKitProfile = true;
+ if (Profile->Location == 3) Profile->HeadSetProfile = true;
+ }
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ Profile->HeadSetProfile = false; //fixme
+ Profile->CarKitProfile = false;
+ }
+
+ for (i = 0x00; i <= 0x09; i++) {
+ feat_req[5] = Profile->Location - 1;
+ feat_req[6] = i;
+ smprintf(s, "Getting profile feature\n");
+ error = GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetProfile);
+ if (error!=ERR_NONE) return error;
+ }
+
+ for (i=0;i<Profile->FeaturesNumber;i++) {
+ if (Profile->FeatureID[i] == Profile_CallAlert &&
+ Profile->FeatureValue[i] != PROFILE_CALLALERT_CALLERGROUPS) {
+ for (j=0;j<5;j++) Profile->CallerGroups[j] = true;
+ }
+ }
+
+ Profile->Active = false;
+ feat_req[5] = 0;
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
+ feat_req[6] = 0x24;
+ } else {
+ feat_req[6] = 0x2A;
+ }
+ smprintf(s, "Getting profile feature\n");
+ error = GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetProfile);
+
+ return error;
+}
+
+static GSM_Error N6110_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
+{
+ int i;
+ bool found;
+ unsigned char ID,Value;
+ GSM_Error error;
+ GSM_Profile_PhoneTableValue *ProfilePhone = Profile6110;
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) ProfilePhone = Profile3310;
+
+ for (i=0;i<Profile->FeaturesNumber;i++) {
+ found = false;
+ if (ProfilePhone == Profile3310) {
+ switch (Profile->FeatureID[i]) {
+ case Profile_RingtoneID:
+ ID = 0x02;
+ Value = Profile->FeatureValue[i];
+ found = true;
+ break;
+ case Profile_ScreenSaverNumber:
+ ID = 0x09;
+ Value = Profile->FeatureValue[i];
+ found = true;
+ break;
+ default:
+ found=NOKIA_FindPhoneFeatureValue(
+ s,
+ ProfilePhone,
+ Profile->FeatureID[i],Profile->FeatureValue[i],
+ &ID,&Value);
+ }
+ }
+ if (ProfilePhone == Profile6110) {
+ switch (Profile->FeatureID[i]) {
+ case Profile_RingtoneID:
+ ID = 0x03;
+ Value = Profile->FeatureValue[i];
+ found = true;
+ break;
+ default:
+ found=NOKIA_FindPhoneFeatureValue(
+ s,
+ ProfilePhone,
+ Profile->FeatureID[i],Profile->FeatureValue[i],
+ &ID,&Value);
+ }
+ }
+ if (found) {
+ error=N6110_SetProfileFeature (s,((unsigned char)(Profile->Location-1)),ID,Value);
+ if (error!=ERR_NONE) return error;
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+ GSM_SMSMessage sms;
+
+#ifdef DEBUG
+ smprintf(s, "SMS message received\n");
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+7);
+#endif
+ if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+7);
+
+ s->User.IncomingSMS(s->CurrentConfig->Device,sms);
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N6110_ReplyAddCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Writting calendar note: ");
+ switch (msg.Buffer[4]) {
+ case 0x01:
+ smprintf(s, "OK\n");
+ return ERR_NONE;
+ case 0x73:
+ case 0x7d:
+ smprintf(s, "error\n");
+ return ERR_UNKNOWN;
+ case 0x81:
+ smprintf(s,"during editing notes in phone menu\n");
+ return ERR_INSIDEPHONEMENU;
+ default:
+ smprintf(s, "unknown ERROR %i\n",msg.Buffer[4]);
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
+{
+ bool Reminder3310 = false;
+ int Text, Time, Alarm, Phone, Recurrance, EndTime, Location, i, current;
+ unsigned char mychar1,mychar2;
+ unsigned char req[200] = {N6110_FRAME_HEADER, 0x64, 0x01, 0x10,
+ 0x00, /* Length of the rest of the frame */
+ 0x00, /* Calendar note type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x66, 0x01};
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED;
+
+ GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL52)) {
+ switch(Note->Type) {
+ case GSM_CAL_REMINDER: req[7]=0x01; break;
+ case GSM_CAL_CALL : req[7]=0x02; break;
+ case GSM_CAL_MEETING : req[7]=0x03; break;
+ case GSM_CAL_BIRTHDAY: req[7]=0x04; break;
+ case GSM_CAL_T_ATHL : req[7]=0x05; break;
+ case GSM_CAL_T_BALL : req[7]=0x06; break;
+ case GSM_CAL_T_CYCL : req[7]=0x07; break;
+ case GSM_CAL_T_BUDO : req[7]=0x08; break;
+ case GSM_CAL_T_DANC : req[7]=0x09; break;
+ case GSM_CAL_T_EXTR : req[7]=0x0a; break;
+ case GSM_CAL_T_FOOT : req[7]=0x0b; break;
+ case GSM_CAL_T_GOLF : req[7]=0x0c; break;
+ case GSM_CAL_T_GYM : req[7]=0x0d; break;
+ case GSM_CAL_T_HORS : req[7]=0x0e; break;
+ case GSM_CAL_T_HOCK : req[7]=0x0f; break;
+ case GSM_CAL_T_RACE : req[7]=0x10; break;
+ case GSM_CAL_T_RUGB : req[7]=0x11; break;
+ case GSM_CAL_T_SAIL : req[7]=0x12; break;
+ case GSM_CAL_T_STRE : req[7]=0x13; break;
+ case GSM_CAL_T_SWIM : req[7]=0x14; break;
+ case GSM_CAL_T_TENN : req[7]=0x15; break;
+ case GSM_CAL_T_TRAV : req[7]=0x16; break;
+ case GSM_CAL_T_WINT : req[7]=0x17; break;
+ default : req[7]=0x01; break;
+ }
+ } else {
+ switch(Note->Type) {
+ case GSM_CAL_CALL : req[7]=0x02; break;
+ case GSM_CAL_MEETING : req[7]=0x03; break;
+ case GSM_CAL_BIRTHDAY: req[7]=0x04; break;
+ case GSM_CAL_REMINDER:
+ default : req[7]=0x01; break;
+ }
+ }
+
+ if (Time == -1) return ERR_UNKNOWN;
+ NOKIA_EncodeDateTime(s, req+8, &Note->Entries[Time].Date);
+ req[14] = Note->Entries[Time].Date.Second;
+
+ if (Alarm != -1) {
+ NOKIA_EncodeDateTime(s, req+15, &Note->Entries[Alarm].Date);
+ req[21] = Note->Entries[Alarm].Date.Second;
+ }
+
+ current = 23;
+
+ if (Text != -1) {
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL52) ||
+ IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL82)) {
+ req[22] = UnicodeLength(Note->Entries[Text].Text)*2;
+ memcpy(req+current,Note->Entries[Text].Text,UnicodeLength(Note->Entries[Text].Text)*2);
+ current += UnicodeLength(Note->Entries[Text].Text)*2;
+ } else {
+ req[22] = UnicodeLength(Note->Entries[Text].Text);
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL33)) {
+ Reminder3310 = true;
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"3310") && s->Phone.Data.VerNum<5.11) {
+ if (Note->Type!=GSM_CAL_REMINDER) Reminder3310 = false;
+ }
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"3330") && s->Phone.Data.VerNum<=4.50) {
+ if (Note->Type!=GSM_CAL_REMINDER) Reminder3310 = false;
+ }
+ if (Reminder3310) {
+ req[22]++; /* one additional char */
+ req[current++] = 0x01; /* we use now subset 1 */
+ for (i=0;i<((int)UnicodeLength(Note->Entries[Text].Text));i++) {
+ /* Euro char */
+ if (Note->Entries[Text].Text[i*2]==0x20 && Note->Entries[Text].Text[i*2+1]==0xAC) {
+ req[current++] = 0xe2;
+ req[current++] = 0x82;
+ req[current++] = 0xac;
+ req[23] = 0x03; /* use subset 3 */
+ req[22]+=2; /* two additional chars */
+ } else if (EncodeWithUTF8Alphabet(Note->Entries[Text].Text[i*2],Note->Entries[Text].Text[i*2+1],&mychar1,&mychar2)) {
+ req[current++] = mychar1;
+ req[current++] = mychar2;
+ req[23] = 0x03; /* use subset 3 */
+ req[22]++; /* one additional char */
+ } else {
+ current+=DecodeWithUnicodeAlphabet(((wchar_t)(Note->Entries[Text].Text[i*2]*256+Note->Entries[Text].Text[i*2+1])),req+current);
+ }
+ }
+ }
+ }
+ if (!Reminder3310) {
+ memcpy(req+current,DecodeUnicodeString(Note->Entries[Text].Text),UnicodeLength(Note->Entries[Text].Text));
+ current += UnicodeLength(Note->Entries[Text].Text);
+ }
+ }
+ } else req[22] = 0x00;
+
+ if (Note->Type == GSM_CAL_CALL) {
+ if (Phone != -1) {
+ req[current++] = UnicodeLength(Note->Entries[Phone].Text);
+ memcpy(req+current,DecodeUnicodeString(Note->Entries[Phone].Text),UnicodeLength(Note->Entries[Phone].Text));
+ current += UnicodeLength(Note->Entries[Phone].Text);
+ } else req[current++] = 0x00;
+ }
+
+ req[6] = current - 8;
+
+ smprintf(s, "Writing calendar note\n");
+ return GSM_WaitFor (s, req, current, 0x13, 4, ID_SetCalendarNote);
+}
+
+static GSM_Error N6110_ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Deleting calendar note: ");
+ switch (msg.Buffer[4]) {
+ case 0x01:
+ smprintf(s, "done OK\n");
+ return ERR_NONE;
+ case 0x81:
+ smprintf(s,"during editing notes in phone menu\n");
+ return ERR_INSIDEPHONEMENU;
+ case 0x93:
+ smprintf(s, "Can't be done - too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "unknown ERROR %i\n",msg.Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+static GSM_Error N6110_DeleteCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x68,
+ 0x00}; /* Location */
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED;
+
+ req[4] = Note->Location;
+
+ smprintf(s, "Deleting calendar note\n");
+ return GSM_WaitFor (s, req, 5, 0x13, 5, ID_DeleteCalendarNote);
+}
+
+/* for example: "Euro_char" text */
+static void Decode3310Subset3(int j, GSM_Protocol_Message msg, GSM_Phone_Data *Data)
+{
+ wchar_t wc;
+ int len = 0;
+ int i;
+ bool charfound;
+ GSM_CalendarEntry *Entry = Data->Cal;
+
+ i = j;
+ while (i!=msg.Buffer[23]) {
+ EncodeWithUnicodeAlphabet(msg.Buffer+24+i,&wc);
+ charfound = false;
+ if (i!=msg.Buffer[23]-2) {
+ if (msg.Buffer[24+i] ==0xe2 && msg.Buffer[24+i+1]==0x82 &&
+ msg.Buffer[24+i+2]==0xac) {
+ wc = 0x20 * 256 + 0xac;
+ i+=2;
+ charfound = true;
+ }
+ }
+ if (i!=msg.Buffer[23]-1 && !charfound) {
+ if (msg.Buffer[24+i]>=0xc2) {
+ wc = DecodeWithUTF8Alphabet(msg.Buffer[24+i],msg.Buffer[24+i+1]);
+ i++;
+ }
+ }
+ Entry->Entries[Entry->EntriesNum].Text[len++] = (wc >> 8) & 0xff;
+ Entry->Entries[Entry->EntriesNum].Text[len++] = wc & 0xff;
+ i++;
+ }
+ Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
+ Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
+}
+
+/* For example: "a with : above" char */
+static void Decode3310Subset2(int j, GSM_Protocol_Message msg, GSM_Phone_Data *Data)
+{
+ int len = 0;
+ int i;
+ GSM_CalendarEntry *Entry = Data->Cal;
+
+ i = j;
+ while (i!=msg.Buffer[23]) {
+ Entry->Entries[Entry->EntriesNum].Text[len++] = 0x00;
+ Entry->Entries[Entry->EntriesNum].Text[len++] = msg.Buffer[24+i];
+ i++;
+ }
+ Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
+ Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
+}
+
+static GSM_Error N6110_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i = 0;
+ bool SpecialSubSet = false;
+ GSM_CalendarEntry *Entry = s->Phone.Data.Cal;
+
+ switch (msg.Buffer[4]) {
+ case 0x01:
+ smprintf(s, "Calendar note received\n");
+ switch (msg.Buffer[8]) {
+ case 0x01: Entry->Type = GSM_CAL_REMINDER; break;
+ case 0x02: Entry->Type = GSM_CAL_CALL; break;
+ case 0x03: Entry->Type = GSM_CAL_MEETING; break;
+ case 0x04: Entry->Type = GSM_CAL_BIRTHDAY; break;
+ case 0x05: Entry->Type = GSM_CAL_T_ATHL; break;
+ case 0x06: Entry->Type = GSM_CAL_T_BALL; break;
+ case 0x07: Entry->Type = GSM_CAL_T_CYCL; break;
+ case 0x08: Entry->Type = GSM_CAL_T_BUDO; break;
+ case 0x09: Entry->Type = GSM_CAL_T_DANC; break;
+ case 0x0a: Entry->Type = GSM_CAL_T_EXTR; break;
+ case 0x0b: Entry->Type = GSM_CAL_T_FOOT; break;
+ case 0x0c: Entry->Type = GSM_CAL_T_GOLF; break;
+ case 0x0d: Entry->Type = GSM_CAL_T_GYM; break;
+ case 0x0e: Entry->Type = GSM_CAL_T_HORS; break;
+ case 0x0f: Entry->Type = GSM_CAL_T_HOCK; break;
+ case 0x10: Entry->Type = GSM_CAL_T_RACE; break;
+ case 0x11: Entry->Type = GSM_CAL_T_RUGB; break;
+ case 0x12: Entry->Type = GSM_CAL_T_SAIL; break;
+ case 0x13: Entry->Type = GSM_CAL_T_STRE; break;
+ case 0x14: Entry->Type = GSM_CAL_T_SWIM; break;
+ case 0x15: Entry->Type = GSM_CAL_T_TENN; break;
+ case 0x16: Entry->Type = GSM_CAL_T_TRAV; break;
+ case 0x17: Entry->Type = GSM_CAL_T_WINT; break;
+ default :
+ smprintf(s, "Unknown note type %i\n",msg.Buffer[8]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+#ifdef DEBUG
+ switch (msg.Buffer[8]) {
+ case 0x01: smprintf(s, "Reminder\n"); break;
+ case 0x02: smprintf(s, "Call\n"); break;
+ case 0x03: smprintf(s, "Meeting\n"); break;
+ case 0x04: smprintf(s, "Birthday\n"); break;
+ }
+#endif
+ Entry->EntriesNum = 0;
+
+ NOKIA_DecodeDateTime(s, msg.Buffer+9, &Entry->Entries[0].Date);
+ smprintf(s, "Time : %02i-%02i-%04i %02i:%02i:%02i\n",
+ Entry->Entries[0].Date.Day,Entry->Entries[0].Date.Month,Entry->Entries[0].Date.Year,
+ Entry->Entries[0].Date.Hour,Entry->Entries[0].Date.Minute,Entry->Entries[0].Date.Second);
+ Entry->Entries[0].EntryType = CAL_START_DATETIME;
+ Entry->EntriesNum++;
+
+ NOKIA_DecodeDateTime(s, msg.Buffer+16, &Entry->Entries[1].Date);
+ if (Entry->Entries[1].Date.Year!=0) {
+ smprintf(s, "Alarm : %02i-%02i-%04i %02i:%02i:%02i\n",
+ Entry->Entries[1].Date.Day,Entry->Entries[1].Date.Month,Entry->Entries[1].Date.Year,
+ Entry->Entries[1].Date.Hour,Entry->Entries[1].Date.Minute,Entry->Entries[1].Date.Second);
+ Entry->Entries[1].EntryType = CAL_ALARM_DATETIME;
+ Entry->EntriesNum++;
+ } else {
+ smprintf(s, "No alarm\n");
+ }
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL52) ||
+ IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL82)) {
+ memcpy(Entry->Entries[Entry->EntriesNum].Text,msg.Buffer+24,msg.Buffer[23]);
+ Entry->Entries[Entry->EntriesNum].Text[msg.Buffer[23] ]=0;
+ Entry->Entries[Entry->EntriesNum].Text[msg.Buffer[23]+1]=0;
+ } else {
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_CAL33)) {
+ /* first char is subset for 33xx and reminders */
+ if (Entry->Type == GSM_CAL_REMINDER) {
+ i=1;
+ smprintf(s, "Subset %i in reminder note !\n",msg.Buffer[24]);
+ }
+ SpecialSubSet = true;
+ switch (msg.Buffer[24]) {
+ case 2 : Decode3310Subset2(i,msg,&s->Phone.Data); break;
+ case 3 : Decode3310Subset3(i,msg,&s->Phone.Data); break;
+ default : SpecialSubSet = false; break;
+ }
+ }
+ if (!SpecialSubSet) {
+ N6110_EncodeUnicode(s,Entry->Entries[Entry->EntriesNum].Text,msg.Buffer+24+i,msg.Buffer[23]-i);
+ }
+ }
+ smprintf(s, "Text \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
+ if (msg.Buffer[23] != 0x00) {
+ Entry->Entries[Entry->EntriesNum].EntryType = CAL_TEXT;
+ Entry->EntriesNum++;
+ }
+
+ if (Entry->Type == GSM_CAL_CALL) {
+ EncodeUnicode(Entry->Entries[Entry->EntriesNum].Text,msg.Buffer+24+msg.Buffer[23]+1,msg.Buffer[24+msg.Buffer[23]]);
+ smprintf(s, "Phone : \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
+ if (msg.Buffer[24+msg.Buffer[23]] != 0x00) {
+ Entry->Entries[Entry->EntriesNum].EntryType = CAL_PHONE;
+ Entry->EntriesNum++;
+ }
+ }
+ return ERR_NONE;
+ case 0x93:
+ smprintf(s, "Can't get calendar note - too high location?\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
+{
+ int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
+ GSM_Error error;
+ GSM_DateTime date_time;
+ GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x66,
+ 0x00}; /* Location */
+
+ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED;
+
+ if (start) {
+ Priv->LastCalendarPos = 1;
+ } else {
+ Priv->LastCalendarPos++;
+ }
+
+ Note->Location = Priv->LastCalendarPos;
+ req[4] = Priv->LastCalendarPos;
+
+ s->Phone.Data.Cal=Note;
+ smprintf(s, "Getting calendar note\n");
+ error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote);
+
+ GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
+ /* 2090 year is set for example in 3310 */
+ if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) {
+ error=N6110_GetDateTime(s, &date_time);
+ if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year;
+ }
+ return error;
+}
+
+GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned char buffer[2000],buffer2[4000];
+ int tmp;
+
+ tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer);
+ msg.Buffer[tmp] = 0;
+
+ smprintf(s, "USSD reply: \"%s\"\n",buffer);
+
+ if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
+ EncodeUnicode(buffer2,buffer,strlen(buffer));
+ s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
+ }
+
+ return ERR_NONE;
+}
+
+GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
+{
+ GSM_Error error;
+ unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01,
+ 0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8,
+ 0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15,
+ 0x63, 0x80};
+
+ if (!all) {
+ smprintf(s, "Answering call part 1\n");
+ error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall);
+ if (error != ERR_NONE) return error;
+ return DCT3DCT4_AnswerCall(s,ID);
+ }
+
+ return DCT3_AnswerAllCalls(s);
+}
+
+static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
+{
+ unsigned int pos = 4;
+ unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
+ 0x0c}; /* Length of number */
+
+ if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber);
+
+ req[pos++] = strlen(number);
+ memcpy(req+pos,number,strlen(number));
+ pos += strlen(number);
+ req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
+ req[pos++] = 0x01;
+ req[pos++] = 0x01;
+ req[pos++] = 0x05;
+ req[pos++] = 0x81;
+ switch (ShowNumber) {
+ case GSM_CALL_HideNumber:
+ req[pos++] = 0x02;
+ break;
+ case GSM_CALL_ShowNumber:
+ req[pos++] = 0x03;
+ break;
+ case GSM_CALL_DefaultNumberPresence:
+ req[pos++] = 0x01;
+ break;
+ }
+ req[pos++] = 0x00;
+ req[pos++] = 0x00;
+
+ smprintf(s, "Making voice call\n");
+ return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
+}
+
+GSM_Error N6110_UnholdCall(GSM_StateMachine *s, int ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x24, 0x00, 0x02};
+
+ req[4] = (unsigned char)ID;
+ s->Phone.Data.CallID = ID;
+
+ smprintf(s, "Unholding call\n");
+ return GSM_WaitFor (s, req, 6, 0x01, 4, ID_UnholdCall);
+}
+
+GSM_Error N6110_HoldCall(GSM_StateMachine *s, int ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x22, 0x00, 0x00};
+
+ req[4] = (unsigned char)ID;
+ s->Phone.Data.CallID = ID;
+
+ smprintf(s, "Unholding call\n");
+ return GSM_WaitFor (s, req, 6, 0x01, 4, ID_HoldCall);
+}
+
+/* Joining selected call to current (and making conference) */
+GSM_Error N6110_ConferenceCall(GSM_StateMachine *s, int ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x28, 0x00, 0x01};
+
+ req[4] = (unsigned char)ID;
+ s->Phone.Data.CallID = ID;
+
+ smprintf(s, "Conference call\n");
+ return GSM_WaitFor (s, req, 6, 0x01, 4, ID_ConferenceCall);
+}
+
+/* Removing selected call from conference and making private call with it
+ * (conference call is on hold) */
+GSM_Error N6110_SplitCall(GSM_StateMachine *s, int ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x2A, 0x00, 0x01};
+
+ req[4] = (unsigned char)ID;
+ s->Phone.Data.CallID = ID;
+
+ smprintf(s, "Split call\n");
+ return GSM_WaitFor (s, req, 6, 0x01, 4, ID_SplitCall);
+}
+
+/* This probably need more investigation */
+GSM_Error N6110_SwitchCall(GSM_StateMachine *s, int ID, bool next)
+{
+// unsigned char req[] = {N6110_FRAME_HEADER, 0x20}; calls info
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x26, 0x00};
+
+ s->Phone.Data.CallID = ID;
+
+ if (next) {
+ smprintf(s, "Switch call\n");
+ return GSM_WaitFor (s, req, 4, 0x01, 4, ID_SwitchCall);
+ } else {
+ req[4] = (unsigned char)ID;
+
+ smprintf(s, "Switch call\n");
+ return GSM_WaitFor (s, req, 5, 0x01, 4, ID_SwitchCall);
+ }
+}
+
+/* This probably need more investigation */
+GSM_Error N6110_TransferCall(GSM_StateMachine *s, int ID, bool next)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x2C, 0x00};
+
+ s->Phone.Data.CallID = ID;
+
+ if (next) {
+ smprintf(s, "Transfer call\n");
+ return GSM_WaitFor (s, req, 4, 0x01, 4, ID_TransferCall);
+ } else {
+ req[4] = (unsigned char)ID;
+
+ smprintf(s, "Transfer call\n");
+ return GSM_WaitFor (s, req, 5, 0x01, 4, ID_TransferCall);
+ }
+}
+
+static GSM_Reply_Function N6110ReplyFunctions[] = {
+ {N6110_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_HoldCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_UnholdCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_ConferenceCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_IncomingFrame },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_SplitCall },
+ {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_IncomingFrame },
+ {N6110_ReplySendDTMF, "\x01",0x03,0x40,ID_SendDTMF },
+ {NoneReply, "\x01",0x03,0x40,ID_DialVoice },
+ {NoneReply, "\x01",0x03,0x40,ID_IncomingFrame },
+ {NoneReply, "\x01",0x03,0x43,ID_AnswerCall },
+ {N6110_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
+
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
+ {N6110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
+#ifdef GSM_ENABLE_CELLBROADCAST
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
+ {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
+#endif
+ {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
+
+ {N6110_ReplyGetMemory, "\x03",0x03,0x02,ID_GetMemory },
+ {N6110_ReplyGetMemory, "\x03",0x03,0x03,ID_GetMemory },
+ {N6110_ReplySetMemory, "\x03",0x03,0x05,ID_SetMemory },
+ {N6110_ReplySetMemory, "\x03",0x03,0x06,ID_SetMemory },
+ {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x08,ID_GetMemoryStatus },
+ {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x09,ID_GetMemoryStatus },
+ {N6110_ReplyGetCallerLogo, "\x03",0x03,0x11,ID_GetBitmap },
+ {N6110_ReplyGetCallerLogo, "\x03",0x03,0x12,ID_GetBitmap },
+ {N6110_ReplySetCallerLogo, "\x03",0x03,0x14,ID_SetBitmap },
+ {N6110_ReplySetCallerLogo, "\x03",0x03,0x15,ID_SetBitmap },
+ {N6110_ReplyGetSpeedDial, "\x03",0x03,0x17,ID_GetSpeedDial },
+ {N6110_ReplyGetSpeedDial, "\x03",0x03,0x18,ID_GetSpeedDial },
+ /* 0x1A, 0x1B - reply set speed dial */
+
+ {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetSignalQuality },
+ {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetBatteryCharge },
+
+ {N6110_ReplySetProfileFeature, "\x05",0x03,0x11,ID_SetProfile },
+ {N6110_ReplySetProfileFeature, "\x05",0x03,0x12,ID_SetProfile },
+ {N6110_ReplyGetProfileFeature, "\x05",0x03,0x14,ID_GetProfile },
+ {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x14,ID_GetLanguage },
+ {N6110_ReplyGetProfileFeature, "\x05",0x03,0x15,ID_GetProfile },
+ {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x15,ID_GetLanguage },
+ {N6110_ReplyGetStartup, "\x05",0x03,0x17,ID_GetBitmap },
+ {N6110_ReplySetStartup, "\x05",0x03,0x19,ID_SetBitmap },
+ {N6110_ReplyGetProfileFeature, "\x05",0x03,0x1b,ID_GetProfile },
+ {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
+ {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
+ {N6110_ReplyGetOpLogo, "\x05",0x03,0x34,ID_GetBitmap },
+ {N6110_ReplySetRingtone, "\x05",0x03,0x37,ID_SetRingtone },
+ {N6110_ReplySetRingtone, "\x05",0x03,0x38,ID_SetRingtone },
+
+ {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
+ {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x03,ID_Divert },
+ {N6110_ReplyUSSDInfo, "\x06",0x03,0x05,ID_IncomingFrame },
+ {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },//incoming call divert info
+
+ {N6110_ReplyGetSecurityStatus, "\x08",0x03,0x08,ID_GetSecurityStatus },
+ {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0b,ID_EnterSecurityCode },
+ {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0c,ID_EnterSecurityCode },
+
+ {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
+ {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
+
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
+
+ {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_GetDisplayStatus },
+ {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_IncomingFrame },
+
+ {DCT3_ReplySetDateTime, "\x11",0x03,0x61,ID_SetDateTime },
+ {DCT3_ReplyGetDateTime, "\x11",0x03,0x63,ID_GetDateTime },
+ {DCT3_ReplySetAlarm, "\x11",0x03,0x6C,ID_SetAlarm },
+ {DCT3_ReplyGetAlarm, "\x11",0x03,0x6E,ID_GetAlarm },
+
+ {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_SetCalendarNote },
+ {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_IncomingFrame },
+ {N6110_ReplyGetNextCalendar, "\x13",0x03,0x67,ID_GetCalendarNote },
+ {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_DeleteCalendarNote },
+ {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_IncomingFrame },
+
+ {N6110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
+ {N6110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
+ {N6110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
+ {N6110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
+ {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
+ {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
+ {N6110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
+ {N6110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
+
+ {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
+ {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
+ {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
+ {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
+ {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
+ {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
+ {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
+ {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
+ {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
+ {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
+ {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
+ {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
+
+ {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
+ {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
+ {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
+ {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
+ {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
+ {N6110_ReplyGetRingtone, "\x40",0x02,0x9E,ID_GetRingtone },
+ {N6110_ReplySetBinRingtone, "\x40",0x02,0xA0,ID_SetRingtone },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth},
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
+
+ {N6110_ReplyGetSetPicture, "\x47",0x03,0x02,ID_GetBitmap },
+ {N6110_ReplyGetSetPicture, "\x47",0x03,0x04,ID_SetBitmap },
+ {N6110_ReplyGetSetPicture, "\x47",0x03,0x05,ID_SetBitmap },
+ {N6110_ReplyGetSetPicture, "\x47",0x03,0x06,ID_GetBitmap },
+
+#ifndef ENABLE_LGPL
+ {N6110_ReplyGetMagicBytes, "\x64",0x00,0x00,ID_MakeAuthentication },
+#endif
+
+ {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
+ {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
+ {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
+ {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+GSM_Phone_Functions N6110Phone = {
+ "2100|3210|3310|3330|3390|3410|3610|5110|5110i|5130|5190|5210|5510|6110|6130|6150|6190|8210|8250|8290|8850|8855|8890",
+ N6110ReplyFunctions,
+ N6110_Initialise,
+ PHONE_Terminate,
+ GSM_DispatchMessage,
+ N6110_ShowStartInfo,
+ NOKIA_GetManufacturer,
+ DCT3DCT4_GetModel,
+ DCT3DCT4_GetFirmware,
+ DCT3_GetIMEI,
+ DCT3_GetOriginalIMEI,
+ DCT3_GetManufactureMonth,
+ DCT3_GetProductCode,
+ DCT3_GetHardware,
+ DCT3_GetPPM,
+ NOTSUPPORTED, /* GetSIMIMSI */
+ N6110_GetDateTime,
+ N6110_SetDateTime,
+ N6110_GetAlarm,
+ N6110_SetAlarm,
+ NOTSUPPORTED, /* GetLocale */
+ NOTSUPPORTED, /* SetLocale */
+ DCT3_PressKey,
+ DCT3_Reset,
+ N61_71_ResetPhoneSettings,
+ N6110_EnterSecurityCode,
+ N6110_GetSecurityStatus,
+ N6110_GetDisplayStatus,
+ NOTIMPLEMENTED, /* SetAutoNetworkLogin */
+ N6110_GetBatteryCharge,
+ N6110_GetSignalQuality,
+ DCT3_GetNetworkInfo,
+ NOTSUPPORTED, /* GetCategory */
+ NOTSUPPORTED, /* AddCategory */
+ NOTSUPPORTED, /* GetCategoryStatus */
+ N6110_GetMemoryStatus,
+ N6110_GetMemory,
+ NOTIMPLEMENTED, /* GetNextMemory */
+ N6110_SetMemory,
+ NOTIMPLEMENTED, /* AddMemory */
+ N6110_DeleteMemory,
+ NOTIMPLEMENTED, /* DeleteAllMemory */
+ N6110_GetSpeedDial,
+ NOTIMPLEMENTED, /* SetSpeedDial */
+ DCT3_GetSMSC,
+ DCT3_SetSMSC,
+ DCT3_GetSMSStatus,
+ N6110_GetSMSMessage,
+ N6110_GetNextSMSMessage,
+ N6110_SetSMS,
+ N6110_AddSMS,
+ N6110_DeleteSMSMessage,
+ DCT3_SendSMSMessage,
+ NOTSUPPORTED, /* SendSavedSMS */
+ NOKIA_SetIncomingSMS,
+ DCT3_SetIncomingCB,
+ PHONE_GetSMSFolders,
+ NOTSUPPORTED, /* AddSMSFolder */
+ NOTSUPPORTED, /* DeleteSMSFolder */
+ N6110_DialVoice,
+ N6110_AnswerCall,
+ DCT3_CancelCall,
+ N6110_HoldCall,
+ N6110_UnholdCall,
+ N6110_ConferenceCall,
+ N6110_SplitCall,
+ N6110_TransferCall,
+ N6110_SwitchCall,
+ DCT3DCT4_GetCallDivert,
+ DCT3DCT4_SetCallDivert,
+ DCT3DCT4_CancelAllDiverts,
+ NOKIA_SetIncomingCall,
+ NOKIA_SetIncomingUSSD,
+ DCT3DCT4_SendDTMF,
+ N6110_GetRingtone,
+ N6110_SetRingtone,
+ NOTSUPPORTED, /* GetRingtonesInfo */
+ NOTSUPPORTED, /* DeleteUserRingtones */
+ DCT3_PlayTone,
+ DCT3_GetWAPBookmark,
+ DCT3_SetWAPBookmark,
+ DCT3_DeleteWAPBookmark,
+ DCT3_GetWAPSettings,
+ DCT3_SetWAPSettings,
+ NOTSUPPORTED, /* GetMMSSettings */
+ NOTSUPPORTED, /* SetMMSSettings */
+ NOTSUPPORTED, /* GetSyncMLSettings */
+ NOTSUPPORTED, /* SetSyncMLSettings */
+ NOTSUPPORTED, /* GetChatSettings */
+ NOTSUPPORTED, /* SetChatSettings */
+ N6110_GetBitmap,
+ N6110_SetBitmap,
+ NOTSUPPORTED, /* GetToDoStatus */
+ NOTSUPPORTED, /* GetToDo */
+ NOTSUPPORTED, /* GetNextToDo */
+ NOTSUPPORTED, /* SetToDo */
+ NOTSUPPORTED, /* AddToDo */
+ NOTSUPPORTED, /* DeleteToDo */
+ NOTSUPPORTED, /* DeleteAllToDo */
+ NOTIMPLEMENTED, /* GetCalendarStatus */
+ NOTIMPLEMENTED, /* GetCalendar */
+ N6110_GetNextCalendarNote,
+ NOTIMPLEMENTED, /* SetCalendar */
+ N6110_AddCalendarNote,
+ N6110_DeleteCalendarNote,
+ NOTIMPLEMENTED, /* DeleteAllCalendar */
+ NOTSUPPORTED, /* GetCalendarSettings */
+ NOTSUPPORTED, /* SetCalendarSettings */
+ NOTSUPPORTED, /* GetNote */
+ N6110_GetProfile,
+ N6110_SetProfile,
+ NOTSUPPORTED, /* GetFMStation */
+ NOTSUPPORTED, /* SetFMStation */
+ NOTSUPPORTED, /* ClearFMStations */
+ NOTSUPPORTED, /* GetNextFileFolder */
+ NOTSUPPORTED, /* GetFilePart */
+ NOTSUPPORTED, /* AddFile */
+ NOTSUPPORTED, /* GetFileSystemStatus */
+ NOTSUPPORTED, /* DeleteFile */
+ NOTSUPPORTED, /* AddFolder */
+ NOTSUPPORTED, /* GetGPRSAccessPoint */
+ NOTSUPPORTED /* SetGPRSAccessPoint */
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.h b/gammu/emb/common/phone/nokia/dct3/n6110.h
new file mode 100644
index 0000000..d243766
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.h
@@ -0,0 +1,45 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#ifndef n6110_h
+#define n6110_h
+
+#include "../../../config.h"
+#include "../../../service/sms/gsmsms.h"
+#include "dct3comm.h"
+
+typedef struct {
+#ifndef ENABLE_LGPL
+ unsigned char MagicBytes[4];
+#endif
+ int LastCalendarPos;
+ DCT3_WAPSettings_Locations WAPLocations;
+
+ GSM_SMSMemoryStatus LastSMSStatus;
+ int LastSMSRead;
+
+ int PhoneLanguage;
+} GSM_Phone_N6110Data;
+
+typedef enum {
+ N6110_Auto = 1,
+ N6110_Europe
+} N6110_Language;
+
+#ifndef GSM_USED_MBUS2
+# define GSM_USED_MBUS2
+#endif
+#ifndef GSM_USED_FBUS2
+# define GSM_USED_FBUS2
+#endif
+#ifndef GSM_USED_FBUS2IRDA
+# define GSM_USED_FBUS2IRDA
+#endif
+#ifndef GSM_USED_IRDAPHONET
+# define GSM_USED_IRDAPHONET
+#endif
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
new file mode 100644
index 0000000..5a02c9c
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -0,0 +1,1724 @@
+/* (c) 2001-2004 by Marcin Wiacek */
+/* based on some work from Markus Plail and Gnokii */
+
+#include "../../../gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA7110
+
+#include <string.h>
+#include <time.h>
+
+#include "../../../misc/coding/coding.h"
+#include "../../../gsmcomon.h"
+#include "../../../service/gsmlogo.h"
+#include "../../pfunc.h"
+#include "../nfunc.h"
+#include "../nfuncold.h"
+#include "n7110.h"
+#include "dct3func.h"
+
+static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ return DCT3_GetAlarm(s, alarm, 0x19);
+}
+
+static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ return DCT3_SetAlarm(s, alarm, 0x19);
+}
+
+static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Phonebook entry received\n");
+ switch (msg.Buffer[6]) {
+ case 0x0f:
+ return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
+ default:
+ return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false);
+ }
+ return ERR_UNKNOWN;
+}
+
+static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
+ 0x02, /* memory type */
+ 0x05,
+ 0x00, 0x00, /* location */
+ 0x00, 0x00};
+
+ req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
+ if (req[9]==0xff) return ERR_NOTSUPPORTED;
+
+ if (entry->Location==0x00) return ERR_INVALIDLOCATION;
+
+ req[10] = entry->Location / 256;
+ req[11] = entry->Location % 256;
+
+ s->Phone.Data.Memory=entry;
+ smprintf(s, "Getting phonebook entry\n");
+ return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory);
+}
+
+static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Memory status received\n");
+ /* Quess ;-)) */
+ if (msg.Buffer[10]==0x10) {
+ Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15];
+ } else {
+ Data->MemoryStatus->MemoryFree = msg.Buffer[18];
+ }
+ smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree);
+ Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17];
+ smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed);
+ Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
+ smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree);
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
+ 0x05}; /* Memory type */
+
+ req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
+ if (req[5]==0xff) return ERR_NOTSUPPORTED;
+
+ s->Phone.Data.MemoryStatus=Status;
+ smprintf(s, "Getting memory status\n");
+ return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus);
+}
+
+static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
+{
+ int ifolderid;
+
+ /* simulate flat SMS memory */
+ if (sms->Folder==0x00) {
+ ifolderid = sms->Location / PHONE_MAXSMSINFOLDER;
+ *folderid = (ifolderid + 1) * 0x08;
+ *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER;
+ } else {
+ *folderid = sms->Folder * 0x08;
+ *location = sms->Location;
+ }
+ smprintf(s, "SMS folder %i & location %i -> 7110 folder %i & location %i\n",
+ sms->Folder,sms->Location,*folderid,*location);
+}
+
+static void N7110_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
+{
+ sms->Folder = 0;
+ sms->Location = (folderid / 0x08 - 1) * PHONE_MAXSMSINFOLDER + location;
+ smprintf(s, "7110 folder %i & location %i -> SMS folder %i & location %i\n",
+ folderid,location,sms->Folder,sms->Location);
+}
+
+static GSM_Error N7110_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int j,current=5;
+ unsigned char buffer[200];
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x7B:
+ smprintf(s, "Names for SMS folders received\n");
+ Data->SMSFolders->Number=msg.Buffer[4];
+ for (j=0;j<msg.Buffer[4];j++) {
+ smprintf(s, "Folder index: %02x",msg.Buffer[current]);
+ current++;
+ smprintf(s, ", folder name: \"");
+ CopyUnicodeString(buffer,msg.Buffer+current);
+ if ((UnicodeLength(buffer))>GSM_MAX_SMS_FOLDER_NAME_LEN) {
+ smprintf(s, "Too long text\n");
+ return ERR_UNKNOWNRESPONSE;
+ }
+ CopyUnicodeString(Data->SMSFolders->Folder[j].Name,buffer);
+ smprintf(s, "%s\"\n",DecodeUnicodeString(buffer));
+ current=current+2+UnicodeLength(buffer)*2;
+ Data->SMSFolders->Folder[j].InboxFolder = false;
+ if (j==0) Data->SMSFolders->Folder[j].InboxFolder = true;
+ Data->SMSFolders->Folder[j].Memory = MEM_ME;
+ if (j==0 || j==1) Data->SMSFolders->Folder[j].InboxFolder = MEM_MT;
+ }
+ return ERR_NONE;
+ case 0x7C:
+ smprintf(s, "Security error ? No PIN ?\n");
+ return ERR_SECURITYERROR;
+ case 0xCA:
+ smprintf(s, "Wait a moment. Phone is during power on and busy now\n");
+ return ERR_SECURITYERROR;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x7A, 0x00, 0x00};
+
+ s->Phone.Data.SMSFolders=folders;
+ smprintf(s, "Getting SMS folders\n");
+ return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders);
+}
+
+static GSM_Error N7110_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+
+ smprintf(s, "SMS folder status received\n");
+ Priv->LastSMSFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
+ smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number);
+ smprintf(s, "Locations: ");
+ for (i=0;i<Priv->LastSMSFolder.Number;i++) {
+ Priv->LastSMSFolder.Location[i]=msg.Buffer[6+(i*2)]*256+msg.Buffer[(i*2)+7];
+ if (Priv->LastSMSFolder.Location[i] > PHONE_MAXSMSINFOLDER) {
+ smprintf(s, "Increase PHONE_MAXSMSINFOLDER\n");
+ return ERR_UNKNOWNRESPONSE;
+ }
+ smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]);
+ }
+ smprintf(s, "\n");
+ NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder);
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_PrivGetSMSFolderStatus(GSM_StateMachine *s, int folderid)
+{
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x6b,
+ 0x08, /* folderID */
+ 0x0F, 0x01};
+
+ req[4] = folderid;
+
+ smprintf(s, "Getting SMS folder status\n");
+ return GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetSMSFolderStatus);
+}
+
+static GSM_Error N7110_GetSMSFolderStatus(GSM_StateMachine *s, int folderid)
+{
+ GSM_Error error;
+ int i;
+ GSM_NOKIASMSFolder folder;
+
+ error = N7110_PrivGetSMSFolderStatus(s,folderid);
+ /* 0x08 contais read Inbox, 0xf8 unread Inbox.
+ * we want all msg from Inbox, so read both 0x08 and 0xf8 */
+ if (folderid==0x08 && error==ERR_NONE) {
+ folder=s->Phone.Data.Priv.N7110.LastSMSFolder;
+ error = N7110_PrivGetSMSFolderStatus(s,0xf8);
+ if (error==ERR_NONE) {
+ for (i=0;i<folder.Number;i++) {
+ s->Phone.Data.Priv.N7110.LastSMSFolder.Location[s->Phone.Data.Priv.N7110.LastSMSFolder.Number++]=folder.Location[i];
+ }
+ }
+ }
+ return error;
+}
+
+static GSM_SMSMessageLayout N7110_SMSTemplate = {
+ 36 /* SMS Text */, 17 /* Phone number */,
+ 255 /* SMSC Number */, 15 /* TPDCS */,
+ 255 /* SendingDateTime */, 255 /* SMSCDateTime */,
+ 255 /* TPStatus */, 16 /* TPUDL */,
+ 255 /* TPVP */, 12 /* firstbyte */,
+ 13 /* TPMR */, 255 /* TPPID?? */};
+
+static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+ int Width, Height;
+ unsigned char output[500], output2[500];
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch(msg.Buffer[3]) {
+ case 0x08:
+ switch (msg.Buffer[8]) {
+ case 0x00:
+ case 0x01:
+ smprintf(s, "SMS message\n");
+ if (Data->RequestID == ID_GetSMSMessage) {
+ Data->GetSMSMessage->Number=1;
+ NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
+ DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+9);
+ return ERR_NONE;
+ }
+ case 0x02:
+ smprintf(s, "SMS template\n");
+ if (Data->RequestID == ID_GetSMSMessage) {
+ Data->GetSMSMessage->Number=1;
+ NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
+ Data->GetSMSMessage->SMS[0].PDU=SMS_Submit;
+ GSM_DecodeSMSFrame(&Data->GetSMSMessage->SMS[0],msg.Buffer+9,N7110_SMSTemplate);
+ return ERR_NONE;
+ }
+ case 0x07:
+ smprintf(s, "Picture Image\n");
+ switch (Data->RequestID) {
+ case ID_GetBitmap:
+ PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
+ Data->Bitmap->BitmapWidth = Width;
+ Data->Bitmap->BitmapHeight = Height;
+ PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 51, Data->Bitmap);
+ GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender,msg.Buffer+22,true);
+#ifdef DEBUG
+ GSM_UnpackSemiOctetNumber(output,msg.Buffer+9,true);
+ smprintf(s, "SMSC : %s\n",DecodeUnicodeString(output));
+#endif
+ Data->Bitmap->Text[0] = 0;
+ Data->Bitmap->Text[1] = 0;
+ if (msg.Length!=304) {
+ GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output);
+ DecodeDefault(Data->Bitmap->Text, output, msg.Length - 304, true, NULL);
+ }
+ return ERR_NONE;
+ case ID_GetSMSMessage:
+ Data->GetSMSMessage->Number = 0;
+ i = 0;
+ output[i++] = 0x30; /* Smart Messaging 3.0 */
+ output[i++] = SM30_OTA;
+ output[i++] = 0x01; /* Length */
+ output[i++] = 0x00; /* Length */
+ output[i++] = 0x00;
+ PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
+ output[i++] = Width;
+ output[i++] = Height;
+ output[i++] = 0x01;
+ memcpy(output+i,msg.Buffer+51,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0));
+ i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0);
+ if (msg.Length!=304) {
+ output[i++] = SM30_UNICODETEXT;
+ output[i++] = 0;
+ output[i++] = 0; /* Length - later changed */
+ GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output2);
+ DecodeDefault(output+i, output2, msg.Length - 304, true, NULL);
+ output[i - 1] = UnicodeLength(output+i) * 2;
+ i = i + output[i-1];
+ }
+ GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0);
+ for (i=0;i<3;i++) {
+ Data->GetSMSMessage->SMS[i].Number[0]=0;
+ Data->GetSMSMessage->SMS[i].Number[1]=0;
+ }
+ return ERR_NONE;
+ default:
+ smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
+ return ERR_UNKNOWNRESPONSE;
+ }
+ default:
+ smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
+ }
+ break;
+ case 0x09:
+ switch (msg.Buffer[4]) {
+ case 0x02:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ case 0x07:
+ smprintf(s, "Empty\n");
+ return ERR_EMPTY;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ case 0x6F:
+ smprintf(s, "SMS message info received\n");
+ if (msg.Length == 43) {
+ Data->GetSMSMessage->SMS[0].Name[0] = 0;
+ Data->GetSMSMessage->SMS[0].Name[1] = 0;
+ } else {
+ CopyUnicodeString(Data->GetSMSMessage->SMS[0].Name,msg.Buffer+43);
+ }
+ smprintf(s, "Name: \"%s\"\n",DecodeUnicodeString(Data->GetSMSMessage->SMS[0].Name));
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_PrivGetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
+{
+ GSM_Error error;
+ unsigned char folderid;
+ int location;
+ int i;
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
+ 0x08, /* folder ID */
+ 0x00, 0x05, /* location */
+ 0x01, 0x65, 0x01};
+ unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x6E,
+ 0x08, /* folder ID */
+ 0x00, 0x05}; /* location */
+
+ N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
+
+ req[4]=folderid;
+ req[5]=location / 256;
+ req[6]=location;
+
+ s->Phone.Data.GetSMSMessage=sms;
+ smprintf(s, "Getting sms\n");
+ error=GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSMessage);
+ if (error==ERR_NONE) {
+ NameReq[4] = folderid;
+ NameReq[5] = location / 256;
+ NameReq[6] = location;
+ smprintf(s, "Getting sms info\n");
+ error=GSM_WaitFor (s, NameReq, 7, 0x14, 4, ID_GetSMSMessage);
+ if (error != ERR_NONE) return error;
+ for (i=0;i<sms->Number;i++) {
+ N7110_SetSMSLocation(s, &sms->SMS[i], folderid, location);
+ sms->SMS[i].Folder = folderid/0x08;
+ sms->SMS[i].InboxFolder = true;
+ if (folderid/0x08 != 0x01) sms->SMS[i].InboxFolder = false;
+ CopyUnicodeString(sms->SMS[i].Name,sms->SMS[0].Name);
+ sms->SMS[i].Memory = MEM_ME;
+ if (folderid/0x08 == 0x01 || folderid/0x08 == 0x02) {
+ sms->SMS[i].Memory = MEM_MT;
+ if (folderid/0x08 == 0x01) { /* Inbox */
+ if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_ME;
+ if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_ME;
+ if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_SM;
+ if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_SM;
+ }
+ if (folderid/0x08 == 0x02) { /* Outbox */
+ if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_SM;
+ if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_SM;
+ if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_ME;
+ if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_ME;
+ }
+ }
+ }
+ }
+ return error;
+}
+
+static GSM_Error N7110_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
+{
+ GSM_Error error;
+ unsigned char folderid;
+ int location;
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+ int i;
+ bool found = false;
+
+ N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
+ error=N7110_GetSMSFolderStatus(s, folderid);
+ if (error!=ERR_NONE) return error;
+ for (i=0;i<Priv->LastSMSFolder.Number;i++) {
+ if (Priv->LastSMSFolder.Location[i]==location) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) return ERR_EMPTY;
+ return N7110_PrivGetSMSMessage(s,sms);
+}
+
+static GSM_Error N7110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
+{
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+ unsigned char folderid;
+ int location;
+ GSM_Error error;
+ int i;
+ bool findnextfolder = false;
+
+ if (start) {
+ folderid=0x00;
+ findnextfolder=true;
+ error=N7110_GetSMSFolders(s,&Priv->LastSMSFolders);
+ if (error!=ERR_NONE) return error;
+ } else {
+ N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
+ for (i=0;i<Priv->LastSMSFolder.Number;i++) {
+ if (Priv->LastSMSFolder.Location[i]==location) break;
+ }
+ /* Is this last location in this folder ? */
+ if (i==Priv->LastSMSFolder.Number-1) {
+ findnextfolder=true;
+ } else {
+ location=Priv->LastSMSFolder.Location[i+1];
+ }
+ }
+ if (findnextfolder) {
+ Priv->LastSMSFolder.Number=0;
+ while (Priv->LastSMSFolder.Number==0) {
+ folderid=folderid+0x08;
+ /* Too high folder number */
+ if ((folderid/0x08)>Priv->LastSMSFolders.Number) return ERR_EMPTY;
+ /* Get next folder status */
+ error=N7110_GetSMSFolderStatus(s, folderid);
+ if (error!=ERR_NONE) return error;
+ /* First location from this folder */
+ location=Priv->LastSMSFolder.Location[0];
+ }
+ }
+ N7110_SetSMSLocation(s, &sms->SMS[0], folderid, location);
+
+ return N7110_PrivGetSMSMessage(s, sms);
+}
+
+static int N7110_ReturnBinaryRingtoneLocation(char *model)
+{
+ if (strcmp(model,"NSE-5") == 0) return 0x72; /* first 0x72 - 7110 */
+ if (strcmp(model,"NPE-3") == 0) return 0x89; /* first 0x89 - 6210 */
+ if (strcmp(model,"NHM-3") == 0) return 0x89; /* quess for 6250 */
+ return 0;
+}
+
+static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int tmp,i;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "Ringtone received\n");
+ switch (msg.Buffer[3]) {
+ case 0x23:
+ tmp=0;i=4;
+ while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) {
+ tmp++;
+ i=i+2;
+ if (i>msg.Length) return ERR_EMPTY;
+ }
+ memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2);
+ smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
+ /* Looking for end */
+ i=37;
+ while (true) {
+ if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
+ i=i+2; break;
+ }
+ if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
+ i=i+2; break;
+ }
+ i++;
+ if (i==msg.Length) return ERR_EMPTY;
+ }
+ /* Copying frame */
+ memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37);
+ Data->Ringtone->NokiaBinary.Length=i-37;
+ return ERR_NONE;
+ case 0x24:
+ smprintf(s, "Invalid location. Too high ?\n");
+ return ERR_INVALIDLOCATION;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00};
+
+ if (PhoneRingtone) return ERR_NOTSUPPORTED;
+ if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
+
+ switch (Ringtone->Format) {
+ case RING_NOTETONE:
+ /* In the future get binary and convert */
+ return ERR_NOTSUPPORTED;
+ case RING_NOKIABINARY:
+ req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
+ s->Phone.Data.Ringtone=Ringtone;
+ smprintf(s, "Getting binary ringtone\n");
+ return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
+ case RING_MIDI:
+ return ERR_NOTSUPPORTED;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ int i;
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+
+ smprintf(s, "Received info for Picture Images\n");
+ smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
+ smprintf(s, "Locations :");
+ Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
+ for (i=0;i<Priv->LastPictureImageFolder.Number;i++) {
+ Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2];
+ smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]);
+ }
+ smprintf(s, "\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location)
+{
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+ GSM_SMSFolders folders;
+ GSM_Error error;
+ int i, j = 0, count = 0;
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x96,
+ 0x00, /* Folder ID */
+ 0x0f, 0x07};
+
+ error=N7110_GetSMSFolders (s, &folders);
+ if (error!=ERR_NONE) return error;
+
+ for (i=0;i<folders.Number;i++) {
+ req[4] = (i+1) * 0x08; /* SMS folder ID */
+ error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap);
+ if (error!=ERR_NONE) return error;
+ for (j=0;j<Priv->LastPictureImageFolder.Number;j++) {
+ count++;
+ if (count==Bitmap->Location) break;
+ }
+ if (count==Bitmap->Location) break;
+ }
+ if (count!=Bitmap->Location) return ERR_INVALIDLOCATION;
+ *folder = (i+1) * 0x08; /* SMS Folder ID */
+ *location = Priv->LastPictureImageFolder.Location[j];
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char folder;
+ int location;
+ GSM_Error error;
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
+ 0x00, /* Folder ID */
+ 0x00, 0x00, /* Location */
+ 0x00, 0x64};
+
+ error = N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
+ switch (error) {
+ case ERR_NONE:
+ req[4] = folder;
+ req[5] = location / 256;
+ req[6] = location % 256;
+ return GSM_WaitFor (s, req, 9, 0x14, 4, ID_GetBitmap);
+ default:
+ return error;
+ }
+}
+
+static GSM_Error N7110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_MemoryEntry pbk;
+ GSM_Error error;
+ unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
+
+ s->Phone.Data.Bitmap=Bitmap;
+ switch (Bitmap->Type) {
+ case GSM_StartupLogo:
+ smprintf(s, "Getting startup logo\n");
+ return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
+ case GSM_WelcomeNote_Text:
+ smprintf(s, "Getting welcome note\n");
+ return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
+ case GSM_DealerNote_Text:
+ smprintf(s, "Getting dealer note\n");
+ return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x17);
+ case GSM_CallerGroupLogo:
+ pbk.MemoryType = MEM7110_CG;
+ pbk.Location = Bitmap->Location;
+ smprintf(s, "Getting caller group logo\n");
+ error=N7110_GetMemory(s,&pbk);
+ if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s,Bitmap);
+ return error;
+ case GSM_OperatorLogo:
+ smprintf(s, "Getting operator logo\n");
+ /* This is like DCT3_GetNetworkInfo */
+ return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
+ case GSM_PictureImage:
+ /* 7110 doesn't support it */
+ if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return ERR_NOTSUPPORTED;
+ return N7110_GetPictureImage(s, Bitmap);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N7110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ GSM_Ringtone dest;
+ GSM_Error error;
+ GSM_NetworkInfo NetInfo;
+ int size=200;
+ unsigned char req[1000] = {0x7C, 0x01, 0x00, 0x0D, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00}; /*Length*/
+ unsigned char req2[4000] = {N7110_FRAME_HEADER, 0x1F, 0x00,
+ 0x87, /* Location */
+ 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};
+
+ switch (Ringtone->Format) {
+ case RING_NOTETONE:
+ if (Ringtone->Location==255) {
+ /* 7110 doesn't support it */
+ if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return ERR_NOTSUPPORTED;
+ *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+11, &size);
+ req[10] = size;
+ error = s->Protocol.Functions->WriteMessage(s, req, size+11, 0x00);
+ if (error!=ERR_NONE) return error;
+ my_sleep(1000);
+ /* We have to make something (not important, what) now */
+ /* no answer from phone*/
+ return DCT3_GetNetworkInfo(s,&NetInfo);
+ }
+ GSM_RingtoneConvert(&dest, Ringtone, RING_NOKIABINARY);
+ break;
+ case RING_NOKIABINARY:
+ memcpy(&dest,Ringtone,sizeof(GSM_Ringtone));
+ break;
+ default:
+ return ERR_NOTSUPPORTED;
+ }
+ req2[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
+ CopyUnicodeString(req2+6,Ringtone->Name);
+ memcpy(req2+37,dest.NokiaBinary.Frame,dest.NokiaBinary.Length);
+ error = s->Protocol.Functions->WriteMessage(s, req2, 37+dest.NokiaBinary.Length, 0x1F);
+ if (error!=ERR_NONE) return error;
+ my_sleep(1000);
+ /* We have to make something (not important, what) now */
+ /* no answer from phone*/
+ return DCT3_GetNetworkInfo(s,&NetInfo);
+}
+
+static GSM_Error N7110_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x05:
+ smprintf(s, "SMS message saving status\n");
+ smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
+ if (msg.Buffer[4] == 0xf8) {
+ N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
+ Data->SaveSMSMessage->Folder = 0x01;
+ } else {
+ N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
+ Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
+ }
+ return ERR_NONE;
+ case 0x06:
+ smprintf(s, "SMS message saving status\n");
+ switch (msg.Buffer[4]) {
+ case 0x03:
+ smprintf(s, "Too high location ?\n");
+ return ERR_INVALIDLOCATION;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ break;
+ case 0x84:
+ smprintf(s, "Name for SMS changed OK to \"%s\"\n",DecodeUnicodeString(msg.Buffer+7));
+ smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
+ if (msg.Buffer[4] == 0xf8) {
+ N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
+ Data->SaveSMSMessage->Folder = 0x01;
+ } else {
+ N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
+ Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
+ }
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int length, location;
+ unsigned char folderid, folder;
+ GSM_Error error;
+ unsigned char req[256] = {N6110_FRAME_HEADER, 0x04,
+ 0x03, /* sms status */
+ 0x10, /* folder */
+ 0x00,0x00, /* location */
+ 0x00};
+ unsigned char NameReq[200] = {N6110_FRAME_HEADER, 0x83};
+
+ switch (sms->State) {
+ case SMS_Read : req[4] = 0x01; break;
+ case SMS_UnRead : req[4] = 0x03; break;
+ case SMS_Sent : req[4] = 0x05; break;
+ case SMS_UnSent : req[4] = 0x07; break;
+ }
+
+ N7110_GetSMSLocation(s, sms, &folderid, &location);
+ req[5] = folderid;
+ req[6] = location / 256;
+ req[7] = location;
+
+ /* Outbox */
+ if (folderid == 0x10 && (sms->State == SMS_Sent || sms->State == SMS_UnSent)) {
+ /* We will use SIM Outbox */
+ sms->PDU = SMS_Submit;
+ }
+ /* Inbox */
+ if (folderid == 0x08 && sms->State == SMS_UnRead) {
+ /* We will use SIM Inbox */
+ req[5] = 0xf8;
+ }
+
+ switch (sms->PDU) {
+ case SMS_Deliver:
+ error = PHONE_EncodeSMSFrame(s,sms,req+9,PHONE_SMSDeliver,&length,true);
+ break;
+ case SMS_Submit:
+ smprintf(s, "Saving SMS template\n");
+ error = PHONE_EncodeSMSFrame(s,sms,req+9,N7110_SMSTemplate,&length,true);
+ req[8] = 0x02; /* SMS Template info */
+ break;
+ default:
+ return ERR_UNKNOWN;
+ }
+ if (error != ERR_NONE) return error;
+
+ s->Phone.Data.SaveSMSMessage=sms;
+ smprintf(s, "Saving sms\n");
+ error=GSM_WaitFor (s, req, 9+length, 0x14, 4, ID_SaveSMSMessage);
+ if (error == ERR_NONE && UnicodeLength(sms->Name)!=0) {
+ folder = sms->Folder;
+ sms->Folder = 0;
+ N7110_GetSMSLocation(s, sms, &folderid, &location);
+ length = 4;
+ NameReq[length++] = folderid;
+ NameReq[length++] = location / 256;
+ NameReq[length++] = location;
+ CopyUnicodeString(NameReq+length, sms->Name);
+ length = length+UnicodeLength(sms->Name)*2;
+ NameReq[length++] = 0;
+ NameReq[length++] = 0;
+ error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage);
+ sms->Folder = folder;
+ }
+ return error;
+}
+
+static GSM_Error N7110_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int location;
+ unsigned char folderid;
+
+ N7110_GetSMSLocation(s, sms, &folderid, &location);
+ if (location == 0) return ERR_INVALIDLOCATION;
+ return N7110_PrivSetSMSMessage(s, sms);
+}
+
+static GSM_Error N7110_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int location;
+ unsigned char folderid;
+
+ N7110_GetSMSLocation(s, sms, &folderid, &location);
+ location = 0;
+ N7110_SetSMSLocation(s, sms, folderid, location);
+ return N7110_PrivSetSMSMessage(s, sms);
+}
+
+static GSM_Error N7110_ReplyClearOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Clearing operator logo.....\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Setting operator logo.....\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap)
+{
+ int block=0, i, Width, Height;
+ unsigned int count = 18;
+ char string[500];
+ unsigned char req[500] = {N6110_FRAME_HEADER, 0x0b, 0x00,
+ 0x01, 0x01, 0x00, 0x00, 0x0c,
+ 0x00, 0x10, /* memory type */
+ 0x00, 0x00, /* location */
+ 0x00, 0x00, 0x00};
+
+ req[13] = bitmap->Location;
+
+ /* Enabling/disabling logo */
+ if (bitmap->DefaultBitmap) {
+ string[0] = 0; //disabling
+ } else {
+ string[0] = bitmap->BitmapEnabled?1:0;
+ }
+ string[1] = 0;
+ count += N71_65_PackPBKBlock(s, N7110_PBK_LOGOON, 2, block++, string, req + count);
+
+ /* Ringtone */
+ if (!bitmap->DefaultRingtone) {
+ string[0] = bitmap->RingtoneID;
+ string[1] = 0;
+ count += N71_65_PackPBKBlock(s, N7110_PBK_RINGTONE_ID, 2, block++, string, req + count);
+ }
+
+ /* Number of group */
+ string[0] = bitmap->Location;
+ string[1] = 0;
+ count += N71_65_PackPBKBlock(s, N7110_PBK_GROUP, 2, block++, string, req + count);
+
+ /* Name */
+ if (!bitmap->DefaultName) {
+ i = UnicodeLength(bitmap->Text) * 2;
+ string[0] = i + 2;
+ memcpy(string + 1, bitmap->Text, i);
+ string[i + 1] = 0;
+ count += N71_65_PackPBKBlock(s, N7110_PBK_NAME, i + 2, block++, string, req + count);
+ }
+
+ /* Logo */
+ if (bitmap->DefaultBitmap) {
+ bitmap->BitmapWidth = 72;
+ bitmap->BitmapHeight = 14;
+ GSM_ClearBitmap(bitmap);
+ }
+ PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height);
+ string[0] = Width;
+ string[1] = Height;
+ string[2] = 0;
+ string[3] = 0;
+ string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0);
+ PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap);
+ count += N71_65_PackPBKBlock(s, N7110_PBK_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count);
+
+ req[17] = block;
+
+ return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
+}
+
+static GSM_Error N7110_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_SetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char folder;
+ GSM_Error error;
+ int location, i, count, Width, Height;
+ GSM_Phone_Bitmap_Types Type = GSM_NokiaPictureImage;
+ unsigned char req[500] = {N6110_FRAME_HEADER, 0x50, 0x07,
+ 0x00, /* location */
+ 0x00, 0x00, /* index */
+ 0x07};
+
+ error=N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
+ switch (error) {
+ case ERR_NONE:
+ req[5] = folder;
+ req[6] = location / 256;
+ req[7] = location % 256;
+ break;
+ case ERR_INVALIDLOCATION:
+ req[5] = 0x21; /* Save in Templates folder */
+ req[6] = 0;
+ req[7] = 0;
+ break;
+ default:
+ return error;
+ }
+
+ /* Cleaning */
+ for (i=0;i<36;i++) req[i+9]=0;
+
+ count=8;
+ if (UnicodeLength(Bitmap->Text)==0) {
+ count+=2 ;req[count]=0x0c;
+ count+=2 ;req[count]=0x0d;
+ count+=2 ;req[count]=0x0e;
+ count+=2 ;req[count]=0x0f;
+ count+=2 ;req[count]=0x10;
+ count+=2 ;req[count]=0x11;
+ count+=23;req[count]=0x02;
+ count++ ;
+ } else {
+ count+=2 ;req[count]=0x54;
+ count++ ;req[count]=0xd4;
+ count++ ;req[count]=0x0d;
+ count+=2 ;req[count]=0x0e;
+ count+=2 ;req[count]=0x0f;
+ count+=2 ;req[count]=0x10;
+ count+=2 ;req[count]=0x11;
+ count+=21;req[count]=0x01;
+ count+=3 ;
+ }
+ req[count] = 0x01;
+ count+=2;
+ req[count++] = 0x01;
+ PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
+ req[count++] = Width;
+ req[count++] = Height;
+ req[count++] = PHONE_GetBitmapSize(Type,0,0) / 256;
+ req[count++] = PHONE_GetBitmapSize(Type,0,0) % 256;
+ PHONE_EncodeBitmap(Type, req + count, Bitmap);
+ count += PHONE_GetBitmapSize(Type,0,0);
+ if (UnicodeLength(Bitmap->Text)!=0) {
+ req[count] = UnicodeLength(Bitmap->Text);
+ GSM_PackSevenBitsToEight(0, Bitmap->Text, req+count+1,strlen(Bitmap->Text));
+ count = count + req[count];
+ } else {
+ req[count++]=0x00;
+ }
+ req[count++]=0x00;
+ smprintf(s, "Setting Picture Image\n");
+ return GSM_WaitFor (s, req, count, 0x14, 4, ID_SetBitmap);
+}
+
+static GSM_Error N7110_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Error error;
+ GSM_Phone_Bitmap_Types Type;
+ int Width, Height, i;
+ unsigned char reqStartup[1000] = {N7110_FRAME_HEADER, 0xec,
+ 0x15, /* Startup Logo setting */
+ 0x00, 0x00, 0x00, 0x04, 0xc0, 0x02, 0x00,
+ 0x00, /* Bitmap height */
+ 0xc0, 0x03, 0x00,
+ 0x00, /* Bitmap width */
+ 0xc0, 0x04, 0x03, 0x00};
+ unsigned char reqOp[1000] = {N7110_FRAME_HEADER, 0xa3, 0x01,
+ 0x00, /* logo disabled */
+ 0x00, 0xf0, 0x00, /* network code (000 00) */
+ 0x00 ,0x04,
+ 0x08, /* length of rest */
+ 0x00, 0x00, /* Bitmap width / height */
+ 0x00,
+ 0x00, /* Bitmap size */
+ 0x00, 0x00};
+ unsigned char reqClrOp[] = {0x00, 0x01, 0x00, 0xaf, 0x00};
+ unsigned char reqStartupText[500] = {N7110_FRAME_HEADER, 0xec,
+ 0x02}; /* Startup Text setting */
+
+ switch (Bitmap->Type) {
+ case GSM_StartupLogo:
+ if (Bitmap->Location!=1) return ERR_NOTSUPPORTED;
+ Type=GSM_Nokia6210StartupLogo;
+ if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) Type=GSM_Nokia7110StartupLogo;
+ PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
+ reqStartup[12] = Height;
+ reqStartup[16] = Width;
+ PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
+ smprintf(s, "Setting startup logo\n");
+ return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
+ case GSM_WelcomeNote_Text:
+ CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
+ i = 6 + UnicodeLength(Bitmap->Text) * 2;
+ reqStartupText[i++] = 0;
+ reqStartupText[i++] = 0;
+ return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
+ case GSM_DealerNote_Text:
+ reqStartupText[4] = 0x17;
+ CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
+ i = 6 + UnicodeLength(Bitmap->Text) * 2;
+ reqStartupText[i++] = 0;
+ reqStartupText[i++] = 0;
+ return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
+ case GSM_OperatorLogo:
+ /* We want to set operator logo, not clear */
+ if (strcmp(Bitmap->NetworkCode,"000 00")) {
+ reqOp[5] = 0x01; /* Logo enabled */
+ NOKIA_EncodeNetworkCode(reqOp+6, Bitmap->NetworkCode);
+ Type = GSM_Nokia7110OperatorLogo;
+ reqOp[11] = 8 + PHONE_GetBitmapSize(Type,0,0);
+ PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
+ reqOp[12]=Width;
+ reqOp[13]=Height;
+ reqOp[15]=PHONE_GetBitmapSize(Type,0,0);
+ PHONE_EncodeBitmap(Type, reqOp + 18, Bitmap);
+ smprintf(s, "Setting operator logo\n");
+ return GSM_WaitFor (s, reqOp, 18+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
+ } else {
+ smprintf(s, "Clearing operator logo\n");
+ for (i=0;i<5;i++) {
+ reqClrOp[4]=i;
+ error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
+ if (error!=ERR_NONE) return error;
+ }
+ return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap);
+ }
+ case GSM_CallerGroupLogo:
+ return N7110_SetCallerLogo(s,Bitmap);
+ case GSM_PictureImage:
+ return N7110_SetPictureImage(s,Bitmap);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N7110_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Phonebook entry deleted\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x00, 0x01,
+ 0x04, 0x00, 0x00, 0x0c, 0x01, 0xff,
+ 0x00, 0x01, /* location */
+ 0x05, /* memory type */
+ 0x00, 0x00, 0x00};
+
+ req[12] = entry->Location / 256;
+ req[13] = entry->Location % 256;
+
+ req[14] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
+ if (req[14]==0xff) return ERR_NOTSUPPORTED;
+
+ smprintf(s, "Deleting phonebook entry\n");
+ return GSM_WaitFor (s, req, 18, 0x03, 4, ID_SetMemory);
+}
+
+static GSM_Error N7110_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
+{
+ int count = 18, blocks;
+ unsigned char req[500] = {N7110_FRAME_HEADER, 0x0b, 0x00,
+ 0x01, 0x01, 0x00, 0x00, 0x0c,
+ 0x00, 0x00, /* memory type */
+ 0x00, 0x00, /* location */
+ 0x00, 0x00, 0x00};
+
+ if (entry->Location == 0) return ERR_NOTSUPPORTED;
+
+ req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
+ if (req[11]==0xff) return ERR_NOTSUPPORTED;
+
+ req[12] = entry->Location >> 8;
+ req[13] = entry->Location & 0xff;
+
+ count = count + N71_65_EncodePhonebookFrame(s, req+18, *entry, &blocks, false, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS));
+ req[17] = blocks;
+
+ smprintf(s, "Writing phonebook entry\n");
+ return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory);
+}
+
+static GSM_Error N7110_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ unsigned char folderid;
+ int location;
+ unsigned char req[] = {N7110_FRAME_HEADER, 0x0a,
+ 0x00, /* folder */
+ 0x00, 0x00, /* location */
+ 0x01};
+
+ N7110_GetSMSLocation(s, sms, &folderid, &location);
+ req[4] = folderid;
+ req[5] = location / 256;
+ req[6] = location;
+
+ smprintf(s, "Deleting sms\n");
+ return GSM_WaitFor (s, req, 8, 0x14, 4, ID_DeleteSMSMessage);
+}
+
+static GSM_Error N7110_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ smprintf(s, "SMS status received\n");
+ switch (msg.Buffer[3]) {
+ case 0x37:
+ smprintf(s, "SIM size : %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
+ smprintf(s, "Used in phone memory : %i\n",msg.Buffer[10]*256+msg.Buffer[11]);
+ smprintf(s, "Unread in phone memory : %i\n",msg.Buffer[12]*256+msg.Buffer[13]);
+ smprintf(s, "Used in SIM : %i\n",msg.Buffer[14]*256+msg.Buffer[15]);
+ smprintf(s, "Unread in SIM : %i\n",msg.Buffer[16]*256+msg.Buffer[17]);
+ Data->SMSStatus->SIMSize = msg.Buffer[8]*256+msg.Buffer[9];
+ Data->SMSStatus->PhoneUsed = msg.Buffer[10]*256+msg.Buffer[11];
+ Data->SMSStatus->PhoneUnRead = msg.Buffer[12]*256+msg.Buffer[13];
+ Data->SMSStatus->PhoneSize = 150;
+ Data->SMSStatus->SIMUsed = msg.Buffer[14]*256+msg.Buffer[15];
+ Data->SMSStatus->SIMUnRead = msg.Buffer[16]*256+msg.Buffer[17];
+ return ERR_NONE;
+ case 0x38:
+ smprintf(s, "Error. No PIN ?\n");
+ return ERR_SECURITYERROR;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
+{
+ GSM_Error error;
+ GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
+
+ error = DCT3_GetSMSStatus(s,status);
+ if (error != ERR_NONE) return error;
+
+ /* 6210 family doesn't show in frame with SMS status info
+ * about Templates. We get separately info about this SMS folder.
+ */
+ error = N7110_GetSMSFolderStatus(s, 0x20);
+ if (error != ERR_NONE) return error;
+ status->TemplatesUsed = Priv->LastSMSFolder.Number;
+
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_ReplyGetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+ switch (msg.Buffer[3]) {
+ case 0x02:
+ smprintf(s, "Profile feature %02x with value %02x\n",msg.Buffer[6],msg.Buffer[10]);
+ switch (msg.Buffer[6]) {
+ case 0x03:
+ smprintf(s, "Ringtone ID\n");
+ Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_RingtoneID;
+ Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg.Buffer[10];
+ Data->Profile->FeaturesNumber++;
+ break;
+ case 0x08: /* Caller groups */
+ NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,true);
+ break;
+ case 0x09: /* Autoanswer */
+ if (Data->Profile->CarKitProfile || Data->Profile->HeadSetProfile) {
+ NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
+ }
+ break;
+ case 0xff :
+ CopyUnicodeString(Data->Profile->Name, msg.Buffer+10);
+ smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
+ Data->Profile->DefaultName = false;
+ break;
+ default:
+ NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
+ }
+ return ERR_NONE;
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+
+static GSM_Error N7110_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
+{
+ GSM_Error error;
+ int i;
+ unsigned char Features[12] = {0x00,0x02,0x03,0x04,0x05,0x06,
+ 0x07,0x08,0x09,0xff,
+ 0x0a,0x22};
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x01, 0x01,
+ 0x00, /* Profile Location */
+ 0xff}; /* Feature number */
+
+ if (Profile->Location > 7) return ERR_INVALIDLOCATION;
+
+ Profile->CarKitProfile = false;
+ Profile->HeadSetProfile = false;
+ if (Profile->Location == 6) Profile->CarKitProfile = true;
+ if (Profile->Location == 7) Profile->HeadSetProfile = true;
+
+ Profile->FeaturesNumber = 0;
+
+ s->Phone.Data.Profile=Profile;
+ for (i = 0; i < 10; i++) {
+ req[7] = Profile->Location;
+ req[8] = Features[i];
+ smprintf(s, "Getting profile feature\n");
+ error = GSM_WaitFor (s, req, 9, 0x39, 4, ID_GetProfile);
+ if (error!=ERR_NONE) return error;
+ }
+ NOKIA_GetDefaultProfileName(s, Profile);
+ Profile->Active = false;
+ return error;
+}
+
+static GSM_Error N7110_ReplySetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Profile feature set\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
+{
+ int i;
+ bool found;
+ GSM_Error error;
+ unsigned char ID,Value;
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x01, 0x01, 0x03,
+ 0x02, /* feature number */
+ 0x01, /* Profile Location */
+ 0x01,
+ 0xff}; /* Value */
+
+ for (i=0;i<Profile->FeaturesNumber;i++) {
+ found = false;
+ switch (Profile->FeatureID[i]) {
+ case Profile_RingtoneID:
+ ID = 0x03;
+ Value = Profile->FeatureValue[i];
+ found = true;
+ break;
+ default:
+ found=NOKIA_FindPhoneFeatureValue(
+ s,
+ Profile71_65,
+ Profile->FeatureID[i],Profile->FeatureValue[i],
+ &ID,&Value);
+ }
+ if (found) {
+ req[7] = ID;
+ req[8] = Profile->Location;
+ req[10] = Value;
+ smprintf(s, "Setting profile feature\n");
+ error = GSM_WaitFor (s, req, 11, 0x39, 4, ID_SetProfile);
+ if (error!=ERR_NONE) return error;
+ }
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
+{
+ GSM_MemoryEntry pbk;
+ GSM_Error error;
+
+ pbk.MemoryType = MEM7110_SP;
+ pbk.Location = SpeedDial->Location;
+ SpeedDial->MemoryLocation = 0;
+ s->Phone.Data.SpeedDial = SpeedDial;
+
+ smprintf(s, "Getting speed dial\n");
+ error=N7110_GetMemory(s,&pbk);
+ switch (error) {
+ case ERR_NOTSUPPORTED:
+ smprintf(s, "No speed dials set in phone\n");
+ return ERR_EMPTY;
+ case ERR_NONE:
+ if (SpeedDial->MemoryLocation == 0) {
+ smprintf(s, "Speed dial not assigned or error in firmware\n");
+ return ERR_EMPTY;
+ }
+ return ERR_NONE;
+ default:
+ return error;
+ }
+}
+
+static GSM_Error N7110_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_SMSMessage sms;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+#ifdef DEBUG
+ smprintf(s, "SMS message received\n");
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
+#endif
+ if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
+
+ s->User.IncomingSMS(s->CurrentConfig->Device,sms);
+ }
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_Initialise (GSM_StateMachine *s)
+{
+#ifdef DEBUG
+ DCT3_SetIncomingCB(s,true);
+#endif
+#ifdef GSM_ENABLE_N71_92INCOMINGINFO
+ /* Enables various things like incoming SMS, call info, etc. */
+ return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17", 6);
+#endif
+ return ERR_NONE;
+}
+
+static GSM_Error N7110_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ /* Old method 1 for accessing calendar */
+ return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N7110.LastCalendar);
+}
+
+#ifdef DEBUG
+static GSM_Error N7110_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ /* Old method 1 for accessing calendar */
+ return N71_65_ReplyGetCalendarNotePos1(msg, s, &s->Phone.Data.Priv.N7110.FirstCalendarPos);
+}
+#endif
+
+static GSM_Error N7110_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
+{
+ return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendar,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
+// return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
+}
+
+static GSM_Error N7110_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
+{
+ GSM_Error error;
+
+ /* Method 1 */
+ error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N7110.LastCalendar);
+ if (error!=ERR_NONE) return error;
+ Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
+ return ERR_NONE;
+
+ /* Method 2 */
+// return GE_NOTSUPPORTED;
+}
+
+static GSM_Error N7110_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
+{
+// return N71_65_AddCalendar1(s, Note, NULL);
+ return N71_65_AddCalendar2(s,Note);
+}
+
+static GSM_Error N7110_ReplyGetNetworkInfoError(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Probably means no PIN\n");
+ return ERR_SECURITYERROR;
+}
+
+static GSM_Error N7110_SetIncomingCall(GSM_StateMachine *s, bool enable)
+{
+#ifndef GSM_ENABLE_N71_92INCOMINGINFO
+ return ERR_SOURCENOTAVAILABLE;
+#endif
+ return NOKIA_SetIncomingCall(s,enable);
+}
+
+static GSM_Error N7110_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
+{
+#ifndef GSM_ENABLE_N71_92INCOMINGINFO
+ return ERR_SOURCENOTAVAILABLE;
+#endif
+ return NOKIA_SetIncomingUSSD(s,enable);
+}
+
+static GSM_Error N7110_SetIncomingSMS(GSM_StateMachine *s, bool enable)
+{
+#ifndef GSM_ENABLE_N71_92INCOMINGINFO
+ return ERR_SOURCENOTAVAILABLE;
+#endif
+ return NOKIA_SetIncomingSMS(s,enable);
+}
+
+GSM_Error N7110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
+{
+ if (!all) return DCT3DCT4_AnswerCall(s,ID);
+ return DCT3_AnswerAllCalls(s);
+}
+
+GSM_Error N7110_SetCallDivert(GSM_StateMachine *s, GSM_MultiCallDivert *divert)
+{
+ GSM_Error error;
+ int i;
+
+ /* No answer from phone side */
+ i = s->ReplyNum;
+ s->ReplyNum = 1;
+ error = DCT3DCT4_SetCallDivert(s,divert);
+ s->ReplyNum = i;
+ return error;
+}
+
+GSM_Error N7110_CancelAllDiverts(GSM_StateMachine *s)
+{
+ GSM_Error error;
+ int i;
+
+ /* No answer from phone side */
+ i = s->ReplyNum;
+ s->ReplyNum = 1;
+ error = DCT3DCT4_CancelAllDiverts(s);
+ s->ReplyNum = i;
+ return error;
+}
+
+static GSM_Reply_Function N7110ReplyFunctions[] = {
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
+ {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
+ {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
+ {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
+
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
+ {N7110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
+#ifdef GSM_ENABLE_CELLBROADCAST
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
+ {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
+#endif
+ {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
+#ifdef GSM_ENABLE_CELLBROADCAST
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0xCA,ID_SetIncomingCB },
+#endif
+
+ {N7110_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
+ {N7110_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
+ {N7110_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
+ {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
+ {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
+
+ {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
+ {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
+
+ {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
+ {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
+
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetBitmap },
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
+ {N7110_ReplyGetNetworkInfoError, "\x0A",0x03,0x72,ID_GetNetworkInfo },
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x73,ID_IncomingFrame },
+ {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality },
+ {N7110_ReplySetOperatorLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
+ {N7110_ReplyClearOperatorLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
+ {NoneReply, "\x0A",0x03,0xB5,ID_IncomingFrame },
+
+#ifdef DEBUG
+ {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },/*method 1*/
+ {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },/*method 1*/
+ {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },/*method 1*/
+ {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },/*method 1*/
+#endif
+ {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
+ {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
+#ifdef DEBUG
+ {N7110_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
+#endif
+ {N7110_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
+#ifdef DEBUG
+ {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },/*method 2*/
+#endif
+ {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
+
+ {N7110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
+ {N7110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
+ {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
+ {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetBitmap },
+ {N7110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
+ {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
+ {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
+ {N7110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
+ {N7110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
+ {N7110_ReplySetPicture, "\x14",0x03,0x51,ID_SetBitmap },
+ {N7110_ReplyGetSMSFolderStatus, "\x14",0x03,0x6C,ID_GetSMSFolderStatus },
+ {N7110_ReplyGetSMSMessage, "\x14",0x03,0x6F,ID_GetSMSMessage },
+ {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7B,ID_GetSMSFolders },
+ {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7C,ID_GetSMSFolders },
+ {N7110_ReplySaveSMSMessage, "\x14",0x03,0x84,ID_SaveSMSMessage },
+ {N7110_ReplyGetPictureImageInfo, "\x14",0x03,0x97,ID_GetBitmap },
+ {N7110_ReplyGetSMSFolders, "\x14",0x03,0xCA,ID_GetSMSFolders },
+
+ {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge },
+
+ {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
+ {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
+ {DCT3_ReplySetAlarm, "\x19",0x03,0x6C,ID_SetAlarm },
+ {DCT3_ReplyGetAlarm, "\x19",0x03,0x6E,ID_GetAlarm },
+
+ {N7110_ReplyGetRingtone, "\x1f",0x03,0x23,ID_GetRingtone },
+ {N7110_ReplyGetRingtone, "\x1f",0x03,0x24,ID_GetRingtone },
+
+ {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
+ {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
+ {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
+ {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
+ {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
+ {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
+ {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
+ {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
+ {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
+ {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
+ {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
+ {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
+ {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
+ {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
+
+ {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile },
+ {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile },
+
+ {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
+ {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
+ {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
+ {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
+ {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
+ {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame },
+
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap },
+
+ {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
+ {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
+ {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
+ {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+GSM_Phone_Functions N7110Phone = {
+ "6210|6250|7110|7190",
+ N7110ReplyFunctions,
+ N7110_Initialise,
+ PHONE_Terminate,
+ GSM_DispatchMessage,
+ NOTSUPPORTED, /* ShowStartInfo */
+ NOKIA_GetManufacturer,
+ DCT3DCT4_GetModel,
+ DCT3DCT4_GetFirmware,
+ DCT3_GetIMEI,
+ DCT3_GetOriginalIMEI,
+ DCT3_GetManufactureMonth,
+ DCT3_GetProductCode,
+ DCT3_GetHardware,
+ DCT3_GetPPM,
+ NOTSUPPORTED, /* GetSIMIMSI */
+ N71_92_GetDateTime,
+ N71_92_SetDateTime,
+ N7110_GetAlarm,
+ N7110_SetAlarm,
+ NOTSUPPORTED, /* GetLocale */
+ NOTSUPPORTED, /* SetLocale */
+ DCT3_PressKey,
+ DCT3_Reset,
+ N61_71_ResetPhoneSettings,
+ NOTSUPPORTED, /* EnterSecurityCode */
+ NOTSUPPORTED, /* GetSecurityStatus */
+ NOTSUPPORTED, /* GetDisplayStatus */
+ NOTIMPLEMENTED, /* SetAutoNetworkLogin */
+ N71_92_GetBatteryCharge,
+ N71_92_GetSignalQuality,
+ DCT3_GetNetworkInfo,
+ NOTSUPPORTED, /* GetCategory */
+ NOTSUPPORTED, /* AddCategory */
+ NOTSUPPORTED, /* GetCategoryStatus */
+ N7110_GetMemoryStatus,
+ N7110_GetMemory,
+ NOTIMPLEMENTED, /* GetNextMemory */
+ N7110_SetMemory,
+ NOTIMPLEMENTED, /* AddMemory */
+ N7110_DeleteMemory,
+ NOTIMPLEMENTED, /* DeleteAllMemory */
+ N7110_GetSpeedDial,
+ NOTIMPLEMENTED, /* SetSpeedDial */
+ DCT3_GetSMSC,
+ DCT3_SetSMSC,
+ N7110_GetSMSStatus,
+ N7110_GetSMSMessage,
+ N7110_GetNextSMSMessage,
+ N7110_SetSMS,
+ N7110_AddSMS,
+ N7110_DeleteSMS,
+ DCT3_SendSMSMessage,
+ NOTSUPPORTED, /* SendSavedSMS */
+ N7110_SetIncomingSMS,
+ DCT3_SetIncomingCB,
+ N7110_GetSMSFolders,
+ NOTIMPLEMENTED, /* AddSMSFolder */
+ NOTIMPLEMENTED, /* DeleteSMSFolder */
+ DCT3_DialVoice,
+ N7110_AnswerCall,
+ DCT3_CancelCall,
+ NOTIMPLEMENTED, /* HoldCall */
+ NOTIMPLEMENTED, /* UnholdCall */
+ NOTIMPLEMENTED, /* ConferenceCall */
+ NOTIMPLEMENTED, /* SplitCall */
+ NOTIMPLEMENTED, /* TransferCall */
+ NOTIMPLEMENTED, /* SwitchCall */
+ NOTSUPPORTED, /* GetCallDivert */
+ N7110_SetCallDivert,
+ N7110_CancelAllDiverts,
+ N7110_SetIncomingCall,
+ N7110_SetIncomingUSSD,
+ DCT3DCT4_SendDTMF,
+ N7110_GetRingtone,
+ N7110_SetRingtone,
+ NOTSUPPORTED, /* GetRingtonesInfo */
+ NOTSUPPORTED, /* DeleteUserRingtones */
+ DCT3_PlayTone,
+ DCT3_GetWAPBookmark,
+ DCT3_SetWAPBookmark,
+ DCT3_DeleteWAPBookmark,
+ DCT3_GetWAPSettings,
+ DCT3_SetWAPSettings,
+ NOTSUPPORTED, /* GetMMSSettings */
+ NOTSUPPORTED, /* SetMMSSettings */
+ NOTSUPPORTED, /* GetSyncMLSettings */
+ NOTSUPPORTED, /* SetSyncMLSettings */
+ NOTSUPPORTED, /* GetChatSettings */
+ NOTSUPPORTED, /* SetChatSettings */
+ N7110_GetBitmap,
+ N7110_SetBitmap,
+ NOTSUPPORTED, /* GetToDoStatus */
+ NOTSUPPORTED, /* GetToDo */
+ NOTSUPPORTED, /* GetNextToDo */
+ NOTSUPPORTED, /* SetToDo */
+ NOTSUPPORTED, /* AddToDo */
+ NOTSUPPORTED, /* DeleteToDo */
+ NOTSUPPORTED, /* DeleteAllToDo */
+ N7110_GetCalendarStatus,
+ NOTIMPLEMENTED, /* GetCalendar */
+ N7110_GetNextCalendar,
+ NOTIMPLEMENTED, /* SetCalendar */
+ N7110_AddCalendar,
+ N71_65_DelCalendar,
+ NOTIMPLEMENTED, /* DeleteAllCalendar */
+ NOTSUPPORTED, /* GetCalendarSettings */
+ NOTSUPPORTED, /* SetCalendarSettings */
+ NOTSUPPORTED, /* GetNote */
+ N7110_GetProfile,
+ N7110_SetProfile,
+ NOTSUPPORTED, /* GetFMStation */
+ NOTSUPPORTED, /* SetFMStation */
+ NOTSUPPORTED, /* ClearFMStations */
+ NOTSUPPORTED, /* GetNextFileFolder */
+ NOTSUPPORTED, /* GetFilePart */
+ NOTSUPPORTED, /* AddFile */
+ NOTSUPPORTED, /* GetFileSystemStatus */
+ NOTSUPPORTED, /* DeleteFile */
+ NOTSUPPORTED, /* AddFolder */
+ NOTSUPPORTED, /* GetGPRSAccessPoint */
+ NOTSUPPORTED /* SetGPRSAccessPoint */
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.h b/gammu/emb/common/phone/nokia/dct3/n7110.h
new file mode 100644
index 0000000..a7934c2
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.h
@@ -0,0 +1,45 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#ifndef n7110_h
+#define n7110_h
+
+#include "../ncommon.h"
+#include "dct3comm.h"
+
+typedef struct {
+ int LastCalendarYear;
+ int LastCalendarPos;
+ GSM_NOKIACalToDoLocations LastCalendar;
+ int FirstCalendarPos;
+
+ GSM_NOKIASMSFolder LastSMSFolder;
+ GSM_SMSFolders LastSMSFolders;
+ GSM_NOKIASMSFolder LastPictureImageFolder;
+
+ DCT3_WAPSettings_Locations WAPLocations;
+} GSM_Phone_N7110Data;
+
+#ifndef GSM_USED_MBUS2
+# define GSM_USED_MBUS2
+#endif
+#ifndef GSM_USED_FBUS2
+# define GSM_USED_FBUS2
+#endif
+#ifndef GSM_USED_FBUS2DLR3
+# define GSM_USED_FBUS2DLR3
+#endif
+#ifndef GSM_USED_FBUS2BLUE
+# define GSM_USED_FBUS2BLUE
+#endif
+#ifndef GSM_USED_IRDAPHONET
+# define GSM_USED_IRDAPHONET
+#endif
+#ifndef GSM_USED_BLUEFBUS2
+# define GSM_USED_BLUEFBUS2
+#endif
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
new file mode 100644
index 0000000..e82d530
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -0,0 +1,396 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#include "../../../gsmstate.h"
+
+#ifdef GSM_ENABLE_NOKIA9210
+
+#include <string.h>
+#include <time.h>
+
+#include "../../../misc/coding/coding.h"
+#include "../../../gsmcomon.h"
+#include "../../../service/gsmlogo.h"
+#include "../../pfunc.h"
+#include "../nfunc.h"
+#include "n9210.h"
+#include "dct3func.h"
+
+static GSM_Error N9210_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
+
+ s->Phone.Data.Bitmap=Bitmap;
+ switch (Bitmap->Type) {
+ case GSM_OperatorLogo:
+ smprintf(s, "Getting operator logo\n");
+ /* This is like DCT3_GetNetworkInfo */
+ return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
+ case GSM_StartupLogo:
+ smprintf(s, "Getting startup logo\n");
+ return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
+ case GSM_WelcomeNote_Text:
+ smprintf(s, "Getting welcome note\n");
+ return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N9210_ReplySetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Operator logo clear/set\n");
+ return ERR_NONE;
+}
+
+static GSM_Error N9210_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Error error;
+ GSM_Phone_Bitmap_Types Type;
+ int Width, Height, i,count=3;
+ unsigned char req[600] = { N7110_FRAME_HEADER };
+ unsigned char reqStartup[1000] = {
+ N6110_FRAME_HEADER, 0xec,
+ 0x15, /* Startup Logo setting */
+ 0x04, 0x00, 0x00, 0x00, 0x30, 0x00,
+ 0x02, 0xc0, 0x54, 0x00, 0x03, 0xc0,
+ 0xf8, 0xf8, 0x01, 0x04};
+ unsigned char reqStartupText[500] = {
+ N7110_FRAME_HEADER, 0xec,
+ 0x02}; /* Startup Text setting */
+ unsigned char reqClrOp[] = {
+ N7110_FRAME_HEADER, 0xAF,
+ 0x02}; /* Number of logo = 0 - 0x04 */
+
+ switch (Bitmap->Type) {
+ case GSM_StartupLogo:
+ if (Bitmap->Location!=1) return ERR_NOTSUPPORTED;
+ Type=GSM_NokiaStartupLogo;
+ PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
+ PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
+ smprintf(s, "Setting startup logo\n");
+ return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
+ case GSM_WelcomeNote_Text:
+ /* Nokia bug: Unicode text is moved one char to left */
+ CopyUnicodeString(reqStartupText + 4, Bitmap->Text);
+ reqStartupText[4] = 0x02;
+ i = 5 + UnicodeLength(Bitmap->Text) * 2;
+ reqStartupText[i++] = 0;
+ reqStartupText[i++] = 0;
+ return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
+ case GSM_OperatorLogo:
+ /* First part for clearing logo */
+ if (!strcmp(Bitmap->NetworkCode,"000 00")) {
+ for (i=0;i<5;i++) {
+ reqClrOp[4] = i;
+ error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
+ if (error != ERR_NONE) return error;
+ }
+ }
+ Type=GSM_NokiaOperatorLogo;
+ req[count++] = 0xA3;
+ req[count++] = 0x01;
+ req[count++] = 0x00; /* Logo removed */
+ NOKIA_EncodeNetworkCode(req+count, "000 00");
+ count = count + 3;
+ req[count++] = 0x00;
+ req[count++] = 0x04;
+ req[count++] = 0x08; /* Length of rest + 2 */
+ memcpy(req+count, "\x00\x00\x00\x00\x00\x00", 6);
+ count += 6;
+ error=GSM_WaitFor (s, req, count, 0x0A, 4, ID_SetBitmap);
+ if (error != ERR_NONE) return error;
+ /* We wanted only clear - now exit */
+ if (!strcmp(Bitmap->NetworkCode,"000 00")) return error;
+
+ /* Now setting logo */
+ count=3;
+ req[count++] = 0xA3;
+ req[count++] = 0x01;
+ req[count++] = 0x01; /* Logo set */
+ NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode);
+ count = count + 3;
+ req[count++] = 0x00;
+ req[count++] = 0x04;
+ req[count++] = PHONE_GetBitmapSize(Type,0,0)+8;
+ PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
+ req[count++] = Width;
+ req[count++] = Height;
+ req[count++] = PHONE_GetBitmapSize(Type,0,0);
+ req[count++] = 0x00;
+ req[count++] = 0x00;
+ req[count++] = 0x00;
+ PHONE_EncodeBitmap(Type, req+count, Bitmap);
+ return GSM_WaitFor (s, req, count+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
+ default:
+ break;
+ }
+ return ERR_NOTSUPPORTED;
+}
+
+static GSM_Error N9210_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_SMSMessage sms;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+
+#ifdef DEBUG
+ smprintf(s, "SMS message received\n");
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
+#endif
+ if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
+ sms.State = SMS_UnRead;
+ sms.InboxFolder = true;
+ DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
+
+ s->User.IncomingSMS(s->CurrentConfig->Device,sms);
+ }
+ return ERR_NONE;
+}
+
+#ifdef GSM_ENABLE_N71_92INCOMINGINFO
+static GSM_Error N9210_ReplySetIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ switch (msg.Buffer[3]) {
+ case 0x0e:
+ s->Phone.Data.EnableIncomingSMS = true;
+ smprintf(s, "Incoming SMS enabled\n");
+ return ERR_NONE;
+ case 0x0f:
+ smprintf(s, "Error enabling incoming SMS\n");
+ switch (msg.Buffer[4]) {
+ case 0x0c:
+ smprintf(s, "No PIN ?\n");
+ return ERR_SECURITYERROR;
+ default:
+ smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
+ }
+ }
+ return ERR_UNKNOWNRESPONSE;
+}
+#endif
+
+static GSM_Error N9210_SetIncomingSMS(GSM_StateMachine *s, bool enable)
+{
+#ifdef GSM_ENABLE_N71_92INCOMINGINFO
+ unsigned char req[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02};
+
+ if (enable!=s->Phone.Data.EnableIncomingSMS) {
+ if (enable) {
+ smprintf(s, "Enabling incoming SMS\n");
+ return GSM_WaitFor (s, req, 7, 0x02, 4, ID_SetIncomingSMS);
+ } else {
+ s->Phone.Data.EnableIncomingSMS = false;
+ smprintf(s, "Disabling incoming SMS\n");
+ }
+ }
+ return ERR_NONE;
+#else
+ return ERR_SOURCENOTAVAILABLE;
+#endif
+}
+
+static GSM_Error N9210_Initialise (GSM_StateMachine *s)
+{
+#ifdef DEBUG
+ DCT3_SetIncomingCB(s,true);
+
+#ifdef GSM_ENABLE_N71_92INCOMINGINFO
+ N9210_SetIncomingSMS(s,true);
+#endif
+
+#endif
+ return ERR_NONE;
+}
+
+GSM_Error N9210_AnswerCall(GSM_StateMachine *s, int ID, bool all)
+{
+ if (!all) return DCT3DCT4_AnswerCall(s,ID);
+ return DCT3_AnswerAllCalls(s);
+}
+
+static GSM_Reply_Function N9210ReplyFunctions[] = {
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
+ {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
+#ifdef GSM_ENABLE_N71_92INCOMINGINFO
+ {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0E,ID_SetIncomingSMS },
+ {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0F,ID_SetIncomingSMS },
+#endif
+ {N9210_ReplyIncomingSMS, "\x02",0x03,0x11,ID_IncomingFrame },
+#ifdef GSM_ENABLE_CELLBROADCAST
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
+ {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
+ {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
+#endif
+ {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
+ {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
+
+ {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
+ {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
+
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
+ {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
+ {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality },
+ {N9210_ReplySetOpLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
+ {N9210_ReplySetOpLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
+
+ {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge },
+
+ {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
+ {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
+
+ {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
+ {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
+ {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
+ {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth },
+ {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
+
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
+ {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
+
+ {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel },
+ {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware },
+
+ {NULL, "\x00",0x00,0x00,ID_None }
+};
+
+GSM_Phone_Functions N9210Phone = {
+ "9210|9210i",
+ N9210ReplyFunctions,
+ N9210_Initialise,
+ PHONE_Terminate,
+ GSM_DispatchMessage,
+ NOTSUPPORTED, /* ShowStartInfo */
+ NOKIA_GetManufacturer,
+ DCT3DCT4_GetModel,
+ DCT3DCT4_GetFirmware,
+ DCT3_GetIMEI,
+ DCT3_GetOriginalIMEI,
+ DCT3_GetManufactureMonth,
+ DCT3_GetProductCode,
+ DCT3_GetHardware,
+ DCT3_GetPPM,
+ NOTSUPPORTED, /* GetSIMIMSI */
+ N71_92_GetDateTime,
+ N71_92_SetDateTime,
+ NOTIMPLEMENTED, /* GetAlarm */
+ NOTIMPLEMENTED, /* SetAlarm */
+ NOTSUPPORTED, /* GetLocale */
+ NOTSUPPORTED, /* SetLocale */
+ NOTIMPLEMENTED, /* PressKey */
+ NOTIMPLEMENTED, /* Reset */
+ NOTIMPLEMENTED, /* ResetPhoneSettings */
+ NOTSUPPORTED, /* EnterSecurityCode */
+ NOTSUPPORTED, /* GetSecurityStatus */
+ NOTSUPPORTED, /* GetDisplayStatus */
+ NOTIMPLEMENTED, /* SetAutoNetworkLogin */
+ N71_92_GetBatteryCharge,
+ N71_92_GetSignalQuality,
+ DCT3_GetNetworkInfo,
+ NOTSUPPORTED, /* GetCategory */
+ NOTSUPPORTED, /* AddCategory */
+ NOTSUPPORTED, /* GetCategoryStatus */
+ NOTIMPLEMENTED, /* GetMemoryStatus */
+ NOTIMPLEMENTED, /* GetMemory */
+ NOTIMPLEMENTED, /* GetNextMemory */
+ NOTIMPLEMENTED, /* SetMemory */
+ NOTIMPLEMENTED, /* AddMemory */
+ NOTIMPLEMENTED, /* DeleteMemory */
+ NOTIMPLEMENTED, /* DeleteAllMemory */
+ NOTIMPLEMENTED, /* GetSpeedDial */
+ NOTIMPLEMENTED, /* SetSpeedDial */
+ DCT3_GetSMSC,
+ DCT3_SetSMSC, /* FIXME: test it */
+ NOTIMPLEMENTED, /* GetSMSStatus */
+ NOTIMPLEMENTED, /* GetSMS */
+ NOTIMPLEMENTED, /* GetNextSMS */
+ NOTIMPLEMENTED, /* SetSMS */
+ NOTIMPLEMENTED, /* AddSMS */
+ NOTIMPLEMENTED, /* DeleteSMS */
+ DCT3_SendSMSMessage,
+ NOTSUPPORTED, /* SendSavedSMS */
+ N9210_SetIncomingSMS,
+ DCT3_SetIncomingCB,
+ NOTIMPLEMENTED, /* GetSMSFolders */
+ NOTSUPPORTED, /* AddSMSFolder */
+ NOTSUPPORTED, /* DeleteSMSFolder */
+ DCT3_DialVoice,
+ N9210_AnswerCall,
+ DCT3_CancelCall,
+ NOTSUPPORTED, /* HoldCall */
+ NOTSUPPORTED, /* UnholdCall */
+ NOTSUPPORTED, /* ConferenceCall */
+ NOTSUPPORTED, /* SplitCall */
+ NOTSUPPORTED, /* TransferCall */
+ NOTSUPPORTED, /* SwitchCall */
+ NOTSUPPORTED, /* GetCallDivert */
+ NOTSUPPORTED, /* SetCallDivert */
+ NOTSUPPORTED, /* CancelAllDiverts */
+ NOTSUPPORTED, /* SetIncomingCall */
+ NOTIMPLEMENTED, /* SetIncomingUSSD */
+ NOTSUPPORTED, /* SendDTMF */
+ NOTIMPLEMENTED, /* GetRingtone */
+ NOTIMPLEMENTED, /* SetRingtone */
+ NOTSUPPORTED, /* GetRingtonesInfo */
+ NOTSUPPORTED, /* DeleteUserRingtones */
+ NOTSUPPORTED, /* PlayTone */
+ NOTIMPLEMENTED, /* GetWAPBookmark */
+ NOTIMPLEMENTED, /* SetWAPBookmark */
+ NOTIMPLEMENTED, /* DeleteWAPBookmark */
+ NOTIMPLEMENTED, /* GetWAPSettings */
+ NOTSUPPORTED, /* SetWAPSettings */
+ NOTSUPPORTED, /* GetMMSSettings */
+ NOTSUPPORTED, /* SetMMSSettings */
+ NOTSUPPORTED, /* GetSyncMLSettings */
+ NOTSUPPORTED, /* SetSyncMLSettings */
+ NOTSUPPORTED, /* GetChatSettings */
+ NOTSUPPORTED, /* SetChatSettings */
+ N9210_GetBitmap,
+ N9210_SetBitmap,
+ NOTSUPPORTED, /* GetToDoStatus */
+ NOTSUPPORTED, /* GetToDo */
+ NOTSUPPORTED, /* GetNextToDo */
+ NOTSUPPORTED, /* SetToDo */
+ NOTSUPPORTED, /* AddToDo */
+ NOTSUPPORTED, /* DeleteToDo */
+ NOTSUPPORTED, /* DeleteAllToDo */
+ NOTSUPPORTED, /* GetCalendarStatus */
+ NOTSUPPORTED, /* GetCalendar */
+ NOTSUPPORTED, /* GetNextCalendar */
+ NOTSUPPORTED, /* SetCalendar */
+ NOTSUPPORTED, /* AddCalendar */
+ NOTSUPPORTED, /* DeleteCalendar */
+ NOTSUPPORTED, /* DeleteAllCalendar */
+ NOTSUPPORTED, /* GetCalendarSettings */
+ NOTSUPPORTED, /* SetCalendarSettings */
+ NOTSUPPORTED, /* GetNote */
+ NOTIMPLEMENTED, /* GetProfile */
+ NOTSUPPORTED, /* SetProfile */
+ NOTSUPPORTED, /* GetFMStation */
+ NOTSUPPORTED, /* SetFMStation */
+ NOTSUPPORTED, /* ClearFMStations */
+ NOTSUPPORTED, /* GetNextFileFolder */
+ NOTSUPPORTED, /* GetFilePart */
+ NOTSUPPORTED, /* AddFile */
+ NOTSUPPORTED, /* GetFileSystemStatus */
+ NOTSUPPORTED, /* DeleteFile */
+ NOTSUPPORTED, /* AddFolder */
+ NOTSUPPORTED, /* GetGPRSAccessPoint */
+ NOTSUPPORTED /* SetGPRSAccessPoint */
+};
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.h b/gammu/emb/common/phone/nokia/dct3/n9210.h
new file mode 100644
index 0000000..8998532
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.h
@@ -0,0 +1,17 @@
+/* (c) 2002-2003 by Marcin Wiacek */
+
+#ifndef n9210_h
+#define n9210_h
+
+#ifndef GSM_USED_MBUS2
+# define GSM_USED_MBUS2
+#endif
+#ifndef GSM_USED_FBUS2
+# define GSM_USED_FBUS2
+#endif
+
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */