summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct4/n6510.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct4/n6510.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.c142
1 files changed, 126 insertions, 16 deletions
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c
index 2208def..c481863 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.c
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.c
@@ -6,2 +6,11 @@
6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */ 6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
@@ -288,6 +297,6 @@ static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMa
288 297
289 sprintf(NetInfo.LAC,"%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 298 sprintf(NetInfo.LAC,"%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]);
290 smprintf(s, "LAC : %s\n", NetInfo.LAC); 299 smprintf(s, "LAC : %s\n", NetInfo.LAC);
291 300
292 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 301 sprintf(NetInfo.CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]);
293 smprintf(s, "CID : %s\n", NetInfo.CID); 302 smprintf(s, "CID : %s\n", NetInfo.CID);
@@ -313,4 +322,4 @@ static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMa
313 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true); 322 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true);
314 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 323 sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]);
315 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 324 sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]);
316 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode); 325 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode);
@@ -1129,6 +1138,4 @@ static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1129 int Width, Height, i, count; 1138 int Width, Height, i, count;
1130#ifdef DEVELOP
1131 unsigned char folderid; 1139 unsigned char folderid;
1132 int location; 1140 int location;
1133#endif
1134 GSM_NetworkInfo NetInfo; 1141 GSM_NetworkInfo NetInfo;
@@ -1257,3 +1264,2 @@ static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1257 if (error == ERR_NONE) { 1264 if (error == ERR_NONE) {
1258#ifdef DEVELOP
1259 sms.Folder = 0; 1265 sms.Folder = 0;
@@ -1267,5 +1273,2 @@ static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1267 reqPicture[7]=location; 1273 reqPicture[7]=location;
1268#else
1269 return ERR_NOTSUPPORTED;
1270#endif
1271 } 1274 }
@@ -2421,2 +2424,5 @@ static GSM_Error N6510_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMa
2421 return ERR_INVALIDLOCATION; 2424 return ERR_INVALIDLOCATION;
2425 case 0x03:
2426 printf("Memory full (for example no empty space in SIM)\n");
2427 return ERR_FULL;
2422 case 0x05: 2428 case 0x05:
@@ -2678,2 +2684,4 @@ static GSM_Error N6510_ReplyGetRingtonesInfo(GSM_Protocol_Message msg, GSM_State
2678 Data->RingtonesInfo->Number = msg.Buffer[4] * 256 + msg.Buffer[5]; 2684 Data->RingtonesInfo->Number = msg.Buffer[4] * 256 + msg.Buffer[5];
2685 // allocate array of ringtones based on number
2686 Data->RingtonesInfo->Ringtone = calloc(Data->RingtonesInfo->Number, sizeof(GSM_RingtoneInfo));
2679 tmp = 6; 2687 tmp = 6;
@@ -2756,3 +2764,3 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
2756{ 2764{
2757 GSM_AllRingtonesInfo Info; 2765 GSM_AllRingtonesInfo Info = {0, NULL};
2758 GSM_Error error; 2766 GSM_Error error;
@@ -2776,3 +2784,5 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
2776 smprintf(s, "Getting binary ringtone\n"); 2784 smprintf(s, "Getting binary ringtone\n");
2777 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); 2785 error = GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone);
2786 if (Info.Ringtone) free(Info.Ringtone);
2787 return error;
2778 case RING_MIDI: 2788 case RING_MIDI:
@@ -4056,2 +4066,93 @@ GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start
4056 4066
4067static GSM_Error N6510_DeleteNote(GSM_StateMachine *s, GSM_NoteEntry *Not)
4068{
4069 GSM_Error error;
4070 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4071 GSM_CalendarEntry Note;
4072
4073 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
4074
4075 error=N6510_GetCalendarInfo3(s,LastNote,2);
4076 if (error!=ERR_NONE) return error;
4077
4078 smprintf(s, "Deleting Note\n");
4079
4080 if (Not->Location > LastNote->Number || Not->Location == 0) return ERR_INVALIDLOCATION;
4081
4082 Note.Location = LastNote->Location[Not->Location-1];
4083 return N71_65_DelCalendar(s,&Note);
4084}
4085
4086static GSM_Error N6510_ReplyGetNoteFirstLoc(GSM_Protocol_Message msg, GSM_StateMachine *s)
4087{
4088 smprintf(s, "First Note location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
4089 s->Phone.Data.Note->Location = msg.Buffer[8]*256+msg.Buffer[9];
4090 return ERR_NONE;
4091}
4092
4093static GSM_Error N6510_ReplyAddNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
4094{
4095 smprintf(s, "ToDo added\n");
4096 return ERR_NONE;
4097}
4098
4099static GSM_Error N6510_AddNote(GSM_StateMachine *s, GSM_NoteEntry *Not)
4100{
4101 GSM_Error error;
4102 int count=54;
4103 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95,
4104 0x02};/* 1 = todo, 2 = note */
4105 unsigned char req[5000] = {
4106 N6110_FRAME_HEADER, 0x65,
4107 0x02, /* 0 = calendar, 1 = todo, 2 = note */
4108 0x00, 0x00, 0x00,
4109 0x00, 0x00, /* location */
4110 0x00, 0x00, 0x00, 0x00,
4111 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */
4112 0x80, 0x00, 0x00,
4113 0xA9, /* note icon */
4114 0x00, 0x00, 0x00, 0x00, /* alarm type */
4115 0x00, /* 0x02 or 0x00 */
4116 0x80, /* note type */
4117 0x07, 0xD2, 0x01, 0x01, 0x00, 0x00, /* start date/time */
4118 0x07, 0xD2, 0x01, 0x11, 0x00, 0x00, /* end date/time */
4119 0x00, 0x00, /* recurrance */
4120 0xFF, 0xFF, /* birth year */
4121 0x00, /* ToDo priority */
4122 0x00, /* ToDo completed ? */
4123 0x00, 0x00, 0x00,
4124 0x00, /* note text length */
4125 0x00, /* phone length/meeting place */
4126 0x00, 0x00, 0x00};
4127
4128 s->Phone.Data.Note = Not;
4129
4130 smprintf(s, "Getting first free Note location\n");
4131 error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetNote);
4132 if (error!=ERR_NONE) return error;
4133 req[8] = Not->Location/256;
4134 req[9] = Not->Location%256;
4135
4136 req[49] = UnicodeLength(Not->Text);
4137 CopyUnicodeString(req+54,Not->Text);
4138 count+= req[49]*2;
4139
4140 req[count++] = 0x00;
4141
4142 smprintf(s, "Adding Note\n");
4143 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetNote);
4144}
4145
4146static GSM_Error N6510_GetNoteStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
4147{
4148 GSM_NOKIACalToDoLocations*LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4149 GSM_Error error;
4150
4151 error = N6510_GetCalendarInfo3(s,LastNote,2);
4152 if (error!=ERR_NONE) return error;
4153
4154 status->Used = LastNote->Number;
4155 return ERR_NONE;
4156}
4157
4057static int N6510_FindFileCheckSum(unsigned char *ptr, int len) 4158static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
@@ -5191,3 +5292,3 @@ static GSM_Error N6510_ReplyGetToDoFirstLoc2(GSM_Protocol_Message msg, GSM_State
5191 smprintf(s, "First ToDo location method 2: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); 5292 smprintf(s, "First ToDo location method 2: %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
5192 s->Phone.Data.ToDo->Location = msg.Buffer[9]; 5293 s->Phone.Data.ToDo->Location = msg.Buffer[8]*256+msg.Buffer[9];
5193 return ERR_NONE; 5294 return ERR_NONE;
@@ -5203,3 +5304,4 @@ static GSM_Error N6510_AddToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5203 int Text, Alarm, EndTime, Completed, count=54, Phone; 5304 int Text, Alarm, EndTime, Completed, count=54, Phone;
5204 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95, 0x01}; 5305 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95,
5306 0x01};/* 1 = todo, 2 = note */
5205 unsigned char req[5000] = { 5307 unsigned char req[5000] = {
@@ -5587,2 +5689,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5587 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo }, 5689 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo },
5690 {N6510_ReplyAddNote, "\x13",0x03,0x66,ID_SetNote },
5588 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/ 5691 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/
@@ -5595,2 +5698,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5595 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo }, 5698 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo },
5699 {N6510_ReplyGetNoteFirstLoc, "\x13",0x03,0x96,ID_SetNote },
5596 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/ 5700 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/
@@ -5734,3 +5838,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5734GSM_Phone_Functions N6510Phone = { 5838GSM_Phone_Functions N6510Phone = {
5735 "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i", 5839 "1100|1100a|1100b|3100|3100b|3105|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i",
5736 N6510ReplyFunctions, 5840 N6510ReplyFunctions,
@@ -5843,3 +5947,9 @@ GSM_Phone_Functions N6510Phone = {
5843 NOTSUPPORTED, /* SetCalendarSettings*/ 5947 NOTSUPPORTED, /* SetCalendarSettings*/
5948 N6510_GetNoteStatus,
5949 NOTIMPLEMENTED, /* GetNote */
5844 N6510_GetNextNote, 5950 N6510_GetNextNote,
5951 NOTIMPLEMENTED, /* SetNote */
5952 N6510_AddNote,
5953 N6510_DeleteNote,
5954 NOTSUPPORTED, /* DeleteAllNotes */
5845 N6510_GetProfile, 5955 N6510_GetProfile,