summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone
Unidiff
Diffstat (limited to 'gammu/emb/common/phone') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/alcatel/alcatel.c298
-rw-r--r--gammu/emb/common/phone/at/atgen.c295
-rw-r--r--gammu/emb/common/phone/at/atgen.h8
-rw-r--r--gammu/emb/common/phone/at/samsung.c447
-rw-r--r--gammu/emb/common/phone/at/samsung.h16
-rw-r--r--gammu/emb/common/phone/at/siemens.c74
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c141
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.c16
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.h2
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.c17
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c9
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3320.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3650.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.c168
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.h2
-rw-r--r--gammu/emb/common/phone/nokia/nauto.c2
-rw-r--r--gammu/emb/common/phone/nokia/nfunc.c14
-rw-r--r--gammu/emb/common/phone/obex/obexgen.c3
-rw-r--r--gammu/emb/common/phone/obex/obexgen.h4
-rw-r--r--gammu/emb/common/phone/symbian/mroutgen.c3
21 files changed, 1216 insertions, 312 deletions
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c
index f004ad4..3821f13 100644
--- a/gammu/emb/common/phone/alcatel/alcatel.c
+++ b/gammu/emb/common/phone/alcatel/alcatel.c
@@ -1,494 +1,495 @@
1/* (c) 2002-2004 by Michal Cihar */ 1/* (c) 2002-2004 by Michal Cihar */
2 2
3/* 3/*
4 * High level functions for communication with Alcatel One Touch 501 and 4 * High level functions for communication with Alcatel One Touch 501 and
5 * compatible mobile phone. 5 * compatible mobile phone.
6 * 6 *
7 * This code implements functions to communicate with Alcatel phones, 7 * This code implements functions to communicate with Alcatel phones,
8 * currently seem to work: 8 * currently seem to work:
9 * - BE5 series (501/701) 9 * - BE5 series (501/701)
10 * - BF5 series (715) 10 * - BF5 series (715)
11 * - BH4 series (535/735) 11 * - BH4 series (535/735)
12 * For some functions it uses normal AT mode (not implemented here, look at 12 * For some functions it uses normal AT mode (not implemented here, look at
13 * ../at/atgen.[ch]) for others it switches into binary mode and initialises 13 * ../at/atgen.[ch]) for others it switches into binary mode and initialises
14 * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and 14 * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and
15 * communicates over it. Don't ask me why Alcatel uses such silly thing... 15 * communicates over it. Don't ask me why Alcatel uses such silly thing...
16 * 16 *
17 * Notes for future features: 17 * Notes for future features:
18 * - max phone number length is 61 (BE5) 18 * - max phone number length is 61 (BE5)
19 * - max name length is 50 (BE5) 19 * - max name length is 50 (BE5)
20 */ 20 */
21 21
22#include "../../gsmstate.h" 22#include "../../gsmstate.h"
23 23
24#ifdef GSM_ENABLE_ALCATEL 24#ifdef GSM_ENABLE_ALCATEL
25#ifdef GSM_ENABLE_ATGEN 25#ifdef GSM_ENABLE_ATGEN
26 26
27#include <string.h> 27#include <string.h>
28#include <time.h> 28#include <time.h>
29 29
30#include "../../gsmcomon.h" 30#include "../../gsmcomon.h"
31#include "../../misc/coding/coding.h" 31#include "../../misc/coding/coding.h"
32#include "../../misc/misc.h" 32#include "../../misc/misc.h"
33#include "../../service/sms/gsmsms.h" 33#include "../../service/sms/gsmsms.h"
34#include "../pfunc.h" 34#include "../pfunc.h"
35#include "alcatel.h" 35#include "alcatel.h"
36 36
37/* Timeout for GSM_WaitFor calls. */ 37/* Timeout for GSM_WaitFor calls. */
38 #define ALCATEL_TIMEOUT 64 38 #define ALCATEL_TIMEOUT 64
39 39
40/* Some magic numbers for protocol follow */ 40/* Some magic numbers for protocol follow */
41 41
42/* synchronisation types (for everything except begin transfer): */ 42/* synchronisation types (for everything except begin transfer): */
43 #define ALCATEL_SYNC_TYPE_CALENDAR0x64 43 #define ALCATEL_SYNC_TYPE_CALENDAR0x64
44 #define ALCATEL_SYNC_TYPE_TODO 0x68 44 #define ALCATEL_SYNC_TYPE_TODO 0x68
45 #define ALCATEL_SYNC_TYPE_CONTACTS0x6C 45 #define ALCATEL_SYNC_TYPE_CONTACTS0x6C
46 46
47/* synchronisation types (for begin transfer): */ 47/* synchronisation types (for begin transfer): */
48 #define ALCATEL_BEGIN_SYNC_CALENDAR0x00 48 #define ALCATEL_BEGIN_SYNC_CALENDAR0x00
49 #define ALCATEL_BEGIN_SYNC_TODO 0x02 49 #define ALCATEL_BEGIN_SYNC_TODO 0x02
50 #define ALCATEL_BEGIN_SYNC_CONTACTS0x01 50 #define ALCATEL_BEGIN_SYNC_CONTACTS0x01
51 51
52/* category types */ 52/* category types */
53 #define ALCATEL_LIST_TODO_CAT 0x9B 53 #define ALCATEL_LIST_TODO_CAT 0x9B
54 #define ALCATEL_LIST_CONTACTS_CAT0x96 54 #define ALCATEL_LIST_CONTACTS_CAT0x96
55 55
56 56
57/* We need lot of ATGEN functions, because Alcatel is an AT device. */ 57/* We need lot of ATGEN functions, because Alcatel is an AT device. */
58 58
59extern GSM_Reply_Function ALCATELReplyFunctions[]; 59extern GSM_Reply_Function ALCATELReplyFunctions[];
60extern GSM_Reply_Function ATGENReplyFunctions[]; 60extern GSM_Reply_Function ATGENReplyFunctions[];
61 61
62 extern GSM_Error ATGEN_Initialise (GSM_StateMachine *s); 62 extern GSM_Error ATGEN_Initialise (GSM_StateMachine *s);
63 extern GSM_Error ATGEN_Terminate (GSM_StateMachine *s); 63 extern GSM_Error ATGEN_Terminate (GSM_StateMachine *s);
64 extern GSM_Error ATGEN_GetIMEI (GSM_StateMachine *s); 64 extern GSM_Error ATGEN_GetIMEI (GSM_StateMachine *s);
65 extern GSM_Error ATGEN_GetFirmware (GSM_StateMachine *s); 65 extern GSM_Error ATGEN_GetFirmware (GSM_StateMachine *s);
66 extern GSM_Error ATGEN_GetModel (GSM_StateMachine *s); 66 extern GSM_Error ATGEN_GetModel (GSM_StateMachine *s);
67 extern GSM_Error ATGEN_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); 67 extern GSM_Error ATGEN_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time);
68 extern GSM_Error ATGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); 68 extern GSM_Error ATGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
69 extern GSM_Error ATGEN_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start); 69 extern GSM_Error ATGEN_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start);
70 extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); 70 extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
71 extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); 71 extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
72 extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); 72 extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
73 extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status); 73 extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status);
74 extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); 74 extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc);
75 extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); 75 extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc);
76 extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders); 76 extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders);
77 extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); 77 extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status);
78 extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); 78 extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms);
79 extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start); 79 extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start);
80 extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location); 80 extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location);
81 extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); 81 extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
82 extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); 82 extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
83 extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); 83 extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
84 extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat); 84 extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat);
85 extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig); 85 extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig);
86 extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); 86 extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber);
87 extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all); 87 extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all);
88 extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all); 88 extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all);
89 extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); 89 extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time);
90 extern GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code); 90 extern GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code);
91 extern GSM_Error ATGEN_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status); 91 extern GSM_Error ATGEN_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status);
92 extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type); 92 extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type);
93 extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence); 93 extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence);
94 extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); 94 extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI);
95 extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s); 95 extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s);
96 extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); 96 extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo);
97 extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard); 97 extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard);
98 extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); 98 extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
99 extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features); 99 extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features);
100 extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s); 100 extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s);
101 extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type); 101 extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type);
102 102
103 extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); 103 extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
104 extern GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable);
104 extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); 105 extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable);
105 extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); 106 extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable);
106 107
107/** 108/**
108 * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table 109 * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table
109 * attempts to decode it, it is probably not complete, here are just chars 110 * attempts to decode it, it is probably not complete, here are just chars
110 * that I found... 111 * that I found...
111 */ 112 */
112unsigned char GSM_AlcatelAlphabet[] = 113unsigned char GSM_AlcatelAlphabet[] =
113{ 114{
114 /* in phone unicode description*/ 115 /* in phone unicode description*/
115 0x80, 0x00,0x20, /* empty */ 116 0x80, 0x00,0x20, /* empty */
116 0x81, 0x00,0x20, /* empty*/ 117 0x81, 0x00,0x20, /* empty*/
117 0x82, 0x00,0x20, /* empty*/ 118 0x82, 0x00,0x20, /* empty*/
118 0x83, 0x00,0x20, /* empty*/ 119 0x83, 0x00,0x20, /* empty*/
119 120
120 0x84, 0x00,0xe7, /* c cedilla*/ 121 0x84, 0x00,0xe7, /* c cedilla*/
121 0x85, 0x20,0x26, /* ... */ 122 0x85, 0x20,0x26, /* ... */
122 0x86, 0x03,0xc0, /* pi */ 123 0x86, 0x03,0xc0, /* pi */
123 0x87, 0x01,0x3e, /* l caron*/ 124 0x87, 0x01,0x3e, /* l caron*/
124 0x88, 0x00,0xc0, /* A grave*/ 125 0x88, 0x00,0xc0, /* A grave*/
125 0x89, 0x00,0xc1, /* A acute*/ 126 0x89, 0x00,0xc1, /* A acute*/
126 0x8a, 0x00,0xc2, /* A circumflex*/ 127 0x8a, 0x00,0xc2, /* A circumflex*/
127 0x8b, 0x00,0xc3, /* A tilde*/ 128 0x8b, 0x00,0xc3, /* A tilde*/
128 0x8c, 0x00,0xc8, /* E grave*/ 129 0x8c, 0x00,0xc8, /* E grave*/
129 0x8d, 0x00,0xca, /* E circumflex*/ 130 0x8d, 0x00,0xca, /* E circumflex*/
130 0x8e, 0x00,0xcb, /* E diaresis*/ 131 0x8e, 0x00,0xcb, /* E diaresis*/
131 0x8f, 0x00,0xcc, /* I grave*/ 132 0x8f, 0x00,0xcc, /* I grave*/
132 0x90, 0x00,0xcd, /* I acute*/ 133 0x90, 0x00,0xcd, /* I acute*/
133 0x91, 0x00,0xd0, /* ETH */ 134 0x91, 0x00,0xd0, /* ETH */
134 0x92, 0x00,0xd2, /* O grave*/ 135 0x92, 0x00,0xd2, /* O grave*/
135 0x93, 0x00,0xd3, /* O acute*/ 136 0x93, 0x00,0xd3, /* O acute*/
136 0x94, 0x00,0xd4, /* O circumflex*/ 137 0x94, 0x00,0xd4, /* O circumflex*/
137 0x95, 0x00,0xd5, /* O tilde*/ 138 0x95, 0x00,0xd5, /* O tilde*/
138 0x96, 0x00,0xd9, /* U grave*/ 139 0x96, 0x00,0xd9, /* U grave*/
139 0x97, 0x00,0xda, /* U acute*/ 140 0x97, 0x00,0xda, /* U acute*/
140 0x98, 0x00,0xe1, /* a acute*/ 141 0x98, 0x00,0xe1, /* a acute*/
141 0x99, 0x00,0xe2, /* a circumflex*/ 142 0x99, 0x00,0xe2, /* a circumflex*/
142 0x9a, 0x00,0xe3, /* a tilde*/ 143 0x9a, 0x00,0xe3, /* a tilde*/
143 0x9b, 0x00,0xea, /* e circumflex*/ 144 0x9b, 0x00,0xea, /* e circumflex*/
144 0x9c, 0x00,0xeb, /* e diaresis*/ 145 0x9c, 0x00,0xeb, /* e diaresis*/
145 0x9d, 0x00,0xed, /* i acute*/ 146 0x9d, 0x00,0xed, /* i acute*/
146 0x9e, 0x00,0xee, /* i circumflex*/ 147 0x9e, 0x00,0xee, /* i circumflex*/
147 0x9f, 0x00,0xef, /* i diaresis*/ 148 0x9f, 0x00,0xef, /* i diaresis*/
148 0xa0, 0x00,0xf3, /* o acute*/ 149 0xa0, 0x00,0xf3, /* o acute*/
149 0xa1, 0x00,0xf4, /* o circumflex*/ 150 0xa1, 0x00,0xf4, /* o circumflex*/
150 0xa2, 0x00,0xf5, /* o tilde*/ 151 0xa2, 0x00,0xf5, /* o tilde*/
151 0xa3, 0x00,0xfa, /* u acute*/ 152 0xa3, 0x00,0xfa, /* u acute*/
152 0xa4, 0x00,0xa2, /* cent */ 153 0xa4, 0x00,0xa2, /* cent */
153 0xa5, 0x00,0x5b, /* [ */ 154 0xa5, 0x00,0x5b, /* [ */
154 0xa6, 0x01,0x59, /* r caron*/ 155 0xa6, 0x01,0x59, /* r caron*/
155 0xa7, 0x01,0x0d, /* c caron*/ 156 0xa7, 0x01,0x0d, /* c caron*/
156 0xa8, 0x01,0x61, /* s caron*/ 157 0xa8, 0x01,0x61, /* s caron*/
157 0xa9, 0x01,0x1b, /* e caron*/ 158 0xa9, 0x01,0x1b, /* e caron*/
158 0xaa, 0x01,0x6f, /* u ring*/ 159 0xaa, 0x01,0x6f, /* u ring*/
159 0xab, 0x00,0xfd, /* y acute*/ 160 0xab, 0x00,0xfd, /* y acute*/
160 0xac, 0x00,0xf0, /* eth */ 161 0xac, 0x00,0xf0, /* eth */
161 0xad, 0x01,0x07, /* c acute*/ 162 0xad, 0x01,0x07, /* c acute*/
162 0xae, 0x01,0x19, /* e ogonek*/ 163 0xae, 0x01,0x19, /* e ogonek*/
163 0xaf, 0x01,0x05, /* a ogonek*/ 164 0xaf, 0x01,0x05, /* a ogonek*/
164 0xb0, 0x01,0x7c, /* z dot*/ 165 0xb0, 0x01,0x7c, /* z dot*/
165 0xb1, 0x01,0x7a, /* z acute*/ 166 0xb1, 0x01,0x7a, /* z acute*/
166 0xb2, 0x01,0x5b, /* s acute*/ 167 0xb2, 0x01,0x5b, /* s acute*/
167 0xb3, 0x01,0x44, /* n acute*/ 168 0xb3, 0x01,0x44, /* n acute*/
168 0xb4, 0x01,0x42, /* l stroke*/ 169 0xb4, 0x01,0x42, /* l stroke*/
169 170
170 0xb5, 0x00,0x20, /* empty*/ 171 0xb5, 0x00,0x20, /* empty*/
171 172
172 0xb6, 0x01,0x48, /* n caron*/ 173 0xb6, 0x01,0x48, /* n caron*/
173 0xb7, 0x01,0x65, /* t caron*/ 174 0xb7, 0x01,0x65, /* t caron*/
174 175
175 0xb8, 0x00,0x20, /* empty*/ 176 0xb8, 0x00,0x20, /* empty*/
176 177
177 0xb9, 0x01,0x7e, /* z caron*/ 178 0xb9, 0x01,0x7e, /* z caron*/
178 0xba, 0x01,0xe7, /* g caron*/ 179 0xba, 0x01,0xe7, /* g caron*/
179 180
180 0xbb, 0x00,0x20, /* empty*/ 181 0xbb, 0x00,0x20, /* empty*/
181 0xbc, 0x00,0x20, /* empty*/ 182 0xbc, 0x00,0x20, /* empty*/
182 183
183 0xbd, 0x1e,0x20, /* G macron*/ 184 0xbd, 0x1e,0x20, /* G macron*/
184 0xbe, 0x1e,0x21, /* g macron*/ 185 0xbe, 0x1e,0x21, /* g macron*/
185 0xbf, 0x01,0x5e, /* S cedilla*/ 186 0xbf, 0x01,0x5e, /* S cedilla*/
186 0xc0, 0x01,0x5f, /* s cedilla*/ 187 0xc0, 0x01,0x5f, /* s cedilla*/
187 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */ 188 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */
188 0xc2, 0x01,0x31, /* i dotless*/ 189 0xc2, 0x01,0x31, /* i dotless*/
189 0xc3, 0x01,0x68, /* U tilde*/ 190 0xc3, 0x01,0x68, /* U tilde*/
190 0xc4, 0x01,0x50, /* O dbl acute*/ 191 0xc4, 0x01,0x50, /* O dbl acute*/
191 0xc5, 0x01,0x69, /* u tilde*/ 192 0xc5, 0x01,0x69, /* u tilde*/
192 0xc6, 0x01,0x51, /* o dbl acute*/ 193 0xc6, 0x01,0x51, /* o dbl acute*/
193 0xc7, 0x27,0xa9, /* => */ 194 0xc7, 0x27,0xa9, /* => */
194 0xc8, 0x27,0xa8, /* filled =>*/ 195 0xc8, 0x27,0xa8, /* filled =>*/
195 0xc9, 0x00,0xd7, /* x */ 196 0xc9, 0x00,0xd7, /* x */
196 0xca, 0x00,0x5d, /* ] */ 197 0xca, 0x00,0x5d, /* ] */
197 0xcb, 0x26,0x0f, /* phone*/ 198 0xcb, 0x26,0x0f, /* phone*/
198 0xcc, 0x01,0x0f, /* d caron*/ 199 0xcc, 0x01,0x0f, /* d caron*/
199 200
200 0xcd, 0x00,0x20, /* empty*/ 201 0xcd, 0x00,0x20, /* empty*/
201 202
202 0xce, 0x00,0x7e, /* ~ */ 203 0xce, 0x00,0x7e, /* ~ */
203 0xcf, 0x00,0x5c, /* \ */ 204 0xcf, 0x00,0x5c, /* \ */
204 0xd0, 0x00,0x5e, /* ^ */ 205 0xd0, 0x00,0x5e, /* ^ */
205 206
206 0xd1, 0x00,0x20, /* empty*/ 207 0xd1, 0x00,0x20, /* empty*/
207 208
208 0xd2, 0x00,0x7b, /* { */ 209 0xd2, 0x00,0x7b, /* { */
209 0xd3, 0x00,0x7c, /* | */ 210 0xd3, 0x00,0x7c, /* | */
210 0xd4, 0x00,0x7d, /* } */ 211 0xd4, 0x00,0x7d, /* } */
211 212
212 0xd5, 0x00,0x20, /* empty*/ 213 0xd5, 0x00,0x20, /* empty*/
213 214
214 0xd6, 0x01,0x63, /* t cedilla*/ 215 0xd6, 0x01,0x63, /* t cedilla*/
215 216
216 0xd7, 0x00,0x20, /* empty*/ 217 0xd7, 0x00,0x20, /* empty*/
217 0xd8, 0x00,0x20, /* empty*/ 218 0xd8, 0x00,0x20, /* empty*/
218 0xd9, 0x00,0x20, /* empty*/ 219 0xd9, 0x00,0x20, /* empty*/
219 0xda, 0x00,0x20, /* empty*/ 220 0xda, 0x00,0x20, /* empty*/
220 0xdb, 0x00,0x20, /* empty*/ 221 0xdb, 0x00,0x20, /* empty*/
221 0xdc, 0x00,0x20, /* empty*/ 222 0xdc, 0x00,0x20, /* empty*/
222 0xdd, 0x00,0x20, /* empty*/ 223 0xdd, 0x00,0x20, /* empty*/
223 0xde, 0x00,0x20, /* empty*/ 224 0xde, 0x00,0x20, /* empty*/
224 0xdf, 0x00,0x20, /* empty*/ 225 0xdf, 0x00,0x20, /* empty*/
225 0xe0, 0x00,0x20, /* empty*/ 226 0xe0, 0x00,0x20, /* empty*/
226 227
227 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ 228 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */
228 229
229 0xe2, 0x00,0x20, /* empty*/ 230 0xe2, 0x00,0x20, /* empty*/
230 0xe3, 0x00,0x20, /* empty*/ 231 0xe3, 0x00,0x20, /* empty*/
231 0xe4, 0x00,0x20, /* empty*/ 232 0xe4, 0x00,0x20, /* empty*/
232 233
233 0xe5, 0x01,0xce, /* a caron*/ 234 0xe5, 0x01,0xce, /* a caron*/
234 0xe6, 0x01,0x01, /* a macron*/ 235 0xe6, 0x01,0x01, /* a macron*/
235 0xe7, 0x01,0x13, /* e macron*/ 236 0xe7, 0x01,0x13, /* e macron*/
236 0xe8, 0x01,0x2b, /* i macron*/ 237 0xe8, 0x01,0x2b, /* i macron*/
237 0xe9, 0x01,0x4d, /* o macron*/ 238 0xe9, 0x01,0x4d, /* o macron*/
238 0xea, 0x01,0x6b, /* u macron*/ 239 0xea, 0x01,0x6b, /* u macron*/
239 0xeb, 0x00,0x41, /* A */ 240 0xeb, 0x00,0x41, /* A */
240 0xec, 0x00,0x40, /* @ */ 241 0xec, 0x00,0x40, /* @ */
241 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ 242 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */
242 243
243 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ 244 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */
244 0xef, 0x00,0x20, /* big key*/ /* FIXME */ 245 0xef, 0x00,0x20, /* big key*/ /* FIXME */
245 246
246 0xf0, 0x00,0x20, /* empty*/ 247 0xf0, 0x00,0x20, /* empty*/
247 248
248 0xf1, 0x00,0x31, /* 1 */ 249 0xf1, 0x00,0x31, /* 1 */
249 0xf2, 0x00,0x21, /* bold !*/ 250 0xf2, 0x00,0x21, /* bold !*/
250 0xf3, 0x26,0x0e, /* black phone*/ 251 0xf3, 0x26,0x0e, /* black phone*/
251 0xf4, 0x00,0x26, /* & */ 252 0xf4, 0x00,0x26, /* & */
252 0xf5, 0x23,0x7e, /* bell */ 253 0xf5, 0x23,0x7e, /* bell */
253 0xf6, 0x26,0x6a, /* note */ 254 0xf6, 0x26,0x6a, /* note */
254 255
255 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ 256 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */
256 0xf8, 0x27,0x13, /* okay */ 257 0xf8, 0x27,0x13, /* okay */
257 258
258 0xf9, 0x00,0x20, /* empty*/ 259 0xf9, 0x00,0x20, /* empty*/
259 260
260 0xfa, 0x00,0x20, /* key */ /* FIXME */ 261 0xfa, 0x00,0x20, /* key */ /* FIXME */
261 262
262 0xfb, 0x00,0x20, /* empty*/ 263 0xfb, 0x00,0x20, /* empty*/
263 264
264 0xfc, 0x20,0xac, /* Euro */ 265 0xfc, 0x20,0xac, /* Euro */
265 0xfd, 0x21,0x97, /* NE arrow*/ 266 0xfd, 0x21,0x97, /* NE arrow*/
266 0xfe, 0x21,0x98, /* SE arrow*/ 267 0xfe, 0x21,0x98, /* SE arrow*/
267 268
268 0xff, 0x00,0x20, /* empty*/ 269 0xff, 0x00,0x20, /* empty*/
269 270
270 0x00, 0x00,0x00 271 0x00, 0x00,0x00
271}; 272};
272 273
273/* This is being called from atgen */ 274/* This is being called from atgen */
274 GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 275 GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
275{ 276{
276 char *str, *str2; 277 char *str, *str2;
277/* 278/*
278 * Reply received here looks like: 279 * Reply received here looks like:
279 * 1 "AT+CPROT=?" 280 * 1 "AT+CPROT=?"
280 * 2 "+CPROT: 0,"V1.0",1" 281 * 2 "+CPROT: 0,"V1.0",1"
281 * 3 "+CPROT: 16,"V1.1",16" 282 * 3 "+CPROT: 16,"V1.1",16"
282 * 4 "OK" 283 * 4 "OK"
283 */ 284 */
284 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 285 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
285 case AT_Reply_OK: 286 case AT_Reply_OK:
286 str = strstr(msg.Buffer, "\"V"); 287 str = strstr(msg.Buffer, "\"V");
287 if (str == NULL) return ERR_UNKNOWNRESPONSE; 288 if (str == NULL) return ERR_UNKNOWNRESPONSE;
288 str += 2; 289 str += 2;
289 while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2; 290 while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2;
290 if (strncmp(str, "1.0", 3) == 0) { 291 if (strncmp(str, "1.0", 3) == 0) {
291 s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0; 292 s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0;
292 } else if (strncmp(str, "1.1", 3) == 0) { 293 } else if (strncmp(str, "1.1", 3) == 0) {
293 s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1; 294 s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1;
294 } else { 295 } else {
295 smprintf(s, "Unknown protocol version. Please send debug log and phone info to author.\n"); 296 smprintf(s, "Unknown protocol version. Please send debug log and phone info to author.\n");
296 return ERR_NOTIMPLEMENTED; 297 return ERR_NOTIMPLEMENTED;
297 } 298 }
298 return ERR_NONE; 299 return ERR_NONE;
299 case AT_Reply_Error: 300 case AT_Reply_Error:
300 case AT_Reply_CMSError: 301 case AT_Reply_CMSError:
301 return ATGEN_HandleCMSError(s); 302 return ATGEN_HandleCMSError(s);
302 default: 303 default:
303 return ERR_UNKNOWNRESPONSE; 304 return ERR_UNKNOWNRESPONSE;
304 } 305 }
305} 306}
306 307
307static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) 308static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
308{ 309{
309 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 310 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
310 GSM_Error error; 311 GSM_Error error;
311 312
312 if (Priv->Mode == ModeBinary) return ERR_NONE; 313 if (Priv->Mode == ModeBinary) return ERR_NONE;
313 314
314 dbgprintf ("Changing to binary mode\n"); 315 dbgprintf ("Changing to binary mode\n");
315 316
316 error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl); 317 error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl);
317 if (error != ERR_NONE) return error; 318 if (error != ERR_NONE) return error;
318 319
319 error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol); 320 error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol);
320 if (error != ERR_NONE) return error; 321 if (error != ERR_NONE) return error;
321 322
322 if (Priv->ProtocolVersion == V_1_0) { 323 if (Priv->ProtocolVersion == V_1_0) {
323 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect); 324 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect);
324 } else { 325 } else {
325 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect); 326 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect);
326 } 327 }
327 328
328 if (error == ERR_TIMEOUT && s->Speed != 19200) { 329 if (error == ERR_TIMEOUT && s->Speed != 19200) {
329 smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n"); 330 smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n");
330 } 331 }
331 332
332 if (error != ERR_NONE) return error; 333 if (error != ERR_NONE) return error;
333 334
334 dbgprintf ("Changing protocol to Alcabus\n"); 335 dbgprintf ("Changing protocol to Alcabus\n");
335 336
336 s->Protocol.Functions = &ALCABUSProtocol; 337 s->Protocol.Functions = &ALCABUSProtocol;
337 error = s->Protocol.Functions->Initialise(s); 338 error = s->Protocol.Functions->Initialise(s);
338 if (error != ERR_NONE) { 339 if (error != ERR_NONE) {
339 s->Protocol.Functions = &ATProtocol; 340 s->Protocol.Functions = &ATProtocol;
340 return error; 341 return error;
341 } 342 }
342 s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; 343 s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions;
343 Priv->Mode = ModeBinary; 344 Priv->Mode = ModeBinary;
344 Priv->BinaryItem = 0; 345 Priv->BinaryItem = 0;
345 Priv->BinaryType = 0; 346 Priv->BinaryType = 0;
346 Priv->BinaryState = StateAttached; 347 Priv->BinaryState = StateAttached;
347 return ERR_NONE; 348 return ERR_NONE;
348} 349}
349 350
350static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) { 351static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) {
351 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 352 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
352 GSM_Error error; 353 GSM_Error error;
353 unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20}; 354 unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20};
354 unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00}; 355 unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00};
355 unsigned char start_buffer[] = 356 unsigned char start_buffer[] =
356 {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */ 357 {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */
357 0x12, 0x34, 0x56, 0x78}; 358 0x12, 0x34, 0x56, 0x78};
358 unsigned char end_buffer[] = 359 unsigned char end_buffer[] =
359 {0x00, 0x04, 0x7C, 0x82, 360 {0x00, 0x04, 0x7C, 0x82,
360 0x00, /* type */ 361 0x00, /* type */
361 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */ 362 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */
362 unsigned char close_buffer[] = 363 unsigned char close_buffer[] =
363 {0x00, 0x04, 364 {0x00, 0x04,
364 0x00, /*type */ 365 0x00, /*type */
365 0x23, 0x01}; 366 0x23, 0x01};
366 unsigned char select1_buffer[] = 367 unsigned char select1_buffer[] =
367 {0x00, 0x00, 368 {0x00, 0x00,
368 0x00, /*type */ 369 0x00, /*type */
369 0x20}; 370 0x20};
370 unsigned char select2_buffer[] = 371 unsigned char select2_buffer[] =
371 {0x00, 0x04, 372 {0x00, 0x04,
372 0x00, /*type */ 373 0x00, /*type */
373 0x22, 0x01, 0x00}; 374 0x22, 0x01, 0x00};
374 unsigned char begin_buffer[] = 375 unsigned char begin_buffer[] =
375 {0x00, 0x04, 0x7C, 0x81, 376 {0x00, 0x04, 0x7C, 0x81,
376 0x00, /*type */ 377 0x00, /*type */
377 0x00, 0x85, 0x00}; 378 0x00, 0x85, 0x00};
378 unsigned char commit_buffer[] = 379 unsigned char commit_buffer[] =
379 {0x00, 0x04, 380 {0x00, 0x04,
380 0x00, /*type */ 381 0x00, /*type */
381 0x20, 0x01}; 382 0x20, 0x01};
382 383
383 smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item); 384 smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item);
384 error = ALCATEL_SetBinaryMode(s); 385 error = ALCATEL_SetBinaryMode(s);
385 if (error != ERR_NONE) return error; 386 if (error != ERR_NONE) return error;
386 387
387 /* Do we need to do anything? */ 388 /* Do we need to do anything? */
388 if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE; 389 if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE;
389 390
390 /* We're editing, but the next state is not the same. so commit editing */ 391 /* We're editing, but the next state is not the same. so commit editing */
391 if (Priv->BinaryState == StateEdit) { 392 if (Priv->BinaryState == StateEdit) {
392 /* Something has changed, we will have to reread fields! */ 393 /* Something has changed, we will have to reread fields! */
393 Priv->CurrentFieldsItem = -1; 394 Priv->CurrentFieldsItem = -1;
394 switch (Priv->BinaryType) { 395 switch (Priv->BinaryType) {
395 case TypeCalendar: 396 case TypeCalendar:
396 commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 397 commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
397 break; 398 break;
398 case TypeContacts: 399 case TypeContacts:
399 commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 400 commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
400 break; 401 break;
401 case TypeToDo: 402 case TypeToDo:
402 commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO; 403 commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO;
403 break; 404 break;
404 } 405 }
405 dbgprintf ("Commiting edited record\n"); 406 dbgprintf ("Commiting edited record\n");
406 error=GSM_WaitFor (s, commit_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelCommit); 407 error=GSM_WaitFor (s, commit_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelCommit);
407 if (error != ERR_NONE) return error; 408 if (error != ERR_NONE) return error;
408 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2); 409 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2);
409 if (error != ERR_NONE) return error; 410 if (error != ERR_NONE) return error;
410 Priv->BinaryState = StateSession; 411 Priv->BinaryState = StateSession;
411 Priv->BinaryItem = 0; 412 Priv->BinaryItem = 0;
412 } 413 }
413 414
414 /* Do we want to edit something of same type? */ 415 /* Do we want to edit something of same type? */
415 if ((state == StateEdit) && (type == Priv->BinaryType)) { 416 if ((state == StateEdit) && (type == Priv->BinaryType)) {
416 /* Edit state doesn't need any switching, it is needed only for 417 /* Edit state doesn't need any switching, it is needed only for
417 * indication that e have to commit record before we switch to other 418 * indication that e have to commit record before we switch to other
418 * mode. 419 * mode.
419 */ 420 */
420 Priv->BinaryState = StateEdit; 421 Priv->BinaryState = StateEdit;
421 Priv->BinaryItem = item; 422 Priv->BinaryItem = item;
422 return ERR_NONE; 423 return ERR_NONE;
423 } 424 }
424 425
425 /* Now we can be only in Attached or Session state, so if states and types matches, just keep them as they are */ 426 /* Now we can be only in Attached or Session state, so if states and types matches, just keep them as they are */
426 if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) { 427 if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) {
427 return ERR_NONE; 428 return ERR_NONE;
428 } 429 }
429 430
430 /* Do we need to close session? */ 431 /* Do we need to close session? */
431 if (Priv->BinaryState == StateSession) { 432 if (Priv->BinaryState == StateSession) {
432 dbgprintf ("Ending session\n"); 433 dbgprintf ("Ending session\n");
433 switch (Priv->BinaryType) { 434 switch (Priv->BinaryType) {
434 case TypeCalendar: 435 case TypeCalendar:
435 end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; 436 end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR;
436 break; 437 break;
437 case TypeContacts: 438 case TypeContacts:
438 end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; 439 end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS;
439 break; 440 break;
440 case TypeToDo: 441 case TypeToDo:
441 end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; 442 end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO;
442 break; 443 break;
443 } 444 }
444 error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd); 445 error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd);
445 if (error != ERR_NONE) return error; 446 if (error != ERR_NONE) return error;
446 447
447 switch (Priv->BinaryType) { 448 switch (Priv->BinaryType) {
448 case TypeCalendar: 449 case TypeCalendar:
449 close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 450 close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
450 break; 451 break;
451 case TypeContacts: 452 case TypeContacts:
452 close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 453 close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
453 break; 454 break;
454 case TypeToDo: 455 case TypeToDo:
455 close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; 456 close_buffer[2] = ALCATEL_SYNC_TYPE_TODO;
456 break; 457 break;
457 } 458 }
458 dbgprintf ("Closing session\n"); 459 dbgprintf ("Closing session\n");
459 error=GSM_WaitFor (s, close_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelClose); 460 error=GSM_WaitFor (s, close_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelClose);
460 if (error != ERR_NONE) return error; 461 if (error != ERR_NONE) return error;
461 462
462 dbgprintf ("Detaching binary mode\n"); 463 dbgprintf ("Detaching binary mode\n");
463 GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach); 464 GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach);
464 465
465 Priv->BinaryState = StateAttached; 466 Priv->BinaryState = StateAttached;
466 Priv->BinaryType = 0; 467 Priv->BinaryType = 0;
467 } 468 }
468 469
469 /* Do we need to open session? */ 470 /* Do we need to open session? */
470 if (state == StateSession || state == StateEdit) { 471 if (state == StateSession || state == StateEdit) {
471 dbgprintf ("Starting session for %s\n", 472 dbgprintf ("Starting session for %s\n",
472 (type == TypeCalendar ? "Calendar" : 473 (type == TypeCalendar ? "Calendar" :
473 (type == TypeToDo ? "Todo" : 474 (type == TypeToDo ? "Todo" :
474 (type == TypeContacts ? "Contacts" : 475 (type == TypeContacts ? "Contacts" :
475 "Unknown!")))); 476 "Unknown!"))));
476 /* Fill up buffers */ 477 /* Fill up buffers */
477 switch (type) { 478 switch (type) {
478 case TypeCalendar: 479 case TypeCalendar:
479 select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 480 select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
480 select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 481 select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
481 begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; 482 begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR;
482 break; 483 break;
483 case TypeContacts: 484 case TypeContacts:
484 select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 485 select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
485 select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 486 select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
486 begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; 487 begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS;
487 break; 488 break;
488 case TypeToDo: 489 case TypeToDo:
489 select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO; 490 select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO;
490 select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO; 491 select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO;
491 begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; 492 begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO;
492 break; 493 break;
493 } 494 }
494 dbgprintf ("Attaching in binary mode\n"); 495 dbgprintf ("Attaching in binary mode\n");
@@ -499,185 +500,187 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
499 500
500 smprintf(s,"Start session\n"); 501 smprintf(s,"Start session\n");
501 error=GSM_WaitFor (s, start_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelStart); 502 error=GSM_WaitFor (s, start_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelStart);
502 if (error != ERR_NONE) return error; 503 if (error != ERR_NONE) return error;
503 504
504 smprintf(s,"Select type\n"); 505 smprintf(s,"Select type\n");
505 error=GSM_WaitFor (s, select1_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect1); 506 error=GSM_WaitFor (s, select1_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect1);
506 if (error != ERR_NONE) return error; 507 if (error != ERR_NONE) return error;
507 error=GSM_WaitFor (s, select2_buffer, 6, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect2); 508 error=GSM_WaitFor (s, select2_buffer, 6, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect2);
508 if (error != ERR_NONE) return error; 509 if (error != ERR_NONE) return error;
509 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); 510 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3);
510 if (error != ERR_NONE) return error; 511 if (error != ERR_NONE) return error;
511 512
512 smprintf(s,"Begin transfer\n"); 513 smprintf(s,"Begin transfer\n");
513 error=GSM_WaitFor (s, begin_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelBegin1); 514 error=GSM_WaitFor (s, begin_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelBegin1);
514 if (error != ERR_NONE) return error; 515 if (error != ERR_NONE) return error;
515 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); 516 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2);
516 if (error != ERR_NONE) return error; 517 if (error != ERR_NONE) return error;
517 518
518 Priv->BinaryState = StateSession; 519 Priv->BinaryState = StateSession;
519 Priv->BinaryType = type; 520 Priv->BinaryType = type;
520 /* Do we want to edit something of same type? */ 521 /* Do we want to edit something of same type? */
521 if ((state == StateEdit) && (type == Priv->BinaryType)) { 522 if ((state == StateEdit) && (type == Priv->BinaryType)) {
522 Priv->BinaryState = StateEdit; 523 Priv->BinaryState = StateEdit;
523 Priv->BinaryItem = item; 524 Priv->BinaryItem = item;
524 return ERR_NONE; 525 return ERR_NONE;
525 } 526 }
526 } 527 }
527 return ERR_NONE; 528 return ERR_NONE;
528} 529}
529 530
530static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) 531static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s)
531{ 532{
532 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 533 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
533 GSM_Error error; 534 GSM_Error error;
534 535
535 if (Priv->Mode == ModeAT) return ERR_NONE; 536 if (Priv->Mode == ModeAT) return ERR_NONE;
536 537
537 error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); 538 error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0);
538 if (error != ERR_NONE) return error; 539 if (error != ERR_NONE) return error;
539 540
540 error = s->Protocol.Functions->Terminate(s); 541 error = s->Protocol.Functions->Terminate(s);
541 if (error != ERR_NONE) return error; 542 if (error != ERR_NONE) return error;
542 543
543 dbgprintf ("Changing protocol to AT\n"); 544 dbgprintf ("Changing protocol to AT\n");
544 s->Protocol.Functions = &ATProtocol; 545 s->Protocol.Functions = &ATProtocol;
545 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; 546 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions;
546 Priv->Mode = ModeAT; 547 Priv->Mode = ModeAT;
548 s->Phone.Data.Priv.ATGEN.PBKCharset= 0;
549 s->Phone.Data.Priv.ATGEN.PBKMemory= 0;
547 550
548 my_sleep(100); 551 my_sleep(100);
549 552
550 /* In case we don't send AT command short after closing binary mode, 553 /* In case we don't send AT command short after closing binary mode,
551 * phone takes VERY long to react next time. The error code in 554 * phone takes VERY long to react next time. The error code in
552 * intetionally ignored. 555 * intetionally ignored.
553 */ 556 */
554 GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); 557 GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame);
555 558
556 return ERR_NONE; 559 return ERR_NONE;
557} 560}
558 561
559static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) 562static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s)
560{ 563{
561 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 564 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
562 GSM_Error error; 565 GSM_Error error;
563 566
564 Priv->Mode = ModeAT; 567 Priv->Mode = ModeAT;
565 568
566 Priv->CalendarItems = NULL; 569 Priv->CalendarItems = NULL;
567 Priv->ContactsItems = NULL; 570 Priv->ContactsItems = NULL;
568 Priv->ToDoItems = NULL; 571 Priv->ToDoItems = NULL;
569 Priv->CalendarItemsCount = 0; 572 Priv->CalendarItemsCount = 0;
570 Priv->ToDoItemsCount = 0; 573 Priv->ToDoItemsCount = 0;
571 Priv->ContactsItemsCount = 0; 574 Priv->ContactsItemsCount = 0;
572 Priv->CurrentFields[0] = 0; 575 Priv->CurrentFields[0] = 0;
573 Priv->CurrentFieldsCount = 0; 576 Priv->CurrentFieldsCount = 0;
574 Priv->CurrentFieldsItem = 0; 577 Priv->CurrentFieldsItem = 0;
575 Priv->CurrentFieldsType = 0; 578 Priv->CurrentFieldsType = 0;
576 Priv->ProtocolVersion = V_1_0; 579 Priv->ProtocolVersion = V_1_0;
577 Priv->CurrentFieldsItem = -1; 580 Priv->CurrentFieldsItem = -1;
578 581
579 Priv->CurrentCategoriesCount = 0; 582 Priv->CurrentCategoriesCount = 0;
580 Priv->CurrentCategoriesType = 0; 583 Priv->CurrentCategoriesType = 0;
581 584
582 s->Protocol.Functions = &ATProtocol; 585 s->Protocol.Functions = &ATProtocol;
583 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; 586 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions;
584 587
585 if (ATGEN_Initialise(s) != ERR_NONE || GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame) != ERR_NONE) { 588 if (ATGEN_Initialise(s) != ERR_NONE || GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame) != ERR_NONE) {
586 smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); 589 smprintf(s,"AT initialisation failed, trying to stop binary mode...\n");
587 s->Protocol.Functions = &ALCABUSProtocol; 590 s->Protocol.Functions = &ALCABUSProtocol;
588 error = s->Protocol.Functions->Terminate(s); 591 error = s->Protocol.Functions->Terminate(s);
589 s->Protocol.Functions = &ATProtocol; 592 s->Protocol.Functions = &ATProtocol;
590 593
591 error = ATGEN_Initialise(s); 594 error = ATGEN_Initialise(s);
592 if (error != ERR_NONE) return error; 595 if (error != ERR_NONE) return error;
593 } 596 }
594 597
595 return ERR_NONE; 598 return ERR_NONE;
596} 599}
597 600
598static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s) 601static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s)
599{ 602{
600 GSM_Error error; 603 GSM_Error error;
601 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 604 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
602 605
603 free(Priv->CalendarItems); 606 free(Priv->CalendarItems);
604 free(Priv->ContactsItems); 607 free(Priv->ContactsItems);
605 free(Priv->ToDoItems); 608 free(Priv->ToDoItems);
606 error = ALCATEL_SetATMode(s); 609 error = ALCATEL_SetATMode(s);
607 return ATGEN_Terminate(s); 610 return ATGEN_Terminate(s);
608} 611}
609 612
610/* finds whether id is set in the phone */ 613/* finds whether id is set in the phone */
611static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { 614static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
612 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 615 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
613 int i; 616 int i;
614 617
615 if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION; 618 if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION;
616 619
617 switch (Priv->BinaryType) { 620 switch (Priv->BinaryType) {
618 case TypeCalendar: 621 case TypeCalendar:
619 Priv->CurrentList = &(Priv->CalendarItems); 622 Priv->CurrentList = &(Priv->CalendarItems);
620 Priv->CurrentCount = &(Priv->CalendarItemsCount); 623 Priv->CurrentCount = &(Priv->CalendarItemsCount);
621 break; 624 break;
622 case TypeContacts: 625 case TypeContacts:
623 Priv->CurrentList = &(Priv->ContactsItems); 626 Priv->CurrentList = &(Priv->ContactsItems);
624 Priv->CurrentCount = &(Priv->ContactsItemsCount); 627 Priv->CurrentCount = &(Priv->ContactsItemsCount);
625 break; 628 break;
626 case TypeToDo: 629 case TypeToDo:
627 Priv->CurrentList = &(Priv->ToDoItems); 630 Priv->CurrentList = &(Priv->ToDoItems);
628 Priv->CurrentCount = &(Priv->ToDoItemsCount); 631 Priv->CurrentCount = &(Priv->ToDoItemsCount);
629 break; 632 break;
630 } 633 }
631 634
632 for (i=0; i<*Priv->CurrentCount; i++) { 635 for (i=0; i<*Priv->CurrentCount; i++) {
633 if ((*Priv->CurrentList)[i] == id) return ERR_NONE; 636 if ((*Priv->CurrentList)[i] == id) return ERR_NONE;
634 } 637 }
635 638
636 return ERR_EMPTY; 639 return ERR_EMPTY;
637} 640}
638 641
639/* finds next id that is available in the phone */ 642/* finds next id that is available in the phone */
640static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { 643static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) {
641 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 644 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
642 int i = 0; 645 int i = 0;
643 int next = ALCATEL_MAX_LOCATION; 646 int next = ALCATEL_MAX_LOCATION;
644 647
645 switch (Priv->BinaryType) { 648 switch (Priv->BinaryType) {
646 case TypeCalendar: 649 case TypeCalendar:
647 Priv->CurrentList = &(Priv->CalendarItems); 650 Priv->CurrentList = &(Priv->CalendarItems);
648 Priv->CurrentCount = &(Priv->CalendarItemsCount); 651 Priv->CurrentCount = &(Priv->CalendarItemsCount);
649 break; 652 break;
650 case TypeContacts: 653 case TypeContacts:
651 Priv->CurrentList = &(Priv->ContactsItems); 654 Priv->CurrentList = &(Priv->ContactsItems);
652 Priv->CurrentCount = &(Priv->ContactsItemsCount); 655 Priv->CurrentCount = &(Priv->ContactsItemsCount);
653 break; 656 break;
654 case TypeToDo: 657 case TypeToDo:
655 Priv->CurrentList = &(Priv->ToDoItems); 658 Priv->CurrentList = &(Priv->ToDoItems);
656 Priv->CurrentCount = &(Priv->ToDoItemsCount); 659 Priv->CurrentCount = &(Priv->ToDoItemsCount);
657 break; 660 break;
658 } 661 }
659 662
660 for (i=0; i<*Priv->CurrentCount; i++) { 663 for (i=0; i<*Priv->CurrentCount; i++) {
661 if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) { 664 if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) {
662 next = (*Priv->CurrentList)[i]; 665 next = (*Priv->CurrentList)[i];
663 } 666 }
664 } 667 }
665 if (next == ALCATEL_MAX_LOCATION) { 668 if (next == ALCATEL_MAX_LOCATION) {
666 return ERR_EMPTY; 669 return ERR_EMPTY;
667 } else { 670 } else {
668 *id = next; 671 *id = next;
669 return ERR_NONE; 672 return ERR_NONE;
670 } 673 }
671} 674}
672 675
673static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s) 676static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s)
674{ 677{
675 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; 678 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
676 int count,i,pos; 679 int count,i,pos;
677 680
678 count = msg.Buffer[10]; 681 count = msg.Buffer[10];
679 *Priv->CurrentCount += count; 682 *Priv->CurrentCount += count;
680 683
681 *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int)); 684 *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int));
682 if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY; 685 if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY;
683 686
@@ -801,97 +804,97 @@ static GSM_Error ALCATEL_GetFields(GSM_StateMachine *s, int id) {
801 case TypeContacts: 804 case TypeContacts:
802 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 805 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
803 break; 806 break;
804 case TypeToDo: 807 case TypeToDo:
805 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 808 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
806 break; 809 break;
807 } 810 }
808 811
809 Priv->CurrentFieldsItem = id; 812 Priv->CurrentFieldsItem = id;
810 Priv->CurrentFieldsType = Priv->BinaryType; 813 Priv->CurrentFieldsType = Priv->BinaryType;
811 814
812 error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1); 815 error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1);
813 if (error != ERR_NONE) return error; 816 if (error != ERR_NONE) return error;
814 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2); 817 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2);
815 if (error != ERR_NONE) return error; 818 if (error != ERR_NONE) return error;
816 819
817 i = 0; 820 i = 0;
818 smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount); 821 smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount);
819 for (i=0; i < Priv->CurrentFieldsCount; i++) { 822 for (i=0; i < Priv->CurrentFieldsCount; i++) {
820 smprintf(s,"%x ", Priv->CurrentFields[i]); 823 smprintf(s,"%x ", Priv->CurrentFields[i]);
821 } 824 }
822 smprintf(s,"\n"); 825 smprintf(s,"\n");
823 826
824 return ERR_NONE; 827 return ERR_NONE;
825} 828}
826 829
827static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s) 830static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s)
828{ 831{
829 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; 832 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
830 unsigned char *buffer = &(msg.Buffer[16]); 833 unsigned char *buffer = &(msg.Buffer[16]);
831 834
832 if (buffer[1] == 0x05 && buffer[2] == 0x67) { 835 if (buffer[1] == 0x05 && buffer[2] == 0x67) {
833 /* date */ 836 /* date */
834 Priv->ReturnType = Alcatel_date; 837 Priv->ReturnType = Alcatel_date;
835 Priv->ReturnDateTime.Day= buffer[4]; 838 Priv->ReturnDateTime.Day= buffer[4];
836 Priv->ReturnDateTime.Month= buffer[5]; 839 Priv->ReturnDateTime.Month= buffer[5];
837 Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); 840 Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8);
838 Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ 841 Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */
839 842
840 Priv->ReturnDateTime.Hour= 0; 843 Priv->ReturnDateTime.Hour= 0;
841 Priv->ReturnDateTime.Minute= 0; 844 Priv->ReturnDateTime.Minute= 0;
842 Priv->ReturnDateTime.Second= 0; 845 Priv->ReturnDateTime.Second= 0;
843 } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { 846 } else if (buffer[1] == 0x06 && buffer[2] == 0x68) {
844 /* time */ 847 /* time */
845 Priv->ReturnType = Alcatel_time; 848 Priv->ReturnType = Alcatel_time;
846 Priv->ReturnDateTime.Hour= buffer[4]; 849 Priv->ReturnDateTime.Hour= buffer[4];
847 Priv->ReturnDateTime.Minute= buffer[5]; 850 Priv->ReturnDateTime.Minute= buffer[5];
848 Priv->ReturnDateTime.Second= buffer[6]; 851 Priv->ReturnDateTime.Second= buffer[6];
849 852
850 Priv->ReturnDateTime.Day= 0; 853 Priv->ReturnDateTime.Day= 0;
851 Priv->ReturnDateTime.Month= 0; 854 Priv->ReturnDateTime.Month= 0;
852 Priv->ReturnDateTime.Year= 0; 855 Priv->ReturnDateTime.Year= 0;
853 Priv->ReturnDateTime.Timezone= 0; 856 Priv->ReturnDateTime.Timezone= 0;
854 } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { 857 } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) {
855 /* string */ 858 /* string */
856 Priv->ReturnType = Alcatel_string; 859 Priv->ReturnType = Alcatel_string;
857 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) 860 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3])
858 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); 861 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1);
859 if (Priv->ProtocolVersion == V_1_0) { 862 if (Priv->ProtocolVersion == V_1_0) {
860 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); 863 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet);
861 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { 864 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) {
862 memcpy(Priv->ReturnString, buffer + 5, buffer[3]); 865 memcpy(Priv->ReturnString, buffer + 5, buffer[3]);
863 Priv->ReturnString[buffer[3] + 1] = 0; 866 Priv->ReturnString[buffer[3] + 1] = 0;
864 Priv->ReturnString[buffer[3] + 2] = 0; 867 Priv->ReturnString[buffer[3] + 2] = 0;
865 ReverseUnicodeString(Priv->ReturnString); 868 ReverseUnicodeString(Priv->ReturnString);
866 } else { 869 } else {
867 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); 870 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet);
868 } 871 }
869 } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) { 872 } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) {
870 /* phone */ 873 /* phone */
871 Priv->ReturnType = Alcatel_phone; 874 Priv->ReturnType = Alcatel_phone;
872 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) 875 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3])
873 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); 876 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1);
874 if (Priv->ProtocolVersion == V_1_0) { 877 if (Priv->ProtocolVersion == V_1_0) {
875 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); 878 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet);
876 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { 879 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) {
877 memcpy(Priv->ReturnString, buffer + 5, buffer[3]); 880 memcpy(Priv->ReturnString, buffer + 5, buffer[3]);
878 Priv->ReturnString[buffer[3] + 1] = 0; 881 Priv->ReturnString[buffer[3] + 1] = 0;
879 Priv->ReturnString[buffer[3] + 2] = 0; 882 Priv->ReturnString[buffer[3] + 2] = 0;
880 ReverseUnicodeString(Priv->ReturnString); 883 ReverseUnicodeString(Priv->ReturnString);
881 } else { 884 } else {
882 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); 885 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet);
883 } 886 }
884 } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) { 887 } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) {
885 /* boolean */ 888 /* boolean */
886 Priv->ReturnType = Alcatel_bool; 889 Priv->ReturnType = Alcatel_bool;
887 Priv->ReturnInt = buffer[3]; 890 Priv->ReturnInt = buffer[3];
888 } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) { 891 } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) {
889 /* integer */ 892 /* integer */
890 Priv->ReturnType = Alcatel_int; 893 Priv->ReturnType = Alcatel_int;
891 Priv->ReturnInt = buffer[6] + (buffer[5] << 8) + (buffer[4] << 16) + (buffer[3] << 24); 894 Priv->ReturnInt = buffer[6] + (buffer[5] << 8) + (buffer[4] << 16) + (buffer[3] << 24);
892 } else if (buffer[1] == 0x04 && buffer[2] == 0x38) { 895 } else if (buffer[1] == 0x04 && buffer[2] == 0x38) {
893 /* enumeration */ 896 /* enumeration */
894 Priv->ReturnType = Alcatel_enum; 897 Priv->ReturnType = Alcatel_enum;
895 Priv->ReturnInt = buffer[3]; 898 Priv->ReturnInt = buffer[3];
896 } else if (buffer[1] == 0x00 && buffer[2] == 0x38) { 899 } else if (buffer[1] == 0x00 && buffer[2] == 0x38) {
897 /* byte */ 900 /* byte */
@@ -1051,216 +1054,216 @@ static GSM_Error ALCATEL_AddCategoryText(GSM_StateMachine *s, const unsigned cha
1051 case TypeContacts: 1054 case TypeContacts:
1052 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1055 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1053 buffer[4] = ALCATEL_LIST_CONTACTS_CAT; 1056 buffer[4] = ALCATEL_LIST_CONTACTS_CAT;
1054 break; 1057 break;
1055 case TypeToDo: 1058 case TypeToDo:
1056 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1059 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1057 buffer[4] = ALCATEL_LIST_TODO_CAT; 1060 buffer[4] = ALCATEL_LIST_TODO_CAT;
1058 break; 1061 break;
1059 default: 1062 default:
1060 return ERR_NOTSUPPORTED; 1063 return ERR_NOTSUPPORTED;
1061 } 1064 }
1062 1065
1063 error=GSM_WaitFor (s, buffer, 8 + len, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText1); 1066 error=GSM_WaitFor (s, buffer, 8 + len, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText1);
1064 if (error != ERR_NONE) return error; 1067 if (error != ERR_NONE) return error;
1065 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2); 1068 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2);
1066 if (error != ERR_NONE) return error; 1069 if (error != ERR_NONE) return error;
1067 1070
1068 /* Refresh list */ 1071 /* Refresh list */
1069 Priv->CurrentCategoriesType = 0; 1072 Priv->CurrentCategoriesType = 0;
1070 return ALCATEL_GetAvailableCategoryIds(s); 1073 return ALCATEL_GetAvailableCategoryIds(s);
1071} 1074}
1072 1075
1073static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) 1076static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s)
1074{ 1077{
1075 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; 1078 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
1076 int len; 1079 int len;
1077 1080
1078 len = msg.Buffer[14]; 1081 len = msg.Buffer[14];
1079 if (len > GSM_MAX_CATEGORY_NAME_LENGTH) { 1082 if (len > GSM_MAX_CATEGORY_NAME_LENGTH) {
1080 smprintf(s, "WARNING: Category name truncated, you should increase GSM_MAX_CATEGORY_NAME_LENGTH to at least %d\n", len); 1083 smprintf(s, "WARNING: Category name truncated, you should increase GSM_MAX_CATEGORY_NAME_LENGTH to at least %d\n", len);
1081 } 1084 }
1082 if (Priv->ProtocolVersion == V_1_0) { 1085 if (Priv->ProtocolVersion == V_1_0) {
1083 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); 1086 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet);
1084 } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) { 1087 } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) {
1085 memcpy(Priv->ReturnString, msg.Buffer + 16, len); 1088 memcpy(Priv->ReturnString, msg.Buffer + 16, len);
1086 Priv->ReturnString[len + 1] = 0; 1089 Priv->ReturnString[len + 1] = 0;
1087 Priv->ReturnString[len + 2] = 0; 1090 Priv->ReturnString[len + 2] = 0;
1088 ReverseUnicodeString(Priv->ReturnString); 1091 ReverseUnicodeString(Priv->ReturnString);
1089 } else { 1092 } else {
1090 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); 1093 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet);
1091 } 1094 }
1092 return ERR_NONE; 1095 return ERR_NONE;
1093} 1096}
1094 1097
1095static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { 1098static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
1096 unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ }; 1099 unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ };
1097 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1100 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1098 GSM_Error error; 1101 GSM_Error error;
1099 1102
1100 if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { 1103 if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') {
1101 CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); 1104 CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]);
1102 return ERR_NONE; 1105 return ERR_NONE;
1103 } 1106 }
1104 1107
1105 smprintf(s,"Reading category %d\n", id); 1108 smprintf(s,"Reading category %d\n", id);
1106 1109
1107 switch (Priv->BinaryType) { 1110 switch (Priv->BinaryType) {
1108 case TypeContacts: 1111 case TypeContacts:
1109 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1112 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1110 buffer[4] = ALCATEL_LIST_CONTACTS_CAT; 1113 buffer[4] = ALCATEL_LIST_CONTACTS_CAT;
1111 break; 1114 break;
1112 case TypeToDo: 1115 case TypeToDo:
1113 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1116 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1114 buffer[4] = ALCATEL_LIST_TODO_CAT; 1117 buffer[4] = ALCATEL_LIST_TODO_CAT;
1115 break; 1118 break;
1116 default: 1119 default:
1117 return ERR_NOTSUPPORTED; 1120 return ERR_NOTSUPPORTED;
1118 } 1121 }
1119 1122
1120 buffer[7] = (id & 0xff); 1123 buffer[7] = (id & 0xff);
1121 1124
1122 error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); 1125 error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1);
1123 if (error != ERR_NONE) return error; 1126 if (error != ERR_NONE) return error;
1124 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); 1127 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2);
1125 if (error != ERR_NONE) return error; 1128 if (error != ERR_NONE) return error;
1126 1129
1127 CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); 1130 CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString);
1128 1131
1129 return ERR_NONE; 1132 return ERR_NONE;
1130} 1133}
1131 1134
1132static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { 1135static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) {
1133 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1136 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1134 GSM_Error error; 1137 GSM_Error error;
1135 unsigned char buffer[] = 1138 unsigned char buffer[] =
1136 {0x00, 0x04, 1139 {0x00, 0x04,
1137 0x00, /* type */ 1140 0x00, /* type */
1138 0x26, 0x01, 1141 0x26, 0x01,
1139 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ 1142 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */
1140 0x65, 0x01, 1143 0x65, 0x01,
1141 0x00, /* field */ 1144 0x00, /* field */
1142 0x01}; 1145 0x01};
1143 1146
1144 smprintf(s,"Deleting field (%08x.%02x)\n", id, field); 1147 smprintf(s,"Deleting field (%08x.%02x)\n", id, field);
1145 1148
1146 switch (Priv->BinaryType) { 1149 switch (Priv->BinaryType) {
1147 case TypeCalendar: 1150 case TypeCalendar:
1148 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1151 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1149 break; 1152 break;
1150 case TypeContacts: 1153 case TypeContacts:
1151 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1154 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1152 break; 1155 break;
1153 case TypeToDo: 1156 case TypeToDo:
1154 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1157 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1155 break; 1158 break;
1156 } 1159 }
1157 1160
1158 buffer[5] = (id >> 24); 1161 buffer[5] = (id >> 24);
1159 buffer[6] = ((id >> 16) & 0xff); 1162 buffer[6] = ((id >> 16) & 0xff);
1160 buffer[7] = ((id >> 8) & 0xff); 1163 buffer[7] = ((id >> 8) & 0xff);
1161 buffer[8] = (id & 0xff); 1164 buffer[8] = (id & 0xff);
1162 buffer[11] = (field & 0xff); 1165 buffer[11] = (field & 0xff);
1163 1166
1164 error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField); 1167 error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField);
1165 if (error != ERR_NONE) return error; 1168 if (error != ERR_NONE) return error;
1166 1169
1167 return ERR_NONE; 1170 return ERR_NONE;
1168} 1171}
1169 1172
1170static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) { 1173static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) {
1171 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1174 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1172 GSM_Error error; 1175 GSM_Error error;
1173 unsigned char buffer[] = 1176 unsigned char buffer[] =
1174 {0x00, 0x04, 1177 {0x00, 0x04,
1175 0x00, /* type */ 1178 0x00, /* type */
1176 0x27, 0x01, 1179 0x27, 0x01,
1177 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ 1180 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */
1178 0x42}; 1181 0x42};
1179 1182
1180 smprintf(s,"Deleting item (%08x)\n", id); 1183 smprintf(s,"Deleting item (%08x)\n", id);
1181 1184
1182 switch (Priv->BinaryType) { 1185 switch (Priv->BinaryType) {
1183 case TypeCalendar: 1186 case TypeCalendar:
1184 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1187 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1185 break; 1188 break;
1186 case TypeContacts: 1189 case TypeContacts:
1187 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1190 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1188 break; 1191 break;
1189 case TypeToDo: 1192 case TypeToDo:
1190 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1193 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1191 break; 1194 break;
1192 } 1195 }
1193 1196
1194 buffer[5] = (id >> 24); 1197 buffer[5] = (id >> 24);
1195 buffer[6] = ((id >> 16) & 0xff); 1198 buffer[6] = ((id >> 16) & 0xff);
1196 buffer[7] = ((id >> 8) & 0xff); 1199 buffer[7] = ((id >> 8) & 0xff);
1197 buffer[8] = (id & 0xff); 1200 buffer[8] = (id & 0xff);
1198 1201
1199 error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1); 1202 error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1);
1200 if (error != ERR_NONE) return error; 1203 if (error != ERR_NONE) return error;
1201 1204
1202 error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2); 1205 error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2);
1203 if (error != ERR_NONE) return error; 1206 if (error != ERR_NONE) return error;
1204 1207
1205 return ERR_NONE; 1208 return ERR_NONE;
1206} 1209}
1207 1210
1208static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) 1211static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s)
1209{ 1212{
1210 if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; 1213 if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE;
1211 return ERR_NONE; 1214 return ERR_NONE;
1212} 1215}
1213 1216
1214static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { 1217static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) {
1215 int len; 1218 int len;
1216 1219
1217 buffer[1] = field & 0xff; 1220 buffer[1] = field & 0xff;
1218 1221
1219 switch(type) { 1222 switch(type) {
1220 case Alcatel_date: 1223 case Alcatel_date:
1221 if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; 1224 if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME;
1222 1225
1223 buffer[3] = 0x05; 1226 buffer[3] = 0x05;
1224 buffer[4] = 0x67; 1227 buffer[4] = 0x67;
1225 1228
1226 buffer[0] = 0x09; 1229 buffer[0] = 0x09;
1227 buffer[5] = 0x04; 1230 buffer[5] = 0x04;
1228 buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; 1231 buffer[6] = ((GSM_DateTime *)data)->Day & 0xff;
1229 buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; 1232 buffer[7] = ((GSM_DateTime *)data)->Month & 0xff;
1230 buffer[8] = ((GSM_DateTime *)data)->Year >> 8; 1233 buffer[8] = ((GSM_DateTime *)data)->Year >> 8;
1231 buffer[9] = ((GSM_DateTime *)data)->Year & 0xff; 1234 buffer[9] = ((GSM_DateTime *)data)->Year & 0xff;
1232 buffer[10] = 0x00; 1235 buffer[10] = 0x00;
1233 break; 1236 break;
1234 case Alcatel_time: 1237 case Alcatel_time:
1235 if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; 1238 if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME;
1236 1239
1237 buffer[3] = 0x06; 1240 buffer[3] = 0x06;
1238 buffer[4] = 0x68; 1241 buffer[4] = 0x68;
1239 1242
1240 buffer[0] = 0x08; 1243 buffer[0] = 0x08;
1241 buffer[5] = 0x03; 1244 buffer[5] = 0x03;
1242 buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff; 1245 buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff;
1243 buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff; 1246 buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff;
1244 buffer[8] = ((GSM_DateTime *)data)->Second & 0xff; 1247 buffer[8] = ((GSM_DateTime *)data)->Second & 0xff;
1245 buffer[9] = 0x00; 1248 buffer[9] = 0x00;
1246 break; 1249 break;
1247 case Alcatel_string: 1250 case Alcatel_string:
1248 buffer[3] = 0x08; 1251 buffer[3] = 0x08;
1249 buffer[4] = 0x3c; 1252 buffer[4] = 0x3c;
1250 1253
1251 len = MIN(UnicodeLength((char *)data),62); 1254 len = MIN(UnicodeLength((char *)data),62);
1252 EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); 1255 EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet);
1253 buffer[5] = len; 1256 buffer[5] = len;
1254 buffer[0] = 5 + len; 1257 buffer[0] = 5 + len;
1255 buffer[6 + len] = 0x00; 1258 buffer[6 + len] = 0x00;
1256 break; 1259 break;
1257 case Alcatel_phone: 1260 case Alcatel_phone:
1258 buffer[3] = 0x07; 1261 buffer[3] = 0x07;
1259 buffer[4] = 0x3c; 1262 buffer[4] = 0x3c;
1260 1263
1261 len = MIN(UnicodeLength((char *)data),50); 1264 len = MIN(UnicodeLength((char *)data),50);
1262 EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); 1265 EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet);
1263 buffer[5] = len; 1266 buffer[5] = len;
1264 buffer[0] = 5 + len; 1267 buffer[0] = 5 + len;
1265 buffer[6 + len] = 0x00; 1268 buffer[6 + len] = 0x00;
1266 break; 1269 break;
@@ -1284,140 +1287,140 @@ static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_Fi
1284 buffer[3] = 0x02; 1287 buffer[3] = 0x02;
1285 buffer[4] = 0x3a; 1288 buffer[4] = 0x3a;
1286 1289
1287 buffer[0] = 0x08; 1290 buffer[0] = 0x08;
1288 buffer[5] = *(unsigned int *)data >> 24; 1291 buffer[5] = *(unsigned int *)data >> 24;
1289 buffer[6] = (*(unsigned int *)data >> 16) & 0xff; 1292 buffer[6] = (*(unsigned int *)data >> 16) & 0xff;
1290 buffer[7] = (*(unsigned int *)data >> 8) & 0xff; 1293 buffer[7] = (*(unsigned int *)data >> 8) & 0xff;
1291 buffer[8] = *(unsigned int *)data & 0xff; 1294 buffer[8] = *(unsigned int *)data & 0xff;
1292 buffer[9] = 0x00; 1295 buffer[9] = 0x00;
1293 break; 1296 break;
1294 case Alcatel_byte: 1297 case Alcatel_byte:
1295 buffer[3] = 0x00; 1298 buffer[3] = 0x00;
1296 buffer[4] = 0x38; 1299 buffer[4] = 0x38;
1297 1300
1298 buffer[0] = 0x05; 1301 buffer[0] = 0x05;
1299 buffer[5] = *(int *)data & 0xff; 1302 buffer[5] = *(int *)data & 0xff;
1300 buffer[6] = 0x00; 1303 buffer[6] = 0x00;
1301 break; 1304 break;
1302 } 1305 }
1303 return ERR_NONE; 1306 return ERR_NONE;
1304} 1307}
1305 1308
1306static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) { 1309static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) {
1307 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1310 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1308 GSM_Error error; 1311 GSM_Error error;
1309 unsigned char buffer[200] = 1312 unsigned char buffer[200] =
1310 {0x00, 0x04, 1313 {0x00, 0x04,
1311 0x00, /* type */ 1314 0x00, /* type */
1312 0x25, 0x01, 0x65, 1315 0x25, 0x01, 0x65,
1313 0x00, /* length of remaining part */ 1316 0x00, /* length of remaining part */
1314 0x00, /* field */ 1317 0x00, /* field */
1315 0x37}; /* data follows here */ 1318 0x37}; /* data follows here */
1316 1319
1317 smprintf(s,"Creating field (%02x)\n", field); 1320 smprintf(s,"Creating field (%02x)\n", field);
1318 1321
1319 switch (Priv->BinaryType) { 1322 switch (Priv->BinaryType) {
1320 case TypeCalendar: 1323 case TypeCalendar:
1321 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1324 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1322 break; 1325 break;
1323 case TypeContacts: 1326 case TypeContacts:
1324 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1327 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1325 break; 1328 break;
1326 case TypeToDo: 1329 case TypeToDo:
1327 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1330 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1328 break; 1331 break;
1329 } 1332 }
1330 error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); 1333 error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data);
1331 if (error != ERR_NONE) return error; 1334 if (error != ERR_NONE) return error;
1332 1335
1333 error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField); 1336 error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField);
1334 if (error != ERR_NONE) return error; 1337 if (error != ERR_NONE) return error;
1335 1338
1336 return ERR_NONE; 1339 return ERR_NONE;
1337} 1340}
1338 1341
1339static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { 1342static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) {
1340 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1343 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1341 GSM_Error error; 1344 GSM_Error error;
1342 unsigned char buffer[200] = 1345 unsigned char buffer[200] =
1343 {0x00, 0x04, 1346 {0x00, 0x04,
1344 0x00, /* type */ 1347 0x00, /* type */
1345 0x26, 0x01, 1348 0x26, 0x01,
1346 0x00, 0x00, 0x00, 0x00,/* id */ 1349 0x00, 0x00, 0x00, 0x00,/* id */
1347 0x65, 1350 0x65,
1348 0x00, /* length of remaining part */ 1351 0x00, /* length of remaining part */
1349 0x00, /* field */ 1352 0x00, /* field */
1350 0x37}; /* data follows here */ 1353 0x37}; /* data follows here */
1351 1354
1352 smprintf(s,"Updating field (%08x.%02x)\n", id, field); 1355 smprintf(s,"Updating field (%08x.%02x)\n", id, field);
1353 1356
1354 buffer[5] = (id >> 24); 1357 buffer[5] = (id >> 24);
1355 buffer[6] = ((id >> 16) & 0xff); 1358 buffer[6] = ((id >> 16) & 0xff);
1356 buffer[7] = ((id >> 8) & 0xff); 1359 buffer[7] = ((id >> 8) & 0xff);
1357 buffer[8] = (id & 0xff); 1360 buffer[8] = (id & 0xff);
1358 1361
1359 switch (Priv->BinaryType) { 1362 switch (Priv->BinaryType) {
1360 case TypeCalendar: 1363 case TypeCalendar:
1361 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1364 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1362 break; 1365 break;
1363 case TypeContacts: 1366 case TypeContacts:
1364 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1367 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1365 break; 1368 break;
1366 case TypeToDo: 1369 case TypeToDo:
1367 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1370 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1368 break; 1371 break;
1369 } 1372 }
1370 error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); 1373 error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data);
1371 if (error != ERR_NONE) return error; 1374 if (error != ERR_NONE) return error;
1372 1375
1373 error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField); 1376 error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField);
1374 if (error != ERR_NONE) return error; 1377 if (error != ERR_NONE) return error;
1375 1378
1376 return ERR_NONE; 1379 return ERR_NONE;
1377} 1380}
1378 1381
1379static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) 1382static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s)
1380{ 1383{
1381 strcpy(s->Phone.Data.Manufacturer, "Alcatel"); 1384 strcpy(s->Phone.Data.Manufacturer, "Alcatel");
1382 return ERR_NONE; 1385 return ERR_NONE;
1383} 1386}
1384 1387
1385static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) 1388static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s)
1386{ 1389{
1387 GSM_Error error; 1390 GSM_Error error;
1388 1391
1389 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1392 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1390 return ATGEN_GetIMEI(s); 1393 return ATGEN_GetIMEI(s);
1391} 1394}
1392 1395
1393static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s) 1396static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s)
1394{ 1397{
1395 GSM_Error error; 1398 GSM_Error error;
1396 1399
1397 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1400 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1398 return ATGEN_GetFirmware(s); 1401 return ATGEN_GetFirmware(s);
1399} 1402}
1400 1403
1401static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s) 1404static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s)
1402{ 1405{
1403 GSM_Error error; 1406 GSM_Error error;
1404 1407
1405 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1408 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1406 return ATGEN_GetModel(s); 1409 return ATGEN_GetModel(s);
1407} 1410}
1408 1411
1409static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 1412static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
1410{ 1413{
1411 GSM_Error error; 1414 GSM_Error error;
1412 1415
1413 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1416 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1414 return ATGEN_GetDateTime(s, date_time); 1417 return ATGEN_GetDateTime(s, date_time);
1415} 1418}
1416 1419
1417static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1420static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1418{ 1421{
1419 GSM_Error error; 1422 GSM_Error error;
1420 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1423 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1421 int i; 1424 int i;
1422 int j = 0; 1425 int j = 0;
1423 1426
@@ -1698,427 +1701,427 @@ static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1698 entry->Entries[i - j].EntryType = PBK_PictureID; 1701 entry->Entries[i - j].EntryType = PBK_PictureID;
1699 entry->Entries[i - j].Number = Priv->ReturnInt; 1702 entry->Entries[i - j].Number = Priv->ReturnInt;
1700 } else { 1703 } else {
1701 entry->EntriesNum--; 1704 entry->EntriesNum--;
1702 j++; 1705 j++;
1703 } 1706 }
1704 break; 1707 break;
1705 default: 1708 default:
1706 entry->EntriesNum--; 1709 entry->EntriesNum--;
1707 j++; 1710 j++;
1708 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); 1711 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType);
1709 switch (Priv->ReturnType) { 1712 switch (Priv->ReturnType) {
1710 case Alcatel_date: 1713 case Alcatel_date:
1711 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); 1714 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year);
1712 break; 1715 break;
1713 case Alcatel_time: 1716 case Alcatel_time:
1714 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); 1717 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second);
1715 break; 1718 break;
1716 case Alcatel_string: 1719 case Alcatel_string:
1717 case Alcatel_phone: 1720 case Alcatel_phone:
1718 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); 1721 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString));
1719 break; 1722 break;
1720 case Alcatel_enum: 1723 case Alcatel_enum:
1721 case Alcatel_bool: 1724 case Alcatel_bool:
1722 case Alcatel_int: 1725 case Alcatel_int:
1723 case Alcatel_byte: 1726 case Alcatel_byte:
1724 smprintf(s, "%d", Priv->ReturnInt); 1727 smprintf(s, "%d", Priv->ReturnInt);
1725 break; 1728 break;
1726 } 1729 }
1727 smprintf(s,"\n"); 1730 smprintf(s,"\n");
1728 } 1731 }
1729 } 1732 }
1730 return ERR_NONE; 1733 return ERR_NONE;
1731 } else { 1734 } else {
1732 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1735 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1733 return ATGEN_GetMemory(s, entry); 1736 return ATGEN_GetMemory(s, entry);
1734 } 1737 }
1735} 1738}
1736 1739
1737static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) 1740static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start)
1738{ 1741{
1739 GSM_Error error; 1742 GSM_Error error;
1740 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1743 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1741 1744
1742 if (entry->MemoryType == MEM_ME) { 1745 if (entry->MemoryType == MEM_ME) {
1743 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1746 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1744 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 1747 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
1745 if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; 1748 if (Priv->ContactsItemsCount == 0) return ERR_EMPTY;
1746 1749
1747 if (start) entry->Location = 0; 1750 if (start) entry->Location = 0;
1748 if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; 1751 if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error;
1749 1752
1750 return ALCATEL_GetMemory(s, entry); 1753 return ALCATEL_GetMemory(s, entry);
1751 } else { 1754 } else {
1752 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1755 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1753 return ATGEN_GetNextMemory(s, entry, start); 1756 return ATGEN_GetNextMemory(s, entry, start);
1754 } 1757 }
1755} 1758}
1756 1759
1757static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1760static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1758{ 1761{
1759 GSM_Error error; 1762 GSM_Error error;
1760 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1763 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1761 int NamePosition = -1; 1764 int NamePosition = -1;
1762 bool NameSet = false; 1765 bool NameSet = false;
1763 int i; 1766 int i;
1764 1767
1765 1768
1766 if (entry->MemoryType == MEM_ME) { 1769 if (entry->MemoryType == MEM_ME) {
1767 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1770 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1768 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error; 1771 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error;
1769 for (i = 0; i < entry->EntriesNum; i++) { 1772 for (i = 0; i < entry->EntriesNum; i++) {
1770 switch (entry->Entries[i].EntryType) { 1773 switch (entry->Entries[i].EntryType) {
1771 case PBK_Number_General: 1774 case PBK_Number_General:
1772 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error; 1775 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
1773 break; 1776 break;
1774 case PBK_Number_Mobile: 1777 case PBK_Number_Mobile:
1775 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error; 1778 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
1776 break; 1779 break;
1777 case PBK_Number_Work: 1780 case PBK_Number_Work:
1778 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error; 1781 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
1779 break; 1782 break;
1780 case PBK_Number_Fax: 1783 case PBK_Number_Fax:
1781 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error; 1784 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
1782 break; 1785 break;
1783 case PBK_Number_Home: 1786 case PBK_Number_Home:
1784 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error; 1787 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
1785 break; 1788 break;
1786 case PBK_Number_Pager: 1789 case PBK_Number_Pager:
1787 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error; 1790 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error;
1788 break; 1791 break;
1789 case PBK_Number_Other: 1792 case PBK_Number_Other:
1790 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error; 1793 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
1791 break; 1794 break;
1792 case PBK_Text_Note: 1795 case PBK_Text_Note:
1793 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, entry->Entries[i].Text)) != ERR_NONE) return error; 1796 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, entry->Entries[i].Text)) != ERR_NONE) return error;
1794 break; 1797 break;
1795 case PBK_Text_Email: 1798 case PBK_Text_Email:
1796 if ((error = ALCATEL_CreateField(s, Alcatel_string, 14, entry->Entries[i].Text)) != ERR_NONE) return error; 1799 if ((error = ALCATEL_CreateField(s, Alcatel_string, 14, entry->Entries[i].Text)) != ERR_NONE) return error;
1797 break; 1800 break;
1798 case PBK_Text_Email2: 1801 case PBK_Text_Email2:
1799 if ((error = ALCATEL_CreateField(s, Alcatel_string, 15, entry->Entries[i].Text)) != ERR_NONE) return error; 1802 if ((error = ALCATEL_CreateField(s, Alcatel_string, 15, entry->Entries[i].Text)) != ERR_NONE) return error;
1800 break; 1803 break;
1801 case PBK_Text_LastName: 1804 case PBK_Text_LastName:
1802 if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error; 1805 if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error;
1803 NameSet = true; 1806 NameSet = true;
1804 break; 1807 break;
1805 case PBK_Text_FirstName: 1808 case PBK_Text_FirstName:
1806 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; 1809 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error;
1807 NameSet = true; 1810 NameSet = true;
1808 break; 1811 break;
1809 case PBK_Text_Company: 1812 case PBK_Text_Company:
1810 if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error; 1813 if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
1811 break; 1814 break;
1812 case PBK_Text_JobTitle: 1815 case PBK_Text_JobTitle:
1813 if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error; 1816 if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error;
1814 break; 1817 break;
1815 case PBK_Category: 1818 case PBK_Category:
1816 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1819 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1817 break; 1820 break;
1818 case PBK_Private: 1821 case PBK_Private:
1819 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1822 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1820 break; 1823 break;
1821 case PBK_Text_StreetAddress: 1824 case PBK_Text_StreetAddress:
1822 if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error; 1825 if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
1823 break; 1826 break;
1824 case PBK_Text_City: 1827 case PBK_Text_City:
1825 if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error; 1828 if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
1826 break; 1829 break;
1827 case PBK_Text_State: 1830 case PBK_Text_State:
1828 if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error; 1831 if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
1829 break; 1832 break;
1830 case PBK_Text_Zip: 1833 case PBK_Text_Zip:
1831 if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error; 1834 if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
1832 break; 1835 break;
1833 case PBK_Text_Country: 1836 case PBK_Text_Country:
1834 if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error; 1837 if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error;
1835 break; 1838 break;
1836 case PBK_Text_Custom1: 1839 case PBK_Text_Custom1:
1837 if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error; 1840 if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error;
1838 break; 1841 break;
1839 case PBK_Text_Custom2: 1842 case PBK_Text_Custom2:
1840 if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error; 1843 if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error;
1841 break; 1844 break;
1842 case PBK_Text_Custom3: 1845 case PBK_Text_Custom3:
1843 if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; 1846 if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
1844 break; 1847 break;
1845 case PBK_Text_Custom4: 1848 case PBK_Text_Custom4:
1846 if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error; 1849 if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error;
1847 break; 1850 break;
1848 case PBK_PictureID: 1851 case PBK_PictureID:
1849 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 1852 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
1850 if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1853 if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1851 } else { 1854 } else {
1852 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 1855 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
1853 } 1856 }
1854 break; 1857 break;
1855 1858
1856 case PBK_Text_Name: NamePosition = i; break; 1859 case PBK_Text_Name: NamePosition = i; break;
1857 /* Following fields are not supported: */ 1860 /* Following fields are not supported: */
1858 case PBK_Text_UserID: 1861 case PBK_Text_UserID:
1859 case PBK_SMSListID: 1862 case PBK_SMSListID:
1860 case PBK_RingtoneFileSystemID: 1863 case PBK_RingtoneFileSystemID:
1861 case PBK_Date: 1864 case PBK_Date:
1862 case PBK_Caller_Group: 1865 case PBK_Caller_Group:
1863 case PBK_RingtoneID: 1866 case PBK_RingtoneID:
1864 case PBK_Text_Postal: 1867 case PBK_Text_Postal:
1865 case PBK_Text_URL: 1868 case PBK_Text_URL:
1866 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 1869 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
1867 break; 1870 break;
1868 } 1871 }
1869 } 1872 }
1870 if (NamePosition != -1) { 1873 if (NamePosition != -1) {
1871 if (NameSet) { 1874 if (NameSet) {
1872 smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); 1875 smprintf(s,"WARNING: Ignoring name, not supported by phone\n");
1873 } else { 1876 } else {
1874 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; 1877 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error;
1875 } 1878 }
1876 } 1879 }
1877 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1880 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1878 entry->Location = Priv->CommitedRecord; 1881 entry->Location = Priv->CommitedRecord;
1879 /* Refresh list */ 1882 /* Refresh list */
1880 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 1883 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
1881 return ERR_NONE; 1884 return ERR_NONE;
1882 } else { 1885 } else {
1883 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1886 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1884 return ATGEN_AddMemory(s, entry); 1887 return ATGEN_AddMemory(s, entry);
1885 } 1888 }
1886} 1889}
1887 1890
1888static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1891static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1889{ 1892{
1890 GSM_Error error; 1893 GSM_Error error;
1891 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1894 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1892 int NamePosition = -1; 1895 int NamePosition = -1;
1893 bool NameSet = false; 1896 bool NameSet = false;
1894 int i; 1897 int i;
1895 bool UpdatedFields[26]; 1898 bool UpdatedFields[26];
1896 1899
1897 if (entry->Location == 0) return ERR_INVALIDLOCATION; 1900 if (entry->Location == 0) return ERR_INVALIDLOCATION;
1898 1901
1899 if (entry->MemoryType == MEM_ME) { 1902 if (entry->MemoryType == MEM_ME) {
1900 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1903 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1901 /* Save modified entry */ 1904 /* Save modified entry */
1902 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 1905 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
1903 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { 1906 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) {
1904 /* Entry doesn't exist, we will create new one */ 1907 /* Entry doesn't exist, we will create new one */
1905 return ALCATEL_AddMemory(s, entry); 1908 return ALCATEL_AddMemory(s, entry);
1906 } 1909 }
1907 /* Get fields for current item */ 1910 /* Get fields for current item */
1908 if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; 1911 if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error;
1909 1912
1910 for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } 1913 for (i = 0; i < 26; i++) { UpdatedFields[i] = false; }
1911 1914
1912 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error; 1915 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error;
1913 for (i = 0; i < entry->EntriesNum; i++) { 1916 for (i = 0; i < entry->EntriesNum; i++) {
1914 switch (entry->Entries[i].EntryType) { 1917 switch (entry->Entries[i].EntryType) {
1915 case PBK_Number_General: 1918 case PBK_Number_General:
1916 UpdatedFields[8] = true; 1919 UpdatedFields[8] = true;
1917 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; 1920 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
1918 break; 1921 break;
1919 case PBK_Number_Mobile: 1922 case PBK_Number_Mobile:
1920 UpdatedFields[12] = true; 1923 UpdatedFields[12] = true;
1921 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; 1924 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
1922 break; 1925 break;
1923 case PBK_Number_Work: 1926 case PBK_Number_Work:
1924 UpdatedFields[7] = true; 1927 UpdatedFields[7] = true;
1925 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; 1928 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
1926 break; 1929 break;
1927 case PBK_Number_Fax: 1930 case PBK_Number_Fax:
1928 UpdatedFields[9] = true; 1931 UpdatedFields[9] = true;
1929 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; 1932 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
1930 break; 1933 break;
1931 case PBK_Number_Home: 1934 case PBK_Number_Home:
1932 UpdatedFields[13] = true; 1935 UpdatedFields[13] = true;
1933 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; 1936 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
1934 break; 1937 break;
1935 case PBK_Number_Pager: 1938 case PBK_Number_Pager:
1936 UpdatedFields[11] = true; 1939 UpdatedFields[11] = true;
1937 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error; 1940 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error;
1938 break; 1941 break;
1939 case PBK_Number_Other: 1942 case PBK_Number_Other:
1940 UpdatedFields[10] = true; 1943 UpdatedFields[10] = true;
1941 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; 1944 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
1942 break; 1945 break;
1943 case PBK_Text_Note: 1946 case PBK_Text_Note:
1944 UpdatedFields[4] = true; 1947 UpdatedFields[4] = true;
1945 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; 1948 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error;
1946 break; 1949 break;
1947 case PBK_Text_Email: 1950 case PBK_Text_Email:
1948 UpdatedFields[14] = true; 1951 UpdatedFields[14] = true;
1949 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error; 1952 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error;
1950 break; 1953 break;
1951 case PBK_Text_Email2: 1954 case PBK_Text_Email2:
1952 UpdatedFields[15] = true; 1955 UpdatedFields[15] = true;
1953 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; 1956 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error;
1954 break; 1957 break;
1955 case PBK_Text_LastName: 1958 case PBK_Text_LastName:
1956 UpdatedFields[0] = true; 1959 UpdatedFields[0] = true;
1957 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; 1960 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
1958 break; 1961 break;
1959 case PBK_Text_FirstName: 1962 case PBK_Text_FirstName:
1960 UpdatedFields[1] = true; 1963 UpdatedFields[1] = true;
1961 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; 1964 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
1962 break; 1965 break;
1963 case PBK_Text_Company: 1966 case PBK_Text_Company:
1964 UpdatedFields[2] = true; 1967 UpdatedFields[2] = true;
1965 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; 1968 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
1966 break; 1969 break;
1967 case PBK_Text_JobTitle: 1970 case PBK_Text_JobTitle:
1968 UpdatedFields[3] = true; 1971 UpdatedFields[3] = true;
1969 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error; 1972 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error;
1970 break; 1973 break;
1971 case PBK_Category: 1974 case PBK_Category:
1972 UpdatedFields[5] = true; 1975 UpdatedFields[5] = true;
1973 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1976 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1974 break; 1977 break;
1975 case PBK_Private: 1978 case PBK_Private:
1976 UpdatedFields[6] = true; 1979 UpdatedFields[6] = true;
1977 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1980 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1978 break; 1981 break;
1979 case PBK_Text_StreetAddress: 1982 case PBK_Text_StreetAddress:
1980 UpdatedFields[16] = true; 1983 UpdatedFields[16] = true;
1981 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; 1984 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
1982 break; 1985 break;
1983 case PBK_Text_City: 1986 case PBK_Text_City:
1984 UpdatedFields[17] = true; 1987 UpdatedFields[17] = true;
1985 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; 1988 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
1986 break; 1989 break;
1987 case PBK_Text_State: 1990 case PBK_Text_State:
1988 UpdatedFields[18] = true; 1991 UpdatedFields[18] = true;
1989 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; 1992 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
1990 break; 1993 break;
1991 case PBK_Text_Zip: 1994 case PBK_Text_Zip:
1992 UpdatedFields[19] = true; 1995 UpdatedFields[19] = true;
1993 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; 1996 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
1994 break; 1997 break;
1995 case PBK_Text_Country: 1998 case PBK_Text_Country:
1996 UpdatedFields[20] = true; 1999 UpdatedFields[20] = true;
1997 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error; 2000 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error;
1998 break; 2001 break;
1999 case PBK_Text_Custom1: 2002 case PBK_Text_Custom1:
2000 UpdatedFields[21] = true; 2003 UpdatedFields[21] = true;
2001 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error; 2004 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error;
2002 break; 2005 break;
2003 case PBK_Text_Custom2: 2006 case PBK_Text_Custom2:
2004 UpdatedFields[22] = true; 2007 UpdatedFields[22] = true;
2005 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error; 2008 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error;
2006 break; 2009 break;
2007 case PBK_Text_Custom3: 2010 case PBK_Text_Custom3:
2008 UpdatedFields[23] = true; 2011 UpdatedFields[23] = true;
2009 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error; 2012 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
2010 break; 2013 break;
2011 case PBK_Text_Custom4: 2014 case PBK_Text_Custom4:
2012 UpdatedFields[24] = true; 2015 UpdatedFields[24] = true;
2013 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error 2016 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error
2014 ; break; 2017 ; break;
2015 case PBK_PictureID: 2018 case PBK_PictureID:
2016 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 2019 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
2017 UpdatedFields[25] = true; 2020 UpdatedFields[25] = true;
2018 if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; 2021 if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error;
2019 } else { 2022 } else {
2020 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 2023 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
2021 } 2024 }
2022 break; 2025 break;
2023 2026
2024 case PBK_Text_Name: NamePosition = i; break; 2027 case PBK_Text_Name: NamePosition = i; break;
2025 /* Following fields are not supported: */ 2028 /* Following fields are not supported: */
2026 case PBK_SMSListID: 2029 case PBK_SMSListID:
2027 case PBK_Text_UserID: 2030 case PBK_Text_UserID:
2028 case PBK_RingtoneFileSystemID: 2031 case PBK_RingtoneFileSystemID:
2029 case PBK_Date: 2032 case PBK_Date:
2030 case PBK_Caller_Group: 2033 case PBK_Caller_Group:
2031 case PBK_RingtoneID: 2034 case PBK_RingtoneID:
2032 case PBK_Text_Postal: 2035 case PBK_Text_Postal:
2033 case PBK_Text_URL: 2036 case PBK_Text_URL:
2034 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 2037 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
2035 break; 2038 break;
2036 } 2039 }
2037 } 2040 }
2038 if (NamePosition != -1) { 2041 if (NamePosition != -1) {
2039 if (NameSet) { 2042 if (NameSet) {
2040 smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); 2043 smprintf(s,"WARNING: Ignoring name, not supported by phone\n");
2041 } else { 2044 } else {
2042 UpdatedFields[1] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; 2045 UpdatedFields[1] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error;
2043 } 2046 }
2044 } 2047 }
2045 /* If we didn't update some field, we have to delete it... */ 2048 /* If we didn't update some field, we have to delete it... */
2046 for (i=0; i<Priv->CurrentFieldsCount; i++) { 2049 for (i=0; i<Priv->CurrentFieldsCount; i++) {
2047 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, entry->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; 2050 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, entry->Location, Priv->CurrentFields[i])) != ERR_NONE) return error;
2048 } 2051 }
2049 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2052 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2050 entry->Location = Priv->CommitedRecord; 2053 entry->Location = Priv->CommitedRecord;
2051 return ERR_NONE; 2054 return ERR_NONE;
2052 } else { 2055 } else {
2053 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2056 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2054 return ATGEN_SetMemory(s, entry); 2057 return ATGEN_SetMemory(s, entry);
2055 } 2058 }
2056} 2059}
2057 2060
2058static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 2061static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2059{ 2062{
2060 GSM_Error error; 2063 GSM_Error error;
2061 2064
2062 if (entry->MemoryType == MEM_ME) { 2065 if (entry->MemoryType == MEM_ME) {
2063 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2066 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2064 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2067 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2065 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { 2068 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) {
2066 /* Entry was empty => no error */ 2069 /* Entry was empty => no error */
2067 return ERR_NONE; 2070 return ERR_NONE;
2068 } 2071 }
2069 /* Do real delete */ 2072 /* Do real delete */
2070 error = ALCATEL_DeleteItem(s, entry->Location); 2073 error = ALCATEL_DeleteItem(s, entry->Location);
2071 if (error != ERR_NONE) return error; 2074 if (error != ERR_NONE) return error;
2072 2075
2073 /* Refresh list */ 2076 /* Refresh list */
2074 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2077 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2075 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2078 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2076 2079
2077 return ERR_NONE; 2080 return ERR_NONE;
2078 } else { 2081 } else {
2079 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2082 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2080 return ATGEN_DeleteMemory(s, entry); 2083 return ATGEN_DeleteMemory(s, entry);
2081 } 2084 }
2082} 2085}
2083 2086
2084static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) 2087static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type)
2085{ 2088{
2086 GSM_Error error; 2089 GSM_Error error;
2087 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2090 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2088 int i; 2091 int i;
2089 2092
2090 if (type == MEM_ME) { 2093 if (type == MEM_ME) {
2091 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2094 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2092 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2095 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2093 2096
2094 for (i=0; i<Priv->ContactsItemsCount; i++) { 2097 for (i=0; i<Priv->ContactsItemsCount; i++) {
2095 error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]); 2098 error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]);
2096 if (error != ERR_NONE) return error; 2099 if (error != ERR_NONE) return error;
2097 } 2100 }
2098 2101
2099 /* Refresh list */ 2102 /* Refresh list */
2100 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2103 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2101 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2104 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2102 2105
2103 return ERR_NONE; 2106 return ERR_NONE;
2104 } else { 2107 } else {
2105 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2108 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2106 return ATGEN_DeleteAllMemory(s, type); 2109 return ATGEN_DeleteAllMemory(s, type);
2107 } 2110 }
2108} 2111}
2109 2112
2110static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 2113static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
2111{ 2114{
2112 GSM_Error error; 2115 GSM_Error error;
2113 2116
2114 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2117 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2115 return ATGEN_GetSMSC(s, smsc); 2118 return ATGEN_GetSMSC(s, smsc);
2116} 2119}
2117 2120
2118 2121
2119static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 2122static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
2120{ 2123{
2121 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; 2124 GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
2122 GSM_Error error; 2125 GSM_Error error;
2123 2126
2124 if (Status->MemoryType == MEM_ME) { 2127 if (Status->MemoryType == MEM_ME) {
@@ -2183,97 +2186,97 @@ static GSM_Error ALCATEL_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *fold
2183 2186
2184static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) 2187static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
2185{ 2188{
2186 GSM_Error error; 2189 GSM_Error error;
2187 2190
2188 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2191 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2189 return ATGEN_GetNextSMS(s, sms, start); 2192 return ATGEN_GetNextSMS(s, sms, start);
2190} 2193}
2191 2194
2192static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) 2195static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
2193{ 2196{
2194 GSM_Error error; 2197 GSM_Error error;
2195 2198
2196 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2199 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2197 return ATGEN_GetSMSStatus(s, status); 2200 return ATGEN_GetSMSStatus(s, status);
2198} 2201}
2199 2202
2200static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 2203static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
2201{ 2204{
2202 GSM_Error error; 2205 GSM_Error error;
2203 2206
2204 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2207 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2205 return ATGEN_DialVoice(s, number, ShowNumber); 2208 return ATGEN_DialVoice(s, number, ShowNumber);
2206} 2209}
2207 2210
2208static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all) 2211static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all)
2209{ 2212{
2210 GSM_Error error; 2213 GSM_Error error;
2211 2214
2212 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2215 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2213 return ATGEN_AnswerCall(s,ID,all); 2216 return ATGEN_AnswerCall(s,ID,all);
2214} 2217}
2215 2218
2216static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) 2219static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
2217{ 2220{
2218 GSM_Error error; 2221 GSM_Error error;
2219 2222
2220 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2223 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2221 return ATGEN_GetNetworkInfo(s, netinfo); 2224 return ATGEN_GetNetworkInfo(s, netinfo);
2222} 2225}
2223 2226
2224static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) 2227static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features)
2225{ 2228{
2226 GSM_Error error; 2229 GSM_Error error;
2227 2230
2228 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2231 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2229 return ATGEN_GetDisplayStatus(s, features); 2232 return ATGEN_GetDisplayStatus(s, features);
2230} 2233}
2231 2234
2232static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) 2235static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s)
2233{ 2236{
2234 GSM_Error error; 2237 GSM_Error error;
2235 2238
2236 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2239 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2237 return ATGEN_SetAutoNetworkLogin(s); 2240 return ATGEN_SetAutoNetworkLogin(s);
2238} 2241}
2239 2242
2240static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 2243static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
2241{ 2244{
2242 GSM_Error error; 2245 GSM_Error error;
2243 2246
2244 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2247 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2245 return ATGEN_PressKey(s, Key, Press); 2248 return ATGEN_PressKey(s, Key, Press);
2246} 2249}
2247 2250
2248static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard) 2251static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard)
2249{ 2252{
2250 GSM_Error error; 2253 GSM_Error error;
2251 2254
2252 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2255 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2253 return ATGEN_Reset(s, hard); 2256 return ATGEN_Reset(s, hard);
2254} 2257}
2255 2258
2256static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all) 2259static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all)
2257{ 2260{
2258 GSM_Error error; 2261 GSM_Error error;
2259 2262
2260 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2263 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2261 return ATGEN_CancelCall(s,ID,all); 2264 return ATGEN_CancelCall(s,ID,all);
2262} 2265}
2263 2266
2264static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location) 2267static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location)
2265{ 2268{
2266 GSM_Error error; 2269 GSM_Error error;
2267 2270
2268 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2271 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2269 return ATGEN_SendSavedSMS(s, Folder, Location); 2272 return ATGEN_SendSavedSMS(s, Folder, Location);
2270} 2273}
2271 2274
2272static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) 2275static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
2273{ 2276{
2274 GSM_Error error; 2277 GSM_Error error;
2275 2278
2276 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2279 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2277 return ATGEN_SendSMS(s, sms); 2280 return ATGEN_SendSMS(s, sms);
2278} 2281}
2279 2282
@@ -2292,99 +2295,99 @@ static GSM_Error ALCATEL_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
2292 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2295 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2293 return ATGEN_SetSMSC(s, smsc); 2296 return ATGEN_SetSMSC(s, smsc);
2294} 2297}
2295 2298
2296static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) 2299static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
2297{ 2300{
2298 GSM_Error error; 2301 GSM_Error error;
2299 2302
2300 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2303 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2301 return ATGEN_EnterSecurityCode(s, Code); 2304 return ATGEN_EnterSecurityCode(s, Code);
2302} 2305}
2303 2306
2304static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) 2307static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
2305{ 2308{
2306 GSM_Error error; 2309 GSM_Error error;
2307 2310
2308 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2311 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2309 return ATGEN_GetSecurityStatus(s, Status); 2312 return ATGEN_GetSecurityStatus(s, Status);
2310} 2313}
2311 2314
2312static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type) 2315static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type)
2313{ 2316{
2314 GSM_Error error; 2317 GSM_Error error;
2315 2318
2316 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2319 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2317 return ATGEN_ResetPhoneSettings(s, Type); 2320 return ATGEN_ResetPhoneSettings(s, Type);
2318} 2321}
2319 2322
2320static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence) 2323static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence)
2321{ 2324{
2322 GSM_Error error; 2325 GSM_Error error;
2323 2326
2324 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2327 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2325 return ATGEN_SendDTMF(s, sequence); 2328 return ATGEN_SendDTMF(s, sequence);
2326} 2329}
2327 2330
2328static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) 2331static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI)
2329{ 2332{
2330 GSM_Error error; 2333 GSM_Error error;
2331 2334
2332 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2335 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2333 return ATGEN_GetSIMIMSI(s, IMSI); 2336 return ATGEN_GetSIMIMSI(s, IMSI);
2334} 2337}
2335 2338
2336static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) 2339static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status)
2337{ 2340{
2338 GSM_Error error; 2341 GSM_Error error;
2339 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2342 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2340 2343
2341 status->Used = 0; 2344 status->Used = 0;
2342 2345
2343 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2346 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2344 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2347 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2345 2348
2346 status->Used = Priv->CalendarItemsCount; 2349 status->Used = Priv->CalendarItemsCount;
2347 return ERR_NONE; 2350 return ERR_NONE;
2348} 2351}
2349 2352
2350static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2353static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2351{ 2354{
2352 GSM_Error error; 2355 GSM_Error error;
2353 GSM_DateTime *dt = NULL; 2356 GSM_DateTime *dt = NULL;
2354 GSM_DateTime evdate; 2357 GSM_DateTime evdate;
2355 bool evdateused = true; 2358 bool evdateused = true;
2356 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2359 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2357 int i; 2360 int i;
2358 int j=0; 2361 int j=0;
2359 2362
2360 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2363 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2361 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2364 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2362 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { 2365 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) {
2363 Note->EntriesNum = 0; 2366 Note->EntriesNum = 0;
2364 return error; 2367 return error;
2365 } 2368 }
2366 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; 2369 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error;
2367 2370
2368 Note->EntriesNum = Priv->CurrentFieldsCount; 2371 Note->EntriesNum = Priv->CurrentFieldsCount;
2369 2372
2370 for (i=0; i < Priv->CurrentFieldsCount; i++) { 2373 for (i=0; i < Priv->CurrentFieldsCount; i++) {
2371 if ((error = ALCATEL_GetFieldValue(s, Note->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; 2374 if ((error = ALCATEL_GetFieldValue(s, Note->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error;
2372 switch (Priv->CurrentFields[i]) { 2375 switch (Priv->CurrentFields[i]) {
2373 case 0: 2376 case 0:
2374 if (Priv->ReturnType != Alcatel_date) { 2377 if (Priv->ReturnType != Alcatel_date) {
2375 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 2378 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
2376 Note->EntriesNum--; 2379 Note->EntriesNum--;
2377 j++; 2380 j++;
2378 break; 2381 break;
2379 } 2382 }
2380 if (!CheckDate(&(Priv->ReturnDateTime))) { 2383 if (!CheckDate(&(Priv->ReturnDateTime))) {
2381 smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); 2384 smprintf(s,"WARNING: Invalid date in phone, ignoring\n");
2382 Note->EntriesNum--; 2385 Note->EntriesNum--;
2383 j++; 2386 j++;
2384 break; 2387 break;
2385 } 2388 }
2386 j++; 2389 j++;
2387 Note->EntriesNum--; 2390 Note->EntriesNum--;
2388 evdate = Priv->ReturnDateTime; 2391 evdate = Priv->ReturnDateTime;
2389 evdateused = false; 2392 evdateused = false;
2390 break; 2393 break;
@@ -2682,556 +2685,556 @@ static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2682 break; 2685 break;
2683 } 2686 }
2684 /* This entry had always same value as the 4th (alarm time) */ 2687 /* This entry had always same value as the 4th (alarm time) */
2685 j++; 2688 j++;
2686 Note->EntriesNum--; 2689 Note->EntriesNum--;
2687 break; 2690 break;
2688 default: 2691 default:
2689 Note->EntriesNum--; 2692 Note->EntriesNum--;
2690 j++; 2693 j++;
2691 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); 2694 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType);
2692 switch (Priv->ReturnType) { 2695 switch (Priv->ReturnType) {
2693 case Alcatel_date: 2696 case Alcatel_date:
2694 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); 2697 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year);
2695 break; 2698 break;
2696 case Alcatel_time: 2699 case Alcatel_time:
2697 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); 2700 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second);
2698 break; 2701 break;
2699 case Alcatel_string: 2702 case Alcatel_string:
2700 case Alcatel_phone: 2703 case Alcatel_phone:
2701 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); 2704 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString));
2702 break; 2705 break;
2703 case Alcatel_enum: 2706 case Alcatel_enum:
2704 case Alcatel_bool: 2707 case Alcatel_bool:
2705 case Alcatel_int: 2708 case Alcatel_int:
2706 case Alcatel_byte: 2709 case Alcatel_byte:
2707 smprintf(s, "%d", Priv->ReturnInt); 2710 smprintf(s, "%d", Priv->ReturnInt);
2708 break; 2711 break;
2709 } 2712 }
2710 smprintf(s,"\n"); 2713 smprintf(s,"\n");
2711 } 2714 }
2712 } 2715 }
2713 /* The event didn't have start/stop time -> we need only date */ 2716 /* The event didn't have start/stop time -> we need only date */
2714 if (!evdateused) { 2717 if (!evdateused) {
2715 Note->EntriesNum++; 2718 Note->EntriesNum++;
2716 Note->Entries[i-j].EntryType = CAL_START_DATETIME; 2719 Note->Entries[i-j].EntryType = CAL_START_DATETIME;
2717 Note->Entries[i-j].Date = evdate; 2720 Note->Entries[i-j].Date = evdate;
2718 } 2721 }
2719 return ERR_NONE; 2722 return ERR_NONE;
2720} 2723}
2721 2724
2722static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 2725static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
2723{ 2726{
2724 GSM_Error error; 2727 GSM_Error error;
2725 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2728 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2726 2729
2727 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2730 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2728 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2731 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2729 if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; 2732 if (Priv->CalendarItemsCount == 0) return ERR_EMPTY;
2730 2733
2731 if (start) Note->Location = 0; 2734 if (start) Note->Location = 0;
2732 if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; 2735 if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error;
2733 2736
2734 return ALCATEL_GetCalendar(s, Note); 2737 return ALCATEL_GetCalendar(s, Note);
2735} 2738}
2736 2739
2737 2740
2738static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2741static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2739{ 2742{
2740 GSM_Error error; 2743 GSM_Error error;
2741 2744
2742 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2745 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2743 /* Delete Calendar */ 2746 /* Delete Calendar */
2744 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2747 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2745 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { 2748 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) {
2746 /* Entry was empty => no error */ 2749 /* Entry was empty => no error */
2747 return ERR_NONE; 2750 return ERR_NONE;
2748 } 2751 }
2749 error = ALCATEL_DeleteItem(s, Note->Location); 2752 error = ALCATEL_DeleteItem(s, Note->Location);
2750 if (error != ERR_NONE) return error; 2753 if (error != ERR_NONE) return error;
2751 /* Refresh list */ 2754 /* Refresh list */
2752 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2755 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2753 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2756 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2754 return ERR_NONE; 2757 return ERR_NONE;
2755} 2758}
2756 2759
2757 2760
2758static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2761static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2759{ 2762{
2760 GSM_Error error; 2763 GSM_Error error;
2761 unsigned int val; 2764 unsigned int val;
2762 bool contact_set = false; 2765 bool contact_set = false;
2763 bool phone_set = false; 2766 bool phone_set = false;
2764 bool date_set = false; 2767 bool date_set = false;
2765 bool repeating = false; 2768 bool repeating = false;
2766 int i; 2769 int i;
2767 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2770 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2768 2771
2769 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2772 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2770 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error; 2773 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error;
2771 2774
2772 for (i = 0; i < Note->EntriesNum; i++) { 2775 for (i = 0; i < Note->EntriesNum; i++) {
2773 switch (Note->Entries[i].EntryType) { 2776 switch (Note->Entries[i].EntryType) {
2774 case CAL_START_DATETIME: 2777 case CAL_START_DATETIME:
2775 if (!date_set) { 2778 if (!date_set) {
2776 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2779 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2777 date_set = true; 2780 date_set = true;
2778 } 2781 }
2779 if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2782 if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2780 break; 2783 break;
2781 case CAL_END_DATETIME: 2784 case CAL_END_DATETIME:
2782 if (!date_set) { 2785 if (!date_set) {
2783 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2786 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2784 date_set = true; 2787 date_set = true;
2785 } 2788 }
2786 if ((error = ALCATEL_CreateField(s, Alcatel_time, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2789 if ((error = ALCATEL_CreateField(s, Alcatel_time, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2787 break; 2790 break;
2788 case CAL_ALARM_DATETIME: 2791 case CAL_ALARM_DATETIME:
2789 if ((error = ALCATEL_CreateField(s, Alcatel_date, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2792 if ((error = ALCATEL_CreateField(s, Alcatel_date, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2790 if ((error = ALCATEL_CreateField(s, Alcatel_time, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2793 if ((error = ALCATEL_CreateField(s, Alcatel_time, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2791 if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { 2794 if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) {
2792 if ((error = ALCATEL_CreateField(s, Alcatel_date, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2795 if ((error = ALCATEL_CreateField(s, Alcatel_date, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2793 if ((error = ALCATEL_CreateField(s, Alcatel_time, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2796 if ((error = ALCATEL_CreateField(s, Alcatel_time, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2794 } 2797 }
2795 break; 2798 break;
2796 case CAL_TEXT: 2799 case CAL_TEXT:
2797 if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error; 2800 if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error;
2798 break; 2801 break;
2799 case CAL_PRIVATE: 2802 case CAL_PRIVATE:
2800 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2803 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2801 break; 2804 break;
2802 case CAL_CONTACTID: 2805 case CAL_CONTACTID:
2803 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2806 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2804 contact_set = true; 2807 contact_set = true;
2805 break; 2808 break;
2806 case CAL_PHONE: 2809 case CAL_PHONE:
2807 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error; 2810 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error;
2808 phone_set = true; 2811 phone_set = true;
2809 break; 2812 break;
2810 case CAL_REPEAT_DAYOFWEEK: 2813 case CAL_REPEAT_DAYOFWEEK:
2811 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2814 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2812 repeating = true; 2815 repeating = true;
2813 break; 2816 break;
2814 case CAL_REPEAT_DAY: 2817 case CAL_REPEAT_DAY:
2815 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2818 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2816 repeating = true; 2819 repeating = true;
2817 break; 2820 break;
2818 case CAL_REPEAT_WEEKOFMONTH: 2821 case CAL_REPEAT_WEEKOFMONTH:
2819 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2822 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2820 repeating = true; 2823 repeating = true;
2821 break; 2824 break;
2822 case CAL_REPEAT_MONTH: 2825 case CAL_REPEAT_MONTH:
2823 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2826 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2824 repeating = true; 2827 repeating = true;
2825 break; 2828 break;
2826 case CAL_REPEAT_FREQUENCY: 2829 case CAL_REPEAT_FREQUENCY:
2827 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2830 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2828 repeating = true; 2831 repeating = true;
2829 break; 2832 break;
2830 case CAL_REPEAT_STARTDATE: 2833 case CAL_REPEAT_STARTDATE:
2831 if ((error = ALCATEL_CreateField(s, Alcatel_date, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2834 if ((error = ALCATEL_CreateField(s, Alcatel_date, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2832 repeating = true; 2835 repeating = true;
2833 break; 2836 break;
2834 case CAL_REPEAT_STOPDATE: 2837 case CAL_REPEAT_STOPDATE:
2835 if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2838 if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2836 repeating = true; 2839 repeating = true;
2837 break; 2840 break;
2838 case CAL_SILENT_ALARM_DATETIME: 2841 case CAL_SILENT_ALARM_DATETIME:
2839 case CAL_RECURRANCE: 2842 case CAL_RECURRANCE:
2840 case CAL_LOCATION: 2843 case CAL_LOCATION:
2841 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); 2844 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType);
2842 break; 2845 break;
2843 } 2846 }
2844 } 2847 }
2845 2848
2846 switch (Note->Type) { 2849 switch (Note->Type) {
2847 case GSM_CAL_CALL: 2850 case GSM_CAL_CALL:
2848 val = 3; 2851 val = 3;
2849 break; 2852 break;
2850 case GSM_CAL_BIRTHDAY: 2853 case GSM_CAL_BIRTHDAY:
2851 val = 2; 2854 val = 2;
2852 break; 2855 break;
2853 case GSM_CAL_ALARM: 2856 case GSM_CAL_ALARM:
2854 val = 4; 2857 val = 4;
2855 break; 2858 break;
2856 case GSM_CAL_DAILY_ALARM: 2859 case GSM_CAL_DAILY_ALARM:
2857 val = 5; 2860 val = 5;
2858 break; 2861 break;
2859 default: 2862 default:
2860 if (repeating) { 2863 if (repeating) {
2861 val = 9; 2864 val = 9;
2862 } else { 2865 } else {
2863 val = 0; 2866 val = 0;
2864 } 2867 }
2865 } 2868 }
2866 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; 2869 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error;
2867 2870
2868 if (!contact_set) { 2871 if (!contact_set) {
2869 if (phone_set) { 2872 if (phone_set) {
2870 val = 0xffffffff; 2873 val = 0xffffffff;
2871 } else { 2874 } else {
2872 val = 0; 2875 val = 0;
2873 } 2876 }
2874 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; 2877 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error;
2875 } 2878 }
2876 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2879 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2877 Note->Location = Priv->CommitedRecord; 2880 Note->Location = Priv->CommitedRecord;
2878 /* Refresh list */ 2881 /* Refresh list */
2879 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2882 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2880 return ERR_NONE; 2883 return ERR_NONE;
2881} 2884}
2882 2885
2883static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2886static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2884{ 2887{
2885 GSM_Error error; 2888 GSM_Error error;
2886 unsigned int val; 2889 unsigned int val;
2887 bool contact_set = false; 2890 bool contact_set = false;
2888 bool phone_set = false; 2891 bool phone_set = false;
2889 bool date_set = false; 2892 bool date_set = false;
2890 bool repeating = false; 2893 bool repeating = false;
2891 int i; 2894 int i;
2892 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2895 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2893 bool UpdatedFields[22]; 2896 bool UpdatedFields[22];
2894 2897
2895 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2898 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2896 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2899 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2897 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { 2900 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) {
2898 /* Entry doesn't exist, we will create new one */ 2901 /* Entry doesn't exist, we will create new one */
2899 return ALCATEL_AddCalendar(s, Note); 2902 return ALCATEL_AddCalendar(s, Note);
2900 } 2903 }
2901 /* Get fields for current item */ 2904 /* Get fields for current item */
2902 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; 2905 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error;
2903 2906
2904 for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } 2907 for (i = 0; i < 22; i++) { UpdatedFields[i] = false; }
2905 2908
2906 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error; 2909 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error;
2907 2910
2908 for (i = 0; i < Note->EntriesNum; i++) { 2911 for (i = 0; i < Note->EntriesNum; i++) {
2909 switch (Note->Entries[i].EntryType) { 2912 switch (Note->Entries[i].EntryType) {
2910 case CAL_START_DATETIME: 2913 case CAL_START_DATETIME:
2911 if (!date_set) { 2914 if (!date_set) {
2912 UpdatedFields[0] = true; 2915 UpdatedFields[0] = true;
2913 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2916 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2914 date_set = true; 2917 date_set = true;
2915 } 2918 }
2916 UpdatedFields[1] = true; 2919 UpdatedFields[1] = true;
2917 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2920 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2918 break; 2921 break;
2919 case CAL_END_DATETIME: 2922 case CAL_END_DATETIME:
2920 if (!date_set) { 2923 if (!date_set) {
2921 UpdatedFields[0] = true; 2924 UpdatedFields[0] = true;
2922 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2925 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2923 date_set = true; 2926 date_set = true;
2924 } 2927 }
2925 UpdatedFields[2] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2928 UpdatedFields[2] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2926 break; 2929 break;
2927 case CAL_ALARM_DATETIME: 2930 case CAL_ALARM_DATETIME:
2928 UpdatedFields[3] = true; 2931 UpdatedFields[3] = true;
2929 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2932 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2930 UpdatedFields[4] = true; 2933 UpdatedFields[4] = true;
2931 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2934 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2932 if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { 2935 if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) {
2933 UpdatedFields[20] = true; 2936 UpdatedFields[20] = true;
2934 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2937 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2935 UpdatedFields[21] = true; 2938 UpdatedFields[21] = true;
2936 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2939 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2937 } 2940 }
2938 break; 2941 break;
2939 case CAL_TEXT: 2942 case CAL_TEXT:
2940 UpdatedFields[5] = true; 2943 UpdatedFields[5] = true;
2941 if ((error = ALCATEL_UpdateField(s, Alcatel_string, Note->Location, 5, Note->Entries[i].Text)) != ERR_NONE) return error; 2944 if ((error = ALCATEL_UpdateField(s, Alcatel_string, Note->Location, 5, Note->Entries[i].Text)) != ERR_NONE) return error;
2942 break; 2945 break;
2943 case CAL_PRIVATE: 2946 case CAL_PRIVATE:
2944 UpdatedFields[6] = true; 2947 UpdatedFields[6] = true;
2945 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2948 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2946 break; 2949 break;
2947 case CAL_CONTACTID: 2950 case CAL_CONTACTID:
2948 UpdatedFields[8] = true; 2951 UpdatedFields[8] = true;
2949 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2952 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2950 contact_set = true; 2953 contact_set = true;
2951 break; 2954 break;
2952 case CAL_PHONE: 2955 case CAL_PHONE:
2953 UpdatedFields[9] = true; 2956 UpdatedFields[9] = true;
2954 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error; 2957 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error;
2955 phone_set = true; 2958 phone_set = true;
2956 break; 2959 break;
2957 case CAL_REPEAT_DAYOFWEEK: 2960 case CAL_REPEAT_DAYOFWEEK:
2958 UpdatedFields[10] = true; 2961 UpdatedFields[10] = true;
2959 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2962 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2960 repeating = true; 2963 repeating = true;
2961 break; 2964 break;
2962 case CAL_REPEAT_DAY: 2965 case CAL_REPEAT_DAY:
2963 UpdatedFields[11] = true; 2966 UpdatedFields[11] = true;
2964 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2967 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2965 repeating = true; 2968 repeating = true;
2966 break; 2969 break;
2967 case CAL_REPEAT_WEEKOFMONTH: 2970 case CAL_REPEAT_WEEKOFMONTH:
2968 UpdatedFields[12] = true; 2971 UpdatedFields[12] = true;
2969 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2972 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2970 repeating = true; 2973 repeating = true;
2971 break; 2974 break;
2972 case CAL_REPEAT_MONTH: 2975 case CAL_REPEAT_MONTH:
2973 UpdatedFields[13] = true; 2976 UpdatedFields[13] = true;
2974 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2977 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2975 repeating = true; 2978 repeating = true;
2976 break; 2979 break;
2977 case CAL_REPEAT_FREQUENCY: 2980 case CAL_REPEAT_FREQUENCY:
2978 UpdatedFields[17] = true; 2981 UpdatedFields[17] = true;
2979 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2982 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2980 repeating = true; 2983 repeating = true;
2981 break; 2984 break;
2982 case CAL_REPEAT_STARTDATE: 2985 case CAL_REPEAT_STARTDATE:
2983 UpdatedFields[18] = true; 2986 UpdatedFields[18] = true;
2984 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2987 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2985 repeating = true; 2988 repeating = true;
2986 break; 2989 break;
2987 case CAL_REPEAT_STOPDATE: 2990 case CAL_REPEAT_STOPDATE:
2988 UpdatedFields[19] = true; 2991 UpdatedFields[19] = true;
2989 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2992 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2990 repeating = true; 2993 repeating = true;
2991 break; 2994 break;
2992 case CAL_SILENT_ALARM_DATETIME: 2995 case CAL_SILENT_ALARM_DATETIME:
2993 case CAL_RECURRANCE: 2996 case CAL_RECURRANCE:
2994 case CAL_LOCATION: 2997 case CAL_LOCATION:
2995 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); 2998 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType);
2996 break; 2999 break;
2997 } 3000 }
2998 } 3001 }
2999 3002
3000 switch (Note->Type) { 3003 switch (Note->Type) {
3001 case GSM_CAL_CALL: 3004 case GSM_CAL_CALL:
3002 val = 3; 3005 val = 3;
3003 break; 3006 break;
3004 case GSM_CAL_BIRTHDAY: 3007 case GSM_CAL_BIRTHDAY:
3005 val = 2; 3008 val = 2;
3006 break; 3009 break;
3007 case GSM_CAL_ALARM: 3010 case GSM_CAL_ALARM:
3008 val = 4; 3011 val = 4;
3009 break; 3012 break;
3010 case GSM_CAL_DAILY_ALARM: 3013 case GSM_CAL_DAILY_ALARM:
3011 val = 5; 3014 val = 5;
3012 break; 3015 break;
3013 default: 3016 default:
3014 if (repeating) { 3017 if (repeating) {
3015 val = 9; 3018 val = 9;
3016 } else { 3019 } else {
3017 val = 0; 3020 val = 0;
3018 } 3021 }
3019 } 3022 }
3020 UpdatedFields[7] = true; 3023 UpdatedFields[7] = true;
3021 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, Note->Location, 7, &val)) != ERR_NONE) return error; 3024 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, Note->Location, 7, &val)) != ERR_NONE) return error;
3022 3025
3023 if (!contact_set) { 3026 if (!contact_set) {
3024 if (phone_set) { 3027 if (phone_set) {
3025 val = 0xffffffff; 3028 val = 0xffffffff;
3026 } else { 3029 } else {
3027 val = 0; 3030 val = 0;
3028 } 3031 }
3029 UpdatedFields[8] = true; 3032 UpdatedFields[8] = true;
3030 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &val)) != ERR_NONE) return error; 3033 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &val)) != ERR_NONE) return error;
3031 } 3034 }
3032 /* If we didn't update some field, we have to delete it... */ 3035 /* If we didn't update some field, we have to delete it... */
3033 for (i=0; i<Priv->CurrentFieldsCount; i++) { 3036 for (i=0; i<Priv->CurrentFieldsCount; i++) {
3034 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, Note->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; 3037 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, Note->Location, Priv->CurrentFields[i])) != ERR_NONE) return error;
3035 } 3038 }
3036 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3039 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
3037 return ERR_NONE; 3040 return ERR_NONE;
3038} 3041}
3039 3042
3040static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s) 3043static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s)
3041{ 3044{
3042 GSM_Error error; 3045 GSM_Error error;
3043 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3046 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3044 int i; 3047 int i;
3045 3048
3046 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3049 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
3047 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3050 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3048 3051
3049 for (i=0; i<Priv->CalendarItemsCount; i++) { 3052 for (i=0; i<Priv->CalendarItemsCount; i++) {
3050 error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]); 3053 error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]);
3051 if (error != ERR_NONE) return error; 3054 if (error != ERR_NONE) return error;
3052 } 3055 }
3053 3056
3054 /* Refresh list */ 3057 /* Refresh list */
3055 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3058 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
3056 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3059 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3057 3060
3058 return ERR_NONE; 3061 return ERR_NONE;
3059} 3062}
3060 3063
3061 3064
3062static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 3065static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
3063{ 3066{
3064 GSM_Error error; 3067 GSM_Error error;
3065 GSM_CalendarEntryNote; 3068 GSM_CalendarEntryNote;
3066 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3069 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3067 int i; 3070 int i;
3068 bool Found = false; 3071 bool Found = false;
3069 bool DateSet = false; 3072 bool DateSet = false;
3070 int alarm_number = alarm->Location; 3073 int alarm_number = alarm->Location;
3071 static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; 3074 static GSM_DateTimenulldt = {0,0,0,0,0,0,0};
3072 3075
3073 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3076 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
3074 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3077 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3075 3078
3076 for (i=0; i<Priv->CalendarItemsCount; i++) { 3079 for (i=0; i<Priv->CalendarItemsCount; i++) {
3077 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; 3080 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error;
3078 if (Priv->ReturnType != Alcatel_enum) { 3081 if (Priv->ReturnType != Alcatel_enum) {
3079 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3082 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3080 continue; 3083 continue;
3081 } 3084 }
3082 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { 3085 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) {
3083 alarm_number--; 3086 alarm_number--;
3084 if (alarm_number == 0) { 3087 if (alarm_number == 0) {
3085 Found = true; 3088 Found = true;
3086 break; 3089 break;
3087 } 3090 }
3088 } 3091 }
3089 } 3092 }
3090 3093
3091 if (!Found) return ERR_EMPTY; 3094 if (!Found) return ERR_EMPTY;
3092 3095
3093 Note.Location = Priv->CalendarItems[i]; 3096 Note.Location = Priv->CalendarItems[i];
3094 3097
3095 if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; 3098 if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error;
3096 3099
3097 if (Note.Type == GSM_CAL_ALARM) { 3100 if (Note.Type == GSM_CAL_ALARM) {
3098 alarm->Repeating = false; 3101 alarm->Repeating = false;
3099 } else { 3102 } else {
3100 alarm->Repeating = true; 3103 alarm->Repeating = true;
3101 } 3104 }
3102 3105
3103 alarm->Text[0] = 0; alarm->Text[1] = 0; 3106 alarm->Text[0] = 0; alarm->Text[1] = 0;
3104 3107
3105 3108
3106 for (i = 0; i < Note.EntriesNum; i++) { 3109 for (i = 0; i < Note.EntriesNum; i++) {
3107 if (Note.Entries[i].EntryType == CAL_TEXT) { 3110 if (Note.Entries[i].EntryType == CAL_TEXT) {
3108 CopyUnicodeString(alarm->Text, Note.Entries[i].Text); 3111 CopyUnicodeString(alarm->Text, Note.Entries[i].Text);
3109 } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { 3112 } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) {
3110 alarm->DateTime = Note.Entries[i].Date; 3113 alarm->DateTime = Note.Entries[i].Date;
3111 DateSet = false; 3114 DateSet = false;
3112 } 3115 }
3113 } 3116 }
3114 if (!DateSet) { 3117 if (!DateSet) {
3115 alarm->DateTime = nulldt; 3118 alarm->DateTime = nulldt;
3116 } 3119 }
3117 3120
3118 return ERR_NONE; 3121 return ERR_NONE;
3119} 3122}
3120 3123
3121 3124
3122static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) 3125static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm)
3123{ 3126{
3124 GSM_Error error; 3127 GSM_Error error;
3125 GSM_CalendarEntryNote; 3128 GSM_CalendarEntryNote;
3126 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3129 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3127 GSM_DateTime dt; 3130 GSM_DateTime dt;
3128 int i; 3131 int i;
3129 bool Found = false; 3132 bool Found = false;
3130 int alarm_number = alarm->Location; 3133 int alarm_number = alarm->Location;
3131 3134
3132 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3135 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
3133 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3136 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3134 3137
3135 for (i=0; i<Priv->CalendarItemsCount; i++) { 3138 for (i=0; i<Priv->CalendarItemsCount; i++) {
3136 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; 3139 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error;
3137 if (Priv->ReturnType != Alcatel_enum) { 3140 if (Priv->ReturnType != Alcatel_enum) {
3138 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3141 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3139 continue; 3142 continue;
3140 } 3143 }
3141 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { 3144 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) {
3142 alarm_number--; 3145 alarm_number--;
3143 if (alarm_number == 0) { 3146 if (alarm_number == 0) {
3144 Found = true; 3147 Found = true;
3145 break; 3148 break;
3146 } 3149 }
3147 } 3150 }
3148 } 3151 }
3149 3152
3150 if (Found) { 3153 if (Found) {
3151 Note.Location = Priv->CalendarItems[i]; 3154 Note.Location = Priv->CalendarItems[i];
3152 } 3155 }
3153 3156
3154 Note.EntriesNum = 1; 3157 Note.EntriesNum = 1;
3155 3158
3156 Note.Entries[0].EntryType = CAL_ALARM_DATETIME; 3159 Note.Entries[0].EntryType = CAL_ALARM_DATETIME;
3157 Note.Entries[0].Date = alarm->DateTime; 3160 Note.Entries[0].Date = alarm->DateTime;
3158 3161
3159 if (alarm->Repeating) { 3162 if (alarm->Repeating) {
3160 Note.Type = GSM_CAL_DAILY_ALARM; 3163 Note.Type = GSM_CAL_DAILY_ALARM;
3161 GSM_GetCurrentDateTime(&dt); 3164 GSM_GetCurrentDateTime(&dt);
3162 Note.Entries[0].Date.Day = dt.Day; 3165 Note.Entries[0].Date.Day = dt.Day;
3163 Note.Entries[0].Date.Month = dt.Month; 3166 Note.Entries[0].Date.Month = dt.Month;
3164 Note.Entries[0].Date.Year = dt.Year; 3167 Note.Entries[0].Date.Year = dt.Year;
3165 } else { 3168 } else {
3166 Note.Type = GSM_CAL_ALARM; 3169 Note.Type = GSM_CAL_ALARM;
3167 } 3170 }
3168 3171
3169 if (alarm->Text[0] != 0 || alarm->Text[1] != 0) { 3172 if (alarm->Text[0] != 0 || alarm->Text[1] != 0) {
3170 Note.EntriesNum++; 3173 Note.EntriesNum++;
3171 Note.Entries[1].EntryType = CAL_TEXT; 3174 Note.Entries[1].EntryType = CAL_TEXT;
3172 CopyUnicodeString(Note.Entries[1].Text, alarm->Text); 3175 CopyUnicodeString(Note.Entries[1].Text, alarm->Text);
3173 } 3176 }
3174 3177
3175 if (Found) { 3178 if (Found) {
3176 return ALCATEL_SetCalendar(s, &Note); 3179 return ALCATEL_SetCalendar(s, &Note);
3177 } else { 3180 } else {
3178 return ALCATEL_AddCalendar(s, &Note); 3181 return ALCATEL_AddCalendar(s, &Note);
3179 } 3182 }
3180} 3183}
3181 3184
3182 3185
3183static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 3186static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
3184{ 3187{
3185 GSM_Error error; 3188 GSM_Error error;
3186 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3189 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3187 3190
3188 status->Used = 0; 3191 status->Used = 0;
3189 3192
3190 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3193 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3191 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3194 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3192 3195
3193 status->Used = Priv->ToDoItemsCount; 3196 status->Used = Priv->ToDoItemsCount;
3194 return ERR_NONE; 3197 return ERR_NONE;
3195} 3198}
3196 3199
3197static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3200static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3198{ 3201{
3199 GSM_Error error; 3202 GSM_Error error;
3200 GSM_DateTime *dt = NULL; 3203 GSM_DateTime *dt = NULL;
3201 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3204 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3202 int i; 3205 int i;
3203 int j=0; 3206 int j=0;
3204 3207
3205 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3208 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3206 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3209 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3207 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { 3210 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) {
3208 ToDo->EntriesNum = 0; 3211 ToDo->EntriesNum = 0;
3209 return error; 3212 return error;
3210 } 3213 }
3211 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; 3214 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error;
3212 3215
3213 ToDo->EntriesNum = Priv->CurrentFieldsCount; 3216 ToDo->EntriesNum = Priv->CurrentFieldsCount;
3214 3217
3215 for (i=0; i < Priv->CurrentFieldsCount; i++) { 3218 for (i=0; i < Priv->CurrentFieldsCount; i++) {
3216 if ((error = ALCATEL_GetFieldValue(s, ToDo->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; 3219 if ((error = ALCATEL_GetFieldValue(s, ToDo->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error;
3217 switch (Priv->CurrentFields[i]) { 3220 switch (Priv->CurrentFields[i]) {
3218 case 0: 3221 case 0:
3219 if (Priv->ReturnType != Alcatel_date) { 3222 if (Priv->ReturnType != Alcatel_date) {
3220 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3223 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3221 ToDo->EntriesNum--; 3224 ToDo->EntriesNum--;
3222 j++; 3225 j++;
3223 break; 3226 break;
3224 } 3227 }
3225 if (!CheckDate(&(Priv->ReturnDateTime))) { 3228 if (!CheckDate(&(Priv->ReturnDateTime))) {
3226 smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); 3229 smprintf(s,"WARNING: Invalid date in phone, ignoring\n");
3227 ToDo->EntriesNum--; 3230 ToDo->EntriesNum--;
3228 j++; 3231 j++;
3229 break; 3232 break;
3230 } 3233 }
3231 ToDo->Entries[i-j].EntryType = TODO_END_DATETIME; 3234 ToDo->Entries[i-j].EntryType = TODO_END_DATETIME;
3232 ToDo->Entries[i-j].Date = Priv->ReturnDateTime; 3235 ToDo->Entries[i-j].Date = Priv->ReturnDateTime;
3233 break; 3236 break;
3234 case 1: 3237 case 1:
3235 if (Priv->ReturnType != Alcatel_bool) { 3238 if (Priv->ReturnType != Alcatel_bool) {
3236 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3239 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3237 ToDo->EntriesNum--; 3240 ToDo->EntriesNum--;
@@ -3406,289 +3409,289 @@ static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3406 break; 3409 break;
3407 } 3410 }
3408 if (!CheckTime(&(Priv->ReturnDateTime))) { 3411 if (!CheckTime(&(Priv->ReturnDateTime))) {
3409 smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); 3412 smprintf(s,"WARNING: Invalid time in phone, ignoring\n");
3410 ToDo->EntriesNum--; 3413 ToDo->EntriesNum--;
3411 j++; 3414 j++;
3412 break; 3415 break;
3413 } 3416 }
3414 /* This entry had always same value as the 3rd (alarm time) */ 3417 /* This entry had always same value as the 3rd (alarm time) */
3415 j++; 3418 j++;
3416 ToDo->EntriesNum--; 3419 ToDo->EntriesNum--;
3417 break; 3420 break;
3418 default: 3421 default:
3419 ToDo->EntriesNum--; 3422 ToDo->EntriesNum--;
3420 j++; 3423 j++;
3421 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); 3424 smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType);
3422 switch (Priv->ReturnType) { 3425 switch (Priv->ReturnType) {
3423 case Alcatel_date: 3426 case Alcatel_date:
3424 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); 3427 smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year);
3425 break; 3428 break;
3426 case Alcatel_time: 3429 case Alcatel_time:
3427 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); 3430 smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second);
3428 break; 3431 break;
3429 case Alcatel_string: 3432 case Alcatel_string:
3430 case Alcatel_phone: 3433 case Alcatel_phone:
3431 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); 3434 smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString));
3432 break; 3435 break;
3433 case Alcatel_enum: 3436 case Alcatel_enum:
3434 case Alcatel_bool: 3437 case Alcatel_bool:
3435 case Alcatel_int: 3438 case Alcatel_int:
3436 case Alcatel_byte: 3439 case Alcatel_byte:
3437 smprintf(s, "%d", Priv->ReturnInt); 3440 smprintf(s, "%d", Priv->ReturnInt);
3438 break; 3441 break;
3439 } 3442 }
3440 smprintf(s,"\n"); 3443 smprintf(s,"\n");
3441 } 3444 }
3442 } 3445 }
3443 return ERR_NONE; 3446 return ERR_NONE;
3444} 3447}
3445 3448
3446static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 3449static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
3447{ 3450{
3448 GSM_Error error; 3451 GSM_Error error;
3449 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3452 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3450 3453
3451 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3454 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3452 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3455 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3453 if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; 3456 if (Priv->ToDoItemsCount == 0) return ERR_EMPTY;
3454 3457
3455 if (start) ToDo->Location = 0; 3458 if (start) ToDo->Location = 0;
3456 if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; 3459 if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error;
3457 3460
3458 return ALCATEL_GetToDo(s, ToDo); 3461 return ALCATEL_GetToDo(s, ToDo);
3459} 3462}
3460 3463
3461static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) 3464static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s)
3462{ 3465{
3463 GSM_Error error; 3466 GSM_Error error;
3464 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3467 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3465 int i; 3468 int i;
3466 3469
3467 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3470 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3468 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3471 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3469 3472
3470 for (i=0; i<Priv->ToDoItemsCount; i++) { 3473 for (i=0; i<Priv->ToDoItemsCount; i++) {
3471 error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]); 3474 error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]);
3472 if (error != ERR_NONE) return error; 3475 if (error != ERR_NONE) return error;
3473 } 3476 }
3474 3477
3475 /* Refresh list */ 3478 /* Refresh list */
3476 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3479 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3477 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3480 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3478 3481
3479 return ERR_NONE; 3482 return ERR_NONE;
3480} 3483}
3481 3484
3482static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3485static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3483{ 3486{
3484 GSM_Error error; 3487 GSM_Error error;
3485 unsigned int val; 3488 unsigned int val;
3486 bool contact_set = false; 3489 bool contact_set = false;
3487 bool phone_set = false; 3490 bool phone_set = false;
3488 int i; 3491 int i;
3489 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3492 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3490 3493
3491 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3494 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3492 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error; 3495 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error;
3493 3496
3494 switch (ToDo->Priority) { 3497 switch (ToDo->Priority) {
3495 case GSM_Priority_High: 3498 case GSM_Priority_High:
3496 val = 0; 3499 val = 0;
3497 break; 3500 break;
3498 case GSM_Priority_Low: 3501 case GSM_Priority_Low:
3499 val = 2; 3502 val = 2;
3500 break; 3503 break;
3501 case GSM_Priority_Medium: 3504 case GSM_Priority_Medium:
3502 default: 3505 default:
3503 val = 1; 3506 val = 1;
3504 break; 3507 break;
3505 } 3508 }
3506 /* This one seems to be byte for BF5 and enum for BE5 */ 3509 /* This one seems to be byte for BF5 and enum for BE5 */
3507 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 3510 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
3508 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 7, &val)) != ERR_NONE) return error; 3511 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 7, &val)) != ERR_NONE) return error;
3509 } else { 3512 } else {
3510 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; 3513 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error;
3511 } 3514 }
3512 3515
3513 for (i = 0; i < ToDo->EntriesNum; i++) { 3516 for (i = 0; i < ToDo->EntriesNum; i++) {
3514 switch (ToDo->Entries[i].EntryType) { 3517 switch (ToDo->Entries[i].EntryType) {
3515 case TODO_END_DATETIME: 3518 case TODO_END_DATETIME:
3516 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3519 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3517 break; 3520 break;
3518 case TODO_COMPLETED: 3521 case TODO_COMPLETED:
3519 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3522 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3520 break; 3523 break;
3521 case TODO_ALARM_DATETIME: 3524 case TODO_ALARM_DATETIME:
3522 if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3525 if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3523 if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3526 if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3524 if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3527 if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3525 if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3528 if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3526 break; 3529 break;
3527 case TODO_TEXT: 3530 case TODO_TEXT:
3528 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3531 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3529 break; 3532 break;
3530 case TODO_PRIVATE: 3533 case TODO_PRIVATE:
3531 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3534 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3532 break; 3535 break;
3533 case TODO_CATEGORY: 3536 case TODO_CATEGORY:
3534 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3537 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3535 break; 3538 break;
3536 case TODO_CONTACTID: 3539 case TODO_CONTACTID:
3537 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3540 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3538 contact_set = true; 3541 contact_set = true;
3539 break; 3542 break;
3540 case TODO_PHONE: 3543 case TODO_PHONE:
3541 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3544 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3542 phone_set = true; 3545 phone_set = true;
3543 break; 3546 break;
3544 default: 3547 default:
3545 break; 3548 break;
3546 } 3549 }
3547 } 3550 }
3548 if (!contact_set) { 3551 if (!contact_set) {
3549 if (phone_set) { 3552 if (phone_set) {
3550 val = 0xffffffff; 3553 val = 0xffffffff;
3551 } else { 3554 } else {
3552 val = 0; 3555 val = 0;
3553 } 3556 }
3554 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; 3557 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error;
3555 } 3558 }
3556 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3559 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3557 ToDo->Location = Priv->CommitedRecord; 3560 ToDo->Location = Priv->CommitedRecord;
3558 /* Refresh list */ 3561 /* Refresh list */
3559 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3562 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3560 return ERR_NONE; 3563 return ERR_NONE;
3561} 3564}
3562 3565
3563static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3566static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3564{ 3567{
3565 GSM_Error error; 3568 GSM_Error error;
3566 unsigned int val; 3569 unsigned int val;
3567 bool contact_set = false; 3570 bool contact_set = false;
3568 bool phone_set = false; 3571 bool phone_set = false;
3569 bool UpdatedFields[12]; 3572 bool UpdatedFields[12];
3570 int i; 3573 int i;
3571 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3574 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3572 3575
3573 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3576 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3574 /* Save modified ToDo */ 3577 /* Save modified ToDo */
3575 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3578 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3576 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { 3579 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) {
3577 /* Entry doesn't exist, we will create new one */ 3580 /* Entry doesn't exist, we will create new one */
3578 return ALCATEL_AddToDo(s, ToDo); 3581 return ALCATEL_AddToDo(s, ToDo);
3579 } 3582 }
3580 /* Get fields for current item */ 3583 /* Get fields for current item */
3581 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; 3584 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error;
3582 3585
3583 for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } 3586 for (i = 0; i < 12; i++) { UpdatedFields[i] = false; }
3584 3587
3585 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error; 3588 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error;
3586 3589
3587 switch (ToDo->Priority) { 3590 switch (ToDo->Priority) {
3588 case GSM_Priority_High: 3591 case GSM_Priority_High:
3589 val = 0; 3592 val = 0;
3590 break; 3593 break;
3591 case GSM_Priority_Low: 3594 case GSM_Priority_Low:
3592 val = 2; 3595 val = 2;
3593 break; 3596 break;
3594 case GSM_Priority_Medium: 3597 case GSM_Priority_Medium:
3595 default: 3598 default:
3596 val = 1; 3599 val = 1;
3597 break; 3600 break;
3598 } 3601 }
3599 /* This one seems to be byte for BF5 and enum for BE5 */ 3602 /* This one seems to be byte for BF5 and enum for BE5 */
3600 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 3603 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
3601 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3604 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3602 } else { 3605 } else {
3603 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3606 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3604 } 3607 }
3605 UpdatedFields[7] = true; 3608 UpdatedFields[7] = true;
3606 3609
3607 for (i = 0; i < ToDo->EntriesNum; i++) { 3610 for (i = 0; i < ToDo->EntriesNum; i++) {
3608 switch (ToDo->Entries[i].EntryType) { 3611 switch (ToDo->Entries[i].EntryType) {
3609 case TODO_END_DATETIME: 3612 case TODO_END_DATETIME:
3610 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3613 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3611 UpdatedFields[0] = true; 3614 UpdatedFields[0] = true;
3612 break; 3615 break;
3613 case TODO_COMPLETED: 3616 case TODO_COMPLETED:
3614 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3617 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3615 UpdatedFields[1] = true; 3618 UpdatedFields[1] = true;
3616 break; 3619 break;
3617 case TODO_ALARM_DATETIME: 3620 case TODO_ALARM_DATETIME:
3618 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3621 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3619 UpdatedFields[2] = true; 3622 UpdatedFields[2] = true;
3620 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3623 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3621 UpdatedFields[3] = true; 3624 UpdatedFields[3] = true;
3622 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3625 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3623 UpdatedFields[10] = true; 3626 UpdatedFields[10] = true;
3624 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3627 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3625 UpdatedFields[11] = true; 3628 UpdatedFields[11] = true;
3626 break; 3629 break;
3627 case TODO_TEXT: 3630 case TODO_TEXT:
3628 if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3631 if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3629 UpdatedFields[4] = true; 3632 UpdatedFields[4] = true;
3630 break; 3633 break;
3631 case TODO_PRIVATE: 3634 case TODO_PRIVATE:
3632 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3635 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3633 UpdatedFields[5] = true; 3636 UpdatedFields[5] = true;
3634 break; 3637 break;
3635 case TODO_CATEGORY: 3638 case TODO_CATEGORY:
3636 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3639 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3637 UpdatedFields[6] = true; 3640 UpdatedFields[6] = true;
3638 break; 3641 break;
3639 case TODO_CONTACTID: 3642 case TODO_CONTACTID:
3640 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3643 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3641 UpdatedFields[8] = true; 3644 UpdatedFields[8] = true;
3642 contact_set = true; 3645 contact_set = true;
3643 break; 3646 break;
3644 case TODO_PHONE: 3647 case TODO_PHONE:
3645 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3648 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3646 UpdatedFields[9] = true; 3649 UpdatedFields[9] = true;
3647 phone_set = true; 3650 phone_set = true;
3648 break; 3651 break;
3649 default: 3652 default:
3650 break; 3653 break;
3651 } 3654 }
3652 } 3655 }
3653 if (!contact_set) { 3656 if (!contact_set) {
3654 if (phone_set) { 3657 if (phone_set) {
3655 val = 0xffffffff; 3658 val = 0xffffffff;
3656 } else { 3659 } else {
3657 val = 0; 3660 val = 0;
3658 } 3661 }
3659 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error; 3662 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error;
3660 UpdatedFields[8] = true; 3663 UpdatedFields[8] = true;
3661 } 3664 }
3662 3665
3663 3666
3664 /* If we didn't update some field, we have to delete it... */ 3667 /* If we didn't update some field, we have to delete it... */
3665 for (i=0; i<Priv->CurrentFieldsCount; i++) { 3668 for (i=0; i<Priv->CurrentFieldsCount; i++) {
3666 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; 3669 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error;
3667 } 3670 }
3668 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3671 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3669 return ERR_NONE; 3672 return ERR_NONE;
3670} 3673}
3671 3674
3672static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3675static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3673{ 3676{
3674 GSM_Error error; 3677 GSM_Error error;
3675 3678
3676 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3679 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3677 /* Delete ToDo */ 3680 /* Delete ToDo */
3678 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3681 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3679 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { 3682 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) {
3680 /* Entry was empty => no error */ 3683 /* Entry was empty => no error */
3681 return ERR_NONE; 3684 return ERR_NONE;
3682 } 3685 }
3683 error = ALCATEL_DeleteItem(s, ToDo->Location); 3686 error = ALCATEL_DeleteItem(s, ToDo->Location);
3684 if (error != ERR_NONE) return error; 3687 if (error != ERR_NONE) return error;
3685 /* Refresh list */ 3688 /* Refresh list */
3686 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3689 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3687 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3690 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3688 return ERR_NONE; 3691 return ERR_NONE;
3689} 3692}
3690 3693
3691static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) 3694static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status)
3692{ 3695{
3693 GSM_Alcatel_BinaryTypetype; 3696 GSM_Alcatel_BinaryTypetype;
3694 GSM_Error error; 3697 GSM_Error error;
@@ -3777,215 +3780,224 @@ static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine
3777 *- phone needs PIN code 3780 *- phone needs PIN code
3778 *- we want to close not opened session 3781 *- we want to close not opened session
3779 * For normal users the second case shouldn't occur... 3782 * For normal users the second case shouldn't occur...
3780 */ 3783 */
3781 return ERR_SECURITYERROR; 3784 return ERR_SECURITYERROR;
3782 case 0x14: /* Bad data */ 3785 case 0x14: /* Bad data */
3783 case 0x2f: /* Closing session when not opened */ 3786 case 0x2f: /* Closing session when not opened */
3784 case 0x1f: /* Bad in/out counter in packet/ack */ 3787 case 0x1f: /* Bad in/out counter in packet/ack */
3785 case 0x0e: /* Openning session when not closed */ 3788 case 0x0e: /* Openning session when not closed */
3786 case 0x0C: /* Bad id (item/database) */ 3789 case 0x0C: /* Bad id (item/database) */
3787 case 0x11: /* Bad list id */ 3790 case 0x11: /* Bad list id */
3788 case 0x2A: /* Nonexistant field/item id */ 3791 case 0x2A: /* Nonexistant field/item id */
3789 case 0x35: /* Too long text */ 3792 case 0x35: /* Too long text */
3790 return ERR_BUG; 3793 return ERR_BUG;
3791 case 0x23: /* Session opened */ 3794 case 0x23: /* Session opened */
3792 case 0x80: /* Transfer started */ 3795 case 0x80: /* Transfer started */
3793 return ERR_NONE; 3796 return ERR_NONE;
3794 case 0x82: /* Transfer canceled */ 3797 case 0x82: /* Transfer canceled */
3795 return ERR_CANCELED; 3798 return ERR_CANCELED;
3796 default: 3799 default:
3797 smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]); 3800 smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]);
3798 return ERR_NONE; 3801 return ERR_NONE;
3799 } 3802 }
3800} 3803}
3801 3804
3802static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) 3805static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s)
3803{ 3806{
3804 s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24); 3807 s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24);
3805 smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord); 3808 smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord);
3806 return ERR_NONE; 3809 return ERR_NONE;
3807} 3810}
3808 3811
3809static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) 3812static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable)
3810{ 3813{
3811 GSM_Error error; 3814 GSM_Error error;
3812 3815
3813 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3816 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3814 return ATGEN_SetIncomingCB(s, enable); 3817 return ATGEN_SetIncomingCB(s, enable);
3815} 3818}
3816 3819
3817static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) 3820static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
3818{ 3821{
3819 GSM_Error error; 3822 GSM_Error error;
3820 3823
3821 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3824 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3822 return ATGEN_SetIncomingSMS(s, enable); 3825 return ATGEN_SetIncomingSMS(s, enable);
3823} 3826}
3824 3827
3828static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3829{
3830 GSM_Error error;
3831
3832 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3833 return ATGEN_SetFastSMSSending(s, enable);
3834}
3835
3825static GSM_Reply_Function ALCATELReplyFunctions[] = { 3836static GSM_Reply_Function ALCATELReplyFunctions[] = {
3826 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, 3837 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach },
3827 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, 3838 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach },
3828 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, 3839 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit },
3829 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, 3840 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 },
3830 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, 3841 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd },
3831 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, 3842 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose },
3832 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, 3843 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart },
3833 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, 3844 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 },
3834 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, 3845 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 },
3835 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, 3846 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 },
3836 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, 3847 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 },
3837 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, 3848 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 },
3838 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, 3849 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 },
3839 {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, 3850 {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 },
3840 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, 3851 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1},
3841 {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, 3852 {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2},
3842 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, 3853 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1},
3843 {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, 3854 {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2},
3844 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, 3855 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1},
3845 {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, 3856 {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2},
3846 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, 3857 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 },
3847 {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, 3858 {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 },
3848 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, 3859 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1},
3849 {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, 3860 {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2},
3850 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, 3861 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField },
3851 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, 3862 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 },
3852 {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, 3863 {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 },
3853 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, 3864 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField },
3854 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, 3865 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField },
3855 {NULL, "\x00",0x00,0x00, ID_None } 3866 {NULL, "\x00",0x00,0x00, ID_None }
3856}; 3867};
3857 3868
3858GSM_Phone_Functions ALCATELPhone = { 3869GSM_Phone_Functions ALCATELPhone = {
3859 /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all 3870 /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all
3860 * they were ever really released, if yes add them here also. 3871 * they were ever really released, if yes add them here also.
3861 */ 3872 */
3862 "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", 3873 "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4",
3863 ALCATELReplyFunctions, 3874 ALCATELReplyFunctions,
3864 ALCATEL_Initialise, 3875 ALCATEL_Initialise,
3865 ALCATEL_Terminate, 3876 ALCATEL_Terminate,
3866 ALCATEL_DispatchMessage, 3877 ALCATEL_DispatchMessage,
3867 NOTSUPPORTED, /* ShowStartInfo */ 3878 NOTSUPPORTED, /* ShowStartInfo */
3868 ALCATEL_GetManufacturer, 3879 ALCATEL_GetManufacturer,
3869 ALCATEL_GetModel, 3880 ALCATEL_GetModel,
3870 ALCATEL_GetFirmware, 3881 ALCATEL_GetFirmware,
3871 ALCATEL_GetIMEI, 3882 ALCATEL_GetIMEI,
3872 NOTSUPPORTED, /* GetOriginalIMEI */ 3883 NOTSUPPORTED, /* GetOriginalIMEI */
3873 NOTSUPPORTED, /* GetManufactureMonth*/ 3884 NOTSUPPORTED, /* GetManufactureMonth*/
3874 ALCATEL_GetProductCode, 3885 ALCATEL_GetProductCode,
3875 NOTSUPPORTED, /* GetHardware */ 3886 NOTSUPPORTED, /* GetHardware */
3876 NOTSUPPORTED, /* GetPPM */ 3887 NOTSUPPORTED, /* GetPPM */
3877 ALCATEL_GetSIMIMSI, 3888 ALCATEL_GetSIMIMSI,
3878 ALCATEL_GetDateTime, 3889 ALCATEL_GetDateTime,
3879 ALCATEL_SetDateTime, 3890 ALCATEL_SetDateTime,
3880 ALCATEL_GetAlarm, 3891 ALCATEL_GetAlarm,
3881 ALCATEL_SetAlarm, 3892 ALCATEL_SetAlarm,
3882 NOTSUPPORTED, /* GetLocale */ 3893 NOTSUPPORTED, /* GetLocale */
3883 NOTSUPPORTED, /* SetLocale */ 3894 NOTSUPPORTED, /* SetLocale */
3884 ALCATEL_PressKey, 3895 ALCATEL_PressKey,
3885 ALCATEL_Reset, 3896 ALCATEL_Reset,
3886 ALCATEL_ResetPhoneSettings, 3897 ALCATEL_ResetPhoneSettings,
3887 ALCATEL_EnterSecurityCode, 3898 ALCATEL_EnterSecurityCode,
3888 ALCATEL_GetSecurityStatus, 3899 ALCATEL_GetSecurityStatus,
3889 ALCATEL_GetDisplayStatus, 3900 ALCATEL_GetDisplayStatus,
3890 ALCATEL_SetAutoNetworkLogin, 3901 ALCATEL_SetAutoNetworkLogin,
3891 ALCATEL_GetBatteryCharge, 3902 ALCATEL_GetBatteryCharge,
3892 ALCATEL_GetSignalStrength, 3903 ALCATEL_GetSignalStrength,
3893 ALCATEL_GetNetworkInfo, 3904 ALCATEL_GetNetworkInfo,
3894 ALCATEL_GetCategory, 3905 ALCATEL_GetCategory,
3895 ALCATEL_AddCategory, 3906 ALCATEL_AddCategory,
3896 ALCATEL_GetCategoryStatus, 3907 ALCATEL_GetCategoryStatus,
3897 ALCATEL_GetMemoryStatus, 3908 ALCATEL_GetMemoryStatus,
3898 ALCATEL_GetMemory, 3909 ALCATEL_GetMemory,
3899 ALCATEL_GetNextMemory, 3910 ALCATEL_GetNextMemory,
3900 ALCATEL_SetMemory, 3911 ALCATEL_SetMemory,
3901 ALCATEL_AddMemory, 3912 ALCATEL_AddMemory,
3902 ALCATEL_DeleteMemory, 3913 ALCATEL_DeleteMemory,
3903 ALCATEL_DeleteAllMemory, 3914 ALCATEL_DeleteAllMemory,
3904 NOTSUPPORTED, /* GetSpeedDial */ 3915 NOTSUPPORTED, /* GetSpeedDial */
3905 NOTSUPPORTED, /* SetSpeedDial */ 3916 NOTSUPPORTED, /* SetSpeedDial */
3906 ALCATEL_GetSMSC, 3917 ALCATEL_GetSMSC,
3907 ALCATEL_SetSMSC, 3918 ALCATEL_SetSMSC,
3908 ALCATEL_GetSMSStatus, 3919 ALCATEL_GetSMSStatus,
3909 ALCATEL_GetSMS, 3920 ALCATEL_GetSMS,
3910 ALCATEL_GetNextSMS, 3921 ALCATEL_GetNextSMS,
3911 NOTSUPPORTED, /* SetSMS */ 3922 NOTSUPPORTED, /* SetSMS */
3912 ALCATEL_AddSMS, 3923 ALCATEL_AddSMS,
3913 ALCATEL_DeleteSMS, 3924 ALCATEL_DeleteSMS,
3914 ALCATEL_SendSMS, 3925 ALCATEL_SendSMS,
3915 ALCATEL_SendSavedSMS, 3926 ALCATEL_SendSavedSMS,
3927 ALCATEL_SetFastSMSSending,
3916 ALCATEL_SetIncomingSMS, 3928 ALCATEL_SetIncomingSMS,
3917 ALCATEL_SetIncomingCB, 3929 ALCATEL_SetIncomingCB,
3918 ALCATEL_GetSMSFolders, 3930 ALCATEL_GetSMSFolders,
3919 NOTSUPPORTED, /* AddSMSFolder */ 3931 NOTSUPPORTED, /* AddSMSFolder */
3920 NOTSUPPORTED, /* DeleteSMSFolder */ 3932 NOTSUPPORTED, /* DeleteSMSFolder */
3921 ALCATEL_DialVoice, 3933 ALCATEL_DialVoice,
3922 ALCATEL_AnswerCall, 3934 ALCATEL_AnswerCall,
3923 ALCATEL_CancelCall, 3935 ALCATEL_CancelCall,
3924 NOTSUPPORTED, /* HoldCall */ 3936 NOTSUPPORTED, /* HoldCall */
3925 NOTSUPPORTED, /* UnholdCall */ 3937 NOTSUPPORTED, /* UnholdCall */
3926 NOTSUPPORTED, /* ConferenceCall */ 3938 NOTSUPPORTED, /* ConferenceCall */
3927 NOTSUPPORTED, /* SplitCall */ 3939 NOTSUPPORTED, /* SplitCall */
3928 NOTSUPPORTED, /* TransferCall */ 3940 NOTSUPPORTED, /* TransferCall */
3929 NOTSUPPORTED, /* SwitchCall */ 3941 NOTSUPPORTED, /* SwitchCall */
3930 NOTSUPPORTED, /* GetCallDivert */ 3942 NOTSUPPORTED, /* GetCallDivert */
3931 NOTSUPPORTED, /* SetCallDivert */ 3943 NOTSUPPORTED, /* SetCallDivert */
3932 NOTSUPPORTED, /* CancelAllDiverts*/ 3944 NOTSUPPORTED, /* CancelAllDiverts*/
3933 NONEFUNCTION, /* SetIncomingCall */ 3945 NONEFUNCTION, /* SetIncomingCall */
3934 NOTSUPPORTED, /* SetIncomingUSSD */ 3946 NOTSUPPORTED, /* SetIncomingUSSD */
3935 ALCATEL_SendDTMF, 3947 ALCATEL_SendDTMF,
3936 NOTSUPPORTED, /* GetRingtone */ 3948 NOTSUPPORTED, /* GetRingtone */
3937 NOTSUPPORTED, /* SetRingtone */ 3949 NOTSUPPORTED, /* SetRingtone */
3938 NOTSUPPORTED, /* GetRingtonesInfo*/ 3950 NOTSUPPORTED, /* GetRingtonesInfo*/
3939 NOTSUPPORTED, /* DeleteUserRingtones*/ 3951 NOTSUPPORTED, /* DeleteUserRingtones*/
3940 NOTSUPPORTED, /* PlayTone */ 3952 NOTSUPPORTED, /* PlayTone */
3941 NOTSUPPORTED, /* GetWAPBookmark */ 3953 NOTSUPPORTED, /* GetWAPBookmark */
3942 NOTSUPPORTED, /* SetWAPBookmark */ 3954 NOTSUPPORTED, /* SetWAPBookmark */
3943 NOTSUPPORTED, /* DeleteWAPBookmark*/ 3955 NOTSUPPORTED, /* DeleteWAPBookmark*/
3944 NOTSUPPORTED, /* GetWAPSettings */ 3956 NOTSUPPORTED, /* GetWAPSettings */
3945 NOTSUPPORTED, /* SetWAPSettings */ 3957 NOTSUPPORTED, /* SetWAPSettings */
3946 NOTSUPPORTED, /* GetMMSSettings */ 3958 NOTSUPPORTED, /* GetMMSSettings */
3947 NOTSUPPORTED, /* SetMMSSettings */ 3959 NOTSUPPORTED, /* SetMMSSettings */
3948 NOTSUPPORTED, /* GetSyncMLSettings*/ 3960 NOTSUPPORTED, /* GetSyncMLSettings*/
3949 NOTSUPPORTED, /* SetSyncMLSettings*/ 3961 NOTSUPPORTED, /* SetSyncMLSettings*/
3950 NOTSUPPORTED, /* GetChatSettings */ 3962 NOTSUPPORTED, /* GetChatSettings */
3951 NOTSUPPORTED, /* SetChatSettings */ 3963 NOTSUPPORTED, /* SetChatSettings */
3952 NOTSUPPORTED, /* GetBitmap */ 3964 NOTSUPPORTED, /* GetBitmap */
3953 NOTSUPPORTED, /* SetBitmap */ 3965 NOTSUPPORTED, /* SetBitmap */
3954 ALCATEL_GetToDoStatus, 3966 ALCATEL_GetToDoStatus,
3955 ALCATEL_GetToDo, 3967 ALCATEL_GetToDo,
3956 ALCATEL_GetNextToDo, 3968 ALCATEL_GetNextToDo,
3957 ALCATEL_SetToDo, 3969 ALCATEL_SetToDo,
3958 ALCATEL_AddToDo, 3970 ALCATEL_AddToDo,
3959 ALCATEL_DeleteToDo, 3971 ALCATEL_DeleteToDo,
3960 ALCATEL_DeleteAllToDo, 3972 ALCATEL_DeleteAllToDo,
3961 ALCATEL_GetCalendarStatus, 3973 ALCATEL_GetCalendarStatus,
3962 ALCATEL_GetCalendar, 3974 ALCATEL_GetCalendar,
3963 ALCATEL_GetNextCalendar, 3975 ALCATEL_GetNextCalendar,
3964 ALCATEL_SetCalendar, 3976 ALCATEL_SetCalendar,
3965 ALCATEL_AddCalendar, 3977 ALCATEL_AddCalendar,
3966 ALCATEL_DeleteCalendar, 3978 ALCATEL_DeleteCalendar,
3967 ALCATEL_DeleteAllCalendar, 3979 ALCATEL_DeleteAllCalendar,
3968 NOTSUPPORTED, /* GetCalendarSettings*/ 3980 NOTSUPPORTED, /* GetCalendarSettings*/
3969 NOTSUPPORTED, /* SetCalendarSettings*/ 3981 NOTSUPPORTED, /* SetCalendarSettings*/
3970 NOTSUPPORTED, /* GetNote */ 3982 NOTSUPPORTED, /* GetNextNote */
3971 NOTSUPPORTED, /* GetProfile */ 3983 NOTSUPPORTED, /* GetProfile */
3972 NOTSUPPORTED, /* SetProfile */ 3984 NOTSUPPORTED, /* SetProfile */
3973 NOTSUPPORTED, /* GetFMStation */ 3985 NOTSUPPORTED, /* GetFMStation */
3974 NOTSUPPORTED, /* SetFMStation */ 3986 NOTSUPPORTED, /* SetFMStation */
3975 NOTSUPPORTED, /* ClearFMStations */ 3987 NOTSUPPORTED, /* ClearFMStations */
3976 NOTSUPPORTED, /* GetNextFileFolder*/ 3988 NOTSUPPORTED, /* GetNextFileFolder*/
3977 NOTSUPPORTED, /* GetFilePart */ 3989 NOTSUPPORTED, /* GetFilePart */
3978 NOTSUPPORTED, /* AddFilePart */ 3990 NOTSUPPORTED, /* AddFilePart */
3979 NOTSUPPORTED, /* GetFileSystemStatus*/ 3991 NOTSUPPORTED, /* GetFileSystemStatus*/
3980 NOTSUPPORTED, /* DeleteFile */ 3992 NOTSUPPORTED, /* DeleteFile */
3981 NOTSUPPORTED, /* AddFolder */ 3993 NOTSUPPORTED, /* AddFolder */
3982 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3994 NOTSUPPORTED, /* GetGPRSAccessPoint*/
3983 NOTSUPPORTED /* SetGPRSAccessPoint*/ 3995 NOTSUPPORTED /* SetGPRSAccessPoint*/
3984}; 3996};
3985 3997
3986#endif 3998#endif
3987#endif 3999#endif
3988 4000
3989/* How should editor hadle tabs in this file? Add editor commands here. 4001/* How should editor hadle tabs in this file? Add editor commands here.
3990 * vim: noexpandtab sw=8 ts=8 sts=8: 4002 * vim: noexpandtab sw=8 ts=8 sts=8:
3991 */ 4003 */
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index 1834f15..ba23eb2 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -1,93 +1,73 @@
1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13#include "../../service/sms/gsmsms.h" 13#include "../../service/sms/gsmsms.h"
14#include "../pfunc.h" 14#include "../pfunc.h"
15
15#include "atgen.h" 16#include "atgen.h"
16 17
18#include "samsung.h"
19#include "siemens.h"
20#include "sonyeric.h"
21
17#ifdef GSM_ENABLE_ALCATEL 22#ifdef GSM_ENABLE_ALCATEL
18 extern GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s); 23GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *);
19#endif 24#endif
20 25
21 extern GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
22 extern GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
23 extern GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
24 extern GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
25 extern GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s);
26 extern GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
27 extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
28 extern GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s);
29
30 extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
31 extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
32 extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
33 extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
34 extern GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
35 extern GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
36 extern GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
37
38 extern GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
39 extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
40 extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status);
41 extern GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
42 extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
43 extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s);
44 extern GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
45 extern GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status);
46 26
47typedef struct { 27typedef struct {
48 int Number; 28 int Number;
49 char Text[60]; 29 char Text[60];
50} ATErrorCode; 30} ATErrorCode;
51 31
52static ATErrorCode CMSErrorCodes[] = { 32static ATErrorCode CMSErrorCodes[] = {
53 /* 33 /*
54 * Error codes not specified here were either undefined or reserved in my 34 * Error codes not specified here were either undefined or reserved in my
55 * copy of specifications, if you have newer one, please fill in the gaps. 35 * copy of specifications, if you have newer one, please fill in the gaps.
56 */ 36 */
57 /* 0...127 from GSM 04.11 Annex E-2 */ 37 /* 0...127 from GSM 04.11 Annex E-2 */
58 {1, "Unassigned (unallocated) number"}, 38 {1, "Unassigned (unallocated) number"},
59 {8, "Operator determined barring"}, 39 {8, "Operator determined barring"},
60 {10, "Call barred"}, 40 {10, "Call barred"},
61 {21, "Short message transfer rejected"}, 41 {21, "Short message transfer rejected"},
62 {27, "Destination out of service"}, 42 {27, "Destination out of service"},
63 {28, "Unidentified subscriber"}, 43 {28, "Unidentified subscriber"},
64 {29, "Facility rejected"}, 44 {29, "Facility rejected"},
65 {30, "Unknown subscriber"}, 45 {30, "Unknown subscriber"},
66 {38, "Network out of order"}, 46 {38, "Network out of order"},
67 {41, "Temporary failure"}, 47 {41, "Temporary failure"},
68 {42, "Congestion"}, 48 {42, "Congestion"},
69 {47, "Resources unavailable, unspecified"}, 49 {47, "Resources unavailable, unspecified"},
70 {50, "Requested facility not subscribed"}, 50 {50, "Requested facility not subscribed"},
71 {69, "Requested facility not implemented"}, 51 {69, "Requested facility not implemented"},
72 {81, "Invalid short message transfer reference value"}, 52 {81, "Invalid short message transfer reference value"},
73 {95, "Invalid message, unspecified"}, 53 {95, "Invalid message, unspecified"},
74 {96, "Invalid mandatory information"}, 54 {96, "Invalid mandatory information"},
75 {97, "Message type non-existent or not implemented"}, 55 {97, "Message type non-existent or not implemented"},
76 {98, "Message not compatible with short message protocol state"}, 56 {98, "Message not compatible with short message protocol state"},
77 {99, "Information element non-existent or not implemented"}, 57 {99, "Information element non-existent or not implemented"},
78 {111, "Protocol error, unspecified"}, 58 {111, "Protocol error, unspecified"},
79 {127, "Interworking, unspecified"}, 59 {127, "Interworking, unspecified"},
80 /* 128...255 from GSM 03.40 subclause 9.2.3.22 */ 60 /* 128...255 from GSM 03.40 subclause 9.2.3.22 */
81 {0x80, "Telematic interworking not supported"}, 61 {0x80, "Telematic interworking not supported"},
82 {0x81, "Short message Type 0 not supported"}, 62 {0x81, "Short message Type 0 not supported"},
83 {0x82, "Cannot replace short message"}, 63 {0x82, "Cannot replace short message"},
84 {0x8F, "Unspecified TP-PID error"}, 64 {0x8F, "Unspecified TP-PID error"},
85 {0x90, "Data coding scheme (alphabet) not supported"}, 65 {0x90, "Data coding scheme (alphabet) not supported"},
86 {0x91, "Message class not supported"}, 66 {0x91, "Message class not supported"},
87 {0x9F, "Unspecified TP-DCS error"}, 67 {0x9F, "Unspecified TP-DCS error"},
88 {0xA0, "Command cannot be actioned"}, 68 {0xA0, "Command cannot be actioned"},
89 {0xA1, "Command unsupported"}, 69 {0xA1, "Command unsupported"},
90 {0xAF, "Unspecified TP-Command error"}, 70 {0xAF, "Unspecified TP-Command error"},
91 {0xB0, "TPDU not supported"}, 71 {0xB0, "TPDU not supported"},
92 {0xC0, "SC busy"}, 72 {0xC0, "SC busy"},
93 {0xC1, "No SC subscription"}, 73 {0xC1, "No SC subscription"},
@@ -130,402 +110,467 @@ static ATErrorCode CMSErrorCodes[] = {
130 /* > 512 are manufacturer specific according to GSM 07.05 subclause 3.2.5 */ 110 /* > 512 are manufacturer specific according to GSM 07.05 subclause 3.2.5 */
131 {-1, ""} 111 {-1, ""}
132}; 112};
133 113
134static ATErrorCode CMEErrorCodes[] = { 114static ATErrorCode CMEErrorCodes[] = {
135 /* CME Error codes from GSM 07.07 section 9.2 */ 115 /* CME Error codes from GSM 07.07 section 9.2 */
136 {0, "phone failure"}, 116 {0, "phone failure"},
137 {1, "no connection to phone"}, 117 {1, "no connection to phone"},
138 {2, "phone-adaptor link reserved"}, 118 {2, "phone-adaptor link reserved"},
139 {3, "operation not allowed"}, 119 {3, "operation not allowed"},
140 {4, "operation not supported"}, 120 {4, "operation not supported"},
141 {5, "PH-SIM PIN required"}, 121 {5, "PH-SIM PIN required"},
142 {10, "SIM not inserted"}, 122 {10, "SIM not inserted"},
143 {11, "SIM PIN required"}, 123 {11, "SIM PIN required"},
144 {12, "SIM PUK required"}, 124 {12, "SIM PUK required"},
145 {13, "SIM failure"}, 125 {13, "SIM failure"},
146 {14, "SIM busy"}, 126 {14, "SIM busy"},
147 {15, "SIM wrong"}, 127 {15, "SIM wrong"},
148 {16, "incorrect password"}, 128 {16, "incorrect password"},
149 {17, "SIM PIN2 required"}, 129 {17, "SIM PIN2 required"},
150 {18, "SIM PUK2 required"}, 130 {18, "SIM PUK2 required"},
151 {20, "memory full"}, 131 {20, "memory full"},
152 {21, "invalid index"}, 132 {21, "invalid index"},
153 {22, "not found"}, 133 {22, "not found"},
154 {23, "memory failure"}, 134 {23, "memory failure"},
155 {24, "text string too long"}, 135 {24, "text string too long"},
156 {25, "invalid characters in text string"}, 136 {25, "invalid characters in text string"},
157 {26, "dial string too long"}, 137 {26, "dial string too long"},
158 {27, "invalid characters in dial string"}, 138 {27, "invalid characters in dial string"},
159 {30, "no network service"}, 139 {30, "no network service"},
160 {31, "network timeout"}, 140 {31, "network timeout"},
161 {100, "unknown"}, 141 {100, "unknown"},
162}; 142};
163 143
164 144
165GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s) 145GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
166{ 146{
167 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 147 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
168 148
169 if (Priv->ErrorCode == 0) { 149 if (Priv->ErrorCode == 0) {
170 smprintf(s, "CME Error occured, but it's type not detected\n"); 150 smprintf(s, "CME Error occured, but it's type not detected\n");
171 } else if (Priv->ErrorText == NULL) { 151 } else if (Priv->ErrorText == NULL) {
172 smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode); 152 smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode);
173 } else { 153 } else {
174 smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText); 154 smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText);
175 } 155 }
176 /* For error codes descriptions see table a bit above */ 156 /* For error codes descriptions see table a bit above */
177 switch (Priv->ErrorCode) { 157 switch (Priv->ErrorCode) {
158 case -1:
159 return ERR_EMPTY;
178 case 3: 160 case 3:
179 return ERR_PERMISSION; 161 return ERR_PERMISSION;
180 case 4: 162 case 4:
181 return ERR_NOTSUPPORTED; 163 return ERR_NOTSUPPORTED;
182 case 5: 164 case 5:
183 case 11: 165 case 11:
184 case 12: 166 case 12:
185 case 16: 167 case 16:
186 case 17: 168 case 17:
187 case 18: 169 case 18:
188 return ERR_SECURITYERROR; 170 return ERR_SECURITYERROR;
189 case 20: 171 case 20:
190 return ERR_FULL; 172 return ERR_FULL;
191 case 21: 173 case 21:
192 return ERR_INVALIDLOCATION; 174 return ERR_INVALIDLOCATION;
193 case 22: 175 case 22:
194 return ERR_EMPTY; 176 return ERR_EMPTY;
195 case 23: 177 case 23:
196 return ERR_MEMORY; 178 return ERR_MEMORY;
197 case 24: 179 case 24:
198 case 25: 180 case 25:
199 case 26: 181 case 26:
200 case 27: 182 case 27:
201 return ERR_INVALIDDATA; 183 return ERR_INVALIDDATA;
202 default: 184 default:
203 return ERR_UNKNOWN; 185 return ERR_UNKNOWN;
204 } 186 }
205} 187}
206 188
207GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s) 189GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s)
208{ 190{
209 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 191 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
210 192
211 if (Priv->ErrorCode == 0) { 193 if (Priv->ErrorCode == 0) {
212 smprintf(s, "CMS Error occured, but it's type not detected\n"); 194 smprintf(s, "CMS Error occured, but it's type not detected\n");
213 } else if (Priv->ErrorText == NULL) { 195 } else if (Priv->ErrorText == NULL) {
214 smprintf(s, "CMS Error %i, no description available\n", Priv->ErrorCode); 196 smprintf(s, "CMS Error %i, no description available\n", Priv->ErrorCode);
215 } else { 197 } else {
216 smprintf(s, "CMS Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText); 198 smprintf(s, "CMS Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText);
217 } 199 }
218 /* For error codes descriptions see table a bit above */ 200 /* For error codes descriptions see table a bit above */
219 switch (Priv->ErrorCode) { 201 switch (Priv->ErrorCode) {
220 case 304: 202 case 304:
221 return ERR_NOTSUPPORTED; 203 return ERR_NOTSUPPORTED;
222 case 305: 204 case 305:
223 return ERR_BUG; 205 return ERR_BUG;
224 case 311: 206 case 311:
225 case 312: 207 case 312:
226 case 316: 208 case 316:
227 case 317: 209 case 317:
228 case 318: 210 case 318:
229 return ERR_SECURITYERROR; 211 return ERR_SECURITYERROR;
230 case 322: 212 case 322:
231 return ERR_FULL; 213 return ERR_FULL;
232 case 321: 214 case 321:
233 return ERR_INVALIDLOCATION; 215 return ERR_INVALIDLOCATION;
234 default: 216 default:
235 return ERR_UNKNOWN; 217 return ERR_UNKNOWN;
236 } 218 }
237} 219}
238 220
239/* FIXME: Function doesn't respect quoting of parameters and thus +FOO: 221/* FIXME: Function doesn't respect quoting of parameters and thus +FOO:
240 * "ab","cd,ef" will consider as three arguments: "ab" >> "cd >> ef" 222 * "ab","cd,ef" will consider as three arguments: "ab" >> "cd >> ef"
241 */ 223 */
242int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output) 224int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output)
243{ 225{
244 int position=0; 226 int position=0;
245 227
246 while (*input!=',' && *input!=0x0d && *input!=0x00) { 228 while (*input!=',' && *input!=0x0d && *input!=0x00) {
247 *output=*input; 229 *output=*input;
248 input++; 230 input++;
249 output++; 231 output++;
250 position++; 232 position++;
251 } 233 }
252 *output=0; 234 *output=0;
253 position++; 235 position++;
254 return position; 236 return position;
255} 237}
256 238
257void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input) 239void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input)
258{ 240{
259 dt->Year=2000+(*input-'0')*10; input++; 241 /* Samsung phones report year as %d instead of %02d */
242 if (input[2] == '/') {
243 dt->Year=(*input-'0')*10;
244 input++;
245 } else {
246 dt->Year=0;
247 }
248
260 dt->Year=dt->Year+(*input-'0'); input++; 249 dt->Year=dt->Year+(*input-'0'); input++;
250 dt->Year+=2000;
261 251
262 input++; 252 input++;
263 dt->Month=(*input-'0')*10; input++; 253 dt->Month=(*input-'0')*10; input++;
264 dt->Month=dt->Month+(*input-'0'); input++; 254 dt->Month=dt->Month+(*input-'0'); input++;
265 255
266 input++; 256 input++;
267 dt->Day=(*input-'0')*10; input++; 257 dt->Day=(*input-'0')*10; input++;
268 dt->Day=dt->Day+(*input-'0'); input++; 258 dt->Day=dt->Day+(*input-'0'); input++;
269 259
270 input++; 260 input++;
271 dt->Hour=(*input-'0')*10; input++; 261 dt->Hour=(*input-'0')*10; input++;
272 dt->Hour=dt->Hour+(*input-'0'); input++; 262 dt->Hour=dt->Hour+(*input-'0'); input++;
273 263
274 input++; 264 input++;
275 dt->Minute=(*input-'0')*10; input++; 265 dt->Minute=(*input-'0')*10; input++;
276 dt->Minute=dt->Minute+(*input-'0');input++; 266 dt->Minute=dt->Minute+(*input-'0');input++;
277 267
278 input++; 268 input++;
279 dt->Second=(*input-'0')*10; input++; 269 dt->Second=(*input-'0')*10; input++;
280 dt->Second=dt->Second+(*input-'0');input++; 270 dt->Second=dt->Second+(*input-'0');input++;
281 271
282 if (input!=NULL) { 272 if (input!=NULL) {
283 input++; 273 input++;
284 dt->Timezone=(*input-'0')*10; input++; 274 dt->Timezone=(*input-'0')*10; input++;
285 dt->Timezone=dt->Timezone+(*input-'0');input++; 275 dt->Timezone=dt->Timezone+(*input-'0');input++;
286 input=input-2; 276 input=input-2;
287 if (*input=='-') dt->Timezone=-dt->Timezone; 277 if (*input=='-') dt->Timezone=-dt->Timezone;
288 } 278 }
289} 279}
290 280
291GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s) 281GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
292{ 282{
293 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 283 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
294 GSM_Protocol_Message *msg= s->Phone.Data.RequestMsg; 284 GSM_Protocol_Message *msg= s->Phone.Data.RequestMsg;
295 int i= 0, j, k; 285 int i= 0, j, k;
296 char *err, *line; 286 char *err, *line;
297 ATErrorCode *ErrorCodes = NULL; 287 ATErrorCode *ErrorCodes = NULL;
298 288
299 SplitLines(msg->Buffer, msg->Length, &Priv->Lines, "\x0D\x0A", 2, true); 289 SplitLines(msg->Buffer, msg->Length, &Priv->Lines, "\x0D\x0A", 2, true);
300 290
301 /* Find number of lines */ 291 /* Find number of lines */
302 while (Priv->Lines.numbers[i*2+1] != 0) { 292 while (Priv->Lines.numbers[i*2+1] != 0) {
303 /* FIXME: handle special chars correctly */ 293 /* FIXME: handle special chars correctly */
304 smprintf(s, "%i \"%s\"\n",i+1,GetLineString(msg->Buffer,Priv->Lines,i+1)); 294 smprintf(s, "%i \"%s\"\n",i+1,GetLineString(msg->Buffer,Priv->Lines,i+1));
305 i++; 295 i++;
306 } 296 }
307 297
308 Priv->ReplyState = AT_Reply_Unknown; 298 Priv->ReplyState = AT_Reply_Unknown;
309 Priv->ErrorText = NULL; 299 Priv->ErrorText = NULL;
310 Priv->ErrorCode = 0; 300 Priv->ErrorCode = 0;
311 301
312 line = GetLineString(msg->Buffer,Priv->Lines,i); 302 line = GetLineString(msg->Buffer,Priv->Lines,i);
313 if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK; 303 if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK;
314 if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit; 304 if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit;
315 if (!strcmp(line,"CONNECT"))Priv->ReplyState = AT_Reply_Connect; 305 if (!strcmp(line,"CONNECT"))Priv->ReplyState = AT_Reply_Connect;
316 if (!strcmp(line,"ERROR" ))Priv->ReplyState = AT_Reply_Error; 306 if (!strcmp(line,"ERROR" ))Priv->ReplyState = AT_Reply_Error;
317 if (!strncmp(line,"+CME ERROR:",11)) { 307 if (!strncmp(line,"+CME ERROR:",11)) {
318 Priv->ReplyState = AT_Reply_CMEError; 308 Priv->ReplyState = AT_Reply_CMEError;
319 ErrorCodes = CMEErrorCodes; 309 ErrorCodes = CMEErrorCodes;
320 } 310 }
321 if (!strncmp(line,"+CMS ERROR:",11)) { 311 if (!strncmp(line,"+CMS ERROR:",11)) {
322 Priv->ReplyState = AT_Reply_CMSError; 312 Priv->ReplyState = AT_Reply_CMSError;
323 ErrorCodes = CMSErrorCodes; 313 ErrorCodes = CMSErrorCodes;
324 } 314 }
315
316 /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
317 if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
318 err = line + 11;
319 Priv->ErrorCode = atoi(err);
320
321 if (Priv->ErrorCode == -1) {
322 Priv->ErrorText = "[Samsung] Empty location";
323 return GSM_DispatchMessage(s);
324 }
325 }
326
325 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) { 327 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
326 j = 0; 328 j = 0;
327 /* One char behind +CM[SE] ERROR */ 329 /* One char behind +CM[SE] ERROR */
328 err = line + 12; 330 err = line + 12;
329 while (err[j] && !isalnum(err[j])) j++; 331 while (err[j] && !isalnum(err[j])) j++;
330 if (isdigit(err[j])) { 332 if (isdigit(err[j])) {
331 Priv->ErrorCode = atoi(&(err[j])); 333 Priv->ErrorCode = atoi(&(err[j]));
332 k = 0; 334 k = 0;
333 while (ErrorCodes[k].Number != -1) { 335 while (ErrorCodes[k].Number != -1) {
334 if (ErrorCodes[k].Number == Priv->ErrorCode) { 336 if (ErrorCodes[k].Number == Priv->ErrorCode) {
335 Priv->ErrorText = (char *)&(ErrorCodes[k].Text); 337 Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
336 break; 338 break;
337 } 339 }
338 k++; 340 k++;
339 } 341 }
340 } else if (isalpha(err[j])) { 342 } else if (isalpha(err[j])) {
341 k = 0; 343 k = 0;
342 while (ErrorCodes[k].Number != -1) { 344 while (ErrorCodes[k].Number != -1) {
343 if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) { 345 if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) {
344 Priv->ErrorCode = ErrorCodes[k].Number; 346 Priv->ErrorCode = ErrorCodes[k].Number;
345 Priv->ErrorText = (char *)&(ErrorCodes[k].Text); 347 Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
346 break; 348 break;
347 } 349 }
348 k++; 350 k++;
349 } 351 }
350 } 352 }
351 } 353 }
352 return GSM_DispatchMessage(s); 354 return GSM_DispatchMessage(s);
353} 355}
354 356
355GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 357GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
356{ 358{
357 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 359 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
358 case AT_Reply_OK: 360 case AT_Reply_OK:
359 case AT_Reply_Connect: 361 case AT_Reply_Connect:
360 return ERR_NONE; 362 return ERR_NONE;
361 case AT_Reply_Error: 363 case AT_Reply_Error:
362 return ERR_UNKNOWN; 364 return ERR_UNKNOWN;
363 case AT_Reply_CMSError: 365 case AT_Reply_CMSError:
364 return ATGEN_HandleCMSError(s); 366 return ATGEN_HandleCMSError(s);
365 case AT_Reply_CMEError: 367 case AT_Reply_CMEError:
366 return ATGEN_HandleCMEError(s); 368 return ATGEN_HandleCMEError(s);
367 default: 369 default:
368 break; 370 break;
369 } 371 }
370 return ERR_UNKNOWNRESPONSE; 372 return ERR_UNKNOWNRESPONSE;
371} 373}
372 374
375GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
376{
377 unsigned char buffer[2000],buffer2[4000];
378 int i = 10;
379
380 /* Ugly hack */
381 while (msg.Buffer[i]!=13) i++;
382 i = i - 6;
383 memcpy(buffer,msg.Buffer+10,i-11);
384 buffer[i-11] = 0x00;
385
386 smprintf(s, "USSD reply: \"%s\"\n",buffer);
387
388 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
389 EncodeUnicode(buffer2,buffer,strlen(buffer));
390 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
391 }
392
393 return ERR_NONE;
394}
395
396GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
397{
398 GSM_Error error;
399
400 if (enable) {
401 smprintf(s, "Enabling incoming USSD\n");
402 error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
403 } else {
404 smprintf(s, "Disabling incoming USSD\n");
405 error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
406 }
407 if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
408 return error;
409}
410
373GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) 411GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
374{ 412{
375 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 413 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
376 GSM_Phone_Data *Data = &s->Phone.Data; 414 GSM_Phone_Data *Data = &s->Phone.Data;
377 415
378 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED; 416 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED;
379 417
380 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) { 418 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) {
381 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2); 419 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2);
382 420
383 /* Sometimes phone adds this before manufacturer (Sagem) */ 421 /* Sometimes phone adds this before manufacturer (Sagem) */
384 if (strncmp("+CGMM: ", Data->Model, 7) == 0) { 422 if (strncmp("+CGMM: ", Data->Model, 7) == 0) {
385 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1); 423 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1);
386 } 424 }
387 425
388 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL); 426 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL);
389 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model); 427 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model);
390 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL); 428 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL);
391 429
392 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number); 430 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number);
393 431
394 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia; 432 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia;
395 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens; 433 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens;
396 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens; 434 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens;
435 else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens;
397 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP; 436 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
398 437
399 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20"); 438 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20");
400 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35"); 439 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35");
440 else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35");
401 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ"); 441 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
402 } else { 442 } else {
403 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); 443 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
404 } 444 }
405 445
406 return ERR_NONE; 446 return ERR_NONE;
407} 447}
408 448
409GSM_Error ATGEN_GetModel(GSM_StateMachine *s) 449GSM_Error ATGEN_GetModel(GSM_StateMachine *s)
410{ 450{
411 GSM_Error error; 451 GSM_Error error;
412 452
413 if (s->Phone.Data.Model[0] != 0) return ERR_NONE; 453 if (s->Phone.Data.Model[0] != 0) return ERR_NONE;
414 454
415 smprintf(s, "Getting model\n"); 455 smprintf(s, "Getting model\n");
416 error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel); 456 error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel);
417 if (error==ERR_NONE) { 457 if (error==ERR_NONE) {
418 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 458 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
419 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 459 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
420 smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model); 460 smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model);
421 } 461 }
422 } 462 }
423 return error; 463 return error;
424} 464}
425 465
426GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s) 466GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s)
427{ 467{
428 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 468 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
429 469
430 switch (Priv->ReplyState) { 470 switch (Priv->ReplyState) {
431 case AT_Reply_OK: 471 case AT_Reply_OK:
432 smprintf(s, "Manufacturer info received\n"); 472 smprintf(s, "Manufacturer info received\n");
433 Priv->Manufacturer = AT_Unknown; 473 Priv->Manufacturer = AT_Unknown;
434 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MANUFACTURER_LENGTH) { 474 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MANUFACTURER_LENGTH) {
435 CopyLineString(s->Phone.Data.Manufacturer, msg.Buffer, Priv->Lines, 2); 475 CopyLineString(s->Phone.Data.Manufacturer, msg.Buffer, Priv->Lines, 2);
436 } else { 476 } else {
437 smprintf(s, "WARNING: Manufacturer name too long, increase MAX_MANUFACTURER_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); 477 smprintf(s, "WARNING: Manufacturer name too long, increase MAX_MANUFACTURER_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
438 s->Phone.Data.Manufacturer[0] = 0; 478 s->Phone.Data.Manufacturer[0] = 0;
439 } 479 }
440 /* Sometimes phone adds this before manufacturer (Sagem) */ 480 /* Sometimes phone adds this before manufacturer (Sagem) */
441 if (strncmp("+CGMI: ", s->Phone.Data.Manufacturer, 7) == 0) { 481 if (strncmp("+CGMI: ", s->Phone.Data.Manufacturer, 7) == 0) {
442 memmove(s->Phone.Data.Manufacturer, s->Phone.Data.Manufacturer + 7, strlen(s->Phone.Data.Manufacturer + 7) + 1); 482 memmove(s->Phone.Data.Manufacturer, s->Phone.Data.Manufacturer + 7, strlen(s->Phone.Data.Manufacturer + 7) + 1);
443 } 483 }
444 if (strstr(msg.Buffer,"Falcom")) { 484 if (strstr(msg.Buffer,"Falcom")) {
445 smprintf(s, "Falcom\n"); 485 smprintf(s, "Falcom\n");
446 strcpy(s->Phone.Data.Manufacturer,"Falcom"); 486 strcpy(s->Phone.Data.Manufacturer,"Falcom");
447 Priv->Manufacturer = AT_Falcom; 487 Priv->Manufacturer = AT_Falcom;
448 if (strstr(msg.Buffer,"A2D")) { 488 if (strstr(msg.Buffer,"A2D")) {
449 strcpy(s->Phone.Data.Model,"A2D"); 489 strcpy(s->Phone.Data.Model,"A2D");
450 s->Phone.Data.ModelInfo = GetModelData(NULL,s->Phone.Data.Model,NULL); 490 s->Phone.Data.ModelInfo = GetModelData(NULL,s->Phone.Data.Model,NULL);
451 smprintf(s, "Model A2D\n"); 491 smprintf(s, "Model A2D\n");
452 } 492 }
453 } 493 }
454 if (strstr(msg.Buffer,"Nokia")) { 494 if (strstr(msg.Buffer,"Nokia")) {
455 smprintf(s, "Nokia\n"); 495 smprintf(s, "Nokia\n");
456 strcpy(s->Phone.Data.Manufacturer,"Nokia"); 496 strcpy(s->Phone.Data.Manufacturer,"Nokia");
457 Priv->Manufacturer = AT_Nokia; 497 Priv->Manufacturer = AT_Nokia;
458 } 498 }
459 if (strstr(msg.Buffer,"SIEMENS")) { 499 if (strstr(msg.Buffer,"SIEMENS")) {
460 smprintf(s, "Siemens\n"); 500 smprintf(s, "Siemens\n");
461 strcpy(s->Phone.Data.Manufacturer,"Siemens"); 501 strcpy(s->Phone.Data.Manufacturer,"Siemens");
462 Priv->Manufacturer = AT_Siemens; 502 Priv->Manufacturer = AT_Siemens;
463 } 503 }
464 if (strstr(msg.Buffer,"ERICSSON")) { 504 if (strstr(msg.Buffer,"ERICSSON")) {
465 smprintf(s, "Ericsson\n"); 505 smprintf(s, "Ericsson\n");
466 strcpy(s->Phone.Data.Manufacturer,"Ericsson"); 506 strcpy(s->Phone.Data.Manufacturer,"Ericsson");
467 Priv->Manufacturer = AT_Ericsson; 507 Priv->Manufacturer = AT_Ericsson;
468 } 508 }
469 if (strstr(msg.Buffer,"iPAQ")) { 509 if (strstr(msg.Buffer,"iPAQ")) {
470 smprintf(s, "iPAQ\n"); 510 smprintf(s, "iPAQ\n");
471 strcpy(s->Phone.Data.Manufacturer,"HP"); 511 strcpy(s->Phone.Data.Manufacturer,"HP");
472 Priv->Manufacturer = AT_HP; 512 Priv->Manufacturer = AT_HP;
473 } 513 }
474 if (strstr(msg.Buffer,"ALCATEL")) { 514 if (strstr(msg.Buffer,"ALCATEL")) {
475 smprintf(s, "Alcatel\n"); 515 smprintf(s, "Alcatel\n");
476 strcpy(s->Phone.Data.Manufacturer,"Alcatel"); 516 strcpy(s->Phone.Data.Manufacturer,"Alcatel");
477 Priv->Manufacturer = AT_Alcatel; 517 Priv->Manufacturer = AT_Alcatel;
478 } 518 }
479 if (strstr(msg.Buffer,"SAGEM")) { 519 if (strstr(msg.Buffer,"SAGEM")) {
480 smprintf(s, "Sagem\n"); 520 smprintf(s, "Sagem\n");
481 strcpy(s->Phone.Data.Manufacturer,"Sagem"); 521 strcpy(s->Phone.Data.Manufacturer,"Sagem");
482 Priv->Manufacturer = AT_Sagem; 522 Priv->Manufacturer = AT_Sagem;
483 } 523 }
524 if (strstr(msg.Buffer,"Samsung")) {
525 smprintf(s, "Samsung\n");
526 strcpy(s->Phone.Data.Manufacturer,"Samsung");
527 Priv->Manufacturer = AT_Samsung;
528 }
484 return ERR_NONE; 529 return ERR_NONE;
485 case AT_Reply_CMSError: 530 case AT_Reply_CMSError:
486 return ATGEN_HandleCMSError(s); 531 return ATGEN_HandleCMSError(s);
487 default: 532 default:
488 break; 533 break;
489 } 534 }
490 return ERR_UNKNOWNRESPONSE; 535 return ERR_UNKNOWNRESPONSE;
491} 536}
492 537
493GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s) 538GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s)
494{ 539{
495 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE; 540 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE;
496 541
497 return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer); 542 return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer);
498} 543}
499 544
500GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s) 545GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s)
501{ 546{
502 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 547 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
503 unsigned int i = 0; 548 unsigned int i = 0;
504 549
505 strcpy(s->Phone.Data.Version,"unknown"); 550 strcpy(s->Phone.Data.Version,"unknown");
506 s->Phone.Data.VerNum = 0; 551 s->Phone.Data.VerNum = 0;
507 if (Priv->ReplyState == AT_Reply_OK) { 552 if (Priv->ReplyState == AT_Reply_OK) {
508 CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2); 553 CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2);
509 /* Sometimes phone adds this before manufacturer (Sagem) */ 554 /* Sometimes phone adds this before manufacturer (Sagem) */
510 if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) { 555 if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) {
511 memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1); 556 memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1);
512 } 557 }
513 } 558 }
514 if (Priv->Manufacturer == AT_Ericsson) { 559 if (Priv->Manufacturer == AT_Ericsson) {
515 while (1) { 560 while (1) {
516 if (s->Phone.Data.Version[i] == 0x20) { 561 if (s->Phone.Data.Version[i] == 0x20) {
517 s->Phone.Data.Version[i] = 0x00; 562 s->Phone.Data.Version[i] = 0x00;
518 break; 563 break;
519 } 564 }
520 if (i == strlen(s->Phone.Data.Version)) break; 565 if (i == strlen(s->Phone.Data.Version)) break;
521 i++; 566 i++;
522 } 567 }
523 } 568 }
524 smprintf(s, "Received firmware version: \"%s\"\n",s->Phone.Data.Version); 569 smprintf(s, "Received firmware version: \"%s\"\n",s->Phone.Data.Version);
525 GSM_CreateFirmwareNumber(s); 570 GSM_CreateFirmwareNumber(s);
526 return ERR_NONE; 571 return ERR_NONE;
527} 572}
528 573
529GSM_Error ATGEN_ReplyGetFirmwareATI(GSM_Protocol_Message msg, GSM_StateMachine *s) 574GSM_Error ATGEN_ReplyGetFirmwareATI(GSM_Protocol_Message msg, GSM_StateMachine *s)
530{ 575{
531 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 576 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
@@ -629,106 +674,116 @@ GSM_Error ATGEN_Initialise(GSM_StateMachine *s)
629 if (error != ERR_NONE) return error; 674 if (error != ERR_NONE) return error;
630 675
631 smprintf(s, "Enabling CME errors\n"); 676 smprintf(s, "Enabling CME errors\n");
632 /* Try numeric errors */ 677 /* Try numeric errors */
633 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 678 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
634 /* Try textual errors */ 679 /* Try textual errors */
635 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 680 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
636 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n"); 681 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n");
637 } 682 }
638 } 683 }
639 684
640 error = ATGEN_GetModel(s); 685 error = ATGEN_GetModel(s);
641 if (error != ERR_NONE) return error; 686 if (error != ERR_NONE) return error;
642 687
643 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) { 688 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) {
644 s->Protocol.Data.AT.FastWrite = true; 689 s->Protocol.Data.AT.FastWrite = true;
645 } 690 }
646 691
647 return error; 692 return error;
648} 693}
649 694
650GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 695GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
651{ 696{
652 unsigned char req[50]; 697 unsigned char req[50];
653 698
654 if (smsc->Location!=1) return ERR_NOTSUPPORTED; 699 if (smsc->Location!=1) return ERR_NOTSUPPORTED;
655 700
656 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number)); 701 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number));
657 702
658 smprintf(s, "Setting SMSC\n"); 703 smprintf(s, "Setting SMSC\n");
659 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC); 704 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC);
660} 705}
661 706
662GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s) 707GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s)
663{ 708{
664 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 709 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
665 case AT_Reply_OK: 710 case AT_Reply_OK:
666 /* Reply here is: 711 /* Reply here is:
667 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]] 712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
668 * each memory is in quotes, 713 * each memory is in quotes,
669 * Example: ("SM"), ("SM"), ("SM") 714 * Example: ("SM"), ("SM"), ("SM")
670 * 715 *
671 * We need to get from this supported memories. For this case 716 * We need to get from this supported memories. For this case
672 * we assume, that just appearence of memory makes it 717 * we assume, that just appearence of memory makes it
673 * available for everything. Then we need to find out whether 718 * available for everything. Then we need to find out whether
674 * phone supports writing to memory. This is done by searching 719 * phone supports writing to memory. This is done by searching
675 * for "), (", which will appear between lists. 720 * for "), (", which will appear between lists.
676 */ 721 */
677 s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL); 722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
724 s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
725 }
726
678 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE; 727 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE;
679 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE; 728 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
729
680 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE; 730 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE;
681 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE; 731 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
682 smprintf(s, "Available SMS memories received, ME = %d, SM = %d\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); 732
733 smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
734 if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
735 smprintf(s, "\n");
683 return ERR_NONE; 736 return ERR_NONE;
684 case AT_Reply_Error: 737 case AT_Reply_Error:
685 case AT_Reply_CMSError: 738 case AT_Reply_CMSError:
686 return ATGEN_HandleCMSError(s); 739 return ATGEN_HandleCMSError(s);
740 case AT_Reply_CMEError:
741 return ATGEN_HandleCMEError(s);
687 default: 742 default:
688 return ERR_UNKNOWNRESPONSE; 743 return ERR_UNKNOWNRESPONSE;
689 } 744 }
690} 745}
691 746
692GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s) 747GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s)
693{ 748{
694 smprintf(s, "Getting available SMS memories\n"); 749 smprintf(s, "Getting available SMS memories\n");
695 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories); 750 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories);
696} 751}
697 752
698GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM) 753GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM)
699{ 754{
700 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 755 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
701 char req[] = "AT+CPMS=\"XX\",\"XX\"\r"; 756 char req[] = "AT+CPMS=\"XX\",\"XX\"\r";
702 int reqlen = 18; 757 int reqlen = 18;
703 GSM_Error error; 758 GSM_Error error;
704 759
705 if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) { 760 if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) {
706 /* We silently ignore error here, because when this fails, we can try to setmemory anyway */ 761 /* We silently ignore error here, because when this fails, we can try to setmemory anyway */
707 ATGEN_GetSMSMemories(s); 762 ATGEN_GetSMSMemories(s);
708 } 763 }
709 764
710 /* If phone can not save SMS, don't try to set memory for saving */ 765 /* If phone can not save SMS, don't try to set memory for saving */
711 if (!Priv->CanSaveSMS) { 766 if (!Priv->CanSaveSMS) {
712 req[12] = '\r'; 767 req[12] = '\r';
713 reqlen = 13; 768 reqlen = 13;
714 } 769 }
715 770
716 if (SIM) { 771 if (SIM) {
717 if (Priv->SMSMemory == MEM_SM) return ERR_NONE; 772 if (Priv->SMSMemory == MEM_SM) return ERR_NONE;
718 if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED; 773 if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED;
719 774
720 req[9] = 'S'; req[10] = 'M'; 775 req[9] = 'S'; req[10] = 'M';
721 req[14] = 'S'; req[15] = 'M'; 776 req[14] = 'S'; req[15] = 'M';
722 777
723 smprintf(s, "Setting SMS memory type to SM\n"); 778 smprintf(s, "Setting SMS memory type to SM\n");
724 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType); 779 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType);
725 if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) { 780 if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) {
726 Priv->SIMSMSMemory = AT_AVAILABLE; 781 Priv->SIMSMSMemory = AT_AVAILABLE;
727 } 782 }
728 if (error == ERR_NOTSUPPORTED) { 783 if (error == ERR_NOTSUPPORTED) {
729 smprintf(s, "Can't access SIM card?\n"); 784 smprintf(s, "Can't access SIM card?\n");
730 return ERR_SECURITYERROR; 785 return ERR_SECURITYERROR;
731 } 786 }
732 if (error != ERR_NONE) return error; 787 if (error != ERR_NONE) return error;
733 Priv->SMSMemory = MEM_SM; 788 Priv->SMSMemory = MEM_SM;
734 } else { 789 } else {
@@ -813,188 +868,189 @@ GSM_Error ATGEN_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigne
813 } 868 }
814 smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n", 869 smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n",
815 sms->Folder,sms->Location,*folderid,*location); 870 sms->Folder,sms->Location,*folderid,*location);
816 871
817 if (Priv->SIMSMSMemory == AT_AVAILABLE && *folderid == 1) { 872 if (Priv->SIMSMSMemory == AT_AVAILABLE && *folderid == 1) {
818 return ATGEN_SetSMSMemory(s, true); 873 return ATGEN_SetSMSMemory(s, true);
819 } else { 874 } else {
820 return ATGEN_SetSMSMemory(s, false); 875 return ATGEN_SetSMSMemory(s, false);
821 } 876 }
822} 877}
823 878
824void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location) 879void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
825{ 880{
826 sms->Folder= 0; 881 sms->Folder= 0;
827 sms->Location= (folderid - 1) * PHONE_MAXSMSINFOLDER + location; 882 sms->Location= (folderid - 1) * PHONE_MAXSMSINFOLDER + location;
828 smprintf(s, "ATGEN folder %i & location %i -> SMS folder %i & location %i\n", 883 smprintf(s, "ATGEN folder %i & location %i -> SMS folder %i & location %i\n",
829 folderid,location,sms->Folder,sms->Location); 884 folderid,location,sms->Folder,sms->Location);
830} 885}
831 886
832GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 887GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
833{ 888{
834 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 889 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
835 GSM_SMSMessage *sms= &s->Phone.Data.GetSMSMessage->SMS[0]; 890 GSM_SMSMessage *sms= &s->Phone.Data.GetSMSMessage->SMS[0];
836 int current = 0, current2, i; 891 int current = 0, current2, i;
837 unsigned char buffer[300],smsframe[800]; 892 unsigned char buffer[300],smsframe[800];
838 unsigned char firstbyte, TPDCS, TPUDL, TPStatus; 893 unsigned char firstbyte, TPDCS, TPUDL, TPStatus;
839 GSM_Error error; 894 GSM_Error error;
840 895
841 switch (Priv->ReplyState) { 896 switch (Priv->ReplyState) {
842 case AT_Reply_OK: 897 case AT_Reply_OK:
843 if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY; 898 if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY;
844 s->Phone.Data.GetSMSMessage->Number = 1; 899 s->Phone.Data.GetSMSMessage->Number = 1;
845 s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0; 900 s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0;
846 s->Phone.Data.GetSMSMessage->SMS[0].Name[1]= 0; 901 s->Phone.Data.GetSMSMessage->SMS[0].Name[1]= 0;
847 switch (Priv->SMSMode) { 902 switch (Priv->SMSMode) {
848 case SMS_AT_PDU: 903 case SMS_AT_PDU:
849 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2); 904 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2);
850 switch (buffer[7]) { 905 switch (buffer[7]) {
851 case '0': sms->State = SMS_UnRead; break; 906 case '0': sms->State = SMS_UnRead; break;
852 case '1': sms->State = SMS_Read;break; 907 case '1': sms->State = SMS_Read;break;
853 case '2': sms->State = SMS_UnSent;break; 908 case '2': sms->State = SMS_UnSent;break;
854 default : sms->State = SMS_Sent;break;//case '3' 909 default : sms->State = SMS_Sent;break;//case '3'
855 } 910 }
856 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3))); 911 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3)));
857 /* Siemens MC35 (only ?) */ 912 /* Siemens MC35 (only ?) */
858 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY; 913 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY;
859 /* Siemens M20 */ 914 /* Siemens M20 */
860 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 915 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
861 if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL && 916 /* we check for the most often visible */
862 buffer[1]!=NUMBER_ALPHANUMERIC) { 917 if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
918 buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
863 /* Seems to be Delivery Report */ 919 /* Seems to be Delivery Report */
864 smprintf(s, "SMS type - status report (M20 style)\n"); 920 smprintf(s, "SMS type - status report (M20 style)\n");
865 sms->PDU = SMS_Status_Report; 921 sms->PDU = SMS_Status_Report;
866 sms->Folder = 1;/*INBOX SIM*/ 922 sms->Folder = 1;/*INBOX SIM*/
867 sms->InboxFolder = true; 923 sms->InboxFolder = true;
868 924
869 smsframe[12]=buffer[current++]; 925 smsframe[12]=buffer[current++];
870 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++]; 926 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++];
871 current2=((buffer[current])+1)/2+1; 927 current2=((buffer[current])+1)/2+1;
872 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 928 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
873 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 929 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
874 smsframe[0] = 0; 930 smsframe[0] = 0;
875 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; 931 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
876 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; 932 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
877 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); 933 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
878 return ERR_NONE; 934 return ERR_NONE;
879 } 935 }
880 } 936 }
881 /* We use locations from SMS layouts like in ../phone2.c(h) */ 937 /* We use locations from SMS layouts like in ../phone2.c(h) */
882 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; 938 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
883 smsframe[12]=buffer[current++]; 939 smsframe[12]=buffer[current++];
884 /* See GSM 03.40 section 9.2.3.1 */ 940 /* See GSM 03.40 section 9.2.3.1 */
885 switch (smsframe[12] & 0x03) { 941 switch (smsframe[12] & 0x03) {
886 case 0x00: 942 case 0x00:
887 smprintf(s, "SMS type - deliver\n"); 943 smprintf(s, "SMS type - deliver\n");
888 sms->PDU = SMS_Deliver; 944 sms->PDU = SMS_Deliver;
889 if (Priv->SMSMemory == MEM_SM) { 945 if (Priv->SMSMemory == MEM_SM) {
890 sms->Folder = 1; /*INBOX SIM*/ 946 sms->Folder = 1; /*INBOX SIM*/
891 } else { 947 } else {
892 sms->Folder = 3; /*INBOX ME*/ 948 sms->Folder = 3; /*INBOX ME*/
893 } 949 }
894 sms->InboxFolder = true; 950 sms->InboxFolder = true;
895 current2=((buffer[current])+1)/2+1; 951 current2=((buffer[current])+1)/2+1;
896 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 952 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
897 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 953 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
898 smprintf(s, "Trying to read alphanumeric number\n"); 954 smprintf(s, "Trying to read alphanumeric number\n");
899 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 955 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
900 current+=6; 956 current+=6;
901 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++]; 957 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++];
902 } else { 958 } else {
903 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 959 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
904 } 960 }
905 } else { 961 } else {
906 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 962 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
907 } 963 }
908 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; 964 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
909 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; 965 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
910 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; 966 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++];
911 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; 967 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++];
912 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; 968 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++];
913 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver); 969 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver);
914 return ERR_NONE; 970 return ERR_NONE;
915 case 0x01: 971 case 0x01:
916 smprintf(s, "SMS type - submit\n"); 972 smprintf(s, "SMS type - submit\n");
917 sms->PDU = SMS_Submit; 973 sms->PDU = SMS_Submit;
918 if (Priv->SMSMemory == MEM_SM) { 974 if (Priv->SMSMemory == MEM_SM) {
919 sms->Folder = 2; /*OUTBOX SIM*/ 975 sms->Folder = 2; /*OUTBOX SIM*/
920 smprintf(s, "Outbox SIM\n"); 976 smprintf(s, "Outbox SIM\n");
921 } else { 977 } else {
922 sms->Folder = 4; /*OUTBOX ME*/ 978 sms->Folder = 4; /*OUTBOX ME*/
923 } 979 }
924 sms->InboxFolder = false; 980 sms->InboxFolder = false;
925 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++]; 981 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++];
926 current2=((buffer[current])+1)/2+1; 982 current2=((buffer[current])+1)/2+1;
927 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 983 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
928 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 984 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
929 smprintf(s, "Trying to read alphanumeric number\n"); 985 smprintf(s, "Trying to read alphanumeric number\n");
930 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 986 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
931 current+=6; 987 current+=6;
932 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++]; 988 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++];
933 } else { 989 } else {
934 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 990 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
935 } 991 }
936 } else { 992 } else {
937 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 993 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
938 } 994 }
939 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++]; 995 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++];
940 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++]; 996 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++];
941 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */ 997 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */
942 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now 998 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now
943 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++]; 999 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++];
944 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++]; 1000 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++];
945 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit); 1001 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit);
946 return ERR_NONE; 1002 return ERR_NONE;
947 case 0x02: 1003 case 0x02:
948 smprintf(s, "SMS type - status report\n"); 1004 smprintf(s, "SMS type - status report\n");
949 sms->PDU = SMS_Status_Report; 1005 sms->PDU = SMS_Status_Report;
950 sms->Folder = 1;/*INBOX SIM*/ 1006 sms->Folder = 1;/*INBOX SIM*/
951 sms->InboxFolder = true; 1007 sms->InboxFolder = true;
952 smprintf(s, "TPMR is %02x\n",buffer[current]); 1008 smprintf(s, "TPMR is %d\n",buffer[current]);
953 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++]; 1009 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
954 current2=((buffer[current])+1)/2+1; 1010 current2=((buffer[current])+1)/2+1;
955 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 1011 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
956 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 1012 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
957 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; 1013 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
958 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; 1014 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
959 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); 1015 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
960 return ERR_NONE; 1016 return ERR_NONE;
961 } 1017 }
962 break; 1018 break;
963 case SMS_AT_TXT: 1019 case SMS_AT_TXT:
964 current = 0; 1020 current = 0;
965 while (msg.Buffer[current]!='"') current++; 1021 while (msg.Buffer[current]!='"') current++;
966 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1022 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
967 if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) { 1023 if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) {
968 smprintf(s, "SMS type - deliver\n"); 1024 smprintf(s, "SMS type - deliver\n");
969 sms->State = SMS_UnRead; 1025 sms->State = SMS_UnRead;
970 sms->PDU = SMS_Deliver; 1026 sms->PDU = SMS_Deliver;
971 if (Priv->SMSMemory == MEM_SM) { 1027 if (Priv->SMSMemory == MEM_SM) {
972 sms->Folder = 1; /*INBOX SIM*/ 1028 sms->Folder = 1; /*INBOX SIM*/
973 } else { 1029 } else {
974 sms->Folder = 3; /*INBOX ME*/ 1030 sms->Folder = 3; /*INBOX ME*/
975 } 1031 }
976 sms->InboxFolder = true; 1032 sms->InboxFolder = true;
977 } else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) { 1033 } else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) {
978 smprintf(s, "SMS type - deliver\n"); 1034 smprintf(s, "SMS type - deliver\n");
979 sms->State = SMS_Read; 1035 sms->State = SMS_Read;
980 sms->PDU = SMS_Deliver; 1036 sms->PDU = SMS_Deliver;
981 if (Priv->SMSMemory == MEM_SM) { 1037 if (Priv->SMSMemory == MEM_SM) {
982 sms->Folder = 1; /*INBOX SIM*/ 1038 sms->Folder = 1; /*INBOX SIM*/
983 } else { 1039 } else {
984 sms->Folder = 3; /*INBOX ME*/ 1040 sms->Folder = 3; /*INBOX ME*/
985 } 1041 }
986 sms->InboxFolder = true; 1042 sms->InboxFolder = true;
987 } else if (!strcmp(buffer,"\"2\"") || !strcmp(buffer,"\"STO UNSENT\"")) { 1043 } else if (!strcmp(buffer,"\"2\"") || !strcmp(buffer,"\"STO UNSENT\"")) {
988 smprintf(s, "SMS type - submit\n"); 1044 smprintf(s, "SMS type - submit\n");
989 sms->State = SMS_UnSent; 1045 sms->State = SMS_UnSent;
990 sms->PDU = SMS_Submit; 1046 sms->PDU = SMS_Submit;
991 if (Priv->SMSMemory == MEM_SM) { 1047 if (Priv->SMSMemory == MEM_SM) {
992 sms->Folder = 2; /*OUTBOX SIM*/ 1048 sms->Folder = 2; /*OUTBOX SIM*/
993 } else { 1049 } else {
994 sms->Folder = 4; /*OUTBOX ME*/ 1050 sms->Folder = 4; /*OUTBOX ME*/
995 } 1051 }
996 sms->InboxFolder = false; 1052 sms->InboxFolder = false;
997 } else if (!strcmp(buffer,"\"3\"") || !strcmp(buffer,"\"STO SENT\"")) { 1053 } else if (!strcmp(buffer,"\"3\"") || !strcmp(buffer,"\"STO SENT\"")) {
998 smprintf(s, "SMS type - submit\n"); 1054 smprintf(s, "SMS type - submit\n");
999 sms->State = SMS_Sent; 1055 sms->State = SMS_Sent;
1000 sms->PDU = SMS_Submit; 1056 sms->PDU = SMS_Submit;
@@ -1595,107 +1651,107 @@ GSM_Error ATGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
1595 } 1651 }
1596 } 1652 }
1597 s->Protocol.Data.AT.EditMode = true; 1653 s->Protocol.Data.AT.EditMode = true;
1598 Replies = s->ReplyNum; 1654 Replies = s->ReplyNum;
1599 s->ReplyNum = 1; 1655 s->ReplyNum = 1;
1600 smprintf(s,"Waiting for modem prompt\n"); 1656 smprintf(s,"Waiting for modem prompt\n");
1601 error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_SaveSMSMessage); 1657 error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_SaveSMSMessage);
1602 s->ReplyNum = Replies; 1658 s->ReplyNum = Replies;
1603 if (error == ERR_NONE) { 1659 if (error == ERR_NONE) {
1604 Phone->DispatchError = ERR_TIMEOUT; 1660 Phone->DispatchError = ERR_TIMEOUT;
1605 Phone->RequestID = ID_SaveSMSMessage; 1661 Phone->RequestID = ID_SaveSMSMessage;
1606 smprintf(s, "Saving SMS\n"); 1662 smprintf(s, "Saving SMS\n");
1607 error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00); 1663 error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00);
1608 if (error!=ERR_NONE) return error; 1664 if (error!=ERR_NONE) return error;
1609 my_sleep(500); 1665 my_sleep(500);
1610 /* CTRL+Z ends entering */ 1666 /* CTRL+Z ends entering */
1611 error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); 1667 error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00);
1612 if (error!=ERR_NONE) return error; 1668 if (error!=ERR_NONE) return error;
1613 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); 1669 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4);
1614 if (error != ERR_TIMEOUT) return error; 1670 if (error != ERR_TIMEOUT) return error;
1615 } else { 1671 } else {
1616 smprintf(s, "Escaping SMS mode\n"); 1672 smprintf(s, "Escaping SMS mode\n");
1617 error2 = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); 1673 error2 = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00);
1618 if (error2 != ERR_NONE) return error2; 1674 if (error2 != ERR_NONE) return error2;
1619 return error; 1675 return error;
1620 } 1676 }
1621 } 1677 }
1622 1678
1623 return Phone->DispatchError; 1679 return Phone->DispatchError;
1624} 1680}
1625 1681
1626GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) 1682GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1627{ 1683{
1628 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 1684 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
1629 char *start; 1685 char *start;
1630 1686
1631 if (s->Protocol.Data.AT.EditMode) { 1687 if (s->Protocol.Data.AT.EditMode) {
1632 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) { 1688 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) {
1633 return ERR_UNKNOWN; 1689 return ERR_UNKNOWN;
1634 } 1690 }
1635 s->Protocol.Data.AT.EditMode = false; 1691 s->Protocol.Data.AT.EditMode = false;
1636 return ERR_NONE; 1692 return ERR_NONE;
1637 } 1693 }
1638 1694
1639 switch (Priv->ReplyState) { 1695 switch (Priv->ReplyState) {
1640 case AT_Reply_OK: 1696 case AT_Reply_OK:
1641 smprintf(s, "SMS sent OK\n"); 1697 smprintf(s, "SMS sent OK\n");
1642 if (s->User.SendSMSStatus!=NULL) { 1698 if (s->User.SendSMSStatus!=NULL) {
1643 start = strstr(msg.Buffer, "+CMGW: "); 1699 start = strstr(msg.Buffer, "+CMGS: ");
1644 if (start != NULL) { 1700 if (start != NULL) {
1645 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7)); 1701 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7));
1646 } else { 1702 } else {
1647 s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1703 s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
1648 } 1704 }
1649 } 1705 }
1650 return ERR_NONE; 1706 return ERR_NONE;
1651 case AT_Reply_CMSError: 1707 case AT_Reply_CMSError:
1652 smprintf(s, "Error %i\n",Priv->ErrorCode); 1708 smprintf(s, "Error %i\n",Priv->ErrorCode);
1653 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0); 1709 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1);
1654 return ATGEN_HandleCMSError(s); 1710 return ATGEN_HandleCMSError(s);
1655 case AT_Reply_Error: 1711 case AT_Reply_Error:
1656 return ERR_UNKNOWN; 1712 return ERR_UNKNOWN;
1657 default: 1713 default:
1658 return ERR_UNKNOWNRESPONSE; 1714 return ERR_UNKNOWNRESPONSE;
1659 } 1715 }
1660} 1716}
1661 1717
1662GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) 1718GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
1663{ 1719{
1664 GSM_Error error,error2; 1720 GSM_Error error,error2;
1665 int current, current2, Replies; 1721 int current, current2, Replies;
1666 unsigned char buffer[1000], hexreq[1000]; 1722 unsigned char buffer[1000], hexreq[1000];
1667 GSM_Phone_Data *Phone = &s->Phone.Data; 1723 GSM_Phone_Data *Phone = &s->Phone.Data;
1668 1724
1669 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit; 1725 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
1670 1726
1671 error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &current2); 1727 error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &current2);
1672 if (error != ERR_NONE) return error; 1728 if (error != ERR_NONE) return error;
1673 1729
1674 switch (Phone->Priv.ATGEN.SMSMode) { 1730 switch (Phone->Priv.ATGEN.SMSMode) {
1675 case SMS_AT_PDU: 1731 case SMS_AT_PDU:
1676 sprintf(buffer, "AT+CMGS=%i\r",current); 1732 sprintf(buffer, "AT+CMGS=%i\r",current);
1677 break; 1733 break;
1678 case SMS_AT_TXT: 1734 case SMS_AT_TXT:
1679 sprintf(buffer, "AT+CMGS=\"%s\"\r",DecodeUnicodeString(sms->Number)); 1735 sprintf(buffer, "AT+CMGS=\"%s\"\r",DecodeUnicodeString(sms->Number));
1680 } 1736 }
1681 1737
1682 s->Protocol.Data.AT.EditMode = true; 1738 s->Protocol.Data.AT.EditMode = true;
1683 Replies = s->ReplyNum; 1739 Replies = s->ReplyNum;
1684 s->ReplyNum = 1; 1740 s->ReplyNum = 1;
1685 smprintf(s,"Waiting for modem prompt\n"); 1741 smprintf(s,"Waiting for modem prompt\n");
1686 error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_IncomingFrame); 1742 error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_IncomingFrame);
1687 s->ReplyNum = Replies; 1743 s->ReplyNum = Replies;
1688 if (error == ERR_NONE) { 1744 if (error == ERR_NONE) {
1689 smprintf(s, "Sending SMS\n"); 1745 smprintf(s, "Sending SMS\n");
1690 error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00); 1746 error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00);
1691 if (error!=ERR_NONE) return error; 1747 if (error!=ERR_NONE) return error;
1692 my_sleep(500); 1748 my_sleep(500);
1693 /* CTRL+Z ends entering */ 1749 /* CTRL+Z ends entering */
1694 error=s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); 1750 error=s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00);
1695 my_sleep(100); 1751 my_sleep(100);
1696 return error; 1752 return error;
1697 } else { 1753 } else {
1698 smprintf(s, "Escaping SMS mode\n"); 1754 smprintf(s, "Escaping SMS mode\n");
1699 error2=s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); 1755 error2=s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00);
1700 if (error2 != ERR_NONE) return error2; 1756 if (error2 != ERR_NONE) return error2;
1701 } 1757 }
@@ -1742,96 +1798,109 @@ GSM_Error ATGEN_ReplyGetDateTime_Alarm(GSM_Protocol_Message msg, GSM_StateMachin
1742 if (Data->RequestID == ID_GetDateTime) { 1798 if (Data->RequestID == ID_GetDateTime) {
1743 ATGEN_DecodeDateTime(Data->DateTime, msg.Buffer+current); 1799 ATGEN_DecodeDateTime(Data->DateTime, msg.Buffer+current);
1744 } else { 1800 } else {
1745 ATGEN_DecodeDateTime(&(Data->Alarm->DateTime), msg.Buffer+current); 1801 ATGEN_DecodeDateTime(&(Data->Alarm->DateTime), msg.Buffer+current);
1746 } 1802 }
1747 return ERR_NONE; 1803 return ERR_NONE;
1748 } 1804 }
1749 case AT_Reply_Error: 1805 case AT_Reply_Error:
1750 return ERR_NOTSUPPORTED; 1806 return ERR_NOTSUPPORTED;
1751 case AT_Reply_CMSError: 1807 case AT_Reply_CMSError:
1752 return ATGEN_HandleCMSError(s); 1808 return ATGEN_HandleCMSError(s);
1753 default: 1809 default:
1754 break; 1810 break;
1755 } 1811 }
1756 return ERR_UNKNOWNRESPONSE; 1812 return ERR_UNKNOWNRESPONSE;
1757} 1813}
1758 1814
1759GSM_Error ATGEN_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 1815GSM_Error ATGEN_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
1760{ 1816{
1761 s->Phone.Data.DateTime=date_time; 1817 s->Phone.Data.DateTime=date_time;
1762 smprintf(s, "Getting date & time\n"); 1818 smprintf(s, "Getting date & time\n");
1763 return GSM_WaitFor (s, "AT+CCLK?\r", 9, 0x00, 4, ID_GetDateTime); 1819 return GSM_WaitFor (s, "AT+CCLK?\r", 9, 0x00, 4, ID_GetDateTime);
1764} 1820}
1765 1821
1766GSM_Error ATGEN_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 1822GSM_Error ATGEN_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
1767{ 1823{
1768 char req[128]; 1824 char req[128];
1769 1825
1770 sprintf(req, "AT+CCLK=\"%02i/%02i/%02i,%02i:%02i:%02i+00\"\r", 1826 sprintf(req, "AT+CCLK=\"%02i/%02i/%02i,%02i:%02i:%02i+00\"\r",
1771 date_time->Year-2000,date_time->Month,date_time->Day, 1827 date_time->Year-2000,date_time->Month,date_time->Day,
1772 date_time->Hour,date_time->Minute,date_time->Second); 1828 date_time->Hour,date_time->Minute,date_time->Second);
1773 1829
1774 smprintf(s, "Setting date & time\n"); 1830 smprintf(s, "Setting date & time\n");
1775 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetDateTime); 1831 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetDateTime);
1776} 1832}
1777 1833
1778GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 1834GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1779{ 1835{
1780 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 1836 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
1781 1837
1782 alarm->Repeating = true; 1838 alarm->Repeating = true;
1783 alarm->Text[0] = 0; alarm->Text[1] = 0; 1839 alarm->Text[0] = 0; alarm->Text[1] = 0;
1784 1840
1785 s->Phone.Data.Alarm = alarm; 1841 s->Phone.Data.Alarm = alarm;
1786 smprintf(s, "Getting alarm\n"); 1842 smprintf(s, "Getting alarm\n");
1787 return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm); 1843 return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm);
1788} 1844}
1789 1845
1846/* R320 only takes HH:MM. Do other phones understand full date? */
1847GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1848{
1849 char req[20];
1850
1851 if (alarm->Location != 1) return ERR_INVALIDLOCATION;
1852
1853 sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute);
1854
1855 smprintf(s, "Setting Alarm\n");
1856 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm);
1857}
1858
1790GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 1859GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
1791{ 1860{
1792 GSM_SMSC *SMSC = s->Phone.Data.SMSC; 1861 GSM_SMSC *SMSC = s->Phone.Data.SMSC;
1793 int current; 1862 int current;
1794 int len; 1863 int len;
1795 unsigned char buffer[100]; 1864 unsigned char buffer[100];
1796 1865
1797 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 1866 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
1798 case AT_Reply_OK: 1867 case AT_Reply_OK:
1799 smprintf(s, "SMSC info received\n"); 1868 smprintf(s, "SMSC info received\n");
1800 1869
1801 current = 0; 1870 current = 0;
1802 while (msg.Buffer[current]!='"') current++; 1871 while (msg.Buffer[current]!='"') current++;
1803 1872
1804 /* SMSC number */ 1873 /* SMSC number */
1805 /* FIXME: support for all formats */ 1874 /* FIXME: support for all formats */
1806 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1875 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1807 /* 1876 /*
1808 * Some phones return this as unicode encoded when they are 1877 * Some phones return this as unicode encoded when they are
1809 * switched to UCS2 mode, so we try to solve this correctly. 1878 * switched to UCS2 mode, so we try to solve this correctly.
1810 */ 1879 */
1811 len = strlen(buffer + 1) - 1; 1880 len = strlen(buffer + 1) - 1;
1812 buffer[len + 1] = 0; 1881 buffer[len + 1] = 0;
1813 if ((len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) { 1882 if ((len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) {
1814 /* This is probably unicode encoded number */ 1883 /* This is probably unicode encoded number */
1815 DecodeHexUnicode(SMSC->Number,buffer + 1,len); 1884 DecodeHexUnicode(SMSC->Number,buffer + 1,len);
1816 } else { 1885 } else {
1817 EncodeUnicode(SMSC->Number,buffer + 1,len); 1886 EncodeUnicode(SMSC->Number,buffer + 1,len);
1818 } 1887 }
1819 smprintf(s, "Number: \"%s\"\n",DecodeUnicodeString(SMSC->Number)); 1888 smprintf(s, "Number: \"%s\"\n",DecodeUnicodeString(SMSC->Number));
1820 1889
1821 /* Format of SMSC number */ 1890 /* Format of SMSC number */
1822 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1891 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1823 smprintf(s, "Format %s\n",buffer); 1892 smprintf(s, "Format %s\n",buffer);
1824 /* International number */ 1893 /* International number */
1825 if (!strcmp(buffer,"145")) { 1894 if (!strcmp(buffer,"145")) {
1826 sprintf(buffer+1,"%s",DecodeUnicodeString(SMSC->Number)); 1895 sprintf(buffer+1,"%s",DecodeUnicodeString(SMSC->Number));
1827 if (strlen(buffer+1)!=0 && buffer[1] != '+') { 1896 if (strlen(buffer+1)!=0 && buffer[1] != '+') {
1828 /* Sony Ericsson issue */ 1897 /* Sony Ericsson issue */
1829 /* International number is without + */ 1898 /* International number is without + */
1830 buffer[0] = '+'; 1899 buffer[0] = '+';
1831 EncodeUnicode(SMSC->Number,buffer,strlen(buffer)); 1900 EncodeUnicode(SMSC->Number,buffer,strlen(buffer));
1832 } 1901 }
1833 } 1902 }
1834 1903
1835 SMSC->Format = SMS_FORMAT_Text; 1904 SMSC->Format = SMS_FORMAT_Text;
1836 SMSC->Validity.Format = SMS_Validity_RelativeFormat; 1905 SMSC->Validity.Format = SMS_Validity_RelativeFormat;
1837 SMSC->Validity.Relative= SMS_VALID_Max_Time; 1906 SMSC->Validity.Relative= SMS_VALID_Max_Time;
@@ -2157,162 +2226,170 @@ GSM_Error ATGEN_ReplyGetCPBRMemoryStatus(GSM_Protocol_Message msg, GSM_StateMach
2157{ 2226{
2158 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 2227 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
2159 GSM_MemoryStatus*MemoryStatus = s->Phone.Data.MemoryStatus; 2228 GSM_MemoryStatus*MemoryStatus = s->Phone.Data.MemoryStatus;
2160 int line=0; 2229 int line=0;
2161 char *str; 2230 char *str;
2162 int cur; 2231 int cur;
2163 2232
2164 switch (Priv->ReplyState) { 2233 switch (Priv->ReplyState) {
2165 case AT_Reply_OK: 2234 case AT_Reply_OK:
2166 smprintf(s, "Memory entries received\n"); 2235 smprintf(s, "Memory entries received\n");
2167 /* Walk through lines with +CPBR: */ 2236 /* Walk through lines with +CPBR: */
2168 while (Priv->Lines.numbers[line*2+1]!=0) { 2237 while (Priv->Lines.numbers[line*2+1]!=0) {
2169 str = GetLineString(msg.Buffer,Priv->Lines,line+1); 2238 str = GetLineString(msg.Buffer,Priv->Lines,line+1);
2170 if (strncmp(str, "+CPBR: ", 7) == 0) { 2239 if (strncmp(str, "+CPBR: ", 7) == 0) {
2171 MemoryStatus->MemoryUsed++; 2240 MemoryStatus->MemoryUsed++;
2172 if (sscanf(str, "+CPBR: %d,", &cur) == 1) { 2241 if (sscanf(str, "+CPBR: %d,", &cur) == 1) {
2173 cur -= Priv->FirstMemoryEntry - 1; 2242 cur -= Priv->FirstMemoryEntry - 1;
2174 if (cur == Priv->NextMemoryEntry || Priv->NextMemoryEntry == 0) 2243 if (cur == Priv->NextMemoryEntry || Priv->NextMemoryEntry == 0)
2175 Priv->NextMemoryEntry = cur + 1; 2244 Priv->NextMemoryEntry = cur + 1;
2176 } 2245 }
2177 } 2246 }
2178 line++; 2247 line++;
2179 } 2248 }
2180 return ERR_NONE; 2249 return ERR_NONE;
2181 case AT_Reply_Error: 2250 case AT_Reply_Error:
2182 return ERR_UNKNOWN; 2251 return ERR_UNKNOWN;
2183 case AT_Reply_CMSError: 2252 case AT_Reply_CMSError:
2184 return ATGEN_HandleCMSError(s); 2253 return ATGEN_HandleCMSError(s);
2185 default: 2254 default:
2186 return ERR_UNKNOWNRESPONSE; 2255 return ERR_UNKNOWNRESPONSE;
2187 } 2256 }
2188} 2257}
2189 2258
2190GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM_AT_NeededMemoryInfo NeededInfo) 2259GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM_AT_NeededMemoryInfo NeededInfo)
2191{ 2260{
2192 GSM_Error error; 2261 GSM_Error error;
2193 char req[20]; 2262 char req[20];
2194 int start; 2263 int start;
2195 int end; 2264 int end;
2196 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 2265 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
2197 2266
2198 smprintf(s, "Getting memory information\n"); 2267 smprintf(s, "Getting memory information\n");
2199 2268
2200 Priv->MemorySize = 0; 2269 Priv->MemorySize = 0;
2201 Priv->TextLength = 0; 2270 Priv->TextLength = 0;
2202 Priv->NumberLength = 0; 2271 Priv->NumberLength = 0;
2203 2272
2204 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus); 2273 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus);
2274 if (Priv->Manufacturer == AT_Samsung)
2275 error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus);
2205 if (error != ERR_NONE) return error; 2276 if (error != ERR_NONE) return error;
2206 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE; 2277 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE;
2207 2278
2208 smprintf(s, "Getting memory status by reading values\n"); 2279 smprintf(s, "Getting memory status by reading values\n");
2209 2280
2210 s->Phone.Data.MemoryStatus= Status; 2281 s->Phone.Data.MemoryStatus= Status;
2211 Status->MemoryUsed = 0; 2282 Status->MemoryUsed = 0;
2212 Status->MemoryFree = 0; 2283 Status->MemoryFree = 0;
2213 start = Priv->FirstMemoryEntry; 2284 start = Priv->FirstMemoryEntry;
2214 Priv->NextMemoryEntry = 0; 2285 Priv->NextMemoryEntry = 0;
2215 while (1) { 2286 while (1) {
2216 end= start + 20; 2287 end= start + 20;
2217 if (end > Priv->MemorySize) end = Priv->MemorySize; 2288 if (end > Priv->MemorySize) end = Priv->MemorySize;
2218 sprintf(req, "AT+CPBR=%i,%i\r", start, end); 2289 sprintf(req, "AT+CPBR=%i,%i\r", start, end);
2219 error= GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemoryStatus); 2290 error= GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemoryStatus);
2220 if (error != ERR_NONE) return error; 2291 if (error != ERR_NONE) return error;
2221 if (NeededInfo == AT_NextEmpty && Priv->NextMemoryEntry != 0 && Priv->NextMemoryEntry != end + 1) return ERR_NONE; 2292 if (NeededInfo == AT_NextEmpty && Priv->NextMemoryEntry != 0 && Priv->NextMemoryEntry != end + 1) return ERR_NONE;
2222 if (end == Priv->MemorySize) { 2293 if (end == Priv->MemorySize) {
2223 Status->MemoryFree = Priv->MemorySize - Status->MemoryUsed; 2294 Status->MemoryFree = Priv->MemorySize - Status->MemoryUsed;
2224 return ERR_NONE; 2295 return ERR_NONE;
2225 } 2296 }
2226 start = end + 1; 2297 start = end + 1;
2227 } 2298 }
2228} 2299}
2229 2300
2230GSM_Error ATGEN_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 2301GSM_Error ATGEN_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
2231{ 2302{
2232 GSM_Error error; 2303 GSM_Error error;
2233 2304
2234 error = ATGEN_SetPBKMemory(s, Status->MemoryType); 2305 error = ATGEN_SetPBKMemory(s, Status->MemoryType);
2235 if (error != ERR_NONE) return error; 2306 if (error != ERR_NONE) return error;
2236 2307
2237 s->Phone.Data.MemoryStatus=Status; 2308 s->Phone.Data.MemoryStatus=Status;
2238 2309
2239 /* in some phones doesn't work or doesn't return memory status inside */ 2310 /* in some phones doesn't work or doesn't return memory status inside */
2240 /* Some workaround for buggy mobile, that hangs after "AT+CPBS?" for other 2311 /* Some workaround for buggy mobile, that hangs after "AT+CPBS?" for other
2241 * memory than SM. 2312 * memory than SM.
2242 */ 2313 */
2243 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_BROKENCPBS) || (Status->MemoryType == MEM_SM)) { 2314 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_BROKENCPBS) || (Status->MemoryType == MEM_SM)) {
2244 smprintf(s, "Getting memory status\n"); 2315 smprintf(s, "Getting memory status\n");
2245 error=GSM_WaitFor (s, "AT+CPBS?\r", 9, 0x00, 4, ID_GetMemoryStatus); 2316 error=GSM_WaitFor (s, "AT+CPBS?\r", 9, 0x00, 4, ID_GetMemoryStatus);
2246 if (error == ERR_NONE) return ERR_NONE; 2317 if (error == ERR_NONE) return ERR_NONE;
2247 } 2318 }
2248 2319
2249 return ATGEN_GetMemoryInfo(s, Status, AT_Status); 2320 return ATGEN_GetMemoryInfo(s, Status, AT_Status);
2250} 2321}
2251 2322
2252GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode) 2323GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
2253{ 2324{
2254 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 2325 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
2255 GSM_Error error; 2326 GSM_Error error;
2256 2327
2257 /* Have we already selected something? */ 2328 /* Have we already selected something? */
2258 if (Priv->PBKCharset!=0) { 2329 if (Priv->PBKCharset!=0) {
2259 /* If we want unicode charset and we have it already or setting of it 2330 /* If we want unicode charset and we have it already or setting of it
2260 * failed, we have nothing to do. */ 2331 * failed, we have nothing to do. */
2261 if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE; 2332 if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE;
2262 2333
2263 /* If we don't need unicode charset and we have some (or have unicode 2334 /* If we don't need unicode charset and we have some (or have unicode
2264 * charset when other failed), we have nothing to do. */ 2335 * charset when other failed), we have nothing to do. */
2265 if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE; 2336 if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE;
2266 } 2337 }
2267 2338
2268 error=ATGEN_GetManufacturer(s); 2339 error=ATGEN_GetManufacturer(s);
2269 if (error != ERR_NONE) return error; 2340 if (error != ERR_NONE) return error;
2270 2341
2342 /* Samsung (and Sagem?) phones use only PCCP437? */
2343 if (Priv->Manufacturer == AT_Samsung) {
2344 Priv->PBKCharset = AT_PBK_PCCP437;
2345 return ERR_NONE;
2346 }
2347
2271 if (PreferUnicode && !Priv->UCS2CharsetFailed) { 2348 if (PreferUnicode && !Priv->UCS2CharsetFailed) {
2272 smprintf(s, "Setting charset to UCS2\n"); 2349 smprintf(s, "Setting charset to UCS2\n");
2273 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset); 2350 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset);
2274 if (error == ERR_NONE) { 2351 if (error == ERR_NONE) {
2275 Priv->PBKCharset = AT_PBK_UCS2; 2352 Priv->PBKCharset = AT_PBK_UCS2;
2276 return ERR_NONE; 2353 return ERR_NONE;
2277 } else { 2354 } else {
2278 Priv->UCS2CharsetFailed = true; 2355 Priv->UCS2CharsetFailed = true;
2279 } 2356 }
2280 } 2357 }
2281 2358
2282 smprintf(s, "Setting charset to HEX\n"); 2359 smprintf(s, "Setting charset to HEX\n");
2283 error=GSM_WaitFor (s, "AT+CSCS=\"HEX\"\r", 14, 0x00, 3, ID_SetMemoryCharset); 2360 error=GSM_WaitFor (s, "AT+CSCS=\"HEX\"\r", 14, 0x00, 3, ID_SetMemoryCharset);
2284 /* Falcom replies OK for HEX mode and send everything 2361 /* Falcom replies OK for HEX mode and send everything
2285 * in normal format */ 2362 * in normal format */
2286 if (error == ERR_NONE && Priv->Manufacturer != AT_Falcom) { 2363 if (error == ERR_NONE && Priv->Manufacturer != AT_Falcom) {
2287 Priv->PBKCharset = AT_PBK_HEX; 2364 Priv->PBKCharset = AT_PBK_HEX;
2288 return ERR_NONE; 2365 return ERR_NONE;
2289 } 2366 }
2290 2367
2291 smprintf(s, "Setting charset to GSM\n"); 2368 smprintf(s, "Setting charset to GSM\n");
2292 error=GSM_WaitFor (s, "AT+CSCS=\"GSM\"\r", 14, 0x00, 3, ID_SetMemoryCharset); 2369 error=GSM_WaitFor (s, "AT+CSCS=\"GSM\"\r", 14, 0x00, 3, ID_SetMemoryCharset);
2293 if (error == ERR_NONE) { 2370 if (error == ERR_NONE) {
2294 Priv->PBKCharset = AT_PBK_GSM; 2371 Priv->PBKCharset = AT_PBK_GSM;
2295 return ERR_NONE; 2372 return ERR_NONE;
2296 } 2373 }
2297 2374
2298 if (!Priv->UCS2CharsetFailed) { 2375 if (!Priv->UCS2CharsetFailed) {
2299 Priv->NonUCS2CharsetFailed = true; 2376 Priv->NonUCS2CharsetFailed = true;
2300 smprintf(s, "Setting charset to UCS2\n"); 2377 smprintf(s, "Setting charset to UCS2\n");
2301 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset); 2378 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset);
2302 if (error == ERR_NONE) { 2379 if (error == ERR_NONE) {
2303 Priv->PBKCharset = AT_PBK_UCS2; 2380 Priv->PBKCharset = AT_PBK_UCS2;
2304 return ERR_NONE; 2381 return ERR_NONE;
2305 } else { 2382 } else {
2306 Priv->UCS2CharsetFailed = true; 2383 Priv->UCS2CharsetFailed = true;
2307 } 2384 }
2308 } 2385 }
2309 2386
2310 return error; 2387 return error;
2311} 2388}
2312 2389
2313GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 2390GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
2314{ 2391{
2315 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 2392 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
2316 GSM_MemoryEntry *Memory = s->Phone.Data.Memory; 2393 GSM_MemoryEntry *Memory = s->Phone.Data.Memory;
2317 char *pos; 2394 char *pos;
2318 unsigned char buffer[500],buffer2[500]; 2395 unsigned char buffer[500],buffer2[500];
@@ -2340,97 +2417,127 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
2340 Memory->EntriesNum++; 2417 Memory->EntriesNum++;
2341 Memory->Entries[0].EntryType = PBK_Number_General; 2418 Memory->Entries[0].EntryType = PBK_Number_General;
2342 Memory->Entries[0].VoiceTag = 0; 2419 Memory->Entries[0].VoiceTag = 0;
2343 Memory->Entries[0].SMSList[0] = 0; 2420 Memory->Entries[0].SMSList[0] = 0;
2344 2421
2345 len = strlen(buffer + 1) - 1; 2422 len = strlen(buffer + 1) - 1;
2346 if (Priv->PBKCharset == AT_PBK_HEX && (len > 10) && (len % 2 == 0) && (strchr(buffer + 1, '+') == NULL)) { 2423 if (Priv->PBKCharset == AT_PBK_HEX && (len > 10) && (len % 2 == 0) && (strchr(buffer + 1, '+') == NULL)) {
2347 /* This is probably hex encoded number */ 2424 /* This is probably hex encoded number */
2348 DecodeHexBin(buffer2, buffer+1, len); 2425 DecodeHexBin(buffer2, buffer+1, len);
2349 DecodeDefault(Memory->Entries[0].Text ,buffer2, strlen(buffer2), false, NULL); 2426 DecodeDefault(Memory->Entries[0].Text ,buffer2, strlen(buffer2), false, NULL);
2350 } else if (Priv->PBKCharset == AT_PBK_UCS2 && (len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) { 2427 } else if (Priv->PBKCharset == AT_PBK_UCS2 && (len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) {
2351 /* This is probably unicode encoded number */ 2428 /* This is probably unicode encoded number */
2352 DecodeHexUnicode(Memory->Entries[0].Text, buffer + 1,len); 2429 DecodeHexUnicode(Memory->Entries[0].Text, buffer + 1,len);
2353 } else { 2430 } else {
2354 EncodeUnicode(Memory->Entries[0].Text, buffer + 1, len); 2431 EncodeUnicode(Memory->Entries[0].Text, buffer + 1, len);
2355 } 2432 }
2356 2433
2357 /* Number format */ 2434 /* Number format */
2358 pos += ATGEN_ExtractOneParameter(pos, buffer); 2435 pos += ATGEN_ExtractOneParameter(pos, buffer);
2359 smprintf(s, "Number format: %s\n",buffer); 2436 smprintf(s, "Number format: %s\n",buffer);
2360 2437
2361 /* International number */ 2438 /* International number */
2362 if (!strcmp(buffer,"145")) { 2439 if (!strcmp(buffer,"145")) {
2363 sprintf(buffer+1,"%s",DecodeUnicodeString(Memory->Entries[0].Text)); 2440 sprintf(buffer+1,"%s",DecodeUnicodeString(Memory->Entries[0].Text));
2364 if (strlen(buffer+1)!=0 && buffer[1] != '+') { 2441 if (strlen(buffer+1)!=0 && buffer[1] != '+') {
2365 /* Sony Ericsson issue */ 2442 /* Sony Ericsson issue */
2366 /* International number is without + */ 2443 /* International number is without + */
2367 buffer[0] = '+'; 2444 buffer[0] = '+';
2368 EncodeUnicode(Memory->Entries[0].Text,buffer,strlen(buffer)); 2445 EncodeUnicode(Memory->Entries[0].Text,buffer,strlen(buffer));
2369 } 2446 }
2370 } 2447 }
2371 2448
2372 /* Name */ 2449 /* Name */
2373 pos += ATGEN_ExtractOneParameter(pos, buffer); 2450 pos += ATGEN_ExtractOneParameter(pos, buffer);
2374 smprintf(s, "Name text: %s\n",buffer); 2451 smprintf(s, "Name text: %s\n",buffer);
2375 Memory->EntriesNum++; 2452 Memory->EntriesNum++;
2376 Memory->Entries[1].EntryType=PBK_Text_Name; 2453 Memory->Entries[1].EntryType=PBK_Text_Name;
2377 switch (Priv->PBKCharset) { 2454 switch (Priv->PBKCharset) {
2378 case AT_PBK_HEX: 2455 case AT_PBK_HEX:
2379 DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2); 2456 DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2);
2380 DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL); 2457 DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL);
2381 break; 2458 break;
2382 case AT_PBK_GSM: 2459 case AT_PBK_GSM:
2383 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL); 2460 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
2384 break; 2461 break;
2385 case AT_PBK_UCS2: 2462 case AT_PBK_UCS2:
2386 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1); 2463 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1);
2387 break; 2464 break;
2465 case AT_PBK_PCCP437:
2466 /* FIXME: correctly decode PCCP437 */
2467 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
2468 break;
2469 }
2470
2471 /* Samsung number type */
2472 if (Priv->Manufacturer == AT_Samsung) {
2473 int type;
2474
2475 pos += ATGEN_ExtractOneParameter(pos, buffer);
2476 smprintf(s, "Number type: %s\n",buffer);
2477 type = strtoul(buffer, NULL, 0);
2478 switch (type) {
2479 case 0:
2480 Memory->Entries[0].EntryType = PBK_Number_Mobile;
2481 break;
2482 case 1:
2483 Memory->Entries[0].EntryType = PBK_Number_Work;
2484 break;
2485 case 2:
2486 Memory->Entries[0].EntryType = PBK_Number_Home;
2487 break;
2488 case 3:
2489 Memory->Entries[0].EntryType = PBK_Text_Email;
2490 break;
2491 default:
2492 Memory->Entries[0].EntryType = PBK_Number_General;
2493 }
2388 } 2494 }
2495
2389 return ERR_NONE; 2496 return ERR_NONE;
2390 case AT_Reply_CMEError: 2497 case AT_Reply_CMEError:
2391 return ATGEN_HandleCMEError(s); 2498 return ATGEN_HandleCMEError(s);
2392 case AT_Reply_Error: 2499 case AT_Reply_Error:
2393 smprintf(s, "Error - too high location ?\n"); 2500 smprintf(s, "Error - too high location ?\n");
2394 return ERR_INVALIDLOCATION; 2501 return ERR_INVALIDLOCATION;
2395 case AT_Reply_CMSError: 2502 case AT_Reply_CMSError:
2396 return ATGEN_HandleCMSError(s); 2503 return ATGEN_HandleCMSError(s);
2397 default: 2504 default:
2398 break; 2505 break;
2399 } 2506 }
2400 return ERR_UNKNOWNRESPONSE; 2507 return ERR_UNKNOWNRESPONSE;
2401} 2508}
2402 2509
2403GSM_Error ATGEN_PrivGetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, int endlocation) 2510GSM_Error ATGEN_PrivGetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, int endlocation)
2404{ 2511{
2405 GSM_Error error; 2512 GSM_Error error;
2406 unsigned char req[20]; 2513 unsigned char req[20];
2407 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 2514 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
2408 2515
2409 if (entry->Location==0x00) return ERR_INVALIDLOCATION; 2516 if (entry->Location==0x00) return ERR_INVALIDLOCATION;
2410 2517
2411 if (entry->MemoryType == MEM_ME) { 2518 if (entry->MemoryType == MEM_ME) {
2412 if (Priv->PBKSBNR == 0) { 2519 if (Priv->PBKSBNR == 0) {
2413 sprintf(req, "AT^SBNR=?\r"); 2520 sprintf(req, "AT^SBNR=?\r");
2414 smprintf(s, "Checking availablity of SBNR\n"); 2521 smprintf(s, "Checking availablity of SBNR\n");
2415 error=GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory); 2522 error=GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory);
2416 switch (error) { 2523 switch (error) {
2417 case ERR_NONE: 2524 case ERR_NONE:
2418 Priv->PBKSBNR = AT_SBNR_AVAILABLE; 2525 Priv->PBKSBNR = AT_SBNR_AVAILABLE;
2419 break; 2526 break;
2420 case ERR_UNKNOWN: 2527 case ERR_UNKNOWN:
2421 case ERR_NOTSUPPORTED: 2528 case ERR_NOTSUPPORTED:
2422 Priv->PBKSBNR = AT_SBNR_NOTAVAILABLE; 2529 Priv->PBKSBNR = AT_SBNR_NOTAVAILABLE;
2423 break; 2530 break;
2424 default: 2531 default:
2425 return error; 2532 return error;
2426 } 2533 }
2427 } 2534 }
2428 if (Priv->PBKSBNR == AT_SBNR_AVAILABLE) { 2535 if (Priv->PBKSBNR == AT_SBNR_AVAILABLE) {
2429 sprintf(req, "AT^SBNR=vcf,%i\r",entry->Location-1); 2536 sprintf(req, "AT^SBNR=vcf,%i\r",entry->Location-1);
2430 s->Phone.Data.Memory=entry; 2537 s->Phone.Data.Memory=entry;
2431 smprintf(s, "Getting phonebook entry\n"); 2538 smprintf(s, "Getting phonebook entry\n");
2432 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory); 2539 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory);
2433 } 2540 }
2434 } 2541 }
2435 2542
2436 error=ATGEN_GetManufacturer(s); 2543 error=ATGEN_GetManufacturer(s);
@@ -2517,96 +2624,98 @@ GSM_Error ATGEN_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type)
2517 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetMemory); 2624 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetMemory);
2518 if (error != ERR_NONE) return error; 2625 if (error != ERR_NONE) return error;
2519 } 2626 }
2520 return ERR_NONE; 2627 return ERR_NONE;
2521} 2628}
2522 2629
2523GSM_Error ATGEN_ReplyDialVoice(GSM_Protocol_Message msg, GSM_StateMachine *s) 2630GSM_Error ATGEN_ReplyDialVoice(GSM_Protocol_Message msg, GSM_StateMachine *s)
2524{ 2631{
2525 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 2632 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
2526 case AT_Reply_OK: 2633 case AT_Reply_OK:
2527 smprintf(s, "Dial voice OK\n"); 2634 smprintf(s, "Dial voice OK\n");
2528 return ERR_NONE; 2635 return ERR_NONE;
2529 case AT_Reply_Error: 2636 case AT_Reply_Error:
2530 smprintf(s, "Dial voice error\n"); 2637 smprintf(s, "Dial voice error\n");
2531 return ERR_UNKNOWN; 2638 return ERR_UNKNOWN;
2532 case AT_Reply_CMSError: 2639 case AT_Reply_CMSError:
2533 return ATGEN_HandleCMSError(s); 2640 return ATGEN_HandleCMSError(s);
2534 default: 2641 default:
2535 break; 2642 break;
2536 } 2643 }
2537 return ERR_UNKNOWNRESPONSE; 2644 return ERR_UNKNOWNRESPONSE;
2538} 2645}
2539 2646
2540GSM_Error ATGEN_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 2647GSM_Error ATGEN_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
2541{ 2648{
2542 char req[39] = "ATDT"; 2649 char req[39] = "ATDT";
2543 2650
2544 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED; 2651 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
2545 if (strlen(number) > 32) return (ERR_UNKNOWN); 2652 if (strlen(number) > 32) return (ERR_UNKNOWN);
2546 2653
2547 strcat(req, number); 2654 strcat(req, number);
2548 strcat(req, ";\r"); 2655 strcat(req, ";\r");
2549 2656
2550 smprintf(s, "Making voice call\n"); 2657 smprintf(s, "Making voice call\n");
2551 return GSM_WaitFor (s, req, 4+2+strlen(number), 0x00, 5, ID_DialVoice); 2658 return GSM_WaitFor (s, req, 4+2+strlen(number), 0x00, 5, ID_DialVoice);
2552} 2659}
2553 2660
2554GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) 2661GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
2555{ 2662{
2556 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 2663 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
2557 case AT_Reply_OK: 2664 case AT_Reply_OK:
2558 smprintf(s, "Security code was OK\n"); 2665 smprintf(s, "Security code was OK\n");
2559 return ERR_NONE; 2666 return ERR_NONE;
2560 case AT_Reply_Error: 2667 case AT_Reply_Error:
2561 smprintf(s, "Incorrect security code\n"); 2668 smprintf(s, "Incorrect security code\n");
2562 return ERR_SECURITYERROR; 2669 return ERR_SECURITYERROR;
2563 case AT_Reply_CMSError: 2670 case AT_Reply_CMSError:
2564 return ATGEN_HandleCMSError(s); 2671 return ATGEN_HandleCMSError(s);
2672 case AT_Reply_CMEError:
2673 return ATGEN_HandleCMEError(s);
2565 default: 2674 default:
2566 break; 2675 break;
2567 } 2676 }
2568 return ERR_UNKNOWNRESPONSE; 2677 return ERR_UNKNOWNRESPONSE;
2569} 2678}
2570 2679
2571GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) 2680GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
2572{ 2681{
2573 unsigned char req[50]; 2682 unsigned char req[50];
2574 2683
2575 switch (Code.Type) { 2684 switch (Code.Type) {
2576 case SEC_Pin : 2685 case SEC_Pin :
2577 sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code); 2686 sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code);
2578 break; 2687 break;
2579 case SEC_Pin2 : 2688 case SEC_Pin2 :
2580 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Siemens) { 2689 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Siemens) {
2581 sprintf(req, "AT+CPIN2=\"%s\"\r", Code.Code); 2690 sprintf(req, "AT+CPIN2=\"%s\"\r", Code.Code);
2582 } else { 2691 } else {
2583 sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code); 2692 sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code);
2584 } 2693 }
2585 break; 2694 break;
2586 default : return ERR_NOTIMPLEMENTED; 2695 default : return ERR_NOTIMPLEMENTED;
2587 } 2696 }
2588 2697
2589 smprintf(s, "Entering security code\n"); 2698 smprintf(s, "Entering security code\n");
2590 return GSM_WaitFor (s, req, strlen(req), 0x00, 6, ID_EnterSecurityCode); 2699 return GSM_WaitFor (s, req, strlen(req), 0x00, 6, ID_EnterSecurityCode);
2591} 2700}
2592 2701
2593GSM_Error ATGEN_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 2702GSM_Error ATGEN_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
2594{ 2703{
2595 GSM_SecurityCodeType *Status = s->Phone.Data.SecurityStatus; 2704 GSM_SecurityCodeType *Status = s->Phone.Data.SecurityStatus;
2596 2705
2597 smprintf(s, "Security status received - "); 2706 smprintf(s, "Security status received - ");
2598 if (strstr(msg.Buffer,"READY")) { 2707 if (strstr(msg.Buffer,"READY")) {
2599 *Status = SEC_None; 2708 *Status = SEC_None;
2600 smprintf(s, "nothing to enter\n"); 2709 smprintf(s, "nothing to enter\n");
2601 return ERR_NONE; 2710 return ERR_NONE;
2602 } 2711 }
2603 if (strstr(msg.Buffer,"PH_SIM PIN")) { 2712 if (strstr(msg.Buffer,"PH_SIM PIN")) {
2604 smprintf(s, "no SIM inside or other error\n"); 2713 smprintf(s, "no SIM inside or other error\n");
2605 return ERR_UNKNOWN; 2714 return ERR_UNKNOWN;
2606 } 2715 }
2607 if (strstr(msg.Buffer,"SIM PIN2")) { 2716 if (strstr(msg.Buffer,"SIM PIN2")) {
2608 *Status = SEC_Pin2; 2717 *Status = SEC_Pin2;
2609 smprintf(s, "waiting for PIN2\n"); 2718 smprintf(s, "waiting for PIN2\n");
2610 return ERR_NONE; 2719 return ERR_NONE;
2611 } 2720 }
2612 if (strstr(msg.Buffer,"SIM PUK2")) { 2721 if (strstr(msg.Buffer,"SIM PUK2")) {
@@ -2879,96 +2988,102 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2879 if (entry->Location == 0) return ERR_INVALIDLOCATION; 2988 if (entry->Location == 0) return ERR_INVALIDLOCATION;
2880 2989
2881 error = ATGEN_SetPBKMemory(s, entry->MemoryType); 2990 error = ATGEN_SetPBKMemory(s, entry->MemoryType);
2882 if (error != ERR_NONE) return error; 2991 if (error != ERR_NONE) return error;
2883 2992
2884 GSM_PhonebookFindDefaultNameNumberGroup(entry, &Name, &Number, &Group); 2993 GSM_PhonebookFindDefaultNameNumberGroup(entry, &Name, &Number, &Group);
2885 2994
2886 name[0] = 0; 2995 name[0] = 0;
2887 if (Name != -1) { 2996 if (Name != -1) {
2888 len = UnicodeLength(entry->Entries[Name].Text); 2997 len = UnicodeLength(entry->Entries[Name].Text);
2889 2998
2890 /* Compare if we would loose some information when not using 2999 /* Compare if we would loose some information when not using
2891 * unicode */ 3000 * unicode */
2892 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); 3001 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
2893 DecodeDefault(uname, name, len, true, NULL); 3002 DecodeDefault(uname, name, len, true, NULL);
2894 if (!mywstrncmp(uname, entry->Entries[Name].Text, len)) { 3003 if (!mywstrncmp(uname, entry->Entries[Name].Text, len)) {
2895 /* Get maximal text length */ 3004 /* Get maximal text length */
2896 if (Priv->TextLength == 0) { 3005 if (Priv->TextLength == 0) {
2897 ATGEN_GetMemoryInfo(s, NULL, AT_Sizes); 3006 ATGEN_GetMemoryInfo(s, NULL, AT_Sizes);
2898 } 3007 }
2899 3008
2900 /* I char stored in GSM alphabet takes 7 bits, one 3009 /* I char stored in GSM alphabet takes 7 bits, one
2901 * unicode 16, if storing in unicode would truncate 3010 * unicode 16, if storing in unicode would truncate
2902 * text, do not use it, otherwise we will use it */ 3011 * text, do not use it, otherwise we will use it */
2903 if ((Priv->TextLength != 0) && ((Priv->TextLength * 7 / 16) <= len)) { 3012 if ((Priv->TextLength != 0) && ((Priv->TextLength * 7 / 16) <= len)) {
2904 PreferUnicode = false; 3013 PreferUnicode = false;
2905 } else { 3014 } else {
2906 PreferUnicode = true; 3015 PreferUnicode = true;
2907 } 3016 }
2908 } 3017 }
2909 3018
2910 error = ATGEN_SetPBKCharset(s, PreferUnicode); 3019 error = ATGEN_SetPBKCharset(s, PreferUnicode);
2911 if (error != ERR_NONE) return error; 3020 if (error != ERR_NONE) return error;
2912 3021
2913 switch (Priv->PBKCharset) { 3022 switch (Priv->PBKCharset) {
2914 case AT_PBK_HEX: 3023 case AT_PBK_HEX:
2915 EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text)); 3024 EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text));
2916 len = strlen(name); 3025 len = strlen(name);
2917 break; 3026 break;
2918 case AT_PBK_GSM: 3027 case AT_PBK_GSM:
2919 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text)); 3028 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
2920 len = UnicodeLength(entry->Entries[Name].Text); 3029 len = UnicodeLength(entry->Entries[Name].Text);
2921 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); 3030 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
2922 break; 3031 break;
2923 case AT_PBK_UCS2: 3032 case AT_PBK_UCS2:
2924 EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text)); 3033 EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text));
2925 len = strlen(name); 3034 len = strlen(name);
2926 break; 3035 break;
3036 case AT_PBK_PCCP437:
3037 /* FIXME: correctly decode PCCP437 */
3038 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
3039 len = UnicodeLength(entry->Entries[Name].Text);
3040 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
3041 break;
2927 } 3042 }
2928 } else { 3043 } else {
2929 smprintf(s, "WARNING: No usable name found!\n"); 3044 smprintf(s, "WARNING: No usable name found!\n");
2930 len = 0; 3045 len = 0;
2931 } 3046 }
2932 3047
2933 if (Number != -1) { 3048 if (Number != -1) {
2934 GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false); 3049 GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false);
2935 NumberType = number[0]; 3050 NumberType = number[0];
2936 sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text)); 3051 sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text));
2937 } else { 3052 } else {
2938 smprintf(s, "WARNING: No usable number found!\n"); 3053 smprintf(s, "WARNING: No usable number found!\n");
2939 number[0] = 0; 3054 number[0] = 0;
2940 } 3055 }
2941 3056
2942 if (Priv->FirstMemoryEntry == 0) { 3057 if (Priv->FirstMemoryEntry == 0) {
2943 error = ATGEN_GetMemoryInfo(s, NULL, AT_First); 3058 error = ATGEN_GetMemoryInfo(s, NULL, AT_First);
2944 if (error != ERR_NONE) return error; 3059 if (error != ERR_NONE) return error;
2945 } 3060 }
2946 3061
2947 /* We can't use here: 3062 /* We can't use here:
2948 * sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"%s\"\r", 3063 * sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"%s\"\r",
2949 * entry->Location, number, NumberType, name); 3064 * entry->Location, number, NumberType, name);
2950 * because name can contain 0 when using GSM alphabet. 3065 * because name can contain 0 when using GSM alphabet.
2951 */ 3066 */
2952 sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"", entry->Location + Priv->FirstMemoryEntry - 1, number, NumberType); 3067 sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"", entry->Location + Priv->FirstMemoryEntry - 1, number, NumberType);
2953 reqlen = strlen(req); 3068 reqlen = strlen(req);
2954 if (reqlen + len > REQUEST_SIZE - 2) { 3069 if (reqlen + len > REQUEST_SIZE - 2) {
2955 smprintf(s, "WARNING: Text truncated to fit in buffer!\n"); 3070 smprintf(s, "WARNING: Text truncated to fit in buffer!\n");
2956 len = REQUEST_SIZE - 2 - reqlen; 3071 len = REQUEST_SIZE - 2 - reqlen;
2957 } 3072 }
2958 memcpy(req + reqlen, name, len); 3073 memcpy(req + reqlen, name, len);
2959 reqlen += len; 3074 reqlen += len;
2960 memcpy(req + reqlen, "\"\r", 2); 3075 memcpy(req + reqlen, "\"\r", 2);
2961 reqlen += 2; 3076 reqlen += 2;
2962 3077
2963 smprintf(s, "Writing phonebook entry\n"); 3078 smprintf(s, "Writing phonebook entry\n");
2964 return GSM_WaitFor (s, req, reqlen, 0x00, 4, ID_SetMemory); 3079 return GSM_WaitFor (s, req, reqlen, 0x00, 4, ID_SetMemory);
2965#undef REQUEST_SIZE 3080#undef REQUEST_SIZE
2966} 3081}
2967 3082
2968GSM_Error ATGEN_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 3083GSM_Error ATGEN_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2969{ 3084{
2970 if (entry->Location == 0) return ERR_INVALIDLOCATION; 3085 if (entry->Location == 0) return ERR_INVALIDLOCATION;
2971 return ATGEN_PrivSetMemory(s, entry); 3086 return ATGEN_PrivSetMemory(s, entry);
2972} 3087}
2973 3088
2974GSM_Error ATGEN_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 3089GSM_Error ATGEN_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
@@ -3207,463 +3322,541 @@ GSM_Error ATGEN_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
3207 return GSM_WaitFor (s, "AT+CSQ\r", 7, 0x00, 4, ID_GetSignalQuality); 3322 return GSM_WaitFor (s, "AT+CSQ\r", 7, 0x00, 4, ID_GetSignalQuality);
3208} 3323}
3209 3324
3210/* When use AT+CPIN?, A2D returns it without OK and because of it Gammu 3325/* When use AT+CPIN?, A2D returns it without OK and because of it Gammu
3211 parses answer without it. 3326 parses answer without it.
3212 MC35 and other return OK after answer for AT+CPIN?. Here we handle it. 3327 MC35 and other return OK after answer for AT+CPIN?. Here we handle it.
3213 Any better idea ? 3328 Any better idea ?
3214 */ 3329 */
3215GSM_Error ATGEN_ReplyOK(GSM_Protocol_Message msg, GSM_StateMachine *s) 3330GSM_Error ATGEN_ReplyOK(GSM_Protocol_Message msg, GSM_StateMachine *s)
3216{ 3331{
3217 return ERR_NONE; 3332 return ERR_NONE;
3218} 3333}
3219 3334
3220static GSM_Error ATGEN_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 3335static GSM_Error ATGEN_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
3221{ 3336{
3222 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 3337 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3223 3338
3224 if (Priv->Manufacturer==AT_Siemens ) return SIEMENS_GetNextCalendar(s,Note,start); 3339 if (Priv->Manufacturer==AT_Siemens ) return SIEMENS_GetNextCalendar(s,Note,start);
3225 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_GetNextCalendar(s,Note,start); 3340 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_GetNextCalendar(s,Note,start);
3226 return ERR_NOTSUPPORTED; 3341 return ERR_NOTSUPPORTED;
3227} 3342}
3228 3343
3229GSM_Error ATGEN_Terminate(GSM_StateMachine *s) 3344GSM_Error ATGEN_Terminate(GSM_StateMachine *s)
3230{ 3345{
3231 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 3346 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
3232 3347
3233 free(Priv->file.Buffer); 3348 free(Priv->file.Buffer);
3234 return ERR_NONE; 3349 return ERR_NONE;
3235} 3350}
3236 3351
3237GSM_Error ATGEN_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3352GSM_Error ATGEN_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3238{ 3353{
3239 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 3354 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
3240 3355
3241 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_AddCalendarNote(s, Note); 3356 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_AddCalendarNote(s, Note);
3242 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_AddCalendarNote(s, Note); 3357 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_AddCalendarNote(s, Note);
3243 return ERR_NOTSUPPORTED; 3358 return ERR_NOTSUPPORTED;
3244} 3359}
3245 3360
3246GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3361GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3247{ 3362{
3248 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 3363 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
3249 3364
3250 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note); 3365 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note);
3251 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note); 3366 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note);
3252 return ERR_NOTSUPPORTED; 3367 return ERR_NOTSUPPORTED;
3253} 3368}
3254 3369
3370
3371GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3372{
3373 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3374
3375 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap);
3376 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap);
3377 return ERR_NOTSUPPORTED;
3378}
3379
3380GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3381{
3382 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3383
3384 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap);
3385 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap);
3386 return ERR_NOTSUPPORTED;
3387}
3388
3389GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
3390{
3391 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3392
3393 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone);
3394 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone);
3395 return ERR_NOTSUPPORTED;
3396}
3397
3398GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
3399{
3400 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3401
3402 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength);
3403 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength);
3404 return ERR_NOTSUPPORTED;
3405}
3406
3255GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 3407GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
3256{ 3408{
3257 GSM_Errorerror; 3409 GSM_Errorerror;
3258 unsigned char Frame[] = "AT+CKPD=\"?\"\r"; 3410 unsigned char Frame[] = "AT+CKPD=\"?\"\r";
3259 3411
3260 if (Press) { 3412 if (Press) {
3261 switch (Key) { 3413 switch (Key) {
3262 case GSM_KEY_1 : Frame[9] = '1'; break; 3414 case GSM_KEY_1 : Frame[9] = '1'; break;
3263 case GSM_KEY_2 : Frame[9] = '2'; break; 3415 case GSM_KEY_2 : Frame[9] = '2'; break;
3264 case GSM_KEY_3 : Frame[9] = '3'; break; 3416 case GSM_KEY_3 : Frame[9] = '3'; break;
3265 case GSM_KEY_4 : Frame[9] = '4'; break; 3417 case GSM_KEY_4 : Frame[9] = '4'; break;
3266 case GSM_KEY_5 : Frame[9] = '5'; break; 3418 case GSM_KEY_5 : Frame[9] = '5'; break;
3267 case GSM_KEY_6 : Frame[9] = '6'; break; 3419 case GSM_KEY_6 : Frame[9] = '6'; break;
3268 case GSM_KEY_7 : Frame[9] = '7'; break; 3420 case GSM_KEY_7 : Frame[9] = '7'; break;
3269 case GSM_KEY_8 : Frame[9] = '8'; break; 3421 case GSM_KEY_8 : Frame[9] = '8'; break;
3270 case GSM_KEY_9 : Frame[9] = '9'; break; 3422 case GSM_KEY_9 : Frame[9] = '9'; break;
3271 case GSM_KEY_0 : Frame[9] = '0'; break; 3423 case GSM_KEY_0 : Frame[9] = '0'; break;
3272 case GSM_KEY_HASH : Frame[9] = '#'; break; 3424 case GSM_KEY_HASH : Frame[9] = '#'; break;
3273 case GSM_KEY_ASTERISK : Frame[9] = '*'; break; 3425 case GSM_KEY_ASTERISK : Frame[9] = '*'; break;
3274 case GSM_KEY_POWER : return ERR_NOTSUPPORTED; 3426 case GSM_KEY_POWER : return ERR_NOTSUPPORTED;
3275 case GSM_KEY_GREEN : Frame[9] = 'S'; break; 3427 case GSM_KEY_GREEN : Frame[9] = 'S'; break;
3276 case GSM_KEY_RED : Frame[9] = 'E'; break; 3428 case GSM_KEY_RED : Frame[9] = 'E'; break;
3277 case GSM_KEY_INCREASEVOLUME: Frame[9] = 'U'; break; 3429 case GSM_KEY_INCREASEVOLUME: Frame[9] = 'U'; break;
3278 case GSM_KEY_DECREASEVOLUME: Frame[9] = 'D'; break; 3430 case GSM_KEY_DECREASEVOLUME: Frame[9] = 'D'; break;
3279 case GSM_KEY_UP : Frame[9] = '^'; break; 3431 case GSM_KEY_UP : Frame[9] = '^'; break;
3280 case GSM_KEY_DOWN : Frame[9] = 'V'; break; 3432 case GSM_KEY_DOWN : Frame[9] = 'V'; break;
3281 case GSM_KEY_MENU : Frame[9] = 'F'; break; 3433 case GSM_KEY_MENU : Frame[9] = 'F'; break;
3282 case GSM_KEY_NAMES : Frame[9] = 'C'; break; 3434 case GSM_KEY_NAMES : Frame[9] = 'C'; break;
3283 default : return ERR_NOTSUPPORTED; 3435 default : return ERR_NOTSUPPORTED;
3284 } 3436 }
3285 smprintf(s, "Pressing key\n"); 3437 smprintf(s, "Pressing key\n");
3286 error = GSM_WaitFor (s, Frame, 12, 0x00, 4, ID_PressKey); 3438 error = GSM_WaitFor (s, Frame, 12, 0x00, 4, ID_PressKey);
3287 if (error != ERR_NONE) return error; 3439 if (error != ERR_NONE) return error;
3288 3440
3289 /* Strange. My T310 needs it */ 3441 /* Strange. My T310 needs it */
3290 return GSM_WaitFor (s, "ATE1\r", 5, 0x00, 4, ID_EnableEcho); 3442 return GSM_WaitFor (s, "ATE1\r", 5, 0x00, 4, ID_EnableEcho);
3291 } else { 3443 } else {
3292 return ERR_NONE; 3444 return ERR_NONE;
3293 } 3445 }
3294} 3446}
3295 3447
3296#ifdef GSM_ENABLE_CELLBROADCAST 3448#ifdef GSM_ENABLE_CELLBROADCAST
3297 3449
3298GSM_Error ATGEN_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s) 3450GSM_Error ATGEN_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
3299{ 3451{
3300 GSM_CBMessage CB; 3452 GSM_CBMessage CB;
3301 int i,j; 3453 int i,j;
3302 char Buffer[300],Buffer2[300]; 3454 char Buffer[300],Buffer2[300];
3303 3455
3304 smprintf(s, "CB received\n"); 3456 smprintf(s, "CB received\n");
3305 return ERR_NONE; 3457 return ERR_NONE;
3306 3458
3307 DecodeHexBin (Buffer,msg.Buffer+6,msg.Length-6); 3459 DecodeHexBin (Buffer,msg.Buffer+6,msg.Length-6);
3308 DumpMessage(stdout, di.dl ,Buffer,msg.Length-6); 3460 DumpMessage(stdout, di.dl ,Buffer,msg.Length-6);
3309 3461
3310 CB.Channel = Buffer[4]; 3462 CB.Channel = Buffer[4];
3311 3463
3312 for (j=0;j<msg.Length;j++) { 3464 for (j=0;j<msg.Length;j++) {
3313 smprintf(s, "j=%i\n",j); 3465 smprintf(s, "j=%i\n",j);
3314 i=GSM_UnpackEightBitsToSeven(0, msg.Buffer[6], msg.Buffer[6], msg.Buffer+j, Buffer2); 3466 i=GSM_UnpackEightBitsToSeven(0, msg.Buffer[6], msg.Buffer[6], msg.Buffer+j, Buffer2);
3315 //i = msg.Buffer[6] - 1; 3467 //i = msg.Buffer[6] - 1;
3316 //while (i!=0) { 3468 //while (i!=0) {
3317 // if (Buffer[i] == 13) i = i - 1; else break; 3469 // if (Buffer[i] == 13) i = i - 1; else break;
3318 //} 3470 //}
3319 DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL); 3471 DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL);
3320 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text)); 3472 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text));
3321 } 3473 }
3322 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) { 3474 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) {
3323 s->User.IncomingCB(s->CurrentConfig->Device,CB); 3475 s->User.IncomingCB(s->CurrentConfig->Device,CB);
3324 } 3476 }
3325 return ERR_NONE; 3477 return ERR_NONE;
3326} 3478}
3327 3479
3328#endif 3480#endif
3329 3481
3330GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable) 3482GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
3331{ 3483{
3332#ifdef GSM_ENABLE_CELLBROADCAST 3484#ifdef GSM_ENABLE_CELLBROADCAST
3333 if (s->Phone.Data.EnableIncomingCB!=enable) { 3485 if (s->Phone.Data.EnableIncomingCB!=enable) {
3334 s->Phone.Data.EnableIncomingCB = enable; 3486 s->Phone.Data.EnableIncomingCB = enable;
3335 if (enable) { 3487 if (enable) {
3336 smprintf(s, "Enabling incoming CB\n"); 3488 smprintf(s, "Enabling incoming CB\n");
3337 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB); 3489 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB);
3338 } else { 3490 } else {
3339 smprintf(s, "Disabling incoming CB\n"); 3491 smprintf(s, "Disabling incoming CB\n");
3340 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB); 3492 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB);
3341 } 3493 }
3342 } 3494 }
3343 return ERR_NONE; 3495 return ERR_NONE;
3344#else 3496#else
3345 return ERR_SOURCENOTAVAILABLE; 3497 return ERR_SOURCENOTAVAILABLE;
3346#endif 3498#endif
3347} 3499}
3348 3500
3501GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3502{
3503 if (enable) {
3504 smprintf(s, "Enabling fast SMS sending\n");
3505 return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
3506 } else {
3507 smprintf(s, "Disabling fast SMS sending\n");
3508 return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
3509 }
3510}
3511
3349GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 3512GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
3350{ 3513{
3351 smprintf(s, "Incoming SMS\n"); 3514 smprintf(s, "Incoming SMS\n");
3352 return ERR_NONE; 3515 return ERR_NONE;
3353} 3516}
3354 3517
3355GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s) 3518GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s)
3356{ 3519{
3357 GSM_Phone_Data *Data = &s->Phone.Data; 3520 GSM_Phone_Data *Data = &s->Phone.Data;
3358 GSM_SMSMessage sms; 3521 GSM_SMSMessage sms;
3359 int current = 0, current2, i=0; 3522 int current = 0, current2, i=0;
3360 unsigned char buffer[300],smsframe[800]; 3523 unsigned char buffer[300],smsframe[800];
3361 3524
3362 smprintf(s, "Incoming SMS received (Deliver)\n"); 3525 smprintf(s, "Incoming SMS received (Deliver)\n");
3363 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) { 3526 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
3364 sms.State = SMS_UnRead; 3527 sms.State = SMS_UnRead;
3365 sms.InboxFolder = true; 3528 sms.InboxFolder = true;
3366 sms.PDU = SMS_Deliver; 3529 sms.PDU = SMS_Deliver;
3367 3530
3368 /* T310 with larger SMS goes crazy and mix this incoming 3531 /* T310 with larger SMS goes crazy and mix this incoming
3369 * frame with normal answers. PDU is always last frame 3532 * frame with normal answers. PDU is always last frame
3370 * We find its' number and parse it */ 3533 * We find its' number and parse it */
3371 while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) { 3534 while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) {
3372 /* FIXME: handle special chars correctly */ 3535 /* FIXME: handle special chars correctly */
3373 i++; 3536 i++;
3374 } 3537 }
3375 DecodeHexBin (buffer, 3538 DecodeHexBin (buffer,
3376 GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i), 3539 GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i),
3377 strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i))); 3540 strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i)));
3378 3541
3379 /* We use locations from SMS layouts like in ../phone2.c(h) */ 3542 /* We use locations from SMS layouts like in ../phone2.c(h) */
3380 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; 3543 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
3381 smsframe[12]=buffer[current++]; 3544 smsframe[12]=buffer[current++];
3382 3545
3383 current2=((buffer[current])+1)/2+1; 3546 current2=((buffer[current])+1)/2+1;
3384 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 3547 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
3385 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; 3548 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
3386 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; 3549 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
3387 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; 3550 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++];
3388 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; 3551 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++];
3389 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; 3552 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++];
3390 GSM_DecodeSMSFrame(&sms,smsframe,PHONE_SMSDeliver); 3553 GSM_DecodeSMSFrame(&sms,smsframe,PHONE_SMSDeliver);
3391 3554
3392 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 3555 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
3393 } 3556 }
3394 return ERR_NONE; 3557 return ERR_NONE;
3395} 3558}
3396 3559
3397/* I don't have phone able to do it and can't fill it */ 3560/* I don't have phone able to do it and can't fill it */
3398GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s) 3561GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s)
3399{ 3562{
3400 smprintf(s, "Incoming SMS received (Report)\n"); 3563 smprintf(s, "Incoming SMS received (Report)\n");
3401 return ERR_NONE; 3564 return ERR_NONE;
3402} 3565}
3403 3566
3404GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable) 3567GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
3405{ 3568{
3406 /* Nokia returns OK, but doesn't return anything */ 3569 /* Nokia returns OK, but doesn't return anything */
3407 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED; 3570 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED;
3408 3571
3409 if (s->Phone.Data.EnableIncomingSMS!=enable) { 3572 if (s->Phone.Data.EnableIncomingSMS!=enable) {
3410 s->Phone.Data.EnableIncomingSMS = enable; 3573 s->Phone.Data.EnableIncomingSMS = enable;
3411 if (enable) { 3574 if (enable) {
3412 smprintf(s, "Enabling incoming SMS\n"); 3575 smprintf(s, "Enabling incoming SMS\n");
3413 3576
3414 /* Delivery reports */ 3577 /* Delivery reports */
3415 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS); 3578 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS);
3416 3579
3417 /* SMS deliver */ 3580 /* SMS deliver */
3418 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS); 3581 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS);
3419 } else { 3582 } else {
3420 smprintf(s, "Disabling incoming SMS\n"); 3583 smprintf(s, "Disabling incoming SMS\n");
3421 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS); 3584 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS);
3422 } 3585 }
3423 } 3586 }
3424 return ERR_NONE; 3587 return ERR_NONE;
3425} 3588}
3426 3589
3590GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3591{
3592 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
3593 return ERR_NOTSUPPORTED;
3594}
3595
3596GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3597{
3598 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
3599 return ERR_NOTSUPPORTED;
3600}
3601
3427GSM_Reply_Function ATGENReplyFunctions[] = { 3602GSM_Reply_Function ATGENReplyFunctions[] = {
3428 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame }, 3603 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame },
3429 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho }, 3604 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho },
3430 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo }, 3605 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo },
3431 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey }, 3606 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey },
3432 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI }, 3607 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI },
3433 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX }, 3608 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX },
3434 3609
3610 {ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
3611 {ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
3612 {ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
3613 {ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
3614
3435#ifdef GSM_ENABLE_CELLBROADCAST 3615#ifdef GSM_ENABLE_CELLBROADCAST
3436 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame }, 3616 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame },
3437 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB }, 3617 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB },
3438#endif 3618#endif
3439 3619
3440 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame }, 3620 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame },
3441 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge }, 3621 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge },
3442 3622
3443 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel }, 3623 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel },
3444 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer }, 3624 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer },
3445 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware }, 3625 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware },
3446 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware }, 3626 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware },
3447 {ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI }, 3627 {ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI },
3448 3628
3449 {ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame }, 3629 {ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame },
3450 {ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame }, 3630 {ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame },
3451 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS }, 3631 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS },
3452 {ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode }, 3632 {ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode },
3453 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode }, 3633 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode },
3454 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage }, 3634 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage },
3455 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType }, 3635 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType },
3456 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus }, 3636 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus },
3457 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories }, 3637 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories },
3458 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage }, 3638 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage },
3459 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters }, 3639 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters },
3460 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC }, 3640 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC },
3461 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC }, 3641 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC },
3462 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage }, 3642 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage },
3463 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters }, 3643 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters },
3464 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters }, 3644 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters },
3645 {ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending },
3465 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame }, 3646 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
3466 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame }, 3647 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame },
3467 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame }, 3648 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame },
3468 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame }, 3649 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame },
3469 3650
3470 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime }, 3651 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime },
3471 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime }, 3652 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime },
3653 {ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm },
3472 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm }, 3654 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
3473 3655
3474 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo }, 3656 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo },
3475 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo }, 3657 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo },
3476 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo }, 3658 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo },
3477 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin}, 3659 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin},
3478 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo }, 3660 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo },
3479 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality }, 3661 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality },
3480 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame }, 3662 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame },
3481 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame }, 3663 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame },
3482 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame }, 3664 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame },
3483 3665
3484 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType }, 3666 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType },
3485 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType }, 3667 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType },
3486 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus }, 3668 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus },
3669// /* Samsung phones reply +CPBR: after OK --claudio*/
3487 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus }, 3670 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus },
3671 {ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus },
3488 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus }, 3672 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
3489 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset }, 3673 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset },
3490 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory }, 3674 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory },
3491 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory }, 3675 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
3492 {ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, 3676 {SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
3493 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory }, 3677 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
3494 3678
3495 {ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, 3679 {SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
3496 {ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, 3680 {SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
3497 3681
3498 {ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, 3682 {SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
3499 {ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, 3683 {SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
3500 3684
3501 {ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, 3685 {SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
3502 {ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, 3686 {SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
3503 {ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote }, 3687 {SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote },
3504 3688
3505 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode }, 3689 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode },
3506 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode }, 3690 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode },
3507 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus }, 3691 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus },
3508 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame }, 3692 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame },
3509 3693
3510 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF }, 3694 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF },
3511 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall }, 3695 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall },
3512 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice }, 3696 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice },
3513 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall }, 3697 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
3698 {ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
3699 {ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
3514 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame }, 3700 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
3515 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame }, 3701 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
3516 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame }, 3702 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame },
3517 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame }, 3703 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame },
3518 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame }, 3704 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame },
3519 3705
3520 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset }, 3706 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset },
3521 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset }, 3707 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset },
3522 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings }, 3708 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings },
3523 3709
3710 {SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
3711 {SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
3712
3713 {SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
3714 {SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
3715
3524#ifdef GSM_ENABLE_ALCATEL 3716#ifdef GSM_ENABLE_ALCATEL
3525/* Why do I give Alcatel specific things here? It's simple, Alcatel needs 3717/* Why do I give Alcatel specific things here? It's simple, Alcatel needs
3526 * some AT commands to start it's binary mode, so this needs to be in AT 3718 * some AT commands to start it's binary mode, so this needs to be in AT
3527 * related stuff. 3719 * related stuff.
3528 * 3720 *
3529 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel 3721 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel
3530 * specific and it's part of ETSI specifications 3722 * specific and it's part of ETSI specifications
3531 */ 3723 */
3532 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl }, 3724 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl },
3533 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol }, 3725 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol },
3534 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect }, 3726 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect },
3535#endif 3727#endif
3536 3728
3537 {NULL, "\x00" ,0x00,0x00,ID_None } 3729 {NULL, "\x00" ,0x00,0x00,ID_None }
3538}; 3730};
3539 3731
3540GSM_Phone_Functions ATGENPhone = { 3732GSM_Phone_Functions ATGENPhone = {
3541 "A2D|iPAQ|at|M20|S25|MC35|C35i|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210", 3733 "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210",
3542 ATGENReplyFunctions, 3734 ATGENReplyFunctions,
3543 ATGEN_Initialise, 3735 ATGEN_Initialise,
3544 ATGEN_Terminate, 3736 ATGEN_Terminate,
3545 ATGEN_DispatchMessage, 3737 ATGEN_DispatchMessage,
3546 NOTSUPPORTED, /* ShowStartInfo */ 3738 NOTSUPPORTED, /* ShowStartInfo */
3547 ATGEN_GetManufacturer, 3739 ATGEN_GetManufacturer,
3548 ATGEN_GetModel, 3740 ATGEN_GetModel,
3549 ATGEN_GetFirmware, 3741 ATGEN_GetFirmware,
3550 ATGEN_GetIMEI, 3742 ATGEN_GetIMEI,
3551 NOTSUPPORTED, /* GetOriginalIMEI */ 3743 NOTSUPPORTED, /* GetOriginalIMEI */
3552 NOTSUPPORTED, /* GetManufactureMonth*/ 3744 NOTSUPPORTED, /* GetManufactureMonth*/
3553 NOTSUPPORTED, /* GetProductCode */ 3745 NOTSUPPORTED, /* GetProductCode */
3554 NOTSUPPORTED, /* GetHardware */ 3746 NOTSUPPORTED, /* GetHardware */
3555 NOTSUPPORTED, /* GetPPM */ 3747 NOTSUPPORTED, /* GetPPM */
3556 ATGEN_GetSIMIMSI, 3748 ATGEN_GetSIMIMSI,
3557 ATGEN_GetDateTime, 3749 ATGEN_GetDateTime,
3558 ATGEN_SetDateTime, 3750 ATGEN_SetDateTime,
3559 ATGEN_GetAlarm, 3751 ATGEN_GetAlarm,
3560 NOTIMPLEMENTED, /* SetAlarm */ 3752 ATGEN_SetAlarm,
3561 NOTSUPPORTED, /* GetLocale */ 3753 ATGEN_GetLocale,
3562 NOTSUPPORTED, /* SetLocale */ 3754 ATGEN_SetLocale,
3563 ATGEN_PressKey, 3755 ATGEN_PressKey,
3564 ATGEN_Reset, 3756 ATGEN_Reset,
3565 ATGEN_ResetPhoneSettings, 3757 ATGEN_ResetPhoneSettings,
3566 ATGEN_EnterSecurityCode, 3758 ATGEN_EnterSecurityCode,
3567 ATGEN_GetSecurityStatus, 3759 ATGEN_GetSecurityStatus,
3568 ATGEN_GetDisplayStatus, 3760 ATGEN_GetDisplayStatus,
3569 ATGEN_SetAutoNetworkLogin, 3761 ATGEN_SetAutoNetworkLogin,
3570 ATGEN_GetBatteryCharge, 3762 ATGEN_GetBatteryCharge,
3571 ATGEN_GetSignalQuality, 3763 ATGEN_GetSignalQuality,
3572 ATGEN_GetNetworkInfo, 3764 ATGEN_GetNetworkInfo,
3573 NOTSUPPORTED, /* GetCategory */ 3765 NOTSUPPORTED, /* GetCategory */
3574 NOTSUPPORTED, /* AddCategory */ 3766 NOTSUPPORTED, /* AddCategory */
3575 NOTSUPPORTED, /* GetCategoryStatus */ 3767 NOTSUPPORTED, /* GetCategoryStatus */
3576 ATGEN_GetMemoryStatus, 3768 ATGEN_GetMemoryStatus,
3577 ATGEN_GetMemory, 3769 ATGEN_GetMemory,
3578 ATGEN_GetNextMemory, 3770 ATGEN_GetNextMemory,
3579 ATGEN_SetMemory, 3771 ATGEN_SetMemory,
3580 ATGEN_AddMemory, 3772 ATGEN_AddMemory,
3581 ATGEN_DeleteMemory, 3773 ATGEN_DeleteMemory,
3582 ATGEN_DeleteAllMemory, 3774 ATGEN_DeleteAllMemory,
3583 NOTSUPPORTED, /* GetSpeedDial */ 3775 NOTSUPPORTED, /* GetSpeedDial */
3584 NOTSUPPORTED, /* SetSpeedDial */ 3776 NOTSUPPORTED, /* SetSpeedDial */
3585 ATGEN_GetSMSC, 3777 ATGEN_GetSMSC,
3586 ATGEN_SetSMSC, 3778 ATGEN_SetSMSC,
3587 ATGEN_GetSMSStatus, 3779 ATGEN_GetSMSStatus,
3588 ATGEN_GetSMS, 3780 ATGEN_GetSMS,
3589 ATGEN_GetNextSMS, 3781 ATGEN_GetNextSMS,
3590 NOTSUPPORTED, /* SetSMS */ 3782 NOTSUPPORTED, /* SetSMS */
3591 ATGEN_AddSMS, 3783 ATGEN_AddSMS,
3592 ATGEN_DeleteSMS, 3784 ATGEN_DeleteSMS,
3593 ATGEN_SendSMS, 3785 ATGEN_SendSMS,
3594 ATGEN_SendSavedSMS, 3786 ATGEN_SendSavedSMS,
3787 ATGEN_SetFastSMSSending,
3595 ATGEN_SetIncomingSMS, 3788 ATGEN_SetIncomingSMS,
3596 ATGEN_SetIncomingCB, 3789 ATGEN_SetIncomingCB,
3597 ATGEN_GetSMSFolders, 3790 ATGEN_GetSMSFolders,
3598 NOTSUPPORTED, /* AddSMSFolder */ 3791 NOTSUPPORTED, /* AddSMSFolder */
3599 NOTSUPPORTED, /* DeleteSMSFolder */ 3792 NOTSUPPORTED, /* DeleteSMSFolder */
3600 ATGEN_DialVoice, 3793 ATGEN_DialVoice,
3601 ATGEN_AnswerCall, 3794 ATGEN_AnswerCall,
3602 ATGEN_CancelCall, 3795 ATGEN_CancelCall,
3603 NOTSUPPORTED, /* HoldCall */ 3796 NOTSUPPORTED, /* HoldCall */
3604 NOTSUPPORTED, /* UnholdCall */ 3797 NOTSUPPORTED, /* UnholdCall */
3605 NOTSUPPORTED, /* ConferenceCall */ 3798 NOTSUPPORTED, /* ConferenceCall */
3606 NOTSUPPORTED, /* SplitCall */ 3799 NOTSUPPORTED, /* SplitCall */
3607 NOTSUPPORTED, /* TransferCall */ 3800 NOTSUPPORTED, /* TransferCall */
3608 NOTSUPPORTED, /* SwitchCall */ 3801 NOTSUPPORTED, /* SwitchCall */
3609 NOTSUPPORTED, /* GetCallDivert */ 3802 NOTSUPPORTED, /* GetCallDivert */
3610 NOTSUPPORTED, /* SetCallDivert */ 3803 NOTSUPPORTED, /* SetCallDivert */
3611 NOTSUPPORTED, /* CancelAllDiverts*/ 3804 NOTSUPPORTED, /* CancelAllDiverts*/
3612 NONEFUNCTION, /* SetIncomingCall */ 3805 NONEFUNCTION, /* SetIncomingCall */
3613 NOTSUPPORTED, /* SetIncomingUSSD */ 3806 ATGEN_SetIncomingUSSD,
3614 ATGEN_SendDTMF, 3807 ATGEN_SendDTMF,
3615 ATGEN_GetRingtone, 3808 ATGEN_GetRingtone,
3616 ATGEN_SetRingtone, 3809 ATGEN_SetRingtone,
3617 NOTSUPPORTED, /* GetRingtonesInfo*/ 3810 NOTSUPPORTED, /* GetRingtonesInfo*/
3618 NOTSUPPORTED, /* DeleteUserRingtones*/ 3811 NOTSUPPORTED, /* DeleteUserRingtones*/
3619 NOTSUPPORTED, /* PlayTone */ 3812 NOTSUPPORTED, /* PlayTone */
3620 NOTSUPPORTED, /* GetWAPBookmark */ 3813 NOTSUPPORTED, /* GetWAPBookmark */
3621 NOTSUPPORTED, /* SetWAPBookmark */ 3814 NOTSUPPORTED, /* SetWAPBookmark */
3622 NOTSUPPORTED, /* DeleteWAPBookmark */ 3815 NOTSUPPORTED, /* DeleteWAPBookmark */
3623 NOTSUPPORTED, /* GetWAPSettings */ 3816 NOTSUPPORTED, /* GetWAPSettings */
3624 NOTSUPPORTED, /* SetWAPSettings */ 3817 NOTSUPPORTED, /* SetWAPSettings */
3625 NOTSUPPORTED, /* GetMMSSettings */ 3818 NOTSUPPORTED, /* GetMMSSettings */
3626 NOTSUPPORTED, /* SetMMSSettings */ 3819 NOTSUPPORTED, /* SetMMSSettings */
3627 NOTSUPPORTED, /* GetSyncMLSettings*/ 3820 NOTSUPPORTED, /* GetSyncMLSettings*/
3628 NOTSUPPORTED, /* SetSyncMLSettings*/ 3821 NOTSUPPORTED, /* SetSyncMLSettings*/
3629 NOTSUPPORTED, /* GetChatSettings */ 3822 NOTSUPPORTED, /* GetChatSettings */
3630 NOTSUPPORTED, /* SetChatSettings */ 3823 NOTSUPPORTED, /* SetChatSettings */
3631 ATGEN_GetBitmap, /* GetBitmap */ 3824 ATGEN_GetBitmap, /* GetBitmap */
3632 ATGEN_SetBitmap, /* SetBitmap */ 3825 ATGEN_SetBitmap, /* SetBitmap */
3633 SONYERIC_GetToDoStatus, 3826 SONYERIC_GetToDoStatus,
3634 NOTSUPPORTED, /* GetToDo */ 3827 NOTSUPPORTED, /* GetToDo */
3635 SONYERIC_GetNextToDo, 3828 SONYERIC_GetNextToDo,
3636 NOTSUPPORTED, /* SetToDo */ 3829 NOTSUPPORTED, /* SetToDo */
3637 SONYERIC_AddToDo, 3830 SONYERIC_AddToDo,
3638 NOTSUPPORTED, /* DeleteToDo */ 3831 NOTSUPPORTED, /* DeleteToDo */
3639 SONYERIC_DeleteAllToDo, 3832 SONYERIC_DeleteAllToDo,
3640 SONYERIC_GetCalendarStatus, 3833 SONYERIC_GetCalendarStatus,
3641 NOTIMPLEMENTED, /* GetCalendar */ 3834 NOTIMPLEMENTED, /* GetCalendar */
3642 ATGEN_GetNextCalendar, 3835 ATGEN_GetNextCalendar,
3643 NOTIMPLEMENTED, /* SetCalendar */ 3836 NOTIMPLEMENTED, /* SetCalendar */
3644 ATGEN_AddCalendarNote, 3837 ATGEN_AddCalendarNote,
3645 ATGEN_DelCalendarNote, 3838 ATGEN_DelCalendarNote,
3646 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/
3647 NOTSUPPORTED, /* GetCalendarSettings*/ 3840 NOTSUPPORTED, /* GetCalendarSettings*/
3648 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3649 NOTSUPPORTED, /* GetNote */ 3842 NOTSUPPORTED, /* GetNextNote */
3650 NOTSUPPORTED, /* GetProfile */ 3843 NOTSUPPORTED, /* GetProfile */
3651 NOTSUPPORTED, /* SetProfile */ 3844 NOTSUPPORTED, /* SetProfile */
3652 NOTSUPPORTED, /* GetFMStation */ 3845 NOTSUPPORTED, /* GetFMStation */
3653 NOTSUPPORTED, /* SetFMStation */ 3846 NOTSUPPORTED, /* SetFMStation */
3654 NOTSUPPORTED, /* ClearFMStations */ 3847 NOTSUPPORTED, /* ClearFMStations */
3655 NOTSUPPORTED, /* GetNextFileFolder*/ 3848 NOTSUPPORTED, /* GetNextFileFolder*/
3656 NOTSUPPORTED, /* GetFilePart */ 3849 NOTSUPPORTED, /* GetFilePart */
3657 NOTSUPPORTED, /* AddFile */ 3850 NOTSUPPORTED, /* AddFile */
3658 NOTSUPPORTED, /* GetFileSystemStatus*/ 3851 NOTSUPPORTED, /* GetFileSystemStatus*/
3659 NOTSUPPORTED, /* DeleteFile */ 3852 NOTSUPPORTED, /* DeleteFile */
3660 NOTSUPPORTED, /* AddFolder */ 3853 NOTSUPPORTED, /* AddFolder */
3661 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3854 NOTSUPPORTED, /* GetGPRSAccessPoint*/
3662 NOTSUPPORTED /* SetGPRSAccessPoint*/ 3855 NOTSUPPORTED /* SetGPRSAccessPoint*/
3663}; 3856};
3664 3857
3665#endif 3858#endif
3666 3859
3667/* How should editor hadle tabs in this file? Add editor commands here. 3860/* How should editor hadle tabs in this file? Add editor commands here.
3668 * vim: noexpandtab sw=8 ts=8 sts=8: 3861 * vim: noexpandtab sw=8 ts=8 sts=8:
3669 */ 3862 */
diff --git a/gammu/emb/common/phone/at/atgen.h b/gammu/emb/common/phone/at/atgen.h
index 0e08ee4..bb5c559 100644
--- a/gammu/emb/common/phone/at/atgen.h
+++ b/gammu/emb/common/phone/at/atgen.h
@@ -1,110 +1,116 @@
1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
2 2
3#ifndef atgen_h 3#ifndef atgen_h
4#define atgen_h 4#define atgen_h
5 5
6#include "../../gsmcomon.h" 6#include "../../gsmcomon.h"
7#include "../../gsmstate.h" 7#include "../../gsmstate.h"
8#include "../../service/sms/gsmsms.h" 8#include "../../service/sms/gsmsms.h"
9 9
10#ifndef GSM_USED_AT 10#ifndef GSM_USED_AT
11# define GSM_USED_AT 11# define GSM_USED_AT
12#endif 12#endif
13#ifndef GSM_USED_BLUEAT 13#ifndef GSM_USED_BLUEAT
14# define GSM_USED_BLUEAT 14# define GSM_USED_BLUEAT
15#endif 15#endif
16#ifndef GSM_USED_IRDAAT 16#ifndef GSM_USED_IRDAAT
17# define GSM_USED_IRDAAT 17# define GSM_USED_IRDAAT
18#endif 18#endif
19 19
20#define MAX_VCALENDAR_LOCATION 50 20#define MAX_VCALENDAR_LOCATION 50
21 21
22typedef enum { 22typedef enum {
23 SMS_AT_PDU = 1, 23 SMS_AT_PDU = 1,
24 SMS_AT_TXT 24 SMS_AT_TXT
25} GSM_AT_SMS_Modes; 25} GSM_AT_SMS_Modes;
26 26
27typedef enum { 27typedef enum {
28 AT_Reply_OK = 1, 28 AT_Reply_OK = 1,
29 AT_Reply_Connect, 29 AT_Reply_Connect,
30 AT_Reply_Error, 30 AT_Reply_Error,
31 AT_Reply_Unknown, 31 AT_Reply_Unknown,
32 AT_Reply_CMSError, 32 AT_Reply_CMSError,
33 AT_Reply_CMEError, 33 AT_Reply_CMEError,
34 AT_Reply_SMSEdit 34 AT_Reply_SMSEdit
35} GSM_AT_Reply_State; 35} GSM_AT_Reply_State;
36 36
37typedef enum { 37typedef enum {
38 AT_Nokia = 1, 38 AT_Nokia = 1,
39 AT_Alcatel, 39 AT_Alcatel,
40 AT_Siemens, 40 AT_Siemens,
41 AT_HP, 41 AT_HP,
42 AT_Falcom, 42 AT_Falcom,
43 AT_Ericsson, 43 AT_Ericsson,
44 AT_Sagem, 44 AT_Sagem,
45 AT_Samsung,
45 AT_Unknown 46 AT_Unknown
46} GSM_AT_Manufacturer; 47} GSM_AT_Manufacturer;
47 48
48typedef enum { 49typedef enum {
49 AT_PBK_HEX = 1, 50 AT_PBK_HEX = 1,
50 AT_PBK_GSM, 51 AT_PBK_GSM,
51 AT_PBK_UCS2 52 AT_PBK_UCS2,
53 AT_PBK_PCCP437
52} GSM_AT_PBK_Charset; 54} GSM_AT_PBK_Charset;
53 55
54typedef enum { 56typedef enum {
55 AT_AVAILABLE = 1, 57 AT_AVAILABLE = 1,
56 AT_NOTAVAILABLE 58 AT_NOTAVAILABLE
57} GSM_AT_SMSMemory; 59} GSM_AT_SMSMemory;
58 60
59typedef enum { 61typedef enum {
60 AT_SBNR_AVAILABLE = 1, 62 AT_SBNR_AVAILABLE = 1,
61 AT_SBNR_NOTAVAILABLE 63 AT_SBNR_NOTAVAILABLE
62} GSM_AT_SBNR; 64} GSM_AT_SBNR;
63 65
64typedef enum { 66typedef enum {
65 AT_Status, 67 AT_Status,
66 AT_NextEmpty, 68 AT_NextEmpty,
67 AT_Total, 69 AT_Total,
68 AT_First, 70 AT_First,
69 AT_Sizes 71 AT_Sizes
70} GSM_AT_NeededMemoryInfo; 72} GSM_AT_NeededMemoryInfo;
71 73
72 #define AT_PBK_MAX_MEMORIES200 74 #define AT_PBK_MAX_MEMORIES200
73 75
74typedef struct { 76typedef struct {
75 GSM_AT_Manufacturer Manufacturer; /* Who is manufacturer */ 77 GSM_AT_Manufacturer Manufacturer; /* Who is manufacturer */
76 GSM_Lines Lines; /* Allow to simply get each line in response */ 78 GSM_Lines Lines; /* Allow to simply get each line in response */
77 GSM_AT_Reply_State ReplyState; /* What response type - error, OK, etc. */ 79 GSM_AT_Reply_State ReplyState; /* What response type - error, OK, etc. */
78 int ErrorCode; /* Error codes from responses */ 80 int ErrorCode; /* Error codes from responses */
79 char *ErrorText; /* Error description */ 81 char *ErrorText; /* Error description */
80 82
81 GSM_MemoryType PBKMemory; /* Last read PBK memory */ 83 GSM_MemoryType PBKMemory; /* Last read PBK memory */
82 char PBKMemories[AT_PBK_MAX_MEMORIES + 1]; /* Supported by phone PBK memories */ 84 char PBKMemories[AT_PBK_MAX_MEMORIES + 1]; /* Supported by phone PBK memories */
83 int NextMemoryEntry; /* Next empty memory entry */ 85 int NextMemoryEntry; /* Next empty memory entry */
84 int FirstMemoryEntry; /* First memory entry to be read */ 86 int FirstMemoryEntry; /* First memory entry to be read */
85 GSM_AT_PBK_Charset PBKCharset; /* Last read PBK charset */ 87 GSM_AT_PBK_Charset PBKCharset; /* Last read PBK charset */
86 bool UCS2CharsetFailed; /* Whether setting of UCS2 charset has already failed */ 88 bool UCS2CharsetFailed; /* Whether setting of UCS2 charset has already failed */
87 bool NonUCS2CharsetFailed; /* Whether setting of non-UCS2 charset has already failed */ 89 bool NonUCS2CharsetFailed; /* Whether setting of non-UCS2 charset has already failed */
88 GSM_AT_SBNR PBKSBNR; 90 GSM_AT_SBNR PBKSBNR;
89 int NumberLength; 91 int NumberLength;
90 int TextLength; 92 int TextLength;
91 int MemorySize; 93 int MemorySize;
92 94
93 GSM_SMSMemoryStatusLastSMSStatus; 95 GSM_SMSMemoryStatusLastSMSStatus;
94 int LastSMSRead; 96 int LastSMSRead;
95 int FirstCalendarPos; 97 int FirstCalendarPos;
96 bool CanSaveSMS; 98 bool CanSaveSMS;
97 GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */ 99 GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */
98 GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */ 100 GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */
99 GSM_MemoryType SMSMemory; /* Last read SMS memory */ 101 GSM_MemoryType SMSMemory; /* Last read SMS memory */
100 GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */ 102 GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */
101 103
102 bool OBEX; 104 bool OBEX;
103 GSM_File file; 105 GSM_File file;
104} GSM_Phone_ATGENData; 106} GSM_Phone_ATGENData;
105 107
108 GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *);
109 GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *);
110 GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *);
111
106#endif 112#endif
107 113
108/* How should editor hadle tabs in this file? Add editor commands here. 114/* How should editor hadle tabs in this file? Add editor commands here.
109 * vim: noexpandtab sw=8 ts=8 sts=8: 115 * vim: noexpandtab sw=8 ts=8 sts=8:
110 */ 116 */
diff --git a/gammu/emb/common/phone/at/samsung.c b/gammu/emb/common/phone/at/samsung.c
new file mode 100644
index 0000000..55a42e5
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.c
@@ -0,0 +1,447 @@
1/* Samsung-specific functions
2 * Copyright (C) 2004 Claudio Matsuoka <cmatsuoka@gmail.com>
3 * Tested with S300 only!
4 */
5
6#include "../../gsmstate.h"
7
8#ifdef GSM_ENABLE_ATGEN
9
10#include <string.h>
11#include <time.h>
12#include <ctype.h>
13
14#include "../../misc/coding/coding.h"
15#include "../../gsmcomon.h"
16#include "../../service/sms/gsmsms.h"
17#include "../pfunc.h"
18
19#include "atgen.h"
20#include "samsung.h"
21
22/* Binary frame size */
23#define BLKSZ 1024
24
25struct ModelRes {
26 char *model;
27 int width;
28 int height;
29};
30
31static struct ModelRes modres[] = {
32 { "S100", 128, 128 },
33 { "S200", 128, 113 },
34 { "S300", 128, 97 },
35 { "S500", 128, 128 },
36 { "T100", 128, 128 },
37 { "E700", 128, 128 },
38 { NULL, 0, 0 }
39};
40
41/*
42 * CRC functions from the Granch SBNI12 Linux driver by
43 * Denis I. Timofeev <timofeev@granch.ru>
44 */
45static unsigned int crc32tab[] = {
46 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
47 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
48 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
49 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C,
50 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53,
51 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A,
52 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661,
53 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278,
54 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF,
55 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6,
56 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD,
57 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4,
58 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B,
59 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82,
60 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9,
61 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0,
62 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7,
63 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE,
64 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795,
65 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C,
66 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3,
67 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA,
68 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1,
69 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8,
70 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F,
71 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76,
72 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D,
73 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344,
74 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B,
75 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12,
76 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739,
77 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320,
78 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17,
79 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E,
80 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525,
81 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C,
82 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73,
83 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A,
84 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541,
85 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158,
86 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF,
87 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6,
88 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED,
89 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4,
90 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB,
91 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2,
92 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589,
93 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190,
94 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87,
95 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E,
96 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5,
97 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC,
98 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3,
99 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA,
100 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1,
101 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8,
102 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F,
103 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856,
104 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D,
105 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064,
106 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B,
107 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832,
108 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419,
109 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000
110};
111
112static unsigned int GetCRC(char *data, int size)
113{
114 unsigned int crc = 0;
115
116 while (size--)
117 crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
118
119 return crc;
120}
121
122/*
123 * Frame transfer
124 */
125
126static GSM_Error WaitFor(GSM_StateMachine *s, char *t, int ttl)
127{
128 char readbuf[100];
129 int n;
130 unsigned int sec;
131 GSM_DateTime Date;
132
133 GSM_GetCurrentDateTime (&Date);
134 sec = Date.Second;
135
136 n = s->Device.Functions->ReadDevice(s, readbuf, 80);
137 readbuf[n] = 0;
138 while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.Second) {
139 my_sleep(5000);
140 n = s->Device.Functions->ReadDevice(s, readbuf, 80);
141 readbuf[n] = 0;
142 GSM_GetCurrentDateTime (&Date);
143 }
144
145 return (sec + ttl) >= Date.Second ? ERR_NONE : ERR_TIMEOUT;
146}
147
148static GSM_Error SetSamsungFrame(GSM_StateMachine *s, unsigned char *buff, int size, GSM_Phone_RequestID id)
149{
150 GSM_Phone_Data *Phone = &s->Phone.Data;
151 GSM_Error error;
152 int i, count;
153
154 count = size / BLKSZ;
155
156 for (i = 0; i < count; i++) {
157 error = WaitFor(s, ">", 4);
158 if (error!=ERR_NONE) return error;
159
160 error = s->Protocol.Functions->WriteMessage(s,
161 buff + i * BLKSZ, BLKSZ, 0x00);
162 if (error!=ERR_NONE) return error;
163 }
164
165 error = WaitFor(s, ">", 4);
166 if (error!=ERR_NONE) return error;
167 error = s->Protocol.Functions->WriteMessage(s,
168 buff + i * BLKSZ, size%BLKSZ, 0x00);
169 if (error!=ERR_NONE) return error;
170
171 error = GSM_WaitFor(s, "", 0, 0x00, 4, id);
172 if (error!=ERR_NONE) return error;
173
174 return Phone->DispatchError;
175}
176
177/* Answer format for binary data transfer
178 *
179 * SDNDCRC = 0xa : RECEIVECRC = 0xcbf53a1c : BINSIZE = 5
180 * CRCERR
181 */
182static GSM_Error ReplySetSamsungFrame(GSM_Protocol_Message msg, GSM_StateMachine *s)
183{
184 unsigned long txcrc, rxcrc;
185 int binsize;
186 char *pos;
187
188 /* Parse SDNDCRC */
189 pos = strchr(msg.Buffer, '=');
190 if (!pos) return ERR_UNKNOWN;
191 pos++;
192 txcrc = strtoul(pos, NULL, 0);
193 smprintf(s, "Sent CRC : 0x%lx\n", txcrc);
194
195 /* Parse RECEIVECRC */
196 pos = strchr(pos, '=');
197 if (!pos) return ERR_UNKNOWN;
198 pos++;
199 rxcrc = strtoul(pos, NULL, 0);
200 smprintf(s, "Reveived CRC : 0x%lx\n", rxcrc);
201
202 /* Parse BINSIZE */
203 pos = strchr(pos, '=');
204 if (!pos) return ERR_UNKNOWN;
205 pos++;
206 binsize = strtoul(pos, NULL, 0);
207 smprintf(s, "Binary size : %d\n", binsize);
208
209 return txcrc == rxcrc ? ERR_NONE : ERR_WRONGCRC;
210}
211
212/*
213 * Bitmaps
214 */
215
216GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
217{
218 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
219 unsigned char buffer[32];
220 char *pos;
221 int location, count;
222
223 switch (Priv->ReplyState) {
224 case AT_Reply_OK:
225 smprintf(s, "Bitmap info received\n");
226 /* Parse +IMGR:location,name,0,0,0,0 */
227
228 /* Parse location */
229 pos = strchr(msg.Buffer, ':');
230 if (!pos) return ERR_UNKNOWN;
231 pos++;
232 location = atoi(pos);
233 smprintf(s, "Location : %d\n", location);
234
235 /* Parse name */
236 pos = strchr(pos, '"');
237 if (!pos) return ERR_UNKNOWN;
238 pos++;
239 for (count = 0; count < 31; count++) {
240 if (pos[count] == '"')
241 break;
242 buffer[count] = pos[count];
243 }
244 buffer[count] = 0;
245 smprintf(s, "Name : %s\n", buffer);
246 s->Phone.Data.Bitmap->Name = malloc((strlen(buffer) + 1) * 2);
247 if (s->Phone.Data.Bitmap->Name == NULL)
248 return ERR_MOREMEMORY;
249 EncodeUnicode(s->Phone.Data.Bitmap->Name, buffer, strlen(buffer));
250
251 s->Phone.Data.Bitmap->Location = location;
252
253 return ERR_NONE;
254 case AT_Reply_Error:
255 return ERR_UNKNOWN;
256 case AT_Reply_CMSError:
257 return ATGEN_HandleCMSError(s);
258 case AT_Reply_CMEError:
259 return ATGEN_HandleCMEError(s);
260 default:
261 return ERR_UNKNOWNRESPONSE;
262 }
263}
264
265GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
266{
267 smprintf(s, "Bitmap sent\n");
268 return ReplySetSamsungFrame(msg, s);
269}
270
271GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
272{
273 unsigned char req[100];
274
275 s->Phone.Data.Bitmap=Bitmap;
276 smprintf(s, "Getting bitmap\n");
277 sprintf(req, "AT+IMGR=%d\r", Bitmap->Location-1);
278 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
279}
280
281GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
282{
283 unsigned charreq[100];
284 unsigned longcrc;
285 GSM_Errorerror;
286 char name[50], *dot, *model;
287 GSM_Phone_Data *Data = &s->Phone.Data;
288 int i;
289
290 s->Phone.Data.Bitmap = Bitmap;
291 smprintf(s, "Setting bitmap\n");
292
293 if (Bitmap->Type != GSM_PictureBinary) {
294 smprintf(s, "Invalid picture type\n");
295 return ERR_INVALIDDATA;
296 }
297
298 if (Bitmap->BinaryPic.Type != PICTURE_GIF) {
299 smprintf(s, "Invalid binary picture type\n");
300 return ERR_INVALIDDATA;
301 }
302
303 /* Check if picture size matches phone model */
304 model = GetModelData(NULL,Data->Model,NULL)->model;
305 smprintf(s, "Checking picture size for %s\n", model);
306 for (i = 0; modres[i].model; i++) {
307 if (!strcmp(model, modres[i].model)) {
308 if (Bitmap->BitmapWidth != modres[i].width ||
309 Bitmap->BitmapHeight != modres[i].height) {
310 smprintf(s, "Model %s must use %d x %d picture size\n",
311 modres[i].model, modres[i].width,
312 modres[i].height);
313 return ERR_INVALIDDATA;
314 }
315 break;
316 }
317 }
318 if (modres[i].model == NULL) {
319 smprintf(s, "Model \"%s\" is not supported.\n", Data->Model);
320 return ERR_NOTSUPPORTED;
321 }
322
323 crc = GetCRC(Bitmap->BinaryPic.Buffer, Bitmap->BinaryPic.Length);
324
325 /* Remove extension from file name */
326 strncpy(name, DecodeUnicodeString(Bitmap->Name), 50);
327 if ((dot = strrchr(name, '.')) != NULL)
328 *dot = 0;
329
330 sprintf(req, "AT+IMGW=0,\"%s\",2,0,0,0,0,100,%d,%u\r", name,
331 Bitmap->BinaryPic.Length, (unsigned int)crc);
332
333 error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
334 if (error!=ERR_NONE) return error;
335
336 return SetSamsungFrame(s, Bitmap->BinaryPic.Buffer,
337 Bitmap->BinaryPic.Length, ID_SetBitmap);
338}
339
340/*
341 * Ringtones
342 */
343
344GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
345{
346 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
347 unsigned char buffer[32];
348 char *pos;
349 int location, length, count;
350
351 switch (Priv->ReplyState) {
352 case AT_Reply_OK:
353 smprintf(s, "Ringtone info received\n");
354 /* Parse +MELR:location,name,size */
355
356 /* Parse location */
357 pos = strchr(msg.Buffer, ':');
358 if (!pos) return ERR_UNKNOWN;
359 pos++;
360 location = atoi(pos);
361 smprintf(s, "Location : %d\n", location);
362
363 /* Parse name */
364 pos = strchr(pos, '"');
365 if (!pos) return ERR_UNKNOWN;
366 pos++;
367 /* Ringtone.Name size is 20 chars */
368 for (count = 0; count < 19; count++) {
369 if (pos[count] == '"')
370 break;
371 buffer[count] = pos[count];
372 }
373 buffer[count] = 0;
374 smprintf(s, "Name : %s\n", buffer);
375 EncodeUnicode(s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
376
377 /* Parse ringtone length */
378 pos = strchr(pos, ',');
379 if (!pos) return ERR_UNKNOWN;
380 pos++;
381 length = atoi(pos);
382 smprintf(s, "Length : %d\n", length);
383
384 /* S300 ringtones are always MMF */
385 s->Phone.Data.Ringtone->Format = RING_MMF;
386 s->Phone.Data.Ringtone->Location = location;
387 s->Phone.Data.Ringtone->BinaryTone.Length = length;
388
389 return ERR_NONE;
390 case AT_Reply_Error:
391 return ERR_UNKNOWN;
392 case AT_Reply_CMSError:
393 return ATGEN_HandleCMSError(s);
394 case AT_Reply_CMEError:
395 return ATGEN_HandleCMEError(s);
396 default:
397 return ERR_UNKNOWNRESPONSE;
398 }
399}
400
401GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
402{
403 unsigned char req[100];
404
405 s->Phone.Data.Ringtone = Ringtone;
406 smprintf(s, "Getting ringtone\n");
407 sprintf(req, "AT+MELR=%d\r", Ringtone->Location-1);
408 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
409}
410
411GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
412{
413 smprintf(s, "Ringtone sent\n");
414 return ReplySetSamsungFrame(msg, s);
415}
416
417GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
418{
419 unsigned charreq[100];
420 unsigned longcrc;
421 GSM_Errorerror;
422 char name[50], *dot;
423
424 s->Phone.Data.Ringtone = Ringtone;
425 smprintf(s, "Setting ringtone\n");
426
427 if (Ringtone->Format != RING_MMF) {
428 smprintf(s, "Not MMF ringtone\n");
429 return ERR_INVALIDDATA;
430 }
431
432 /* Remove extension from file name */
433 strncpy(name, DecodeUnicodeString(Ringtone->Name), 50);
434 if ((dot = strrchr(name, '.')) != NULL) *dot = 0;
435
436 crc = GetCRC(Ringtone->BinaryTone.Buffer, Ringtone->BinaryTone.Length);
437 sprintf(req, "AT+MELW=0,\"%s\",4,%d,%u\r", name,
438 Ringtone->BinaryTone.Length, (unsigned int)crc);
439
440 error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
441 if (error!=ERR_NONE) return error;
442
443 return SetSamsungFrame(s, Ringtone->BinaryTone.Buffer,
444 Ringtone->BinaryTone.Length, ID_SetRingtone);
445}
446
447#endif
diff --git a/gammu/emb/common/phone/at/samsung.h b/gammu/emb/common/phone/at/samsung.h
new file mode 100644
index 0000000..3b2947c
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.h
@@ -0,0 +1,16 @@
1#ifndef samsung_h
2#define samsung_h
3
4#include "../../gsmstate.h"
5
6 GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message, GSM_StateMachine *);
7 GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message, GSM_StateMachine *);
8 GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message, GSM_StateMachine *);
9 GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message, GSM_StateMachine *);
10 GSM_Error SAMSUNG_GetRingtone (GSM_StateMachine *, GSM_Ringtone *, bool);
11 GSM_Error SAMSUNG_SetRingtone (GSM_StateMachine *, GSM_Ringtone *, int *);
12 GSM_Error SAMSUNG_GetBitmap (GSM_StateMachine *, GSM_Bitmap *);
13 GSM_Error SAMSUNG_SetBitmap (GSM_StateMachine *, GSM_Bitmap *);
14 GSM_Error SAMSUNG_GetCallLogs (GSM_StateMachine *, GSM_MemoryEntry *, int);
15
16#endif
diff --git a/gammu/emb/common/phone/at/siemens.c b/gammu/emb/common/phone/at/siemens.c
index ab7dd2c..7f66cf8 100644
--- a/gammu/emb/common/phone/at/siemens.c
+++ b/gammu/emb/common/phone/at/siemens.c
@@ -1,320 +1,316 @@
1/* (c) 2002-2003 by Walek */ 1/* (c) 2002-2003 by Walek */
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../misc/coding/coding.h" 11#include "../../misc/coding/coding.h"
12#include "../../gsmcomon.h" 12#include "../../gsmcomon.h"
13#include "../../service/sms/gsmsms.h" 13#include "../../service/sms/gsmsms.h"
14#include "../pfunc.h" 14#include "../pfunc.h"
15 15
16extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s); 16#include "atgen.h"
17#include "siemens.h"
17 18
18GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
19{
20 if (s->Protocol.Data.AT.EditMode) {
21 s->Protocol.Data.AT.EditMode = false;
22 return ERR_NONE;
23 }
24 dbgprintf ("Written %s",function);
25 if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
26 dbgprintf (" - OK\n");
27 return ERR_NONE;
28 } else {
29 dbgprintf (" - error\n");
30 return ERR_UNKNOWN;
31 }
32}
33 19
34GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, 20static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
35 unsigned char *buffer, int *len) 21 unsigned char *buffer, int *len)
36{ 22{
37 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 23 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
38 int i=2, pos=0, length=0; 24 int i=2, pos=0, length=0;
39 unsigned char buf[512]; 25 unsigned char buf[512];
40 26
41 if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY; 27 if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY;
42 if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN; 28 if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN;
43 29
44 while (1) { 30 while (1) {
45 if (Priv->Lines.numbers[i*2+1]==0) break; 31 if (Priv->Lines.numbers[i*2+1]==0) break;
46 if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) && 32 if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) &&
47 (strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){ 33 (strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){
48 length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)); 34 length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1));
49 DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length); 35 DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length);
50 length = length/2; 36 length = length/2;
51 memcpy (buffer+pos,buf,length); 37 memcpy (buffer+pos,buf,length);
52 pos+=length; 38 pos+=length;
53 } 39 }
54 i++; 40 i++;
55 } 41 }
56 *len = pos; 42 *len = pos;
57 return ERR_NONE; 43 return ERR_NONE;
58} 44}
59 45
60GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, 46static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
61 int Location, GSM_Phone_RequestID RequestID, int len) 47 int Location, GSM_Phone_RequestID RequestID, int len)
62{ 48{
63 GSM_Phone_Data *Phone = &s->Phone.Data; 49 GSM_Phone_Data *Phone = &s->Phone.Data;
64 GSM_Error error; 50 GSM_Error error;
65 unsigned char req[20],req1[512],hexreq[2096]; 51 unsigned char req[20],req1[512],hexreq[2096];
66 int MaxFrame,CurrentFrame,size,sz,pos=0; 52 int MaxFrame,CurrentFrame,size,sz,pos=0;
67 53
68 EncodeHexBin(hexreq,buff,len); 54 EncodeHexBin(hexreq,buff,len);
69 size = len * 2; 55 size = len * 2;
70 MaxFrame = size / 352; 56 MaxFrame = size / 352;
71 if (size % 352) MaxFrame++; 57 if (size % 352) MaxFrame++;
72 58
73 for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) { 59 for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) {
74 pos=CurrentFrame*352; 60 pos=CurrentFrame*352;
75 if (pos+352 < size) sz = 352; else sz = size - pos; 61 if (pos+352 < size) sz = 352; else sz = size - pos;
76 sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame); 62 sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame);
77 s->Protocol.Data.AT.EditMode = true; 63 s->Protocol.Data.AT.EditMode = true;
78 error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID); 64 error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID);
79 s->Phone.Data.DispatchError=ERR_TIMEOUT; 65 s->Phone.Data.DispatchError=ERR_TIMEOUT;
80 s->Phone.Data.RequestID=RequestID; 66 s->Phone.Data.RequestID=RequestID;
81 if (error!=ERR_NONE) return error; 67 if (error!=ERR_NONE) return error;
82 memcpy (req1,hexreq+pos,sz); 68 memcpy (req1,hexreq+pos,sz);
83 error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00); 69 error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00);
84 if (error!=ERR_NONE) return error; 70 if (error!=ERR_NONE) return error;
85 error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00); 71 error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00);
86 if (error!=ERR_NONE) return error; 72 if (error!=ERR_NONE) return error;
87 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); 73 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4);
88 if (error == ERR_TIMEOUT) return error; 74 if (error == ERR_TIMEOUT) return error;
89 } 75 }
90 return Phone->DispatchError; 76 return Phone->DispatchError;
91} 77}
92 78
93GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) 79GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
94{ 80{
95 unsigned char buffer[4096]; 81 unsigned char buffer[4096];
96 int length; 82 int length;
97 GSM_Error error; 83 GSM_Error error;
98 84
99 error = GetSiemensFrame(msg,s,"bmp",buffer,&length); 85 error = GetSiemensFrame(msg,s,"bmp",buffer,&length);
100 if (error!=ERR_NONE) return error; 86 if (error!=ERR_NONE) return error;
101 dbgprintf ("Operator logo received lenght=%i\n",length); 87 dbgprintf ("Operator logo received lenght=%i\n",length);
102 error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap); 88 error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap);
103 if (error==ERR_NONE) return error; 89 if (error==ERR_NONE) return error;
104 else return ERR_UNKNOWN; 90 else return ERR_UNKNOWN;
105} 91}
106 92
107GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) 93GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
108{ 94{
109 return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo"); 95 if (s->Protocol.Data.AT.EditMode) {
96 s->Protocol.Data.AT.EditMode = false;
97 return ERR_NONE;
98 }
99 dbgprintf ("Written %s",function);
100 if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
101 dbgprintf (" - OK\n");
102 return ERR_NONE;
103 } else {
104 dbgprintf (" - error\n");
105 return ERR_UNKNOWN;
106 }
110} 107}
111 108
112GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 109GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
110{
111 return SIEMENS_ReplySetFunction (msg, s, "Operator Logo");
112}
113
114GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
113{ 115{
114 unsigned char req[32]; 116 unsigned char req[32];
115 117
116 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
117 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; 118 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
118 if (Bitmap->Location-1 < 0) Bitmap->Location++; 119 if (Bitmap->Location-1 < 0) Bitmap->Location++;
119 s->Phone.Data.Bitmap=Bitmap; 120 s->Phone.Data.Bitmap=Bitmap;
120 sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1); 121 sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1);
121 smprintf(s, "Getting Bitmap\n"); 122 smprintf(s, "Getting Bitmap\n");
122 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); 123 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
123} 124}
124 125
125GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 126GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
126{ 127{
127 unsigned char buffer[4096]; 128 unsigned char buffer[4096];
128 int length; 129 int length;
129 GSM_Errorerror; 130 GSM_Errorerror;
130 131
131 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
132 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; 132 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
133 133
134 error = Bitmap2BMP (buffer,NULL,Bitmap); 134 error = Bitmap2BMP (buffer,NULL,Bitmap);
135 if (error!=ERR_NONE) return error; 135 if (error!=ERR_NONE) return error;
136 length = 0x100 * buffer[3] + buffer[2]; 136 length = 0x100 * buffer[3] + buffer[2];
137 buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff; 137 buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff;
138 if (Bitmap->Location-1 < 0) Bitmap->Location++; 138 if (Bitmap->Location-1 < 0) Bitmap->Location++;
139 s->Phone.Data.Bitmap=Bitmap; 139 s->Phone.Data.Bitmap=Bitmap;
140 return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1, 140 return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1,
141 ID_SetBitmap,length); 141 ID_SetBitmap,length);
142} 142}
143 143
144GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 144GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
145{ 145{
146 unsigned char buffer[32]; 146 unsigned char buffer[32];
147 int length; 147 int length;
148 GSM_Error error; 148 GSM_Error error;
149 149
150 error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length); 150 error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length);
151 if (error!=ERR_NONE) return error; 151 if (error!=ERR_NONE) return error;
152 dbgprintf ("Midi ringtone received\n"); 152 dbgprintf ("Midi ringtone received\n");
153 153
154 s->Phone.Data.Ringtone->Format = RING_MIDI; 154 s->Phone.Data.Ringtone->Format = RING_MIDI;
155 s->Phone.Data.Ringtone->NokiaBinary.Length= length; 155 s->Phone.Data.Ringtone->NokiaBinary.Length= length;
156 sprintf(buffer,"Individual"); 156 sprintf(buffer,"Individual");
157 EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); 157 EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
158 return ERR_NONE; 158 return ERR_NONE;
159} 159}
160 160
161GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 161GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
162{ 162{
163 unsigned char req[32]; 163 unsigned char req[32];
164 164
165 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
166
167 s->Phone.Data.Ringtone=Ringtone; 165 s->Phone.Data.Ringtone=Ringtone;
168 sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1); 166 sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1);
169 smprintf(s, "Getting RingTone\n"); 167 smprintf(s, "Getting RingTone\n");
170 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); 168 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
171} 169}
172 170
173GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 171GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
174{ 172{
175 return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone"); 173 return SIEMENS_ReplySetFunction (msg, s, "Ringtone");
176} 174}
177 175
178GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) 176GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
179{ 177{
180 GSM_Phone_Data *Phone = &s->Phone.Data; 178 GSM_Phone_Data *Phone = &s->Phone.Data;
181 179
182 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
183
184 if (Ringtone->Location==255) Ringtone->Location=1; 180 if (Ringtone->Location==255) Ringtone->Location=1;
185 if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION; 181 if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION;
186 182
187 s->Phone.Data.Ringtone= Ringtone; 183 s->Phone.Data.Ringtone= Ringtone;
188 Phone->Ringtone = Ringtone; 184 Phone->Ringtone = Ringtone;
189 return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1, 185 return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1,
190 ID_SetRingtone,Ringtone->NokiaBinary.Length); 186 ID_SetRingtone,Ringtone->NokiaBinary.Length);
191} 187}
192 188
193GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s) 189GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
194{ 190{
195 GSM_Phone_Data *Data = &s->Phone.Data; 191 GSM_Phone_Data *Data = &s->Phone.Data;
196 GSM_CalendarEntry*Calendar = Data->Cal; 192 GSM_CalendarEntry*Calendar = Data->Cal;
197 GSM_ToDoEntry ToDo; 193 GSM_ToDoEntry ToDo;
198 GSM_Error error; 194 GSM_Error error;
199 unsigned char buffer[354]; 195 unsigned char buffer[354];
200 int len, pos=0; 196 int len, pos=0;
201 197
202 if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN; 198 if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN;
203 199
204 error = GetSiemensFrame(msg,s,"vcs",buffer,&len); 200 error = GetSiemensFrame(msg,s,"vcs",buffer,&len);
205 if (error!=ERR_NONE) return error; 201 if (error!=ERR_NONE) return error;
206 error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0); 202 error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0);
207 203
208 return error; 204 return error;
209} 205}
210 206
211GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 207GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
212{ 208{
213 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 209 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
214 GSM_Error error; 210 GSM_Error error;
215 unsigned char req[32]; 211 unsigned char req[32];
216 int Location; 212 int Location;
217 213
218 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; 214 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
219 215
220 if (start) Note->Location=Priv->FirstCalendarPos; 216 if (start) Note->Location=Priv->FirstCalendarPos;
221 s->Phone.Data.Cal = Note; 217 s->Phone.Data.Cal = Note;
222 Note->EntriesNum = 0; 218 Note->EntriesNum = 0;
223 smprintf(s, "Getting VCALENDAR\n"); 219 smprintf(s, "Getting VCALENDAR\n");
224 Location = Note->Location; 220 Location = Note->Location;
225 while (1){ 221 while (1){
226 Location++; 222 Location++;
227 sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location); 223 sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location);
228 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote); 224 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote);
229 if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION; 225 if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION;
230 Note->Location = Location; 226 Note->Location = Location;
231 Priv->FirstCalendarPos = Location; 227 Priv->FirstCalendarPos = Location;
232 if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY; 228 if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY;
233 if (error==ERR_NONE) return error; 229 if (error==ERR_NONE) return error;
234 } 230 }
235 return error; 231 return error;
236} 232}
237 233
238GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) 234GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
239{ 235{
240 return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note"); 236 return SIEMENS_ReplySetFunction (msg, s, "Calendar Note");
241} 237}
242 238
243GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) 239GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
244{ 240{
245 GSM_Phone_Data *Data = &s->Phone.Data; 241 GSM_Phone_Data *Data = &s->Phone.Data;
246 242
247 if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN; 243 if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN;
248 244
249 if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) { 245 if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) {
250 smprintf(s, "Calendar note deleted\n"); 246 smprintf(s, "Calendar note deleted\n");
251 return ERR_NONE; 247 return ERR_NONE;
252 } else { 248 } else {
253 smprintf(s, "Can't delete calendar note\n"); 249 smprintf(s, "Can't delete calendar note\n");
254 return ERR_UNKNOWN; 250 return ERR_UNKNOWN;
255 } 251 }
256} 252}
257 253
258GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 254GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
259{ 255{
260 unsigned char req[32]; 256 unsigned char req[32];
261 257
262 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; 258 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
263 s->Phone.Data.Cal = Note; 259 s->Phone.Data.Cal = Note;
264 sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location); 260 sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location);
265 smprintf(s, "Deleting calendar note\n"); 261 smprintf(s, "Deleting calendar note\n");
266 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote); 262 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote);
267} 263}
268 264
269GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 265GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
270{ 266{
271 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 267 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
272 GSM_Error error; 268 GSM_Error error;
273 unsigned char req[500]; 269 unsigned char req[500];
274 int size=0; 270 int size=0;
275 271
276 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; 272 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
277 // if (Note->Location==0x00) return ERR_INVALIDLOCATION; 273 // if (Note->Location==0x00) return ERR_INVALIDLOCATION;
278 274
279 s->Phone.Data.Cal = Note; 275 s->Phone.Data.Cal = Note;
280 error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar); 276 error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar);
281 277
282 return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size); 278 return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size);
283} 279}
284 280
285/* (c) by Timo Teras */ 281/* (c) by Timo Teras */
286GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 282GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
287{ 283{
288#ifndef ENABLE_LGPL 284#ifndef ENABLE_LGPL
289 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 285 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
290 GSM_MemoryEntry *Memory = s->Phone.Data.Memory; 286 GSM_MemoryEntry *Memory = s->Phone.Data.Memory;
291 unsigned char buffer[500],buffer2[500]; 287 unsigned char buffer[500],buffer2[500];
292 288
293 switch (Priv->ReplyState) { 289 switch (Priv->ReplyState) {
294 case AT_Reply_OK: 290 case AT_Reply_OK:
295 smprintf(s, "Phonebook entry received\n"); 291 smprintf(s, "Phonebook entry received\n");
296 CopyLineString(buffer, msg.Buffer, Priv->Lines, 3); 292 CopyLineString(buffer, msg.Buffer, Priv->Lines, 3);
297 DecodeHexBin(buffer2,buffer,strlen(buffer)); 293 DecodeHexBin(buffer2,buffer,strlen(buffer));
298 Memory->EntriesNum = 0; 294 Memory->EntriesNum = 0;
299 DecodeVCARD21Text(buffer2, Memory); 295 DecodeVCARD21Text(buffer2, Memory);
300 if (Memory->EntriesNum == 0) return ERR_EMPTY; 296 if (Memory->EntriesNum == 0) return ERR_EMPTY;
301 return ERR_NONE; 297 return ERR_NONE;
302 case AT_Reply_Error: 298 case AT_Reply_Error:
303 smprintf(s, "Error - too high location ?\n"); 299 smprintf(s, "Error - too high location ?\n");
304 return ERR_INVALIDLOCATION; 300 return ERR_INVALIDLOCATION;
305 case AT_Reply_CMSError: 301 case AT_Reply_CMSError:
306 return ATGEN_HandleCMSError(s); 302 return ATGEN_HandleCMSError(s);
307 default: 303 default:
308 break; 304 break;
309 } 305 }
310 return ERR_UNKNOWNRESPONSE; 306 return ERR_UNKNOWNRESPONSE;
311#else 307#else
312 return ERR_NOTIMPLEMENTED; 308 return ERR_NOTIMPLEMENTED;
313#endif 309#endif
314} 310}
315 311
316#endif 312#endif
317 313
318/* How should editor hadle tabs in this file? Add editor commands here. 314/* How should editor hadle tabs in this file? Add editor commands here.
319 * vim: noexpandtab sw=8 ts=8 sts=8: 315 * vim: noexpandtab sw=8 ts=8 sts=8:
320 */ 316 */
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 4b2670a..8eeb39b 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -1,72 +1,70 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13 13
14 extern GSM_Reply_Function ATGENReplyFunctions[]; 14#include "atgen.h"
15 extern GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s); 15#include "sonyeric.h"
16 16
17#ifdef GSM_ENABLE_OBEXGEN 17#ifdef GSM_ENABLE_OBEXGEN
18 18
19 extern GSM_Reply_Function OBEXGENReplyFunctions[]; 19#include "../obex/obexgen.h"
20 extern GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File);
21 extern GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos);
22 extern GSM_Error OBEXGEN_Disconnect(GSM_StateMachine *s);
23 20
24#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 21 extern GSM_Reply_FunctionOBEXGENReplyFunctions[];
22 extern GSM_Reply_FunctionATGENReplyFunctions[];
25 23
26static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) 24static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
27{ 25{
28 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 26 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
29 GSM_Error error; 27 GSM_Error error;
30 28
31 if (Priv->OBEX) return ERR_NONE; 29 if (Priv->OBEX) return ERR_NONE;
32 30
33 dbgprintf ("Changing to OBEX\n"); 31 dbgprintf ("Changing to OBEX\n");
34 32
35 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX); 33 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
36 if (error != ERR_NONE) return error; 34 if (error != ERR_NONE) return error;
37 35
38 error = s->Protocol.Functions->Terminate(s); 36 error = s->Protocol.Functions->Terminate(s);
39 if (error != ERR_NONE) return error; 37 if (error != ERR_NONE) return error;
40 38
41 s->Protocol.Functions = &OBEXProtocol; 39 s->Protocol.Functions = &OBEXProtocol;
42 error = s->Protocol.Functions->Initialise(s); 40 error = s->Protocol.Functions->Initialise(s);
43 if (error != ERR_NONE) { 41 if (error != ERR_NONE) {
44 s->Protocol.Functions = &ATProtocol; 42 s->Protocol.Functions = &ATProtocol;
45 return error; 43 return error;
46 } 44 }
47 strcpy(s->CurrentConfig->Model,"seobex"); 45 strcpy(s->CurrentConfig->Model,"seobex");
48 s->Phone.Data.Priv.OBEXGEN.Service = 0; 46 s->Phone.Data.Priv.OBEXGEN.Service = 0;
49 s->Phone.Functions->DispatchMessage= GSM_DispatchMessage; 47 s->Phone.Functions->DispatchMessage= GSM_DispatchMessage;
50 s->Phone.Functions->ReplyFunctions= OBEXGENReplyFunctions; 48 s->Phone.Functions->ReplyFunctions= OBEXGENReplyFunctions;
51 Priv->OBEX = true; 49 Priv->OBEX = true;
52 return ERR_NONE; 50 return ERR_NONE;
53} 51}
54 52
55static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s) 53static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
56{ 54{
57 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 55 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
58 GSM_Error error; 56 GSM_Error error;
59 57
60 if (!Priv->OBEX) return ERR_NONE; 58 if (!Priv->OBEX) return ERR_NONE;
61 59
62 dbgprintf ("Changing to AT\n"); 60 dbgprintf ("Changing to AT\n");
63 61
64 error = OBEXGEN_Disconnect(s); 62 error = OBEXGEN_Disconnect(s);
65 if (error != ERR_NONE) return error; 63 if (error != ERR_NONE) return error;
66 64
67 error = s->Protocol.Functions->Terminate(s); 65 error = s->Protocol.Functions->Terminate(s);
68 if (error != ERR_NONE) return error; 66 if (error != ERR_NONE) return error;
69 67
70 s->Protocol.Functions = &ATProtocol; 68 s->Protocol.Functions = &ATProtocol;
71 error = s->Protocol.Functions->Initialise(s); 69 error = s->Protocol.Functions->Initialise(s);
72 if (error != ERR_NONE) { 70 if (error != ERR_NONE) {
@@ -81,331 +79,442 @@ static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
81} 79}
82 80
83static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName) 81static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName)
84{ 82{
85 GSM_Error error; 83 GSM_Error error;
86 84
87 strcpy(File->ID_FullName,FileName); 85 strcpy(File->ID_FullName,FileName);
88 File->Used = 0; 86 File->Used = 0;
89 if (File->Buffer != NULL) free(File->Buffer); 87 if (File->Buffer != NULL) free(File->Buffer);
90 File->Buffer = NULL; 88 File->Buffer = NULL;
91 89
92 error = SONYERIC_SetOBEXMode(s); 90 error = SONYERIC_SetOBEXMode(s);
93 if (error != ERR_NONE) return error; 91 if (error != ERR_NONE) return error;
94 92
95 error = ERR_NONE; 93 error = ERR_NONE;
96 while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File); 94 while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File);
97 if (error != ERR_EMPTY) return error; 95 if (error != ERR_EMPTY) return error;
98 96
99 return SONYERIC_SetATMode(s); 97 return SONYERIC_SetATMode(s);
100} 98}
101 99
102static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length) 100static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length)
103{ 101{
104 GSM_Errorerror; 102 GSM_Errorerror;
105 GSM_File File; 103 GSM_File File;
106 int Pos = 0; 104 int Pos = 0;
107 105
108 error = SONYERIC_SetOBEXMode(s); 106 error = SONYERIC_SetOBEXMode(s);
109 if (error != ERR_NONE) return error; 107 if (error != ERR_NONE) return error;
110 108
111 strcpy(File.ID_FullName,FileName); 109 strcpy(File.ID_FullName,FileName);
112 EncodeUnicode(File.Name,FileName,strlen(FileName)); 110 EncodeUnicode(File.Name,FileName,strlen(FileName));
113 File.Used = Length; 111 File.Used = Length;
114 File.Buffer = malloc(Length); 112 File.Buffer = malloc(Length);
115 memcpy(File.Buffer,Buffer,Length); 113 memcpy(File.Buffer,Buffer,Length);
116 114
117 error = ERR_NONE; 115 error = ERR_NONE;
118 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos); 116 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
119 free(File.Buffer); 117 free(File.Buffer);
120 if (error != ERR_EMPTY) return error; 118 if (error != ERR_EMPTY) return error;
121 119
122 return SONYERIC_SetATMode(s); 120 return SONYERIC_SetATMode(s);
123} 121}
124 122
125#endif 123#endif
126 124
127GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 125GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
128{ 126{
129#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 127#ifdef GSM_ENABLE_OBEXGEN
130 GSM_Error error; 128 GSM_Error error;
131 GSM_ToDoEntry ToDo; 129 GSM_ToDoEntry ToDo;
132 int Pos, num, Loc; 130 int Pos, num, Loc;
133 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 131 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
134 132
135 if (start) { 133 if (start) {
136 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 134 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
137 if (error != ERR_NONE) return error; 135 if (error != ERR_NONE) return error;
138 136
139 Note->Location = 1; 137 Note->Location = 1;
140 } else { 138 } else {
141 Note->Location++; 139 Note->Location++;
142 } 140 }
143 smprintf(s, "Getting calendar note %i\n",Note->Location); 141 smprintf(s, "Getting calendar note %i\n",Note->Location);
144 142
145 Loc = Note->Location; 143 Loc = Note->Location;
146 Pos = 0; 144 Pos = 0;
147 num = 0; 145 num = 0;
148 while (1) { 146 while (1) {
149 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 147 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
150 if (error == ERR_EMPTY) break; 148 if (error == ERR_EMPTY) break;
151 if (error != ERR_NONE) return error; 149 if (error != ERR_NONE) return error;
152 if (Note->EntriesNum != 0) { 150 if (Note->EntriesNum != 0) {
153 num++; 151 num++;
154 if (num == Loc) return ERR_NONE; 152 if (num == Loc) return ERR_NONE;
155 } 153 }
156 } 154 }
157 return ERR_EMPTY; 155 return ERR_EMPTY;
158#else 156#else
159 return ERR_SOURCENOTAVAILABLE; 157 return ERR_SOURCENOTAVAILABLE;
160#endif 158#endif
161} 159}
162 160
163GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 161GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
164{ 162{
165#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 163#ifdef GSM_ENABLE_OBEXGEN
166 GSM_Error error; 164 GSM_Error error;
167 GSM_CalendarEntryCalendar; 165 GSM_CalendarEntryCalendar;
168 int Pos, num, Loc; 166 int Pos, num, Loc;
169 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 167 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
170 168
171 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 169 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
172 170
173 if (start) { 171 if (start) {
174 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 172 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
175 if (error != ERR_NONE) return error; 173 if (error != ERR_NONE) return error;
176 174
177 ToDo->Location = 1; 175 ToDo->Location = 1;
178 } else { 176 } else {
179 ToDo->Location++; 177 ToDo->Location++;
180 } 178 }
181 smprintf(s,"Getting ToDo %i\n",ToDo->Location); 179 smprintf(s,"Getting ToDo %i\n",ToDo->Location);
182 180
183 Loc = ToDo->Location; 181 Loc = ToDo->Location;
184 Pos = 0; 182 Pos = 0;
185 num = 0; 183 num = 0;
186 while (1) { 184 while (1) {
187 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 185 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
188 if (error == ERR_EMPTY) break; 186 if (error == ERR_EMPTY) break;
189 if (error != ERR_NONE) return error; 187 if (error != ERR_NONE) return error;
190 if (ToDo->EntriesNum != 0) { 188 if (ToDo->EntriesNum != 0) {
191 num++; 189 num++;
192 if (num == Loc) return ERR_NONE; 190 if (num == Loc) return ERR_NONE;
193 } 191 }
194 } 192 }
195 193
196 return ERR_EMPTY; 194 return ERR_EMPTY;
197#else 195#else
198 return ERR_SOURCENOTAVAILABLE; 196 return ERR_SOURCENOTAVAILABLE;
199#endif 197#endif
200} 198}
201 199
202GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 200GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
203{ 201{
204#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 202#ifdef GSM_ENABLE_OBEXGEN
205 GSM_Error error; 203 GSM_Error error;
206 GSM_ToDoEntry ToDo; 204 GSM_ToDoEntry ToDo;
207 GSM_CalendarEntry Calendar; 205 GSM_CalendarEntry Calendar;
208 int Pos; 206 int Pos;
209 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 207 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
210 208
211 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 209 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
212 210
213 smprintf(s,"Getting ToDo status\n"); 211 smprintf(s,"Getting ToDo status\n");
214 212
215 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 213 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
216 if (error != ERR_NONE) return error; 214 if (error != ERR_NONE) return error;
217 215
218 status->Used = 0; 216 status->Used = 0;
219 Pos = 0; 217 Pos = 0;
220 while (1) { 218 while (1) {
221 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 219 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
222 if (error == ERR_EMPTY) break; 220 if (error == ERR_EMPTY) break;
223 if (error != ERR_NONE) return error; 221 if (error != ERR_NONE) return error;
224 if (ToDo.EntriesNum != 0) status->Used++; 222 if (ToDo.EntriesNum != 0) status->Used++;
225 } 223 }
226 224
227 return ERR_NONE; 225 return ERR_NONE;
228#else 226#else
229 return ERR_SOURCENOTAVAILABLE; 227 return ERR_SOURCENOTAVAILABLE;
230#endif 228#endif
231} 229}
232 230
233GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 231GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
234{ 232{
235#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 233#ifdef GSM_ENABLE_OBEXGEN
236 unsigned char req[5000]; 234 unsigned char req[5000];
237 int size=0; 235 int size=0;
238 236
239 smprintf(s,"Adding calendar note\n"); 237 smprintf(s,"Adding calendar note\n");
240 238
241 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar); 239 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
242 240
243 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 241 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
244#else 242#else
245 return ERR_SOURCENOTAVAILABLE; 243 return ERR_SOURCENOTAVAILABLE;
246#endif 244#endif
247} 245}
248 246
249GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 247GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
250{ 248{
251#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 249#ifdef GSM_ENABLE_OBEXGEN
252 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 250 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
253 unsigned char req[5000]; 251 unsigned char req[5000];
254 int size=0; 252 int size=0;
255 253
256 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 254 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
257 255
258 smprintf(s,"Adding ToDo\n"); 256 smprintf(s,"Adding ToDo\n");
259 257
260 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo); 258 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
261 259
262 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 260 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
263#else 261#else
264 return ERR_SOURCENOTAVAILABLE; 262 return ERR_SOURCENOTAVAILABLE;
265#endif 263#endif
266} 264}
267 265
268GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 266GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
269{ 267{
270#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 268#ifdef GSM_ENABLE_OBEXGEN
271 GSM_Error error; 269 GSM_Error error;
272 int Pos,Level = 0,Used; 270 int Pos,Level = 0,Used;
273 unsigned char *Buf; 271 unsigned char *Buf;
274 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 272 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
275 unsigned char Line[2000]; 273 unsigned char Line[2000];
276 274
277 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 275 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
278 276
279 smprintf(s,"Deleting all ToDo\n"); 277 smprintf(s,"Deleting all ToDo\n");
280 278
281 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 279 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
282 if (error != ERR_NONE) return error; 280 if (error != ERR_NONE) return error;
283 281
284 Pos = 0; 282 Pos = 0;
285 Buf = NULL; 283 Buf = NULL;
286 Used = 0; 284 Used = 0;
287 while (1) { 285 while (1) {
288 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 286 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
289 if (strlen(Line) == 0) break; 287 if (strlen(Line) == 0) break;
290 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 288 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
291 switch (Level) { 289 switch (Level) {
292 case 0: 290 case 0:
293 if (strstr(Line,"BEGIN:VTODO")) { 291 if (strstr(Line,"BEGIN:VTODO")) {
294 Level = 2; 292 Level = 2;
295 break; 293 break;
296 } 294 }
297 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); 295 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
298 strcpy(Buf+Used,Line); 296 strcpy(Buf+Used,Line);
299 Used=Used+strlen(Line)+3; 297 Used=Used+strlen(Line)+3;
300 Buf[Used-3] = 13; 298 Buf[Used-3] = 13;
301 Buf[Used-2] = 10; 299 Buf[Used-2] = 10;
302 Buf[Used-1] = 0x00; 300 Buf[Used-1] = 0x00;
303 break; 301 break;
304 case 2: /* ToDo note */ 302 case 2: /* ToDo note */
305 if (strstr(Line,"END:VTODO")) { 303 if (strstr(Line,"END:VTODO")) {
306 Level = 0; 304 Level = 0;
307 } 305 }
308 break; 306 break;
309 } 307 }
310 } 308 }
311 309
312 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 310 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
313 //if (Buf != NULL) free(Buf); 311 //if (Buf != NULL) free(Buf);
314 return error; 312 return error;
315#else 313#else
316 return ERR_SOURCENOTAVAILABLE; 314 return ERR_SOURCENOTAVAILABLE;
317#endif 315#endif
318} 316}
319 317
320GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 318GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
321{ 319{
322#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 320#ifdef GSM_ENABLE_OBEXGEN
323 GSM_Error error; 321 GSM_Error error;
324 int Pos,Level = 0,Loc=0,Used; 322 int Pos,Level = 0,Loc=0,Used;
325 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 323 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
326 unsigned char Line[2000]; 324 unsigned char Line[2000];
327 unsigned char *Buf; 325 unsigned char *Buf;
328 326
329 smprintf(s, "Deleting calendar note %i\n",Note->Location); 327 smprintf(s, "Deleting calendar note %i\n",Note->Location);
330 328
331 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 329 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
332 if (error != ERR_NONE) return error; 330 if (error != ERR_NONE) return error;
333 331
334 Pos = 0; 332 Pos = 0;
335 Buf = NULL; 333 Buf = NULL;
336 Used = 0; 334 Used = 0;
337 while (1) { 335 while (1) {
338 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 336 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
339 if (strlen(Line) == 0) break; 337 if (strlen(Line) == 0) break;
340 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 338 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
341 switch (Level) { 339 switch (Level) {
342 case 0: 340 case 0:
343 if (strstr(Line,"BEGIN:VEVENT")) { 341 if (strstr(Line,"BEGIN:VEVENT")) {
344 Loc++; 342 Loc++;
345 if (Loc == Note->Location) { 343 if (Loc == Note->Location) {
346 Level = 1; 344 Level = 1;
347 break; 345 break;
348 } 346 }
349 } 347 }
350 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); 348 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
351 strcpy(Buf+Used,Line); 349 strcpy(Buf+Used,Line);
352 Used=Used+strlen(Line)+3; 350 Used=Used+strlen(Line)+3;
353 Buf[Used-3] = 13; 351 Buf[Used-3] = 13;
354 Buf[Used-2] = 10; 352 Buf[Used-2] = 10;
355 Buf[Used-1] = 0x00; 353 Buf[Used-1] = 0x00;
356 break; 354 break;
357 case 1: /* Calendar note */ 355 case 1: /* Calendar note */
358 if (strstr(Line,"END:VEVENT")) { 356 if (strstr(Line,"END:VEVENT")) {
359 Level = 0; 357 Level = 0;
360 } 358 }
361 break; 359 break;
362 } 360 }
363 } 361 }
364 362
365 DumpMessage(s->di.df, s->di.dl, Buf, Used); 363 DumpMessage(s->di.df, s->di.dl, Buf, Used);
366 364
367 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 365 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
368 if (Buf != NULL) free(Buf); 366 if (Buf != NULL) free(Buf);
369 return error; 367 return error;
370#else 368#else
371 return ERR_SOURCENOTAVAILABLE; 369 return ERR_SOURCENOTAVAILABLE;
372#endif 370#endif
373} 371}
374 372
375GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 373GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
376{ 374{
377#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 375#ifdef GSM_ENABLE_OBEXGEN
378 GSM_Error error; 376 GSM_Error error;
379 GSM_ToDoEntry ToDo; 377 GSM_ToDoEntry ToDo;
380 GSM_CalendarEntry Calendar; 378 GSM_CalendarEntry Calendar;
381 int Pos; 379 int Pos;
382 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 380 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
383 381
384 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 382 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
385 383
386 smprintf(s, "Getting calendar status\n"); 384 smprintf(s, "Getting calendar status\n");
387 385
388 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 386 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
389 if (error != ERR_NONE) return error; 387 if (error != ERR_NONE) return error;
390 388
391 Status->Used = 0; 389 Status->Used = 0;
392 Pos = 0; 390 Pos = 0;
393 while (1) { 391 while (1) {
394 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 392 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
395 if (error == ERR_EMPTY) break; 393 if (error == ERR_EMPTY) break;
396 if (error != ERR_NONE) return error; 394 if (error != ERR_NONE) return error;
397 if (Calendar.EntriesNum != 0) Status->Used++; 395 if (Calendar.EntriesNum != 0) Status->Used++;
398 } 396 }
399 397
400 return ERR_NONE; 398 return ERR_NONE;
401#else 399#else
402 return ERR_SOURCENOTAVAILABLE; 400 return ERR_SOURCENOTAVAILABLE;
403#endif 401#endif
404} 402}
405 403
406#endif 404GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
405 { /*Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar
406 License: Whatever the current maintainer of gammulib chooses, as long as there
407 is an easy way to obtain the source under GPL, otherwise the author's parts
408 of this function are GPL 2.0.
409 */
410 GSM_Locale*locale = s->Phone.Data.Locale;
411 char format;
412
413 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
414 case AT_Reply_OK:
415 smprintf(s, "Date settings received\n");
416 format=atoi(msg.Buffer);
417 switch (format) {
418 case 0: locale->DateFormat = GSM_Date_OFF;
419 locale->DateSeparator = 0;
420 break;
421 case 1: locale->DateFormat = GSM_Date_DDMMMYY;
422 locale->DateSeparator = '-';
423 break;
424 case 2: locale->DateFormat = GSM_Date_DDMMYY;
425 locale->DateSeparator = '-';
426 break;
427 case 3: locale->DateFormat = GSM_Date_MMDDYY;
428 locale->DateSeparator = '/';
429 break;
430 case 4: locale->DateFormat = GSM_Date_DDMMYY;
431 locale->DateSeparator = '/';
432 break;
433 case 5: locale->DateFormat = GSM_Date_DDMMYY;
434 locale->DateSeparator = '.';
435 break;
436 case 6: locale->DateFormat = GSM_Date_YYMMDD;
437 locale->DateSeparator = 0;
438 break;
439 case 7: locale->DateFormat = GSM_Date_YYMMDD;
440 locale->DateSeparator = '-';
441 break;
442 default:return ERR_UNKNOWNRESPONSE;
443 }
444 default:
445 return ERR_NOTSUPPORTED;
446 }
447}
448
449GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
450 { /*Author: Peter Ondraska
451 License: Whatever the current maintainer of gammulib chooses, as long as there
452 is an easy way to obtain the source under GPL, otherwise the author's parts
453 of this function are GPL 2.0.
454 */
455 char format;
456
457 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
458 case AT_Reply_OK:
459 smprintf(s, "Time settings received\n");
460 format=atoi(msg.Buffer);
461 switch (format) {
462 case 1:
463 case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
464 return ERR_NONE;
465 default:return ERR_UNKNOWNRESPONSE;
466 }
467 default: return ERR_NOTSUPPORTED;
468 }
469}
470
471GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
472{
473 GSM_Error error;
474
475 s->Phone.Data.Locale = locale;
476
477 smprintf(s, "Getting date format\n");
478 error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
479 if (error!=ERR_NONE) return error;
480
481 smprintf(s, "Getting time format\n");
482 return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
483}
484
485
486GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
487 { /*Author: Peter Ondraska
488 License: Whatever the current maintainer of gammulib chooses, as long as there
489 is an easy way to obtain the source under GPL, otherwise the author's parts
490 of this function are GPL 2.0.
491 */
492 /* this is not yet supported by gammu.c */
493 intformat=0;
494 charreq[12];
495
496 if (locale->DateFormat==GSM_Date_OFF) { format=0; } else
497 if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else
498 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
499 if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else
500 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else
501 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else
502 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
503 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
504 else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
505
506 sprintf(req,"AT+ESDF=%i\r",format);
507 smprintf(s, "Setting date format\n");
508 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
509
510 if (locale->AMPMTime) { format=2; } else { format=1; }
511 sprintf(req,"AT+ESTF=%i\r",format);
512 smprintf(s, "Setting time format\n");
513 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
514}
515
407#endif 516#endif
408 517
409/* How should editor hadle tabs in this file? Add editor commands here. 518/* How should editor hadle tabs in this file? Add editor commands here.
410 * vim: noexpandtab sw=8 ts=8 sts=8: 519 * vim: noexpandtab sw=8 ts=8 sts=8:
411 */ 520 */
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c
index beef33c..17cd0a4 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.c
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c
@@ -1,51 +1,54 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */
3/* resetting DCT4 phones settings (c) by Walek */ 2/* resetting DCT4 phones settings (c) by Walek */
3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
4 7
5#include <string.h> /* memcpy only */ 8#include <string.h> /* memcpy only */
6#include <stdio.h> 9#include <stdio.h>
7#include <ctype.h> 10#include <ctype.h>
8 11
9#include "../../../gsmstate.h" 12#include "../../../gsmstate.h"
10#include "../../../misc/coding/coding.h" 13#include "../../../misc/coding/coding.h"
11#include "../../../service/sms/gsmsms.h" 14#include "../../../service/sms/gsmsms.h"
12#include "../../pfunc.h" 15#include "../../pfunc.h"
13#include "../nfunc.h" 16#include "../nfunc.h"
14#include "dct3func.h" 17#include "dct3func.h"
15 18
16#ifdef GSM_ENABLE_NOKIA_DCT3 19#ifdef GSM_ENABLE_NOKIA_DCT3
17 20
18GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 21GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
19{ 22{
20 GSM_Error error; 23 GSM_Error error;
21 24
22 /* We have to enable WAP frames in phone */ 25 /* We have to enable WAP frames in phone */
23 error=DCT3DCT4_EnableWAPFunctions(s); 26 error=DCT3DCT4_EnableWAPFunctions(s);
24 if (error!=ERR_NONE) return error; 27 if (error!=ERR_NONE) return error;
25 28
26 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); 29 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
27} 30}
28 31
29GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 32GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
30{ 33{
31 GSM_Error error; 34 GSM_Error error;
32 35
33 /* We have to enable WAP frames in phone */ 36 /* We have to enable WAP frames in phone */
34 error=DCT3DCT4_EnableWAPFunctions(s); 37 error=DCT3DCT4_EnableWAPFunctions(s);
35 if (error!=ERR_NONE) return error; 38 if (error!=ERR_NONE) return error;
36 39
37 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); 40 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
38} 41}
39 42
40GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s) 43GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s)
41{ 44{
42 GSM_Phone_Data *Data = &s->Phone.Data; 45 GSM_Phone_Data *Data = &s->Phone.Data;
43 46
44 switch (msg.Buffer[2]) { 47 switch (msg.Buffer[2]) {
45 case 0x46: 48 case 0x46:
46 smprintf(s, "Pressing key OK\n"); 49 smprintf(s, "Pressing key OK\n");
47 if (Data->PressKey) return ERR_NONE; 50 if (Data->PressKey) return ERR_NONE;
48 break; 51 break;
49 case 0x47: 52 case 0x47:
50 smprintf(s, "Releasing key OK\n"); 53 smprintf(s, "Releasing key OK\n");
51 if (!Data->PressKey) return ERR_NONE; 54 if (!Data->PressKey) return ERR_NONE;
@@ -349,163 +352,164 @@ GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigne
349 return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime); 352 return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime);
350} 353}
351 354
352GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) 355GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
353{ 356{
354 smprintf(s, "Alarm: "); 357 smprintf(s, "Alarm: ");
355 if (msg.Buffer[4]==0x01) { 358 if (msg.Buffer[4]==0x01) {
356 smprintf(s, "set OK\n"); 359 smprintf(s, "set OK\n");
357 return ERR_NONE; 360 return ERR_NONE;
358 } 361 }
359 smprintf(s, "error setting\n"); 362 smprintf(s, "error setting\n");
360 return ERR_UNKNOWN; 363 return ERR_UNKNOWN;
361} 364}
362 365
363GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype) 366GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype)
364{ 367{
365 unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03, 368 unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03,
366 0x02, /* Unknown. Not for enabling/disabling */ 369 0x02, /* Unknown. Not for enabling/disabling */
367 0x00, /* Hour */ 370 0x00, /* Hour */
368 0x00, /* Minute */ 371 0x00, /* Minute */
369 0x00}; /* Unknown. Not seconds */ 372 0x00}; /* Unknown. Not seconds */
370 373
371 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 374 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
372 375
373 req[8] = alarm->DateTime.Hour; 376 req[8] = alarm->DateTime.Hour;
374 req[9] = alarm->DateTime.Minute; 377 req[9] = alarm->DateTime.Minute;
375 378
376 smprintf(s, "Setting alarm\n"); 379 smprintf(s, "Setting alarm\n");
377 return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm); 380 return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm);
378} 381}
379 382
380GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 383GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
381{ 384{
382 int i; 385 int i;
383 GSM_Phone_Data*Data = &s->Phone.Data; 386 GSM_Phone_Data*Data = &s->Phone.Data;
384 387
385 switch (msg.Buffer[3]) { 388 switch (msg.Buffer[3]) {
386 case 0x34: 389 case 0x34:
387 smprintf(s, "SMSC received\n"); 390 smprintf(s, "SMSC received\n");
388 Data->SMSC->Format = SMS_FORMAT_Text; 391 Data->SMSC->Format = SMS_FORMAT_Text;
389 switch (msg.Buffer[6]) { 392 switch (msg.Buffer[6]) {
390 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 393 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
391 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 394 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
392 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 395 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
393 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 396 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
394 } 397 }
395 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; 398 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
396 Data->SMSC->Validity.Relative= msg.Buffer[8]; 399 Data->SMSC->Validity.Relative= msg.Buffer[8];
400 if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
397 401
398 i=33; 402 i=33;
399 while (msg.Buffer[i]!=0) {i++;} 403 while (msg.Buffer[i]!=0) {i++;}
400 i=i-33; 404 i=i-33;
401 if (i>GSM_MAX_SMSC_NAME_LENGTH) { 405 if (i>GSM_MAX_SMSC_NAME_LENGTH) {
402 smprintf(s, "Too long name\n"); 406 smprintf(s, "Too long name\n");
403 return ERR_UNKNOWNRESPONSE; 407 return ERR_UNKNOWNRESPONSE;
404 } 408 }
405 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); 409 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i);
406 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); 410 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
407 411
408 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); 412 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true);
409 smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); 413 smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
410 414
411 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false); 415 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false);
412 smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); 416 smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
413 417
414 return ERR_NONE; 418 return ERR_NONE;
415 case 0x35: 419 case 0x35:
416 smprintf(s, "Getting SMSC failed\n"); 420 smprintf(s, "Getting SMSC failed\n");
417 return ERR_INVALIDLOCATION; 421 return ERR_INVALIDLOCATION;
418 } 422 }
419 return ERR_UNKNOWNRESPONSE; 423 return ERR_UNKNOWNRESPONSE;
420} 424}
421 425
422GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 426GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
423{ 427{
424 unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64, 428 unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64,
425 0x00}; /* Location */ 429 0x00}; /* Location */
426 430
427 if (smsc->Location==0x00) return ERR_INVALIDLOCATION; 431 if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
428 432
429 req[5]=smsc->Location; 433 req[5]=smsc->Location;
430 434
431 s->Phone.Data.SMSC=smsc; 435 s->Phone.Data.SMSC=smsc;
432 smprintf(s, "Getting SMSC\n"); 436 smprintf(s, "Getting SMSC\n");
433 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); 437 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
434} 438}
435 439
436GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 440GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
437{ 441{
438 int count; 442 int count;
439 GSM_Phone_Data*Data = &s->Phone.Data; 443 GSM_Phone_Data*Data = &s->Phone.Data;
440#ifdef DEBUG 444#ifdef DEBUG
441 GSM_NetworkInfo NetInfo; 445 GSM_NetworkInfo NetInfo;
442 char name[100]; 446 char name[100];
443 447
444 smprintf(s, "Network info received\n"); 448 smprintf(s, "Network info received\n");
445 smprintf(s, " Status : "); 449 smprintf(s, "Status : ");
446 switch (msg.Buffer[8]) { 450 switch (msg.Buffer[8]) {
447 case 0x01: smprintf(s, "home network"); break; 451 case 0x01: smprintf(s, "home network"); break;
448 case 0x02: smprintf(s, "roaming network"); break; 452 case 0x02: smprintf(s, "roaming network"); break;
449 case 0x03: smprintf(s, "requesting network"); break; 453 case 0x03: smprintf(s, "requesting network"); break;
450 case 0x04: smprintf(s, "not registered in the network");break; 454 case 0x04: smprintf(s, "not registered in the network");break;
451 default : smprintf(s, "unknown"); 455 default : smprintf(s, "unknown");
452 } 456 }
453 smprintf(s, "\n"); 457 smprintf(s, "\n");
454 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); 458 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
455 if (msg.Buffer[8]<0x03) { 459 if (msg.Buffer[8]<0x03) {
456 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); 460 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
457 smprintf(s, "CID : %s\n", NetInfo.CID); 461 smprintf(s, "CID : %s\n", NetInfo.CID);
458 462
459 sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); 463 sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
460 smprintf(s, "LAC : %s\n", NetInfo.LAC); 464 smprintf(s, "LAC : %s\n", NetInfo.LAC);
461 465
462 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
463 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); 466 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
467 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
464 smprintf(s, "Network name for Gammu : %s ", 468 smprintf(s, "Network name for Gammu : %s ",
465 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); 469 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
466 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); 470 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
467 471
468 if (msg.Length>18) { 472 if (msg.Length>18) {
469 if (msg.Buffer[18]==0x00) { 473 if (msg.Buffer[18]==0x00) {
470 /* In 6210 name is in "normal" Unicode */ 474 /* In 6210 name is in "normal" Unicode */
471 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); 475 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2);
472 name[msg.Buffer[17]*2]=0x00; 476 name[msg.Buffer[17]*2]=0x00;
473 name[msg.Buffer[17]*2+1]=0x00; 477 name[msg.Buffer[17]*2+1]=0x00;
474 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 478 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
475 } else { 479 } else {
476 /* In 9210 first 0x00 is cut from Unicode string */ 480 /* In 9210 first 0x00 is cut from Unicode string */
477 name[0] = 0; 481 name[0] = 0;
478 memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2); 482 memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2);
479 name[msg.Buffer[17]*2+1]=0x00; 483 name[msg.Buffer[17]*2+1]=0x00;
480 name[msg.Buffer[17]*2+2]=0x00; 484 name[msg.Buffer[17]*2+2]=0x00;
481 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 485 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
482 } 486 }
483 } 487 }
484 } 488 }
485#endif 489#endif
486 if (Data->RequestID==ID_GetNetworkInfo) { 490 if (Data->RequestID==ID_GetNetworkInfo) {
487 Data->NetworkInfo->NetworkName[0] = 0x00; 491 Data->NetworkInfo->NetworkName[0] = 0x00;
488 Data->NetworkInfo->NetworkName[1] = 0x00; 492 Data->NetworkInfo->NetworkName[1] = 0x00;
489 Data->NetworkInfo->State = 0; 493 Data->NetworkInfo->State = 0;
490 switch (msg.Buffer[8]) { 494 switch (msg.Buffer[8]) {
491 case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break; 495 case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break;
492 case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork;break; 496 case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork;break;
493 case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork;break; 497 case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork;break;
494 case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break; 498 case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break;
495 } 499 }
496 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { 500 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) {
497 if (msg.Buffer[18]==0x00) { 501 if (msg.Buffer[18]==0x00) {
498 /* In 6210 name is in "normal" Unicode */ 502 /* In 6210 name is in "normal" Unicode */
499 memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2); 503 memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2);
500 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00; 504 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00;
501 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00; 505 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00;
502 } else { 506 } else {
503 /* In 9210 first 0x00 is cut from Unicode string */ 507 /* In 9210 first 0x00 is cut from Unicode string */
504 Data->NetworkInfo->NetworkName[0] = 0; 508 Data->NetworkInfo->NetworkName[0] = 0;
505 memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2); 509 memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2);
506 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00; 510 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00;
507 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00; 511 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00;
508 } 512 }
509 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode); 513 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode);
510 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); 514 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
511 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); 515 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
@@ -1163,101 +1167,101 @@ GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *setting
1163 SetReq2[pos++] = 0x02; 1167 SetReq2[pos++] = 0x02;
1164 SetReq2[pos++] = 0x00; /* SMS */ 1168 SetReq2[pos++] = 0x00; /* SMS */
1165 if (loc2 != -1) { 1169 if (loc2 != -1) {
1166 /* Service number */ 1170 /* Service number */
1167 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Service, false); 1171 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Service, false);
1168 /* Server number */ 1172 /* Server number */
1169 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Server, false); 1173 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Server, false);
1170 } else pos += 2; 1174 } else pos += 2;
1171 memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); 1175 memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
1172 pos += 8; 1176 pos += 8;
1173 smprintf(s, "Writing WAP settings part 2 (SMS bearer)\n"); 1177 smprintf(s, "Writing WAP settings part 2 (SMS bearer)\n");
1174 error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); 1178 error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
1175 if (error != ERR_NONE) return error; 1179 if (error != ERR_NONE) return error;
1176 } 1180 }
1177 /* USSD */ 1181 /* USSD */
1178 if (phone3 != -1) { 1182 if (phone3 != -1) {
1179 pos = 4; 1183 pos = 4;
1180 memset(SetReq2 + pos, 0, 200 - pos); 1184 memset(SetReq2 + pos, 0, 200 - pos);
1181 SetReq2[pos++] = phone3; 1185 SetReq2[pos++] = phone3;
1182 SetReq2[pos++] = 0x02; 1186 SetReq2[pos++] = 0x02;
1183 SetReq2[pos++] = 0x02; /* USSD */ 1187 SetReq2[pos++] = 0x02; /* USSD */
1184 if (loc3 != -1) { 1188 if (loc3 != -1) {
1185 if (!settings->Settings[loc3].IsIP) SetReq2[pos] = 0x01; 1189 if (!settings->Settings[loc3].IsIP) SetReq2[pos] = 0x01;
1186 } 1190 }
1187 pos++; 1191 pos++;
1188 if (loc3 != -1) { 1192 if (loc3 != -1) {
1189 /* Service number or IP address */ 1193 /* Service number or IP address */
1190 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false); 1194 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false);
1191 /* Code number */ 1195 /* Code number */
1192 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false); 1196 pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false);
1193 } else pos+=2; 1197 } else pos+=2;
1194 memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); 1198 memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
1195 pos += 8; 1199 pos += 8;
1196 smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n"); 1200 smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n");
1197 error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); 1201 error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
1198 if (error != ERR_NONE) return error; 1202 if (error != ERR_NONE) return error;
1199 } 1203 }
1200 error = DCT3DCT4_SetActiveConnectSet(s, settings); 1204 error = DCT3DCT4_SetActiveConnectSet(s, settings);
1201 if (error != ERR_NONE) return error; 1205 if (error != ERR_NONE) return error;
1202 1206
1203 return DCT3DCT4_DisableConnectionFunctions(s); 1207 return DCT3DCT4_DisableConnectionFunctions(s);
1204} 1208}
1205 1209
1206GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 1210GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
1207{ 1211{
1208 switch (msg.Buffer[3]) { 1212 switch (msg.Buffer[3]) {
1209 case 0x02: 1213 case 0x02:
1210 smprintf(s, "SMS sent OK\n"); 1214 smprintf(s, "SMS sent OK\n");
1211 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1215 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]);
1212 return ERR_NONE; 1216 return ERR_NONE;
1213 case 0x03: 1217 case 0x03:
1214 smprintf(s, "Error %i\n",msg.Buffer[6]); 1218 smprintf(s, "Error %i\n",msg.Buffer[6]);
1215 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0); 1219 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1);
1216 return ERR_NONE; 1220 return ERR_NONE;
1217 } 1221 }
1218 return ERR_UNKNOWNRESPONSE; 1222 return ERR_UNKNOWNRESPONSE;
1219} 1223}
1220 1224
1221GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 1225GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
1222{ 1226{
1223 int length; 1227 int length;
1224 GSM_Error error; 1228 GSM_Error error;
1225 unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00}; 1229 unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00};
1226 1230
1227 error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true); 1231 error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true);
1228 if (error != ERR_NONE) return error; 1232 if (error != ERR_NONE) return error;
1229 1233
1230 smprintf(s, "Sending sms\n"); 1234 smprintf(s, "Sending sms\n");
1231 return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02); 1235 return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02);
1232} 1236}
1233 1237
1234GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s) 1238GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s)
1235{ 1239{
1236 switch (msg.Buffer[3]) { 1240 switch (msg.Buffer[3]) {
1237 case 0x00: 1241 case 0x00:
1238 smprintf(s, "Netmonitor correctly set\n"); 1242 smprintf(s, "Netmonitor correctly set\n");
1239 break; 1243 break;
1240 default: 1244 default:
1241 smprintf(s, "Menu %i\n",msg.Buffer[3]); 1245 smprintf(s, "Menu %i\n",msg.Buffer[3]);
1242 smprintf(s, "%s\n",msg.Buffer+4); 1246 smprintf(s, "%s\n",msg.Buffer+4);
1243 strcpy(s->Phone.Data.Netmonitor,msg.Buffer+4); 1247 strcpy(s->Phone.Data.Netmonitor,msg.Buffer+4);
1244 break; 1248 break;
1245 } 1249 }
1246 return ERR_NONE; 1250 return ERR_NONE;
1247} 1251}
1248 1252
1249GSM_Error DCT3_Netmonitor(GSM_StateMachine *s, int testnumber, char *value) 1253GSM_Error DCT3_Netmonitor(GSM_StateMachine *s, int testnumber, char *value)
1250{ 1254{
1251 GSM_Error error; 1255 GSM_Error error;
1252 unsigned char req[] = {0x00, 0x01, 0x7e, 1256 unsigned char req[] = {0x00, 0x01, 0x7e,
1253 0x00}; /* Test number */ 1257 0x00}; /* Test number */
1254 1258
1255 value[0] = 0; 1259 value[0] = 0;
1256 1260
1257 error=DCT3_EnableSecurity (s, 0x01); 1261 error=DCT3_EnableSecurity (s, 0x01);
1258 if (error != ERR_NONE) return error; 1262 if (error != ERR_NONE) return error;
1259 1263
1260 req[3] = testnumber; 1264 req[3] = testnumber;
1261 1265
1262 smprintf(s, "Getting netmonitor test\n"); 1266 smprintf(s, "Getting netmonitor test\n");
1263 s->Phone.Data.Netmonitor = value; 1267 s->Phone.Data.Netmonitor = value;
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h
index 66b67ec..18b2026 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.h
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h
@@ -1,53 +1,55 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#ifndef phone_nokia_dct3_h 3#ifndef phone_nokia_dct3_h
4#define phone_nokia_dct3_h 4#define phone_nokia_dct3_h
5 5
6#include "../ncommon.h"
7
6 GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s); 8 GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s);
7 GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s); 9 GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s);
8 GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s); 10 GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s);
9 GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s); 11 GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s);
10 GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s); 12 GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
11 GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s); 13 GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s);
12 GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s); 14 GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s);
13 GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); 15 GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
14 GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); 16 GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
15 GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); 17 GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
16 GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); 18 GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
17 GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s); 19 GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s);
18 GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s); 20 GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s);
19 GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s); 21 GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s);
20 GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s); 22 GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s);
21 GSM_Error DCT3_ReplySetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s); 23 GSM_Error DCT3_ReplySetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
22 GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s); 24 GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s);
23 GSM_Error DCT3_ReplySetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s); 25 GSM_Error DCT3_ReplySetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s);
24 GSM_Error DCT3_ReplyNetmonitor (GSM_Protocol_Message msg, GSM_StateMachine *s); 26 GSM_Error DCT3_ReplyNetmonitor (GSM_Protocol_Message msg, GSM_StateMachine *s);
25 GSM_Error DCT3_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s); 27 GSM_Error DCT3_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s);
26 GSM_Error N71_92_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s); 28 GSM_Error N71_92_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s);
27 GSM_Error N71_92_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s); 29 GSM_Error N71_92_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s);
28 GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message msg, GSM_StateMachine *s); 30 GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message msg, GSM_StateMachine *s);
29GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s); 31GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s);
30 GSM_Error N61_91_ReplySetOpLogo (GSM_Protocol_Message msg, GSM_StateMachine *s); 32 GSM_Error N61_91_ReplySetOpLogo (GSM_Protocol_Message msg, GSM_StateMachine *s);
31#ifdef GSM_ENABLE_CELLBROADCAST 33#ifdef GSM_ENABLE_CELLBROADCAST
32 GSM_Error DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s); 34 GSM_Error DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s);
33 GSM_Error DCT3_ReplyIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s); 35 GSM_Error DCT3_ReplyIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s);
34#endif 36#endif
35 37
36 GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 38 GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
37 GSM_Error DCT3_GetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 39 GSM_Error DCT3_GetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
38 GSM_Error DCT3_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); 40 GSM_Error DCT3_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
39 GSM_Error DCT3_PlayTone (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start); 41 GSM_Error DCT3_PlayTone (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start);
40 GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status); 42 GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status);
41 GSM_Error DCT3_GetIMEI (GSM_StateMachine *s); 43 GSM_Error DCT3_GetIMEI (GSM_StateMachine *s);
42 GSM_Error DCT3_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc ); 44 GSM_Error DCT3_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc );
43 GSM_Error DCT3_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); 45 GSM_Error DCT3_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo);
44 GSM_Error DCT3_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); 46 GSM_Error DCT3_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber);
45 GSM_Error DCT3_Reset (GSM_StateMachine *s, bool hard ); 47 GSM_Error DCT3_Reset (GSM_StateMachine *s, bool hard );
46 GSM_Error DCT3_CancelCall (GSM_StateMachine *s, int ID, bool all); 48 GSM_Error DCT3_CancelCall (GSM_StateMachine *s, int ID, bool all);
47 GSM_Error DCT3_AnswerAllCalls (GSM_StateMachine *s); 49 GSM_Error DCT3_AnswerAllCalls (GSM_StateMachine *s);
48 GSM_Error DCT3_SendSMSMessage (GSM_StateMachine *s, GSM_SMSMessage *sms ); 50 GSM_Error DCT3_SendSMSMessage (GSM_StateMachine *s, GSM_SMSMessage *sms );
49 GSM_Error DCT3_GetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm,unsigned char msgtype); 51 GSM_Error DCT3_GetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm,unsigned char msgtype);
50 GSM_Error DCT3_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype); 52 GSM_Error DCT3_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype);
51 GSM_Error DCT3_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype); 53 GSM_Error DCT3_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype);
52 GSM_Error DCT3_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype); 54 GSM_Error DCT3_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype);
53 GSM_Error DCT3_SetIncomingCB (GSM_StateMachine *s, bool enable); 55 GSM_Error DCT3_SetIncomingCB (GSM_StateMachine *s, bool enable);
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c
index 263d12b..dac6c12 100644
--- a/gammu/emb/common/phone/nokia/dct3/n6110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.c
@@ -1,52 +1,54 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail and Gnokii */
3/* Authentication function (c) 1999 or earlier by Pavel Janik */
4/* 5210 calendar IDs by Frederick Ros */ 2/* 5210 calendar IDs by Frederick Ros */
3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
5 7
6#include "../../../gsmstate.h" 8#include "../../../gsmstate.h"
7 9
8#ifdef GSM_ENABLE_NOKIA6110 10#ifdef GSM_ENABLE_NOKIA6110
9 11
10#include <string.h> 12#include <string.h>
11 13
12#include "../../../../cfg/config.h" 14#include "../../../../cfg/config.h"
13#include "../../../misc/coding/coding.h" 15#include "../../../misc/coding/coding.h"
14#include "../../../service/sms/gsmsms.h" 16#include "../../../service/sms/gsmsms.h"
15#include "../../../gsmcomon.h" 17#include "../../../gsmcomon.h"
16#include "../../pfunc.h" 18#include "../../pfunc.h"
17#include "../nfunc.h" 19#include "../nfunc.h"
18#include "n6110.h" 20#include "n6110.h"
19#include "dct3func.h" 21#include "dct3func.h"
20 22
21static unsigned char N6110_MEMORY_TYPES[] = { 23static unsigned char N6110_MEMORY_TYPES[] = {
22 MEM_ME, 0x02, 24 MEM_ME, 0x02,
23 MEM_SM, 0x03, 25 MEM_SM, 0x03,
24 MEM_ON, 0x05, 26 MEM_ON, 0x05,
25 MEM_DC, 0x07, 27 MEM_DC, 0x07,
26 MEM_RC, 0x08, 28 MEM_RC, 0x08,
27 MEM_MC, 0x09, 29 MEM_MC, 0x09,
28 MEM_VM, 0x0b, 30 MEM_VM, 0x0b,
29 0x00, 0x00 31 0x00, 0x00
30}; 32};
31 33
32static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s) 34static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s)
33{ 35{
34 N6110_Language lang = N6110_Auto; 36 N6110_Language lang = N6110_Auto;
35 37
36 if (msg.Buffer[3] == 0x15) return ERR_NONE; 38 if (msg.Buffer[3] == 0x15) return ERR_NONE;
37 39
38 smprintf(s, "Phone language is %02x\n",msg.Buffer[6]); 40 smprintf(s, "Phone language is %02x\n",msg.Buffer[6]);
39 switch (msg.Buffer[6]) { 41 switch (msg.Buffer[6]) {
40 case 0x21: lang = N6110_Europe; break; //Polish 42 case 0x21: lang = N6110_Europe; break; //Polish
41 } 43 }
42 s->Phone.Data.Priv.N6110.PhoneLanguage = lang; 44 s->Phone.Data.Priv.N6110.PhoneLanguage = lang;
43 return ERR_NONE; 45 return ERR_NONE;
44} 46}
45 47
46static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s) 48static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s)
47{ 49{
48 unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01, 50 unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
49 0x00, /* Profile location */ 51 0x00, /* Profile location */
50 0x00}; /* Feature number */ 52 0x00}; /* Feature number */
51 53
52 s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto; 54 s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto;
@@ -82,96 +84,97 @@ static struct N6110_Lang_Char N6110_Lang_Table[] = {
82{N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute 84{N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute
83{N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute 85{N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute
84{N6110_Europe,0xB2,0x20,0xAC},//euro 86{N6110_Europe,0xB2,0x20,0xAC},//euro
85{N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute 87{N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute
86{N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute 88{N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute
87{N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute 89{N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute
88{N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute 90{N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute
89{N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above 91{N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above
90{N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above 92{N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above
91{0,0,0,0} 93{0,0,0,0}
92}; 94};
93 95
94static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len) 96static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len)
95{ 97{
96 int i_len = 0, o_len, i; 98 int i_len = 0, o_len, i;
97 wchar_t wc; 99 wchar_t wc;
98 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; 100 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
99 bool found; 101 bool found;
100 102
101 for (o_len = 0; i_len < len; o_len++) { 103 for (o_len = 0; i_len < len; o_len++) {
102 found = false; 104 found = false;
103 if (Priv->PhoneLanguage != N6110_Auto) { 105 if (Priv->PhoneLanguage != N6110_Auto) {
104 i = 0; 106 i = 0;
105 while(1) { 107 while(1) {
106 if (N6110_Lang_Table[i].Lang == 0) break; 108 if (N6110_Lang_Table[i].Lang == 0) break;
107 if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage && 109 if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage &&
108 N6110_Lang_Table[i].Phone == src[i_len]) { 110 N6110_Lang_Table[i].Phone == src[i_len]) {
109 dest[o_len*2] = N6110_Lang_Table[i].Unicode1; 111 dest[o_len*2] = N6110_Lang_Table[i].Unicode1;
110 dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2; 112 dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2;
111 i_len++; 113 i_len++;
112 found = true; 114 found = true;
113 break; 115 break;
114 } 116 }
115 i++; 117 i++;
116 } 118 }
117 } 119 }
118 if (!found) { 120 if (!found) {
119 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc); 121 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
120 dest[o_len*2] = (wc >> 8) & 0xff; 122 dest[o_len*2] = (wc >> 8) & 0xff;
121 dest[(o_len*2)+1] = wc & 0xff; 123 dest[(o_len*2)+1] = wc & 0xff;
122 } 124 }
123 } 125 }
124 dest[o_len*2] = 0; 126 dest[o_len*2] = 0;
125 dest[(o_len*2)+1] = 0; 127 dest[(o_len*2)+1] = 0;
126} 128}
127 129
128#ifndef ENABLE_LGPL 130#ifndef ENABLE_LGPL
129 131
132/* Pavel Janik */
130/* This function provides Nokia authentication protocol. 133/* This function provides Nokia authentication protocol.
131 * Nokia authentication protocol is used in the communication between Nokia 134 * Nokia authentication protocol is used in the communication between Nokia
132 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software, 135 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
133 * commercially sold by Nokia Corp. 136 * commercially sold by Nokia Corp.
134 * The authentication scheme is based on the token send by the phone to the 137 * The authentication scheme is based on the token send by the phone to the
135 * software. The software does it's magic (see the function 138 * software. The software does it's magic (see the function
136 * N6110_GetNokiaAuthentication) and returns the result back to the phone. 139 * N6110_GetNokiaAuthentication) and returns the result back to the phone.
137 * If the result is correct the phone responds with the message "Accessory 140 * If the result is correct the phone responds with the message "Accessory
138 * connected!" displayed on the LCD. Otherwise it will display "Accessory not 141 * connected!" displayed on the LCD. Otherwise it will display "Accessory not
139 * supported" and some functions will not be available for use (?). 142 * supported" and some functions will not be available for use (?).
140 * The specification of the protocol is not publicly available, no comment. 143 * The specification of the protocol is not publicly available, no comment.
141 */ 144 */
142static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse) 145static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
143{ 146{
144 int i, j, CRC=0; 147 int i, j, CRC=0;
145 unsigned char Temp[16]; /* This is our temporary working area. */ 148 unsigned char Temp[16]; /* This is our temporary working area. */
146 149
147 /* Here we put FAC (Final Assembly Code) and serial number into our area. */ 150 /* Here we put FAC (Final Assembly Code) and serial number into our area. */
148 Temp[0] = Imei[6]; Temp[1] = Imei[7]; 151 Temp[0] = Imei[6]; Temp[1] = Imei[7];
149 Temp[2] = Imei[8]; Temp[3] = Imei[9]; 152 Temp[2] = Imei[8]; Temp[3] = Imei[9];
150 Temp[4] = Imei[10]; Temp[5] = Imei[11]; 153 Temp[4] = Imei[10]; Temp[5] = Imei[11];
151 Temp[6] = Imei[12]; Temp[7] = Imei[13]; 154 Temp[6] = Imei[12]; Temp[7] = Imei[13];
152 155
153 /* And now the TAC (Type Approval Code). */ 156 /* And now the TAC (Type Approval Code). */
154 Temp[8] = Imei[2]; Temp[9] = Imei[3]; 157 Temp[8] = Imei[2]; Temp[9] = Imei[3];
155 Temp[10] = Imei[4]; Temp[11] = Imei[5]; 158 Temp[10] = Imei[4]; Temp[11] = Imei[5];
156 159
157 /* And now we pack magic bytes from the phone. */ 160 /* And now we pack magic bytes from the phone. */
158 Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1]; 161 Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1];
159 Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3]; 162 Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3];
160 163
161 for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1; 164 for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1;
162 switch (Temp[15] & 0x03) { 165 switch (Temp[15] & 0x03) {
163 case 1: 166 case 1:
164 case 2: j = Temp[13] & 0x07; 167 case 2: j = Temp[13] & 0x07;
165 for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12]; 168 for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12];
166 break; 169 break;
167 default: j = Temp[14] & 0x07; 170 default: j = Temp[14] & 0x07;
168 for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12]; 171 for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12];
169 } 172 }
170 for (i=0; i<=15; i++) CRC ^= Temp[i]; 173 for (i=0; i<=15; i++) CRC ^= Temp[i];
171 for (i=0; i<=15; i++) { 174 for (i=0; i<=15; i++) {
172 switch (Temp[15 - i] & 0x06) { 175 switch (Temp[15 - i] & 0x06) {
173 case 0: j = Temp[i] | CRC; break; 176 case 0: j = Temp[i] | CRC; break;
174 case 2: 177 case 2:
175 case 4: j = Temp[i] ^ CRC; break; 178 case 4: j = Temp[i] ^ CRC; break;
176 case 6: j = Temp[i] & CRC; break; 179 case 6: j = Temp[i] & CRC; break;
177 } 180 }
@@ -779,96 +782,97 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
779 0x00,0x78}; 782 0x00,0x78};
780 unsigned char reqBin[1000] = {0x00,0x01,0xa0,0x00,0x00,0x0c,0x01,0x2c}; 783 unsigned char reqBin[1000] = {0x00,0x01,0xa0,0x00,0x00,0x0c,0x01,0x2c};
781 784
782 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NORING)) return ERR_NOTSUPPORTED; 785 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NORING)) return ERR_NOTSUPPORTED;
783 if (Ringtone->Location == 0) return ERR_INVALIDLOCATION; 786 if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
784 787
785 switch (Ringtone->Format) { 788 switch (Ringtone->Format) {
786 case RING_NOTETONE: 789 case RING_NOTETONE:
787 if (Ringtone->Location==255) { 790 if (Ringtone->Location==255) {
788 /* Only 6110, 6130 and 6150 support it */ 791 /* Only 6110, 6130 and 6150 support it */
789 if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 || 792 if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 ||
790 strcmp(s->Phone.Data.Model,"NSM-1") == 0) { 793 strcmp(s->Phone.Data.Model,"NSM-1") == 0) {
791 req[0] = 0x0c; 794 req[0] = 0x0c;
792 req[1] = 0x01; 795 req[1] = 0x01;
793 UDHHeader.Type = UDH_NokiaRingtone; 796 UDHHeader.Type = UDH_NokiaRingtone;
794 GSM_EncodeUDHHeader(&UDHHeader); 797 GSM_EncodeUDHHeader(&UDHHeader);
795 /* We copy UDH now */ 798 /* We copy UDH now */
796 memcpy(req+2,UDHHeader.Text,UDHHeader.Length); 799 memcpy(req+2,UDHHeader.Text,UDHHeader.Length);
797 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+2+UDHHeader.Length, &size); 800 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+2+UDHHeader.Length, &size);
798 error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12); 801 error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12);
799 if (error!=ERR_NONE) return error; 802 if (error!=ERR_NONE) return error;
800 my_sleep(1000); 803 my_sleep(1000);
801 /* We have to make something (not important, what) now */ 804 /* We have to make something (not important, what) now */
802 /* no answer from phone*/ 805 /* no answer from phone*/
803 return DCT3_GetNetworkInfo(s,&NetInfo); 806 return DCT3_GetNetworkInfo(s,&NetInfo);
804 } else { 807 } else {
805 return ERR_NOTSUPPORTED; 808 return ERR_NOTSUPPORTED;
806 } 809 }
807 } 810 }
808 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+7, &size); 811 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+7, &size);
809 req[4] = Ringtone->Location - 1; 812 req[4] = Ringtone->Location - 1;
810 smprintf(s, "Setting ringtone\n"); 813 smprintf(s, "Setting ringtone\n");
811 return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone); 814 return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone);
812 case RING_NOKIABINARY: 815 case RING_NOKIABINARY:
813 error=DCT3_EnableSecurity (s, 0x01); 816 error=DCT3_EnableSecurity (s, 0x01);
814 if (error!=ERR_NONE) return error; 817 if (error!=ERR_NONE) return error;
815 memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name)); 818 memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name));
816 current += UnicodeLength(Ringtone->Name); 819 current += UnicodeLength(Ringtone->Name);
817 reqBin[current++] = 0x00; 820 reqBin[current++] = 0x00;
818 reqBin[current++] = 0x00; 821 reqBin[current++] = 0x00;
819 reqBin[current++] = 0x00;/*xxx*/ 822 reqBin[current++] = 0x00;/*xxx*/
820 memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); 823 memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
821 current=current+Ringtone->NokiaBinary.Length; 824 current=current+Ringtone->NokiaBinary.Length;
822 reqBin[3]=Ringtone->Location-1; 825 reqBin[3]=Ringtone->Location-1;
823 if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10; 826 if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10;
824 smprintf(s, "Setting binary ringtone\n"); 827 smprintf(s, "Setting binary ringtone\n");
825 return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone); 828 return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone);
826 case RING_MIDI: 829 case RING_MIDI:
830 case RING_MMF:
827 return ERR_NOTSUPPORTED; 831 return ERR_NOTSUPPORTED;
828 } 832 }
829 return ERR_NOTSUPPORTED; 833 return ERR_NOTSUPPORTED;
830} 834}
831 835
832static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 836static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
833{ 837{
834 int count=5; 838 int count=5;
835 GSM_Phone_Data *Data = &s->Phone.Data; 839 GSM_Phone_Data *Data = &s->Phone.Data;
836 840
837 smprintf(s, "Operator logo received\n"); 841 smprintf(s, "Operator logo received\n");
838 NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode); 842 NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode);
839 count = count + 3; 843 count = count + 3;
840 smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode); 844 smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode);
841 smprintf(s, "Network name for Gammu : %s ", 845 smprintf(s, "Network name for Gammu : %s ",
842 DecodeUnicodeString(GSM_GetNetworkName(Data->Bitmap->NetworkCode))); 846 DecodeUnicodeString(GSM_GetNetworkName(Data->Bitmap->NetworkCode)));
843 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(Data->Bitmap->NetworkCode))); 847 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(Data->Bitmap->NetworkCode)));
844 848
845 count = count + 3; /* We ignore size */ 849 count = count + 3; /* We ignore size */
846 Data->Bitmap->BitmapWidth = msg.Buffer[count++]; 850 Data->Bitmap->BitmapWidth = msg.Buffer[count++];
847 Data->Bitmap->BitmapHeight = msg.Buffer[count++]; 851 Data->Bitmap->BitmapHeight = msg.Buffer[count++];
848 count++; 852 count++;
849 PHONE_DecodeBitmap(GSM_NokiaOperatorLogo,msg.Buffer+count,Data->Bitmap); 853 PHONE_DecodeBitmap(GSM_NokiaOperatorLogo,msg.Buffer+count,Data->Bitmap);
850 return ERR_NONE; 854 return ERR_NONE;
851} 855}
852 856
853static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s) 857static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s)
854{ 858{
855 int i, count = 5; 859 int i, count = 5;
856 GSM_Phone_Data *Data = &s->Phone.Data; 860 GSM_Phone_Data *Data = &s->Phone.Data;
857 861
858 smprintf(s, "Startup logo & notes received\n"); 862 smprintf(s, "Startup logo & notes received\n");
859 for (i=0;i<msg.Buffer[4];i++) { 863 for (i=0;i<msg.Buffer[4];i++) {
860 switch (msg.Buffer[count++]) { 864 switch (msg.Buffer[count++]) {
861 case 0x01: 865 case 0x01:
862 smprintf(s, "Startup logo\n"); 866 smprintf(s, "Startup logo\n");
863 if (Data->Bitmap->Type == GSM_StartupLogo) { 867 if (Data->Bitmap->Type == GSM_StartupLogo) {
864 Data->Bitmap->BitmapHeight = msg.Buffer[count++]; 868 Data->Bitmap->BitmapHeight = msg.Buffer[count++];
865 Data->Bitmap->BitmapWidth = msg.Buffer[count++]; 869 Data->Bitmap->BitmapWidth = msg.Buffer[count++];
866 PHONE_DecodeBitmap(GSM_NokiaStartupLogo, msg.Buffer + count, Data->Bitmap); 870 PHONE_DecodeBitmap(GSM_NokiaStartupLogo, msg.Buffer + count, Data->Bitmap);
867 } else { 871 } else {
868 count = count + 2; 872 count = count + 2;
869 } 873 }
870 count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0); 874 count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0);
871 break; 875 break;
872 case 0x02: 876 case 0x02:
873 smprintf(s, "Welcome note\n"); 877 smprintf(s, "Welcome note\n");
874 if (Data->Bitmap->Type == GSM_WelcomeNote_Text) { 878 if (Data->Bitmap->Type == GSM_WelcomeNote_Text) {
@@ -1479,133 +1483,135 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
1479 int i,end,start; 1483 int i,end,start;
1480 1484
1481 smprintf(s, "Ringtone received\n"); 1485 smprintf(s, "Ringtone received\n");
1482 switch (msg.Buffer[4]) { 1486 switch (msg.Buffer[4]) {
1483 case 0x00: 1487 case 0x00:
1484 switch (Data->Ringtone->Format) { 1488 switch (Data->Ringtone->Format) {
1485 case RING_NOTETONE: 1489 case RING_NOTETONE:
1486 memcpy(buffer,msg.Buffer,msg.Length); 1490 memcpy(buffer,msg.Buffer,msg.Length);
1487 i=7; 1491 i=7;
1488 if (buffer[9]==0x4a && buffer[10]==0x3a) i=8; 1492 if (buffer[9]==0x4a && buffer[10]==0x3a) i=8;
1489 buffer[i]=0x02; 1493 buffer[i]=0x02;
1490 error=GSM_DecodeNokiaRTTLRingtone(Data->Ringtone, buffer+i, msg.Length-i); 1494 error=GSM_DecodeNokiaRTTLRingtone(Data->Ringtone, buffer+i, msg.Length-i);
1491 if (error!=ERR_NONE) return ERR_EMPTY; 1495 if (error!=ERR_NONE) return ERR_EMPTY;
1492 return ERR_NONE; 1496 return ERR_NONE;
1493 case RING_NOKIABINARY: 1497 case RING_NOKIABINARY:
1494 i=8; 1498 i=8;
1495 while (msg.Buffer[i]!=0) { 1499 while (msg.Buffer[i]!=0) {
1496 i++; 1500 i++;
1497 if (i>msg.Length) return ERR_EMPTY; 1501 if (i>msg.Length) return ERR_EMPTY;
1498 } 1502 }
1499 EncodeUnicode(Data->Ringtone->Name,msg.Buffer+8,i-8); 1503 EncodeUnicode(Data->Ringtone->Name,msg.Buffer+8,i-8);
1500 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); 1504 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
1501 /* Looking for start && end */ 1505 /* Looking for start && end */
1502 end=0;start=0;i=0; 1506 end=0;start=0;i=0;
1503 while (true) { 1507 while (true) {
1504 if (start!=0) { 1508 if (start!=0) {
1505 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { 1509 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
1506 end=i+2; break; 1510 end=i+2; break;
1507 } 1511 }
1508 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) { 1512 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
1509 end=i+2; break; 1513 end=i+2; break;
1510 } 1514 }
1511 } else { 1515 } else {
1512 if (msg.Buffer[i]==0x02 && msg.Buffer[i+1]==0xfc && msg.Buffer[i+2]==0x09) { 1516 if (msg.Buffer[i]==0x02 && msg.Buffer[i+1]==0xfc && msg.Buffer[i+2]==0x09) {
1513 start = i; 1517 start = i;
1514 } 1518 }
1515 } 1519 }
1516 i++; 1520 i++;
1517 if (i==msg.Length-3) return ERR_EMPTY; 1521 if (i==msg.Length-3) return ERR_EMPTY;
1518 } 1522 }
1519 /* Copying frame */ 1523 /* Copying frame */
1520 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start); 1524 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start);
1521 Data->Ringtone->NokiaBinary.Length=end-start; 1525 Data->Ringtone->NokiaBinary.Length=end-start;
1522#ifdef DEBUG 1526#ifdef DEBUG
1523 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length); 1527 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length);
1524#endif 1528#endif
1525 return ERR_NONE; 1529 return ERR_NONE;
1526 case RING_MIDI: 1530 case RING_MIDI:
1531 case RING_MMF:
1527 return ERR_NOTSUPPORTED; 1532 return ERR_NOTSUPPORTED;
1528 } 1533 }
1529 smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format); 1534 smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format);
1530 break; 1535 break;
1531 default: 1536 default:
1532 smprintf(s, "Invalid location. Too high ?\n"); 1537 smprintf(s, "Invalid location. Too high ?\n");
1533 return ERR_INVALIDLOCATION; 1538 return ERR_INVALIDLOCATION;
1534 } 1539 }
1535 return ERR_UNKNOWNRESPONSE; 1540 return ERR_UNKNOWNRESPONSE;
1536} 1541}
1537 1542
1538static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 1543static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
1539{ 1544{
1540 GSM_Error error; 1545 GSM_Error error;
1541 unsigned char req[] = {0x00, 0x01, 0x9e, 1546 unsigned char req[] = {0x00, 0x01, 0x9e,
1542 0x00}; /* location */ 1547 0x00}; /* location */
1543 1548
1544 if (PhoneRingtone) return ERR_NOTSUPPORTED; 1549 if (PhoneRingtone) return ERR_NOTSUPPORTED;
1545 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NORING)) return ERR_NOTSUPPORTED; 1550 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NORING)) return ERR_NOTSUPPORTED;
1546 if (Ringtone->Location == 0) return ERR_INVALIDLOCATION; 1551 if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
1547 1552
1548 if (Ringtone->Format == 0x00) { 1553 if (Ringtone->Format == 0x00) {
1549 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) { 1554 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) {
1550 Ringtone->Format = RING_NOTETONE; 1555 Ringtone->Format = RING_NOTETONE;
1551 } else { 1556 } else {
1552 Ringtone->Format = RING_NOKIABINARY; 1557 Ringtone->Format = RING_NOKIABINARY;
1553 } 1558 }
1554 } 1559 }
1555 1560
1556 switch (Ringtone->Format) { 1561 switch (Ringtone->Format) {
1557 case RING_NOTETONE: 1562 case RING_NOTETONE:
1558 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; 1563 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
1559 break; 1564 break;
1560 case RING_NOKIABINARY: 1565 case RING_NOKIABINARY:
1561 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; 1566 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
1562 break; 1567 break;
1563 case RING_MIDI: 1568 case RING_MIDI:
1569 case RING_MMF:
1564 return ERR_NOTSUPPORTED; 1570 return ERR_NOTSUPPORTED;
1565 } 1571 }
1566 1572
1567 error=DCT3_EnableSecurity (s, 0x01); 1573 error=DCT3_EnableSecurity (s, 0x01);
1568 if (error!=ERR_NONE) return error; 1574 if (error!=ERR_NONE) return error;
1569 1575
1570 req[3]=Ringtone->Location-1; 1576 req[3]=Ringtone->Location-1;
1571 s->Phone.Data.Ringtone=Ringtone; 1577 s->Phone.Data.Ringtone=Ringtone;
1572 smprintf(s, "Getting (binary) ringtone\n"); 1578 smprintf(s, "Getting (binary) ringtone\n");
1573 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone); 1579 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone);
1574} 1580}
1575 1581
1576static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 1582static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
1577{ 1583{
1578 *s->Phone.Data.SecurityStatus = msg.Buffer[4]; 1584 *s->Phone.Data.SecurityStatus = msg.Buffer[4];
1579 1585
1580#ifdef DEBUG 1586#ifdef DEBUG
1581 smprintf(s, "Security code status\n"); 1587 smprintf(s, "Security code status\n");
1582 switch(msg.Buffer[4]) { 1588 switch(msg.Buffer[4]) {
1583 case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break; 1589 case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break;
1584 case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break; 1590 case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break;
1585 case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break; 1591 case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break;
1586 case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break; 1592 case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break;
1587 case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break; 1593 case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break;
1588 case SEC_None : smprintf(s, "nothing to enter.\n"); break; 1594 case SEC_None : smprintf(s, "nothing to enter.\n"); break;
1589 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 1595 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
1590 return ERR_UNKNOWNRESPONSE; 1596 return ERR_UNKNOWNRESPONSE;
1591 } 1597 }
1592#endif 1598#endif
1593 return ERR_NONE; 1599 return ERR_NONE;
1594} 1600}
1595 1601
1596static GSM_Error N6110_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) 1602static GSM_Error N6110_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
1597{ 1603{
1598 unsigned char req[4] = {N6110_FRAME_HEADER, 0x07}; 1604 unsigned char req[4] = {N6110_FRAME_HEADER, 0x07};
1599 1605
1600 s->Phone.Data.SecurityStatus=Status; 1606 s->Phone.Data.SecurityStatus=Status;
1601 smprintf(s, "Getting security code status\n"); 1607 smprintf(s, "Getting security code status\n");
1602 return GSM_WaitFor (s, req, 4, 0x08, 2, ID_GetSecurityStatus); 1608 return GSM_WaitFor (s, req, 4, 0x08, 2, ID_GetSecurityStatus);
1603} 1609}
1604 1610
1605static GSM_Error N6110_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) 1611static GSM_Error N6110_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
1606{ 1612{
1607 switch (msg.Buffer[3]) { 1613 switch (msg.Buffer[3]) {
1608 case 0x0b: 1614 case 0x0b:
1609 smprintf(s, "Security code OK\n"); 1615 smprintf(s, "Security code OK\n");
1610 return ERR_NONE; 1616 return ERR_NONE;
1611 case 0x0c: 1617 case 0x0c:
@@ -2398,98 +2404,98 @@ static GSM_Error N6110_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateM
2398 } 2404 }
2399 } 2405 }
2400 return ERR_NONE; 2406 return ERR_NONE;
2401 case 0x93: 2407 case 0x93:
2402 smprintf(s, "Can't get calendar note - too high location?\n"); 2408 smprintf(s, "Can't get calendar note - too high location?\n");
2403 return ERR_INVALIDLOCATION; 2409 return ERR_INVALIDLOCATION;
2404 } 2410 }
2405 return ERR_UNKNOWNRESPONSE; 2411 return ERR_UNKNOWNRESPONSE;
2406} 2412}
2407 2413
2408static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 2414static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
2409{ 2415{
2410 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; 2416 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
2411 GSM_Error error; 2417 GSM_Error error;
2412 GSM_DateTime date_time; 2418 GSM_DateTime date_time;
2413 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; 2419 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
2414 unsigned char req[] = {N6110_FRAME_HEADER, 0x66, 2420 unsigned char req[] = {N6110_FRAME_HEADER, 0x66,
2415 0x00}; /* Location */ 2421 0x00}; /* Location */
2416 2422
2417 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED; 2423 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED;
2418 2424
2419 if (start) { 2425 if (start) {
2420 Priv->LastCalendarPos = 1; 2426 Priv->LastCalendarPos = 1;
2421 } else { 2427 } else {
2422 Priv->LastCalendarPos++; 2428 Priv->LastCalendarPos++;
2423 } 2429 }
2424 2430
2425 Note->Location = Priv->LastCalendarPos; 2431 Note->Location = Priv->LastCalendarPos;
2426 req[4] = Priv->LastCalendarPos; 2432 req[4] = Priv->LastCalendarPos;
2427 2433
2428 s->Phone.Data.Cal=Note; 2434 s->Phone.Data.Cal=Note;
2429 smprintf(s, "Getting calendar note\n"); 2435 smprintf(s, "Getting calendar note\n");
2430 error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote); 2436 error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote);
2431 2437
2432 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); 2438 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
2433 /* 2090 year is set for example in 3310 */ 2439 /* 2090 year is set for example in 3310 */
2434 if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) { 2440 if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) {
2435 error=N6110_GetDateTime(s, &date_time); 2441 error=N6110_GetDateTime(s, &date_time);
2436 if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year; 2442 if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year;
2437 } 2443 }
2438 return error; 2444 return error;
2439} 2445}
2440 2446
2441GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 2447GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
2442{ 2448{
2443 unsigned char buffer[2000],buffer2[4000]; 2449 unsigned char buffer[2000],buffer2[4000];
2444 int tmp; 2450 int tmp;
2445 2451
2446 tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer); 2452 tmp=GSM_UnpackEightBitsToSeven(0, msg.Buffer[7], 82, msg.Buffer+8, buffer);
2447 msg.Buffer[tmp] = 0; 2453 buffer[tmp] = 0;
2448 2454
2449 smprintf(s, "USSD reply: \"%s\"\n",buffer); 2455 smprintf(s, "USSD reply: \"%s\"\n",buffer);
2450 2456
2451 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) { 2457 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
2452 EncodeUnicode(buffer2,buffer,strlen(buffer)); 2458 EncodeUnicode(buffer2,buffer,strlen(buffer));
2453 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2); 2459 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
2454 } 2460 }
2455 2461
2456 return ERR_NONE; 2462 return ERR_NONE;
2457} 2463}
2458 2464
2459GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all) 2465GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
2460{ 2466{
2461 GSM_Error error; 2467 GSM_Error error;
2462 unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01, 2468 unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01,
2463 0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8, 2469 0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8,
2464 0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15, 2470 0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15,
2465 0x63, 0x80}; 2471 0x63, 0x80};
2466 2472
2467 if (!all) { 2473 if (!all) {
2468 smprintf(s, "Answering call part 1\n"); 2474 smprintf(s, "Answering call part 1\n");
2469 error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall); 2475 error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall);
2470 if (error != ERR_NONE) return error; 2476 if (error != ERR_NONE) return error;
2471 return DCT3DCT4_AnswerCall(s,ID); 2477 return DCT3DCT4_AnswerCall(s,ID);
2472 } 2478 }
2473 2479
2474 return DCT3_AnswerAllCalls(s); 2480 return DCT3_AnswerAllCalls(s);
2475} 2481}
2476 2482
2477static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 2483static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
2478{ 2484{
2479 unsigned int pos = 4; 2485 unsigned int pos = 4;
2480 unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 2486 unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
2481 0x0c}; /* Length of number */ 2487 0x0c}; /* Length of number */
2482 2488
2483 if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber); 2489 if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber);
2484 2490
2485 req[pos++] = strlen(number); 2491 req[pos++] = strlen(number);
2486 memcpy(req+pos,number,strlen(number)); 2492 memcpy(req+pos,number,strlen(number));
2487 pos += strlen(number); 2493 pos += strlen(number);
2488 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ 2494 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
2489 req[pos++] = 0x01; 2495 req[pos++] = 0x01;
2490 req[pos++] = 0x01; 2496 req[pos++] = 0x01;
2491 req[pos++] = 0x05; 2497 req[pos++] = 0x05;
2492 req[pos++] = 0x81; 2498 req[pos++] = 0x81;
2493 switch (ShowNumber) { 2499 switch (ShowNumber) {
2494 case GSM_CALL_HideNumber: 2500 case GSM_CALL_HideNumber:
2495 req[pos++] = 0x02; 2501 req[pos++] = 0x02;
@@ -2762,123 +2768,124 @@ GSM_Phone_Functions N6110Phone = {
2762 NOKIA_GetManufacturer, 2768 NOKIA_GetManufacturer,
2763 DCT3DCT4_GetModel, 2769 DCT3DCT4_GetModel,
2764 DCT3DCT4_GetFirmware, 2770 DCT3DCT4_GetFirmware,
2765 DCT3_GetIMEI, 2771 DCT3_GetIMEI,
2766 DCT3_GetOriginalIMEI, 2772 DCT3_GetOriginalIMEI,
2767 DCT3_GetManufactureMonth, 2773 DCT3_GetManufactureMonth,
2768 DCT3_GetProductCode, 2774 DCT3_GetProductCode,
2769 DCT3_GetHardware, 2775 DCT3_GetHardware,
2770 DCT3_GetPPM, 2776 DCT3_GetPPM,
2771 NOTSUPPORTED, /* GetSIMIMSI */ 2777 NOTSUPPORTED, /* GetSIMIMSI */
2772 N6110_GetDateTime, 2778 N6110_GetDateTime,
2773 N6110_SetDateTime, 2779 N6110_SetDateTime,
2774 N6110_GetAlarm, 2780 N6110_GetAlarm,
2775 N6110_SetAlarm, 2781 N6110_SetAlarm,
2776 NOTSUPPORTED, /* GetLocale */ 2782 NOTSUPPORTED, /* GetLocale */
2777 NOTSUPPORTED, /* SetLocale */ 2783 NOTSUPPORTED, /* SetLocale */
2778 DCT3_PressKey, 2784 DCT3_PressKey,
2779 DCT3_Reset, 2785 DCT3_Reset,
2780 N61_71_ResetPhoneSettings, 2786 N61_71_ResetPhoneSettings,
2781 N6110_EnterSecurityCode, 2787 N6110_EnterSecurityCode,
2782 N6110_GetSecurityStatus, 2788 N6110_GetSecurityStatus,
2783 N6110_GetDisplayStatus, 2789 N6110_GetDisplayStatus,
2784 NOTIMPLEMENTED, /* SetAutoNetworkLogin */ 2790 NOTIMPLEMENTED, /* SetAutoNetworkLogin */
2785 N6110_GetBatteryCharge, 2791 N6110_GetBatteryCharge,
2786 N6110_GetSignalQuality, 2792 N6110_GetSignalQuality,
2787 DCT3_GetNetworkInfo, 2793 DCT3_GetNetworkInfo,
2788 NOTSUPPORTED, /* GetCategory */ 2794 NOTSUPPORTED, /* GetCategory */
2789 NOTSUPPORTED, /* AddCategory */ 2795 NOTSUPPORTED, /* AddCategory */
2790 NOTSUPPORTED, /* GetCategoryStatus */ 2796 NOTSUPPORTED, /* GetCategoryStatus */
2791 N6110_GetMemoryStatus, 2797 N6110_GetMemoryStatus,
2792 N6110_GetMemory, 2798 N6110_GetMemory,
2793 NOTIMPLEMENTED, /* GetNextMemory */ 2799 NOTIMPLEMENTED, /* GetNextMemory */
2794 N6110_SetMemory, 2800 N6110_SetMemory,
2795 NOTIMPLEMENTED, /* AddMemory */ 2801 NOTIMPLEMENTED, /* AddMemory */
2796 N6110_DeleteMemory, 2802 N6110_DeleteMemory,
2797 NOTIMPLEMENTED, /* DeleteAllMemory */ 2803 NOTIMPLEMENTED, /* DeleteAllMemory */
2798 N6110_GetSpeedDial, 2804 N6110_GetSpeedDial,
2799 NOTIMPLEMENTED, /* SetSpeedDial */ 2805 NOTIMPLEMENTED, /* SetSpeedDial */
2800 DCT3_GetSMSC, 2806 DCT3_GetSMSC,
2801 DCT3_SetSMSC, 2807 DCT3_SetSMSC,
2802 DCT3_GetSMSStatus, 2808 DCT3_GetSMSStatus,
2803 N6110_GetSMSMessage, 2809 N6110_GetSMSMessage,
2804 N6110_GetNextSMSMessage, 2810 N6110_GetNextSMSMessage,
2805 N6110_SetSMS, 2811 N6110_SetSMS,
2806 N6110_AddSMS, 2812 N6110_AddSMS,
2807 N6110_DeleteSMSMessage, 2813 N6110_DeleteSMSMessage,
2808 DCT3_SendSMSMessage, 2814 DCT3_SendSMSMessage,
2809 NOTSUPPORTED, /* SendSavedSMS */ 2815 NOTSUPPORTED, /* SendSavedSMS */
2816 NOTSUPPORTED, /* SetFastSMSSending*/
2810 NOKIA_SetIncomingSMS, 2817 NOKIA_SetIncomingSMS,
2811 DCT3_SetIncomingCB, 2818 DCT3_SetIncomingCB,
2812 PHONE_GetSMSFolders, 2819 PHONE_GetSMSFolders,
2813 NOTSUPPORTED, /* AddSMSFolder */ 2820 NOTSUPPORTED, /* AddSMSFolder */
2814 NOTSUPPORTED, /* DeleteSMSFolder */ 2821 NOTSUPPORTED, /* DeleteSMSFolder */
2815 N6110_DialVoice, 2822 N6110_DialVoice,
2816 N6110_AnswerCall, 2823 N6110_AnswerCall,
2817 DCT3_CancelCall, 2824 DCT3_CancelCall,
2818 N6110_HoldCall, 2825 N6110_HoldCall,
2819 N6110_UnholdCall, 2826 N6110_UnholdCall,
2820 N6110_ConferenceCall, 2827 N6110_ConferenceCall,
2821 N6110_SplitCall, 2828 N6110_SplitCall,
2822 N6110_TransferCall, 2829 N6110_TransferCall,
2823 N6110_SwitchCall, 2830 N6110_SwitchCall,
2824 DCT3DCT4_GetCallDivert, 2831 DCT3DCT4_GetCallDivert,
2825 DCT3DCT4_SetCallDivert, 2832 DCT3DCT4_SetCallDivert,
2826 DCT3DCT4_CancelAllDiverts, 2833 DCT3DCT4_CancelAllDiverts,
2827 NOKIA_SetIncomingCall, 2834 NOKIA_SetIncomingCall,
2828 NOKIA_SetIncomingUSSD, 2835 NOKIA_SetIncomingUSSD,
2829 DCT3DCT4_SendDTMF, 2836 DCT3DCT4_SendDTMF,
2830 N6110_GetRingtone, 2837 N6110_GetRingtone,
2831 N6110_SetRingtone, 2838 N6110_SetRingtone,
2832 NOTSUPPORTED, /* GetRingtonesInfo */ 2839 NOTSUPPORTED, /* GetRingtonesInfo */
2833 NOTSUPPORTED, /* DeleteUserRingtones */ 2840 NOTSUPPORTED, /* DeleteUserRingtones */
2834 DCT3_PlayTone, 2841 DCT3_PlayTone,
2835 DCT3_GetWAPBookmark, 2842 DCT3_GetWAPBookmark,
2836 DCT3_SetWAPBookmark, 2843 DCT3_SetWAPBookmark,
2837 DCT3_DeleteWAPBookmark, 2844 DCT3_DeleteWAPBookmark,
2838 DCT3_GetWAPSettings, 2845 DCT3_GetWAPSettings,
2839 DCT3_SetWAPSettings, 2846 DCT3_SetWAPSettings,
2840 NOTSUPPORTED, /* GetMMSSettings */ 2847 NOTSUPPORTED, /* GetMMSSettings */
2841 NOTSUPPORTED, /* SetMMSSettings */ 2848 NOTSUPPORTED, /* SetMMSSettings */
2842 NOTSUPPORTED, /* GetSyncMLSettings*/ 2849 NOTSUPPORTED, /* GetSyncMLSettings*/
2843 NOTSUPPORTED, /* SetSyncMLSettings*/ 2850 NOTSUPPORTED, /* SetSyncMLSettings*/
2844 NOTSUPPORTED, /* GetChatSettings */ 2851 NOTSUPPORTED, /* GetChatSettings */
2845 NOTSUPPORTED, /* SetChatSettings */ 2852 NOTSUPPORTED, /* SetChatSettings */
2846 N6110_GetBitmap, 2853 N6110_GetBitmap,
2847 N6110_SetBitmap, 2854 N6110_SetBitmap,
2848 NOTSUPPORTED, /* GetToDoStatus */ 2855 NOTSUPPORTED, /* GetToDoStatus */
2849 NOTSUPPORTED, /* GetToDo */ 2856 NOTSUPPORTED, /* GetToDo */
2850 NOTSUPPORTED, /* GetNextToDo */ 2857 NOTSUPPORTED, /* GetNextToDo */
2851 NOTSUPPORTED, /* SetToDo */ 2858 NOTSUPPORTED, /* SetToDo */
2852 NOTSUPPORTED, /* AddToDo */ 2859 NOTSUPPORTED, /* AddToDo */
2853 NOTSUPPORTED, /* DeleteToDo */ 2860 NOTSUPPORTED, /* DeleteToDo */
2854 NOTSUPPORTED, /* DeleteAllToDo */ 2861 NOTSUPPORTED, /* DeleteAllToDo */
2855 NOTIMPLEMENTED, /* GetCalendarStatus */ 2862 NOTIMPLEMENTED, /* GetCalendarStatus */
2856 NOTIMPLEMENTED, /* GetCalendar */ 2863 NOTIMPLEMENTED, /* GetCalendar */
2857 N6110_GetNextCalendarNote, 2864 N6110_GetNextCalendarNote,
2858 NOTIMPLEMENTED, /* SetCalendar */ 2865 NOTIMPLEMENTED, /* SetCalendar */
2859 N6110_AddCalendarNote, 2866 N6110_AddCalendarNote,
2860 N6110_DeleteCalendarNote, 2867 N6110_DeleteCalendarNote,
2861 NOTIMPLEMENTED, /* DeleteAllCalendar */ 2868 NOTIMPLEMENTED, /* DeleteAllCalendar */
2862 NOTSUPPORTED, /* GetCalendarSettings */ 2869 NOTSUPPORTED, /* GetCalendarSettings */
2863 NOTSUPPORTED, /* SetCalendarSettings */ 2870 NOTSUPPORTED, /* SetCalendarSettings */
2864 NOTSUPPORTED, /* GetNote */ 2871 NOTSUPPORTED, /* GetNextNote */
2865 N6110_GetProfile, 2872 N6110_GetProfile,
2866 N6110_SetProfile, 2873 N6110_SetProfile,
2867 NOTSUPPORTED, /* GetFMStation */ 2874 NOTSUPPORTED, /* GetFMStation */
2868 NOTSUPPORTED, /* SetFMStation */ 2875 NOTSUPPORTED, /* SetFMStation */
2869 NOTSUPPORTED, /* ClearFMStations */ 2876 NOTSUPPORTED, /* ClearFMStations */
2870 NOTSUPPORTED, /* GetNextFileFolder */ 2877 NOTSUPPORTED, /* GetNextFileFolder */
2871 NOTSUPPORTED, /* GetFilePart */ 2878 NOTSUPPORTED, /* GetFilePart */
2872 NOTSUPPORTED, /* AddFile */ 2879 NOTSUPPORTED, /* AddFile */
2873 NOTSUPPORTED, /* GetFileSystemStatus */ 2880 NOTSUPPORTED, /* GetFileSystemStatus */
2874 NOTSUPPORTED, /* DeleteFile */ 2881 NOTSUPPORTED, /* DeleteFile */
2875 NOTSUPPORTED, /* AddFolder */ 2882 NOTSUPPORTED, /* AddFolder */
2876 NOTSUPPORTED, /* GetGPRSAccessPoint */ 2883 NOTSUPPORTED, /* GetGPRSAccessPoint */
2877 NOTSUPPORTED /* SetGPRSAccessPoint */ 2884 NOTSUPPORTED /* SetGPRSAccessPoint */
2878}; 2885};
2879 2886
2880#endif 2887#endif
2881 2888
2882/* How should editor hadle tabs in this file? Add editor commands here. 2889/* How should editor hadle tabs in this file? Add editor commands here.
2883 * vim: noexpandtab sw=8 ts=8 sts=8: 2890 * vim: noexpandtab sw=8 ts=8 sts=8:
2884 */ 2891 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
index 5a02c9c..b597f9b 100644
--- a/gammu/emb/common/phone/nokia/dct3/n7110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -1,50 +1,53 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail and Gnokii */ 2/* based on some Markus Plail work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
4#include "../../../gsmstate.h" 7#include "../../../gsmstate.h"
5 8
6#ifdef GSM_ENABLE_NOKIA7110 9#ifdef GSM_ENABLE_NOKIA7110
7 10
8#include <string.h> 11#include <string.h>
9#include <time.h> 12#include <time.h>
10 13
11#include "../../../misc/coding/coding.h" 14#include "../../../misc/coding/coding.h"
12#include "../../../gsmcomon.h" 15#include "../../../gsmcomon.h"
13#include "../../../service/gsmlogo.h" 16#include "../../../service/gsmlogo.h"
14#include "../../pfunc.h" 17#include "../../pfunc.h"
15#include "../nfunc.h" 18#include "../nfunc.h"
16#include "../nfuncold.h" 19#include "../nfuncold.h"
17#include "n7110.h" 20#include "n7110.h"
18#include "dct3func.h" 21#include "dct3func.h"
19 22
20static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 23static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
21{ 24{
22 return DCT3_GetAlarm(s, alarm, 0x19); 25 return DCT3_GetAlarm(s, alarm, 0x19);
23} 26}
24 27
25static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 28static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
26{ 29{
27 return DCT3_SetAlarm(s, alarm, 0x19); 30 return DCT3_SetAlarm(s, alarm, 0x19);
28} 31}
29 32
30static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 33static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
31{ 34{
32 GSM_Phone_Data *Data = &s->Phone.Data; 35 GSM_Phone_Data *Data = &s->Phone.Data;
33 36
34 smprintf(s, "Phonebook entry received\n"); 37 smprintf(s, "Phonebook entry received\n");
35 switch (msg.Buffer[6]) { 38 switch (msg.Buffer[6]) {
36 case 0x0f: 39 case 0x0f:
37 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); 40 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
38 default: 41 default:
39 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false); 42 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false);
40 } 43 }
41 return ERR_UNKNOWN; 44 return ERR_UNKNOWN;
42} 45}
43 46
44static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) 47static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
45{ 48{
46 unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 49 unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
47 0x02, /* memory type */ 50 0x02, /* memory type */
48 0x05, 51 0x05,
49 0x00, 0x00,/* location */ 52 0x00, 0x00,/* location */
50 0x00, 0x00}; 53 0x00, 0x00};
@@ -481,96 +484,97 @@ static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
481 tmp=0;i=4; 484 tmp=0;i=4;
482 while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) { 485 while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) {
483 tmp++; 486 tmp++;
484 i=i+2; 487 i=i+2;
485 if (i>msg.Length) return ERR_EMPTY; 488 if (i>msg.Length) return ERR_EMPTY;
486 } 489 }
487 memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2); 490 memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2);
488 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); 491 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
489 /* Looking for end */ 492 /* Looking for end */
490 i=37; 493 i=37;
491 while (true) { 494 while (true) {
492 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { 495 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
493 i=i+2; break; 496 i=i+2; break;
494 } 497 }
495 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) { 498 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
496 i=i+2; break; 499 i=i+2; break;
497 } 500 }
498 i++; 501 i++;
499 if (i==msg.Length) return ERR_EMPTY; 502 if (i==msg.Length) return ERR_EMPTY;
500 } 503 }
501 /* Copying frame */ 504 /* Copying frame */
502 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37); 505 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37);
503 Data->Ringtone->NokiaBinary.Length=i-37; 506 Data->Ringtone->NokiaBinary.Length=i-37;
504 return ERR_NONE; 507 return ERR_NONE;
505 case 0x24: 508 case 0x24:
506 smprintf(s, "Invalid location. Too high ?\n"); 509 smprintf(s, "Invalid location. Too high ?\n");
507 return ERR_INVALIDLOCATION; 510 return ERR_INVALIDLOCATION;
508 } 511 }
509 return ERR_UNKNOWNRESPONSE; 512 return ERR_UNKNOWNRESPONSE;
510} 513}
511 514
512static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 515static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
513{ 516{
514 unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00}; 517 unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00};
515 518
516 if (PhoneRingtone) return ERR_NOTSUPPORTED; 519 if (PhoneRingtone) return ERR_NOTSUPPORTED;
517 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY; 520 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
518 521
519 switch (Ringtone->Format) { 522 switch (Ringtone->Format) {
520 case RING_NOTETONE: 523 case RING_NOTETONE:
521 /* In the future get binary and convert */ 524 /* In the future get binary and convert */
522 return ERR_NOTSUPPORTED; 525 return ERR_NOTSUPPORTED;
523 case RING_NOKIABINARY: 526 case RING_NOKIABINARY:
524 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location; 527 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
525 s->Phone.Data.Ringtone=Ringtone; 528 s->Phone.Data.Ringtone=Ringtone;
526 smprintf(s, "Getting binary ringtone\n"); 529 smprintf(s, "Getting binary ringtone\n");
527 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone); 530 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
528 case RING_MIDI: 531 case RING_MIDI:
532 case RING_MMF:
529 return ERR_NOTSUPPORTED; 533 return ERR_NOTSUPPORTED;
530 } 534 }
531 return ERR_NOTSUPPORTED; 535 return ERR_NOTSUPPORTED;
532} 536}
533 537
534static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 538static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
535{ 539{
536 int i; 540 int i;
537 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110; 541 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
538 542
539 smprintf(s, "Received info for Picture Images\n"); 543 smprintf(s, "Received info for Picture Images\n");
540 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]); 544 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
541 smprintf(s, "Locations :"); 545 smprintf(s, "Locations :");
542 Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5]; 546 Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
543 for (i=0;i<Priv->LastPictureImageFolder.Number;i++) { 547 for (i=0;i<Priv->LastPictureImageFolder.Number;i++) {
544 Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2]; 548 Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2];
545 smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]); 549 smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]);
546 } 550 }
547 smprintf(s, "\n"); 551 smprintf(s, "\n");
548 return ERR_NONE; 552 return ERR_NONE;
549} 553}
550 554
551static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location) 555static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location)
552{ 556{
553 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110; 557 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
554 GSM_SMSFolders folders; 558 GSM_SMSFolders folders;
555 GSM_Error error; 559 GSM_Error error;
556 int i, j = 0, count = 0; 560 int i, j = 0, count = 0;
557 unsigned char req[] = {N6110_FRAME_HEADER, 0x96, 561 unsigned char req[] = {N6110_FRAME_HEADER, 0x96,
558 0x00, /* Folder ID */ 562 0x00, /* Folder ID */
559 0x0f, 0x07}; 563 0x0f, 0x07};
560 564
561 error=N7110_GetSMSFolders (s, &folders); 565 error=N7110_GetSMSFolders (s, &folders);
562 if (error!=ERR_NONE) return error; 566 if (error!=ERR_NONE) return error;
563 567
564 for (i=0;i<folders.Number;i++) { 568 for (i=0;i<folders.Number;i++) {
565 req[4] = (i+1) * 0x08;/* SMS folder ID */ 569 req[4] = (i+1) * 0x08;/* SMS folder ID */
566 error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap); 570 error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap);
567 if (error!=ERR_NONE) return error; 571 if (error!=ERR_NONE) return error;
568 for (j=0;j<Priv->LastPictureImageFolder.Number;j++) { 572 for (j=0;j<Priv->LastPictureImageFolder.Number;j++) {
569 count++; 573 count++;
570 if (count==Bitmap->Location) break; 574 if (count==Bitmap->Location) break;
571 } 575 }
572 if (count==Bitmap->Location) break; 576 if (count==Bitmap->Location) break;
573 } 577 }
574 if (count!=Bitmap->Location) return ERR_INVALIDLOCATION; 578 if (count!=Bitmap->Location) return ERR_INVALIDLOCATION;
575 *folder = (i+1) * 0x08;/* SMS Folder ID */ 579 *folder = (i+1) * 0x08;/* SMS Folder ID */
576 *location= Priv->LastPictureImageFolder.Location[j]; 580 *location= Priv->LastPictureImageFolder.Location[j];
@@ -1602,123 +1606,124 @@ GSM_Phone_Functions N7110Phone = {
1602 NOKIA_GetManufacturer, 1606 NOKIA_GetManufacturer,
1603 DCT3DCT4_GetModel, 1607 DCT3DCT4_GetModel,
1604 DCT3DCT4_GetFirmware, 1608 DCT3DCT4_GetFirmware,
1605 DCT3_GetIMEI, 1609 DCT3_GetIMEI,
1606 DCT3_GetOriginalIMEI, 1610 DCT3_GetOriginalIMEI,
1607 DCT3_GetManufactureMonth, 1611 DCT3_GetManufactureMonth,
1608 DCT3_GetProductCode, 1612 DCT3_GetProductCode,
1609 DCT3_GetHardware, 1613 DCT3_GetHardware,
1610 DCT3_GetPPM, 1614 DCT3_GetPPM,
1611 NOTSUPPORTED, /* GetSIMIMSI */ 1615 NOTSUPPORTED, /* GetSIMIMSI */
1612 N71_92_GetDateTime, 1616 N71_92_GetDateTime,
1613 N71_92_SetDateTime, 1617 N71_92_SetDateTime,
1614 N7110_GetAlarm, 1618 N7110_GetAlarm,
1615 N7110_SetAlarm, 1619 N7110_SetAlarm,
1616 NOTSUPPORTED, /* GetLocale */ 1620 NOTSUPPORTED, /* GetLocale */
1617 NOTSUPPORTED, /* SetLocale */ 1621 NOTSUPPORTED, /* SetLocale */
1618 DCT3_PressKey, 1622 DCT3_PressKey,
1619 DCT3_Reset, 1623 DCT3_Reset,
1620 N61_71_ResetPhoneSettings, 1624 N61_71_ResetPhoneSettings,
1621 NOTSUPPORTED, /* EnterSecurityCode*/ 1625 NOTSUPPORTED, /* EnterSecurityCode*/
1622 NOTSUPPORTED, /* GetSecurityStatus*/ 1626 NOTSUPPORTED, /* GetSecurityStatus*/
1623 NOTSUPPORTED, /* GetDisplayStatus*/ 1627 NOTSUPPORTED, /* GetDisplayStatus*/
1624 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 1628 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
1625 N71_92_GetBatteryCharge, 1629 N71_92_GetBatteryCharge,
1626 N71_92_GetSignalQuality, 1630 N71_92_GetSignalQuality,
1627 DCT3_GetNetworkInfo, 1631 DCT3_GetNetworkInfo,
1628 NOTSUPPORTED, /* GetCategory */ 1632 NOTSUPPORTED, /* GetCategory */
1629 NOTSUPPORTED, /* AddCategory */ 1633 NOTSUPPORTED, /* AddCategory */
1630 NOTSUPPORTED, /* GetCategoryStatus */ 1634 NOTSUPPORTED, /* GetCategoryStatus */
1631 N7110_GetMemoryStatus, 1635 N7110_GetMemoryStatus,
1632 N7110_GetMemory, 1636 N7110_GetMemory,
1633 NOTIMPLEMENTED, /* GetNextMemory */ 1637 NOTIMPLEMENTED, /* GetNextMemory */
1634 N7110_SetMemory, 1638 N7110_SetMemory,
1635 NOTIMPLEMENTED, /* AddMemory */ 1639 NOTIMPLEMENTED, /* AddMemory */
1636 N7110_DeleteMemory, 1640 N7110_DeleteMemory,
1637 NOTIMPLEMENTED, /* DeleteAllMemory */ 1641 NOTIMPLEMENTED, /* DeleteAllMemory */
1638 N7110_GetSpeedDial, 1642 N7110_GetSpeedDial,
1639 NOTIMPLEMENTED, /* SetSpeedDial */ 1643 NOTIMPLEMENTED, /* SetSpeedDial */
1640 DCT3_GetSMSC, 1644 DCT3_GetSMSC,
1641 DCT3_SetSMSC, 1645 DCT3_SetSMSC,
1642 N7110_GetSMSStatus, 1646 N7110_GetSMSStatus,
1643 N7110_GetSMSMessage, 1647 N7110_GetSMSMessage,
1644 N7110_GetNextSMSMessage, 1648 N7110_GetNextSMSMessage,
1645 N7110_SetSMS, 1649 N7110_SetSMS,
1646 N7110_AddSMS, 1650 N7110_AddSMS,
1647 N7110_DeleteSMS, 1651 N7110_DeleteSMS,
1648 DCT3_SendSMSMessage, 1652 DCT3_SendSMSMessage,
1649 NOTSUPPORTED, /* SendSavedSMS */ 1653 NOTSUPPORTED, /* SendSavedSMS */
1654 NOTSUPPORTED, /* SetFastSMSSending*/
1650 N7110_SetIncomingSMS, 1655 N7110_SetIncomingSMS,
1651 DCT3_SetIncomingCB, 1656 DCT3_SetIncomingCB,
1652 N7110_GetSMSFolders, 1657 N7110_GetSMSFolders,
1653 NOTIMPLEMENTED, /* AddSMSFolder */ 1658 NOTIMPLEMENTED, /* AddSMSFolder */
1654 NOTIMPLEMENTED, /* DeleteSMSFolder */ 1659 NOTIMPLEMENTED, /* DeleteSMSFolder */
1655 DCT3_DialVoice, 1660 DCT3_DialVoice,
1656 N7110_AnswerCall, 1661 N7110_AnswerCall,
1657 DCT3_CancelCall, 1662 DCT3_CancelCall,
1658 NOTIMPLEMENTED, /* HoldCall */ 1663 NOTIMPLEMENTED, /* HoldCall */
1659 NOTIMPLEMENTED, /* UnholdCall */ 1664 NOTIMPLEMENTED, /* UnholdCall */
1660 NOTIMPLEMENTED, /* ConferenceCall */ 1665 NOTIMPLEMENTED, /* ConferenceCall */
1661 NOTIMPLEMENTED, /* SplitCall */ 1666 NOTIMPLEMENTED, /* SplitCall */
1662 NOTIMPLEMENTED, /* TransferCall */ 1667 NOTIMPLEMENTED, /* TransferCall */
1663 NOTIMPLEMENTED, /* SwitchCall */ 1668 NOTIMPLEMENTED, /* SwitchCall */
1664 NOTSUPPORTED, /* GetCallDivert */ 1669 NOTSUPPORTED, /* GetCallDivert */
1665 N7110_SetCallDivert, 1670 N7110_SetCallDivert,
1666 N7110_CancelAllDiverts, 1671 N7110_CancelAllDiverts,
1667 N7110_SetIncomingCall, 1672 N7110_SetIncomingCall,
1668 N7110_SetIncomingUSSD, 1673 N7110_SetIncomingUSSD,
1669 DCT3DCT4_SendDTMF, 1674 DCT3DCT4_SendDTMF,
1670 N7110_GetRingtone, 1675 N7110_GetRingtone,
1671 N7110_SetRingtone, 1676 N7110_SetRingtone,
1672 NOTSUPPORTED, /* GetRingtonesInfo*/ 1677 NOTSUPPORTED, /* GetRingtonesInfo*/
1673 NOTSUPPORTED, /* DeleteUserRingtones*/ 1678 NOTSUPPORTED, /* DeleteUserRingtones*/
1674 DCT3_PlayTone, 1679 DCT3_PlayTone,
1675 DCT3_GetWAPBookmark, 1680 DCT3_GetWAPBookmark,
1676 DCT3_SetWAPBookmark, 1681 DCT3_SetWAPBookmark,
1677 DCT3_DeleteWAPBookmark, 1682 DCT3_DeleteWAPBookmark,
1678 DCT3_GetWAPSettings, 1683 DCT3_GetWAPSettings,
1679 DCT3_SetWAPSettings, 1684 DCT3_SetWAPSettings,
1680 NOTSUPPORTED, /* GetMMSSettings */ 1685 NOTSUPPORTED, /* GetMMSSettings */
1681 NOTSUPPORTED, /* SetMMSSettings */ 1686 NOTSUPPORTED, /* SetMMSSettings */
1682 NOTSUPPORTED, /* GetSyncMLSettings*/ 1687 NOTSUPPORTED, /* GetSyncMLSettings*/
1683 NOTSUPPORTED, /* SetSyncMLSettings*/ 1688 NOTSUPPORTED, /* SetSyncMLSettings*/
1684 NOTSUPPORTED, /* GetChatSettings */ 1689 NOTSUPPORTED, /* GetChatSettings */
1685 NOTSUPPORTED, /* SetChatSettings */ 1690 NOTSUPPORTED, /* SetChatSettings */
1686 N7110_GetBitmap, 1691 N7110_GetBitmap,
1687 N7110_SetBitmap, 1692 N7110_SetBitmap,
1688 NOTSUPPORTED, /* GetToDoStatus */ 1693 NOTSUPPORTED, /* GetToDoStatus */
1689 NOTSUPPORTED, /* GetToDo */ 1694 NOTSUPPORTED, /* GetToDo */
1690 NOTSUPPORTED, /* GetNextToDo */ 1695 NOTSUPPORTED, /* GetNextToDo */
1691 NOTSUPPORTED, /* SetToDo */ 1696 NOTSUPPORTED, /* SetToDo */
1692 NOTSUPPORTED, /* AddToDo */ 1697 NOTSUPPORTED, /* AddToDo */
1693 NOTSUPPORTED, /* DeleteToDo */ 1698 NOTSUPPORTED, /* DeleteToDo */
1694 NOTSUPPORTED, /* DeleteAllToDo */ 1699 NOTSUPPORTED, /* DeleteAllToDo */
1695 N7110_GetCalendarStatus, 1700 N7110_GetCalendarStatus,
1696 NOTIMPLEMENTED, /* GetCalendar */ 1701 NOTIMPLEMENTED, /* GetCalendar */
1697 N7110_GetNextCalendar, 1702 N7110_GetNextCalendar,
1698 NOTIMPLEMENTED, /* SetCalendar */ 1703 NOTIMPLEMENTED, /* SetCalendar */
1699 N7110_AddCalendar, 1704 N7110_AddCalendar,
1700 N71_65_DelCalendar, 1705 N71_65_DelCalendar,
1701 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 1706 NOTIMPLEMENTED, /* DeleteAllCalendar*/
1702 NOTSUPPORTED, /* GetCalendarSettings*/ 1707 NOTSUPPORTED, /* GetCalendarSettings*/
1703 NOTSUPPORTED, /* SetCalendarSettings*/ 1708 NOTSUPPORTED, /* SetCalendarSettings*/
1704 NOTSUPPORTED, /* GetNote */ 1709 NOTSUPPORTED, /* GetNextNote */
1705 N7110_GetProfile, 1710 N7110_GetProfile,
1706 N7110_SetProfile, 1711 N7110_SetProfile,
1707 NOTSUPPORTED, /* GetFMStation */ 1712 NOTSUPPORTED, /* GetFMStation */
1708 NOTSUPPORTED, /* SetFMStation */ 1713 NOTSUPPORTED, /* SetFMStation */
1709 NOTSUPPORTED, /* ClearFMStations */ 1714 NOTSUPPORTED, /* ClearFMStations */
1710 NOTSUPPORTED, /* GetNextFileFolder*/ 1715 NOTSUPPORTED, /* GetNextFileFolder*/
1711 NOTSUPPORTED, /* GetFilePart */ 1716 NOTSUPPORTED, /* GetFilePart */
1712 NOTSUPPORTED, /* AddFile */ 1717 NOTSUPPORTED, /* AddFile */
1713 NOTSUPPORTED, /* GetFileSystemStatus*/ 1718 NOTSUPPORTED, /* GetFileSystemStatus*/
1714 NOTSUPPORTED, /* DeleteFile */ 1719 NOTSUPPORTED, /* DeleteFile */
1715 NOTSUPPORTED, /* AddFolder */ 1720 NOTSUPPORTED, /* AddFolder */
1716 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 1721 NOTSUPPORTED, /* GetGPRSAccessPoint*/
1717 NOTSUPPORTED /* SetGPRSAccessPoint*/ 1722 NOTSUPPORTED /* SetGPRSAccessPoint*/
1718}; 1723};
1719 1724
1720#endif 1725#endif
1721 1726
1722/* How should editor hadle tabs in this file? Add editor commands here. 1727/* How should editor hadle tabs in this file? Add editor commands here.
1723 * vim: noexpandtab sw=8 ts=8 sts=8: 1728 * vim: noexpandtab sw=8 ts=8 sts=8:
1724 */ 1729 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
index e82d530..ff71ad3 100644
--- a/gammu/emb/common/phone/nokia/dct3/n9210.c
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -274,123 +274,124 @@ GSM_Phone_Functions N9210Phone = {
274 NOKIA_GetManufacturer, 274 NOKIA_GetManufacturer,
275 DCT3DCT4_GetModel, 275 DCT3DCT4_GetModel,
276 DCT3DCT4_GetFirmware, 276 DCT3DCT4_GetFirmware,
277 DCT3_GetIMEI, 277 DCT3_GetIMEI,
278 DCT3_GetOriginalIMEI, 278 DCT3_GetOriginalIMEI,
279 DCT3_GetManufactureMonth, 279 DCT3_GetManufactureMonth,
280 DCT3_GetProductCode, 280 DCT3_GetProductCode,
281 DCT3_GetHardware, 281 DCT3_GetHardware,
282 DCT3_GetPPM, 282 DCT3_GetPPM,
283 NOTSUPPORTED, /* GetSIMIMSI */ 283 NOTSUPPORTED, /* GetSIMIMSI */
284 N71_92_GetDateTime, 284 N71_92_GetDateTime,
285 N71_92_SetDateTime, 285 N71_92_SetDateTime,
286 NOTIMPLEMENTED, /* GetAlarm */ 286 NOTIMPLEMENTED, /* GetAlarm */
287 NOTIMPLEMENTED, /* SetAlarm */ 287 NOTIMPLEMENTED, /* SetAlarm */
288 NOTSUPPORTED, /* GetLocale */ 288 NOTSUPPORTED, /* GetLocale */
289 NOTSUPPORTED, /* SetLocale */ 289 NOTSUPPORTED, /* SetLocale */
290 NOTIMPLEMENTED, /* PressKey */ 290 NOTIMPLEMENTED, /* PressKey */
291 NOTIMPLEMENTED, /* Reset */ 291 NOTIMPLEMENTED, /* Reset */
292 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 292 NOTIMPLEMENTED, /* ResetPhoneSettings*/
293 NOTSUPPORTED, /* EnterSecurityCode*/ 293 NOTSUPPORTED, /* EnterSecurityCode*/
294 NOTSUPPORTED, /* GetSecurityStatus*/ 294 NOTSUPPORTED, /* GetSecurityStatus*/
295 NOTSUPPORTED, /* GetDisplayStatus*/ 295 NOTSUPPORTED, /* GetDisplayStatus*/
296 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 296 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
297 N71_92_GetBatteryCharge, 297 N71_92_GetBatteryCharge,
298 N71_92_GetSignalQuality, 298 N71_92_GetSignalQuality,
299 DCT3_GetNetworkInfo, 299 DCT3_GetNetworkInfo,
300 NOTSUPPORTED, /* GetCategory */ 300 NOTSUPPORTED, /* GetCategory */
301 NOTSUPPORTED, /* AddCategory */ 301 NOTSUPPORTED, /* AddCategory */
302 NOTSUPPORTED, /* GetCategoryStatus */ 302 NOTSUPPORTED, /* GetCategoryStatus */
303 NOTIMPLEMENTED, /* GetMemoryStatus */ 303 NOTIMPLEMENTED, /* GetMemoryStatus */
304 NOTIMPLEMENTED, /* GetMemory */ 304 NOTIMPLEMENTED, /* GetMemory */
305 NOTIMPLEMENTED, /* GetNextMemory */ 305 NOTIMPLEMENTED, /* GetNextMemory */
306 NOTIMPLEMENTED, /* SetMemory */ 306 NOTIMPLEMENTED, /* SetMemory */
307 NOTIMPLEMENTED, /* AddMemory */ 307 NOTIMPLEMENTED, /* AddMemory */
308 NOTIMPLEMENTED, /* DeleteMemory */ 308 NOTIMPLEMENTED, /* DeleteMemory */
309 NOTIMPLEMENTED, /* DeleteAllMemory */ 309 NOTIMPLEMENTED, /* DeleteAllMemory */
310 NOTIMPLEMENTED, /* GetSpeedDial */ 310 NOTIMPLEMENTED, /* GetSpeedDial */
311 NOTIMPLEMENTED, /* SetSpeedDial */ 311 NOTIMPLEMENTED, /* SetSpeedDial */
312 DCT3_GetSMSC, 312 DCT3_GetSMSC,
313 DCT3_SetSMSC, /* FIXME: test it */ 313 DCT3_SetSMSC, /* FIXME: test it */
314 NOTIMPLEMENTED, /* GetSMSStatus */ 314 NOTIMPLEMENTED, /* GetSMSStatus */
315 NOTIMPLEMENTED, /* GetSMS */ 315 NOTIMPLEMENTED, /* GetSMS */
316 NOTIMPLEMENTED, /* GetNextSMS */ 316 NOTIMPLEMENTED, /* GetNextSMS */
317 NOTIMPLEMENTED, /* SetSMS */ 317 NOTIMPLEMENTED, /* SetSMS */
318 NOTIMPLEMENTED, /* AddSMS */ 318 NOTIMPLEMENTED, /* AddSMS */
319 NOTIMPLEMENTED, /* DeleteSMS */ 319 NOTIMPLEMENTED, /* DeleteSMS */
320 DCT3_SendSMSMessage, 320 DCT3_SendSMSMessage,
321 NOTSUPPORTED, /* SendSavedSMS */ 321 NOTSUPPORTED, /* SendSavedSMS */
322 NOTSUPPORTED, /* SetFastSMSSending*/
322 N9210_SetIncomingSMS, 323 N9210_SetIncomingSMS,
323 DCT3_SetIncomingCB, 324 DCT3_SetIncomingCB,
324 NOTIMPLEMENTED, /* GetSMSFolders */ 325 NOTIMPLEMENTED, /* GetSMSFolders */
325 NOTSUPPORTED, /* AddSMSFolder */ 326 NOTSUPPORTED, /* AddSMSFolder */
326 NOTSUPPORTED, /* DeleteSMSFolder */ 327 NOTSUPPORTED, /* DeleteSMSFolder */
327 DCT3_DialVoice, 328 DCT3_DialVoice,
328 N9210_AnswerCall, 329 N9210_AnswerCall,
329 DCT3_CancelCall, 330 DCT3_CancelCall,
330 NOTSUPPORTED, /* HoldCall */ 331 NOTSUPPORTED, /* HoldCall */
331 NOTSUPPORTED, /* UnholdCall */ 332 NOTSUPPORTED, /* UnholdCall */
332 NOTSUPPORTED, /* ConferenceCall */ 333 NOTSUPPORTED, /* ConferenceCall */
333 NOTSUPPORTED, /* SplitCall */ 334 NOTSUPPORTED, /* SplitCall */
334 NOTSUPPORTED, /* TransferCall */ 335 NOTSUPPORTED, /* TransferCall */
335 NOTSUPPORTED, /* SwitchCall */ 336 NOTSUPPORTED, /* SwitchCall */
336 NOTSUPPORTED, /* GetCallDivert */ 337 NOTSUPPORTED, /* GetCallDivert */
337 NOTSUPPORTED, /* SetCallDivert */ 338 NOTSUPPORTED, /* SetCallDivert */
338 NOTSUPPORTED, /* CancelAllDiverts*/ 339 NOTSUPPORTED, /* CancelAllDiverts*/
339 NOTSUPPORTED, /* SetIncomingCall */ 340 NOTSUPPORTED, /* SetIncomingCall */
340 NOTIMPLEMENTED, /* SetIncomingUSSD */ 341 NOTIMPLEMENTED, /* SetIncomingUSSD */
341 NOTSUPPORTED, /* SendDTMF */ 342 NOTSUPPORTED, /* SendDTMF */
342 NOTIMPLEMENTED, /* GetRingtone */ 343 NOTIMPLEMENTED, /* GetRingtone */
343 NOTIMPLEMENTED, /* SetRingtone */ 344 NOTIMPLEMENTED, /* SetRingtone */
344 NOTSUPPORTED, /* GetRingtonesInfo*/ 345 NOTSUPPORTED, /* GetRingtonesInfo*/
345 NOTSUPPORTED, /* DeleteUserRingtones*/ 346 NOTSUPPORTED, /* DeleteUserRingtones*/
346 NOTSUPPORTED, /* PlayTone */ 347 NOTSUPPORTED, /* PlayTone */
347 NOTIMPLEMENTED, /* GetWAPBookmark */ 348 NOTIMPLEMENTED, /* GetWAPBookmark */
348 NOTIMPLEMENTED, /* SetWAPBookmark */ 349 NOTIMPLEMENTED, /* SetWAPBookmark */
349 NOTIMPLEMENTED, /* DeleteWAPBookmark */ 350 NOTIMPLEMENTED, /* DeleteWAPBookmark */
350 NOTIMPLEMENTED, /* GetWAPSettings */ 351 NOTIMPLEMENTED, /* GetWAPSettings */
351 NOTSUPPORTED, /* SetWAPSettings */ 352 NOTSUPPORTED, /* SetWAPSettings */
352 NOTSUPPORTED, /* GetMMSSettings */ 353 NOTSUPPORTED, /* GetMMSSettings */
353 NOTSUPPORTED, /* SetMMSSettings */ 354 NOTSUPPORTED, /* SetMMSSettings */
354 NOTSUPPORTED, /* GetSyncMLSettings*/ 355 NOTSUPPORTED, /* GetSyncMLSettings*/
355 NOTSUPPORTED, /* SetSyncMLSettings*/ 356 NOTSUPPORTED, /* SetSyncMLSettings*/
356 NOTSUPPORTED, /* GetChatSettings */ 357 NOTSUPPORTED, /* GetChatSettings */
357 NOTSUPPORTED, /* SetChatSettings */ 358 NOTSUPPORTED, /* SetChatSettings */
358 N9210_GetBitmap, 359 N9210_GetBitmap,
359 N9210_SetBitmap, 360 N9210_SetBitmap,
360 NOTSUPPORTED, /* GetToDoStatus */ 361 NOTSUPPORTED, /* GetToDoStatus */
361 NOTSUPPORTED, /* GetToDo */ 362 NOTSUPPORTED, /* GetToDo */
362 NOTSUPPORTED, /* GetNextToDo */ 363 NOTSUPPORTED, /* GetNextToDo */
363 NOTSUPPORTED, /* SetToDo */ 364 NOTSUPPORTED, /* SetToDo */
364 NOTSUPPORTED, /* AddToDo */ 365 NOTSUPPORTED, /* AddToDo */
365 NOTSUPPORTED, /* DeleteToDo */ 366 NOTSUPPORTED, /* DeleteToDo */
366 NOTSUPPORTED, /* DeleteAllToDo */ 367 NOTSUPPORTED, /* DeleteAllToDo */
367 NOTSUPPORTED, /* GetCalendarStatus*/ 368 NOTSUPPORTED, /* GetCalendarStatus*/
368 NOTSUPPORTED, /* GetCalendar */ 369 NOTSUPPORTED, /* GetCalendar */
369 NOTSUPPORTED, /* GetNextCalendar */ 370 NOTSUPPORTED, /* GetNextCalendar */
370 NOTSUPPORTED, /* SetCalendar */ 371 NOTSUPPORTED, /* SetCalendar */
371 NOTSUPPORTED, /* AddCalendar */ 372 NOTSUPPORTED, /* AddCalendar */
372 NOTSUPPORTED, /* DeleteCalendar */ 373 NOTSUPPORTED, /* DeleteCalendar */
373 NOTSUPPORTED, /* DeleteAllCalendar*/ 374 NOTSUPPORTED, /* DeleteAllCalendar*/
374 NOTSUPPORTED, /* GetCalendarSettings*/ 375 NOTSUPPORTED, /* GetCalendarSettings*/
375 NOTSUPPORTED, /* SetCalendarSettings*/ 376 NOTSUPPORTED, /* SetCalendarSettings*/
376 NOTSUPPORTED, /* GetNote */ 377 NOTSUPPORTED, /* GetNextNote */
377 NOTIMPLEMENTED, /* GetProfile */ 378 NOTIMPLEMENTED, /* GetProfile */
378 NOTSUPPORTED, /* SetProfile */ 379 NOTSUPPORTED, /* SetProfile */
379 NOTSUPPORTED, /* GetFMStation */ 380 NOTSUPPORTED, /* GetFMStation */
380 NOTSUPPORTED, /* SetFMStation */ 381 NOTSUPPORTED, /* SetFMStation */
381 NOTSUPPORTED, /* ClearFMStations */ 382 NOTSUPPORTED, /* ClearFMStations */
382 NOTSUPPORTED, /* GetNextFileFolder*/ 383 NOTSUPPORTED, /* GetNextFileFolder*/
383 NOTSUPPORTED, /* GetFilePart */ 384 NOTSUPPORTED, /* GetFilePart */
384 NOTSUPPORTED, /* AddFile */ 385 NOTSUPPORTED, /* AddFile */
385 NOTSUPPORTED, /* GetFileSystemStatus*/ 386 NOTSUPPORTED, /* GetFileSystemStatus*/
386 NOTSUPPORTED, /* DeleteFile */ 387 NOTSUPPORTED, /* DeleteFile */
387 NOTSUPPORTED, /* AddFolder */ 388 NOTSUPPORTED, /* AddFolder */
388 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 389 NOTSUPPORTED, /* GetGPRSAccessPoint*/
389 NOTSUPPORTED /* SetGPRSAccessPoint*/ 390 NOTSUPPORTED /* SetGPRSAccessPoint*/
390}; 391};
391 392
392#endif 393#endif
393 394
394/* How should editor hadle tabs in this file? Add editor commands here. 395/* How should editor hadle tabs in this file? Add editor commands here.
395 * vim: noexpandtab sw=8 ts=8 sts=8: 396 * vim: noexpandtab sw=8 ts=8 sts=8:
396 */ 397 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c
index 51e6f18..9b1d6cd 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3320.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3320.c
@@ -149,123 +149,124 @@ GSM_Phone_Functions N3320Phone = {
149 NOKIA_GetManufacturer, 149 NOKIA_GetManufacturer,
150 DCT3DCT4_GetModel, 150 DCT3DCT4_GetModel,
151 DCT3DCT4_GetFirmware, 151 DCT3DCT4_GetFirmware,
152 NOTSUPPORTED, /* GetIMEI */ 152 NOTSUPPORTED, /* GetIMEI */
153 NOTSUPPORTED, /* GetOriginalIMEI */ 153 NOTSUPPORTED, /* GetOriginalIMEI */
154 NOTSUPPORTED, /* GetManufactureMonth*/ 154 NOTSUPPORTED, /* GetManufactureMonth*/
155 NOTSUPPORTED, /* GetProductCode */ 155 NOTSUPPORTED, /* GetProductCode */
156 NOTSUPPORTED, /* GetHardware */ 156 NOTSUPPORTED, /* GetHardware */
157 NOTSUPPORTED, /* GetPPM */ 157 NOTSUPPORTED, /* GetPPM */
158 NOTSUPPORTED, /* GetSIMIMSI */ 158 NOTSUPPORTED, /* GetSIMIMSI */
159 N3320_GetDateTime, 159 N3320_GetDateTime,
160 NOTSUPPORTED, /* SetDateTime */ 160 NOTSUPPORTED, /* SetDateTime */
161 NOTSUPPORTED, /* GetAlarm */ 161 NOTSUPPORTED, /* GetAlarm */
162 NOTSUPPORTED, /* SetAlarm */ 162 NOTSUPPORTED, /* SetAlarm */
163 NOTSUPPORTED, /* GetLocale */ 163 NOTSUPPORTED, /* GetLocale */
164 NOTSUPPORTED, /* SetLocale */ 164 NOTSUPPORTED, /* SetLocale */
165 NOTSUPPORTED, /* PressKey */ 165 NOTSUPPORTED, /* PressKey */
166 NOTSUPPORTED, /* Reset */ 166 NOTSUPPORTED, /* Reset */
167 NOTSUPPORTED, /* ResetPhoneSettings*/ 167 NOTSUPPORTED, /* ResetPhoneSettings*/
168 NOTSUPPORTED, /* EnterSecurityCode*/ 168 NOTSUPPORTED, /* EnterSecurityCode*/
169 NOTSUPPORTED, /* GetSecurityStatus*/ 169 NOTSUPPORTED, /* GetSecurityStatus*/
170 NOTSUPPORTED, /* GetDisplayStatus*/ 170 NOTSUPPORTED, /* GetDisplayStatus*/
171 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 171 NOTSUPPORTED, /* SetAutoNetworkLogin*/
172 NOTSUPPORTED, /* GetBatteryCharge*/ 172 NOTSUPPORTED, /* GetBatteryCharge*/
173 NOTSUPPORTED, /* GetSignalQuality*/ 173 NOTSUPPORTED, /* GetSignalQuality*/
174 NOTSUPPORTED, /* GetNetworkInfo */ 174 NOTSUPPORTED, /* GetNetworkInfo */
175 NOTSUPPORTED, /* GetCategory */ 175 NOTSUPPORTED, /* GetCategory */
176 NOTSUPPORTED, /* AddCategory */ 176 NOTSUPPORTED, /* AddCategory */
177 NOTSUPPORTED, /* GetCategoryStatus */ 177 NOTSUPPORTED, /* GetCategoryStatus */
178 N3320_GetMemoryStatus, 178 N3320_GetMemoryStatus,
179 N3320_GetMemory, 179 N3320_GetMemory,
180 NOTSUPPORTED, /* GetNextMemory */ 180 NOTSUPPORTED, /* GetNextMemory */
181 NOTSUPPORTED, /* SetMemory */ 181 NOTSUPPORTED, /* SetMemory */
182 NOTSUPPORTED, /* AddMemory */ 182 NOTSUPPORTED, /* AddMemory */
183 NOTSUPPORTED, /* DeleteMemory */ 183 NOTSUPPORTED, /* DeleteMemory */
184 NOTIMPLEMENTED, /* DeleteAllMemory */ 184 NOTIMPLEMENTED, /* DeleteAllMemory */
185 NOTSUPPORTED, /* GetSpeedDial */ 185 NOTSUPPORTED, /* GetSpeedDial */
186 NOTSUPPORTED, /* SetSpeedDial */ 186 NOTSUPPORTED, /* SetSpeedDial */
187 NOTSUPPORTED, /* GetSMSC */ 187 NOTSUPPORTED, /* GetSMSC */
188 NOTSUPPORTED, /* SetSMSC */ 188 NOTSUPPORTED, /* SetSMSC */
189 NOTSUPPORTED, /* GetSMSStatus */ 189 NOTSUPPORTED, /* GetSMSStatus */
190 NOTSUPPORTED, /* GetSMS */ 190 NOTSUPPORTED, /* GetSMS */
191 NOTSUPPORTED, /* GetNextSMS */ 191 NOTSUPPORTED, /* GetNextSMS */
192 NOTSUPPORTED, /* SetSMS */ 192 NOTSUPPORTED, /* SetSMS */
193 NOTSUPPORTED, /* AddSMS */ 193 NOTSUPPORTED, /* AddSMS */
194 NOTSUPPORTED, /* DeleteSMS */ 194 NOTSUPPORTED, /* DeleteSMS */
195 NOTSUPPORTED, /* SendSMS */ 195 NOTSUPPORTED, /* SendSMS */
196 NOTSUPPORTED, /* SendSavedSMS */ 196 NOTSUPPORTED, /* SendSavedSMS */
197 NOTSUPPORTED, /* SetFastSMSSending*/
197 NOTSUPPORTED, /* SetIncomingSMS */ 198 NOTSUPPORTED, /* SetIncomingSMS */
198 NOTSUPPORTED, /* SetIncomingCB */ 199 NOTSUPPORTED, /* SetIncomingCB */
199 NOTSUPPORTED, /* GetSMSFolders */ 200 NOTSUPPORTED, /* GetSMSFolders */
200 NOTSUPPORTED, /* AddSMSFolder */ 201 NOTSUPPORTED, /* AddSMSFolder */
201 NOTSUPPORTED, /* DeleteSMSFolder */ 202 NOTSUPPORTED, /* DeleteSMSFolder */
202 NOTIMPLEMENTED, /* DialVoice */ 203 NOTIMPLEMENTED, /* DialVoice */
203 NOTIMPLEMENTED, /* AnswerCall */ 204 NOTIMPLEMENTED, /* AnswerCall */
204 NOTIMPLEMENTED, /* CancelCall */ 205 NOTIMPLEMENTED, /* CancelCall */
205 NOTIMPLEMENTED, /* HoldCall */ 206 NOTIMPLEMENTED, /* HoldCall */
206 NOTIMPLEMENTED, /* UnholdCall */ 207 NOTIMPLEMENTED, /* UnholdCall */
207 NOTIMPLEMENTED, /* ConferenceCall */ 208 NOTIMPLEMENTED, /* ConferenceCall */
208 NOTIMPLEMENTED, /* SplitCall */ 209 NOTIMPLEMENTED, /* SplitCall */
209 NOTIMPLEMENTED, /* TransferCall */ 210 NOTIMPLEMENTED, /* TransferCall */
210 NOTIMPLEMENTED, /* SwitchCall */ 211 NOTIMPLEMENTED, /* SwitchCall */
211 NOTSUPPORTED, /* GetCallDivert */ 212 NOTSUPPORTED, /* GetCallDivert */
212 NOTSUPPORTED, /* SetCallDivert */ 213 NOTSUPPORTED, /* SetCallDivert */
213 NOTSUPPORTED, /* CancelAllDiverts*/ 214 NOTSUPPORTED, /* CancelAllDiverts*/
214 NOTIMPLEMENTED, /* SetIncomingCall */ 215 NOTIMPLEMENTED, /* SetIncomingCall */
215 NOTIMPLEMENTED, /* SetIncomingUSSD */ 216 NOTIMPLEMENTED, /* SetIncomingUSSD */
216 NOTSUPPORTED, /* SendDTMF */ 217 NOTSUPPORTED, /* SendDTMF */
217 NOTSUPPORTED, /* GetRingtone */ 218 NOTSUPPORTED, /* GetRingtone */
218 NOTSUPPORTED, /* SetRingtone */ 219 NOTSUPPORTED, /* SetRingtone */
219 NOTSUPPORTED, /* GetRingtonesInfo*/ 220 NOTSUPPORTED, /* GetRingtonesInfo*/
220 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 221 NOTIMPLEMENTED, /* DeleteUserRingtones*/
221 NOTSUPPORTED, /* PlayTone */ 222 NOTSUPPORTED, /* PlayTone */
222 NOTSUPPORTED, /* GetWAPBookmark */ 223 NOTSUPPORTED, /* GetWAPBookmark */
223 NOTSUPPORTED, /* SetWAPBookmark */ 224 NOTSUPPORTED, /* SetWAPBookmark */
224 NOTSUPPORTED, /* DeleteWAPBookmark */ 225 NOTSUPPORTED, /* DeleteWAPBookmark */
225 NOTSUPPORTED, /* GetWAPSettings */ 226 NOTSUPPORTED, /* GetWAPSettings */
226 NOTSUPPORTED, /* SetWAPSettings */ 227 NOTSUPPORTED, /* SetWAPSettings */
227 NOTSUPPORTED, /* GetMMSSettings */ 228 NOTSUPPORTED, /* GetMMSSettings */
228 NOTSUPPORTED, /* SetMMSSettings */ 229 NOTSUPPORTED, /* SetMMSSettings */
229 NOTSUPPORTED, /* GetSyncMLSettings*/ 230 NOTSUPPORTED, /* GetSyncMLSettings*/
230 NOTSUPPORTED, /* SetSyncMLSettings*/ 231 NOTSUPPORTED, /* SetSyncMLSettings*/
231 NOTSUPPORTED, /* GetChatSettings */ 232 NOTSUPPORTED, /* GetChatSettings */
232 NOTSUPPORTED, /* SetChatSettings */ 233 NOTSUPPORTED, /* SetChatSettings */
233 NOTSUPPORTED, /* GetBitmap */ 234 NOTSUPPORTED, /* GetBitmap */
234 NOTSUPPORTED, /* SetBitmap */ 235 NOTSUPPORTED, /* SetBitmap */
235 NOTSUPPORTED, /* GetToDoStatus */ 236 NOTSUPPORTED, /* GetToDoStatus */
236 NOTSUPPORTED, /* GetToDo */ 237 NOTSUPPORTED, /* GetToDo */
237 NOTSUPPORTED, /* GetNextToDo */ 238 NOTSUPPORTED, /* GetNextToDo */
238 NOTSUPPORTED, /* SetToDo */ 239 NOTSUPPORTED, /* SetToDo */
239 NOTSUPPORTED, /* AddToDo */ 240 NOTSUPPORTED, /* AddToDo */
240 NOTSUPPORTED, /* DeleteToDo */ 241 NOTSUPPORTED, /* DeleteToDo */
241 NOTSUPPORTED, /* DeleteAllToDo */ 242 NOTSUPPORTED, /* DeleteAllToDo */
242 N3320_GetCalendarStatus, 243 N3320_GetCalendarStatus,
243 NOTIMPLEMENTED, /* GetCalendar */ 244 NOTIMPLEMENTED, /* GetCalendar */
244 N3320_GetNextCalendar, 245 N3320_GetNextCalendar,
245 NOTIMPLEMENTED, /* SetCalendar */ 246 NOTIMPLEMENTED, /* SetCalendar */
246 NOTSUPPORTED, /* AddCalendar */ 247 NOTSUPPORTED, /* AddCalendar */
247 NOTSUPPORTED, /* DeleteCalendar */ 248 NOTSUPPORTED, /* DeleteCalendar */
248 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 249 NOTIMPLEMENTED, /* DeleteAllCalendar*/
249 NOTSUPPORTED, /* GetCalendarSettings*/ 250 NOTSUPPORTED, /* GetCalendarSettings*/
250 NOTSUPPORTED, /* SetCalendarSettings*/ 251 NOTSUPPORTED, /* SetCalendarSettings*/
251 NOTSUPPORTED, /* GetNote */ 252 NOTSUPPORTED, /* GetNextNote */
252 NOTSUPPORTED, /* GetProfile */ 253 NOTSUPPORTED, /* GetProfile */
253 NOTSUPPORTED, /* SetProfile */ 254 NOTSUPPORTED, /* SetProfile */
254 NOTSUPPORTED, /* GetFMStation */ 255 NOTSUPPORTED, /* GetFMStation */
255 NOTSUPPORTED, /* SetFMStation */ 256 NOTSUPPORTED, /* SetFMStation */
256 NOTSUPPORTED, /* ClearFMStations */ 257 NOTSUPPORTED, /* ClearFMStations */
257 NOTSUPPORTED, /* GetNextFileFolder*/ 258 NOTSUPPORTED, /* GetNextFileFolder*/
258 NOTSUPPORTED, /* GetFilePart */ 259 NOTSUPPORTED, /* GetFilePart */
259 NOTIMPLEMENTED, /* AddFilePart */ 260 NOTIMPLEMENTED, /* AddFilePart */
260 NOTSUPPORTED, /* GetFileSystemStatus*/ 261 NOTSUPPORTED, /* GetFileSystemStatus*/
261 NOTIMPLEMENTED, /* DeleteFile */ 262 NOTIMPLEMENTED, /* DeleteFile */
262 NOTIMPLEMENTED, /* AddFolder */ 263 NOTIMPLEMENTED, /* AddFolder */
263 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 264 NOTSUPPORTED, /* GetGPRSAccessPoint*/
264 NOTSUPPORTED /* SetGPRSAccessPoint*/ 265 NOTSUPPORTED /* SetGPRSAccessPoint*/
265}; 266};
266 267
267#endif 268#endif
268 269
269/* How should editor hadle tabs in this file? Add editor commands here. 270/* How should editor hadle tabs in this file? Add editor commands here.
270 * vim: noexpandtab sw=8 ts=8 sts=8: 271 * vim: noexpandtab sw=8 ts=8 sts=8:
271 */ 272 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3650.c b/gammu/emb/common/phone/nokia/dct4/n3650.c
index 2da55bf..d4746a7 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3650.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3650.c
@@ -270,123 +270,124 @@ GSM_Phone_Functions N3650Phone = {
270 NOKIA_GetManufacturer, 270 NOKIA_GetManufacturer,
271 DCT3DCT4_GetModel, 271 DCT3DCT4_GetModel,
272 DCT3DCT4_GetFirmware, 272 DCT3DCT4_GetFirmware,
273 DCT4_GetIMEI, 273 DCT4_GetIMEI,
274 NOTSUPPORTED, /* GetOriginalIMEI */ 274 NOTSUPPORTED, /* GetOriginalIMEI */
275 NOTSUPPORTED, /* GetManufactureMonth*/ 275 NOTSUPPORTED, /* GetManufactureMonth*/
276 DCT4_GetProductCode, 276 DCT4_GetProductCode,
277 DCT4_GetHardware, 277 DCT4_GetHardware,
278 NOTSUPPORTED, /* GetPPM */ 278 NOTSUPPORTED, /* GetPPM */
279 NOTSUPPORTED, /* GetSIMIMSI */ 279 NOTSUPPORTED, /* GetSIMIMSI */
280 NOTSUPPORTED, /* GetDateTime */ 280 NOTSUPPORTED, /* GetDateTime */
281 NOTSUPPORTED, /* SetDateTime */ 281 NOTSUPPORTED, /* SetDateTime */
282 NOTSUPPORTED, /* GetAlarm */ 282 NOTSUPPORTED, /* GetAlarm */
283 NOTSUPPORTED, /* SetAlarm */ 283 NOTSUPPORTED, /* SetAlarm */
284 NOTSUPPORTED, /* GetLocale */ 284 NOTSUPPORTED, /* GetLocale */
285 NOTSUPPORTED, /* SetLocale */ 285 NOTSUPPORTED, /* SetLocale */
286 NOTSUPPORTED, /* PressKey */ 286 NOTSUPPORTED, /* PressKey */
287 DCT4_Reset, 287 DCT4_Reset,
288 NOTSUPPORTED, /* ResetPhoneSettings*/ 288 NOTSUPPORTED, /* ResetPhoneSettings*/
289 NOTSUPPORTED, /* EnterSecurityCode*/ 289 NOTSUPPORTED, /* EnterSecurityCode*/
290 NOTSUPPORTED, /* GetSecurityStatus*/ 290 NOTSUPPORTED, /* GetSecurityStatus*/
291 NOTSUPPORTED, /* GetDisplayStatus*/ 291 NOTSUPPORTED, /* GetDisplayStatus*/
292 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 292 NOTSUPPORTED, /* SetAutoNetworkLogin*/
293 NOTSUPPORTED, /* GetBatteryCharge*/ 293 NOTSUPPORTED, /* GetBatteryCharge*/
294 NOTSUPPORTED, /* GetSignalQuality*/ 294 NOTSUPPORTED, /* GetSignalQuality*/
295 NOTSUPPORTED, /* GetNetworkInfo */ 295 NOTSUPPORTED, /* GetNetworkInfo */
296 NOTSUPPORTED, /* GetCategory */ 296 NOTSUPPORTED, /* GetCategory */
297 NOTSUPPORTED, /* AddCategory */ 297 NOTSUPPORTED, /* AddCategory */
298 NOTSUPPORTED, /* GetCategoryStatus */ 298 NOTSUPPORTED, /* GetCategoryStatus */
299 NOTSUPPORTED, /* GetMemoryStatus */ 299 NOTSUPPORTED, /* GetMemoryStatus */
300 NOTSUPPORTED, /* GetMemory */ 300 NOTSUPPORTED, /* GetMemory */
301 NOTSUPPORTED, /* GetNextMemory */ 301 NOTSUPPORTED, /* GetNextMemory */
302 NOTSUPPORTED, /* SetMemory */ 302 NOTSUPPORTED, /* SetMemory */
303 NOTSUPPORTED, /* AddMemory */ 303 NOTSUPPORTED, /* AddMemory */
304 NOTSUPPORTED, /* DeleteMemory */ 304 NOTSUPPORTED, /* DeleteMemory */
305 NOTIMPLEMENTED, /* DeleteAllMemory */ 305 NOTIMPLEMENTED, /* DeleteAllMemory */
306 NOTSUPPORTED, /* GetSpeedDial */ 306 NOTSUPPORTED, /* GetSpeedDial */
307 NOTSUPPORTED, /* SetSpeedDial */ 307 NOTSUPPORTED, /* SetSpeedDial */
308 NOTSUPPORTED, /* GetSMSC */ 308 NOTSUPPORTED, /* GetSMSC */
309 NOTSUPPORTED, /* SetSMSC */ 309 NOTSUPPORTED, /* SetSMSC */
310 NOTSUPPORTED, /* GetSMSStatus */ 310 NOTSUPPORTED, /* GetSMSStatus */
311 NOTSUPPORTED, /* GetSMS */ 311 NOTSUPPORTED, /* GetSMS */
312 NOTSUPPORTED, /* GetNextSMS */ 312 NOTSUPPORTED, /* GetNextSMS */
313 NOTSUPPORTED, /* SetSMS */ 313 NOTSUPPORTED, /* SetSMS */
314 NOTSUPPORTED, /* AddSMS */ 314 NOTSUPPORTED, /* AddSMS */
315 NOTSUPPORTED, /* DeleteSMS */ 315 NOTSUPPORTED, /* DeleteSMS */
316 NOTSUPPORTED, /* SendSMS */ 316 NOTSUPPORTED, /* SendSMS */
317 NOTSUPPORTED, /* SendSavedSMS */ 317 NOTSUPPORTED, /* SendSavedSMS */
318 NOTSUPPORTED, /* SetFastSMSSending*/
318 NOTSUPPORTED, /* SetIncomingSMS */ 319 NOTSUPPORTED, /* SetIncomingSMS */
319 NOTSUPPORTED, /* SetIncomingCB */ 320 NOTSUPPORTED, /* SetIncomingCB */
320 NOTSUPPORTED, /* GetSMSFolders */ 321 NOTSUPPORTED, /* GetSMSFolders */
321 NOTSUPPORTED, /* AddSMSFolder */ 322 NOTSUPPORTED, /* AddSMSFolder */
322 NOTSUPPORTED, /* DeleteSMSFolder */ 323 NOTSUPPORTED, /* DeleteSMSFolder */
323 NOTIMPLEMENTED, /* DialVoice */ 324 NOTIMPLEMENTED, /* DialVoice */
324 NOTIMPLEMENTED, /* AnswerCall */ 325 NOTIMPLEMENTED, /* AnswerCall */
325 NOTIMPLEMENTED, /* CancelCall */ 326 NOTIMPLEMENTED, /* CancelCall */
326 NOTIMPLEMENTED, /* HoldCall */ 327 NOTIMPLEMENTED, /* HoldCall */
327 NOTIMPLEMENTED, /* UnholdCall */ 328 NOTIMPLEMENTED, /* UnholdCall */
328 NOTIMPLEMENTED, /* ConferenceCall */ 329 NOTIMPLEMENTED, /* ConferenceCall */
329 NOTIMPLEMENTED, /* SplitCall */ 330 NOTIMPLEMENTED, /* SplitCall */
330 NOTIMPLEMENTED, /* TransferCall */ 331 NOTIMPLEMENTED, /* TransferCall */
331 NOTIMPLEMENTED, /* SwitchCall */ 332 NOTIMPLEMENTED, /* SwitchCall */
332 NOTSUPPORTED, /* GetCallDivert */ 333 NOTSUPPORTED, /* GetCallDivert */
333 NOTSUPPORTED, /* SetCallDivert */ 334 NOTSUPPORTED, /* SetCallDivert */
334 NOTSUPPORTED, /* CancelAllDiverts*/ 335 NOTSUPPORTED, /* CancelAllDiverts*/
335 NOTIMPLEMENTED, /* SetIncomingCall */ 336 NOTIMPLEMENTED, /* SetIncomingCall */
336 NOTIMPLEMENTED, /* SetIncomingUSSD */ 337 NOTIMPLEMENTED, /* SetIncomingUSSD */
337 NOTSUPPORTED, /* SendDTMF */ 338 NOTSUPPORTED, /* SendDTMF */
338 NOTSUPPORTED, /* GetRingtone */ 339 NOTSUPPORTED, /* GetRingtone */
339 NOTSUPPORTED, /* SetRingtone */ 340 NOTSUPPORTED, /* SetRingtone */
340 NOTSUPPORTED, /* GetRingtonesInfo*/ 341 NOTSUPPORTED, /* GetRingtonesInfo*/
341 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 342 NOTIMPLEMENTED, /* DeleteUserRingtones*/
342 NOTSUPPORTED, /* PlayTone */ 343 NOTSUPPORTED, /* PlayTone */
343 NOTSUPPORTED, /* GetWAPBookmark */ 344 NOTSUPPORTED, /* GetWAPBookmark */
344 NOTSUPPORTED, /* SetWAPBookmark */ 345 NOTSUPPORTED, /* SetWAPBookmark */
345 NOTSUPPORTED, /* DeleteWAPBookmark */ 346 NOTSUPPORTED, /* DeleteWAPBookmark */
346 NOTSUPPORTED, /* GetWAPSettings */ 347 NOTSUPPORTED, /* GetWAPSettings */
347 NOTSUPPORTED, /* SetWAPSettings */ 348 NOTSUPPORTED, /* SetWAPSettings */
348 NOTSUPPORTED, /* GetMMSSettings */ 349 NOTSUPPORTED, /* GetMMSSettings */
349 NOTSUPPORTED, /* SetMMSSettings */ 350 NOTSUPPORTED, /* SetMMSSettings */
350 NOTSUPPORTED, /* GetSyncMLSettings*/ 351 NOTSUPPORTED, /* GetSyncMLSettings*/
351 NOTSUPPORTED, /* SetSyncMLSettings*/ 352 NOTSUPPORTED, /* SetSyncMLSettings*/
352 NOTSUPPORTED, /* GetChatSettings */ 353 NOTSUPPORTED, /* GetChatSettings */
353 NOTSUPPORTED, /* SetChatSettings */ 354 NOTSUPPORTED, /* SetChatSettings */
354 NOTSUPPORTED, /* GetBitmap */ 355 NOTSUPPORTED, /* GetBitmap */
355 NOTSUPPORTED, /* SetBitmap */ 356 NOTSUPPORTED, /* SetBitmap */
356 NOTSUPPORTED, /* GetToDoStatus */ 357 NOTSUPPORTED, /* GetToDoStatus */
357 NOTSUPPORTED, /* GetToDo */ 358 NOTSUPPORTED, /* GetToDo */
358 NOTSUPPORTED, /* GetNextToDo */ 359 NOTSUPPORTED, /* GetNextToDo */
359 NOTSUPPORTED, /* SetToDo */ 360 NOTSUPPORTED, /* SetToDo */
360 NOTSUPPORTED, /* AddToDo */ 361 NOTSUPPORTED, /* AddToDo */
361 NOTSUPPORTED, /* DeleteToDo */ 362 NOTSUPPORTED, /* DeleteToDo */
362 NOTSUPPORTED, /* DeleteAllToDo */ 363 NOTSUPPORTED, /* DeleteAllToDo */
363 NOTIMPLEMENTED, /* GetCalendarStatus*/ 364 NOTIMPLEMENTED, /* GetCalendarStatus*/
364 NOTIMPLEMENTED, /* GetCalendar */ 365 NOTIMPLEMENTED, /* GetCalendar */
365 NOTSUPPORTED, /* GetNextCalendar */ 366 NOTSUPPORTED, /* GetNextCalendar */
366 NOTIMPLEMENTED, /* SetCalendar */ 367 NOTIMPLEMENTED, /* SetCalendar */
367 NOTSUPPORTED, /* AddCalendar */ 368 NOTSUPPORTED, /* AddCalendar */
368 NOTSUPPORTED, /* DeleteCalendar */ 369 NOTSUPPORTED, /* DeleteCalendar */
369 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 370 NOTIMPLEMENTED, /* DeleteAllCalendar*/
370 NOTSUPPORTED, /* GetCalendarSettings*/ 371 NOTSUPPORTED, /* GetCalendarSettings*/
371 NOTSUPPORTED, /* SetCalendarSettings*/ 372 NOTSUPPORTED, /* SetCalendarSettings*/
372 NOTSUPPORTED, /* GetNote */ 373 NOTSUPPORTED, /* GetNextNote */
373 NOTSUPPORTED, /* GetProfile */ 374 NOTSUPPORTED, /* GetProfile */
374 NOTSUPPORTED, /* SetProfile */ 375 NOTSUPPORTED, /* SetProfile */
375 NOTSUPPORTED, /* GetFMStation */ 376 NOTSUPPORTED, /* GetFMStation */
376 NOTSUPPORTED, /* SetFMStation */ 377 NOTSUPPORTED, /* SetFMStation */
377 NOTSUPPORTED, /* ClearFMStations */ 378 NOTSUPPORTED, /* ClearFMStations */
378 N3650_GetNextFileFolder, 379 N3650_GetNextFileFolder,
379 N3650_GetFilePart, 380 N3650_GetFilePart,
380 NOTIMPLEMENTED, /* AddFilePart */ 381 NOTIMPLEMENTED, /* AddFilePart */
381 NOTSUPPORTED, /* GetFileSystemStatus*/ 382 NOTSUPPORTED, /* GetFileSystemStatus*/
382 NOTIMPLEMENTED, /* DeleteFile */ 383 NOTIMPLEMENTED, /* DeleteFile */
383 NOTIMPLEMENTED, /* AddFolder */ 384 NOTIMPLEMENTED, /* AddFolder */
384 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 385 NOTSUPPORTED, /* GetGPRSAccessPoint*/
385 NOTSUPPORTED /* SetGPRSAccessPoint*/ 386 NOTSUPPORTED /* SetGPRSAccessPoint*/
386}; 387};
387 388
388#endif 389#endif
389 390
390/* How should editor hadle tabs in this file? Add editor commands here. 391/* How should editor hadle tabs in this file? Add editor commands here.
391 * vim: noexpandtab sw=8 ts=8 sts=8: 392 * vim: noexpandtab sw=8 ts=8 sts=8:
392 */ 393 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c
index 67fe492..2208def 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.c
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.c
@@ -1,50 +1,53 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail, Pawel Kot and Gnokii */ 2/* based on some Markus Plail, Pawel Kot work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */ 6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
4 7
5#include "../../../gsmstate.h" 8#include "../../../gsmstate.h"
6 9
7#ifdef GSM_ENABLE_NOKIA6510 10#ifdef GSM_ENABLE_NOKIA6510
8 11
9#include <string.h> 12#include <string.h>
10#include <time.h> 13#include <time.h>
11 14
12#include "../../../misc/coding/coding.h" 15#include "../../../misc/coding/coding.h"
13#include "../../../gsmcomon.h" 16#include "../../../gsmcomon.h"
14#include "../../../service/gsmlogo.h" 17#include "../../../service/gsmlogo.h"
15#include "../nfunc.h" 18#include "../nfunc.h"
16#include "../nfuncold.h" 19#include "../nfuncold.h"
17#include "../../pfunc.h" 20#include "../../pfunc.h"
18#include "dct4func.h" 21#include "dct4func.h"
19#include "n6510.h" 22#include "n6510.h"
20 23
21static GSM_Error N6510_Initialise (GSM_StateMachine *s) 24static GSM_Error N6510_Initialise (GSM_StateMachine *s)
22{ 25{
23 s->Phone.Data.Priv.N6510.CalendarIconsNum = 0; 26 s->Phone.Data.Priv.N6510.CalendarIconsNum = 0;
24 27
25 /* Enables various things like incoming SMS, call info, etc. */ 28 /* Enables various things like incoming SMS, call info, etc. */
26 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7); 29 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7);
27} 30}
28 31
29static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 32static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
30{ 33{
31 smprintf(s, "Phonebook entry received\n"); 34 smprintf(s, "Phonebook entry received\n");
32 switch (msg.Buffer[6]) { 35 switch (msg.Buffer[6]) {
33 case 0x0f: 36 case 0x0f:
34 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); 37 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
35 default: 38 default:
36 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false); 39 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false);
37 } 40 }
38 return ERR_UNKNOWN; 41 return ERR_UNKNOWN;
39} 42}
40 43
41static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) 44static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
42{ 45{
43 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 46 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
44 0xfe, 0x10, /* memory type */ 47 0xfe, 0x10, /* memory type */
45 0x00, 0x00, 0x00, 0x00, 48 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x01, /* location */ 49 0x00, 0x01, /* location */
47 0x00, 0x00, 0x01}; 50 0x00, 0x00, 0x01};
48 51
49 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 52 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
50 if (req[9]==0xff) return ERR_NOTSUPPORTED; 53 if (req[9]==0xff) return ERR_NOTSUPPORTED;
@@ -74,96 +77,98 @@ static GSM_Error N6510_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateM
74 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; 77 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21];
75 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed); 78 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed);
76 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; 79 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
77 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree); 80 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree);
78 return ERR_NONE; 81 return ERR_NONE;
79} 82}
80 83
81static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 84static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
82{ 85{
83 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 86 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
84 0x00, /* memory type */ 87 0x00, /* memory type */
85 0x55, 0x55, 0x55, 0x00}; 88 0x55, 0x55, 0x55, 0x00};
86 89
87 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); 90 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
88 if (req[5]==0xff) return ERR_NOTSUPPORTED; 91 if (req[5]==0xff) return ERR_NOTSUPPORTED;
89 92
90 s->Phone.Data.MemoryStatus=Status; 93 s->Phone.Data.MemoryStatus=Status;
91 smprintf(s, "Getting memory status\n"); 94 smprintf(s, "Getting memory status\n");
92 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus); 95 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus);
93} 96}
94 97
95static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 98static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
96{ 99{
97 int i, current, j; 100 int i, current, j;
98 GSM_Phone_Data *Data = &s->Phone.Data; 101 GSM_Phone_Data *Data = &s->Phone.Data;
99 102
100 switch (msg.Buffer[4]) { 103 switch (msg.Buffer[4]) {
101 case 0x00: 104 case 0x00:
102 smprintf(s, "SMSC received\n"); 105 smprintf(s, "SMSC received\n");
103 break; 106 break;
104 case 0x02: 107 case 0x02:
105 smprintf(s, "SMSC empty\n"); 108 smprintf(s, "SMSC empty\n");
106 return ERR_INVALIDLOCATION; 109 return ERR_INVALIDLOCATION;
107 default: 110 default:
108 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]); 111 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]);
109 return ERR_UNKNOWNRESPONSE; 112 return ERR_UNKNOWNRESPONSE;
110 } 113 }
111 memset(Data->SMSC,0,sizeof(GSM_SMSC)); 114 memset(Data->SMSC,0,sizeof(GSM_SMSC));
112 Data->SMSC->Location = msg.Buffer[8]; 115 Data->SMSC->Location = msg.Buffer[8];
113 Data->SMSC->Format = SMS_FORMAT_Text; 116 Data->SMSC->Format = SMS_FORMAT_Text;
114 switch (msg.Buffer[10]) { 117 switch (msg.Buffer[10]) {
115 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 118 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
116 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 119 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
117 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 120 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
118 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 121 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
119 } 122 }
120 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat; 123 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat;
121 Data->SMSC->Validity.Relative= msg.Buffer[12]; 124 Data->SMSC->Validity.Relative= msg.Buffer[12];
125 if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
126
122 current = 14; 127 current = 14;
123 for (i=0;i<msg.Buffer[13];i++) { 128 for (i=0;i<msg.Buffer[13];i++) {
124 switch (msg.Buffer[current]) { 129 switch (msg.Buffer[current]) {
125 case 0x81: 130 case 0x81:
126 j=current+4; 131 j=current+4;
127 while (msg.Buffer[j]!=0) {j++;} 132 while (msg.Buffer[j]!=0) {j++;}
128 j=j-33; 133 j=j-33;
129 if (j>GSM_MAX_SMSC_NAME_LENGTH) { 134 if (j>GSM_MAX_SMSC_NAME_LENGTH) {
130 smprintf(s, "Too long name\n"); 135 smprintf(s, "Too long name\n");
131 return ERR_UNKNOWNRESPONSE; 136 return ERR_UNKNOWNRESPONSE;
132 } 137 }
133 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4); 138 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4);
134 smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); 139 smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
135 break; 140 break;
136 case 0x82: 141 case 0x82:
137 switch (msg.Buffer[current+2]) { 142 switch (msg.Buffer[current+2]) {
138 case 0x01: 143 case 0x01:
139 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true); 144 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true);
140 smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); 145 smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
141 break; 146 break;
142 case 0x02: 147 case 0x02:
143 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false); 148 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false);
144 smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); 149 smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
145 break; 150 break;
146 default: 151 default:
147 smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]); 152 smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]);
148 return ERR_UNKNOWNRESPONSE; 153 return ERR_UNKNOWNRESPONSE;
149 } 154 }
150 break; 155 break;
151 default: 156 default:
152 smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]); 157 smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]);
153 return ERR_UNKNOWNRESPONSE; 158 return ERR_UNKNOWNRESPONSE;
154 } 159 }
155 current = current + msg.Buffer[current+1]; 160 current = current + msg.Buffer[current+1];
156 } 161 }
157 return ERR_NONE; 162 return ERR_NONE;
158} 163}
159 164
160static GSM_Error N6510_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 165static GSM_Error N6510_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
161{ 166{
162 unsigned char req[] = {N6110_FRAME_HEADER, 0x14, 167 unsigned char req[] = {N6110_FRAME_HEADER, 0x14,
163 0x01, /* location */ 168 0x01, /* location */
164 0x00}; 169 0x00};
165 170
166 if (smsc->Location==0x00) return ERR_INVALIDLOCATION; 171 if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
167 172
168 req[4]=smsc->Location; 173 req[4]=smsc->Location;
169 174
@@ -220,97 +225,97 @@ static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
220 req[count++] = 0x02; 225 req[count++] = 0x02;
221 req[count] = GSM_PackSemiOctetNumber(smsc->Number, req+count+2, false) + 1; 226 req[count] = GSM_PackSemiOctetNumber(smsc->Number, req+count+2, false) + 1;
222 if (req[count]>18) { 227 if (req[count]>18) {
223 smprintf(s, "Too long SMSC number in frame\n"); 228 smprintf(s, "Too long SMSC number in frame\n");
224 return ERR_UNKNOWN; 229 return ERR_UNKNOWN;
225 } 230 }
226 req[count+1] = req[count] - 1; 231 req[count+1] = req[count] - 1;
227 count += 23; 232 count += 23;
228 233
229 /* --------------- Default number ------------- */ 234 /* --------------- Default number ------------- */
230 /* Block type: number */ 235 /* Block type: number */
231 req[count++] = 0x82; 236 req[count++] = 0x82;
232 /* Offset to next block */ 237 /* Offset to next block */
233 req[count++] = 0x14; 238 req[count++] = 0x14;
234 /* Type of number: default number */ 239 /* Type of number: default number */
235 req[count++] = 0x01; 240 req[count++] = 0x01;
236 req[count] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+count+2, true) + 1; 241 req[count] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+count+2, true) + 1;
237 if (req[count]*2>12) { 242 if (req[count]*2>12) {
238 smprintf(s, "Too long SMSC number in frame\n"); 243 smprintf(s, "Too long SMSC number in frame\n");
239 return ERR_UNKNOWN; 244 return ERR_UNKNOWN;
240 } 245 }
241 req[count+1] = req[count] - 1; 246 req[count+1] = req[count] - 1;
242 count += 17; 247 count += 17;
243 248
244 /* -------------- SMSC name ------------------- */ 249 /* -------------- SMSC name ------------------- */
245 req[count++] = 0x81; 250 req[count++] = 0x81;
246 req[count++] = UnicodeLength(smsc->Name)*2 + 2 + 4; 251 req[count++] = UnicodeLength(smsc->Name)*2 + 2 + 4;
247 req[count++] = UnicodeLength(smsc->Name)*2 + 2; 252 req[count++] = UnicodeLength(smsc->Name)*2 + 2;
248 req[count++] = 0x00; 253 req[count++] = 0x00;
249 /* Can't make CopyUnicodeString(req+count,sms->Name) !!!! 254 /* Can't make CopyUnicodeString(req+count,sms->Name) !!!!
250 * with MSVC6 count is changed then 255 * with MSVC6 count is changed then
251 */ 256 */
252 i = count; 257 i = count;
253 CopyUnicodeString(req+i,smsc->Name); 258 CopyUnicodeString(req+i,smsc->Name);
254 count += UnicodeLength(smsc->Name)*2 + 2; 259 count += UnicodeLength(smsc->Name)*2 + 2;
255 260
256 smprintf(s, "Setting SMSC\n"); 261 smprintf(s, "Setting SMSC\n");
257 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC); 262 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC);
258} 263}
259 264
260static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 265static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
261{ 266{
262 int current = msg.Buffer[7]+7, tmp; 267 int current = msg.Buffer[7]+7, tmp;
263 GSM_Phone_Data*Data = &s->Phone.Data; 268 GSM_Phone_Data*Data = &s->Phone.Data;
264#ifdef DEBUG 269#ifdef DEBUG
265 char name[100]; 270 char name[100];
266 GSM_NetworkInfo NetInfo; 271 GSM_NetworkInfo NetInfo;
267 272
268 smprintf(s, "Network status: "); 273 smprintf(s, "Network status : ");
269 switch (msg.Buffer[8]) { 274 switch (msg.Buffer[8]) {
270 case 0x00 : smprintf(s, "home network\n"); break; 275 case 0x00 : smprintf(s, "home network\n"); break;
271 case 0x01 : smprintf(s, "roaming network\n"); break; 276 case 0x01 : smprintf(s, "roaming network\n"); break;
272 case 0x04 : smprintf(s, "not logged"); break; 277 case 0x04 : smprintf(s, "not logged"); break;
273 case 0x06 : smprintf(s, "SIM card rejected\n"); break; 278 case 0x06 : smprintf(s, "SIM card rejected\n"); break;
274 case 0x09 : smprintf(s, "not logged"); break; 279 case 0x09 : smprintf(s, "not logged"); break;
275 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break; 280 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break;
276 } 281 }
277 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) { 282 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) {
278 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode); 283 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode);
279 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); 284 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
280 smprintf(s, "Network name for Gammu : %s ", 285 smprintf(s, "Network name for Gammu : %s ",
281 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); 286 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
282 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); 287 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
283 288
284 sprintf(NetInfo.LAC,"%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 289 sprintf(NetInfo.LAC,"%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]);
285 smprintf(s, "LAC : %s\n", NetInfo.LAC); 290 smprintf(s, "LAC : %s\n", NetInfo.LAC);
286 291
287 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 292 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]);
288 smprintf(s, "CID : %s\n", NetInfo.CID); 293 smprintf(s, "CID : %s\n", NetInfo.CID);
289 294
290 tmp = 10; 295 tmp = 10;
291 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,true); 296 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,true);
292 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 297 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
293 } 298 }
294#endif 299#endif
295 if (Data->RequestID==ID_GetNetworkInfo) { 300 if (Data->RequestID==ID_GetNetworkInfo) {
296 Data->NetworkInfo->NetworkName[0] = 0x00; 301 Data->NetworkInfo->NetworkName[0] = 0x00;
297 Data->NetworkInfo->NetworkName[1] = 0x00; 302 Data->NetworkInfo->NetworkName[1] = 0x00;
298 Data->NetworkInfo->State = 0; 303 Data->NetworkInfo->State = 0;
299 switch (msg.Buffer[8]) { 304 switch (msg.Buffer[8]) {
300 case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break; 305 case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break;
301 case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork;break; 306 case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork;break;
302 case 0x04: 307 case 0x04:
303 case 0x06: 308 case 0x06:
304 case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break; 309 case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break;
305 } 310 }
306 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { 311 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) {
307 tmp = 10; 312 tmp = 10;
308 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true); 313 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true);
309 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 314 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]);
310 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 315 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]);
311 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode); 316 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode);
312 } 317 }
313 } 318 }
314 return ERR_NONE; 319 return ERR_NONE;
315} 320}
316 321
@@ -940,101 +945,101 @@ static GSM_Error N6510_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_State
940{ 945{
941 GSM_Phone_Data *Data = &s->Phone.Data; 946 GSM_Phone_Data *Data = &s->Phone.Data;
942 947
943 smprintf(s, "Network level received: %i\n",msg.Buffer[8]); 948 smprintf(s, "Network level received: %i\n",msg.Buffer[8]);
944 Data->SignalQuality->SignalStrength = -1; 949 Data->SignalQuality->SignalStrength = -1;
945 Data->SignalQuality->SignalPercent = ((int)msg.Buffer[8]); 950 Data->SignalQuality->SignalPercent = ((int)msg.Buffer[8]);
946 Data->SignalQuality->BitErrorRate = -1; 951 Data->SignalQuality->BitErrorRate = -1;
947 return ERR_NONE; 952 return ERR_NONE;
948} 953}
949 954
950static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig) 955static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
951{ 956{
952 unsigned char req[] = {N6110_FRAME_HEADER, 0x0B, 0x00, 0x02, 0x00, 0x00, 0x00}; 957 unsigned char req[] = {N6110_FRAME_HEADER, 0x0B, 0x00, 0x02, 0x00, 0x00, 0x00};
953 958
954 s->Phone.Data.SignalQuality = sig; 959 s->Phone.Data.SignalQuality = sig;
955 smprintf(s, "Getting network level\n"); 960 smprintf(s, "Getting network level\n");
956 return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality); 961 return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality);
957} 962}
958 963
959static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s) 964static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s)
960{ 965{
961 GSM_Phone_Data *Data = &s->Phone.Data; 966 GSM_Phone_Data *Data = &s->Phone.Data;
962 967
963 smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7); 968 smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7);
964 Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7)); 969 Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7));
965 Data->BatteryCharge->ChargeState = 0; 970 Data->BatteryCharge->ChargeState = 0;
966 return ERR_NONE; 971 return ERR_NONE;
967} 972}
968 973
969static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat) 974static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
970{ 975{
971 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00}; 976 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00};
972 977
973 s->Phone.Data.BatteryCharge = bat; 978 s->Phone.Data.BatteryCharge = bat;
974 smprintf(s, "Getting battery level\n"); 979 smprintf(s, "Getting battery level\n");
975 return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge); 980 return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge);
976} 981}
977 982
978static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s) 983static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
979{ 984{
980 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true); 985 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true);
981} 986}
982 987
983static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 988static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
984{ 989{
985 GSM_Phone_Data *Data = &s->Phone.Data; 990 GSM_Phone_Data *Data = &s->Phone.Data;
986 991
987 smprintf(s, "Operator logo received\n"); 992 smprintf(s, "Operator logo received\n");
993 if (msg.Length == 18) return ERR_EMPTY;
988 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode); 994 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode);
989 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode); 995 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode);
990 Data->Bitmap->BitmapWidth= msg.Buffer[20]; 996 Data->Bitmap->BitmapWidth= msg.Buffer[20];
991 Data->Bitmap->BitmapHeight= msg.Buffer[21]; 997 Data->Bitmap->BitmapHeight= msg.Buffer[21];
992 if (msg.Length == 18) return ERR_EMPTY;
993 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap); 998 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap);
994 return ERR_NONE; 999 return ERR_NONE;
995} 1000}
996 1001
997GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 1002GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
998{ 1003{
999 smprintf(s, "Phonebook entry deleted\n"); 1004 smprintf(s, "Phonebook entry deleted\n");
1000 return ERR_NONE; 1005 return ERR_NONE;
1001} 1006}
1002 1007
1003GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1008GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1004{ 1009{
1005 unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01, 1010 unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01,
1006 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02, 1011 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02,
1007 0x00, 0x01, /* location*/ 1012 0x00, 0x01, /* location*/
1008 0x00, 0x00, 0x00, 0x00, 1013 0x00, 0x00, 0x00, 0x00,
1009 0x05, /* memory type*/ 1014 0x05, /* memory type*/
1010 0x55, 0x55, 0x55}; 1015 0x55, 0x55, 0x55};
1011 1016
1012 req[12] = entry->Location / 256; 1017 req[12] = entry->Location / 256;
1013 req[13] = entry->Location % 256; 1018 req[13] = entry->Location % 256;
1014 1019
1015 req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 1020 req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1016 if (req[18]==0xff) return ERR_NOTSUPPORTED; 1021 if (req[18]==0xff) return ERR_NOTSUPPORTED;
1017 1022
1018 smprintf(s, "Deleting phonebook entry\n"); 1023 smprintf(s, "Deleting phonebook entry\n");
1019 return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory); 1024 return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory);
1020} 1025}
1021 1026
1022static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1027static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1023{ 1028{
1024 int count = 22, blocks; 1029 int count = 22, blocks;
1025 unsigned char req[500] = { 1030 unsigned char req[500] = {
1026 N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 1031 N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,
1027 0x02, 0x00, /* memory type */ 1032 0x02, 0x00, /* memory type */
1028 0x00, 0x00, /* location */ 1033 0x00, 0x00, /* location */
1029 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1034 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1030 1035
1031 if (entry->Location == 0) return ERR_NOTSUPPORTED; 1036 if (entry->Location == 0) return ERR_NOTSUPPORTED;
1032 1037
1033 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 1038 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1034 if (req[11]==0xff) return ERR_NOTSUPPORTED; 1039 if (req[11]==0xff) return ERR_NOTSUPPORTED;
1035 1040
1036 req[12] = entry->Location / 256; 1041 req[12] = entry->Location / 256;
1037 req[13] = entry->Location % 256; 1042 req[13] = entry->Location % 256;
1038 1043
1039 count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS)); 1044 count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS));
1040 req[21] = blocks; 1045 req[21] = blocks;
@@ -1720,97 +1725,98 @@ static GSM_Error N6510_ReplyGetSyncMLSettings(GSM_Protocol_Message msg, GSM_Stat
1720 smprintf(s, "SyncML settings received OK\n"); 1725 smprintf(s, "SyncML settings received OK\n");
1721 CopyUnicodeString(Sett->User,msg.Buffer+18); 1726 CopyUnicodeString(Sett->User,msg.Buffer+18);
1722 CopyUnicodeString(Sett->Password,msg.Buffer+86); 1727 CopyUnicodeString(Sett->Password,msg.Buffer+86);
1723 CopyUnicodeString(Sett->PhonebookDataBase,msg.Buffer+130); 1728 CopyUnicodeString(Sett->PhonebookDataBase,msg.Buffer+130);
1724 CopyUnicodeString(Sett->CalendarDataBase,msg.Buffer+234); 1729 CopyUnicodeString(Sett->CalendarDataBase,msg.Buffer+234);
1725 CopyUnicodeString(Sett->Server,msg.Buffer+338); 1730 CopyUnicodeString(Sett->Server,msg.Buffer+338);
1726 1731
1727 Sett->SyncPhonebook = false; 1732 Sett->SyncPhonebook = false;
1728 Sett->SyncCalendar = false; 1733 Sett->SyncCalendar = false;
1729 if ((msg.Buffer[598] & 0x02)==0x02) Sett->SyncCalendar = true; 1734 if ((msg.Buffer[598] & 0x02)==0x02) Sett->SyncCalendar = true;
1730 if ((msg.Buffer[598] & 0x01)==0x01) Sett->SyncPhonebook = true; 1735 if ((msg.Buffer[598] & 0x01)==0x01) Sett->SyncPhonebook = true;
1731 1736
1732 return ERR_NONE; 1737 return ERR_NONE;
1733} 1738}
1734 1739
1735static GSM_Error N6510_ReplyGetSyncMLName(GSM_Protocol_Message msg, GSM_StateMachine *s) 1740static GSM_Error N6510_ReplyGetSyncMLName(GSM_Protocol_Message msg, GSM_StateMachine *s)
1736{ 1741{
1737 GSM_SyncMLSettings *Sett = s->Phone.Data.SyncMLSettings; 1742 GSM_SyncMLSettings *Sett = s->Phone.Data.SyncMLSettings;
1738 1743
1739 smprintf(s, "SyncML names received OK\n"); 1744 smprintf(s, "SyncML names received OK\n");
1740 1745
1741 CopyUnicodeString(Sett->Name,msg.Buffer+18); 1746 CopyUnicodeString(Sett->Name,msg.Buffer+18);
1742 1747
1743 return ERR_NONE; 1748 return ERR_NONE;
1744} 1749}
1745 1750
1746static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings *settings) 1751static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings *settings)
1747{ 1752{
1748 GSM_Error error; 1753 GSM_Error error;
1749 // unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x05, 1754 // unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x05,
1750 // 0x00, 0x00, 0x00, 0x31, 0x00, 1755 // 0x00, 0x00, 0x00, 0x31, 0x00,
1751 // 0x06, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00}; 1756 // 0x06, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00};
1752 // unsigned char GetActive[] = {N6110_FRAME_HEADER, 0x05, 1757 // unsigned char GetActive[] = {N6110_FRAME_HEADER, 0x05,
1753 // 0x00, 0x00, 0x00, 0x31, 0x00, 1758 // 0x00, 0x00, 0x00, 0x31, 0x00,
1754 // 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}; 1759 // 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
1755 unsigned char req[] = {N6110_FRAME_HEADER, 0x05, 1760 unsigned char req[] = {N6110_FRAME_HEADER, 0x05,
1756 0x00, 0x00, 0x00, 0x31, 0x00, 1761 0x00, 0x00, 0x00, 0x31, 0x00,
1757 0x01, //location 1762 0x01, //location
1758 0x00, 0x00, 0x02, 0x46, 0x00, 0x00}; 1763 0x00, 0x00, 0x02, 0x46, 0x00, 0x00};
1759 1764
1760 settings->Connection.Location = settings->Location; 1765 settings->Connection.Location = settings->Location;
1761 error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS); 1766 error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS);
1762 if (error != ERR_NONE) return error; 1767 if (error != ERR_NONE) return error;
1763 1768
1764 settings->Active = settings->Connection.Active; 1769 settings->Active = settings->Connection.Active;
1765 1770
1766 settings->Name[0] = 0; 1771 settings->Name[0] = 0;
1767 settings->Name[1] = 0; 1772 settings->Name[1] = 0;
1768 //s->Phone.Data.SyncMLSettings = settings; 1773 s->Phone.Data.SyncMLSettings = settings;
1774
1769 //smprintf(s, "Getting SyncML settings name\n"); 1775 //smprintf(s, "Getting SyncML settings name\n");
1770 //error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName); 1776 //error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName);
1771 //if (error != ERR_NONE) return error; 1777 //if (error != ERR_NONE) return error;
1772 1778
1773 req[9] = settings->Location - 1; 1779 req[9] = settings->Location - 1;
1774 smprintf(s, "Getting additional SyncML settings\n"); 1780 smprintf(s, "Getting additional SyncML settings\n");
1775 return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings); 1781 return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings);
1776} 1782}
1777 1783
1778static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) 1784static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
1779{ 1785{
1780 GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings; 1786 GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings;
1781 int i; 1787 int i;
1782 1788
1783 Sett->Name[0] = 0; 1789 Sett->Name[0] = 0;
1784 Sett->Name[1] = 0; 1790 Sett->Name[1] = 0;
1785 Sett->HomePage[0] = 0; 1791 Sett->HomePage[0] = 0;
1786 Sett->HomePage[1] = 0; 1792 Sett->HomePage[1] = 0;
1787 Sett->User[0] = 0; 1793 Sett->User[0] = 0;
1788 Sett->User[1] = 0; 1794 Sett->User[1] = 0;
1789 Sett->Password[0] = 0; 1795 Sett->Password[0] = 0;
1790 Sett->Password[1] = 0; 1796 Sett->Password[1] = 0;
1791 1797
1792 switch(msg.Buffer[3]) { 1798 switch(msg.Buffer[3]) {
1793 case 0x3B: 1799 case 0x3B:
1794 smprintf(s, "Chat settings received OK\n"); 1800 smprintf(s, "Chat settings received OK\n");
1795 memcpy(Sett->Name,msg.Buffer+20,msg.Buffer[12]*2); 1801 memcpy(Sett->Name,msg.Buffer+20,msg.Buffer[12]*2);
1796 Sett->Name[msg.Buffer[12]*2] = 0; 1802 Sett->Name[msg.Buffer[12]*2] = 0;
1797 Sett->Name[msg.Buffer[12]*2+1] = 0; 1803 Sett->Name[msg.Buffer[12]*2+1] = 0;
1798 memcpy(Sett->HomePage,msg.Buffer+20+msg.Buffer[12]*2,msg.Buffer[15]*2); 1804 memcpy(Sett->HomePage,msg.Buffer+20+msg.Buffer[12]*2,msg.Buffer[15]*2);
1799 Sett->HomePage[msg.Buffer[15]*2] = 0; 1805 Sett->HomePage[msg.Buffer[15]*2] = 0;
1800 Sett->HomePage[msg.Buffer[15]*2+1] = 0; 1806 Sett->HomePage[msg.Buffer[15]*2+1] = 0;
1801 i = msg.Buffer[12]*2 + msg.Buffer[15]*2 + 29; 1807 i = msg.Buffer[12]*2 + msg.Buffer[15]*2 + 29;
1802 memcpy(Sett->User,msg.Buffer+i+3,msg.Buffer[i]*2); 1808 memcpy(Sett->User,msg.Buffer+i+3,msg.Buffer[i]*2);
1803 Sett->User[msg.Buffer[i]*2] = 0; 1809 Sett->User[msg.Buffer[i]*2] = 0;
1804 Sett->User[msg.Buffer[i]*2+1] = 0; 1810 Sett->User[msg.Buffer[i]*2+1] = 0;
1805 memcpy(Sett->Password,msg.Buffer+i+3+msg.Buffer[i]*2,msg.Buffer[i+1]*2); 1811 memcpy(Sett->Password,msg.Buffer+i+3+msg.Buffer[i]*2,msg.Buffer[i+1]*2);
1806 Sett->Password[msg.Buffer[i+1]*2] = 0; 1812 Sett->Password[msg.Buffer[i+1]*2] = 0;
1807 Sett->Password[msg.Buffer[i+1]*2+1] = 0; 1813 Sett->Password[msg.Buffer[i+1]*2+1] = 0;
1808 return ERR_NONE; 1814 return ERR_NONE;
1809 case 0x3C: 1815 case 0x3C:
1810 smprintf(s, "Empty chat settings received\n"); 1816 smprintf(s, "Empty chat settings received\n");
1811 return ERR_NONE; 1817 return ERR_NONE;
1812 } 1818 }
1813 return ERR_UNKNOWNRESPONSE; 1819 return ERR_UNKNOWNRESPONSE;
1814} 1820}
1815 1821
1816static GSM_Error N6510_GetChatSettings(GSM_StateMachine *s, GSM_ChatSettings *settings) 1822static GSM_Error N6510_GetChatSettings(GSM_StateMachine *s, GSM_ChatSettings *settings)
@@ -2238,97 +2244,97 @@ static GSM_Error N6510_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *st
2238 2244
2239static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2245static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2240{ 2246{
2241 switch (msg.Buffer[3]) { 2247 switch (msg.Buffer[3]) {
2242 case 0x05: 2248 case 0x05:
2243 smprintf(s, "SMS deleted OK\n"); 2249 smprintf(s, "SMS deleted OK\n");
2244 return ERR_NONE; 2250 return ERR_NONE;
2245 case 0x06: 2251 case 0x06:
2246 switch (msg.Buffer[4]) { 2252 switch (msg.Buffer[4]) {
2247 case 0x02: 2253 case 0x02:
2248 smprintf(s, "Invalid location\n"); 2254 smprintf(s, "Invalid location\n");
2249 return ERR_INVALIDLOCATION; 2255 return ERR_INVALIDLOCATION;
2250 default: 2256 default:
2251 smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]); 2257 smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]);
2252 return ERR_UNKNOWNRESPONSE; 2258 return ERR_UNKNOWNRESPONSE;
2253 } 2259 }
2254 } 2260 }
2255 return ERR_UNKNOWNRESPONSE; 2261 return ERR_UNKNOWNRESPONSE;
2256} 2262}
2257 2263
2258static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2264static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2259{ 2265{
2260 unsigned char folderid; 2266 unsigned char folderid;
2261 int location; 2267 int location;
2262 unsigned char req[] = {N6110_FRAME_HEADER, 0x04, 2268 unsigned char req[] = {N6110_FRAME_HEADER, 0x04,
2263 0x01, /* 0x01=SM, 0x02=ME */ 2269 0x01, /* 0x01=SM, 0x02=ME */
2264 0x00, /* FolderID */ 2270 0x00, /* FolderID */
2265 0x00, 0x02, /* Location */ 2271 0x00, 0x02, /* Location */
2266 0x0F, 0x55}; 2272 0x0F, 0x55};
2267 2273
2268 N6510_GetSMSLocation(s, sms, &folderid, &location); 2274 N6510_GetSMSLocation(s, sms, &folderid, &location);
2269 2275
2270 switch (folderid) { 2276 switch (folderid) {
2271 case 0x01: req[5] = 0x02; break; /* INBOX SIM */ 2277 case 0x01: req[5] = 0x02; break; /* INBOX SIM */
2272 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */ 2278 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */
2273 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/ 2279 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/
2274 } 2280 }
2275 req[6]=location / 256; 2281 req[6]=location / 256;
2276 req[7]=location; 2282 req[7]=location;
2277 2283
2278 smprintf(s, "Deleting sms\n"); 2284 smprintf(s, "Deleting sms\n");
2279 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage); 2285 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage);
2280} 2286}
2281 2287
2282static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2288static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2283{ 2289{
2284 switch (msg.Buffer[8]) { 2290 switch (msg.Buffer[8]) {
2285 case 0x00: 2291 case 0x00:
2286 smprintf(s, "SMS sent OK, TPMR for sent sms is %02x\n",msg.Buffer[10]); 2292 smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]);
2287 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]); 2293 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]);
2288 return ERR_NONE; 2294 return ERR_NONE;
2289 default: 2295 default:
2290 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]); 2296 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]);
2291 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]); 2297 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]);
2292 return ERR_NONE; 2298 return ERR_NONE;
2293 } 2299 }
2294} 2300}
2295 2301
2296static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2302static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2297{ 2303{
2298 int length = 11; 2304 int length = 11;
2299 GSM_Error error; 2305 GSM_Error error;
2300 GSM_SMSMessageLayout Layout; 2306 GSM_SMSMessageLayout Layout;
2301 unsigned char req [300] = { 2307 unsigned char req [300] = {
2302 N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55}; 2308 N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55};
2303 2309
2304 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit; 2310 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
2305 memset(req+9,0x00,sizeof(req) - 9); 2311 memset(req+9,0x00,sizeof(req) - 9);
2306 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length); 2312 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length);
2307 if (error != ERR_NONE) return error; 2313 if (error != ERR_NONE) return error;
2308 2314
2309 smprintf(s, "Sending sms\n"); 2315 smprintf(s, "Sending sms\n");
2310 return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02); 2316 return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02);
2311} 2317}
2312 2318
2313static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 2319static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
2314{ 2320{
2315 GSM_Phone_Data *Data = &s->Phone.Data; 2321 GSM_Phone_Data *Data = &s->Phone.Data;
2316 2322
2317 smprintf(s, "Security Code status received: "); 2323 smprintf(s, "Security Code status received: ");
2318 switch (msg.Buffer[4]) { 2324 switch (msg.Buffer[4]) {
2319 case 0x01 : smprintf(s, "waiting for Security Code.\n"); *Data->SecurityStatus = SEC_SecurityCode;break; 2325 case 0x01 : smprintf(s, "waiting for Security Code.\n"); *Data->SecurityStatus = SEC_SecurityCode;break;
2320 case 0x07 : 2326 case 0x07 :
2321 case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break; 2327 case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break;
2322 case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break; 2328 case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break;
2323 case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break; 2329 case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break;
2324 case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break; 2330 case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break;
2325 case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break; 2331 case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break;
2326 case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break; 2332 case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break;
2327 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 2333 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
2328 return ERR_UNKNOWNRESPONSE; 2334 return ERR_UNKNOWNRESPONSE;
2329 } 2335 }
2330 return ERR_NONE; 2336 return ERR_NONE;
2331} 2337}
2332 2338
2333static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) 2339static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
2334{ 2340{
@@ -2725,96 +2731,97 @@ static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
2725 msg.Buffer[msg.Buffer[7]*2+12] == 'h' && 2731 msg.Buffer[msg.Buffer[7]*2+12] == 'h' &&
2726 msg.Buffer[msg.Buffer[7]*2+13] == 'd') { 2732 msg.Buffer[msg.Buffer[7]*2+13] == 'd') {
2727 smprintf(s,"MIDI\n"); 2733 smprintf(s,"MIDI\n");
2728 tmp = msg.Buffer[7]*2+10; 2734 tmp = msg.Buffer[7]*2+10;
2729 i = msg.Length - 2; /* ?????? */ 2735 i = msg.Length - 2; /* ?????? */
2730 Data->Ringtone->Format = RING_MIDI; 2736 Data->Ringtone->Format = RING_MIDI;
2731 } else { 2737 } else {
2732 /* Looking for end */ 2738 /* Looking for end */
2733 i=8+msg.Buffer[7]*2+3; 2739 i=8+msg.Buffer[7]*2+3;
2734 tmp = i; 2740 tmp = i;
2735 while (true) { 2741 while (true) {
2736 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { 2742 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
2737 i=i+2; break; 2743 i=i+2; break;
2738 } 2744 }
2739 i++; 2745 i++;
2740 if (i==msg.Length) return ERR_EMPTY; 2746 if (i==msg.Length) return ERR_EMPTY;
2741 } 2747 }
2742 } 2748 }
2743 /* Copying frame */ 2749 /* Copying frame */
2744 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+tmp,i-tmp); 2750 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+tmp,i-tmp);
2745 Data->Ringtone->NokiaBinary.Length=i-tmp; 2751 Data->Ringtone->NokiaBinary.Length=i-tmp;
2746 return ERR_NONE; 2752 return ERR_NONE;
2747} 2753}
2748 2754
2749static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 2755static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
2750{ 2756{
2751 GSM_AllRingtonesInfo Info; 2757 GSM_AllRingtonesInfo Info;
2752 GSM_Error error; 2758 GSM_Error error;
2753 unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12, 2759 unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12,
2754 0x00, 0xe7}; /* Location */ 2760 0x00, 0xe7}; /* Location */
2755 2761
2756 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY; 2762 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
2757 2763
2758 switch (Ringtone->Format) { 2764 switch (Ringtone->Format) {
2759 case RING_NOTETONE: 2765 case RING_NOTETONE:
2760 /* In the future get binary and convert */ 2766 /* In the future get binary and convert */
2761 return ERR_NOTSUPPORTED; 2767 return ERR_NOTSUPPORTED;
2762 case RING_NOKIABINARY: 2768 case RING_NOKIABINARY:
2763 s->Phone.Data.Ringtone= Ringtone; 2769 s->Phone.Data.Ringtone= Ringtone;
2764 Info.Number = 0; 2770 Info.Number = 0;
2765 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone); 2771 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone);
2766 if (error != ERR_NONE) return error; 2772 if (error != ERR_NONE) return error;
2767 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION; 2773 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION;
2768 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256; 2774 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256;
2769 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256; 2775 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256;
2770 smprintf(s, "Getting binary ringtone\n"); 2776 smprintf(s, "Getting binary ringtone\n");
2771 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); 2777 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone);
2772 case RING_MIDI: 2778 case RING_MIDI:
2779 case RING_MMF:
2773 return ERR_NOTSUPPORTED; 2780 return ERR_NOTSUPPORTED;
2774 } 2781 }
2775 return ERR_NOTSUPPORTED; 2782 return ERR_NOTSUPPORTED;
2776} 2783}
2777 2784
2778static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) 2785static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
2779{ 2786{
2780 GSM_Error error; 2787 GSM_Error error;
2781 unsigned char reqStart[] = { 2788 unsigned char reqStart[] = {
2782 0x00,0x06,0x01,0x00,0x07,0x00 }; 2789 0x00,0x06,0x01,0x00,0x07,0x00 };
2783 unsigned char reqPlay[] = { 2790 unsigned char reqPlay[] = {
2784 0x00,0x06,0x01,0x14,0x05,0x04, 2791 0x00,0x06,0x01,0x14,0x05,0x04,
2785 0x00,0x00,0x00,0x03,0x03,0x08, 2792 0x00,0x00,0x00,0x03,0x03,0x08,
2786 0x00,0x00,0x00,0x01,0x00,0x00, 2793 0x00,0x00,0x00,0x01,0x00,0x00,
2787 0x03,0x08,0x01,0x00, 2794 0x03,0x08,0x01,0x00,
2788 0x07,0xd0,/*Frequency */ 2795 0x07,0xd0,/*Frequency */
2789 0x00,0x00,0x03,0x08,0x02,0x00,0x00, 2796 0x00,0x00,0x03,0x08,0x02,0x00,0x00,
2790 0x05, /*Volume */ 2797 0x05, /*Volume */
2791 0x00,0x00}; 2798 0x00,0x00};
2792 unsigned char reqOff[] = { 2799 unsigned char reqOff[] = {
2793 0x00,0x06,0x01,0x14,0x05,0x05, 2800 0x00,0x06,0x01,0x14,0x05,0x05,
2794 0x00,0x00,0x00,0x01,0x03,0x08, 2801 0x00,0x00,0x00,0x01,0x03,0x08,
2795 0x05,0x00,0x00,0x08,0x00,0x00}; 2802 0x05,0x00,0x00,0x08,0x00,0x00};
2796 // unsigned char reqOff2[] = { 2803 // unsigned char reqOff2[] = {
2797 // 0x00,0x06,0x01,0x14,0x05,0x04, 2804 // 0x00,0x06,0x01,0x14,0x05,0x04,
2798 // 0x00,0x00,0x00,0x01,0x03,0x08, 2805 // 0x00,0x00,0x00,0x01,0x03,0x08,
2799 // 0x00,0x00,0x00,0x00,0x00,0x00}; 2806 // 0x00,0x00,0x00,0x00,0x00,0x00};
2800 2807
2801 if (start) { 2808 if (start) {
2802 smprintf(s, "Enabling sound - part 1\n"); 2809 smprintf(s, "Enabling sound - part 1\n");
2803 error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone); 2810 error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone);
2804 if (error!=ERR_NONE) return error; 2811 if (error!=ERR_NONE) return error;
2805 smprintf(s, "Enabling sound - part 2 (disabling sound command)\n"); 2812 smprintf(s, "Enabling sound - part 2 (disabling sound command)\n");
2806 error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); 2813 error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone);
2807 if (error!=ERR_NONE) return error; 2814 if (error!=ERR_NONE) return error;
2808 } 2815 }
2809 2816
2810 /* For Herz==255*255 we have silent */ 2817 /* For Herz==255*255 we have silent */
2811 if (Herz!=255*255) { 2818 if (Herz!=255*255) {
2812 reqPlay[23] = Herz%256; 2819 reqPlay[23] = Herz%256;
2813 reqPlay[22] = Herz/256; 2820 reqPlay[22] = Herz/256;
2814 reqPlay[31] = Volume; 2821 reqPlay[31] = Volume;
2815 smprintf(s, "Playing sound\n"); 2822 smprintf(s, "Playing sound\n");
2816 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); 2823 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone);
2817 } else { 2824 } else {
2818 reqPlay[23] = 0; 2825 reqPlay[23] = 0;
2819 reqPlay[22] = 0; 2826 reqPlay[22] = 0;
2820 reqPlay[31] = 0; 2827 reqPlay[31] = 0;
@@ -2941,96 +2948,99 @@ static GSM_Error N6510_ReplyGetProfile(GSM_Protocol_Message msg, GSM_StateMachin
2941 case 0x05:/* SMS tone */ 2948 case 0x05:/* SMS tone */
2942 j = Data->Profile->FeaturesNumber; 2949 j = Data->Profile->FeaturesNumber;
2943 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); 2950 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false);
2944 if (j == Data->Profile->FeaturesNumber) { 2951 if (j == Data->Profile->FeaturesNumber) {
2945 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageTone; 2952 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageTone;
2946 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = PROFILE_MESSAGE_PERSONAL; 2953 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = PROFILE_MESSAGE_PERSONAL;
2947 Data->Profile->FeaturesNumber++; 2954 Data->Profile->FeaturesNumber++;
2948 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageToneID; 2955 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageToneID;
2949 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7]; 2956 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7];
2950 Data->Profile->FeaturesNumber++; 2957 Data->Profile->FeaturesNumber++;
2951 } 2958 }
2952 break; 2959 break;
2953 case 0x08:/* Caller groups */ 2960 case 0x08:/* Caller groups */
2954 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,true); 2961 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,true);
2955 break; 2962 break;
2956 case 0x0c : 2963 case 0x0c :
2957 CopyUnicodeString(Data->Profile->Name,blockstart + 7); 2964 CopyUnicodeString(Data->Profile->Name,blockstart + 7);
2958 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name)); 2965 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
2959 Data->Profile->DefaultName = false; 2966 Data->Profile->DefaultName = false;
2960 break; 2967 break;
2961 default: 2968 default:
2962 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); 2969 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false);
2963 } 2970 }
2964 blockstart = blockstart + blockstart[0]; 2971 blockstart = blockstart + blockstart[0];
2965 } 2972 }
2966 return ERR_NONE; 2973 return ERR_NONE;
2967 case 0x06: 2974 case 0x06:
2968 Data->Profile->Active = false; 2975 Data->Profile->Active = false;
2969 if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true; 2976 if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true;
2970 return ERR_NONE; 2977 return ERR_NONE;
2971 } 2978 }
2972 return ERR_UNKNOWNRESPONSE; 2979 return ERR_UNKNOWNRESPONSE;
2973} 2980}
2974 2981
2975static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile) 2982static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
2976{ 2983{
2977 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01}; 2984 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01};
2978 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05}; 2985 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05};
2979 int i, length = 7; 2986 int i, length = 7;
2980 GSM_Errorerror; 2987 GSM_Errorerror;
2981 2988
2982 /* For now !!! */ 2989 /* For now !!! */
2983 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) { 2990 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) {
2984 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED; 2991 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED;
2985 } 2992 }
2986 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) { 2993 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) {
2987 return ERR_NOTSUPPORTED; 2994 return ERR_NOTSUPPORTED;
2988 } 2995 }
2996 if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
2997 return ERR_NOTSUPPORTED;
2998 }
2989 2999
2990 if (Profile->Location>5) return ERR_INVALIDLOCATION; 3000 if (Profile->Location>5) return ERR_INVALIDLOCATION;
2991 3001
2992 for (i = 0; i < 0x0a; i++) { 3002 for (i = 0; i < 0x0a; i++) {
2993 req[length++] = 0x04; 3003 req[length++] = 0x04;
2994 req[length++] = Profile->Location; 3004 req[length++] = Profile->Location;
2995 req[length++] = i; 3005 req[length++] = i;
2996 req[length++] = 0x01; 3006 req[length++] = 0x01;
2997 } 3007 }
2998 3008
2999 req[length++] = 0x04; 3009 req[length++] = 0x04;
3000 req[length++] = Profile->Location; 3010 req[length++] = Profile->Location;
3001 req[length++] = 0x0c; 3011 req[length++] = 0x0c;
3002 req[length++] = 0x01; 3012 req[length++] = 0x01;
3003 3013
3004 req[length++] = 0x04; 3014 req[length++] = 0x04;
3005 3015
3006 Profile->CarKitProfile= false; 3016 Profile->CarKitProfile= false;
3007 Profile->HeadSetProfile= false; 3017 Profile->HeadSetProfile= false;
3008 3018
3009 Profile->FeaturesNumber = 0; 3019 Profile->FeaturesNumber = 0;
3010 3020
3011 s->Phone.Data.Profile=Profile; 3021 s->Phone.Data.Profile=Profile;
3012 smprintf(s, "Getting profile\n"); 3022 smprintf(s, "Getting profile\n");
3013 error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile); 3023 error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile);
3014 if (error != ERR_NONE) return error; 3024 if (error != ERR_NONE) return error;
3015 3025
3016 smprintf(s, "Checking, which profile is active\n"); 3026 smprintf(s, "Checking, which profile is active\n");
3017 return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile); 3027 return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile);
3018} 3028}
3019 3029
3020static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s) 3030static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s)
3021{ 3031{
3022 unsigned char *blockstart; 3032 unsigned char *blockstart;
3023 int i; 3033 int i;
3024 3034
3025 smprintf(s, "Response to profile writing received!\n"); 3035 smprintf(s, "Response to profile writing received!\n");
3026 3036
3027 blockstart = msg.Buffer + 6; 3037 blockstart = msg.Buffer + 6;
3028 for (i = 0; i < msg.Buffer[5]; i++) { 3038 for (i = 0; i < msg.Buffer[5]; i++) {
3029 switch (blockstart[2]) { 3039 switch (blockstart[2]) {
3030 case 0x00: smprintf(s, "keypad tone level"); break; 3040 case 0x00: smprintf(s, "keypad tone level"); break;
3031 case 0x02: smprintf(s, "call alert"); break; 3041 case 0x02: smprintf(s, "call alert"); break;
3032 case 0x03: smprintf(s, "ringtone"); break; 3042 case 0x03: smprintf(s, "ringtone"); break;
3033 case 0x04: smprintf(s, "ringtone volume"); break; 3043 case 0x04: smprintf(s, "ringtone volume"); break;
3034 case 0x05: smprintf(s, "SMS tone"); break; 3044 case 0x05: smprintf(s, "SMS tone"); break;
3035 case 0x06: smprintf(s, "vibration"); break; 3045 case 0x06: smprintf(s, "vibration"); break;
3036 case 0x07: smprintf(s, "warning tone level"); break; 3046 case 0x07: smprintf(s, "warning tone level"); break;
@@ -3070,194 +3080,224 @@ static GSM_Error N6510_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
3070 Value = Profile->FeatureValue[i]; 3080 Value = Profile->FeatureValue[i];
3071 found = true; 3081 found = true;
3072 break; 3082 break;
3073 default: 3083 default:
3074 found=NOKIA_FindPhoneFeatureValue( 3084 found=NOKIA_FindPhoneFeatureValue(
3075 s, 3085 s,
3076 Profile71_65, 3086 Profile71_65,
3077 Profile->FeatureID[i],Profile->FeatureValue[i], 3087 Profile->FeatureID[i],Profile->FeatureValue[i],
3078 &ID,&Value); 3088 &ID,&Value);
3079 } 3089 }
3080 if (found) { 3090 if (found) {
3081 req[length] = 0x09; 3091 req[length] = 0x09;
3082 req[length + 1] = ID; 3092 req[length + 1] = ID;
3083 req[length + 2] = Profile->Location; 3093 req[length + 2] = Profile->Location;
3084 memcpy(req + length + 4, "\x00\x00\x01", 3); 3094 memcpy(req + length + 4, "\x00\x00\x01", 3);
3085 req[length + 8] = 0x03; 3095 req[length + 8] = 0x03;
3086 req[length + 3] = req[length + 7] = Value; 3096 req[length + 3] = req[length + 7] = Value;
3087 blocks++; 3097 blocks++;
3088 length += 9; 3098 length += 9;
3089 } 3099 }
3090 } 3100 }
3091 3101
3092 smprintf(s, "Setting profile\n"); 3102 smprintf(s, "Setting profile\n");
3093 return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile); 3103 return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile);
3094} 3104}
3095 3105
3096static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) 3106static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
3097{ 3107{
3098 GSM_SMSMessage sms; 3108 GSM_SMSMessage sms;
3099 3109
3100#ifdef DEBUG 3110#ifdef DEBUG
3101 smprintf(s, "SMS message received\n"); 3111 smprintf(s, "SMS message received\n");
3102 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); 3112 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
3103#endif 3113#endif
3104 3114
3105 if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) { 3115 if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
3106 sms.State = SMS_UnRead; 3116 sms.State = SMS_UnRead;
3107 sms.InboxFolder = true; 3117 sms.InboxFolder = true;
3108 3118
3109 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); 3119 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
3110 3120
3111 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 3121 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
3112 } 3122 }
3113 return ERR_NONE; 3123 return ERR_NONE;
3114} 3124}
3115 3125
3116static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 3126static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
3117{ 3127{
3128 unsigned int pos2 = 15;
3118 unsigned intpos = 4; 3129 unsigned intpos = 4;
3130 unsigned char req2[100] = {N6110_FRAME_HEADER,0x01,
3131 0x00,0x02,0x07,0x04,
3132 0x01, // 1 - voice, 2 - data
3133 0x00,0x03,
3134 0x18, // length of rest + 1
3135 0x00,0x00,0x00};
3119 unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 3136 unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
3120 0x0c};/* Number length */ 3137 0x0c};/* Number length */
3138 GSM_Errorerror;
3139
3140 /* USSD not supported */
3141 if (number[0] == '*') return ERR_NOTSUPPORTED;
3142 if (number[0] == '#') return ERR_NOTSUPPORTED;
3121 3143
3122 req[pos++] = strlen(number); 3144 req[pos++] = strlen(number);
3123 EncodeUnicode(req+pos,number,strlen(number)); 3145 EncodeUnicode(req+pos,number,strlen(number));
3124 pos += strlen(number)*2; 3146 pos += strlen(number)*2;
3125 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ 3147 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
3126 req[pos++] = 0x01; 3148 req[pos++] = 0x01;
3127 req[pos++] = 0x05; 3149 req[pos++] = 0x05;
3128 req[pos++] = 0x00; 3150 req[pos++] = 0x00;
3129 req[pos++] = 0x02; 3151 req[pos++] = 0x02;
3130 req[pos++] = 0x00; 3152 req[pos++] = 0x00;
3131 req[pos++] = 0x00; 3153 req[pos++] = 0x00;
3132 switch (ShowNumber) { 3154 switch (ShowNumber) {
3133 case GSM_CALL_HideNumber: 3155 case GSM_CALL_HideNumber:
3134 req[pos++] = 0x02; 3156 req[pos++] = 0x02;
3135 break; 3157 break;
3136 case GSM_CALL_ShowNumber: 3158 case GSM_CALL_ShowNumber:
3137 req[pos++] = 0x03; 3159 req[pos++] = 0x03;
3138 break; 3160 break;
3139 case GSM_CALL_DefaultNumberPresence: 3161 case GSM_CALL_DefaultNumberPresence:
3140 req[pos++] = 0x01; 3162 req[pos++] = 0x01;
3141 break; 3163 break;
3142 } 3164 }
3165 smprintf(s, "Making voice call\n");
3166 error = GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
3167 if (error != ERR_NOTSUPPORTED) return error;
3168
3169 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
3170
3171 req2[11] = strlen(number)*2+6;
3172 req2[pos2++] = strlen(number);
3173 EncodeUnicode(req2+pos2,number,strlen(number));
3174 pos2 += strlen(number)*2;
3143 3175
3144 smprintf(s, "Making voice call\n"); 3176 smprintf(s, "Making voice call\n");
3145 return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice); 3177 error = GSM_WaitFor (s, req2, pos2, 0x01, 4, ID_DialVoice);
3178 if (error == ERR_NOTSUPPORTED) return ERR_NONE;
3179 return error;
3146} 3180}
3147 3181
3148/* method 3 */ 3182/* method 3 */
3149static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last) 3183static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last)
3150{ 3184{
3151 int i=0,j=0; 3185 int i=0,j=0;
3152 3186
3153 while (Last->Location[j] != 0x00) j++; 3187 while (Last->Location[j] != 0x00) j++;
3154 if (j >= GSM_MAXCALENDARTODONOTES) { 3188 if (j >= GSM_MAXCALENDARTODONOTES) {
3155 smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n"); 3189 smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n");
3156 return ERR_UNKNOWN; 3190 return ERR_UNKNOWN;
3157 } 3191 }
3158 if (j == 0) { 3192 if (j == 0) {
3159 Last->Number=msg.Buffer[8]*256+msg.Buffer[9]; 3193 Last->Number=msg.Buffer[8]*256+msg.Buffer[9];
3160 smprintf(s, "Number of Entries: %i\n",Last->Number); 3194 smprintf(s, "Number of Entries: %i\n",Last->Number);
3161 } 3195 }
3162 smprintf(s, "Locations: "); 3196 smprintf(s, "Locations: ");
3163 while (14+(i*4) <= msg.Length) { 3197 while (14+(i*4) <= msg.Length) {
3164 Last->Location[j++]=msg.Buffer[12+i*4]*256+msg.Buffer[13+i*4]; 3198 Last->Location[j++]=msg.Buffer[12+i*4]*256+msg.Buffer[13+i*4];
3165 smprintf(s, "%i ",Last->Location[j-1]); 3199 smprintf(s, "%i ",Last->Location[j-1]);
3166 i++; 3200 i++;
3167 } 3201 }
3168 smprintf(s, "\nNumber of Entries in frame: %i\n",i); 3202 smprintf(s, "\nNumber of Entries in frame: %i\n",i);
3169 Last->Location[j] = 0; 3203 Last->Location[j] = 0;
3170 smprintf(s, "\n"); 3204 smprintf(s, "\n");
3171 if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY; 3205 if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY;
3172 if (i == 0) return ERR_EMPTY; 3206 if (i == 0) return ERR_EMPTY;
3173 return ERR_NONE; 3207 return ERR_NONE;
3174} 3208}
3175 3209
3176/* method 3 */ 3210/* method 3 */
3177static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, bool Calendar) 3211static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, char Type)
3178{ 3212{
3179 GSM_Error error; 3213 GSM_Error error = ERR_UNKNOWN;
3180 int i; 3214 int i;
3181 unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00, 3215 unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00,
3182 0x00, 0x00,/* First location */ 3216 0x00, 0x00,/* First location */
3183 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style */ 3217 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style, 2 = Notes */
3184 3218
3185 Last->Location[0] = 0x00; 3219 Last->Location[0] = 0x00;
3186 Last->Number = 0; 3220 Last->Number = 0;
3187 3221
3188 if (Calendar) { 3222 req[10] = Type;
3223 if (Type == 0) {
3189 smprintf(s, "Getting locations for calendar method 3\n"); 3224 smprintf(s, "Getting locations for calendar method 3\n");
3190 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); 3225 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
3191 } else { 3226 } else if (Type == 1) {
3192 req[10] = 0x01;
3193 smprintf(s, "Getting locations for ToDo method 2\n"); 3227 smprintf(s, "Getting locations for ToDo method 2\n");
3194 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); 3228 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
3229 } else if (Type == 2) {
3230 smprintf(s, "Getting locations for Notes\n");
3231 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
3195 } 3232 }
3196 if (error != ERR_NONE && error != ERR_EMPTY) return error; 3233 if (error != ERR_NONE && error != ERR_EMPTY) return error;
3197 3234
3198 while (1) { 3235 while (1) {
3199 i=0; 3236 i=0;
3200 while (Last->Location[i] != 0x00) i++; 3237 while (Last->Location[i] != 0x00) i++;
3201 smprintf(s, "i = %i %i\n",i,Last->Number); 3238 smprintf(s, "i = %i %i\n",i,Last->Number);
3202 if (i == Last->Number) break; 3239 if (i == Last->Number) break;
3203 if (i != Last->Number && error == ERR_EMPTY) { 3240 if (i != Last->Number && error == ERR_EMPTY) {
3204 smprintf(s, "Phone doesn't support some notes with this method. Workaround\n"); 3241 smprintf(s, "Phone doesn't support some notes with this method. Workaround\n");
3205 Last->Number = i; 3242 Last->Number = i;
3206 break; 3243 break;
3207 } 3244 }
3208 req[8] = Last->Location[i-1] / 256; 3245 req[8] = Last->Location[i-1] / 256;
3209 req[9] = Last->Location[i-1] % 256; 3246 req[9] = Last->Location[i-1] % 256;
3210 if (Calendar) { 3247 if (Type == 0) {
3211 smprintf(s, "Getting locations for calendar method 3\n"); 3248 smprintf(s, "Getting locations for calendar method 3\n");
3212 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); 3249 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
3213 } else { 3250 } else if (Type == 1) {
3214 smprintf(s, "Getting locations for todo method 2\n"); 3251 smprintf(s, "Getting locations for todo method 2\n");
3215 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); 3252 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
3253 } else if (Type == 2) {
3254 smprintf(s, "Getting locations for Notes\n");
3255 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
3216 } 3256 }
3217 if (error != ERR_NONE && error != ERR_EMPTY) return error; 3257 if (error != ERR_NONE && error != ERR_EMPTY) return error;
3218 } 3258 }
3219 return ERR_NONE; 3259 return ERR_NONE;
3220} 3260}
3221 3261
3222/* method 3 */ 3262/* method 3 */
3223GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) 3263GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3224{ 3264{
3225 GSM_CalendarEntry *entry = s->Phone.Data.Cal; 3265 GSM_CalendarEntry *entry = s->Phone.Data.Cal;
3226 GSM_DateTime Date; 3266 GSM_DateTime Date;
3227 unsigned long diff; 3267 unsigned long diff;
3228 int i; 3268 int i;
3229 bool found = false; 3269 bool found = false;
3230 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; 3270 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
3231 3271
3232 smprintf(s, "Calendar note received method 3\n"); 3272 smprintf(s, "Calendar note received method 3\n");
3233 3273
3234 smprintf(s,"Note type %02i: ",msg.Buffer[27]); 3274 smprintf(s,"Note type %02i: ",msg.Buffer[27]);
3235 switch(msg.Buffer[27]) { 3275 switch(msg.Buffer[27]) {
3236 case 0x00: smprintf(s,"Reminder\n"); entry->Type = GSM_CAL_REMINDER; break; 3276 case 0x00: smprintf(s,"Reminder\n"); entry->Type = GSM_CAL_REMINDER; break;
3237 case 0x01: smprintf(s,"Meeting\n"); entry->Type = GSM_CAL_MEETING; break; 3277 case 0x01: smprintf(s,"Meeting\n"); entry->Type = GSM_CAL_MEETING; break;
3238 case 0x02: smprintf(s,"Call\n"); entry->Type = GSM_CAL_CALL; break; 3278 case 0x02: smprintf(s,"Call\n"); entry->Type = GSM_CAL_CALL; break;
3239 case 0x04: smprintf(s,"Birthday\n"); entry->Type = GSM_CAL_BIRTHDAY; break; 3279 case 0x04: smprintf(s,"Birthday\n"); entry->Type = GSM_CAL_BIRTHDAY; break;
3240 case 0x08: smprintf(s,"Memo\n"); entry->Type = GSM_CAL_MEMO; break; 3280 case 0x08: smprintf(s,"Memo\n"); entry->Type = GSM_CAL_MEMO; break;
3241 default : smprintf(s,"unknown\n"); 3281 default : smprintf(s,"unknown\n");
3242 } 3282 }
3243 3283
3244 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n", 3284 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n",
3245 msg.Buffer[28]*256+msg.Buffer[29], 3285 msg.Buffer[28]*256+msg.Buffer[29],
3246 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32], 3286 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32],
3247 msg.Buffer[33]); 3287 msg.Buffer[33]);
3248 Date.Year = msg.Buffer[28]*256+msg.Buffer[29]; 3288 Date.Year = msg.Buffer[28]*256+msg.Buffer[29];
3249 if (entry->Type == GSM_CAL_BIRTHDAY) { 3289 if (entry->Type == GSM_CAL_BIRTHDAY) {
3250 Date.Year = entry->Entries[0].Date.Year; 3290 Date.Year = entry->Entries[0].Date.Year;
3251 smprintf(s,"%i\n",Date.Year); 3291 smprintf(s,"%i\n",Date.Year);
3252 } 3292 }
3253 Date.Month = msg.Buffer[30]; 3293 Date.Month = msg.Buffer[30];
3254 Date.Day = msg.Buffer[31]; 3294 Date.Day = msg.Buffer[31];
3255 Date.Hour = msg.Buffer[32]; 3295 Date.Hour = msg.Buffer[32];
3256 Date.Minute = msg.Buffer[33]; 3296 Date.Minute = msg.Buffer[33];
3257 /* Garbage seen with 3510i 3.51 */ 3297 /* Garbage seen with 3510i 3.51 */
3258 if (Date.Month == 0 && Date.Day == 0 && Date.Hour == 0 && Date.Minute == 0) return ERR_EMPTY; 3298 if (Date.Month == 0 && Date.Day == 0 && Date.Hour == 0 && Date.Minute == 0) return ERR_EMPTY;
3259 Date.Second= 0; 3299 Date.Second= 0;
3260 entry->Entries[0].EntryType = CAL_START_DATETIME; 3300 entry->Entries[0].EntryType = CAL_START_DATETIME;
3261 memcpy(&entry->Entries[0].Date,&Date,sizeof(GSM_DateTime)); 3301 memcpy(&entry->Entries[0].Date,&Date,sizeof(GSM_DateTime));
3262 entry->EntriesNum++; 3302 entry->EntriesNum++;
3263 3303
@@ -3305,241 +3345,247 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3305 entry->Entries[entry->EntriesNum].Date.Year, entry->Entries[entry->EntriesNum].Date.Hour, 3345 entry->Entries[entry->EntriesNum].Date.Year, entry->Entries[entry->EntriesNum].Date.Hour,
3306 entry->Entries[entry->EntriesNum].Date.Minute,entry->Entries[entry->EntriesNum].Date.Second); 3346 entry->Entries[entry->EntriesNum].Date.Minute,entry->Entries[entry->EntriesNum].Date.Second);
3307 3347
3308 entry->Entries[entry->EntriesNum].EntryType = CAL_ALARM_DATETIME; 3348 entry->Entries[entry->EntriesNum].EntryType = CAL_ALARM_DATETIME;
3309 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 && 3349 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 &&
3310 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00) 3350 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00)
3311 { 3351 {
3312 entry->Entries[entry->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; 3352 entry->Entries[entry->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME;
3313 smprintf(s, "Alarm type : Silent\n"); 3353 smprintf(s, "Alarm type : Silent\n");
3314 } 3354 }
3315 entry->EntriesNum++; 3355 entry->EntriesNum++;
3316 } 3356 }
3317 3357
3318 N71_65_GetCalendarRecurrance(s, msg.Buffer+40, entry); 3358 N71_65_GetCalendarRecurrance(s, msg.Buffer+40, entry);
3319 3359
3320 if (entry->Type == GSM_CAL_BIRTHDAY) { 3360 if (entry->Type == GSM_CAL_BIRTHDAY) {
3321 if (msg.Buffer[42] == 0xff && msg.Buffer[43] == 0xff) { 3361 if (msg.Buffer[42] == 0xff && msg.Buffer[43] == 0xff) {
3322 entry->Entries[0].Date.Year = 0; 3362 entry->Entries[0].Date.Year = 0;
3323 } else { 3363 } else {
3324 entry->Entries[0].Date.Year = msg.Buffer[42]*256+msg.Buffer[43]; 3364 entry->Entries[0].Date.Year = msg.Buffer[42]*256+msg.Buffer[43];
3325 } 3365 }
3326 } 3366 }
3327 3367
3328 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+54, msg.Buffer[51]*2); 3368 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+54, msg.Buffer[51]*2);
3329 entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2] = 0; 3369 entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2] = 0;
3330 entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2+1] = 0; 3370 entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2+1] = 0;
3331 entry->Entries[entry->EntriesNum].EntryType = CAL_TEXT; 3371 entry->Entries[entry->EntriesNum].EntryType = CAL_TEXT;
3332 entry->EntriesNum++; 3372 entry->EntriesNum++;
3333 smprintf(s, "Note text: \"%s\"\n",DecodeUnicodeString(entry->Entries[entry->EntriesNum-1].Text)); 3373 smprintf(s, "Note text: \"%s\"\n",DecodeUnicodeString(entry->Entries[entry->EntriesNum-1].Text));
3334 3374
3335 if (entry->Type == GSM_CAL_CALL) { 3375 if (entry->Type == GSM_CAL_CALL) {
3336 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2); 3376 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2);
3337 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0; 3377 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0;
3338 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0; 3378 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0;
3339 entry->Entries[entry->EntriesNum].EntryType = CAL_PHONE; 3379 entry->Entries[entry->EntriesNum].EntryType = CAL_PHONE;
3340 entry->EntriesNum++; 3380 entry->EntriesNum++;
3341 } 3381 }
3342 if (entry->Type == GSM_CAL_MEETING) { 3382 if (entry->Type == GSM_CAL_MEETING) {
3343 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2); 3383 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2);
3344 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0; 3384 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0;
3345 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0; 3385 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0;
3346 entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION; 3386 entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION;
3347 entry->EntriesNum++; 3387 entry->EntriesNum++;
3348 } 3388 }
3349 3389
3350 return ERR_NONE; 3390 return ERR_NONE;
3351} 3391}
3352 3392
3393static GSM_Error N6510_PrivGetGenericCalendar3(GSM_StateMachine *s, int Location, GSM_Phone_RequestID ID)
3394{
3395 unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
3396 0x00,0x99,/* Location */
3397 0xff,0xff,0xff,0xff};
3398
3399 req[8] = Location / 256;
3400 req[9] = Location % 256;
3401
3402 return GSM_WaitFor (s, req, 14, 0x13, 4, ID);
3403}
3404
3353static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear) 3405static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear)
3354{ 3406{
3355 GSM_Error error; 3407 GSM_Error error;
3356 GSM_DateTime date_time; 3408 GSM_DateTime date_time;
3357 unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
3358 0x00,0x99,/* Location */
3359 0xff,0xff,0xff,0xff,0x01};
3360 3409
3361 if (start) { 3410 if (start) {
3362 /* We have to get current year. It's NOT written in frame for 3411 /* We have to get current year. It's NOT written in frame for
3363 * Birthday 3412 * Birthday
3364 */ 3413 */
3365 error=s->Phone.Functions->GetDateTime(s,&date_time); 3414 error=s->Phone.Functions->GetDateTime(s,&date_time);
3366 switch (error) { 3415 switch (error) {
3367 case ERR_EMPTY: 3416 case ERR_EMPTY:
3368 case ERR_NOTIMPLEMENTED: 3417 case ERR_NOTIMPLEMENTED:
3369 GSM_GetCurrentDateTime(&date_time); 3418 GSM_GetCurrentDateTime(&date_time);
3370 break; 3419 break;
3371 case ERR_NONE: 3420 case ERR_NONE:
3372 break; 3421 break;
3373 default: 3422 default:
3374 return error; 3423 return error;
3375 } 3424 }
3376 *LastCalendarYear = date_time.Year; 3425 *LastCalendarYear = date_time.Year;
3377 } 3426 }
3378 3427
3379 Note->EntriesNum = 0; 3428 Note->EntriesNum = 0;
3380 Note->Entries[0].Date.Year = *LastCalendarYear; 3429 Note->Entries[0].Date.Year = *LastCalendarYear;
3381 3430
3382 req[8] = Note->Location / 256;
3383 req[9] = Note->Location % 256;
3384
3385 s->Phone.Data.Cal=Note; 3431 s->Phone.Data.Cal=Note;
3386 smprintf(s, "Getting calendar note method 3\n"); 3432 smprintf(s, "Getting calendar note method 3\n");
3387 return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetCalendarNote); 3433 return N6510_PrivGetGenericCalendar3(s, Note->Location, ID_GetCalendarNote);
3388} 3434}
3389 3435
3390/* method 3 */ 3436/* method 3 */
3391GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos) 3437GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos)
3392{ 3438{
3393 GSM_Error error; 3439 GSM_Error error;
3394 bool start2; 3440 bool start2;
3395 3441
3396 if (start) { 3442 if (start) {
3397 error=N6510_GetCalendarInfo3(s,LastCalendar,true); 3443 error=N6510_GetCalendarInfo3(s,LastCalendar,0);
3398 if (error!=ERR_NONE) return error; 3444 if (error!=ERR_NONE) return error;
3399 if (LastCalendar->Number == 0) return ERR_EMPTY; 3445 if (LastCalendar->Number == 0) return ERR_EMPTY;
3400 3446
3401 *LastCalendarPos = 0; 3447 *LastCalendarPos = 0;
3402 } else { 3448 } else {
3403 (*LastCalendarPos)++; 3449 (*LastCalendarPos)++;
3404 } 3450 }
3405 3451
3406 error = ERR_EMPTY; 3452 error = ERR_EMPTY;
3407 start2 = start; 3453 start2 = start;
3408 while (error == ERR_EMPTY) { 3454 while (error == ERR_EMPTY) {
3409 if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY; 3455 if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY;
3410 3456
3411 Note->Location = LastCalendar->Location[*LastCalendarPos]; 3457 Note->Location = LastCalendar->Location[*LastCalendarPos];
3412 error=N6510_PrivGetCalendar3(s, Note, start2, LastCalendarYear); 3458 error=N6510_PrivGetCalendar3(s, Note, start2, LastCalendarYear);
3413 if (error == ERR_EMPTY) (*LastCalendarPos)++; 3459 if (error == ERR_EMPTY) (*LastCalendarPos)++;
3414 3460
3415 start2 = false; 3461 start2 = false;
3416 } 3462 }
3417 return error; 3463 return error;
3418} 3464}
3419 3465
3420static GSM_Error N6510_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 3466static GSM_Error N6510_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
3421{ 3467{
3422 switch (msg.Buffer[3]) { 3468 switch (msg.Buffer[3]) {
3423 case 0x3B: 3469 case 0x3B:
3424 /* Old method 1 for accessing calendar */ 3470 /* Old method 1 for accessing calendar */
3425 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar); 3471 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar);
3426 case 0x9F: 3472 case 0x9F:
3427 smprintf(s, "Info with calendar notes locations received method 3\n"); 3473 smprintf(s, "Info with calendar notes locations received method 3\n");
3428 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar); 3474 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar);
3429 } 3475 }
3430 return ERR_UNKNOWNRESPONSE; 3476 return ERR_UNKNOWNRESPONSE;
3431} 3477}
3432 3478
3433/* method 3 */ 3479/* method 3 */
3434GSM_Error N6510_ReplyGetCalendarNotePos3(GSM_Protocol_Message msg, GSM_StateMachine *s,int *FirstCalendarPos) 3480GSM_Error N6510_ReplyGetCalendarNotePos3(GSM_Protocol_Message msg, GSM_StateMachine *s,int *FirstCalendarPos)
3435{ 3481{
3436 smprintf(s, "First calendar location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); 3482 smprintf(s, "First calendar location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
3437 *FirstCalendarPos = msg.Buffer[8]*256+msg.Buffer[9]; 3483 *FirstCalendarPos = msg.Buffer[8]*256+msg.Buffer[9];
3438 return ERR_NONE; 3484 return ERR_NONE;
3439} 3485}
3440 3486
3441/* method 3 */ 3487/* method 3 */
3442static GSM_Error N6510_GetCalendarNotePos3(GSM_StateMachine *s) 3488static GSM_Error N6510_GetCalendarNotePos3(GSM_StateMachine *s)
3443{ 3489{
3444 unsigned char req[] = {N6110_FRAME_HEADER, 0x95, 0x00}; 3490 unsigned char req[] = {N6110_FRAME_HEADER, 0x95, 0x00};
3445 3491
3446 smprintf(s, "Getting first free calendar note location\n"); 3492 smprintf(s, "Getting first free calendar note location\n");
3447 return GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNotePos); 3493 return GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNotePos);
3448} 3494}
3449 3495
3450static GSM_Error N6510_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s) 3496static GSM_Error N6510_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
3451{ 3497{
3452 switch (msg.Buffer[3]) { 3498 switch (msg.Buffer[3]) {
3453 case 0x32: 3499 case 0x32:
3454 /* Old method 1 for accessing calendar */ 3500 /* Old method 1 for accessing calendar */
3455 return N71_65_ReplyGetCalendarNotePos1(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos); 3501 return N71_65_ReplyGetCalendarNotePos1(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos);
3456 case 0x96: 3502 case 0x96:
3457 return N6510_ReplyGetCalendarNotePos3(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos); 3503 return N6510_ReplyGetCalendarNotePos3(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos);
3458 } 3504 }
3459 return ERR_UNKNOWNRESPONSE; 3505 return ERR_UNKNOWNRESPONSE;
3460} 3506}
3461 3507
3462static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntry *Entry, unsigned char *ID) 3508static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntry *Entry, unsigned char *ID)
3463{ 3509{
3464 int i,j,LastCalendarYear; 3510 int i,j,LastCalendarYear;
3465 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; 3511 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
3466 GSM_CalendarEntry Note; 3512 GSM_CalendarEntry Note;
3467 GSM_NOKIACalToDoLocationsLastCalendar1,LastCalendar2; 3513 GSM_NOKIACalToDoLocationsLastCalendar1,LastCalendar2;
3468 GSM_Error error; 3514 GSM_Error error;
3469 bool found; 3515 bool found;
3470 3516
3471 for(i=0;i<Priv->CalendarIconsNum;i++) { 3517 for(i=0;i<Priv->CalendarIconsNum;i++) {
3472 if (Priv->CalendarIconsTypes[i] == Entry->Type) { 3518 if (Priv->CalendarIconsTypes[i] == Entry->Type) {
3473 *ID = Priv->CalendarIcons[i]; 3519 *ID = Priv->CalendarIcons[i];
3474 return ERR_NONE; 3520 return ERR_NONE;
3475 } 3521 }
3476 } 3522 }
3477 3523
3478 smprintf(s, "Starting finding note ID\n"); 3524 smprintf(s, "Starting finding note ID\n");
3479 3525
3480 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); 3526 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
3481 memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); 3527 memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
3482 if (error != ERR_NONE) return error; 3528 if (error != ERR_NONE) return error;
3483 3529
3484 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) || 3530 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) ||
3485 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) || 3531 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) ||
3486 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3532 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3487 error=N71_65_AddCalendar2(s,Entry); 3533 error=N71_65_AddCalendar2(s,Entry);
3488 } else { 3534 } else {
3489 if (Entry->Type == GSM_CAL_MEETING) { 3535 if (Entry->Type == GSM_CAL_MEETING) {
3490 error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3536 error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3491 } else { 3537 } else {
3492 error=N71_65_AddCalendar2(s,Entry); 3538 error=N71_65_AddCalendar2(s,Entry);
3493 } 3539 }
3494 } 3540 }
3495 if (error != ERR_NONE) return error; 3541 if (error != ERR_NONE) return error;
3496 3542
3497 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); 3543 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
3498 memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); 3544 memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
3499 if (error != ERR_NONE) return error; 3545 if (error != ERR_NONE) return error;
3500 3546
3501 smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number); 3547 smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number);
3502 3548
3503 for(i=0;i<LastCalendar2.Number;i++) { 3549 for(i=0;i<LastCalendar2.Number;i++) {
3504 found = true; 3550 found = true;
3505 for(j=0;j<LastCalendar1.Number;j++) { 3551 for(j=0;j<LastCalendar1.Number;j++) {
3506 if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) { 3552 if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) {
3507 found = false; 3553 found = false;
3508 break; 3554 break;
3509 } 3555 }
3510 } 3556 }
3511 if (found) { 3557 if (found) {
3512 Note.Location = LastCalendar2.Location[i]; 3558 Note.Location = LastCalendar2.Location[i];
3513 error=N6510_PrivGetCalendar3(s, &Note, true, &LastCalendarYear); 3559 error=N6510_PrivGetCalendar3(s, &Note, true, &LastCalendarYear);
3514 if (error != ERR_NONE) return error; 3560 if (error != ERR_NONE) return error;
3515 3561
3516 error=N71_65_DelCalendar(s, &Note); 3562 error=N71_65_DelCalendar(s, &Note);
3517 if (error != ERR_NONE) return error; 3563 if (error != ERR_NONE) return error;
3518 3564
3519 smprintf(s, "Ending finding note ID\n"); 3565 smprintf(s, "Ending finding note ID\n");
3520 3566
3521 for(j=0;j<Priv->CalendarIconsNum;j++) { 3567 for(j=0;j<Priv->CalendarIconsNum;j++) {
3522 if (Priv->CalendarIconsTypes[j] == Entry->Type) { 3568 if (Priv->CalendarIconsTypes[j] == Entry->Type) {
3523 *ID = Priv->CalendarIcons[j]; 3569 *ID = Priv->CalendarIcons[j];
3524 return ERR_NONE; 3570 return ERR_NONE;
3525 } 3571 }
3526 } 3572 }
3527 return ERR_UNKNOWN; 3573 return ERR_UNKNOWN;
3528 } 3574 }
3529 } 3575 }
3530 3576
3531 return ERR_UNKNOWN; 3577 return ERR_UNKNOWN;
3532} 3578}
3533 3579
3534/* method 3 */ 3580/* method 3 */
3535static GSM_Error N6510_ReplyAddCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) 3581static GSM_Error N6510_ReplyAddCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3536{ 3582{
3537 smprintf(s, "Calendar note added\n"); 3583 smprintf(s, "Calendar note added\n");
3538 return ERR_NONE; 3584 return ERR_NONE;
3539} 3585}
3540 3586
3541/* method 3 */ 3587/* method 3 */
3542GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int *FirstCalendarPos) 3588GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int *FirstCalendarPos)
3543{ 3589{
3544 GSM_CalendarNoteTypeNoteType, OldNoteType; 3590 GSM_CalendarNoteTypeNoteType, OldNoteType;
3545 time_t t_time1,t_time2; 3591 time_t t_time1,t_time2;
@@ -3692,97 +3738,97 @@ GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int *
3692 req[count++] = 0x00; 3738 req[count++] = 0x00;
3693 3739
3694 smprintf(s, "Writing calendar note method 3\n"); 3740 smprintf(s, "Writing calendar note method 3\n");
3695 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetCalendarNote); 3741 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetCalendarNote);
3696} 3742}
3697 3743
3698static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 3744static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
3699{ 3745{
3700#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3746#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3701 /* Method 1. Some features missed. Not working with some notes in 3510 */ 3747 /* Method 1. Some features missed. Not working with some notes in 3510 */
3702 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3748 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3703#endif 3749#endif
3704 3750
3705 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3751 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3706 /* Method 1. Some features missed. Not working with some notes in 3510 */ 3752 /* Method 1. Some features missed. Not working with some notes in 3510 */
3707 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3753 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3708 3754
3709 /* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */ 3755 /* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */
3710 // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3756 // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3711 } else { 3757 } else {
3712 /* Method 3. All DCT4 features supported. Not supported by 8910 */ 3758 /* Method 3. All DCT4 features supported. Not supported by 8910 */
3713 return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3759 return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3714 } 3760 }
3715} 3761}
3716 3762
3717static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 3763static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
3718{ 3764{
3719 GSM_Error error; 3765 GSM_Error error;
3720 3766
3721#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3767#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3722 /* Method 1 */ 3768 /* Method 1 */
3723 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); 3769 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
3724 if (error!=ERR_NONE) return error; 3770 if (error!=ERR_NONE) return error;
3725 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3771 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3726 return ERR_NONE; 3772 return ERR_NONE;
3727#endif 3773#endif
3728 3774
3729 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3775 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3730 /* Method 1 */ 3776 /* Method 1 */
3731 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); 3777 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
3732 if (error!=ERR_NONE) return error; 3778 if (error!=ERR_NONE) return error;
3733 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3779 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3734 return ERR_NONE; 3780 return ERR_NONE;
3735 3781
3736 /* Method 2 */ 3782 /* Method 2 */
3737 // return ERR_NOTSUPPORTED; 3783 // return ERR_NOTSUPPORTED;
3738 } else { 3784 } else {
3739 /* Method 3 */ 3785 /* Method 3 */
3740 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,true); 3786 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0);
3741 if (error!=ERR_NONE) return error; 3787 if (error!=ERR_NONE) return error;
3742 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3788 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3743 return ERR_NONE; 3789 return ERR_NONE;
3744 } 3790 }
3745} 3791}
3746 3792
3747static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3793static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3748{ 3794{
3749#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3795#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3750 return N71_65_AddCalendar2(s,Note); 3796 return N71_65_AddCalendar2(s,Note);
3751#endif 3797#endif
3752 3798
3753 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3799 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3754 return N71_65_AddCalendar2(s,Note); 3800 return N71_65_AddCalendar2(s,Note);
3755 // return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3801 // return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3756 } else { 3802 } else {
3757 /* Method 3. All DCT4 features supported. Not supported by 8910 */ 3803 /* Method 3. All DCT4 features supported. Not supported by 8910 */
3758 return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3804 return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3759 } 3805 }
3760} 3806}
3761 3807
3762static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s) 3808static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s)
3763{ 3809{
3764 smprintf(s, "Probably phone says: I log into network\n"); 3810 smprintf(s, "Probably phone says: I log into network\n");
3765 return ERR_NONE; 3811 return ERR_NONE;
3766} 3812}
3767 3813
3768void N6510_EncodeFMFrequency(double freq, unsigned char *buff) 3814void N6510_EncodeFMFrequency(double freq, unsigned char *buff)
3769{ 3815{
3770 double freq0; 3816 double freq0;
3771 unsigned char buffer[20]; 3817 unsigned char buffer[20];
3772 unsigned int i,freq2; 3818 unsigned int i,freq2;
3773 3819
3774 sprintf(buffer,"%.3f",freq); 3820 sprintf(buffer,"%.3f",freq);
3775 for (i=0;i<strlen(buffer);i++) { 3821 for (i=0;i<strlen(buffer);i++) {
3776 if (buffer[i] == ',' || buffer[i] == '.') buffer[i] = ' '; 3822 if (buffer[i] == ',' || buffer[i] == '.') buffer[i] = ' ';
3777 } 3823 }
3778 StringToDouble(buffer, &freq0); 3824 StringToDouble(buffer, &freq0);
3779 freq2 = (unsigned int)freq0; 3825 freq2 = (unsigned int)freq0;
3780 dbgprintf("Frequency: %s %i\n",buffer,freq2); 3826 dbgprintf("Frequency: %s %i\n",buffer,freq2);
3781 freq2= freq2 - 0xffff; 3827 freq2= freq2 - 0xffff;
3782 buff[0] = freq2 / 0x100; 3828 buff[0] = freq2 / 0x100;
3783 buff[1] = freq2 % 0x100; 3829 buff[1] = freq2 % 0x100;
3784} 3830}
3785 3831
3786void N6510_DecodeFMFrequency(double *freq, unsigned char *buff) 3832void N6510_DecodeFMFrequency(double *freq, unsigned char *buff)
3787{ 3833{
3788 unsigned char buffer[20]; 3834 unsigned char buffer[20];
@@ -3927,180 +3973,216 @@ static GSM_Error N6510_SetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStati
3927 smprintf(s, "Setting FM Station %i\n",FMStation->Location); 3973 smprintf(s, "Setting FM Station %i\n",FMStation->Location);
3928 return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation); 3974 return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation);
3929} 3975}
3930 3976
3931static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s) 3977static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s)
3932{ 3978{
3933 smprintf(s, "Light set\n"); 3979 smprintf(s, "Light set\n");
3934 return ERR_NONE; 3980 return ERR_NONE;
3935} 3981}
3936 3982
3937GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable) 3983GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable)
3938{ 3984{
3939 unsigned char req[14] = { 3985 unsigned char req[14] = {
3940 N6110_FRAME_HEADER, 0x05, 3986 N6110_FRAME_HEADER, 0x05,
3941 0x01, /* 0x01 = Display, 0x03 = keypad */ 3987 0x01, /* 0x01 = Display, 0x03 = keypad */
3942 0x01, /* 0x01 = Enable, 0x02 = disable */ 3988 0x01, /* 0x01 = Enable, 0x02 = disable */
3943 0x00, 0x00, 0x00, 0x01, 3989 0x00, 0x00, 0x00, 0x01,
3944 0x05, 0x04, 0x02, 0x00}; 3990 0x05, 0x04, 0x02, 0x00};
3945 3991
3946 req[4] = light; 3992 req[4] = light;
3947 if (!enable) req[5] = 0x02; 3993 if (!enable) req[5] = 0x02;
3948 smprintf(s, "Setting light\n"); 3994 smprintf(s, "Setting light\n");
3949 return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight); 3995 return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight);
3950} 3996}
3951 3997
3952static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable) 3998static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
3953{ 3999{
3954 GSM_Error error; 4000 GSM_Error error;
3955 4001
3956 if (enable) { 4002 if (enable) {
3957 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true); 4003 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true);
3958 if (error != ERR_NONE) return error; 4004 if (error != ERR_NONE) return error;
3959 4005
3960 error=N6510_SetLight(s,N6510_LIGHT_TORCH,true); 4006 error=N6510_SetLight(s,N6510_LIGHT_TORCH,true);
3961 if (error != ERR_NONE) return error; 4007 if (error != ERR_NONE) return error;
3962 4008
3963 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true); 4009 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true);
3964 } else { 4010 } else {
3965 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false); 4011 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false);
3966 if (error != ERR_NONE) return error; 4012 if (error != ERR_NONE) return error;
3967 4013
3968 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false); 4014 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false);
3969 if (error != ERR_NONE) return error; 4015 if (error != ERR_NONE) return error;
3970 4016
3971 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false); 4017 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false);
3972 } 4018 }
3973} 4019}
3974 4020
4021static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
4022{
4023 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote);
4024}
4025
4026static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
4027{
4028 smprintf(s, "Note received\n");
4029 memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2);
4030 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0;
4031 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0;
4032 return ERR_NONE;
4033}
4034
4035GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start)
4036{
4037 GSM_Error error;
4038 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4039
4040 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
4041
4042 if (start) {
4043 error=N6510_GetCalendarInfo3(s,LastNote,2);
4044 if (error!=ERR_NONE) return error;
4045 Note->Location = 1;
4046 } else {
4047 Note->Location++;
4048 }
4049
4050 if (Note->Location > LastNote->Number) return ERR_EMPTY;
4051
4052 s->Phone.Data.Note = Note;
4053 smprintf(s, "Getting note\n");
4054 return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote);
4055}
4056
3975static int N6510_FindFileCheckSum(unsigned char *ptr, int len) 4057static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
3976{ 4058{
3977 int acc, i, accx; 4059 int acc, i, accx;
3978 4060
3979 accx = 0; 4061 accx = 0;
3980 acc = 0xffff; 4062 acc = 0xffff;
3981 while (len--) { 4063 while (len--) {
3982 accx = (accx & 0xffff00ff) | (acc & 0xff00); 4064 accx = (accx & 0xffff00ff) | (acc & 0xff00);
3983 acc = (acc & 0xffff00ff) | *ptr++ << 8; 4065 acc = (acc & 0xffff00ff) | *ptr++ << 8;
3984 for (i = 0; i < 8; i++) { 4066 for (i = 0; i < 8; i++) {
3985 acc <<= 1; 4067 acc <<= 1;
3986 if (acc & 0x10000) acc ^= 0x1021; 4068 if (acc & 0x10000) acc ^= 0x1021;
3987 if (accx & 0x80000000) acc ^= 0x1021; 4069 if (accx & 0x80000000) acc ^= 0x1021;
3988 accx <<= 1; 4070 accx <<= 1;
3989 } 4071 }
3990 } 4072 }
3991 dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff)); 4073 dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff));
3992 return (acc & 0xffff); 4074 return (acc & 0xffff);
3993} 4075}
3994 4076
3995static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 4077static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
3996{ 4078{
3997 GSM_File *File = s->Phone.Data.FileInfo; 4079 GSM_File *File = s->Phone.Data.FileInfo;
3998 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4080 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
3999 int i; 4081 int i;
4000 4082
4001 switch (msg.Buffer[3]) { 4083 switch (msg.Buffer[3]) {
4002 case 0x15: 4084 case 0x15:
4003 smprintf(s,"File or folder details received\n"); 4085 smprintf(s,"File or folder details received\n");
4004 CopyUnicodeString(File->Name,msg.Buffer+10); 4086 CopyUnicodeString(File->Name,msg.Buffer+10);
4005 if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY; 4087 if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY;
4006 if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN; 4088 if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN;
4007 4089
4008 i = msg.Buffer[8]*256+msg.Buffer[9]; 4090 i = msg.Buffer[8]*256+msg.Buffer[9];
4009 dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 4091 dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
4010 msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3], 4092 msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3],
4011 msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i], 4093 msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i],
4012 msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]); 4094 msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]);
4013 4095
4014 File->Folder = false; 4096 File->Folder = false;
4015 if (msg.Buffer[i-5] == 0x00) File->Folder = true; 4097 if (msg.Buffer[i-5] == 0x00) File->Folder = true;
4016 4098
4017 File->ReadOnly = false; 4099 File->ReadOnly = false;
4018 File->Protected = false; 4100 File->Protected = false;
4019 File->System= false; 4101 File->System= false;
4020 File->Hidden= false; 4102 File->Hidden= false;
4021 if (msg.Buffer[i+2] == 0x01) File->Protected = true; 4103 if (msg.Buffer[i+2] == 0x01) File->Protected = true;
4022 if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true; 4104 if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true;
4023 if (msg.Buffer[i+5] == 0x01) File->Hidden= true; 4105 if (msg.Buffer[i+5] == 0x01) File->Hidden= true;
4024 if (msg.Buffer[i+6] == 0x01) File->System= true;//fixme 4106 if (msg.Buffer[i+6] == 0x01) File->System= true;//fixme
4025 4107
4026 File->ModifiedEmpty = false; 4108 File->ModifiedEmpty = false;
4027 NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified); 4109 NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified);
4028 if (File->Modified.Year == 0x00) File->ModifiedEmpty = true; 4110 if (File->Modified.Year == 0x00) File->ModifiedEmpty = true;
4029 dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]); 4111 dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]);
4030 4112
4031 Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9]; 4113 Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9];
4032 Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1]; 4114 Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1];
4033 smprintf(s,"ParentID is %i\n",Priv->ParentID); 4115 smprintf(s,"ParentID is %i\n",Priv->ParentID);
4034 4116
4035 File->Type = GSM_File_Other; 4117 File->Type = GSM_File_Other;
4036 if (msg.Length > 240){ 4118 if (msg.Length > 240){
4037 i = 227; 4119 i = 227;
4038 if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01) 4120 if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01)
4039 File->Type = GSM_File_Image_JPG; 4121 File->Type = GSM_File_Image_JPG;
4040 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02) 4122 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02)
4041 File->Type = GSM_File_Image_BMP; 4123 File->Type = GSM_File_Image_BMP;
4042 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07) 4124 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07)
4043 File->Type = GSM_File_Image_BMP; 4125 File->Type = GSM_File_Image_BMP;
4044 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03) 4126 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03)
4045 File->Type = GSM_File_Image_PNG; 4127 File->Type = GSM_File_Image_PNG;
4046 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05) 4128 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05)
4047 File->Type = GSM_File_Image_GIF; 4129 File->Type = GSM_File_Image_GIF;
4048 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09) 4130 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09)
4049 File->Type = GSM_File_Image_WBMP; 4131 File->Type = GSM_File_Image_WBMP;
4050 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01) 4132 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01)
4051 File->Type = GSM_File_Sound_AMR; 4133 File->Type = GSM_File_Sound_AMR;
4052 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02) 4134 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02)
4053 File->Type = GSM_File_Sound_MIDI; 4135 File->Type = GSM_File_Sound_MIDI;
4054 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05) 4136 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05)
4055 File->Type = GSM_File_Video_3GP; 4137 File->Type = GSM_File_Video_3GP;
4056 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01) 4138 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01)
4057 File->Type = GSM_File_Java_JAR; 4139 File->Type = GSM_File_Java_JAR;
4058#if DEVELOP 4140#ifdef DEVELOP
4059 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01) 4141 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01)
4060 File->Type = GSM_File_MMS; 4142 File->Type = GSM_File_MMS;
4061#endif 4143#endif
4062 } 4144 }
4063 return ERR_NONE; 4145 return ERR_NONE;
4064 case 0x2F: 4146 case 0x2F:
4065 smprintf(s,"File or folder used bytes received\n"); 4147 smprintf(s,"File or folder used bytes received\n");
4066 File->Used = msg.Buffer[6]*256*256*256+ 4148 File->Used = msg.Buffer[6]*256*256*256+
4067 msg.Buffer[7]*256*256+ 4149 msg.Buffer[7]*256*256+
4068 msg.Buffer[8]*256+ 4150 msg.Buffer[8]*256+
4069 msg.Buffer[9]; 4151 msg.Buffer[9];
4070 return ERR_NONE; 4152 return ERR_NONE;
4071 case 0x33: 4153 case 0x33:
4072 if (s->Phone.Data.RequestID == ID_GetFileInfo) { 4154 if (s->Phone.Data.RequestID == ID_GetFileInfo) {
4073 i = Priv->FilesLocationsUsed-1; 4155 i = Priv->FilesLocationsUsed-1;
4074 while (1) { 4156 while (1) {
4075 if (i==Priv->FilesLocationsCurrent-1) break; 4157 if (i==Priv->FilesLocationsCurrent-1) break;
4076 dbgprintf("Copying %i to %i, max %i, current %i\n", 4158 dbgprintf("Copying %i to %i, max %i, current %i\n",
4077 i,i+msg.Buffer[9], 4159 i,i+msg.Buffer[9],
4078 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent); 4160 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent);
4079 Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i]; 4161 Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i];
4080 Priv->FilesLevels[i+msg.Buffer[9]]= Priv->FilesLevels[i]; 4162 Priv->FilesLevels[i+msg.Buffer[9]]= Priv->FilesLevels[i];
4081 i--; 4163 i--;
4082 } 4164 }
4083 Priv->FilesLocationsUsed += msg.Buffer[9]; 4165 Priv->FilesLocationsUsed += msg.Buffer[9];
4084 for (i=0;i<msg.Buffer[9];i++) { 4166 for (i=0;i<msg.Buffer[9];i++) {
4085 Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4]; 4167 Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4];
4086 Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1; 4168 Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1;
4087 dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]); 4169 dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]);
4088 } 4170 }
4089 dbgprintf("\n"); 4171 dbgprintf("\n");
4090 } 4172 }
4091 if (msg.Buffer[9] != 0x00) File->Folder = true; 4173 if (msg.Buffer[9] != 0x00) File->Folder = true;
4092 return ERR_NONE; 4174 return ERR_NONE;
4093 case 0x43: 4175 case 0x43:
4094 Priv->FileCheckSum = msg.Buffer[6] * 256 + msg.Buffer[7]; 4176 Priv->FileCheckSum = msg.Buffer[6] * 256 + msg.Buffer[7];
4095 smprintf(s,"File checksum from phone is %04X\n",Priv->FileCheckSum); 4177 smprintf(s,"File checksum from phone is %04X\n",Priv->FileCheckSum);
4096 return ERR_NONE; 4178 return ERR_NONE;
4097 } 4179 }
4098 return ERR_UNKNOWNRESPONSE; 4180 return ERR_UNKNOWNRESPONSE;
4099} 4181}
4100 4182
4101static GSM_Error N6510_GetFileFolderInfo(GSM_StateMachine *s, GSM_File *File, GSM_Phone_RequestID Request) 4183static GSM_Error N6510_GetFileFolderInfo(GSM_StateMachine *s, GSM_File *File, GSM_Phone_RequestID Request)
4102{ 4184{
4103 GSM_Error error; 4185 GSM_Error error;
4104 unsigned char req[10] = { 4186 unsigned char req[10] = {
4105 N7110_FRAME_HEADER, 4187 N7110_FRAME_HEADER,
4106 0x14, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */ 4188 0x14, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */
@@ -4353,97 +4435,97 @@ static GSM_Error N6510_SetReadOnly(GSM_StateMachine *s, unsigned char *ID, bool
4353 smprintf(s, "Setting readonly attribute\n"); 4435 smprintf(s, "Setting readonly attribute\n");
4354 return GSM_WaitFor (s, SetAttr, 10, 0x6D, 4, ID_DeleteFile); 4436 return GSM_WaitFor (s, SetAttr, 10, 0x6D, 4, ID_DeleteFile);
4355} 4437}
4356 4438
4357static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMachine *s) 4439static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMachine *s)
4358{ 4440{
4359 switch (msg.Buffer[3]) { 4441 switch (msg.Buffer[3]) {
4360 case 0x03: 4442 case 0x03:
4361 smprintf(s,"File header added\n"); 4443 smprintf(s,"File header added\n");
4362 sprintf(s->Phone.Data.File->ID_FullName,"%i",msg.Buffer[9]); 4444 sprintf(s->Phone.Data.File->ID_FullName,"%i",msg.Buffer[9]);
4363 return ERR_NONE; 4445 return ERR_NONE;
4364 case 0x13: 4446 case 0x13:
4365 return ERR_NONE; 4447 return ERR_NONE;
4366 } 4448 }
4367 return ERR_UNKNOWNRESPONSE; 4449 return ERR_UNKNOWNRESPONSE;
4368} 4450}
4369 4451
4370static GSM_Error N6510_ReplyAddFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s) 4452static GSM_Error N6510_ReplyAddFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s)
4371{ 4453{
4372 return ERR_NONE; 4454 return ERR_NONE;
4373} 4455}
4374 4456
4375static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos) 4457static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos)
4376{ 4458{
4377 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4459 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
4378 GSM_File File2; 4460 GSM_File File2;
4379 GSM_Error error; 4461 GSM_Error error;
4380 int j; 4462 int j;
4381 unsigned char Header[400] = { 4463 unsigned char Header[400] = {
4382 N7110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x01, 4464 N7110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x01,
4383 0x00, 0x0C, /* parent folder ID */ 4465 0x00, 0x0C, /* parent folder ID */
4384 0x00, 0x00, 0x00, 0xE8}; 4466 0x00, 0x00, 0x00, 0xE8};
4385 unsigned char Add[15000] = { 4467 unsigned char Add[15000] = {
4386 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01, 4468 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01,
4387 0x00, 0x04, /* file ID */ 4469 0x00, 0x04, /* file ID */
4388 0x00, 0x00, 4470 0x00, 0x00,
4389 0x01, 0x28}; /* length */ 4471 0x01, 0x28}; /* length */
4390 unsigned char end[30] = { 4472 unsigned char end[30] = {
4391 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01, 4473 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01,
4392 0x00, 0x04, /* file ID */ 4474 0x00, 0x04, /* file ID */
4393 0x00, 0x00, 0x00, 0x00}; 4475 0x00, 0x00, 0x00, 0x00};
4394 4476
4395 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4477 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4396 4478
4397 s->Phone.Data.File = File; 4479 s->Phone.Data.File = File;
4398 4480
4399 if (*Pos == 0) { 4481 if (*Pos == 0) {
4400 error = N6510_SearchForFileName(s,File); 4482 error = N6510_SearchForFileName(s,File);
4401 if (error == ERR_NONE) return ERR_INVALIDLOCATION; 4483 if (error == ERR_NONE) return ERR_FILEALREADYEXIST;
4402 if (error != ERR_EMPTY) return error; 4484 if (error != ERR_EMPTY) return error;
4403 4485
4404 Header[8] = atoi(File->ID_FullName) / 256; 4486 Header[8] = atoi(File->ID_FullName) / 256;
4405 Header[9] = atoi(File->ID_FullName) % 256; 4487 Header[9] = atoi(File->ID_FullName) % 256;
4406 memset(Header+14, 0x00, 300); 4488 memset(Header+14, 0x00, 300);
4407 CopyUnicodeString(Header+14,File->Name); 4489 CopyUnicodeString(Header+14,File->Name);
4408 Header[222] = File->Used / (256*256*256); 4490 Header[222] = File->Used / (256*256*256);
4409 Header[223] = File->Used / (256*256); 4491 Header[223] = File->Used / (256*256);
4410 Header[224] = File->Used / 256; 4492 Header[224] = File->Used / 256;
4411 Header[225] = File->Used % 256; 4493 Header[225] = File->Used % 256;
4412 switch(File->Type) { 4494 switch(File->Type) {
4413 case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break; 4495 case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break;
4414 case GSM_File_Image_BMP : Header[231]=0x02; Header[233]=0x02; break; 4496 case GSM_File_Image_BMP : Header[231]=0x02; Header[233]=0x02; break;
4415 case GSM_File_Image_PNG : Header[231]=0x02; Header[233]=0x03; break; 4497 case GSM_File_Image_PNG : Header[231]=0x02; Header[233]=0x03; break;
4416 case GSM_File_Image_GIF : Header[231]=0x02; Header[233]=0x05; break; 4498 case GSM_File_Image_GIF : Header[231]=0x02; Header[233]=0x05; break;
4417 case GSM_File_Image_WBMP : Header[231]=0x02; Header[233]=0x09; break; 4499 case GSM_File_Image_WBMP : Header[231]=0x02; Header[233]=0x09; break;
4418 case GSM_File_Sound_AMR : Header[231]=0x04; Header[233]=0x01; break; 4500 case GSM_File_Sound_AMR : Header[231]=0x04; Header[233]=0x01; break;
4419 case GSM_File_Sound_MIDI : Header[231]=0x04; Header[233]=0x05; break; //Header[238]=0x01; 4501 case GSM_File_Sound_MIDI : Header[231]=0x04; Header[233]=0x05; break; //Header[238]=0x01;
4420 case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break; 4502 case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break;
4421 case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break; 4503 case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break;
4422 case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break; 4504 case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break;
4423#ifdef DEVELOP 4505#ifdef DEVELOP
4424 case GSM_File_MMS: 4506 case GSM_File_MMS:
4425 Header[214]=0x07; 4507 Header[214]=0x07;
4426 Header[215]=0xd3; 4508 Header[215]=0xd3;
4427 Header[216]=0x06; 4509 Header[216]=0x06;
4428 Header[217]=0x01; 4510 Header[217]=0x01;
4429 Header[218]=0x12; 4511 Header[218]=0x12;
4430 Header[219]=0x13; 4512 Header[219]=0x13;
4431 Header[220]=0x29; 4513 Header[220]=0x29;
4432 Header[233]=0x01; 4514 Header[233]=0x01;
4433 break; 4515 break;
4434#endif 4516#endif
4435 default : Header[231]=0x01; Header[233]=0x05; 4517 default : Header[231]=0x01; Header[233]=0x05;
4436 } 4518 }
4437 Header[235] = 0x01; 4519 Header[235] = 0x01;
4438 Header[236] = atoi(File->ID_FullName) / 256; 4520 Header[236] = atoi(File->ID_FullName) / 256;
4439 Header[237] = atoi(File->ID_FullName) % 256; 4521 Header[237] = atoi(File->ID_FullName) % 256;
4440 if (File->Protected) Header[238] = 0x01; //Nokia forward lock 4522 if (File->Protected) Header[238] = 0x01; //Nokia forward lock
4441 if (File->Hidden) Header[241] = 0x01; 4523 if (File->Hidden) Header[241] = 0x01;
4442 if (File->System) Header[242] = 0x01; //fixme 4524 if (File->System) Header[242] = 0x01; //fixme
4443 smprintf(s, "Adding file header\n"); 4525 smprintf(s, "Adding file header\n");
4444 error=GSM_WaitFor (s, Header, 246, 0x6D, 4, ID_AddFile); 4526 error=GSM_WaitFor (s, Header, 246, 0x6D, 4, ID_AddFile);
4445 if (error != ERR_NONE) return error; 4527 if (error != ERR_NONE) return error;
4446 } 4528 }
4447 4529
4448 j = 1000; 4530 j = 1000;
4449 if (File->Used - *Pos < 1000) j = File->Used - *Pos; 4531 if (File->Used - *Pos < 1000) j = File->Used - *Pos;
@@ -4769,97 +4851,97 @@ static GSM_Error N6510_SetGPRSAccessPoint(GSM_StateMachine *s, GSM_GPRSAccessPoi
4769 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint); 4851 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint);
4770 if (error != ERR_NONE) return error; 4852 if (error != ERR_NONE) return error;
4771 } 4853 }
4772 4854
4773 return error; 4855 return error;
4774} 4856}
4775 4857
4776/* ToDo support - 6310 style */ 4858/* ToDo support - 6310 style */
4777static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMachine *s) 4859static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMachine *s)
4778{ 4860{
4779 int i; 4861 int i;
4780 GSM_NOKIACalToDoLocations*Last = &s->Phone.Data.Priv.N6510.LastToDo; 4862 GSM_NOKIACalToDoLocations*Last = &s->Phone.Data.Priv.N6510.LastToDo;
4781 4863
4782 smprintf(s, "TODO locations received\n"); 4864 smprintf(s, "TODO locations received\n");
4783 Last->Number=msg.Buffer[6]*256+msg.Buffer[7]; 4865 Last->Number=msg.Buffer[6]*256+msg.Buffer[7];
4784 smprintf(s, "Number of Entries: %i\n",Last->Number); 4866 smprintf(s, "Number of Entries: %i\n",Last->Number);
4785 smprintf(s, "Locations: "); 4867 smprintf(s, "Locations: ");
4786 for (i=0;i<Last->Number;i++) { 4868 for (i=0;i<Last->Number;i++) {
4787 Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13]; 4869 Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13];
4788 smprintf(s, "%i ",Last->Location[i]); 4870 smprintf(s, "%i ",Last->Location[i]);
4789 } 4871 }
4790 smprintf(s, "\n"); 4872 smprintf(s, "\n");
4791 return ERR_NONE; 4873 return ERR_NONE;
4792} 4874}
4793 4875
4794/* ToDo support - 6310 style */ 4876/* ToDo support - 6310 style */
4795static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status) 4877static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status)
4796{ 4878{
4797 GSM_Error error; 4879 GSM_Error error;
4798 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4880 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4799 unsigned char reqLoc[] = { 4881 unsigned char reqLoc[] = {
4800 N6110_FRAME_HEADER, 4882 N6110_FRAME_HEADER,
4801 0x15, 0x01, 0x00, 0x00, 4883 0x15, 0x01, 0x00, 0x00,
4802 0x00, 0x00, 0x00}; 4884 0x00, 0x00, 0x00};
4803 4885
4804 smprintf(s, "Getting ToDo locations\n"); 4886 smprintf(s, "Getting ToDo locations\n");
4805 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo); 4887 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo);
4806 if (error != ERR_NONE) return error; 4888 if (error != ERR_NONE) return error;
4807 4889
4808 status->Used = LastToDo->Number; 4890 status->Used = LastToDo->Number;
4809 return ERR_NONE; 4891 return ERR_NONE;
4810} 4892}
4811 4893
4812static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status) 4894static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status)
4813{ 4895{
4814 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4896 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4815 GSM_Error error; 4897 GSM_Error error;
4816 4898
4817 error = N6510_GetCalendarInfo3(s,LastToDo,false); 4899 error = N6510_GetCalendarInfo3(s,LastToDo,1);
4818 if (error!=ERR_NONE) return error; 4900 if (error!=ERR_NONE) return error;
4819 4901
4820 status->Used = LastToDo->Number; 4902 status->Used = LastToDo->Number;
4821 return ERR_NONE; 4903 return ERR_NONE;
4822} 4904}
4823 4905
4824static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 4906static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
4825{ 4907{
4826 status->Used = 0; 4908 status->Used = 0;
4827 4909
4828 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 4910 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
4829 return N6510_GetToDoStatus1(s, status); 4911 return N6510_GetToDoStatus1(s, status);
4830 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 4912 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
4831 return N6510_GetToDoStatus2(s, status); 4913 return N6510_GetToDoStatus2(s, status);
4832 } else { 4914 } else {
4833 return ERR_NOTSUPPORTED; 4915 return ERR_NOTSUPPORTED;
4834 } 4916 }
4835} 4917}
4836 4918
4837/* ToDo support - 6310 style */ 4919/* ToDo support - 6310 style */
4838static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 4920static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
4839{ 4921{
4840 GSM_ToDoEntry *Last = s->Phone.Data.ToDo; 4922 GSM_ToDoEntry *Last = s->Phone.Data.ToDo;
4841 4923
4842 smprintf(s, "TODO received method 1\n"); 4924 smprintf(s, "TODO received method 1\n");
4843 4925
4844 switch (msg.Buffer[4]) { 4926 switch (msg.Buffer[4]) {
4845 case 1 : Last->Priority = GSM_Priority_High; break; 4927 case 1 : Last->Priority = GSM_Priority_High; break;
4846 case 2 : Last->Priority = GSM_Priority_Medium; break; 4928 case 2 : Last->Priority = GSM_Priority_Medium; break;
4847 case 3 : Last->Priority = GSM_Priority_Low; break; 4929 case 3 : Last->Priority = GSM_Priority_Low; break;
4848 default: return ERR_UNKNOWN; 4930 default: return ERR_UNKNOWN;
4849 } 4931 }
4850 smprintf(s, "Priority: %i\n",msg.Buffer[4]); 4932 smprintf(s, "Priority: %i\n",msg.Buffer[4]);
4851 4933
4852 CopyUnicodeString(Last->Entries[0].Text,msg.Buffer+14); 4934 CopyUnicodeString(Last->Entries[0].Text,msg.Buffer+14);
4853 Last->Entries[0].EntryType = TODO_TEXT; 4935 Last->Entries[0].EntryType = TODO_TEXT;
4854 Last->EntriesNum = 1; 4936 Last->EntriesNum = 1;
4855 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); 4937 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text));
4856 4938
4857 return ERR_NONE; 4939 return ERR_NONE;
4858} 4940}
4859 4941
4860/* ToDo support - 6310 style */ 4942/* ToDo support - 6310 style */
4861static GSM_Error N6510_GetNextToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 4943static GSM_Error N6510_GetNextToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
4862{ 4944{
4863 GSM_Error error; 4945 GSM_Error error;
4864 GSM_ToDoStatus status; 4946 GSM_ToDoStatus status;
4865 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4947 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
@@ -4899,196 +4981,187 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
4899 smprintf(s, "ToDo received method 2\n"); 4981 smprintf(s, "ToDo received method 2\n");
4900 4982
4901 switch (msg.Buffer[44]) { 4983 switch (msg.Buffer[44]) {
4902 case 0x10: Last->Priority = GSM_Priority_Low; break; 4984 case 0x10: Last->Priority = GSM_Priority_Low; break;
4903 case 0x20: Last->Priority = GSM_Priority_Medium; break; 4985 case 0x20: Last->Priority = GSM_Priority_Medium; break;
4904 case 0x30: Last->Priority = GSM_Priority_High; break; 4986 case 0x30: Last->Priority = GSM_Priority_High; break;
4905 default : return ERR_UNKNOWN; 4987 default : return ERR_UNKNOWN;
4906 } 4988 }
4907 4989
4908 memcpy(Last->Entries[0].Text,msg.Buffer+54,msg.Buffer[51]*2); 4990 memcpy(Last->Entries[0].Text,msg.Buffer+54,msg.Buffer[51]*2);
4909 Last->Entries[0].Text[msg.Buffer[51]*2] = 0; 4991 Last->Entries[0].Text[msg.Buffer[51]*2] = 0;
4910 Last->Entries[0].Text[msg.Buffer[51]*2+1] = 0; 4992 Last->Entries[0].Text[msg.Buffer[51]*2+1] = 0;
4911 Last->Entries[0].EntryType = TODO_TEXT; 4993 Last->Entries[0].EntryType = TODO_TEXT;
4912 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); 4994 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text));
4913 4995
4914 smprintf(s,"EndTime: %04i-%02i-%02i %02i:%02i\n", 4996 smprintf(s,"EndTime: %04i-%02i-%02i %02i:%02i\n",
4915 msg.Buffer[34]*256+msg.Buffer[35], 4997 msg.Buffer[34]*256+msg.Buffer[35],
4916 msg.Buffer[36],msg.Buffer[37],msg.Buffer[38], 4998 msg.Buffer[36],msg.Buffer[37],msg.Buffer[38],
4917 msg.Buffer[39]); 4999 msg.Buffer[39]);
4918 Date.Year = msg.Buffer[34]*256+msg.Buffer[35]; 5000 Date.Year = msg.Buffer[34]*256+msg.Buffer[35];
4919 Date.Month = msg.Buffer[36]; 5001 Date.Month = msg.Buffer[36];
4920 Date.Day = msg.Buffer[37]; 5002 Date.Day = msg.Buffer[37];
4921 Date.Hour = msg.Buffer[38]; 5003 Date.Hour = msg.Buffer[38];
4922 Date.Minute = msg.Buffer[39]; 5004 Date.Minute = msg.Buffer[39];
4923 Date.Second= 0; 5005 Date.Second= 0;
4924 Last->Entries[1].EntryType = TODO_END_DATETIME; 5006 Last->Entries[1].EntryType = TODO_END_DATETIME;
4925 memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime)); 5007 memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime));
4926 5008
4927 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n", 5009 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n",
4928 msg.Buffer[28]*256+msg.Buffer[29], 5010 msg.Buffer[28]*256+msg.Buffer[29],
4929 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32], 5011 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32],
4930 msg.Buffer[33]); 5012 msg.Buffer[33]);
4931 Date.Year = msg.Buffer[28]*256+msg.Buffer[29]; 5013 Date.Year = msg.Buffer[28]*256+msg.Buffer[29];
4932 Date.Month = msg.Buffer[30]; 5014 Date.Month = msg.Buffer[30];
4933 Date.Day = msg.Buffer[31]; 5015 Date.Day = msg.Buffer[31];
4934 Date.Hour = msg.Buffer[32]; 5016 Date.Hour = msg.Buffer[32];
4935 Date.Minute = msg.Buffer[33]; 5017 Date.Minute = msg.Buffer[33];
4936 Date.Second= 0; 5018 Date.Second= 0;
4937 5019
4938 Last->EntriesNum = 2; 5020 Last->EntriesNum = 2;
4939 5021
4940 if (msg.Buffer[45] == 0x01) { 5022 if (msg.Buffer[45] == 0x01) {
4941 Last->Entries[2].Number = msg.Buffer[45]; 5023 Last->Entries[2].Number = msg.Buffer[45];
4942 Last->Entries[2].EntryType = TODO_COMPLETED; 5024 Last->Entries[2].EntryType = TODO_COMPLETED;
4943 Last->EntriesNum++; 5025 Last->EntriesNum++;
4944 smprintf(s,"Completed\n"); 5026 smprintf(s,"Completed\n");
4945 } 5027 }
4946 5028
4947 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) 5029 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) {
4948 {
4949 smprintf(s, "No alarm\n"); 5030 smprintf(s, "No alarm\n");
4950 } else { 5031 } else {
4951 diff = ((unsigned int)msg.Buffer[14]) << 24; 5032 diff = ((unsigned int)msg.Buffer[14]) << 24;
4952 diff += ((unsigned int)msg.Buffer[15]) << 16; 5033 diff += ((unsigned int)msg.Buffer[15]) << 16;
4953 diff += ((unsigned int)msg.Buffer[16]) << 8; 5034 diff += ((unsigned int)msg.Buffer[16]) << 8;
4954 diff += msg.Buffer[17]; 5035 diff += msg.Buffer[17];
4955 5036
4956 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime)); 5037 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime));
4957 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60); 5038 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60);
4958 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n", 5039 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n",
4959 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month, 5040 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month,
4960 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour, 5041 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour,
4961 Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second); 5042 Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second);
4962 5043
4963 Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME; 5044 Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME;
4964 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 && 5045 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 &&
4965 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00) 5046 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00)
4966 { 5047 {
4967 Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; 5048 Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
4968 smprintf(s, "Alarm type : Silent\n"); 5049 smprintf(s, "Alarm type : Silent\n");
4969 } 5050 }
4970 Last->EntriesNum++; 5051 Last->EntriesNum++;
4971 } 5052 }
4972 5053
4973 return ERR_NONE; 5054 return ERR_NONE;
4974} 5055}
4975 5056
4976/* ToDo support - 6610 style */ 5057/* ToDo support - 6610 style */
4977static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5058static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
4978{ 5059{
4979 GSM_Error error; 5060 GSM_Error error;
4980 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5061 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4981 /* The same to getting calendar method 3 */
4982 unsigned char req[] = {
4983 N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
4984 0x00,0x99, /* Location */
4985 0xff,0xff,0xff,0xff,0x01};
4986 5062
4987 if (refresh) { 5063 if (refresh) {
4988 error=N6510_GetCalendarInfo3(s,LastToDo,false); 5064 error=N6510_GetCalendarInfo3(s,LastToDo,1);
4989 if (error!=ERR_NONE) return error; 5065 if (error!=ERR_NONE) return error;
4990 ToDo->Location = 1; 5066 ToDo->Location = 1;
4991 } else { 5067 } else {
4992 ToDo->Location++; 5068 ToDo->Location++;
4993 } 5069 }
4994 5070
4995 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY; 5071 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY;
4996 5072
4997 req[8] = LastToDo->Location[ToDo->Location-1] / 256;
4998 req[9] = LastToDo->Location[ToDo->Location-1] % 256;
4999
5000 s->Phone.Data.ToDo = ToDo; 5073 s->Phone.Data.ToDo = ToDo;
5001 smprintf(s, "Getting todo method 2\n"); 5074 smprintf(s, "Getting todo method 2\n");
5002 return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetToDo); 5075 return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo);
5003} 5076}
5004 5077
5005static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5078static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
5006{ 5079{
5007 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5080 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5008 return N6510_GetNextToDo1(s, ToDo, refresh); 5081 return N6510_GetNextToDo1(s, ToDo, refresh);
5009 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5082 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5010 return N6510_GetNextToDo2(s, ToDo, refresh); 5083 return N6510_GetNextToDo2(s, ToDo, refresh);
5011 } else { 5084 } else {
5012 return ERR_NOTSUPPORTED; 5085 return ERR_NOTSUPPORTED;
5013 } 5086 }
5014} 5087}
5015 5088
5016/* ToDo support - 6310 style */ 5089/* ToDo support - 6310 style */
5017static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5090static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5018{ 5091{
5019 smprintf(s, "All TODO deleted\n"); 5092 smprintf(s, "All TODO deleted\n");
5020 return ERR_NONE; 5093 return ERR_NONE;
5021} 5094}
5022 5095
5023/* ToDo support - 6310 style */ 5096/* ToDo support - 6310 style */
5024static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s) 5097static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s)
5025{ 5098{
5026 unsigned char req[] = {N6110_FRAME_HEADER, 0x11}; 5099 unsigned char req[] = {N6110_FRAME_HEADER, 0x11};
5027 5100
5028 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5101 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5029 return ERR_NOTSUPPORTED; 5102 return ERR_NOTSUPPORTED;
5030 } 5103 }
5031 5104
5032 smprintf(s, "Deleting all ToDo method 1\n"); 5105 smprintf(s, "Deleting all ToDo method 1\n");
5033 return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo); 5106 return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo);
5034} 5107}
5035 5108
5036static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5109static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5037{ 5110{
5038 GSM_Error error; 5111 GSM_Error error;
5039 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5112 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
5040 GSM_CalendarEntry Note; 5113 GSM_CalendarEntry Note;
5041 5114
5042 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5115 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5043 return ERR_NOTSUPPORTED; 5116 return ERR_NOTSUPPORTED;
5044 } 5117 }
5045 5118
5046 error=N6510_GetCalendarInfo3(s,LastToDo,false); 5119 error=N6510_GetCalendarInfo3(s,LastToDo,1);
5047 if (error!=ERR_NONE) return error; 5120 if (error!=ERR_NONE) return error;
5048 5121
5049 smprintf(s, "Deleting ToDo method 2\n"); 5122 smprintf(s, "Deleting ToDo method 2\n");
5050 5123
5051 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION; 5124 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION;
5052 5125
5053 Note.Location = LastToDo->Location[ToDo->Location-1]; 5126 Note.Location = LastToDo->Location[ToDo->Location-1];
5054 return N71_65_DelCalendar(s,&Note); 5127 return N71_65_DelCalendar(s,&Note);
5055} 5128}
5056 5129
5057/* ToDo support - 6310 style */ 5130/* ToDo support - 6310 style */
5058static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5131static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5059{ 5132{
5060 smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]); 5133 smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]);
5061 s->Phone.Data.ToDo->Location = msg.Buffer[9]; 5134 s->Phone.Data.ToDo->Location = msg.Buffer[9];
5062 return ERR_NONE; 5135 return ERR_NONE;
5063} 5136}
5064 5137
5065/* ToDo support - 6310 style */ 5138/* ToDo support - 6310 style */
5066static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5139static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5067{ 5140{
5068 smprintf(s, "TODO set OK\n"); 5141 smprintf(s, "TODO set OK\n");
5069 return ERR_NONE; 5142 return ERR_NONE;
5070} 5143}
5071 5144
5072/* ToDo support - 6310 style */ 5145/* ToDo support - 6310 style */
5073static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5146static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5074{ 5147{
5075 int Text, Alarm, EndTime, Completed, ulen, Phone; 5148 int Text, Alarm, EndTime, Completed, ulen, Phone;
5076 GSM_Error error; 5149 GSM_Error error;
5077 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F}; 5150 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F};
5078 unsigned char reqSet[500] = { 5151 unsigned char reqSet[500] = {
5079 N6110_FRAME_HEADER, 0x01, 5152 N6110_FRAME_HEADER, 0x01,
5080 0x03, /* Priority */ 5153 0x03, /* Priority */
5081 0x00, /* Length of text */ 5154 0x00, /* Length of text */
5082 0x80,0x00,0x00, 5155 0x80,0x00,0x00,
5083 0x18}; /* Location */ 5156 0x18}; /* Location */
5084 5157
5085 s->Phone.Data.ToDo = ToDo; 5158 s->Phone.Data.ToDo = ToDo;
5086 5159
5087 smprintf(s, "Getting first ToDo location\n"); 5160 smprintf(s, "Getting first ToDo location\n");
5088 error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo); 5161 error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo);
5089 if (error != ERR_NONE) return error; 5162 if (error != ERR_NONE) return error;
5090 reqSet[9] = ToDo->Location; 5163 reqSet[9] = ToDo->Location;
5091 5164
5092 switch (ToDo->Priority) { 5165 switch (ToDo->Priority) {
5093 case GSM_Priority_Low: reqSet[4] = 3; break; 5166 case GSM_Priority_Low: reqSet[4] = 3; break;
5094 case GSM_Priority_Medium: reqSet[4] = 2; break; 5167 case GSM_Priority_Medium: reqSet[4] = 2; break;
@@ -5406,160 +5479,168 @@ static GSM_Error N6510_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *book
5406 5479
5407 smprintf(s, "Setting WAP bookmark\n"); 5480 smprintf(s, "Setting WAP bookmark\n");
5408 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark); 5481 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark);
5409 if (error != ERR_NONE) { 5482 if (error != ERR_NONE) {
5410 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) { 5483 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) {
5411 DCT3DCT4_DisableConnectionFunctions(s); 5484 DCT3DCT4_DisableConnectionFunctions(s);
5412 } 5485 }
5413 return error; 5486 return error;
5414 } 5487 }
5415 5488
5416 return DCT3DCT4_DisableConnectionFunctions(s); 5489 return DCT3DCT4_DisableConnectionFunctions(s);
5417} 5490}
5418 5491
5419GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 5492GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
5420{ 5493{
5421 GSM_Error error; 5494 GSM_Error error;
5422 5495
5423 /* We have to enable WAP frames in phone */ 5496 /* We have to enable WAP frames in phone */
5424 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); 5497 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
5425 if (error!=ERR_NONE) return error; 5498 if (error!=ERR_NONE) return error;
5426 5499
5427 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); 5500 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
5428} 5501}
5429 5502
5430GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 5503GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
5431{ 5504{
5432 GSM_Error error; 5505 GSM_Error error;
5433 5506
5434 /* We have to enable WAP frames in phone */ 5507 /* We have to enable WAP frames in phone */
5435 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); 5508 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
5436 if (error!=ERR_NONE) return error; 5509 if (error!=ERR_NONE) return error;
5437 5510
5438 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); 5511 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
5439} 5512}
5440 5513
5441static GSM_Reply_Function N6510ReplyFunctions[] = { 5514static GSM_Reply_Function N6510ReplyFunctions[] = {
5442 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, 5515 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
5443 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, 5516 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
5444 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, 5517 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
5445 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, 5518 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
5446 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, 5519 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
5447 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, 5520 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
5448 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, 5521 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
5449 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, 5522 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
5450 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, 5523 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
5451 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame }, 5524 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
5452 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice }, 5525 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice },
5453 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame }, 5526 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
5527 {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame },
5528 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice },
5529 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame },
5454 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame }, 5530 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
5455 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame }, 5531 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
5456 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame }, 5532 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
5457 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, 5533 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
5458 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame }, 5534 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
5459 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF }, 5535 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
5460 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF }, 5536 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
5537 {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame },
5538 {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame },
5539 {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame },
5461 5540
5462 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, 5541 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
5463 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame }, 5542 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame },
5464 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC }, 5543 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC },
5465 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC }, 5544 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC },
5466 5545
5467 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, 5546 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
5468 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, 5547 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
5469 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory }, 5548 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
5470 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap }, 5549 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
5471 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory }, 5550 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
5472 5551
5473 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert }, 5552 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
5474 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame }, 5553 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
5475 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame }, 5554 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
5476 {NoneReply, "\x06",0x03,0x09,ID_IncomingFrame }, 5555 {NoneReply, "\x06",0x03,0x09,ID_IncomingFrame },
5477 5556
5478 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode }, 5557 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode },
5479 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode }, 5558 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode },
5480 {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus }, 5559 {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus },
5481 5560
5482 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo }, 5561 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo },
5483 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame }, 5562 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame },
5484 {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame }, 5563 {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame },
5485 {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality }, 5564 {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality },
5486 {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame }, 5565 {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame },
5487 {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame }, 5566 {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame },
5488 {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap }, 5567 {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap },
5489 {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap }, 5568 {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap },
5490 5569
5491 {NoneReply, "\x0B",0x03,0x01,ID_PlayTone }, 5570 {NoneReply, "\x0B",0x03,0x01,ID_PlayTone },
5492 {NoneReply, "\x0B",0x03,0x15,ID_PlayTone }, 5571 {NoneReply, "\x0B",0x03,0x15,ID_PlayTone },
5493 {NoneReply, "\x0B",0x03,0x16,ID_PlayTone }, 5572 {NoneReply, "\x0B",0x03,0x16,ID_PlayTone },
5494 5573
5495 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote }, 5574 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },
5496 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote }, 5575 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },
5497 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote }, 5576 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },
5498 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote }, 5577 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },
5499 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote }, 5578 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
5500 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ 5579 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
5501 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/ 5580 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
5502 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ 5581 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
5503#ifdef DEBUG 5582#ifdef DEBUG
5504 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote }, 5583 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },
5505#endif 5584#endif
5506 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/ 5585 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
5507 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/ 5586 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/
5508 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo }, 5587 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo },
5509 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/ 5588 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/
5510 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo }, 5589 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo },
5590 {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote },
5511 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings }, 5591 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings },
5512 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale }, 5592 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale },
5513 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings }, 5593 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings },
5514 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/ 5594 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/
5515 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo }, 5595 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo },
5516 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/ 5596 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/
5517 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo }, 5597 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo },
5598 {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote },
5518 5599
5519 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage }, 5600 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage },
5520 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap }, 5601 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap },
5521 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage }, 5602 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage },
5522 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage }, 5603 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage },
5523 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage }, 5604 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage },
5524 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus }, 5605 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus },
5525 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus }, 5606 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus },
5526 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage }, 5607 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage },
5527 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder }, 5608 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder },
5528 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders }, 5609 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders },
5529 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage }, 5610 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage },
5530 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus }, 5611 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus },
5531 5612
5532 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset }, 5613 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset },
5533 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset }, 5614 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset },
5534 {NoneReply, "\x15",0x03,0x68,ID_Reset }, 5615 {NoneReply, "\x15",0x03,0x68,ID_Reset },
5535 5616
5536 {N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge }, 5617 {N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge },
5537 5618
5538 {N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime }, 5619 {N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime },
5539 {N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime }, 5620 {N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime },
5540 {N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm }, 5621 {N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm },
5541 {N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm }, 5622 {N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm },
5542 {N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm }, 5623 {N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm },
5543 5624
5544 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI }, 5625 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI },
5545 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware }, 5626 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware },
5546 {N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM }, 5627 {N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM },
5547 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode }, 5628 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode },
5548 5629
5549 /* 0x1C - vibra */ 5630 /* 0x1C - vibra */
5550 5631
5551 {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo }, 5632 {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo },
5552 {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone }, 5633 {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone },
5553 {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone }, 5634 {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone },
5554 {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone }, 5635 {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone },
5555 5636
5556 /* 0x23 - voice records */ 5637 /* 0x23 - voice records */
5557 5638
5558 {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile }, 5639 {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile },
5559 {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile }, 5640 {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile },
5560 {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile }, 5641 {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile },
5561 5642
5562 {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight }, 5643 {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight },
5563 5644
5564 {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation }, 5645 {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation },
5565 {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation }, 5646 {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation },
@@ -5606,177 +5687,178 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5606 5687
5607 /* 0x53 - simlock */ 5688 /* 0x53 - simlock */
5608 5689
5609 {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo }, 5690 {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo },
5610 {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo }, 5691 {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo },
5611 {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo }, 5692 {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo },
5612 {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo }, 5693 {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo },
5613 {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo }, 5694 {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo },
5614 5695
5615 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile }, 5696 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile },
5616 {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder }, 5697 {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder },
5617 {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile }, 5698 {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile },
5618 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile }, 5699 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile },
5619 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo }, 5700 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo },
5620 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile }, 5701 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile },
5621 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile }, 5702 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile },
5622 {N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile }, 5703 {N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile },
5623 {N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile }, 5704 {N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile },
5624 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus }, 5705 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus },
5625 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo }, 5706 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo },
5626 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile }, 5707 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile },
5627 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus }, 5708 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus },
5628 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo }, 5709 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo },
5629 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile }, 5710 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile },
5630 {N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile }, 5711 {N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile },
5631 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile }, 5712 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile },
5632 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile }, 5713 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile },
5633 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo }, 5714 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo },
5634 5715
5635 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap }, 5716 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap },
5636 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap }, 5717 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap },
5637 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap }, 5718 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap },
5638 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap }, 5719 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap },
5639 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap }, 5720 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap },
5640 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap }, 5721 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap },
5641 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap }, 5722 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap },
5642 5723
5643 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 5724 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
5644 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 5725 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
5645 5726
5646 /* 0xD7 - Bluetooth */ 5727 /* 0xD7 - Bluetooth */
5647 5728
5648 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone }, 5729 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone },
5649 5730
5650 {NULL, "\x00",0x00,0x00,ID_None } 5731 {NULL, "\x00",0x00,0x00,ID_None }
5651}; 5732};
5652 5733
5653GSM_Phone_Functions N6510Phone = { 5734GSM_Phone_Functions N6510Phone = {
5654 "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6800|7210|7250|7250i|7600|8310|8390|8910|8910i", 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",
5655 N6510ReplyFunctions, 5736 N6510ReplyFunctions,
5656 N6510_Initialise, 5737 N6510_Initialise,
5657 NONEFUNCTION, /* Terminate */ 5738 NONEFUNCTION, /* Terminate */
5658 GSM_DispatchMessage, 5739 GSM_DispatchMessage,
5659 N6510_ShowStartInfo, 5740 N6510_ShowStartInfo,
5660 NOKIA_GetManufacturer, 5741 NOKIA_GetManufacturer,
5661 DCT3DCT4_GetModel, 5742 DCT3DCT4_GetModel,
5662 DCT3DCT4_GetFirmware, 5743 DCT3DCT4_GetFirmware,
5663 DCT4_GetIMEI, 5744 DCT4_GetIMEI,
5664 N6510_GetOriginalIMEI, 5745 N6510_GetOriginalIMEI,
5665 N6510_GetManufactureMonth, 5746 N6510_GetManufactureMonth,
5666 DCT4_GetProductCode, 5747 DCT4_GetProductCode,
5667 DCT4_GetHardware, 5748 DCT4_GetHardware,
5668 N6510_GetPPM, 5749 N6510_GetPPM,
5669 NOTSUPPORTED, /* GetSIMIMSI */ 5750 NOTSUPPORTED, /* GetSIMIMSI */
5670 N6510_GetDateTime, 5751 N6510_GetDateTime,
5671 N6510_SetDateTime, 5752 N6510_SetDateTime,
5672 N6510_GetAlarm, 5753 N6510_GetAlarm,
5673 N6510_SetAlarm, 5754 N6510_SetAlarm,
5674 N6510_GetLocale, 5755 N6510_GetLocale,
5675 NOTSUPPORTED, /* SetLocale */ 5756 NOTSUPPORTED, /* SetLocale */
5676 N6510_PressKey, 5757 N6510_PressKey,
5677 DCT4_Reset, 5758 DCT4_Reset,
5678 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 5759 NOTIMPLEMENTED, /* ResetPhoneSettings*/
5679 N6510_EnterSecurityCode, 5760 N6510_EnterSecurityCode,
5680 N6510_GetSecurityStatus, 5761 N6510_GetSecurityStatus,
5681 NOTSUPPORTED, /* GetDisplayStatus*/ 5762 NOTSUPPORTED, /* GetDisplayStatus*/
5682 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 5763 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
5683 N6510_GetBatteryCharge, 5764 N6510_GetBatteryCharge,
5684 N6510_GetSignalQuality, 5765 N6510_GetSignalQuality,
5685 N6510_GetNetworkInfo, 5766 N6510_GetNetworkInfo,
5686 NOTSUPPORTED, /* GetCategory */ 5767 NOTSUPPORTED, /* GetCategory */
5687 NOTSUPPORTED, /* AddCategory */ 5768 NOTSUPPORTED, /* AddCategory */
5688 NOTSUPPORTED, /* GetCategoryStatus */ 5769 NOTSUPPORTED, /* GetCategoryStatus */
5689 N6510_GetMemoryStatus, 5770 N6510_GetMemoryStatus,
5690 N6510_GetMemory, 5771 N6510_GetMemory,
5691 NOTIMPLEMENTED, /* GetNextMemory */ 5772 NOTIMPLEMENTED, /* GetNextMemory */
5692 N6510_SetMemory, 5773 N6510_SetMemory,
5693 NOTIMPLEMENTED, /* AddMemory */ 5774 NOTIMPLEMENTED, /* AddMemory */
5694 N6510_DeleteMemory, 5775 N6510_DeleteMemory,
5695 NOTIMPLEMENTED, /* DeleteAllMemory */ 5776 NOTIMPLEMENTED, /* DeleteAllMemory */
5696 N6510_GetSpeedDial, 5777 N6510_GetSpeedDial,
5697 NOTIMPLEMENTED, /* SetSpeedDial */ 5778 NOTIMPLEMENTED, /* SetSpeedDial */
5698 N6510_GetSMSC, 5779 N6510_GetSMSC,
5699 N6510_SetSMSC, 5780 N6510_SetSMSC,
5700 N6510_GetSMSStatus, 5781 N6510_GetSMSStatus,
5701 N6510_GetSMSMessage, 5782 N6510_GetSMSMessage,
5702 N6510_GetNextSMSMessage, 5783 N6510_GetNextSMSMessage,
5703 N6510_SetSMS, 5784 N6510_SetSMS,
5704 N6510_AddSMS, 5785 N6510_AddSMS,
5705 N6510_DeleteSMSMessage, 5786 N6510_DeleteSMSMessage,
5706 N6510_SendSMSMessage, 5787 N6510_SendSMSMessage,
5707 NOTSUPPORTED, /* SendSavedSMS */ 5788 NOTSUPPORTED, /* SendSavedSMS */
5789 NOTSUPPORTED, /* SetFastSMSSending*/
5708 NOKIA_SetIncomingSMS, 5790 NOKIA_SetIncomingSMS,
5709 NOTIMPLEMENTED, /* SetIncomingCB */ 5791 NOTIMPLEMENTED, /* SetIncomingCB */
5710 N6510_GetSMSFolders, 5792 N6510_GetSMSFolders,
5711 N6510_AddSMSFolder, 5793 N6510_AddSMSFolder,
5712 NOTIMPLEMENTED, /* DeleteSMSFolder */ 5794 NOTIMPLEMENTED, /* DeleteSMSFolder */
5713 N6510_DialVoice, 5795 N6510_DialVoice,
5714 N6510_AnswerCall, 5796 N6510_AnswerCall,
5715 N6510_CancelCall, 5797 N6510_CancelCall,
5716 NOTIMPLEMENTED, /* HoldCall */ 5798 NOTIMPLEMENTED, /* HoldCall */
5717 NOTIMPLEMENTED, /* UnholdCall */ 5799 NOTIMPLEMENTED, /* UnholdCall */
5718 NOTIMPLEMENTED, /* ConferenceCall */ 5800 NOTIMPLEMENTED, /* ConferenceCall */
5719 NOTIMPLEMENTED, /* SplitCall */ 5801 NOTIMPLEMENTED, /* SplitCall */
5720 NOTIMPLEMENTED, /* TransferCall */ 5802 NOTIMPLEMENTED, /* TransferCall */
5721 NOTIMPLEMENTED, /* SwitchCall */ 5803 NOTIMPLEMENTED, /* SwitchCall */
5722 DCT3DCT4_GetCallDivert, 5804 DCT3DCT4_GetCallDivert,
5723 DCT3DCT4_SetCallDivert, 5805 DCT3DCT4_SetCallDivert,
5724 DCT3DCT4_CancelAllDiverts, 5806 DCT3DCT4_CancelAllDiverts,
5725 NOKIA_SetIncomingCall, 5807 NOKIA_SetIncomingCall,
5726 NOKIA_SetIncomingUSSD, 5808 NOKIA_SetIncomingUSSD,
5727 DCT3DCT4_SendDTMF, 5809 DCT3DCT4_SendDTMF,
5728 N6510_GetRingtone, 5810 N6510_GetRingtone,
5729 N6510_SetRingtone, 5811 N6510_SetRingtone,
5730 N6510_GetRingtonesInfo, 5812 N6510_GetRingtonesInfo,
5731 N6510_DeleteUserRingtones, 5813 N6510_DeleteUserRingtones,
5732 N6510_PlayTone, 5814 N6510_PlayTone,
5733 N6510_GetWAPBookmark, 5815 N6510_GetWAPBookmark,
5734 N6510_SetWAPBookmark, 5816 N6510_SetWAPBookmark,
5735 N6510_DeleteWAPBookmark, 5817 N6510_DeleteWAPBookmark,
5736 N6510_GetWAPSettings, 5818 N6510_GetWAPSettings,
5737 N6510_SetWAPSettings, 5819 N6510_SetWAPSettings,
5738 N6510_GetMMSSettings, 5820 N6510_GetMMSSettings,
5739 N6510_SetMMSSettings, 5821 N6510_SetMMSSettings,
5740 N6510_GetSyncMLSettings, 5822 N6510_GetSyncMLSettings,
5741 NOTSUPPORTED, /* SetSyncMLSettings*/ 5823 NOTSUPPORTED, /* SetSyncMLSettings*/
5742 N6510_GetChatSettings, 5824 N6510_GetChatSettings,
5743 NOTSUPPORTED, /* SetChatSettings */ 5825 NOTSUPPORTED, /* SetChatSettings */
5744 N6510_GetBitmap, 5826 N6510_GetBitmap,
5745 N6510_SetBitmap, 5827 N6510_SetBitmap,
5746 N6510_GetToDoStatus, 5828 N6510_GetToDoStatus,
5747 NOTIMPLEMENTED, /* GetToDo */ 5829 NOTIMPLEMENTED, /* GetToDo */
5748 N6510_GetNextToDo, 5830 N6510_GetNextToDo,
5749 NOTIMPLEMENTED, /* SetToDo */ 5831 NOTIMPLEMENTED, /* SetToDo */
5750 N6510_AddToDo, 5832 N6510_AddToDo,
5751 N6510_DeleteToDo2, 5833 N6510_DeleteToDo2,
5752 N6510_DeleteAllToDo1, 5834 N6510_DeleteAllToDo1,
5753 N6510_GetCalendarStatus, 5835 N6510_GetCalendarStatus,
5754 NOTIMPLEMENTED, /* GetCalendar */ 5836 NOTIMPLEMENTED, /* GetCalendar */
5755 N6510_GetNextCalendar, 5837 N6510_GetNextCalendar,
5756 NOTIMPLEMENTED, /* SetCalendar */ 5838 NOTIMPLEMENTED, /* SetCalendar */
5757 N6510_AddCalendar, 5839 N6510_AddCalendar,
5758 N71_65_DelCalendar, 5840 N71_65_DelCalendar,
5759 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 5841 NOTIMPLEMENTED, /* DeleteAllCalendar*/
5760 N6510_GetCalendarSettings, 5842 N6510_GetCalendarSettings,
5761 NOTSUPPORTED, /* SetCalendarSettings*/ 5843 NOTSUPPORTED, /* SetCalendarSettings*/
5762 NOTIMPLEMENTED, /* GetNote */ 5844 N6510_GetNextNote,
5763 N6510_GetProfile, 5845 N6510_GetProfile,
5764 N6510_SetProfile, 5846 N6510_SetProfile,
5765 N6510_GetFMStation, 5847 N6510_GetFMStation,
5766 N6510_SetFMStation, 5848 N6510_SetFMStation,
5767 N6510_ClearFMStations, 5849 N6510_ClearFMStations,
5768 N6510_GetNextFileFolder, 5850 N6510_GetNextFileFolder,
5769 N6510_GetFilePart, 5851 N6510_GetFilePart,
5770 N6510_AddFilePart, 5852 N6510_AddFilePart,
5771 N6510_GetFileSystemStatus, 5853 N6510_GetFileSystemStatus,
5772 N6510_DeleteFile, 5854 N6510_DeleteFile,
5773 N6510_AddFolder, 5855 N6510_AddFolder,
5774 N6510_GetGPRSAccessPoint, 5856 N6510_GetGPRSAccessPoint,
5775 N6510_SetGPRSAccessPoint 5857 N6510_SetGPRSAccessPoint
5776}; 5858};
5777 5859
5778#endif 5860#endif
5779 5861
5780/* How should editor hadle tabs in this file? Add editor commands here. 5862/* How should editor hadle tabs in this file? Add editor commands here.
5781 * vim: noexpandtab sw=8 ts=8 sts=8: 5863 * vim: noexpandtab sw=8 ts=8 sts=8:
5782 */ 5864 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.h b/gammu/emb/common/phone/nokia/dct4/n6510.h
index 4717aeb..26623d6 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.h
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.h
@@ -1,84 +1,86 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef n6510_h 3#ifndef n6510_h
4#define n6510_h 4#define n6510_h
5 5
6#include "../ncommon.h" 6#include "../ncommon.h"
7#include "../../../service/sms/gsmsms.h" 7#include "../../../service/sms/gsmsms.h"
8 8
9typedef enum { 9typedef enum {
10 N6510_MMS_SETTINGS = 0x01, 10 N6510_MMS_SETTINGS = 0x01,
11 N6510_CHAT_SETTINGS, 11 N6510_CHAT_SETTINGS,
12 12
13 N6510_WAP_SETTINGS, 13 N6510_WAP_SETTINGS,
14 N6510_SYNCML_SETTINGS 14 N6510_SYNCML_SETTINGS
15} N6510_Connection_Settings; 15} N6510_Connection_Settings;
16 16
17typedef enum { 17typedef enum {
18 N6510_LIGHT_DISPLAY = 0x01, 18 N6510_LIGHT_DISPLAY = 0x01,
19 N6510_LIGHT_KEYPAD = 0x03, 19 N6510_LIGHT_KEYPAD = 0x03,
20 N6510_LIGHT_TORCH = 0x10 20 N6510_LIGHT_TORCH = 0x10
21} N6510_PHONE_LIGHTS; 21} N6510_PHONE_LIGHTS;
22 22
23typedef struct { 23typedef struct {
24 int LastCalendarYear; 24 int LastCalendarYear;
25 int LastCalendarPos; 25 int LastCalendarPos;
26 GSM_NOKIACalToDoLocationsLastCalendar; 26 GSM_NOKIACalToDoLocationsLastCalendar;
27 int FirstCalendarPos; 27 int FirstCalendarPos;
28 unsigned char CalendarIcons[10]; 28 unsigned char CalendarIcons[10];
29 GSM_CalendarNoteType CalendarIconsTypes[10]; 29 GSM_CalendarNoteType CalendarIconsTypes[10];
30 int CalendarIconsNum; 30 int CalendarIconsNum;
31 31
32 GSM_NOKIASMSFolder LastSMSFolder; 32 GSM_NOKIASMSFolder LastSMSFolder;
33 GSM_SMSFolders LastSMSFolders; 33 GSM_SMSFolders LastSMSFolders;
34 34
35 GSM_NOKIACalToDoLocationsLastToDo; 35 GSM_NOKIACalToDoLocationsLastToDo;
36 36
37 GSM_NOKIACalToDoLocationsLastNote;
38
37 unsigned char RingtoneID;/* When set with preview */ 39 unsigned char RingtoneID;/* When set with preview */
38 40
39 int FilesLocations[1000]; 41 int FilesLocations[1000];
40 int FilesLevels[1000]; 42 int FilesLevels[1000];
41 int FilesLocationsUsed; 43 int FilesLocationsUsed;
42 int FilesLocationsCurrent; 44 int FilesLocationsCurrent;
43 int FileToken; 45 int FileToken;
44 int ParentID; 46 int ParentID;
45 int FileCheckSum; 47 int FileCheckSum;
46 48
47 unsigned char FMStatus[4000]; 49 unsigned char FMStatus[4000];
48 int FMStatusLength; 50 int FMStatusLength;
49 51
50 unsigned char GPRSPoints[4000]; 52 unsigned char GPRSPoints[4000];
51 int GPRSPointsLength; 53 int GPRSPointsLength;
52 54
53 int BearerNumber; 55 int BearerNumber;
54 56
55 unsigned char PhoneMode; 57 unsigned char PhoneMode;
56} GSM_Phone_N6510Data; 58} GSM_Phone_N6510Data;
57 59
58void N6510_EncodeFMFrequency(double freq, unsigned char *buff); 60void N6510_EncodeFMFrequency(double freq, unsigned char *buff);
59void N6510_DecodeFMFrequency(double *freq, unsigned char *buff); 61void N6510_DecodeFMFrequency(double *freq, unsigned char *buff);
60 62
61#ifndef GSM_USED_MBUS2 63#ifndef GSM_USED_MBUS2
62# define GSM_USED_MBUS2 64# define GSM_USED_MBUS2
63#endif 65#endif
64#ifndef GSM_USED_FBUS2 66#ifndef GSM_USED_FBUS2
65# define GSM_USED_FBUS2 67# define GSM_USED_FBUS2
66#endif 68#endif
67#ifndef GSM_USED_FBUS2DLR3 69#ifndef GSM_USED_FBUS2DLR3
68# define GSM_USED_FBUS2DLR3 70# define GSM_USED_FBUS2DLR3
69#endif 71#endif
70#ifndef GSM_USED_FBUS2DKU5 72#ifndef GSM_USED_FBUS2DKU5
71# define GSM_USED_FBUS2DKU5 73# define GSM_USED_FBUS2DKU5
72#endif 74#endif
73#ifndef GSM_USED_PHONETBLUE 75#ifndef GSM_USED_PHONETBLUE
74# define GSM_USED_PHONETBLUE 76# define GSM_USED_PHONETBLUE
75#endif 77#endif
76#ifndef GSM_USED_IRDAPHONET 78#ifndef GSM_USED_IRDAPHONET
77# define GSM_USED_IRDAPHONET 79# define GSM_USED_IRDAPHONET
78#endif 80#endif
79#ifndef GSM_USED_BLUEPHONET 81#ifndef GSM_USED_BLUEPHONET
80# define GSM_USED_BLUEPHONET 82# define GSM_USED_BLUEPHONET
81#endif 83#endif
82#ifndef GSM_USED_FBUS2PL2303 84#ifndef GSM_USED_FBUS2PL2303
83# define GSM_USED_FBUS2PL2303 85# define GSM_USED_FBUS2PL2303
84#endif 86#endif
diff --git a/gammu/emb/common/phone/nokia/nauto.c b/gammu/emb/common/phone/nokia/nauto.c
index bf74bc9..3bb53ec 100644
--- a/gammu/emb/common/phone/nokia/nauto.c
+++ b/gammu/emb/common/phone/nokia/nauto.c
@@ -76,69 +76,69 @@ GSM_Phone_Functions NAUTOPhone = {
76 NOTSUPPORTED, /* GetSMSFolders */ 76 NOTSUPPORTED, /* GetSMSFolders */
77 NOTSUPPORTED, /* AddSMSFolder */ 77 NOTSUPPORTED, /* AddSMSFolder */
78 NOTSUPPORTED, /* DeleteSMSFolder */ 78 NOTSUPPORTED, /* DeleteSMSFolder */
79 NOTSUPPORTED, /* DialVoice */ 79 NOTSUPPORTED, /* DialVoice */
80 NOTSUPPORTED, /* AnswerCall */ 80 NOTSUPPORTED, /* AnswerCall */
81 NOTSUPPORTED, /* CancelCall */ 81 NOTSUPPORTED, /* CancelCall */
82 NOTSUPPORTED, /* HoldCall */ 82 NOTSUPPORTED, /* HoldCall */
83 NOTSUPPORTED, /* UnholdCall */ 83 NOTSUPPORTED, /* UnholdCall */
84 NOTSUPPORTED, /* ConferenceCall */ 84 NOTSUPPORTED, /* ConferenceCall */
85 NOTSUPPORTED, /* SplitCall */ 85 NOTSUPPORTED, /* SplitCall */
86 NOTSUPPORTED, /* TransferCall */ 86 NOTSUPPORTED, /* TransferCall */
87 NOTSUPPORTED, /* SwitchCall */ 87 NOTSUPPORTED, /* SwitchCall */
88 NOTSUPPORTED, /* GetCallDivert */ 88 NOTSUPPORTED, /* GetCallDivert */
89 NOTSUPPORTED, /* SetCallDivert */ 89 NOTSUPPORTED, /* SetCallDivert */
90 NOTSUPPORTED, /* CancelAllDiverts*/ 90 NOTSUPPORTED, /* CancelAllDiverts*/
91 NOTSUPPORTED, /* SetIncomingCall */ 91 NOTSUPPORTED, /* SetIncomingCall */
92 NOTSUPPORTED, /* SetIncomingUSSD */ 92 NOTSUPPORTED, /* SetIncomingUSSD */
93 NOTSUPPORTED, /* SendDTMF */ 93 NOTSUPPORTED, /* SendDTMF */
94 NOTSUPPORTED, /* GetRingtone */ 94 NOTSUPPORTED, /* GetRingtone */
95 NOTSUPPORTED, /* SetRingtone */ 95 NOTSUPPORTED, /* SetRingtone */
96 NOTSUPPORTED, /* GetRingtonesInfo*/ 96 NOTSUPPORTED, /* GetRingtonesInfo*/
97 NOTSUPPORTED, /* DeleteUserRingtones*/ 97 NOTSUPPORTED, /* DeleteUserRingtones*/
98 NOTSUPPORTED, /* PlayTone */ 98 NOTSUPPORTED, /* PlayTone */
99 NOTSUPPORTED, /* GetWAPBookmark */ 99 NOTSUPPORTED, /* GetWAPBookmark */
100 NOTSUPPORTED, /* SetWAPBookmark */ 100 NOTSUPPORTED, /* SetWAPBookmark */
101 NOTSUPPORTED, /* DeleteWAPBookmark */ 101 NOTSUPPORTED, /* DeleteWAPBookmark */
102 NOTSUPPORTED, /* GetWAPSettings */ 102 NOTSUPPORTED, /* GetWAPSettings */
103 NOTSUPPORTED, /* SetWAPSettings */ 103 NOTSUPPORTED, /* SetWAPSettings */
104 NOTSUPPORTED, /* GetMMSSettings */ 104 NOTSUPPORTED, /* GetMMSSettings */
105 NOTSUPPORTED, /* SetMMSSettings */ 105 NOTSUPPORTED, /* SetMMSSettings */
106 NOTSUPPORTED, /* GetBitmap */ 106 NOTSUPPORTED, /* GetBitmap */
107 NOTSUPPORTED, /* SetBitmap */ 107 NOTSUPPORTED, /* SetBitmap */
108 NOTSUPPORTED, /* GetToDoStatus */ 108 NOTSUPPORTED, /* GetToDoStatus */
109 NOTSUPPORTED, /* GetToDo */ 109 NOTSUPPORTED, /* GetToDo */
110 NOTSUPPORTED, /* GetNextToDo */ 110 NOTSUPPORTED, /* GetNextToDo */
111 NOTSUPPORTED, /* SetToDo */ 111 NOTSUPPORTED, /* SetToDo */
112 NOTSUPPORTED, /* AddToDo */ 112 NOTSUPPORTED, /* AddToDo */
113 NOTSUPPORTED, /* DeleteToDo */ 113 NOTSUPPORTED, /* DeleteToDo */
114 NOTSUPPORTED, /* DeleteAllToDo */ 114 NOTSUPPORTED, /* DeleteAllToDo */
115 NOTSUPPORTED, /* GetCalendarStatus*/ 115 NOTSUPPORTED, /* GetCalendarStatus*/
116 NOTSUPPORTED, /* GetCalendar */ 116 NOTSUPPORTED, /* GetCalendar */
117 NOTSUPPORTED, /* GetNextCalendar */ 117 NOTSUPPORTED, /* GetNextCalendar */
118 NOTSUPPORTED, /* SetCalendar */ 118 NOTSUPPORTED, /* SetCalendar */
119 NOTSUPPORTED, /* AddCalendar */ 119 NOTSUPPORTED, /* AddCalendar */
120 NOTSUPPORTED, /* DeleteCalendar */ 120 NOTSUPPORTED, /* DeleteCalendar */
121 NOTSUPPORTED, /* DeleteAllCalendar*/ 121 NOTSUPPORTED, /* DeleteAllCalendar*/
122 NOTSUPPORTED, /* GetCalendarSettings*/ 122 NOTSUPPORTED, /* GetCalendarSettings*/
123 NOTSUPPORTED, /* SetCalendarSettings*/ 123 NOTSUPPORTED, /* SetCalendarSettings*/
124 NOTSUPPORTED, /* GetNote */ 124 NOTSUPPORTED, /* GetNextNote */
125 NOTSUPPORTED, /* GetProfile */ 125 NOTSUPPORTED, /* GetProfile */
126 NOTSUPPORTED, /* SetProfile */ 126 NOTSUPPORTED, /* SetProfile */
127 NOTSUPPORTED, /* GetFMStation */ 127 NOTSUPPORTED, /* GetFMStation */
128 NOTSUPPORTED, /* SetFMStation */ 128 NOTSUPPORTED, /* SetFMStation */
129 NOTSUPPORTED, /* ClearFMStations */ 129 NOTSUPPORTED, /* ClearFMStations */
130 NOTSUPPORTED, /* GetNextFileFolder*/ 130 NOTSUPPORTED, /* GetNextFileFolder*/
131 NOTSUPPORTED, /* GetFilePart */ 131 NOTSUPPORTED, /* GetFilePart */
132 NOTSUPPORTED, /* AddFilePart */ 132 NOTSUPPORTED, /* AddFilePart */
133 NOTSUPPORTED, /* GetFileSystemStatus*/ 133 NOTSUPPORTED, /* GetFileSystemStatus*/
134 NOTSUPPORTED, /* DeleteFile */ 134 NOTSUPPORTED, /* DeleteFile */
135 NOTSUPPORTED, /* AddFolder */ 135 NOTSUPPORTED, /* AddFolder */
136 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 136 NOTSUPPORTED, /* GetGPRSAccessPoint*/
137 NOTSUPPORTED /* SetGPRSAccessPoint*/ 137 NOTSUPPORTED /* SetGPRSAccessPoint*/
138}; 138};
139 139
140#endif 140#endif
141 141
142/* How should editor hadle tabs in this file? Add editor commands here. 142/* How should editor hadle tabs in this file? Add editor commands here.
143 * vim: noexpandtab sw=8 ts=8 sts=8: 143 * vim: noexpandtab sw=8 ts=8 sts=8:
144 */ 144 */
diff --git a/gammu/emb/common/phone/nokia/nfunc.c b/gammu/emb/common/phone/nokia/nfunc.c
index 3acfb10..d4d8b03 100644
--- a/gammu/emb/common/phone/nokia/nfunc.c
+++ b/gammu/emb/common/phone/nokia/nfunc.c
@@ -1348,125 +1348,139 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1348 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii 1348 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
1349 tmp = 6; 1349 tmp = 6;
1350 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); 1350 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
1351 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); 1351 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
1352 /* FIXME: read name from frame */ 1352 /* FIXME: read name from frame */
1353 1353
1354 call.Status = GSM_CALL_CallStart; 1354 call.Status = GSM_CALL_CallStart;
1355 break; 1355 break;
1356 case 0x04: 1356 case 0x04:
1357 smprintf(s, "Remote end hang up\n"); 1357 smprintf(s, "Remote end hang up\n");
1358 smprintf(s, "Cause Type : %i\n",msg.Buffer[5]);//such interpretation is in gnokii 1358 smprintf(s, "Cause Type : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
1359 smprintf(s, "CC : %i\n",msg.Buffer[6]); 1359 smprintf(s, "CC : %i\n",msg.Buffer[6]);
1360 smprintf(s, "MM(?) : %i\n",msg.Buffer[7]); 1360 smprintf(s, "MM(?) : %i\n",msg.Buffer[7]);
1361 smprintf(s, "RR(?) : %i\n",msg.Buffer[8]); 1361 smprintf(s, "RR(?) : %i\n",msg.Buffer[8]);
1362 call.Status = GSM_CALL_CallRemoteEnd; 1362 call.Status = GSM_CALL_CallRemoteEnd;
1363 call.StatusCode = msg.Buffer[6]; 1363 call.StatusCode = msg.Buffer[6];
1364 break; 1364 break;
1365 case 0x05: 1365 case 0x05:
1366 smprintf(s, "Incoming call\n"); 1366 smprintf(s, "Incoming call\n");
1367 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii 1367 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
1368 tmp = 6; 1368 tmp = 6;
1369 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); 1369 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
1370 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); 1370 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
1371 /* FIXME: read name from frame */ 1371 /* FIXME: read name from frame */
1372 call.Status = GSM_CALL_IncomingCall; 1372 call.Status = GSM_CALL_IncomingCall;
1373 tmp = 6; 1373 tmp = 6;
1374 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false); 1374 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false);
1375 break; 1375 break;
1376 case 0x07: 1376 case 0x07:
1377 smprintf(s, "Call answer initiated\n"); 1377 smprintf(s, "Call answer initiated\n");
1378 break; 1378 break;
1379 case 0x09: 1379 case 0x09:
1380 smprintf(s, "Call released\n"); 1380 smprintf(s, "Call released\n");
1381 call.Status = GSM_CALL_CallLocalEnd; 1381 call.Status = GSM_CALL_CallLocalEnd;
1382 break; 1382 break;
1383 case 0x0a: 1383 case 0x0a:
1384 smprintf(s, "Call is being released\n"); 1384 smprintf(s, "Call is being released\n");
1385 break; 1385 break;
1386 case 0x0b: 1386 case 0x0b:
1387 smprintf(s, "Meaning not known\n"); 1387 smprintf(s, "Meaning not known\n");
1388 call.CallIDAvailable = false; 1388 call.CallIDAvailable = false;
1389 break; 1389 break;
1390 case 0x0c: 1390 case 0x0c:
1391 smprintf(s, "Audio status\n"); 1391 smprintf(s, "Audio status\n");
1392 if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n"); 1392 if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n");
1393 else smprintf(s, "Audio disabled\n"); 1393 else smprintf(s, "Audio disabled\n");
1394 call.CallIDAvailable = false; 1394 call.CallIDAvailable = false;
1395 break; 1395 break;
1396 case 0x0f:
1397 case 0x10:
1398 smprintf(s, "Meaning not known\n");
1399 call.CallIDAvailable = false;
1400 break;
1396 case 0x23: 1401 case 0x23:
1397 smprintf(s, "Call held\n"); 1402 smprintf(s, "Call held\n");
1398 call.Status = GSM_CALL_CallHeld; 1403 call.Status = GSM_CALL_CallHeld;
1399 break; 1404 break;
1400 case 0x25: 1405 case 0x25:
1401 smprintf(s, "Call resumed\n"); 1406 smprintf(s, "Call resumed\n");
1402 call.Status = GSM_CALL_CallResumed; 1407 call.Status = GSM_CALL_CallResumed;
1403 break; 1408 break;
1404 case 0x27: 1409 case 0x27:
1405 smprintf(s, "Call switched\n"); 1410 smprintf(s, "Call switched\n");
1406 call.Status = GSM_CALL_CallSwitched; 1411 call.Status = GSM_CALL_CallSwitched;
1407 break; 1412 break;
1408 case 0x53: 1413 case 0x53:
1409 smprintf(s, "Outgoing call\n"); 1414 smprintf(s, "Outgoing call\n");
1410 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii 1415 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
1411 tmp = 6; 1416 tmp = 6;
1412 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); 1417 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
1413 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); 1418 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
1414 /* FIXME: read name from frame */ 1419 /* FIXME: read name from frame */
1415 call.Status = GSM_CALL_OutgoingCall; 1420 call.Status = GSM_CALL_OutgoingCall;
1416 tmp = 6; 1421 tmp = 6;
1417 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false); 1422 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false);
1418 break; 1423 break;
1424 case 0xA6:
1425 case 0xD2:
1426 case 0xD3:
1427 smprintf(s, "Meaning not known\n");
1428 call.CallIDAvailable = false;
1429 break;
1419 } 1430 }
1420 if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]); 1431 if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]);
1421 if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) { 1432 if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) {
1422 if (call.CallIDAvailable) call.CallID = msg.Buffer[4]; 1433 if (call.CallIDAvailable) call.CallID = msg.Buffer[4];
1423 s->User.IncomingCall(s->CurrentConfig->Device, call); 1434 s->User.IncomingCall(s->CurrentConfig->Device, call);
1424 } 1435 }
1436 if (s->Phone.Data.RequestID == ID_DialVoice) {
1437 if (msg.Buffer[3] == 0x10) return ERR_NOTSUPPORTED;
1438 }
1425 if (s->Phone.Data.RequestID == ID_CancelCall) { 1439 if (s->Phone.Data.RequestID == ID_CancelCall) {
1426 if (msg.Buffer[3] == 0x09) { 1440 if (msg.Buffer[3] == 0x09) {
1427 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE; 1441 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
1428 /* when we canceled call and see frame about other 1442 /* when we canceled call and see frame about other
1429 * call releasing, we don't give ERR_NONE for "our" 1443 * call releasing, we don't give ERR_NONE for "our"
1430 * call release command 1444 * call release command
1431 */ 1445 */
1432 return ERR_NEEDANOTHERANSWER; 1446 return ERR_NEEDANOTHERANSWER;
1433 } 1447 }
1434 } 1448 }
1435 if (s->Phone.Data.RequestID == ID_AnswerCall) { 1449 if (s->Phone.Data.RequestID == ID_AnswerCall) {
1436 if (msg.Buffer[3] == 0x07) { 1450 if (msg.Buffer[3] == 0x07) {
1437 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE; 1451 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
1438 return ERR_NEEDANOTHERANSWER; 1452 return ERR_NEEDANOTHERANSWER;
1439 } 1453 }
1440 } 1454 }
1441 return ERR_NONE; 1455 return ERR_NONE;
1442} 1456}
1443 1457
1444void N71_65_GetCalendarRecurrance(GSM_StateMachine *s, unsigned char *buffer, GSM_CalendarEntry *entry) 1458void N71_65_GetCalendarRecurrance(GSM_StateMachine *s, unsigned char *buffer, GSM_CalendarEntry *entry)
1445{ 1459{
1446 int Recurrance; 1460 int Recurrance;
1447 1461
1448 Recurrance = buffer[0]*256 + buffer[1]; 1462 Recurrance = buffer[0]*256 + buffer[1];
1449 /* 8760 hours = 1 year */ 1463 /* 8760 hours = 1 year */
1450 if (Recurrance == 0xffff) Recurrance=8760; 1464 if (Recurrance == 0xffff) Recurrance=8760;
1451 if (Recurrance != 0) { 1465 if (Recurrance != 0) {
1452 smprintf(s, "Recurrance : %i hours\n",Recurrance); 1466 smprintf(s, "Recurrance : %i hours\n",Recurrance);
1453 entry->Entries[entry->EntriesNum].EntryType= CAL_RECURRANCE; 1467 entry->Entries[entry->EntriesNum].EntryType= CAL_RECURRANCE;
1454 entry->Entries[entry->EntriesNum].Number= Recurrance; 1468 entry->Entries[entry->EntriesNum].Number= Recurrance;
1455 entry->EntriesNum++; 1469 entry->EntriesNum++;
1456 } 1470 }
1457} 1471}
1458 1472
1459/* method 2 */ 1473/* method 2 */
1460GSM_Error N71_65_ReplyAddCalendar2(GSM_Protocol_Message msg, GSM_StateMachine *s) 1474GSM_Error N71_65_ReplyAddCalendar2(GSM_Protocol_Message msg, GSM_StateMachine *s)
1461{ 1475{
1462 smprintf(s, "Calendar note added\n"); 1476 smprintf(s, "Calendar note added\n");
1463 return ERR_NONE; 1477 return ERR_NONE;
1464} 1478}
1465 1479
1466/* method 2 */ 1480/* method 2 */
1467GSM_Error N71_65_AddCalendar2(GSM_StateMachine *s, GSM_CalendarEntry *Note) 1481GSM_Error N71_65_AddCalendar2(GSM_StateMachine *s, GSM_CalendarEntry *Note)
1468{ 1482{
1469 GSM_CalendarNoteTypeNoteType; 1483 GSM_CalendarNoteTypeNoteType;
1470 time_t t_time1,t_time2; 1484 time_t t_time1,t_time2;
1471 GSM_DateTime Date,date_time; 1485 GSM_DateTime Date,date_time;
1472 GSM_Error error; 1486 GSM_Error error;
diff --git a/gammu/emb/common/phone/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c
index dd14f8e..3106369 100644
--- a/gammu/emb/common/phone/obex/obexgen.c
+++ b/gammu/emb/common/phone/obex/obexgen.c
@@ -729,123 +729,124 @@ GSM_Phone_Functions OBEXGENPhone = {
729 NONEFUNCTION, /* GetManufacturer */ 729 NONEFUNCTION, /* GetManufacturer */
730 NONEFUNCTION, /* GetModel */ 730 NONEFUNCTION, /* GetModel */
731 NONEFUNCTION, /* GetFirmware */ 731 NONEFUNCTION, /* GetFirmware */
732 NOTIMPLEMENTED, /* GetIMEI */ 732 NOTIMPLEMENTED, /* GetIMEI */
733 NOTIMPLEMENTED, /* GetOriginalIMEI */ 733 NOTIMPLEMENTED, /* GetOriginalIMEI */
734 NOTIMPLEMENTED, /* GetManufactureMonth*/ 734 NOTIMPLEMENTED, /* GetManufactureMonth*/
735 NOTIMPLEMENTED, /* GetProductCode */ 735 NOTIMPLEMENTED, /* GetProductCode */
736 NOTIMPLEMENTED, /* GetHardware */ 736 NOTIMPLEMENTED, /* GetHardware */
737 NOTIMPLEMENTED, /* GetPPM */ 737 NOTIMPLEMENTED, /* GetPPM */
738 NOTIMPLEMENTED, /* GetSIMIMSI */ 738 NOTIMPLEMENTED, /* GetSIMIMSI */
739 NOTIMPLEMENTED, /* GetDateTime */ 739 NOTIMPLEMENTED, /* GetDateTime */
740 NOTIMPLEMENTED, /* SetDateTime */ 740 NOTIMPLEMENTED, /* SetDateTime */
741 NOTIMPLEMENTED, /* GetAlarm */ 741 NOTIMPLEMENTED, /* GetAlarm */
742 NOTIMPLEMENTED, /* SetAlarm */ 742 NOTIMPLEMENTED, /* SetAlarm */
743 NOTSUPPORTED, /* GetLocale */ 743 NOTSUPPORTED, /* GetLocale */
744 NOTSUPPORTED, /* SetLocale */ 744 NOTSUPPORTED, /* SetLocale */
745 NOTIMPLEMENTED, /* PressKey */ 745 NOTIMPLEMENTED, /* PressKey */
746 NOTIMPLEMENTED, /* Reset */ 746 NOTIMPLEMENTED, /* Reset */
747 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 747 NOTIMPLEMENTED, /* ResetPhoneSettings*/
748 NOTIMPLEMENTED, /* EnterSecurityCode*/ 748 NOTIMPLEMENTED, /* EnterSecurityCode*/
749 NOTIMPLEMENTED, /* GetSecurityStatus*/ 749 NOTIMPLEMENTED, /* GetSecurityStatus*/
750 NOTIMPLEMENTED, /* GetDisplayStatus*/ 750 NOTIMPLEMENTED, /* GetDisplayStatus*/
751 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 751 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
752 NOTIMPLEMENTED, /* GetBatteryCharge*/ 752 NOTIMPLEMENTED, /* GetBatteryCharge*/
753 NOTIMPLEMENTED, /* GetSignalQuality*/ 753 NOTIMPLEMENTED, /* GetSignalQuality*/
754 NOTIMPLEMENTED, /* GetNetworkInfo */ 754 NOTIMPLEMENTED, /* GetNetworkInfo */
755 NOTIMPLEMENTED, /* GetCategory */ 755 NOTIMPLEMENTED, /* GetCategory */
756 NOTSUPPORTED, /* AddCategory */ 756 NOTSUPPORTED, /* AddCategory */
757 NOTIMPLEMENTED, /* GetCategoryStatus */ 757 NOTIMPLEMENTED, /* GetCategoryStatus */
758 NOTIMPLEMENTED, /* GetMemoryStatus */ 758 NOTIMPLEMENTED, /* GetMemoryStatus */
759 NOTIMPLEMENTED, /* GetMemory */ 759 NOTIMPLEMENTED, /* GetMemory */
760 NOTIMPLEMENTED, /* GetNextMemory */ 760 NOTIMPLEMENTED, /* GetNextMemory */
761 NOTIMPLEMENTED, /* SetMemory */ 761 NOTIMPLEMENTED, /* SetMemory */
762 NOTIMPLEMENTED, /* AddMemory */ 762 NOTIMPLEMENTED, /* AddMemory */
763 NOTIMPLEMENTED, /* DeleteMemory */ 763 NOTIMPLEMENTED, /* DeleteMemory */
764 NOTIMPLEMENTED, /* DeleteAllMemory */ 764 NOTIMPLEMENTED, /* DeleteAllMemory */
765 NOTIMPLEMENTED, /* GetSpeedDial */ 765 NOTIMPLEMENTED, /* GetSpeedDial */
766 NOTIMPLEMENTED, /* SetSpeedDial */ 766 NOTIMPLEMENTED, /* SetSpeedDial */
767 NOTIMPLEMENTED, /* GetSMSC */ 767 NOTIMPLEMENTED, /* GetSMSC */
768 NOTIMPLEMENTED, /* SetSMSC */ 768 NOTIMPLEMENTED, /* SetSMSC */
769 NOTIMPLEMENTED, /* GetSMSStatus */ 769 NOTIMPLEMENTED, /* GetSMSStatus */
770 NOTIMPLEMENTED, /* GetSMS */ 770 NOTIMPLEMENTED, /* GetSMS */
771 NOTIMPLEMENTED, /* GetNextSMS */ 771 NOTIMPLEMENTED, /* GetNextSMS */
772 NOTIMPLEMENTED, /* SetSMS */ 772 NOTIMPLEMENTED, /* SetSMS */
773 NOTIMPLEMENTED, /* AddSMS */ 773 NOTIMPLEMENTED, /* AddSMS */
774 NOTIMPLEMENTED, /* DeleteSMS */ 774 NOTIMPLEMENTED, /* DeleteSMS */
775 NOTIMPLEMENTED, /* SendSMSMessage */ 775 NOTIMPLEMENTED, /* SendSMSMessage */
776 NOTSUPPORTED, /* SendSavedSMS */ 776 NOTSUPPORTED, /* SendSavedSMS */
777 NOTSUPPORTED, /* SetFastSMSSending*/
777 NOTIMPLEMENTED, /* SetIncomingSMS */ 778 NOTIMPLEMENTED, /* SetIncomingSMS */
778 NOTIMPLEMENTED, /* SetIncomingCB */ 779 NOTIMPLEMENTED, /* SetIncomingCB */
779 NOTIMPLEMENTED, /* GetSMSFolders */ 780 NOTIMPLEMENTED, /* GetSMSFolders */
780 NOTIMPLEMENTED, /* AddSMSFolder */ 781 NOTIMPLEMENTED, /* AddSMSFolder */
781 NOTIMPLEMENTED, /* DeleteSMSFolder */ 782 NOTIMPLEMENTED, /* DeleteSMSFolder */
782 NOTIMPLEMENTED, /* DialVoice */ 783 NOTIMPLEMENTED, /* DialVoice */
783 NOTIMPLEMENTED, /* AnswerCall */ 784 NOTIMPLEMENTED, /* AnswerCall */
784 NOTIMPLEMENTED, /* CancelCall */ 785 NOTIMPLEMENTED, /* CancelCall */
785 NOTIMPLEMENTED, /* HoldCall */ 786 NOTIMPLEMENTED, /* HoldCall */
786 NOTIMPLEMENTED, /* UnholdCall */ 787 NOTIMPLEMENTED, /* UnholdCall */
787 NOTIMPLEMENTED, /* ConferenceCall */ 788 NOTIMPLEMENTED, /* ConferenceCall */
788 NOTIMPLEMENTED, /* SplitCall */ 789 NOTIMPLEMENTED, /* SplitCall */
789 NOTIMPLEMENTED, /* TransferCall */ 790 NOTIMPLEMENTED, /* TransferCall */
790 NOTIMPLEMENTED, /* SwitchCall */ 791 NOTIMPLEMENTED, /* SwitchCall */
791 NOTIMPLEMENTED, /* GetCallDivert */ 792 NOTIMPLEMENTED, /* GetCallDivert */
792 NOTIMPLEMENTED, /* SetCallDivert */ 793 NOTIMPLEMENTED, /* SetCallDivert */
793 NOTIMPLEMENTED, /* CancelAllDiverts*/ 794 NOTIMPLEMENTED, /* CancelAllDiverts*/
794 NOTIMPLEMENTED, /* SetIncomingCall */ 795 NOTIMPLEMENTED, /* SetIncomingCall */
795 NOTIMPLEMENTED, /* SetIncomingUSSD */ 796 NOTIMPLEMENTED, /* SetIncomingUSSD */
796 NOTIMPLEMENTED, /* SendDTMF */ 797 NOTIMPLEMENTED, /* SendDTMF */
797 NOTIMPLEMENTED, /* GetRingtone */ 798 NOTIMPLEMENTED, /* GetRingtone */
798 NOTIMPLEMENTED, /* SetRingtone */ 799 NOTIMPLEMENTED, /* SetRingtone */
799 NOTIMPLEMENTED, /* GetRingtonesInfo*/ 800 NOTIMPLEMENTED, /* GetRingtonesInfo*/
800 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 801 NOTIMPLEMENTED, /* DeleteUserRingtones*/
801 NOTIMPLEMENTED, /* PlayTone */ 802 NOTIMPLEMENTED, /* PlayTone */
802 NOTIMPLEMENTED, /* GetWAPBookmark */ 803 NOTIMPLEMENTED, /* GetWAPBookmark */
803 NOTIMPLEMENTED, /* SetWAPBookmark */ 804 NOTIMPLEMENTED, /* SetWAPBookmark */
804 NOTIMPLEMENTED, /* DeleteWAPBookmark */ 805 NOTIMPLEMENTED, /* DeleteWAPBookmark */
805 NOTIMPLEMENTED, /* GetWAPSettings */ 806 NOTIMPLEMENTED, /* GetWAPSettings */
806 NOTIMPLEMENTED, /* SetWAPSettings */ 807 NOTIMPLEMENTED, /* SetWAPSettings */
807 NOTIMPLEMENTED, /* GetMMSSettings */ 808 NOTIMPLEMENTED, /* GetMMSSettings */
808 NOTIMPLEMENTED, /* SetMMSSettings */ 809 NOTIMPLEMENTED, /* SetMMSSettings */
809 NOTSUPPORTED, /* GetSyncMLSettings*/ 810 NOTSUPPORTED, /* GetSyncMLSettings*/
810 NOTSUPPORTED, /* SetSyncMLSettings*/ 811 NOTSUPPORTED, /* SetSyncMLSettings*/
811 NOTSUPPORTED, /* GetChatSettings */ 812 NOTSUPPORTED, /* GetChatSettings */
812 NOTSUPPORTED, /* SetChatSettings */ 813 NOTSUPPORTED, /* SetChatSettings */
813 NOTIMPLEMENTED, /* GetBitmap */ 814 NOTIMPLEMENTED, /* GetBitmap */
814 NOTIMPLEMENTED, /* SetBitmap */ 815 NOTIMPLEMENTED, /* SetBitmap */
815 NOTIMPLEMENTED, /* GetToDoStatus */ 816 NOTIMPLEMENTED, /* GetToDoStatus */
816 NOTIMPLEMENTED, /* GetToDo */ 817 NOTIMPLEMENTED, /* GetToDo */
817 NOTIMPLEMENTED, /* GetNextToDo */ 818 NOTIMPLEMENTED, /* GetNextToDo */
818 NOTIMPLEMENTED, /* SetToDo */ 819 NOTIMPLEMENTED, /* SetToDo */
819 NOTIMPLEMENTED, /* AddToDo */ 820 NOTIMPLEMENTED, /* AddToDo */
820 NOTIMPLEMENTED, /* DeleteToDo */ 821 NOTIMPLEMENTED, /* DeleteToDo */
821 NOTIMPLEMENTED, /* DeleteAllToDo */ 822 NOTIMPLEMENTED, /* DeleteAllToDo */
822 NOTIMPLEMENTED, /* GetCalendarStatus*/ 823 NOTIMPLEMENTED, /* GetCalendarStatus*/
823 NOTIMPLEMENTED, /* GetCalendar */ 824 NOTIMPLEMENTED, /* GetCalendar */
824 NOTIMPLEMENTED, /* GetNextCalendar */ 825 NOTIMPLEMENTED, /* GetNextCalendar */
825 NOTIMPLEMENTED, /* SetCalendar */ 826 NOTIMPLEMENTED, /* SetCalendar */
826 NOTIMPLEMENTED, /* AddCalendar */ 827 NOTIMPLEMENTED, /* AddCalendar */
827 NOTIMPLEMENTED, /* DeleteCalendar */ 828 NOTIMPLEMENTED, /* DeleteCalendar */
828 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 829 NOTIMPLEMENTED, /* DeleteAllCalendar*/
829 NOTSUPPORTED, /* GetCalendarSettings*/ 830 NOTSUPPORTED, /* GetCalendarSettings*/
830 NOTSUPPORTED, /* SetCalendarSettings*/ 831 NOTSUPPORTED, /* SetCalendarSettings*/
831 NOTSUPPORTED, /* GetNote */ 832 NOTSUPPORTED, /* GetNextNote */
832 NOTIMPLEMENTED, /* GetProfile */ 833 NOTIMPLEMENTED, /* GetProfile */
833 NOTIMPLEMENTED, /* SetProfile */ 834 NOTIMPLEMENTED, /* SetProfile */
834 NOTIMPLEMENTED, /* GetFMStation */ 835 NOTIMPLEMENTED, /* GetFMStation */
835 NOTIMPLEMENTED, /* SetFMStation */ 836 NOTIMPLEMENTED, /* SetFMStation */
836 NOTIMPLEMENTED, /* ClearFMStations */ 837 NOTIMPLEMENTED, /* ClearFMStations */
837 OBEXGEN_GetNextFileFolder, 838 OBEXGEN_GetNextFileFolder,
838 OBEXGEN_GetFilePart, 839 OBEXGEN_GetFilePart,
839 OBEXGEN_AddFilePart, 840 OBEXGEN_AddFilePart,
840 NOTIMPLEMENTED, /* GetFileSystemStatus*/ 841 NOTIMPLEMENTED, /* GetFileSystemStatus*/
841 OBEXGEN_DeleteFile, 842 OBEXGEN_DeleteFile,
842 OBEXGEN_AddFolder, 843 OBEXGEN_AddFolder,
843 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/ 844 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/
844 NOTIMPLEMENTED /* SetGPRSAccessPoint*/ 845 NOTIMPLEMENTED /* SetGPRSAccessPoint*/
845}; 846};
846 847
847#endif 848#endif
848 849
849/* How should editor hadle tabs in this file? Add editor commands here. 850/* How should editor hadle tabs in this file? Add editor commands here.
850 * vim: noexpandtab sw=8 ts=8 sts=8: 851 * vim: noexpandtab sw=8 ts=8 sts=8:
851 */ 852 */
diff --git a/gammu/emb/common/phone/obex/obexgen.h b/gammu/emb/common/phone/obex/obexgen.h
index 466fef5..b7033de 100644
--- a/gammu/emb/common/phone/obex/obexgen.h
+++ b/gammu/emb/common/phone/obex/obexgen.h
@@ -1,38 +1,42 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2 2
3#ifndef obexgen_h 3#ifndef obexgen_h
4#define obexgen_h 4#define obexgen_h
5 5
6#include "../../gsmcomon.h" 6#include "../../gsmcomon.h"
7#include "../../gsmstate.h" 7#include "../../gsmstate.h"
8#include "../../service/gsmmisc.h" 8#include "../../service/gsmmisc.h"
9#include "../../service/sms/gsmsms.h" 9#include "../../service/sms/gsmsms.h"
10 10
11#ifndef GSM_USED_IRDAOBEX 11#ifndef GSM_USED_IRDAOBEX
12# define GSM_USED_IRDAOBEX 12# define GSM_USED_IRDAOBEX
13#endif 13#endif
14#ifndef GSM_USED_BLUEOBEX 14#ifndef GSM_USED_BLUEOBEX
15# define GSM_USED_BLUEOBEX 15# define GSM_USED_BLUEOBEX
16#endif 16#endif
17 17
18typedef enum { 18typedef enum {
19 OBEX_None = 1, 19 OBEX_None = 1,
20 OBEX_BrowsingFolders 20 OBEX_BrowsingFolders
21} OBEX_Service; 21} OBEX_Service;
22 22
23typedef struct { 23typedef struct {
24 int FileLev; 24 int FileLev;
25 int FilesLocationsUsed; 25 int FilesLocationsUsed;
26 int FilesLocationsCurrent; 26 int FilesLocationsCurrent;
27 GSM_File Files[500]; 27 GSM_File Files[500];
28 bool FileLastPart; 28 bool FileLastPart;
29 29
30 int FrameSize; 30 int FrameSize;
31 OBEX_Service Service; 31 OBEX_Service Service;
32} GSM_Phone_OBEXGENData; 32} GSM_Phone_OBEXGENData;
33 33
34 GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File);
35 GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos);
36 GSM_Error OBEXGEN_Disconnect(GSM_StateMachine *s);
37
34#endif 38#endif
35 39
36/* How should editor hadle tabs in this file? Add editor commands here. 40/* How should editor hadle tabs in this file? Add editor commands here.
37 * vim: noexpandtab sw=8 ts=8 sts=8: 41 * vim: noexpandtab sw=8 ts=8 sts=8:
38 */ 42 */
diff --git a/gammu/emb/common/phone/symbian/mroutgen.c b/gammu/emb/common/phone/symbian/mroutgen.c
index 2c339be..a7382cf 100644
--- a/gammu/emb/common/phone/symbian/mroutgen.c
+++ b/gammu/emb/common/phone/symbian/mroutgen.c
@@ -98,123 +98,124 @@ GSM_Phone_Functions MROUTERGENPhone = {
98 NOTSUPPORTED, /* ShowStartInfo */ 98 NOTSUPPORTED, /* ShowStartInfo */
99 NONEFUNCTION, /* GetManufacturer */ 99 NONEFUNCTION, /* GetManufacturer */
100 NONEFUNCTION, /* GetModel */ 100 NONEFUNCTION, /* GetModel */
101 NONEFUNCTION, /* GetFirmware */ 101 NONEFUNCTION, /* GetFirmware */
102 NOTIMPLEMENTED, /* GetIMEI */ 102 NOTIMPLEMENTED, /* GetIMEI */
103 NOTSUPPORTED, /* GetOriginalIMEI */ 103 NOTSUPPORTED, /* GetOriginalIMEI */
104 NOTSUPPORTED, /* GetManufactureMonth*/ 104 NOTSUPPORTED, /* GetManufactureMonth*/
105 NOTSUPPORTED, /* GetProductCode */ 105 NOTSUPPORTED, /* GetProductCode */
106 NOTSUPPORTED, /* GetHardware */ 106 NOTSUPPORTED, /* GetHardware */
107 NOTSUPPORTED, /* GetPPM */ 107 NOTSUPPORTED, /* GetPPM */
108 NOTSUPPORTED, /* GetSIMIMSI */ 108 NOTSUPPORTED, /* GetSIMIMSI */
109 NOTSUPPORTED, /* GetDateTime */ 109 NOTSUPPORTED, /* GetDateTime */
110 NOTSUPPORTED, /* SetDateTime */ 110 NOTSUPPORTED, /* SetDateTime */
111 NOTSUPPORTED, /* GetAlarm */ 111 NOTSUPPORTED, /* GetAlarm */
112 NOTSUPPORTED, /* SetAlarm */ 112 NOTSUPPORTED, /* SetAlarm */
113 NOTSUPPORTED, /* GetLocale */ 113 NOTSUPPORTED, /* GetLocale */
114 NOTSUPPORTED, /* SetLocale */ 114 NOTSUPPORTED, /* SetLocale */
115 NOTSUPPORTED, /* PressKey */ 115 NOTSUPPORTED, /* PressKey */
116 NOTSUPPORTED, /* Reset */ 116 NOTSUPPORTED, /* Reset */
117 NOTSUPPORTED, /* ResetPhoneSettings*/ 117 NOTSUPPORTED, /* ResetPhoneSettings*/
118 NOTSUPPORTED, /* EnterSecurityCode*/ 118 NOTSUPPORTED, /* EnterSecurityCode*/
119 NOTSUPPORTED, /* GetSecurityStatus*/ 119 NOTSUPPORTED, /* GetSecurityStatus*/
120 NOTSUPPORTED, /* GetDisplayStatus*/ 120 NOTSUPPORTED, /* GetDisplayStatus*/
121 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 121 NOTSUPPORTED, /* SetAutoNetworkLogin*/
122 NOTSUPPORTED, /* GetBatteryCharge*/ 122 NOTSUPPORTED, /* GetBatteryCharge*/
123 NOTSUPPORTED, /* GetSignalQuality*/ 123 NOTSUPPORTED, /* GetSignalQuality*/
124 NOTSUPPORTED, /* GetNetworkInfo */ 124 NOTSUPPORTED, /* GetNetworkInfo */
125 NOTSUPPORTED, /* GetCategory */ 125 NOTSUPPORTED, /* GetCategory */
126 NOTSUPPORTED, /* GetCategoryStatus */ 126 NOTSUPPORTED, /* GetCategoryStatus */
127 NOTSUPPORTED, /* GetMemoryStatus */ 127 NOTSUPPORTED, /* GetMemoryStatus */
128 NOTSUPPORTED, /* GetMemory */ 128 NOTSUPPORTED, /* GetMemory */
129 NOTSUPPORTED, /* GetNextMemory */ 129 NOTSUPPORTED, /* GetNextMemory */
130 NOTSUPPORTED, /* SetMemory */ 130 NOTSUPPORTED, /* SetMemory */
131 NOTSUPPORTED, /* AddMemory */ 131 NOTSUPPORTED, /* AddMemory */
132 NOTSUPPORTED, /* DeleteMemory */ 132 NOTSUPPORTED, /* DeleteMemory */
133 NOTIMPLEMENTED, /* DeleteAllMemory */ 133 NOTIMPLEMENTED, /* DeleteAllMemory */
134 NOTSUPPORTED, /* GetSpeedDial */ 134 NOTSUPPORTED, /* GetSpeedDial */
135 NOTSUPPORTED, /* SetSpeedDial */ 135 NOTSUPPORTED, /* SetSpeedDial */
136 NOTSUPPORTED, /* GetSMSC */ 136 NOTSUPPORTED, /* GetSMSC */
137 NOTSUPPORTED, /* SetSMSC */ 137 NOTSUPPORTED, /* SetSMSC */
138 NOTSUPPORTED, /* GetSMSStatus */ 138 NOTSUPPORTED, /* GetSMSStatus */
139 NOTSUPPORTED, /* GetSMS */ 139 NOTSUPPORTED, /* GetSMS */
140 NOTSUPPORTED, /* GetNextSMS */ 140 NOTSUPPORTED, /* GetNextSMS */
141 NOTSUPPORTED, /* SetSMS */ 141 NOTSUPPORTED, /* SetSMS */
142 NOTSUPPORTED, /* AddSMS */ 142 NOTSUPPORTED, /* AddSMS */
143 NOTSUPPORTED, /* DeleteSMS */ 143 NOTSUPPORTED, /* DeleteSMS */
144 NOTSUPPORTED, /* SendSMSMessage */ 144 NOTSUPPORTED, /* SendSMSMessage */
145 NOTSUPPORTED, /* SendSavedSMS */ 145 NOTSUPPORTED, /* SendSavedSMS */
146 NOTSUPPORTED, /* SetFastSMSSending*/
146 NOTSUPPORTED, /* SetIncomingSMS */ 147 NOTSUPPORTED, /* SetIncomingSMS */
147 NOTSUPPORTED, /* SetIncomingCB */ 148 NOTSUPPORTED, /* SetIncomingCB */
148 NOTSUPPORTED, /* GetSMSFolders */ 149 NOTSUPPORTED, /* GetSMSFolders */
149 NOTSUPPORTED, /* AddSMSFolder */ 150 NOTSUPPORTED, /* AddSMSFolder */
150 NOTSUPPORTED, /* DeleteSMSFolder */ 151 NOTSUPPORTED, /* DeleteSMSFolder */
151 NOTSUPPORTED, /* DialVoice */ 152 NOTSUPPORTED, /* DialVoice */
152 NOTSUPPORTED, /* AnswerCall */ 153 NOTSUPPORTED, /* AnswerCall */
153 NOTSUPPORTED, /* CancelCall */ 154 NOTSUPPORTED, /* CancelCall */
154 NOTSUPPORTED, /* HoldCall */ 155 NOTSUPPORTED, /* HoldCall */
155 NOTSUPPORTED, /* UnholdCall */ 156 NOTSUPPORTED, /* UnholdCall */
156 NOTSUPPORTED, /* ConferenceCall */ 157 NOTSUPPORTED, /* ConferenceCall */
157 NOTSUPPORTED, /* SplitCall */ 158 NOTSUPPORTED, /* SplitCall */
158 NOTSUPPORTED, /* TransferCall */ 159 NOTSUPPORTED, /* TransferCall */
159 NOTSUPPORTED, /* SwitchCall */ 160 NOTSUPPORTED, /* SwitchCall */
160 NOTSUPPORTED, /* GetCallDivert */ 161 NOTSUPPORTED, /* GetCallDivert */
161 NOTSUPPORTED, /* SetCallDivert */ 162 NOTSUPPORTED, /* SetCallDivert */
162 NOTSUPPORTED, /* CancelAllDiverts*/ 163 NOTSUPPORTED, /* CancelAllDiverts*/
163 NOTSUPPORTED, /* SetIncomingCall */ 164 NOTSUPPORTED, /* SetIncomingCall */
164 NOTSUPPORTED, /* SetIncomingUSSD */ 165 NOTSUPPORTED, /* SetIncomingUSSD */
165 NOTSUPPORTED, /* SendDTMF */ 166 NOTSUPPORTED, /* SendDTMF */
166 NOTSUPPORTED, /* GetRingtone */ 167 NOTSUPPORTED, /* GetRingtone */
167 NOTSUPPORTED, /* SetRingtone */ 168 NOTSUPPORTED, /* SetRingtone */
168 NOTSUPPORTED, /* GetRingtonesInfo*/ 169 NOTSUPPORTED, /* GetRingtonesInfo*/
169 NOTSUPPORTED, /* DeleteUserRingtones*/ 170 NOTSUPPORTED, /* DeleteUserRingtones*/
170 NOTSUPPORTED, /* PlayTone */ 171 NOTSUPPORTED, /* PlayTone */
171 NOTSUPPORTED, /* GetWAPBookmark */ 172 NOTSUPPORTED, /* GetWAPBookmark */
172 NOTSUPPORTED, /* SetWAPBookmark */ 173 NOTSUPPORTED, /* SetWAPBookmark */
173 NOTSUPPORTED, /* DeleteWAPBookmark */ 174 NOTSUPPORTED, /* DeleteWAPBookmark */
174 NOTSUPPORTED, /* GetWAPSettings */ 175 NOTSUPPORTED, /* GetWAPSettings */
175 NOTSUPPORTED, /* SetWAPSettings */ 176 NOTSUPPORTED, /* SetWAPSettings */
176 NOTSUPPORTED, /* GetMMSSettings */ 177 NOTSUPPORTED, /* GetMMSSettings */
177 NOTSUPPORTED, /* SetMMSSettings */ 178 NOTSUPPORTED, /* SetMMSSettings */
178 NOTSUPPORTED, /* GetSyncMLSettings*/ 179 NOTSUPPORTED, /* GetSyncMLSettings*/
179 NOTSUPPORTED, /* SetSyncMLSettings*/ 180 NOTSUPPORTED, /* SetSyncMLSettings*/
180 NOTSUPPORTED, /* GetChatSettings */ 181 NOTSUPPORTED, /* GetChatSettings */
181 NOTSUPPORTED, /* SetChatSettings */ 182 NOTSUPPORTED, /* SetChatSettings */
182 NOTSUPPORTED, /* GetBitmap */ 183 NOTSUPPORTED, /* GetBitmap */
183 NOTSUPPORTED, /* SetBitmap */ 184 NOTSUPPORTED, /* SetBitmap */
184 NOTSUPPORTED, /* GetToDoStatus */ 185 NOTSUPPORTED, /* GetToDoStatus */
185 NOTSUPPORTED, /* GetToDo */ 186 NOTSUPPORTED, /* GetToDo */
186 NOTSUPPORTED, /* GetNextToDo */ 187 NOTSUPPORTED, /* GetNextToDo */
187 NOTSUPPORTED, /* SetToDo */ 188 NOTSUPPORTED, /* SetToDo */
188 NOTSUPPORTED, /* AddToDo */ 189 NOTSUPPORTED, /* AddToDo */
189 NOTSUPPORTED, /* DeleteToDo */ 190 NOTSUPPORTED, /* DeleteToDo */
190 NOTSUPPORTED, /* DeleteAllToDo */ 191 NOTSUPPORTED, /* DeleteAllToDo */
191 NOTSUPPORTED, /* GetCalendarStatus*/ 192 NOTSUPPORTED, /* GetCalendarStatus*/
192 NOTSUPPORTED, /* GetCalendar */ 193 NOTSUPPORTED, /* GetCalendar */
193 NOTSUPPORTED, /* GetNextCalendar */ 194 NOTSUPPORTED, /* GetNextCalendar */
194 NOTSUPPORTED, /* SetCalendar */ 195 NOTSUPPORTED, /* SetCalendar */
195 NOTSUPPORTED, /* AddCalendar */ 196 NOTSUPPORTED, /* AddCalendar */
196 NOTSUPPORTED, /* DeleteCalendar */ 197 NOTSUPPORTED, /* DeleteCalendar */
197 NOTSUPPORTED, /* DeleteAllCalendar*/ 198 NOTSUPPORTED, /* DeleteAllCalendar*/
198 NOTSUPPORTED, /* GetCalendarSettings*/ 199 NOTSUPPORTED, /* GetCalendarSettings*/
199 NOTSUPPORTED, /* SetCalendarSettings*/ 200 NOTSUPPORTED, /* SetCalendarSettings*/
200 NOTSUPPORTED, /* GetNote */ 201 NOTSUPPORTED, /* GetNextNote */
201 NOTSUPPORTED, /* GetProfile */ 202 NOTSUPPORTED, /* GetProfile */
202 NOTSUPPORTED, /* SetProfile */ 203 NOTSUPPORTED, /* SetProfile */
203 NOTSUPPORTED, /* GetFMStation */ 204 NOTSUPPORTED, /* GetFMStation */
204 NOTSUPPORTED, /* SetFMStation */ 205 NOTSUPPORTED, /* SetFMStation */
205 NOTSUPPORTED, /* ClearFMStations */ 206 NOTSUPPORTED, /* ClearFMStations */
206 NOTSUPPORTED, /* GetNextFileFolder*/ 207 NOTSUPPORTED, /* GetNextFileFolder*/
207 NOTSUPPORTED, /* GetFilePart */ 208 NOTSUPPORTED, /* GetFilePart */
208 NOTSUPPORTED, /* AddFilePart */ 209 NOTSUPPORTED, /* AddFilePart */
209 NOTSUPPORTED, /* GetFileSystemStatus*/ 210 NOTSUPPORTED, /* GetFileSystemStatus*/
210 NOTSUPPORTED, /* DeleteFile */ 211 NOTSUPPORTED, /* DeleteFile */
211 NOTSUPPORTED, /* AddFolder */ 212 NOTSUPPORTED, /* AddFolder */
212 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 213 NOTSUPPORTED, /* GetGPRSAccessPoint*/
213 NOTSUPPORTED /* SetGPRSAccessPoint*/ 214 NOTSUPPORTED /* SetGPRSAccessPoint*/
214}; 215};
215 216
216#endif 217#endif
217 218
218/* How should editor hadle tabs in this file? Add editor commands here. 219/* How should editor hadle tabs in this file? Add editor commands here.
219 * vim: noexpandtab sw=8 ts=8 sts=8: 220 * vim: noexpandtab sw=8 ts=8 sts=8:
220 */ 221 */