author | zautrix <zautrix> | 2006-02-24 19:41:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 19:41:06 (UTC) |
commit | 4e2553b95b2787ed7917073f6b628819b1f017c3 (patch) (unidiff) | |
tree | da5cb746bf3373cb2a368afda082999e6c22751f /gammu/emb | |
parent | 08605356c77351d64e14e0fdd69bdb769f933909 (diff) | |
download | kdepimpi-4e2553b95b2787ed7917073f6b628819b1f017c3.zip kdepimpi-4e2553b95b2787ed7917073f6b628819b1f017c3.tar.gz kdepimpi-4e2553b95b2787ed7917073f6b628819b1f017c3.tar.bz2 |
gcc4 fixes
-rw-r--r-- | gammu/emb/common/phone/alcatel/alcatel.c | 2 | ||||
-rw-r--r-- | gammu/emb/gammu/depend/nokia/dct3.c | 2 | ||||
-rw-r--r-- | gammu/emb/gammu/depend/nokia/dct3trac/wmx.c | 2 | ||||
-rw-r--r-- | gammu/emb/gammu/depend/nokia/dct4.c | 2 | ||||
-rw-r--r-- | gammu/emb/gammu/depend/siemens/dsiemens.c | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c index b75077f..718d91e 100644 --- a/gammu/emb/common/phone/alcatel/alcatel.c +++ b/gammu/emb/common/phone/alcatel/alcatel.c | |||
@@ -1,4009 +1,4009 @@ | |||
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 | ||
59 | extern GSM_Reply_Function ALCATELReplyFunctions[]; | 59 | static GSM_Reply_Function ALCATELReplyFunctions[]; |
60 | extern GSM_Reply_Function ATGENReplyFunctions[]; | 60 | extern 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_SetFastSMSSending(GSM_StateMachine *s, bool enable); |
105 | extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); | 105 | extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); |
106 | extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); | 106 | extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * 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 |
110 | * 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 |
111 | * that I found... | 111 | * that I found... |
112 | */ | 112 | */ |
113 | unsigned char GSM_AlcatelAlphabet[] = | 113 | unsigned char GSM_AlcatelAlphabet[] = |
114 | { | 114 | { |
115 | /* in phone unicode description*/ | 115 | /* in phone unicode description*/ |
116 | 0x80, 0x00,0x20, /* empty */ | 116 | 0x80, 0x00,0x20, /* empty */ |
117 | 0x81, 0x00,0x20, /* empty*/ | 117 | 0x81, 0x00,0x20, /* empty*/ |
118 | 0x82, 0x00,0x20, /* empty*/ | 118 | 0x82, 0x00,0x20, /* empty*/ |
119 | 0x83, 0x00,0x20, /* empty*/ | 119 | 0x83, 0x00,0x20, /* empty*/ |
120 | 120 | ||
121 | 0x84, 0x00,0xe7, /* c cedilla*/ | 121 | 0x84, 0x00,0xe7, /* c cedilla*/ |
122 | 0x85, 0x20,0x26, /* ... */ | 122 | 0x85, 0x20,0x26, /* ... */ |
123 | 0x86, 0x03,0xc0, /* pi */ | 123 | 0x86, 0x03,0xc0, /* pi */ |
124 | 0x87, 0x01,0x3e, /* l caron*/ | 124 | 0x87, 0x01,0x3e, /* l caron*/ |
125 | 0x88, 0x00,0xc0, /* A grave*/ | 125 | 0x88, 0x00,0xc0, /* A grave*/ |
126 | 0x89, 0x00,0xc1, /* A acute*/ | 126 | 0x89, 0x00,0xc1, /* A acute*/ |
127 | 0x8a, 0x00,0xc2, /* A circumflex*/ | 127 | 0x8a, 0x00,0xc2, /* A circumflex*/ |
128 | 0x8b, 0x00,0xc3, /* A tilde*/ | 128 | 0x8b, 0x00,0xc3, /* A tilde*/ |
129 | 0x8c, 0x00,0xc8, /* E grave*/ | 129 | 0x8c, 0x00,0xc8, /* E grave*/ |
130 | 0x8d, 0x00,0xca, /* E circumflex*/ | 130 | 0x8d, 0x00,0xca, /* E circumflex*/ |
131 | 0x8e, 0x00,0xcb, /* E diaresis*/ | 131 | 0x8e, 0x00,0xcb, /* E diaresis*/ |
132 | 0x8f, 0x00,0xcc, /* I grave*/ | 132 | 0x8f, 0x00,0xcc, /* I grave*/ |
133 | 0x90, 0x00,0xcd, /* I acute*/ | 133 | 0x90, 0x00,0xcd, /* I acute*/ |
134 | 0x91, 0x00,0xd0, /* ETH */ | 134 | 0x91, 0x00,0xd0, /* ETH */ |
135 | 0x92, 0x00,0xd2, /* O grave*/ | 135 | 0x92, 0x00,0xd2, /* O grave*/ |
136 | 0x93, 0x00,0xd3, /* O acute*/ | 136 | 0x93, 0x00,0xd3, /* O acute*/ |
137 | 0x94, 0x00,0xd4, /* O circumflex*/ | 137 | 0x94, 0x00,0xd4, /* O circumflex*/ |
138 | 0x95, 0x00,0xd5, /* O tilde*/ | 138 | 0x95, 0x00,0xd5, /* O tilde*/ |
139 | 0x96, 0x00,0xd9, /* U grave*/ | 139 | 0x96, 0x00,0xd9, /* U grave*/ |
140 | 0x97, 0x00,0xda, /* U acute*/ | 140 | 0x97, 0x00,0xda, /* U acute*/ |
141 | 0x98, 0x00,0xe1, /* a acute*/ | 141 | 0x98, 0x00,0xe1, /* a acute*/ |
142 | 0x99, 0x00,0xe2, /* a circumflex*/ | 142 | 0x99, 0x00,0xe2, /* a circumflex*/ |
143 | 0x9a, 0x00,0xe3, /* a tilde*/ | 143 | 0x9a, 0x00,0xe3, /* a tilde*/ |
144 | 0x9b, 0x00,0xea, /* e circumflex*/ | 144 | 0x9b, 0x00,0xea, /* e circumflex*/ |
145 | 0x9c, 0x00,0xeb, /* e diaresis*/ | 145 | 0x9c, 0x00,0xeb, /* e diaresis*/ |
146 | 0x9d, 0x00,0xed, /* i acute*/ | 146 | 0x9d, 0x00,0xed, /* i acute*/ |
147 | 0x9e, 0x00,0xee, /* i circumflex*/ | 147 | 0x9e, 0x00,0xee, /* i circumflex*/ |
148 | 0x9f, 0x00,0xef, /* i diaresis*/ | 148 | 0x9f, 0x00,0xef, /* i diaresis*/ |
149 | 0xa0, 0x00,0xf3, /* o acute*/ | 149 | 0xa0, 0x00,0xf3, /* o acute*/ |
150 | 0xa1, 0x00,0xf4, /* o circumflex*/ | 150 | 0xa1, 0x00,0xf4, /* o circumflex*/ |
151 | 0xa2, 0x00,0xf5, /* o tilde*/ | 151 | 0xa2, 0x00,0xf5, /* o tilde*/ |
152 | 0xa3, 0x00,0xfa, /* u acute*/ | 152 | 0xa3, 0x00,0xfa, /* u acute*/ |
153 | 0xa4, 0x00,0xa2, /* cent */ | 153 | 0xa4, 0x00,0xa2, /* cent */ |
154 | 0xa5, 0x00,0x5b, /* [ */ | 154 | 0xa5, 0x00,0x5b, /* [ */ |
155 | 0xa6, 0x01,0x59, /* r caron*/ | 155 | 0xa6, 0x01,0x59, /* r caron*/ |
156 | 0xa7, 0x01,0x0d, /* c caron*/ | 156 | 0xa7, 0x01,0x0d, /* c caron*/ |
157 | 0xa8, 0x01,0x61, /* s caron*/ | 157 | 0xa8, 0x01,0x61, /* s caron*/ |
158 | 0xa9, 0x01,0x1b, /* e caron*/ | 158 | 0xa9, 0x01,0x1b, /* e caron*/ |
159 | 0xaa, 0x01,0x6f, /* u ring*/ | 159 | 0xaa, 0x01,0x6f, /* u ring*/ |
160 | 0xab, 0x00,0xfd, /* y acute*/ | 160 | 0xab, 0x00,0xfd, /* y acute*/ |
161 | 0xac, 0x00,0xf0, /* eth */ | 161 | 0xac, 0x00,0xf0, /* eth */ |
162 | 0xad, 0x01,0x07, /* c acute*/ | 162 | 0xad, 0x01,0x07, /* c acute*/ |
163 | 0xae, 0x01,0x19, /* e ogonek*/ | 163 | 0xae, 0x01,0x19, /* e ogonek*/ |
164 | 0xaf, 0x01,0x05, /* a ogonek*/ | 164 | 0xaf, 0x01,0x05, /* a ogonek*/ |
165 | 0xb0, 0x01,0x7c, /* z dot*/ | 165 | 0xb0, 0x01,0x7c, /* z dot*/ |
166 | 0xb1, 0x01,0x7a, /* z acute*/ | 166 | 0xb1, 0x01,0x7a, /* z acute*/ |
167 | 0xb2, 0x01,0x5b, /* s acute*/ | 167 | 0xb2, 0x01,0x5b, /* s acute*/ |
168 | 0xb3, 0x01,0x44, /* n acute*/ | 168 | 0xb3, 0x01,0x44, /* n acute*/ |
169 | 0xb4, 0x01,0x42, /* l stroke*/ | 169 | 0xb4, 0x01,0x42, /* l stroke*/ |
170 | 170 | ||
171 | 0xb5, 0x00,0x20, /* empty*/ | 171 | 0xb5, 0x00,0x20, /* empty*/ |
172 | 172 | ||
173 | 0xb6, 0x01,0x48, /* n caron*/ | 173 | 0xb6, 0x01,0x48, /* n caron*/ |
174 | 0xb7, 0x01,0x65, /* t caron*/ | 174 | 0xb7, 0x01,0x65, /* t caron*/ |
175 | 175 | ||
176 | 0xb8, 0x00,0x20, /* empty*/ | 176 | 0xb8, 0x00,0x20, /* empty*/ |
177 | 177 | ||
178 | 0xb9, 0x01,0x7e, /* z caron*/ | 178 | 0xb9, 0x01,0x7e, /* z caron*/ |
179 | 0xba, 0x01,0xe7, /* g caron*/ | 179 | 0xba, 0x01,0xe7, /* g caron*/ |
180 | 180 | ||
181 | 0xbb, 0x00,0x20, /* empty*/ | 181 | 0xbb, 0x00,0x20, /* empty*/ |
182 | 0xbc, 0x00,0x20, /* empty*/ | 182 | 0xbc, 0x00,0x20, /* empty*/ |
183 | 183 | ||
184 | 0xbd, 0x1e,0x20, /* G macron*/ | 184 | 0xbd, 0x1e,0x20, /* G macron*/ |
185 | 0xbe, 0x1e,0x21, /* g macron*/ | 185 | 0xbe, 0x1e,0x21, /* g macron*/ |
186 | 0xbf, 0x01,0x5e, /* S cedilla*/ | 186 | 0xbf, 0x01,0x5e, /* S cedilla*/ |
187 | 0xc0, 0x01,0x5f, /* s cedilla*/ | 187 | 0xc0, 0x01,0x5f, /* s cedilla*/ |
188 | 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 */ |
189 | 0xc2, 0x01,0x31, /* i dotless*/ | 189 | 0xc2, 0x01,0x31, /* i dotless*/ |
190 | 0xc3, 0x01,0x68, /* U tilde*/ | 190 | 0xc3, 0x01,0x68, /* U tilde*/ |
191 | 0xc4, 0x01,0x50, /* O dbl acute*/ | 191 | 0xc4, 0x01,0x50, /* O dbl acute*/ |
192 | 0xc5, 0x01,0x69, /* u tilde*/ | 192 | 0xc5, 0x01,0x69, /* u tilde*/ |
193 | 0xc6, 0x01,0x51, /* o dbl acute*/ | 193 | 0xc6, 0x01,0x51, /* o dbl acute*/ |
194 | 0xc7, 0x27,0xa9, /* => */ | 194 | 0xc7, 0x27,0xa9, /* => */ |
195 | 0xc8, 0x27,0xa8, /* filled =>*/ | 195 | 0xc8, 0x27,0xa8, /* filled =>*/ |
196 | 0xc9, 0x00,0xd7, /* x */ | 196 | 0xc9, 0x00,0xd7, /* x */ |
197 | 0xca, 0x00,0x5d, /* ] */ | 197 | 0xca, 0x00,0x5d, /* ] */ |
198 | 0xcb, 0x26,0x0f, /* phone*/ | 198 | 0xcb, 0x26,0x0f, /* phone*/ |
199 | 0xcc, 0x01,0x0f, /* d caron*/ | 199 | 0xcc, 0x01,0x0f, /* d caron*/ |
200 | 200 | ||
201 | 0xcd, 0x00,0x20, /* empty*/ | 201 | 0xcd, 0x00,0x20, /* empty*/ |
202 | 202 | ||
203 | 0xce, 0x00,0x7e, /* ~ */ | 203 | 0xce, 0x00,0x7e, /* ~ */ |
204 | 0xcf, 0x00,0x5c, /* \ */ | 204 | 0xcf, 0x00,0x5c, /* \ */ |
205 | 0xd0, 0x00,0x5e, /* ^ */ | 205 | 0xd0, 0x00,0x5e, /* ^ */ |
206 | 206 | ||
207 | 0xd1, 0x00,0x20, /* empty*/ | 207 | 0xd1, 0x00,0x20, /* empty*/ |
208 | 208 | ||
209 | 0xd2, 0x00,0x7b, /* { */ | 209 | 0xd2, 0x00,0x7b, /* { */ |
210 | 0xd3, 0x00,0x7c, /* | */ | 210 | 0xd3, 0x00,0x7c, /* | */ |
211 | 0xd4, 0x00,0x7d, /* } */ | 211 | 0xd4, 0x00,0x7d, /* } */ |
212 | 212 | ||
213 | 0xd5, 0x00,0x20, /* empty*/ | 213 | 0xd5, 0x00,0x20, /* empty*/ |
214 | 214 | ||
215 | 0xd6, 0x01,0x63, /* t cedilla*/ | 215 | 0xd6, 0x01,0x63, /* t cedilla*/ |
216 | 216 | ||
217 | 0xd7, 0x00,0x20, /* empty*/ | 217 | 0xd7, 0x00,0x20, /* empty*/ |
218 | 0xd8, 0x00,0x20, /* empty*/ | 218 | 0xd8, 0x00,0x20, /* empty*/ |
219 | 0xd9, 0x00,0x20, /* empty*/ | 219 | 0xd9, 0x00,0x20, /* empty*/ |
220 | 0xda, 0x00,0x20, /* empty*/ | 220 | 0xda, 0x00,0x20, /* empty*/ |
221 | 0xdb, 0x00,0x20, /* empty*/ | 221 | 0xdb, 0x00,0x20, /* empty*/ |
222 | 0xdc, 0x00,0x20, /* empty*/ | 222 | 0xdc, 0x00,0x20, /* empty*/ |
223 | 0xdd, 0x00,0x20, /* empty*/ | 223 | 0xdd, 0x00,0x20, /* empty*/ |
224 | 0xde, 0x00,0x20, /* empty*/ | 224 | 0xde, 0x00,0x20, /* empty*/ |
225 | 0xdf, 0x00,0x20, /* empty*/ | 225 | 0xdf, 0x00,0x20, /* empty*/ |
226 | 0xe0, 0x00,0x20, /* empty*/ | 226 | 0xe0, 0x00,0x20, /* empty*/ |
227 | 227 | ||
228 | 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ | 228 | 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ |
229 | 229 | ||
230 | 0xe2, 0x00,0x20, /* empty*/ | 230 | 0xe2, 0x00,0x20, /* empty*/ |
231 | 0xe3, 0x00,0x20, /* empty*/ | 231 | 0xe3, 0x00,0x20, /* empty*/ |
232 | 0xe4, 0x00,0x20, /* empty*/ | 232 | 0xe4, 0x00,0x20, /* empty*/ |
233 | 233 | ||
234 | 0xe5, 0x01,0xce, /* a caron*/ | 234 | 0xe5, 0x01,0xce, /* a caron*/ |
235 | 0xe6, 0x01,0x01, /* a macron*/ | 235 | 0xe6, 0x01,0x01, /* a macron*/ |
236 | 0xe7, 0x01,0x13, /* e macron*/ | 236 | 0xe7, 0x01,0x13, /* e macron*/ |
237 | 0xe8, 0x01,0x2b, /* i macron*/ | 237 | 0xe8, 0x01,0x2b, /* i macron*/ |
238 | 0xe9, 0x01,0x4d, /* o macron*/ | 238 | 0xe9, 0x01,0x4d, /* o macron*/ |
239 | 0xea, 0x01,0x6b, /* u macron*/ | 239 | 0xea, 0x01,0x6b, /* u macron*/ |
240 | 0xeb, 0x00,0x41, /* A */ | 240 | 0xeb, 0x00,0x41, /* A */ |
241 | 0xec, 0x00,0x40, /* @ */ | 241 | 0xec, 0x00,0x40, /* @ */ |
242 | 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ | 242 | 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ |
243 | 243 | ||
244 | 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ | 244 | 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ |
245 | 0xef, 0x00,0x20, /* big key*/ /* FIXME */ | 245 | 0xef, 0x00,0x20, /* big key*/ /* FIXME */ |
246 | 246 | ||
247 | 0xf0, 0x00,0x20, /* empty*/ | 247 | 0xf0, 0x00,0x20, /* empty*/ |
248 | 248 | ||
249 | 0xf1, 0x00,0x31, /* 1 */ | 249 | 0xf1, 0x00,0x31, /* 1 */ |
250 | 0xf2, 0x00,0x21, /* bold !*/ | 250 | 0xf2, 0x00,0x21, /* bold !*/ |
251 | 0xf3, 0x26,0x0e, /* black phone*/ | 251 | 0xf3, 0x26,0x0e, /* black phone*/ |
252 | 0xf4, 0x00,0x26, /* & */ | 252 | 0xf4, 0x00,0x26, /* & */ |
253 | 0xf5, 0x23,0x7e, /* bell */ | 253 | 0xf5, 0x23,0x7e, /* bell */ |
254 | 0xf6, 0x26,0x6a, /* note */ | 254 | 0xf6, 0x26,0x6a, /* note */ |
255 | 255 | ||
256 | 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ | 256 | 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ |
257 | 0xf8, 0x27,0x13, /* okay */ | 257 | 0xf8, 0x27,0x13, /* okay */ |
258 | 258 | ||
259 | 0xf9, 0x00,0x20, /* empty*/ | 259 | 0xf9, 0x00,0x20, /* empty*/ |
260 | 260 | ||
261 | 0xfa, 0x00,0x20, /* key */ /* FIXME */ | 261 | 0xfa, 0x00,0x20, /* key */ /* FIXME */ |
262 | 262 | ||
263 | 0xfb, 0x00,0x20, /* empty*/ | 263 | 0xfb, 0x00,0x20, /* empty*/ |
264 | 264 | ||
265 | 0xfc, 0x20,0xac, /* Euro */ | 265 | 0xfc, 0x20,0xac, /* Euro */ |
266 | 0xfd, 0x21,0x97, /* NE arrow*/ | 266 | 0xfd, 0x21,0x97, /* NE arrow*/ |
267 | 0xfe, 0x21,0x98, /* SE arrow*/ | 267 | 0xfe, 0x21,0x98, /* SE arrow*/ |
268 | 268 | ||
269 | 0xff, 0x00,0x20, /* empty*/ | 269 | 0xff, 0x00,0x20, /* empty*/ |
270 | 270 | ||
271 | 0x00, 0x00,0x00 | 271 | 0x00, 0x00,0x00 |
272 | }; | 272 | }; |
273 | 273 | ||
274 | /* This is being called from atgen */ | 274 | /* This is being called from atgen */ |
275 | GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) | 275 | GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) |
276 | { | 276 | { |
277 | char *str, *str2; | 277 | char *str, *str2; |
278 | /* | 278 | /* |
279 | * Reply received here looks like: | 279 | * Reply received here looks like: |
280 | * 1 "AT+CPROT=?" | 280 | * 1 "AT+CPROT=?" |
281 | * 2 "+CPROT: 0,"V1.0",1" | 281 | * 2 "+CPROT: 0,"V1.0",1" |
282 | * 3 "+CPROT: 16,"V1.1",16" | 282 | * 3 "+CPROT: 16,"V1.1",16" |
283 | * 4 "OK" | 283 | * 4 "OK" |
284 | */ | 284 | */ |
285 | switch (s->Phone.Data.Priv.ATGEN.ReplyState) { | 285 | switch (s->Phone.Data.Priv.ATGEN.ReplyState) { |
286 | case AT_Reply_OK: | 286 | case AT_Reply_OK: |
287 | str = strstr(msg.Buffer, "\"V"); | 287 | str = strstr(msg.Buffer, "\"V"); |
288 | if (str == NULL) return ERR_UNKNOWNRESPONSE; | 288 | if (str == NULL) return ERR_UNKNOWNRESPONSE; |
289 | str += 2; | 289 | str += 2; |
290 | while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2; | 290 | while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2; |
291 | if (strncmp(str, "1.0", 3) == 0) { | 291 | if (strncmp(str, "1.0", 3) == 0) { |
292 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0; | 292 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0; |
293 | } else if (strncmp(str, "1.1", 3) == 0) { | 293 | } else if (strncmp(str, "1.1", 3) == 0) { |
294 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1; | 294 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1; |
295 | } else { | 295 | } else { |
296 | 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"); |
297 | return ERR_NOTIMPLEMENTED; | 297 | return ERR_NOTIMPLEMENTED; |
298 | } | 298 | } |
299 | return ERR_NONE; | 299 | return ERR_NONE; |
300 | case AT_Reply_Error: | 300 | case AT_Reply_Error: |
301 | case AT_Reply_CMSError: | 301 | case AT_Reply_CMSError: |
302 | return ATGEN_HandleCMSError(s); | 302 | return ATGEN_HandleCMSError(s); |
303 | default: | 303 | default: |
304 | return ERR_UNKNOWNRESPONSE; | 304 | return ERR_UNKNOWNRESPONSE; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) | 308 | static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) |
309 | { | 309 | { |
310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
311 | GSM_Error error; | 311 | GSM_Error error; |
312 | 312 | ||
313 | if (Priv->Mode == ModeBinary) return ERR_NONE; | 313 | if (Priv->Mode == ModeBinary) return ERR_NONE; |
314 | 314 | ||
315 | dbgprintf ("Changing to binary mode\n"); | 315 | dbgprintf ("Changing to binary mode\n"); |
316 | 316 | ||
317 | 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); |
318 | if (error != ERR_NONE) return error; | 318 | if (error != ERR_NONE) return error; |
319 | 319 | ||
320 | 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); |
321 | if (error != ERR_NONE) return error; | 321 | if (error != ERR_NONE) return error; |
322 | 322 | ||
323 | if (Priv->ProtocolVersion == V_1_0) { | 323 | if (Priv->ProtocolVersion == V_1_0) { |
324 | 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); |
325 | } else { | 325 | } else { |
326 | 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); |
327 | } | 327 | } |
328 | 328 | ||
329 | if (error == ERR_TIMEOUT && s->Speed != 19200) { | 329 | if (error == ERR_TIMEOUT && s->Speed != 19200) { |
330 | 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"); |
331 | } | 331 | } |
332 | 332 | ||
333 | if (error != ERR_NONE) return error; | 333 | if (error != ERR_NONE) return error; |
334 | 334 | ||
335 | dbgprintf ("Changing protocol to Alcabus\n"); | 335 | dbgprintf ("Changing protocol to Alcabus\n"); |
336 | 336 | ||
337 | s->Protocol.Functions = &ALCABUSProtocol; | 337 | s->Protocol.Functions = &ALCABUSProtocol; |
338 | error = s->Protocol.Functions->Initialise(s); | 338 | error = s->Protocol.Functions->Initialise(s); |
339 | if (error != ERR_NONE) { | 339 | if (error != ERR_NONE) { |
340 | s->Protocol.Functions = &ATProtocol; | 340 | s->Protocol.Functions = &ATProtocol; |
341 | return error; | 341 | return error; |
342 | } | 342 | } |
343 | s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; | 343 | s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; |
344 | Priv->Mode = ModeBinary; | 344 | Priv->Mode = ModeBinary; |
345 | Priv->BinaryItem = 0; | 345 | Priv->BinaryItem = 0; |
346 | Priv->BinaryType = 0; | 346 | Priv->BinaryType = 0; |
347 | Priv->BinaryState = StateAttached; | 347 | Priv->BinaryState = StateAttached; |
348 | return ERR_NONE; | 348 | return ERR_NONE; |
349 | } | 349 | } |
350 | 350 | ||
351 | static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) { | 351 | static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) { |
352 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 352 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
353 | GSM_Error error; | 353 | GSM_Error error; |
354 | unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20}; | 354 | unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20}; |
355 | unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00}; | 355 | unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00}; |
356 | unsigned char start_buffer[] = | 356 | unsigned char start_buffer[] = |
357 | {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */ | 357 | {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */ |
358 | 0x12, 0x34, 0x56, 0x78}; | 358 | 0x12, 0x34, 0x56, 0x78}; |
359 | unsigned char end_buffer[] = | 359 | unsigned char end_buffer[] = |
360 | {0x00, 0x04, 0x7C, 0x82, | 360 | {0x00, 0x04, 0x7C, 0x82, |
361 | 0x00, /* type */ | 361 | 0x00, /* type */ |
362 | 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */ | 362 | 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */ |
363 | unsigned char close_buffer[] = | 363 | unsigned char close_buffer[] = |
364 | {0x00, 0x04, | 364 | {0x00, 0x04, |
365 | 0x00, /*type */ | 365 | 0x00, /*type */ |
366 | 0x23, 0x01}; | 366 | 0x23, 0x01}; |
367 | unsigned char select1_buffer[] = | 367 | unsigned char select1_buffer[] = |
368 | {0x00, 0x00, | 368 | {0x00, 0x00, |
369 | 0x00, /*type */ | 369 | 0x00, /*type */ |
370 | 0x20}; | 370 | 0x20}; |
371 | unsigned char select2_buffer[] = | 371 | unsigned char select2_buffer[] = |
372 | {0x00, 0x04, | 372 | {0x00, 0x04, |
373 | 0x00, /*type */ | 373 | 0x00, /*type */ |
374 | 0x22, 0x01, 0x00}; | 374 | 0x22, 0x01, 0x00}; |
375 | unsigned char begin_buffer[] = | 375 | unsigned char begin_buffer[] = |
376 | {0x00, 0x04, 0x7C, 0x81, | 376 | {0x00, 0x04, 0x7C, 0x81, |
377 | 0x00, /*type */ | 377 | 0x00, /*type */ |
378 | 0x00, 0x85, 0x00}; | 378 | 0x00, 0x85, 0x00}; |
379 | unsigned char commit_buffer[] = | 379 | unsigned char commit_buffer[] = |
380 | {0x00, 0x04, | 380 | {0x00, 0x04, |
381 | 0x00, /*type */ | 381 | 0x00, /*type */ |
382 | 0x20, 0x01}; | 382 | 0x20, 0x01}; |
383 | 383 | ||
384 | 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); |
385 | error = ALCATEL_SetBinaryMode(s); | 385 | error = ALCATEL_SetBinaryMode(s); |
386 | if (error != ERR_NONE) return error; | 386 | if (error != ERR_NONE) return error; |
387 | 387 | ||
388 | /* Do we need to do anything? */ | 388 | /* Do we need to do anything? */ |
389 | 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; |
390 | 390 | ||
391 | /* 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 */ |
392 | if (Priv->BinaryState == StateEdit) { | 392 | if (Priv->BinaryState == StateEdit) { |
393 | /* Something has changed, we will have to reread fields! */ | 393 | /* Something has changed, we will have to reread fields! */ |
394 | Priv->CurrentFieldsItem = -1; | 394 | Priv->CurrentFieldsItem = -1; |
395 | switch (Priv->BinaryType) { | 395 | switch (Priv->BinaryType) { |
396 | case TypeCalendar: | 396 | case TypeCalendar: |
397 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 397 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
398 | break; | 398 | break; |
399 | case TypeContacts: | 399 | case TypeContacts: |
400 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 400 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
401 | break; | 401 | break; |
402 | case TypeToDo: | 402 | case TypeToDo: |
403 | commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 403 | commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
404 | break; | 404 | break; |
405 | } | 405 | } |
406 | dbgprintf ("Commiting edited record\n"); | 406 | dbgprintf ("Commiting edited record\n"); |
407 | 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); |
408 | if (error != ERR_NONE) return error; | 408 | if (error != ERR_NONE) return error; |
409 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2); | 409 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2); |
410 | if (error != ERR_NONE) return error; | 410 | if (error != ERR_NONE) return error; |
411 | Priv->BinaryState = StateSession; | 411 | Priv->BinaryState = StateSession; |
412 | Priv->BinaryItem = 0; | 412 | Priv->BinaryItem = 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | /* Do we want to edit something of same type? */ | 415 | /* Do we want to edit something of same type? */ |
416 | if ((state == StateEdit) && (type == Priv->BinaryType)) { | 416 | if ((state == StateEdit) && (type == Priv->BinaryType)) { |
417 | /* 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 |
418 | * 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 |
419 | * mode. | 419 | * mode. |
420 | */ | 420 | */ |
421 | Priv->BinaryState = StateEdit; | 421 | Priv->BinaryState = StateEdit; |
422 | Priv->BinaryItem = item; | 422 | Priv->BinaryItem = item; |
423 | return ERR_NONE; | 423 | return ERR_NONE; |
424 | } | 424 | } |
425 | 425 | ||
426 | /* 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 */ |
427 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) { | 427 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) { |
428 | return ERR_NONE; | 428 | return ERR_NONE; |
429 | } | 429 | } |
430 | 430 | ||
431 | /* Do we need to close session? */ | 431 | /* Do we need to close session? */ |
432 | if (Priv->BinaryState == StateSession) { | 432 | if (Priv->BinaryState == StateSession) { |
433 | dbgprintf ("Ending session\n"); | 433 | dbgprintf ("Ending session\n"); |
434 | switch (Priv->BinaryType) { | 434 | switch (Priv->BinaryType) { |
435 | case TypeCalendar: | 435 | case TypeCalendar: |
436 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; | 436 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; |
437 | break; | 437 | break; |
438 | case TypeContacts: | 438 | case TypeContacts: |
439 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; | 439 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; |
440 | break; | 440 | break; |
441 | case TypeToDo: | 441 | case TypeToDo: |
442 | end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; | 442 | end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; |
443 | break; | 443 | break; |
444 | } | 444 | } |
445 | 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); |
446 | if (error != ERR_NONE) return error; | 446 | if (error != ERR_NONE) return error; |
447 | 447 | ||
448 | switch (Priv->BinaryType) { | 448 | switch (Priv->BinaryType) { |
449 | case TypeCalendar: | 449 | case TypeCalendar: |
450 | close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 450 | close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
451 | break; | 451 | break; |
452 | case TypeContacts: | 452 | case TypeContacts: |
453 | close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 453 | close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
454 | break; | 454 | break; |
455 | case TypeToDo: | 455 | case TypeToDo: |
456 | close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 456 | close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
457 | break; | 457 | break; |
458 | } | 458 | } |
459 | dbgprintf ("Closing session\n"); | 459 | dbgprintf ("Closing session\n"); |
460 | 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); |
461 | if (error != ERR_NONE) return error; | 461 | if (error != ERR_NONE) return error; |
462 | 462 | ||
463 | dbgprintf ("Detaching binary mode\n"); | 463 | dbgprintf ("Detaching binary mode\n"); |
464 | GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach); | 464 | GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach); |
465 | 465 | ||
466 | Priv->BinaryState = StateAttached; | 466 | Priv->BinaryState = StateAttached; |
467 | Priv->BinaryType = 0; | 467 | Priv->BinaryType = 0; |
468 | } | 468 | } |
469 | 469 | ||
470 | /* Do we need to open session? */ | 470 | /* Do we need to open session? */ |
471 | if (state == StateSession || state == StateEdit) { | 471 | if (state == StateSession || state == StateEdit) { |
472 | dbgprintf ("Starting session for %s\n", | 472 | dbgprintf ("Starting session for %s\n", |
473 | (type == TypeCalendar ? "Calendar" : | 473 | (type == TypeCalendar ? "Calendar" : |
474 | (type == TypeToDo ? "Todo" : | 474 | (type == TypeToDo ? "Todo" : |
475 | (type == TypeContacts ? "Contacts" : | 475 | (type == TypeContacts ? "Contacts" : |
476 | "Unknown!")))); | 476 | "Unknown!")))); |
477 | /* Fill up buffers */ | 477 | /* Fill up buffers */ |
478 | switch (type) { | 478 | switch (type) { |
479 | case TypeCalendar: | 479 | case TypeCalendar: |
480 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 480 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
481 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 481 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
482 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; | 482 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; |
483 | break; | 483 | break; |
484 | case TypeContacts: | 484 | case TypeContacts: |
485 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 485 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
486 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 486 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
487 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; | 487 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; |
488 | break; | 488 | break; |
489 | case TypeToDo: | 489 | case TypeToDo: |
490 | select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 490 | select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
491 | select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 491 | select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
492 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; | 492 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; |
493 | break; | 493 | break; |
494 | } | 494 | } |
495 | dbgprintf ("Attaching in binary mode\n"); | 495 | dbgprintf ("Attaching in binary mode\n"); |
496 | 496 | ||
497 | /* Communicate */ | 497 | /* Communicate */ |
498 | error=GSM_WaitFor (s, attach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAttach); | 498 | error=GSM_WaitFor (s, attach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAttach); |
499 | if (error != ERR_NONE) return error; | 499 | if (error != ERR_NONE) return error; |
500 | 500 | ||
501 | smprintf(s,"Start session\n"); | 501 | smprintf(s,"Start session\n"); |
502 | 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); |
503 | if (error != ERR_NONE) return error; | 503 | if (error != ERR_NONE) return error; |
504 | 504 | ||
505 | smprintf(s,"Select type\n"); | 505 | smprintf(s,"Select type\n"); |
506 | 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); |
507 | if (error != ERR_NONE) return error; | 507 | if (error != ERR_NONE) return error; |
508 | 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); |
509 | if (error != ERR_NONE) return error; | 509 | if (error != ERR_NONE) return error; |
510 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); | 510 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); |
511 | if (error != ERR_NONE) return error; | 511 | if (error != ERR_NONE) return error; |
512 | 512 | ||
513 | smprintf(s,"Begin transfer\n"); | 513 | smprintf(s,"Begin transfer\n"); |
514 | 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); |
515 | if (error != ERR_NONE) return error; | 515 | if (error != ERR_NONE) return error; |
516 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); | 516 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); |
517 | if (error != ERR_NONE) return error; | 517 | if (error != ERR_NONE) return error; |
518 | 518 | ||
519 | Priv->BinaryState = StateSession; | 519 | Priv->BinaryState = StateSession; |
520 | Priv->BinaryType = type; | 520 | Priv->BinaryType = type; |
521 | /* Do we want to edit something of same type? */ | 521 | /* Do we want to edit something of same type? */ |
522 | if ((state == StateEdit) && (type == Priv->BinaryType)) { | 522 | if ((state == StateEdit) && (type == Priv->BinaryType)) { |
523 | Priv->BinaryState = StateEdit; | 523 | Priv->BinaryState = StateEdit; |
524 | Priv->BinaryItem = item; | 524 | Priv->BinaryItem = item; |
525 | return ERR_NONE; | 525 | return ERR_NONE; |
526 | } | 526 | } |
527 | } | 527 | } |
528 | return ERR_NONE; | 528 | return ERR_NONE; |
529 | } | 529 | } |
530 | 530 | ||
531 | static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) | 531 | static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) |
532 | { | 532 | { |
533 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 533 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
534 | GSM_Error error; | 534 | GSM_Error error; |
535 | 535 | ||
536 | if (Priv->Mode == ModeAT) return ERR_NONE; | 536 | if (Priv->Mode == ModeAT) return ERR_NONE; |
537 | 537 | ||
538 | error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); | 538 | error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); |
539 | if (error != ERR_NONE) return error; | 539 | if (error != ERR_NONE) return error; |
540 | 540 | ||
541 | error = s->Protocol.Functions->Terminate(s); | 541 | error = s->Protocol.Functions->Terminate(s); |
542 | if (error != ERR_NONE) return error; | 542 | if (error != ERR_NONE) return error; |
543 | 543 | ||
544 | dbgprintf ("Changing protocol to AT\n"); | 544 | dbgprintf ("Changing protocol to AT\n"); |
545 | s->Protocol.Functions = &ATProtocol; | 545 | s->Protocol.Functions = &ATProtocol; |
546 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; | 546 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; |
547 | Priv->Mode = ModeAT; | 547 | Priv->Mode = ModeAT; |
548 | s->Phone.Data.Priv.ATGEN.PBKCharset= 0; | 548 | s->Phone.Data.Priv.ATGEN.PBKCharset= 0; |
549 | s->Phone.Data.Priv.ATGEN.PBKMemory= 0; | 549 | s->Phone.Data.Priv.ATGEN.PBKMemory= 0; |
550 | 550 | ||
551 | my_sleep(100); | 551 | my_sleep(100); |
552 | 552 | ||
553 | /* 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, |
554 | * 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 |
555 | * intetionally ignored. | 555 | * intetionally ignored. |
556 | */ | 556 | */ |
557 | GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); | 557 | GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); |
558 | 558 | ||
559 | return ERR_NONE; | 559 | return ERR_NONE; |
560 | } | 560 | } |
561 | 561 | ||
562 | static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) | 562 | static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) |
563 | { | 563 | { |
564 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 564 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
565 | GSM_Error error; | 565 | GSM_Error error; |
566 | 566 | ||
567 | Priv->Mode = ModeAT; | 567 | Priv->Mode = ModeAT; |
568 | 568 | ||
569 | Priv->CalendarItems = NULL; | 569 | Priv->CalendarItems = NULL; |
570 | Priv->ContactsItems = NULL; | 570 | Priv->ContactsItems = NULL; |
571 | Priv->ToDoItems = NULL; | 571 | Priv->ToDoItems = NULL; |
572 | Priv->CalendarItemsCount = 0; | 572 | Priv->CalendarItemsCount = 0; |
573 | Priv->ToDoItemsCount = 0; | 573 | Priv->ToDoItemsCount = 0; |
574 | Priv->ContactsItemsCount = 0; | 574 | Priv->ContactsItemsCount = 0; |
575 | Priv->CurrentFields[0] = 0; | 575 | Priv->CurrentFields[0] = 0; |
576 | Priv->CurrentFieldsCount = 0; | 576 | Priv->CurrentFieldsCount = 0; |
577 | Priv->CurrentFieldsItem = 0; | 577 | Priv->CurrentFieldsItem = 0; |
578 | Priv->CurrentFieldsType = 0; | 578 | Priv->CurrentFieldsType = 0; |
579 | Priv->ProtocolVersion = V_1_0; | 579 | Priv->ProtocolVersion = V_1_0; |
580 | Priv->CurrentFieldsItem = -1; | 580 | Priv->CurrentFieldsItem = -1; |
581 | 581 | ||
582 | Priv->CurrentCategoriesCount = 0; | 582 | Priv->CurrentCategoriesCount = 0; |
583 | Priv->CurrentCategoriesType = 0; | 583 | Priv->CurrentCategoriesType = 0; |
584 | 584 | ||
585 | s->Protocol.Functions = &ATProtocol; | 585 | s->Protocol.Functions = &ATProtocol; |
586 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; | 586 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; |
587 | 587 | ||
588 | 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) { |
589 | smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); | 589 | smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); |
590 | s->Protocol.Functions = &ALCABUSProtocol; | 590 | s->Protocol.Functions = &ALCABUSProtocol; |
591 | error = s->Protocol.Functions->Terminate(s); | 591 | error = s->Protocol.Functions->Terminate(s); |
592 | s->Protocol.Functions = &ATProtocol; | 592 | s->Protocol.Functions = &ATProtocol; |
593 | 593 | ||
594 | error = ATGEN_Initialise(s); | 594 | error = ATGEN_Initialise(s); |
595 | if (error != ERR_NONE) return error; | 595 | if (error != ERR_NONE) return error; |
596 | } | 596 | } |
597 | 597 | ||
598 | return ERR_NONE; | 598 | return ERR_NONE; |
599 | } | 599 | } |
600 | 600 | ||
601 | static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s) | 601 | static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s) |
602 | { | 602 | { |
603 | GSM_Error error; | 603 | GSM_Error error; |
604 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 604 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
605 | 605 | ||
606 | free(Priv->CalendarItems); | 606 | free(Priv->CalendarItems); |
607 | free(Priv->ContactsItems); | 607 | free(Priv->ContactsItems); |
608 | free(Priv->ToDoItems); | 608 | free(Priv->ToDoItems); |
609 | error = ALCATEL_SetATMode(s); | 609 | error = ALCATEL_SetATMode(s); |
610 | return ATGEN_Terminate(s); | 610 | return ATGEN_Terminate(s); |
611 | } | 611 | } |
612 | 612 | ||
613 | /* finds whether id is set in the phone */ | 613 | /* finds whether id is set in the phone */ |
614 | static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { | 614 | static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { |
615 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 615 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
616 | int i; | 616 | int i; |
617 | 617 | ||
618 | if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION; | 618 | if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION; |
619 | 619 | ||
620 | switch (Priv->BinaryType) { | 620 | switch (Priv->BinaryType) { |
621 | case TypeCalendar: | 621 | case TypeCalendar: |
622 | Priv->CurrentList = &(Priv->CalendarItems); | 622 | Priv->CurrentList = &(Priv->CalendarItems); |
623 | Priv->CurrentCount = &(Priv->CalendarItemsCount); | 623 | Priv->CurrentCount = &(Priv->CalendarItemsCount); |
624 | break; | 624 | break; |
625 | case TypeContacts: | 625 | case TypeContacts: |
626 | Priv->CurrentList = &(Priv->ContactsItems); | 626 | Priv->CurrentList = &(Priv->ContactsItems); |
627 | Priv->CurrentCount = &(Priv->ContactsItemsCount); | 627 | Priv->CurrentCount = &(Priv->ContactsItemsCount); |
628 | break; | 628 | break; |
629 | case TypeToDo: | 629 | case TypeToDo: |
630 | Priv->CurrentList = &(Priv->ToDoItems); | 630 | Priv->CurrentList = &(Priv->ToDoItems); |
631 | Priv->CurrentCount = &(Priv->ToDoItemsCount); | 631 | Priv->CurrentCount = &(Priv->ToDoItemsCount); |
632 | break; | 632 | break; |
633 | } | 633 | } |
634 | 634 | ||
635 | for (i=0; i<*Priv->CurrentCount; i++) { | 635 | for (i=0; i<*Priv->CurrentCount; i++) { |
636 | if ((*Priv->CurrentList)[i] == id) return ERR_NONE; | 636 | if ((*Priv->CurrentList)[i] == id) return ERR_NONE; |
637 | } | 637 | } |
638 | 638 | ||
639 | return ERR_EMPTY; | 639 | return ERR_EMPTY; |
640 | } | 640 | } |
641 | 641 | ||
642 | /* finds next id that is available in the phone */ | 642 | /* finds next id that is available in the phone */ |
643 | static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { | 643 | static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { |
644 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 644 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
645 | int i = 0; | 645 | int i = 0; |
646 | int next = ALCATEL_MAX_LOCATION; | 646 | int next = ALCATEL_MAX_LOCATION; |
647 | 647 | ||
648 | switch (Priv->BinaryType) { | 648 | switch (Priv->BinaryType) { |
649 | case TypeCalendar: | 649 | case TypeCalendar: |
650 | Priv->CurrentList = &(Priv->CalendarItems); | 650 | Priv->CurrentList = &(Priv->CalendarItems); |
651 | Priv->CurrentCount = &(Priv->CalendarItemsCount); | 651 | Priv->CurrentCount = &(Priv->CalendarItemsCount); |
652 | break; | 652 | break; |
653 | case TypeContacts: | 653 | case TypeContacts: |
654 | Priv->CurrentList = &(Priv->ContactsItems); | 654 | Priv->CurrentList = &(Priv->ContactsItems); |
655 | Priv->CurrentCount = &(Priv->ContactsItemsCount); | 655 | Priv->CurrentCount = &(Priv->ContactsItemsCount); |
656 | break; | 656 | break; |
657 | case TypeToDo: | 657 | case TypeToDo: |
658 | Priv->CurrentList = &(Priv->ToDoItems); | 658 | Priv->CurrentList = &(Priv->ToDoItems); |
659 | Priv->CurrentCount = &(Priv->ToDoItemsCount); | 659 | Priv->CurrentCount = &(Priv->ToDoItemsCount); |
660 | break; | 660 | break; |
661 | } | 661 | } |
662 | 662 | ||
663 | for (i=0; i<*Priv->CurrentCount; i++) { | 663 | for (i=0; i<*Priv->CurrentCount; i++) { |
664 | if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) { | 664 | if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) { |
665 | next = (*Priv->CurrentList)[i]; | 665 | next = (*Priv->CurrentList)[i]; |
666 | } | 666 | } |
667 | } | 667 | } |
668 | if (next == ALCATEL_MAX_LOCATION) { | 668 | if (next == ALCATEL_MAX_LOCATION) { |
669 | return ERR_EMPTY; | 669 | return ERR_EMPTY; |
670 | } else { | 670 | } else { |
671 | *id = next; | 671 | *id = next; |
672 | return ERR_NONE; | 672 | return ERR_NONE; |
673 | } | 673 | } |
674 | } | 674 | } |
675 | 675 | ||
676 | static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s) | 676 | static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s) |
677 | { | 677 | { |
678 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 678 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
679 | int count,i,pos; | 679 | int count,i,pos; |
680 | 680 | ||
681 | count = msg.Buffer[10]; | 681 | count = msg.Buffer[10]; |
682 | *Priv->CurrentCount += count; | 682 | *Priv->CurrentCount += count; |
683 | 683 | ||
684 | *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int)); | 684 | *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int)); |
685 | if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY; | 685 | if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY; |
686 | 686 | ||
687 | for (i = 0; i < count; i++) { | 687 | for (i = 0; i < count; i++) { |
688 | pos = 11 + (4 * i); | 688 | pos = 11 + (4 * i); |
689 | (*Priv->CurrentList)[*Priv->CurrentCount - count + i] = msg.Buffer[pos + 3] + | 689 | (*Priv->CurrentList)[*Priv->CurrentCount - count + i] = msg.Buffer[pos + 3] + |
690 | (msg.Buffer[pos + 2] << 8) + | 690 | (msg.Buffer[pos + 2] << 8) + |
691 | (msg.Buffer[pos + 1] << 16) + | 691 | (msg.Buffer[pos + 1] << 16) + |
692 | (msg.Buffer[pos] << 24); | 692 | (msg.Buffer[pos] << 24); |
693 | } | 693 | } |
694 | (*Priv->CurrentList)[*Priv->CurrentCount] = 0; | 694 | (*Priv->CurrentList)[*Priv->CurrentCount] = 0; |
695 | 695 | ||
696 | /* If last byte is 0, then we transmitted all items */ | 696 | /* If last byte is 0, then we transmitted all items */ |
697 | Priv->TransferCompleted = msg.Buffer[4 + msg.Buffer[4]] == 0; | 697 | Priv->TransferCompleted = msg.Buffer[4 + msg.Buffer[4]] == 0; |
698 | return ERR_NONE; | 698 | return ERR_NONE; |
699 | } | 699 | } |
700 | 700 | ||
701 | static GSM_Error ALCATEL_GetAvailableIds(GSM_StateMachine *s, bool refresh) | 701 | static GSM_Error ALCATEL_GetAvailableIds(GSM_StateMachine *s, bool refresh) |
702 | { | 702 | { |
703 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 703 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
704 | GSM_Error error; | 704 | GSM_Error error; |
705 | int i; | 705 | int i; |
706 | unsigned char buffer[] = | 706 | unsigned char buffer[] = |
707 | {0x00, 0x04, | 707 | {0x00, 0x04, |
708 | 0x00, /*type */ | 708 | 0x00, /*type */ |
709 | 0x2F, 0x01}; | 709 | 0x2F, 0x01}; |
710 | 710 | ||
711 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; | 711 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; |
712 | 712 | ||
713 | switch (Priv->BinaryType) { | 713 | switch (Priv->BinaryType) { |
714 | case TypeCalendar: | 714 | case TypeCalendar: |
715 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 715 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
716 | Priv->CurrentList= &(Priv->CalendarItems); | 716 | Priv->CurrentList= &(Priv->CalendarItems); |
717 | Priv->CurrentCount= &(Priv->CalendarItemsCount); | 717 | Priv->CurrentCount= &(Priv->CalendarItemsCount); |
718 | break; | 718 | break; |
719 | case TypeContacts: | 719 | case TypeContacts: |
720 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 720 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
721 | Priv->CurrentList= &(Priv->ContactsItems); | 721 | Priv->CurrentList= &(Priv->ContactsItems); |
722 | Priv->CurrentCount= &(Priv->ContactsItemsCount); | 722 | Priv->CurrentCount= &(Priv->ContactsItemsCount); |
723 | break; | 723 | break; |
724 | case TypeToDo: | 724 | case TypeToDo: |
725 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 725 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
726 | Priv->CurrentList= &(Priv->ToDoItems); | 726 | Priv->CurrentList= &(Priv->ToDoItems); |
727 | Priv->CurrentCount= &(Priv->ToDoItemsCount); | 727 | Priv->CurrentCount= &(Priv->ToDoItemsCount); |
728 | break; | 728 | break; |
729 | } | 729 | } |
730 | 730 | ||
731 | if (*Priv->CurrentList != NULL) { | 731 | if (*Priv->CurrentList != NULL) { |
732 | if (!refresh) return ERR_NONE; | 732 | if (!refresh) return ERR_NONE; |
733 | free(*Priv->CurrentList); | 733 | free(*Priv->CurrentList); |
734 | *Priv->CurrentList = NULL; | 734 | *Priv->CurrentList = NULL; |
735 | } | 735 | } |
736 | smprintf(s,"Reading items list\n"); | 736 | smprintf(s,"Reading items list\n"); |
737 | 737 | ||
738 | *Priv->CurrentCount = 0; | 738 | *Priv->CurrentCount = 0; |
739 | Priv->TransferCompleted = false; | 739 | Priv->TransferCompleted = false; |
740 | 740 | ||
741 | error=GSM_WaitFor (s, buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetIds1); | 741 | error=GSM_WaitFor (s, buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetIds1); |
742 | if (error != ERR_NONE) return error; | 742 | if (error != ERR_NONE) return error; |
743 | 743 | ||
744 | while (!Priv->TransferCompleted) { | 744 | while (!Priv->TransferCompleted) { |
745 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetIds2); | 745 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetIds2); |
746 | if (error != ERR_NONE) return error; | 746 | if (error != ERR_NONE) return error; |
747 | } | 747 | } |
748 | 748 | ||
749 | i = 0; | 749 | i = 0; |
750 | smprintf(s,"Received %d ids: ", *Priv->CurrentCount); | 750 | smprintf(s,"Received %d ids: ", *Priv->CurrentCount); |
751 | for (i=0; i < *Priv->CurrentCount; i++) { | 751 | for (i=0; i < *Priv->CurrentCount; i++) { |
752 | smprintf(s,"%x ", (*Priv->CurrentList)[i]); | 752 | smprintf(s,"%x ", (*Priv->CurrentList)[i]); |
753 | } | 753 | } |
754 | smprintf(s,"\n"); | 754 | smprintf(s,"\n"); |
755 | 755 | ||
756 | return ERR_NONE; | 756 | return ERR_NONE; |
757 | } | 757 | } |
758 | 758 | ||
759 | static GSM_Error ALCATEL_ReplyGetFields(GSM_Protocol_Message msg, GSM_StateMachine *s) | 759 | static GSM_Error ALCATEL_ReplyGetFields(GSM_Protocol_Message msg, GSM_StateMachine *s) |
760 | { | 760 | { |
761 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 761 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
762 | int i; | 762 | int i; |
763 | 763 | ||
764 | if (msg.Buffer[14] > GSM_PHONEBOOK_ENTRIES) { | 764 | if (msg.Buffer[14] > GSM_PHONEBOOK_ENTRIES) { |
765 | smprintf(s, "WARNING: Field list truncated, you should increase GSM_PHONEBOOK_ENTRIES to at least %d\n", msg.Buffer[14]); | 765 | smprintf(s, "WARNING: Field list truncated, you should increase GSM_PHONEBOOK_ENTRIES to at least %d\n", msg.Buffer[14]); |
766 | Priv->CurrentFieldsCount = GSM_PHONEBOOK_ENTRIES; | 766 | Priv->CurrentFieldsCount = GSM_PHONEBOOK_ENTRIES; |
767 | } else { | 767 | } else { |
768 | Priv->CurrentFieldsCount = msg.Buffer[14]; | 768 | Priv->CurrentFieldsCount = msg.Buffer[14]; |
769 | } | 769 | } |
770 | 770 | ||
771 | Priv->CurrentFields[Priv->CurrentFieldsCount] = 0; | 771 | Priv->CurrentFields[Priv->CurrentFieldsCount] = 0; |
772 | 772 | ||
773 | for (i = 0; i < Priv->CurrentFieldsCount; i++) { | 773 | for (i = 0; i < Priv->CurrentFieldsCount; i++) { |
774 | Priv->CurrentFields[i] = msg.Buffer[15 + i]; | 774 | Priv->CurrentFields[i] = msg.Buffer[15 + i]; |
775 | } | 775 | } |
776 | 776 | ||
777 | return ERR_NONE; | 777 | return ERR_NONE; |
778 | } | 778 | } |
779 | 779 | ||
780 | static GSM_Error ALCATEL_GetFields(GSM_StateMachine *s, int id) { | 780 | static GSM_Error ALCATEL_GetFields(GSM_StateMachine *s, int id) { |
781 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 781 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
782 | GSM_Error error; | 782 | GSM_Error error; |
783 | int i; | 783 | int i; |
784 | unsigned char buffer[] = | 784 | unsigned char buffer[] = |
785 | {0x00, 0x04, | 785 | {0x00, 0x04, |
786 | 0x00, /* type */ | 786 | 0x00, /* type */ |
787 | 0x30, 0x01, | 787 | 0x30, 0x01, |
788 | 0x00, 0x00, 0x00, 0x00}; /* item */ | 788 | 0x00, 0x00, 0x00, 0x00}; /* item */ |
789 | 789 | ||
790 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; | 790 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; |
791 | if ((Priv->CurrentFieldsItem == id) && (Priv->CurrentFieldsType == Priv->BinaryType)) return ERR_NONE; | 791 | if ((Priv->CurrentFieldsItem == id) && (Priv->CurrentFieldsType == Priv->BinaryType)) return ERR_NONE; |
792 | 792 | ||
793 | smprintf(s,"Reading item fields (%d)\n", id); | 793 | smprintf(s,"Reading item fields (%d)\n", id); |
794 | 794 | ||
795 | buffer[5] = (id >> 24); | 795 | buffer[5] = (id >> 24); |
796 | buffer[6] = ((id >> 16) & 0xff); | 796 | buffer[6] = ((id >> 16) & 0xff); |
797 | buffer[7] = ((id >> 8) & 0xff); | 797 | buffer[7] = ((id >> 8) & 0xff); |
798 | buffer[8] = (id & 0xff); | 798 | buffer[8] = (id & 0xff); |
799 | 799 | ||
800 | switch (Priv->BinaryType) { | 800 | switch (Priv->BinaryType) { |
801 | case TypeCalendar: | 801 | case TypeCalendar: |
802 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 802 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
803 | break; | 803 | break; |
804 | case TypeContacts: | 804 | case TypeContacts: |
805 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 805 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
806 | break; | 806 | break; |
807 | case TypeToDo: | 807 | case TypeToDo: |
808 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 808 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
809 | break; | 809 | break; |
810 | } | 810 | } |
811 | 811 | ||
812 | Priv->CurrentFieldsItem = id; | 812 | Priv->CurrentFieldsItem = id; |
813 | Priv->CurrentFieldsType = Priv->BinaryType; | 813 | Priv->CurrentFieldsType = Priv->BinaryType; |
814 | 814 | ||
815 | error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1); | 815 | error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1); |
816 | if (error != ERR_NONE) return error; | 816 | if (error != ERR_NONE) return error; |
817 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2); | 817 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2); |
818 | if (error != ERR_NONE) return error; | 818 | if (error != ERR_NONE) return error; |
819 | 819 | ||
820 | i = 0; | 820 | i = 0; |
821 | smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount); | 821 | smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount); |
822 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 822 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
823 | smprintf(s,"%x ", Priv->CurrentFields[i]); | 823 | smprintf(s,"%x ", Priv->CurrentFields[i]); |
824 | } | 824 | } |
825 | smprintf(s,"\n"); | 825 | smprintf(s,"\n"); |
826 | 826 | ||
827 | return ERR_NONE; | 827 | return ERR_NONE; |
828 | } | 828 | } |
829 | 829 | ||
830 | static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s) | 830 | static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s) |
831 | { | 831 | { |
832 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 832 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
833 | unsigned char *buffer = &(msg.Buffer[16]); | 833 | unsigned char *buffer = &(msg.Buffer[16]); |
834 | 834 | ||
835 | if (buffer[1] == 0x05 && buffer[2] == 0x67) { | 835 | if (buffer[1] == 0x05 && buffer[2] == 0x67) { |
836 | /* date */ | 836 | /* date */ |
837 | Priv->ReturnType = Alcatel_date; | 837 | Priv->ReturnType = Alcatel_date; |
838 | Priv->ReturnDateTime.Day= buffer[4]; | 838 | Priv->ReturnDateTime.Day= buffer[4]; |
839 | Priv->ReturnDateTime.Month= buffer[5]; | 839 | Priv->ReturnDateTime.Month= buffer[5]; |
840 | Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); | 840 | Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); |
841 | Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ | 841 | Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ |
842 | 842 | ||
843 | Priv->ReturnDateTime.Hour= 0; | 843 | Priv->ReturnDateTime.Hour= 0; |
844 | Priv->ReturnDateTime.Minute= 0; | 844 | Priv->ReturnDateTime.Minute= 0; |
845 | Priv->ReturnDateTime.Second= 0; | 845 | Priv->ReturnDateTime.Second= 0; |
846 | } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { | 846 | } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { |
847 | /* time */ | 847 | /* time */ |
848 | Priv->ReturnType = Alcatel_time; | 848 | Priv->ReturnType = Alcatel_time; |
849 | Priv->ReturnDateTime.Hour= buffer[4]; | 849 | Priv->ReturnDateTime.Hour= buffer[4]; |
850 | Priv->ReturnDateTime.Minute= buffer[5]; | 850 | Priv->ReturnDateTime.Minute= buffer[5]; |
851 | Priv->ReturnDateTime.Second= buffer[6]; | 851 | Priv->ReturnDateTime.Second= buffer[6]; |
852 | 852 | ||
853 | Priv->ReturnDateTime.Day= 0; | 853 | Priv->ReturnDateTime.Day= 0; |
854 | Priv->ReturnDateTime.Month= 0; | 854 | Priv->ReturnDateTime.Month= 0; |
855 | Priv->ReturnDateTime.Year= 0; | 855 | Priv->ReturnDateTime.Year= 0; |
856 | Priv->ReturnDateTime.Timezone= 0; | 856 | Priv->ReturnDateTime.Timezone= 0; |
857 | } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { | 857 | } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { |
858 | /* string */ | 858 | /* string */ |
859 | Priv->ReturnType = Alcatel_string; | 859 | Priv->ReturnType = Alcatel_string; |
860 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) | 860 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) |
861 | 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); |
862 | if (Priv->ProtocolVersion == V_1_0) { | 862 | if (Priv->ProtocolVersion == V_1_0) { |
863 | 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); |
864 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { | 864 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { |
865 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); | 865 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); |
866 | Priv->ReturnString[buffer[3] + 1] = 0; | 866 | Priv->ReturnString[buffer[3] + 1] = 0; |
867 | Priv->ReturnString[buffer[3] + 2] = 0; | 867 | Priv->ReturnString[buffer[3] + 2] = 0; |
868 | ReverseUnicodeString(Priv->ReturnString); | 868 | ReverseUnicodeString(Priv->ReturnString); |
869 | } else { | 869 | } else { |
870 | 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); |
871 | } | 871 | } |
872 | } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) { | 872 | } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) { |
873 | /* phone */ | 873 | /* phone */ |
874 | Priv->ReturnType = Alcatel_phone; | 874 | Priv->ReturnType = Alcatel_phone; |
875 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) | 875 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) |
876 | 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); |
877 | if (Priv->ProtocolVersion == V_1_0) { | 877 | if (Priv->ProtocolVersion == V_1_0) { |
878 | 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); |
879 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { | 879 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { |
880 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); | 880 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); |
881 | Priv->ReturnString[buffer[3] + 1] = 0; | 881 | Priv->ReturnString[buffer[3] + 1] = 0; |
882 | Priv->ReturnString[buffer[3] + 2] = 0; | 882 | Priv->ReturnString[buffer[3] + 2] = 0; |
883 | ReverseUnicodeString(Priv->ReturnString); | 883 | ReverseUnicodeString(Priv->ReturnString); |
884 | } else { | 884 | } else { |
885 | 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); |
886 | } | 886 | } |
887 | } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) { | 887 | } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) { |
888 | /* boolean */ | 888 | /* boolean */ |
889 | Priv->ReturnType = Alcatel_bool; | 889 | Priv->ReturnType = Alcatel_bool; |
890 | Priv->ReturnInt = buffer[3]; | 890 | Priv->ReturnInt = buffer[3]; |
891 | } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) { | 891 | } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) { |
892 | /* integer */ | 892 | /* integer */ |
893 | Priv->ReturnType = Alcatel_int; | 893 | Priv->ReturnType = Alcatel_int; |
894 | 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); |
895 | } else if (buffer[1] == 0x04 && buffer[2] == 0x38) { | 895 | } else if (buffer[1] == 0x04 && buffer[2] == 0x38) { |
896 | /* enumeration */ | 896 | /* enumeration */ |
897 | Priv->ReturnType = Alcatel_enum; | 897 | Priv->ReturnType = Alcatel_enum; |
898 | Priv->ReturnInt = buffer[3]; | 898 | Priv->ReturnInt = buffer[3]; |
899 | } else if (buffer[1] == 0x00 && buffer[2] == 0x38) { | 899 | } else if (buffer[1] == 0x00 && buffer[2] == 0x38) { |
900 | /* byte */ | 900 | /* byte */ |
901 | Priv->ReturnType = Alcatel_byte; | 901 | Priv->ReturnType = Alcatel_byte; |
902 | Priv->ReturnInt = buffer[3]; | 902 | Priv->ReturnInt = buffer[3]; |
903 | } else { | 903 | } else { |
904 | smprintf(s, "WARNING: Uknown data type received (%02X,%02X)\n", buffer[1], buffer[2]); | 904 | smprintf(s, "WARNING: Uknown data type received (%02X,%02X)\n", buffer[1], buffer[2]); |
905 | return ERR_UNKNOWNRESPONSE; | 905 | return ERR_UNKNOWNRESPONSE; |
906 | } | 906 | } |
907 | return ERR_NONE; | 907 | return ERR_NONE; |
908 | } | 908 | } |
909 | 909 | ||
910 | static GSM_Error ALCATEL_GetFieldValue(GSM_StateMachine *s, int id, int field) | 910 | static GSM_Error ALCATEL_GetFieldValue(GSM_StateMachine *s, int id, int field) |
911 | { | 911 | { |
912 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 912 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
913 | GSM_Error error; | 913 | GSM_Error error; |
914 | unsigned char buffer[] = | 914 | unsigned char buffer[] = |
915 | {0x00, 0x04, | 915 | {0x00, 0x04, |
916 | 0x00, /* type */ | 916 | 0x00, /* type */ |
917 | 0x1f, 0x01, | 917 | 0x1f, 0x01, |
918 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ | 918 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ |
919 | 0x00}; /* field */ | 919 | 0x00}; /* field */ |
920 | 920 | ||
921 | smprintf(s,"Reading item value (%08x.%02x)\n", id, field); | 921 | smprintf(s,"Reading item value (%08x.%02x)\n", id, field); |
922 | 922 | ||
923 | switch (Priv->BinaryType) { | 923 | switch (Priv->BinaryType) { |
924 | case TypeCalendar: | 924 | case TypeCalendar: |
925 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 925 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
926 | break; | 926 | break; |
927 | case TypeContacts: | 927 | case TypeContacts: |
928 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 928 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
929 | break; | 929 | break; |
930 | case TypeToDo: | 930 | case TypeToDo: |
931 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 931 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
932 | break; | 932 | break; |
933 | } | 933 | } |
934 | 934 | ||
935 | buffer[5] = (id >> 24); | 935 | buffer[5] = (id >> 24); |
936 | buffer[6] = ((id >> 16) & 0xff); | 936 | buffer[6] = ((id >> 16) & 0xff); |
937 | buffer[7] = ((id >> 8) & 0xff); | 937 | buffer[7] = ((id >> 8) & 0xff); |
938 | buffer[8] = (id & 0xff); | 938 | buffer[8] = (id & 0xff); |
939 | buffer[9] = (field & 0xff); | 939 | buffer[9] = (field & 0xff); |
940 | 940 | ||
941 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFieldValue1); | 941 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFieldValue1); |
942 | if (error != ERR_NONE) return error; | 942 | if (error != ERR_NONE) return error; |
943 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFieldValue2); | 943 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFieldValue2); |
944 | if (error != ERR_NONE) return error; | 944 | if (error != ERR_NONE) return error; |
945 | 945 | ||
946 | return ERR_NONE; | 946 | return ERR_NONE; |
947 | } | 947 | } |
948 | 948 | ||
949 | static GSM_Error ALCATEL_ReplyGetCategories(GSM_Protocol_Message msg, GSM_StateMachine *s) | 949 | static GSM_Error ALCATEL_ReplyGetCategories(GSM_Protocol_Message msg, GSM_StateMachine *s) |
950 | { | 950 | { |
951 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 951 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
952 | int i; | 952 | int i; |
953 | 953 | ||
954 | /* Did we get any category? */ | 954 | /* Did we get any category? */ |
955 | if (msg.Buffer[4] == 6) { | 955 | if (msg.Buffer[4] == 6) { |
956 | Priv->CurrentCategoriesCount = 0; | 956 | Priv->CurrentCategoriesCount = 0; |
957 | return ERR_NONE; | 957 | return ERR_NONE; |
958 | } | 958 | } |
959 | if (msg.Buffer[12] > ALCATEL_MAX_CATEGORIES) { | 959 | if (msg.Buffer[12] > ALCATEL_MAX_CATEGORIES) { |
960 | smprintf(s, "WARNING: Field list truncated, you should increase ALCATEL_MAX_CATEGORIES to at least %d\n", msg.Buffer[12]); | 960 | smprintf(s, "WARNING: Field list truncated, you should increase ALCATEL_MAX_CATEGORIES to at least %d\n", msg.Buffer[12]); |
961 | Priv->CurrentCategoriesCount = ALCATEL_MAX_CATEGORIES; | 961 | Priv->CurrentCategoriesCount = ALCATEL_MAX_CATEGORIES; |
962 | } else { | 962 | } else { |
963 | Priv->CurrentCategoriesCount = msg.Buffer[12]; | 963 | Priv->CurrentCategoriesCount = msg.Buffer[12]; |
964 | } | 964 | } |
965 | 965 | ||
966 | for (i = 0; i < Priv->CurrentCategoriesCount; i++) { | 966 | for (i = 0; i < Priv->CurrentCategoriesCount; i++) { |
967 | Priv->CurrentCategories[i] = msg.Buffer[13 + i]; | 967 | Priv->CurrentCategories[i] = msg.Buffer[13 + i]; |
968 | Priv->CurrentCategoriesCache[i][0] = '\000'; | 968 | Priv->CurrentCategoriesCache[i][0] = '\000'; |
969 | Priv->CurrentCategoriesCache[i][1] = '\000'; | 969 | Priv->CurrentCategoriesCache[i][1] = '\000'; |
970 | } | 970 | } |
971 | 971 | ||
972 | return ERR_NONE; | 972 | return ERR_NONE; |
973 | } | 973 | } |
974 | 974 | ||
975 | static GSM_Error ALCATEL_GetAvailableCategoryIds(GSM_StateMachine *s) { | 975 | static GSM_Error ALCATEL_GetAvailableCategoryIds(GSM_StateMachine *s) { |
976 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 976 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
977 | GSM_Error error; | 977 | GSM_Error error; |
978 | int i; | 978 | int i; |
979 | unsigned char buffer[] = | 979 | unsigned char buffer[] = |
980 | {0x00, 0x04, | 980 | {0x00, 0x04, |
981 | 0x00 /*type */, | 981 | 0x00 /*type */, |
982 | 0x0b, | 982 | 0x0b, |
983 | 0x00 /* list */}; | 983 | 0x00 /* list */}; |
984 | 984 | ||
985 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; | 985 | if (Priv->BinaryState != StateSession) return ERR_UNKNOWN; |
986 | if (Priv->CurrentCategoriesType == Priv->BinaryType) return ERR_NONE; | 986 | if (Priv->CurrentCategoriesType == Priv->BinaryType) return ERR_NONE; |
987 | switch (Priv->BinaryType) { | 987 | switch (Priv->BinaryType) { |
988 | case TypeContacts: | 988 | case TypeContacts: |
989 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 989 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
990 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; | 990 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; |
991 | break; | 991 | break; |
992 | case TypeToDo: | 992 | case TypeToDo: |
993 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 993 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
994 | buffer[4] = ALCATEL_LIST_TODO_CAT; | 994 | buffer[4] = ALCATEL_LIST_TODO_CAT; |
995 | break; | 995 | break; |
996 | default: | 996 | default: |
997 | return ERR_NOTSUPPORTED; | 997 | return ERR_NOTSUPPORTED; |
998 | } | 998 | } |
999 | 999 | ||
1000 | Priv->CurrentCategoriesType = Priv->BinaryType; | 1000 | Priv->CurrentCategoriesType = Priv->BinaryType; |
1001 | 1001 | ||
1002 | smprintf(s,"Reading category list\n"); | 1002 | smprintf(s,"Reading category list\n"); |
1003 | 1003 | ||
1004 | error=GSM_WaitFor (s, buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategories1); | 1004 | error=GSM_WaitFor (s, buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategories1); |
1005 | if (error != ERR_NONE) return error; | 1005 | if (error != ERR_NONE) return error; |
1006 | 1006 | ||
1007 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategories2); | 1007 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategories2); |
1008 | if (error != ERR_NONE) return error; | 1008 | if (error != ERR_NONE) return error; |
1009 | 1009 | ||
1010 | i = 0; | 1010 | i = 0; |
1011 | smprintf(s,"Received %d ids: ", Priv->CurrentCategoriesCount); | 1011 | smprintf(s,"Received %d ids: ", Priv->CurrentCategoriesCount); |
1012 | for (i=0; i < Priv->CurrentCategoriesCount; i++) { | 1012 | for (i=0; i < Priv->CurrentCategoriesCount; i++) { |
1013 | smprintf(s,"%i ", Priv->CurrentCategories[i]); | 1013 | smprintf(s,"%i ", Priv->CurrentCategories[i]); |
1014 | } | 1014 | } |
1015 | smprintf(s,"\n"); | 1015 | smprintf(s,"\n"); |
1016 | 1016 | ||
1017 | return ERR_NONE; | 1017 | return ERR_NONE; |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | static GSM_Error ALCATEL_IsCategoryIdAvailable(GSM_StateMachine *s, int id) { | 1020 | static GSM_Error ALCATEL_IsCategoryIdAvailable(GSM_StateMachine *s, int id) { |
1021 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1021 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1022 | int i = 0; | 1022 | int i = 0; |
1023 | 1023 | ||
1024 | if (Priv->CurrentCategoriesType != Priv->BinaryType) return ERR_UNKNOWN; | 1024 | if (Priv->CurrentCategoriesType != Priv->BinaryType) return ERR_UNKNOWN; |
1025 | 1025 | ||
1026 | for (i = 0; i< Priv->CurrentCategoriesCount; i++) { | 1026 | for (i = 0; i< Priv->CurrentCategoriesCount; i++) { |
1027 | if (Priv->CurrentCategories[i] == id) return ERR_NONE; | 1027 | if (Priv->CurrentCategories[i] == id) return ERR_NONE; |
1028 | } | 1028 | } |
1029 | return ERR_EMPTY; | 1029 | return ERR_EMPTY; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static GSM_Error ALCATEL_ReplyAddCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1032 | static GSM_Error ALCATEL_ReplyAddCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1033 | { | 1033 | { |
1034 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 1034 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
1035 | 1035 | ||
1036 | Priv->ReturnInt = msg.Buffer[12]; | 1036 | Priv->ReturnInt = msg.Buffer[12]; |
1037 | 1037 | ||
1038 | return ERR_NONE; | 1038 | return ERR_NONE; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | static GSM_Error ALCATEL_AddCategoryText(GSM_StateMachine *s, const unsigned char *str) { | 1041 | static GSM_Error ALCATEL_AddCategoryText(GSM_StateMachine *s, const unsigned char *str) { |
1042 | unsigned char buffer[200] = {0x00, 0x04, 0x00 /*type*/, 0x0d, 0x00 /*list*/, 0x0b }; | 1042 | unsigned char buffer[200] = {0x00, 0x04, 0x00 /*type*/, 0x0d, 0x00 /*list*/, 0x0b }; |
1043 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1043 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1044 | GSM_Error error; | 1044 | GSM_Error error; |
1045 | int len; | 1045 | int len; |
1046 | 1046 | ||
1047 | smprintf(s,"Creating category\n"); | 1047 | smprintf(s,"Creating category\n"); |
1048 | len = UnicodeLength(str); | 1048 | len = UnicodeLength(str); |
1049 | EncodeDefault(buffer + 8, str, &len, true, GSM_AlcatelAlphabet); | 1049 | EncodeDefault(buffer + 8, str, &len, true, GSM_AlcatelAlphabet); |
1050 | buffer[6] = len + 1; | 1050 | buffer[6] = len + 1; |
1051 | buffer[7] = len; | 1051 | buffer[7] = len; |
1052 | 1052 | ||
1053 | switch (Priv->BinaryType) { | 1053 | switch (Priv->BinaryType) { |
1054 | case TypeContacts: | 1054 | case TypeContacts: |
1055 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1055 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1056 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; | 1056 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; |
1057 | break; | 1057 | break; |
1058 | case TypeToDo: | 1058 | case TypeToDo: |
1059 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1059 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1060 | buffer[4] = ALCATEL_LIST_TODO_CAT; | 1060 | buffer[4] = ALCATEL_LIST_TODO_CAT; |
1061 | break; | 1061 | break; |
1062 | default: | 1062 | default: |
1063 | return ERR_NOTSUPPORTED; | 1063 | return ERR_NOTSUPPORTED; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | 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); |
1067 | if (error != ERR_NONE) return error; | 1067 | if (error != ERR_NONE) return error; |
1068 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2); | 1068 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2); |
1069 | if (error != ERR_NONE) return error; | 1069 | if (error != ERR_NONE) return error; |
1070 | 1070 | ||
1071 | /* Refresh list */ | 1071 | /* Refresh list */ |
1072 | Priv->CurrentCategoriesType = 0; | 1072 | Priv->CurrentCategoriesType = 0; |
1073 | return ALCATEL_GetAvailableCategoryIds(s); | 1073 | return ALCATEL_GetAvailableCategoryIds(s); |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1076 | static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1077 | { | 1077 | { |
1078 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 1078 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
1079 | int len; | 1079 | int len; |
1080 | 1080 | ||
1081 | len = msg.Buffer[14]; | 1081 | len = msg.Buffer[14]; |
1082 | if (len > GSM_MAX_CATEGORY_NAME_LENGTH) { | 1082 | if (len > GSM_MAX_CATEGORY_NAME_LENGTH) { |
1083 | 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); |
1084 | } | 1084 | } |
1085 | if (Priv->ProtocolVersion == V_1_0) { | 1085 | if (Priv->ProtocolVersion == V_1_0) { |
1086 | 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); |
1087 | } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) { | 1087 | } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) { |
1088 | memcpy(Priv->ReturnString, msg.Buffer + 16, len); | 1088 | memcpy(Priv->ReturnString, msg.Buffer + 16, len); |
1089 | Priv->ReturnString[len + 1] = 0; | 1089 | Priv->ReturnString[len + 1] = 0; |
1090 | Priv->ReturnString[len + 2] = 0; | 1090 | Priv->ReturnString[len + 2] = 0; |
1091 | ReverseUnicodeString(Priv->ReturnString); | 1091 | ReverseUnicodeString(Priv->ReturnString); |
1092 | } else { | 1092 | } else { |
1093 | 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); |
1094 | } | 1094 | } |
1095 | return ERR_NONE; | 1095 | return ERR_NONE; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { | 1098 | static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { |
1099 | 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*/ }; |
1100 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1100 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1101 | GSM_Error error; | 1101 | GSM_Error error; |
1102 | 1102 | ||
1103 | if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { | 1103 | if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { |
1104 | CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); | 1104 | CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); |
1105 | return ERR_NONE; | 1105 | return ERR_NONE; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | smprintf(s,"Reading category %d\n", id); | 1108 | smprintf(s,"Reading category %d\n", id); |
1109 | 1109 | ||
1110 | switch (Priv->BinaryType) { | 1110 | switch (Priv->BinaryType) { |
1111 | case TypeContacts: | 1111 | case TypeContacts: |
1112 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1112 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1113 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; | 1113 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; |
1114 | break; | 1114 | break; |
1115 | case TypeToDo: | 1115 | case TypeToDo: |
1116 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1116 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1117 | buffer[4] = ALCATEL_LIST_TODO_CAT; | 1117 | buffer[4] = ALCATEL_LIST_TODO_CAT; |
1118 | break; | 1118 | break; |
1119 | default: | 1119 | default: |
1120 | return ERR_NOTSUPPORTED; | 1120 | return ERR_NOTSUPPORTED; |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | buffer[7] = (id & 0xff); | 1123 | buffer[7] = (id & 0xff); |
1124 | 1124 | ||
1125 | error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); | 1125 | error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); |
1126 | if (error != ERR_NONE) return error; | 1126 | if (error != ERR_NONE) return error; |
1127 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); | 1127 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); |
1128 | if (error != ERR_NONE) return error; | 1128 | if (error != ERR_NONE) return error; |
1129 | 1129 | ||
1130 | CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); | 1130 | CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); |
1131 | 1131 | ||
1132 | return ERR_NONE; | 1132 | return ERR_NONE; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { | 1135 | static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { |
1136 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1136 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1137 | GSM_Error error; | 1137 | GSM_Error error; |
1138 | unsigned char buffer[] = | 1138 | unsigned char buffer[] = |
1139 | {0x00, 0x04, | 1139 | {0x00, 0x04, |
1140 | 0x00, /* type */ | 1140 | 0x00, /* type */ |
1141 | 0x26, 0x01, | 1141 | 0x26, 0x01, |
1142 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ | 1142 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ |
1143 | 0x65, 0x01, | 1143 | 0x65, 0x01, |
1144 | 0x00, /* field */ | 1144 | 0x00, /* field */ |
1145 | 0x01}; | 1145 | 0x01}; |
1146 | 1146 | ||
1147 | smprintf(s,"Deleting field (%08x.%02x)\n", id, field); | 1147 | smprintf(s,"Deleting field (%08x.%02x)\n", id, field); |
1148 | 1148 | ||
1149 | switch (Priv->BinaryType) { | 1149 | switch (Priv->BinaryType) { |
1150 | case TypeCalendar: | 1150 | case TypeCalendar: |
1151 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1151 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1152 | break; | 1152 | break; |
1153 | case TypeContacts: | 1153 | case TypeContacts: |
1154 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1154 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1155 | break; | 1155 | break; |
1156 | case TypeToDo: | 1156 | case TypeToDo: |
1157 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1157 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1158 | break; | 1158 | break; |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | buffer[5] = (id >> 24); | 1161 | buffer[5] = (id >> 24); |
1162 | buffer[6] = ((id >> 16) & 0xff); | 1162 | buffer[6] = ((id >> 16) & 0xff); |
1163 | buffer[7] = ((id >> 8) & 0xff); | 1163 | buffer[7] = ((id >> 8) & 0xff); |
1164 | buffer[8] = (id & 0xff); | 1164 | buffer[8] = (id & 0xff); |
1165 | buffer[11] = (field & 0xff); | 1165 | buffer[11] = (field & 0xff); |
1166 | 1166 | ||
1167 | error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField); | 1167 | error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField); |
1168 | if (error != ERR_NONE) return error; | 1168 | if (error != ERR_NONE) return error; |
1169 | 1169 | ||
1170 | return ERR_NONE; | 1170 | return ERR_NONE; |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) { | 1173 | static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) { |
1174 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1174 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1175 | GSM_Error error; | 1175 | GSM_Error error; |
1176 | unsigned char buffer[] = | 1176 | unsigned char buffer[] = |
1177 | {0x00, 0x04, | 1177 | {0x00, 0x04, |
1178 | 0x00, /* type */ | 1178 | 0x00, /* type */ |
1179 | 0x27, 0x01, | 1179 | 0x27, 0x01, |
1180 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ | 1180 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ |
1181 | 0x42}; | 1181 | 0x42}; |
1182 | 1182 | ||
1183 | smprintf(s,"Deleting item (%08x)\n", id); | 1183 | smprintf(s,"Deleting item (%08x)\n", id); |
1184 | 1184 | ||
1185 | switch (Priv->BinaryType) { | 1185 | switch (Priv->BinaryType) { |
1186 | case TypeCalendar: | 1186 | case TypeCalendar: |
1187 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1187 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1188 | break; | 1188 | break; |
1189 | case TypeContacts: | 1189 | case TypeContacts: |
1190 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1190 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1191 | break; | 1191 | break; |
1192 | case TypeToDo: | 1192 | case TypeToDo: |
1193 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1193 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1194 | break; | 1194 | break; |
1195 | } | 1195 | } |
1196 | 1196 | ||
1197 | buffer[5] = (id >> 24); | 1197 | buffer[5] = (id >> 24); |
1198 | buffer[6] = ((id >> 16) & 0xff); | 1198 | buffer[6] = ((id >> 16) & 0xff); |
1199 | buffer[7] = ((id >> 8) & 0xff); | 1199 | buffer[7] = ((id >> 8) & 0xff); |
1200 | buffer[8] = (id & 0xff); | 1200 | buffer[8] = (id & 0xff); |
1201 | 1201 | ||
1202 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1); | 1202 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1); |
1203 | if (error != ERR_NONE) return error; | 1203 | if (error != ERR_NONE) return error; |
1204 | 1204 | ||
1205 | error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2); | 1205 | error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2); |
1206 | if (error != ERR_NONE) return error; | 1206 | if (error != ERR_NONE) return error; |
1207 | 1207 | ||
1208 | return ERR_NONE; | 1208 | return ERR_NONE; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1211 | static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1212 | { | 1212 | { |
1213 | if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; | 1213 | if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; |
1214 | return ERR_NONE; | 1214 | return ERR_NONE; |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { | 1217 | static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { |
1218 | int len; | 1218 | int len; |
1219 | 1219 | ||
1220 | buffer[1] = field & 0xff; | 1220 | buffer[1] = field & 0xff; |
1221 | 1221 | ||
1222 | switch(type) { | 1222 | switch(type) { |
1223 | case Alcatel_date: | 1223 | case Alcatel_date: |
1224 | if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; | 1224 | if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; |
1225 | 1225 | ||
1226 | buffer[3] = 0x05; | 1226 | buffer[3] = 0x05; |
1227 | buffer[4] = 0x67; | 1227 | buffer[4] = 0x67; |
1228 | 1228 | ||
1229 | buffer[0] = 0x09; | 1229 | buffer[0] = 0x09; |
1230 | buffer[5] = 0x04; | 1230 | buffer[5] = 0x04; |
1231 | buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; | 1231 | buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; |
1232 | buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; | 1232 | buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; |
1233 | buffer[8] = ((GSM_DateTime *)data)->Year >> 8; | 1233 | buffer[8] = ((GSM_DateTime *)data)->Year >> 8; |
1234 | buffer[9] = ((GSM_DateTime *)data)->Year & 0xff; | 1234 | buffer[9] = ((GSM_DateTime *)data)->Year & 0xff; |
1235 | buffer[10] = 0x00; | 1235 | buffer[10] = 0x00; |
1236 | break; | 1236 | break; |
1237 | case Alcatel_time: | 1237 | case Alcatel_time: |
1238 | if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; | 1238 | if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; |
1239 | 1239 | ||
1240 | buffer[3] = 0x06; | 1240 | buffer[3] = 0x06; |
1241 | buffer[4] = 0x68; | 1241 | buffer[4] = 0x68; |
1242 | 1242 | ||
1243 | buffer[0] = 0x08; | 1243 | buffer[0] = 0x08; |
1244 | buffer[5] = 0x03; | 1244 | buffer[5] = 0x03; |
1245 | buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff; | 1245 | buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff; |
1246 | buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff; | 1246 | buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff; |
1247 | buffer[8] = ((GSM_DateTime *)data)->Second & 0xff; | 1247 | buffer[8] = ((GSM_DateTime *)data)->Second & 0xff; |
1248 | buffer[9] = 0x00; | 1248 | buffer[9] = 0x00; |
1249 | break; | 1249 | break; |
1250 | case Alcatel_string: | 1250 | case Alcatel_string: |
1251 | buffer[3] = 0x08; | 1251 | buffer[3] = 0x08; |
1252 | buffer[4] = 0x3c; | 1252 | buffer[4] = 0x3c; |
1253 | 1253 | ||
1254 | len = MIN(UnicodeLength((char *)data),62); | 1254 | len = MIN(UnicodeLength((char *)data),62); |
1255 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); | 1255 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); |
1256 | buffer[5] = len; | 1256 | buffer[5] = len; |
1257 | buffer[0] = 5 + len; | 1257 | buffer[0] = 5 + len; |
1258 | buffer[6 + len] = 0x00; | 1258 | buffer[6 + len] = 0x00; |
1259 | break; | 1259 | break; |
1260 | case Alcatel_phone: | 1260 | case Alcatel_phone: |
1261 | buffer[3] = 0x07; | 1261 | buffer[3] = 0x07; |
1262 | buffer[4] = 0x3c; | 1262 | buffer[4] = 0x3c; |
1263 | 1263 | ||
1264 | len = MIN(UnicodeLength((char *)data),50); | 1264 | len = MIN(UnicodeLength((char *)data),50); |
1265 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); | 1265 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); |
1266 | buffer[5] = len; | 1266 | buffer[5] = len; |
1267 | buffer[0] = 5 + len; | 1267 | buffer[0] = 5 + len; |
1268 | buffer[6 + len] = 0x00; | 1268 | buffer[6 + len] = 0x00; |
1269 | break; | 1269 | break; |
1270 | case Alcatel_enum: | 1270 | case Alcatel_enum: |
1271 | buffer[3] = 0x04; | 1271 | buffer[3] = 0x04; |
1272 | buffer[4] = 0x38; | 1272 | buffer[4] = 0x38; |
1273 | 1273 | ||
1274 | buffer[0] = 0x05; | 1274 | buffer[0] = 0x05; |
1275 | buffer[5] = *(int *)data & 0xff; | 1275 | buffer[5] = *(int *)data & 0xff; |
1276 | buffer[6] = 0x00; | 1276 | buffer[6] = 0x00; |
1277 | break; | 1277 | break; |
1278 | case Alcatel_bool: | 1278 | case Alcatel_bool: |
1279 | buffer[3] = 0x03; | 1279 | buffer[3] = 0x03; |
1280 | buffer[4] = 0x3b; | 1280 | buffer[4] = 0x3b; |
1281 | 1281 | ||
1282 | buffer[0] = 0x05; | 1282 | buffer[0] = 0x05; |
1283 | buffer[5] = *(int *)data & 0xff; | 1283 | buffer[5] = *(int *)data & 0xff; |
1284 | buffer[6] = 0x00; | 1284 | buffer[6] = 0x00; |
1285 | break; | 1285 | break; |
1286 | case Alcatel_int: | 1286 | case Alcatel_int: |
1287 | buffer[3] = 0x02; | 1287 | buffer[3] = 0x02; |
1288 | buffer[4] = 0x3a; | 1288 | buffer[4] = 0x3a; |
1289 | 1289 | ||
1290 | buffer[0] = 0x08; | 1290 | buffer[0] = 0x08; |
1291 | buffer[5] = *(unsigned int *)data >> 24; | 1291 | buffer[5] = *(unsigned int *)data >> 24; |
1292 | buffer[6] = (*(unsigned int *)data >> 16) & 0xff; | 1292 | buffer[6] = (*(unsigned int *)data >> 16) & 0xff; |
1293 | buffer[7] = (*(unsigned int *)data >> 8) & 0xff; | 1293 | buffer[7] = (*(unsigned int *)data >> 8) & 0xff; |
1294 | buffer[8] = *(unsigned int *)data & 0xff; | 1294 | buffer[8] = *(unsigned int *)data & 0xff; |
1295 | buffer[9] = 0x00; | 1295 | buffer[9] = 0x00; |
1296 | break; | 1296 | break; |
1297 | case Alcatel_byte: | 1297 | case Alcatel_byte: |
1298 | buffer[3] = 0x00; | 1298 | buffer[3] = 0x00; |
1299 | buffer[4] = 0x38; | 1299 | buffer[4] = 0x38; |
1300 | 1300 | ||
1301 | buffer[0] = 0x05; | 1301 | buffer[0] = 0x05; |
1302 | buffer[5] = *(int *)data & 0xff; | 1302 | buffer[5] = *(int *)data & 0xff; |
1303 | buffer[6] = 0x00; | 1303 | buffer[6] = 0x00; |
1304 | break; | 1304 | break; |
1305 | } | 1305 | } |
1306 | return ERR_NONE; | 1306 | return ERR_NONE; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) { | 1309 | static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) { |
1310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1311 | GSM_Error error; | 1311 | GSM_Error error; |
1312 | unsigned char buffer[200] = | 1312 | unsigned char buffer[200] = |
1313 | {0x00, 0x04, | 1313 | {0x00, 0x04, |
1314 | 0x00, /* type */ | 1314 | 0x00, /* type */ |
1315 | 0x25, 0x01, 0x65, | 1315 | 0x25, 0x01, 0x65, |
1316 | 0x00, /* length of remaining part */ | 1316 | 0x00, /* length of remaining part */ |
1317 | 0x00, /* field */ | 1317 | 0x00, /* field */ |
1318 | 0x37}; /* data follows here */ | 1318 | 0x37}; /* data follows here */ |
1319 | 1319 | ||
1320 | smprintf(s,"Creating field (%02x)\n", field); | 1320 | smprintf(s,"Creating field (%02x)\n", field); |
1321 | 1321 | ||
1322 | switch (Priv->BinaryType) { | 1322 | switch (Priv->BinaryType) { |
1323 | case TypeCalendar: | 1323 | case TypeCalendar: |
1324 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1324 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1325 | break; | 1325 | break; |
1326 | case TypeContacts: | 1326 | case TypeContacts: |
1327 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1327 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1328 | break; | 1328 | break; |
1329 | case TypeToDo: | 1329 | case TypeToDo: |
1330 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1330 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1331 | break; | 1331 | break; |
1332 | } | 1332 | } |
1333 | error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); | 1333 | error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); |
1334 | if (error != ERR_NONE) return error; | 1334 | if (error != ERR_NONE) return error; |
1335 | 1335 | ||
1336 | 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); |
1337 | if (error != ERR_NONE) return error; | 1337 | if (error != ERR_NONE) return error; |
1338 | 1338 | ||
1339 | return ERR_NONE; | 1339 | return ERR_NONE; |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { | 1342 | static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { |
1343 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1343 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1344 | GSM_Error error; | 1344 | GSM_Error error; |
1345 | unsigned char buffer[200] = | 1345 | unsigned char buffer[200] = |
1346 | {0x00, 0x04, | 1346 | {0x00, 0x04, |
1347 | 0x00, /* type */ | 1347 | 0x00, /* type */ |
1348 | 0x26, 0x01, | 1348 | 0x26, 0x01, |
1349 | 0x00, 0x00, 0x00, 0x00,/* id */ | 1349 | 0x00, 0x00, 0x00, 0x00,/* id */ |
1350 | 0x65, | 1350 | 0x65, |
1351 | 0x00, /* length of remaining part */ | 1351 | 0x00, /* length of remaining part */ |
1352 | 0x00, /* field */ | 1352 | 0x00, /* field */ |
1353 | 0x37}; /* data follows here */ | 1353 | 0x37}; /* data follows here */ |
1354 | 1354 | ||
1355 | smprintf(s,"Updating field (%08x.%02x)\n", id, field); | 1355 | smprintf(s,"Updating field (%08x.%02x)\n", id, field); |
1356 | 1356 | ||
1357 | buffer[5] = (id >> 24); | 1357 | buffer[5] = (id >> 24); |
1358 | buffer[6] = ((id >> 16) & 0xff); | 1358 | buffer[6] = ((id >> 16) & 0xff); |
1359 | buffer[7] = ((id >> 8) & 0xff); | 1359 | buffer[7] = ((id >> 8) & 0xff); |
1360 | buffer[8] = (id & 0xff); | 1360 | buffer[8] = (id & 0xff); |
1361 | 1361 | ||
1362 | switch (Priv->BinaryType) { | 1362 | switch (Priv->BinaryType) { |
1363 | case TypeCalendar: | 1363 | case TypeCalendar: |
1364 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1364 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1365 | break; | 1365 | break; |
1366 | case TypeContacts: | 1366 | case TypeContacts: |
1367 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1367 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1368 | break; | 1368 | break; |
1369 | case TypeToDo: | 1369 | case TypeToDo: |
1370 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1370 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1371 | break; | 1371 | break; |
1372 | } | 1372 | } |
1373 | error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); | 1373 | error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); |
1374 | if (error != ERR_NONE) return error; | 1374 | if (error != ERR_NONE) return error; |
1375 | 1375 | ||
1376 | 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); |
1377 | if (error != ERR_NONE) return error; | 1377 | if (error != ERR_NONE) return error; |
1378 | 1378 | ||
1379 | return ERR_NONE; | 1379 | return ERR_NONE; |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) | 1382 | static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) |
1383 | { | 1383 | { |
1384 | strcpy(s->Phone.Data.Manufacturer, "Alcatel"); | 1384 | strcpy(s->Phone.Data.Manufacturer, "Alcatel"); |
1385 | return ERR_NONE; | 1385 | return ERR_NONE; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) | 1388 | static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) |
1389 | { | 1389 | { |
1390 | GSM_Error error; | 1390 | GSM_Error error; |
1391 | 1391 | ||
1392 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1392 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1393 | return ATGEN_GetIMEI(s); | 1393 | return ATGEN_GetIMEI(s); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s) | 1396 | static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s) |
1397 | { | 1397 | { |
1398 | GSM_Error error; | 1398 | GSM_Error error; |
1399 | 1399 | ||
1400 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1400 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1401 | return ATGEN_GetFirmware(s); | 1401 | return ATGEN_GetFirmware(s); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s) | 1404 | static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s) |
1405 | { | 1405 | { |
1406 | GSM_Error error; | 1406 | GSM_Error error; |
1407 | 1407 | ||
1408 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1408 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1409 | return ATGEN_GetModel(s); | 1409 | return ATGEN_GetModel(s); |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) | 1412 | static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) |
1413 | { | 1413 | { |
1414 | GSM_Error error; | 1414 | GSM_Error error; |
1415 | 1415 | ||
1416 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1416 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1417 | return ATGEN_GetDateTime(s, date_time); | 1417 | return ATGEN_GetDateTime(s, date_time); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1420 | static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1421 | { | 1421 | { |
1422 | GSM_Error error; | 1422 | GSM_Error error; |
1423 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1423 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1424 | int i; | 1424 | int i; |
1425 | int j = 0; | 1425 | int j = 0; |
1426 | 1426 | ||
1427 | if (entry->MemoryType == MEM_ME) { | 1427 | if (entry->MemoryType == MEM_ME) { |
1428 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 1428 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
1429 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 1429 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
1430 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { | 1430 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { |
1431 | entry->EntriesNum = 0; | 1431 | entry->EntriesNum = 0; |
1432 | return error; | 1432 | return error; |
1433 | } | 1433 | } |
1434 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; | 1434 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; |
1435 | 1435 | ||
1436 | entry->EntriesNum = Priv->CurrentFieldsCount; | 1436 | entry->EntriesNum = Priv->CurrentFieldsCount; |
1437 | 1437 | ||
1438 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 1438 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
1439 | if ((error = ALCATEL_GetFieldValue(s, entry->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; | 1439 | if ((error = ALCATEL_GetFieldValue(s, entry->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; |
1440 | entry->Entries[i].VoiceTag = 0; | 1440 | entry->Entries[i].VoiceTag = 0; |
1441 | entry->Entries[i].SMSList[0] = 0; | 1441 | entry->Entries[i].SMSList[0] = 0; |
1442 | switch (Priv->CurrentFields[i]) { | 1442 | switch (Priv->CurrentFields[i]) { |
1443 | case 0: | 1443 | case 0: |
1444 | if (Priv->ReturnType != Alcatel_string) { | 1444 | if (Priv->ReturnType != Alcatel_string) { |
1445 | smprintf(s,"WARNING: Received unexpected type %02X for field 0, ignoring\n", Priv->ReturnType); | 1445 | smprintf(s,"WARNING: Received unexpected type %02X for field 0, ignoring\n", Priv->ReturnType); |
1446 | entry->EntriesNum--; | 1446 | entry->EntriesNum--; |
1447 | j++; | 1447 | j++; |
1448 | break; | 1448 | break; |
1449 | } | 1449 | } |
1450 | entry->Entries[i - j].EntryType = PBK_Text_LastName; | 1450 | entry->Entries[i - j].EntryType = PBK_Text_LastName; |
1451 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1451 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1452 | break; | 1452 | break; |
1453 | case 1: | 1453 | case 1: |
1454 | if (Priv->ReturnType != Alcatel_string) { | 1454 | if (Priv->ReturnType != Alcatel_string) { |
1455 | smprintf(s,"WARNING: Received unexpected type %02X for field 1, ignoring\n", Priv->ReturnType); | 1455 | smprintf(s,"WARNING: Received unexpected type %02X for field 1, ignoring\n", Priv->ReturnType); |
1456 | entry->EntriesNum--; | 1456 | entry->EntriesNum--; |
1457 | j++; | 1457 | j++; |
1458 | break; | 1458 | break; |
1459 | } | 1459 | } |
1460 | entry->Entries[i - j].EntryType = PBK_Text_FirstName; | 1460 | entry->Entries[i - j].EntryType = PBK_Text_FirstName; |
1461 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1461 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1462 | break; | 1462 | break; |
1463 | case 2: | 1463 | case 2: |
1464 | if (Priv->ReturnType != Alcatel_string) { | 1464 | if (Priv->ReturnType != Alcatel_string) { |
1465 | smprintf(s,"WARNING: Received unexpected type %02X for field 2, ignoring\n", Priv->ReturnType); | 1465 | smprintf(s,"WARNING: Received unexpected type %02X for field 2, ignoring\n", Priv->ReturnType); |
1466 | entry->EntriesNum--; | 1466 | entry->EntriesNum--; |
1467 | j++; | 1467 | j++; |
1468 | break; | 1468 | break; |
1469 | } | 1469 | } |
1470 | entry->Entries[i - j].EntryType = PBK_Text_Company; | 1470 | entry->Entries[i - j].EntryType = PBK_Text_Company; |
1471 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1471 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1472 | break; | 1472 | break; |
1473 | case 3: | 1473 | case 3: |
1474 | if (Priv->ReturnType != Alcatel_string) { | 1474 | if (Priv->ReturnType != Alcatel_string) { |
1475 | smprintf(s,"WARNING: Received unexpected type %02X for field 3, ignoring\n", Priv->ReturnType); | 1475 | smprintf(s,"WARNING: Received unexpected type %02X for field 3, ignoring\n", Priv->ReturnType); |
1476 | entry->EntriesNum--; | 1476 | entry->EntriesNum--; |
1477 | j++; | 1477 | j++; |
1478 | break; | 1478 | break; |
1479 | } | 1479 | } |
1480 | entry->Entries[i - j].EntryType = PBK_Text_JobTitle; | 1480 | entry->Entries[i - j].EntryType = PBK_Text_JobTitle; |
1481 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1481 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1482 | break; | 1482 | break; |
1483 | case 4: | 1483 | case 4: |
1484 | if (Priv->ReturnType != Alcatel_string) { | 1484 | if (Priv->ReturnType != Alcatel_string) { |
1485 | smprintf(s,"WARNING: Received unexpected type %02X for field 4, ignoring\n", Priv->ReturnType); | 1485 | smprintf(s,"WARNING: Received unexpected type %02X for field 4, ignoring\n", Priv->ReturnType); |
1486 | entry->EntriesNum--; | 1486 | entry->EntriesNum--; |
1487 | j++; | 1487 | j++; |
1488 | break; | 1488 | break; |
1489 | } | 1489 | } |
1490 | entry->Entries[i - j].EntryType = PBK_Text_Note; | 1490 | entry->Entries[i - j].EntryType = PBK_Text_Note; |
1491 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1491 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1492 | break; | 1492 | break; |
1493 | case 5: | 1493 | case 5: |
1494 | if (Priv->ReturnType != Alcatel_byte) { | 1494 | if (Priv->ReturnType != Alcatel_byte) { |
1495 | smprintf(s,"WARNING: Received unexpected type %02X for field 5, ignoring\n", Priv->ReturnType); | 1495 | smprintf(s,"WARNING: Received unexpected type %02X for field 5, ignoring\n", Priv->ReturnType); |
1496 | entry->EntriesNum--; | 1496 | entry->EntriesNum--; |
1497 | j++; | 1497 | j++; |
1498 | break; | 1498 | break; |
1499 | } | 1499 | } |
1500 | entry->Entries[i - j].EntryType = PBK_Category; | 1500 | entry->Entries[i - j].EntryType = PBK_Category; |
1501 | entry->Entries[i - j].Number = Priv->ReturnInt; | 1501 | entry->Entries[i - j].Number = Priv->ReturnInt; |
1502 | break; | 1502 | break; |
1503 | case 6: | 1503 | case 6: |
1504 | if (Priv->ReturnType != Alcatel_bool) { | 1504 | if (Priv->ReturnType != Alcatel_bool) { |
1505 | smprintf(s,"WARNING: Received unexpected type %02X for field 6, ignoring\n", Priv->ReturnType); | 1505 | smprintf(s,"WARNING: Received unexpected type %02X for field 6, ignoring\n", Priv->ReturnType); |
1506 | entry->EntriesNum--; | 1506 | entry->EntriesNum--; |
1507 | j++; | 1507 | j++; |
1508 | break; | 1508 | break; |
1509 | } | 1509 | } |
1510 | entry->Entries[i - j].EntryType = PBK_Private; | 1510 | entry->Entries[i - j].EntryType = PBK_Private; |
1511 | entry->Entries[i - j].Number = Priv->ReturnInt; | 1511 | entry->Entries[i - j].Number = Priv->ReturnInt; |
1512 | break; | 1512 | break; |
1513 | case 7: | 1513 | case 7: |
1514 | if (Priv->ReturnType != Alcatel_phone) { | 1514 | if (Priv->ReturnType != Alcatel_phone) { |
1515 | smprintf(s,"WARNING: Received unexpected type %02X for field 7, ignoring\n", Priv->ReturnType); | 1515 | smprintf(s,"WARNING: Received unexpected type %02X for field 7, ignoring\n", Priv->ReturnType); |
1516 | entry->EntriesNum--; | 1516 | entry->EntriesNum--; |
1517 | j++; | 1517 | j++; |
1518 | break; | 1518 | break; |
1519 | } | 1519 | } |
1520 | entry->Entries[i - j].EntryType = PBK_Number_Work; | 1520 | entry->Entries[i - j].EntryType = PBK_Number_Work; |
1521 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1521 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1522 | break; | 1522 | break; |
1523 | case 8: | 1523 | case 8: |
1524 | if (Priv->ReturnType != Alcatel_phone) { | 1524 | if (Priv->ReturnType != Alcatel_phone) { |
1525 | smprintf(s,"WARNING: Received unexpected type %02X for field 8, ignoring\n", Priv->ReturnType); | 1525 | smprintf(s,"WARNING: Received unexpected type %02X for field 8, ignoring\n", Priv->ReturnType); |
1526 | entry->EntriesNum--; | 1526 | entry->EntriesNum--; |
1527 | j++; | 1527 | j++; |
1528 | break; | 1528 | break; |
1529 | } | 1529 | } |
1530 | entry->Entries[i - j].EntryType = PBK_Number_General; | 1530 | entry->Entries[i - j].EntryType = PBK_Number_General; |
1531 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1531 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1532 | break; | 1532 | break; |
1533 | case 9: | 1533 | case 9: |
1534 | if (Priv->ReturnType != Alcatel_phone) { | 1534 | if (Priv->ReturnType != Alcatel_phone) { |
1535 | smprintf(s,"WARNING: Received unexpected type %02X for field 9, ignoring\n", Priv->ReturnType); | 1535 | smprintf(s,"WARNING: Received unexpected type %02X for field 9, ignoring\n", Priv->ReturnType); |
1536 | entry->EntriesNum--; | 1536 | entry->EntriesNum--; |
1537 | j++; | 1537 | j++; |
1538 | break; | 1538 | break; |
1539 | } | 1539 | } |
1540 | entry->Entries[i - j].EntryType = PBK_Number_Fax; | 1540 | entry->Entries[i - j].EntryType = PBK_Number_Fax; |
1541 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1541 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1542 | break; | 1542 | break; |
1543 | case 10: | 1543 | case 10: |
1544 | if (Priv->ReturnType != Alcatel_phone) { | 1544 | if (Priv->ReturnType != Alcatel_phone) { |
1545 | smprintf(s,"WARNING: Received unexpected type %02X for field 10, ignoring\n", Priv->ReturnType); | 1545 | smprintf(s,"WARNING: Received unexpected type %02X for field 10, ignoring\n", Priv->ReturnType); |
1546 | entry->EntriesNum--; | 1546 | entry->EntriesNum--; |
1547 | j++; | 1547 | j++; |
1548 | break; | 1548 | break; |
1549 | } | 1549 | } |
1550 | entry->Entries[i - j].EntryType = PBK_Number_Other; | 1550 | entry->Entries[i - j].EntryType = PBK_Number_Other; |
1551 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1551 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1552 | break; | 1552 | break; |
1553 | case 11: | 1553 | case 11: |
1554 | if (Priv->ReturnType != Alcatel_phone) { | 1554 | if (Priv->ReturnType != Alcatel_phone) { |
1555 | smprintf(s,"WARNING: Received unexpected type %02X for field 11, ignoring\n", Priv->ReturnType); | 1555 | smprintf(s,"WARNING: Received unexpected type %02X for field 11, ignoring\n", Priv->ReturnType); |
1556 | entry->EntriesNum--; | 1556 | entry->EntriesNum--; |
1557 | j++; | 1557 | j++; |
1558 | break; | 1558 | break; |
1559 | } | 1559 | } |
1560 | entry->Entries[i - j].EntryType = PBK_Number_Pager; | 1560 | entry->Entries[i - j].EntryType = PBK_Number_Pager; |
1561 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1561 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1562 | break; | 1562 | break; |
1563 | case 12: | 1563 | case 12: |
1564 | if (Priv->ReturnType != Alcatel_phone) { | 1564 | if (Priv->ReturnType != Alcatel_phone) { |
1565 | smprintf(s,"WARNING: Received unexpected type %02X for field 12, ignoring\n", Priv->ReturnType); | 1565 | smprintf(s,"WARNING: Received unexpected type %02X for field 12, ignoring\n", Priv->ReturnType); |
1566 | entry->EntriesNum--; | 1566 | entry->EntriesNum--; |
1567 | j++; | 1567 | j++; |
1568 | break; | 1568 | break; |
1569 | } | 1569 | } |
1570 | entry->Entries[i - j].EntryType = PBK_Number_Mobile; | 1570 | entry->Entries[i - j].EntryType = PBK_Number_Mobile; |
1571 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1571 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1572 | break; | 1572 | break; |
1573 | case 13: | 1573 | case 13: |
1574 | if (Priv->ReturnType != Alcatel_phone) { | 1574 | if (Priv->ReturnType != Alcatel_phone) { |
1575 | smprintf(s,"WARNING: Received unexpected type %02X for field 13, ignoring\n", Priv->ReturnType); | 1575 | smprintf(s,"WARNING: Received unexpected type %02X for field 13, ignoring\n", Priv->ReturnType); |
1576 | entry->EntriesNum--; | 1576 | entry->EntriesNum--; |
1577 | j++; | 1577 | j++; |
1578 | break; | 1578 | break; |
1579 | } | 1579 | } |
1580 | entry->Entries[i - j].EntryType = PBK_Number_Home; | 1580 | entry->Entries[i - j].EntryType = PBK_Number_Home; |
1581 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1581 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1582 | break; | 1582 | break; |
1583 | case 14: | 1583 | case 14: |
1584 | if (Priv->ReturnType != Alcatel_string) { | 1584 | if (Priv->ReturnType != Alcatel_string) { |
1585 | smprintf(s,"WARNING: Received unexpected type %02X for field 14, ignoring\n", Priv->ReturnType); | 1585 | smprintf(s,"WARNING: Received unexpected type %02X for field 14, ignoring\n", Priv->ReturnType); |
1586 | entry->EntriesNum--; | 1586 | entry->EntriesNum--; |
1587 | j++; | 1587 | j++; |
1588 | break; | 1588 | break; |
1589 | } | 1589 | } |
1590 | entry->Entries[i - j].EntryType = PBK_Text_Email; | 1590 | entry->Entries[i - j].EntryType = PBK_Text_Email; |
1591 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1591 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1592 | break; | 1592 | break; |
1593 | case 15: | 1593 | case 15: |
1594 | if (Priv->ReturnType != Alcatel_string) { | 1594 | if (Priv->ReturnType != Alcatel_string) { |
1595 | smprintf(s,"WARNING: Received unexpected type %02X for field 15, ignoring\n", Priv->ReturnType); | 1595 | smprintf(s,"WARNING: Received unexpected type %02X for field 15, ignoring\n", Priv->ReturnType); |
1596 | entry->EntriesNum--; | 1596 | entry->EntriesNum--; |
1597 | j++; | 1597 | j++; |
1598 | break; | 1598 | break; |
1599 | } | 1599 | } |
1600 | entry->Entries[i - j].EntryType = PBK_Text_Email2; | 1600 | entry->Entries[i - j].EntryType = PBK_Text_Email2; |
1601 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1601 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1602 | break; | 1602 | break; |
1603 | case 16: | 1603 | case 16: |
1604 | if (Priv->ReturnType != Alcatel_string) { | 1604 | if (Priv->ReturnType != Alcatel_string) { |
1605 | smprintf(s,"WARNING: Received unexpected type %02X for field 16, ignoring\n", Priv->ReturnType); | 1605 | smprintf(s,"WARNING: Received unexpected type %02X for field 16, ignoring\n", Priv->ReturnType); |
1606 | entry->EntriesNum--; | 1606 | entry->EntriesNum--; |
1607 | j++; | 1607 | j++; |
1608 | break; | 1608 | break; |
1609 | } | 1609 | } |
1610 | entry->Entries[i - j].EntryType = PBK_Text_StreetAddress; | 1610 | entry->Entries[i - j].EntryType = PBK_Text_StreetAddress; |
1611 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1611 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1612 | break; | 1612 | break; |
1613 | case 17: | 1613 | case 17: |
1614 | if (Priv->ReturnType != Alcatel_string) { | 1614 | if (Priv->ReturnType != Alcatel_string) { |
1615 | smprintf(s,"WARNING: Received unexpected type %02X for field 17, ignoring\n", Priv->ReturnType); | 1615 | smprintf(s,"WARNING: Received unexpected type %02X for field 17, ignoring\n", Priv->ReturnType); |
1616 | entry->EntriesNum--; | 1616 | entry->EntriesNum--; |
1617 | j++; | 1617 | j++; |
1618 | break; | 1618 | break; |
1619 | } | 1619 | } |
1620 | entry->Entries[i - j].EntryType = PBK_Text_City; | 1620 | entry->Entries[i - j].EntryType = PBK_Text_City; |
1621 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1621 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1622 | break; | 1622 | break; |
1623 | case 18: | 1623 | case 18: |
1624 | if (Priv->ReturnType != Alcatel_string) { | 1624 | if (Priv->ReturnType != Alcatel_string) { |
1625 | smprintf(s,"WARNING: Received unexpected type %02X for field 18, ignoring\n", Priv->ReturnType); | 1625 | smprintf(s,"WARNING: Received unexpected type %02X for field 18, ignoring\n", Priv->ReturnType); |
1626 | entry->EntriesNum--; | 1626 | entry->EntriesNum--; |
1627 | j++; | 1627 | j++; |
1628 | break; | 1628 | break; |
1629 | } | 1629 | } |
1630 | entry->Entries[i - j].EntryType = PBK_Text_State; | 1630 | entry->Entries[i - j].EntryType = PBK_Text_State; |
1631 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1631 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1632 | break; | 1632 | break; |
1633 | case 19: | 1633 | case 19: |
1634 | if (Priv->ReturnType != Alcatel_string) { | 1634 | if (Priv->ReturnType != Alcatel_string) { |
1635 | smprintf(s,"WARNING: Received unexpected type %02X for field 19, ignoring\n", Priv->ReturnType); | 1635 | smprintf(s,"WARNING: Received unexpected type %02X for field 19, ignoring\n", Priv->ReturnType); |
1636 | entry->EntriesNum--; | 1636 | entry->EntriesNum--; |
1637 | j++; | 1637 | j++; |
1638 | break; | 1638 | break; |
1639 | } | 1639 | } |
1640 | entry->Entries[i - j].EntryType = PBK_Text_Zip; | 1640 | entry->Entries[i - j].EntryType = PBK_Text_Zip; |
1641 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1641 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1642 | break; | 1642 | break; |
1643 | case 20: | 1643 | case 20: |
1644 | if (Priv->ReturnType != Alcatel_string) { | 1644 | if (Priv->ReturnType != Alcatel_string) { |
1645 | smprintf(s,"WARNING: Received unexpected type %02X for field 20, ignoring\n", Priv->ReturnType); | 1645 | smprintf(s,"WARNING: Received unexpected type %02X for field 20, ignoring\n", Priv->ReturnType); |
1646 | entry->EntriesNum--; | 1646 | entry->EntriesNum--; |
1647 | j++; | 1647 | j++; |
1648 | break; | 1648 | break; |
1649 | } | 1649 | } |
1650 | entry->Entries[i - j].EntryType = PBK_Text_Country; | 1650 | entry->Entries[i - j].EntryType = PBK_Text_Country; |
1651 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1651 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1652 | break; | 1652 | break; |
1653 | case 21: | 1653 | case 21: |
1654 | if (Priv->ReturnType != Alcatel_string) { | 1654 | if (Priv->ReturnType != Alcatel_string) { |
1655 | smprintf(s,"WARNING: Received unexpected type %02X for field 21, ignoring\n", Priv->ReturnType); | 1655 | smprintf(s,"WARNING: Received unexpected type %02X for field 21, ignoring\n", Priv->ReturnType); |
1656 | entry->EntriesNum--; | 1656 | entry->EntriesNum--; |
1657 | j++; | 1657 | j++; |
1658 | break; | 1658 | break; |
1659 | } | 1659 | } |
1660 | entry->Entries[i - j].EntryType = PBK_Text_Custom1; | 1660 | entry->Entries[i - j].EntryType = PBK_Text_Custom1; |
1661 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1661 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1662 | break; | 1662 | break; |
1663 | case 22: | 1663 | case 22: |
1664 | if (Priv->ReturnType != Alcatel_string) { | 1664 | if (Priv->ReturnType != Alcatel_string) { |
1665 | smprintf(s,"WARNING: Received unexpected type %02X for field 22, ignoring\n", Priv->ReturnType); | 1665 | smprintf(s,"WARNING: Received unexpected type %02X for field 22, ignoring\n", Priv->ReturnType); |
1666 | entry->EntriesNum--; | 1666 | entry->EntriesNum--; |
1667 | j++; | 1667 | j++; |
1668 | break; | 1668 | break; |
1669 | } | 1669 | } |
1670 | entry->Entries[i - j].EntryType = PBK_Text_Custom2; | 1670 | entry->Entries[i - j].EntryType = PBK_Text_Custom2; |
1671 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1671 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1672 | break; | 1672 | break; |
1673 | case 23: | 1673 | case 23: |
1674 | if (Priv->ReturnType != Alcatel_string) { | 1674 | if (Priv->ReturnType != Alcatel_string) { |
1675 | smprintf(s,"WARNING: Received unexpected type %02X for field 23, ignoring\n", Priv->ReturnType); | 1675 | smprintf(s,"WARNING: Received unexpected type %02X for field 23, ignoring\n", Priv->ReturnType); |
1676 | entry->EntriesNum--; | 1676 | entry->EntriesNum--; |
1677 | j++; | 1677 | j++; |
1678 | break; | 1678 | break; |
1679 | } | 1679 | } |
1680 | entry->Entries[i - j].EntryType = PBK_Text_Custom3; | 1680 | entry->Entries[i - j].EntryType = PBK_Text_Custom3; |
1681 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1681 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1682 | break; | 1682 | break; |
1683 | case 24: | 1683 | case 24: |
1684 | if (Priv->ReturnType != Alcatel_string) { | 1684 | if (Priv->ReturnType != Alcatel_string) { |
1685 | smprintf(s,"WARNING: Received unexpected type %02X for field 24, ignoring\n", Priv->ReturnType); | 1685 | smprintf(s,"WARNING: Received unexpected type %02X for field 24, ignoring\n", Priv->ReturnType); |
1686 | entry->EntriesNum--; | 1686 | entry->EntriesNum--; |
1687 | j++; | 1687 | j++; |
1688 | break; | 1688 | break; |
1689 | } | 1689 | } |
1690 | entry->Entries[i - j].EntryType = PBK_Text_Custom4; | 1690 | entry->Entries[i - j].EntryType = PBK_Text_Custom4; |
1691 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); | 1691 | CopyUnicodeString(entry->Entries[i - j].Text, Priv->ReturnString); |
1692 | break; | 1692 | break; |
1693 | case 25: | 1693 | case 25: |
1694 | if (Priv->ReturnType != Alcatel_int) { | 1694 | if (Priv->ReturnType != Alcatel_int) { |
1695 | smprintf(s,"WARNING: Received unexpected type %02X for field 25, ignoring\n", Priv->ReturnType); | 1695 | smprintf(s,"WARNING: Received unexpected type %02X for field 25, ignoring\n", Priv->ReturnType); |
1696 | entry->EntriesNum--; | 1696 | entry->EntriesNum--; |
1697 | j++; | 1697 | j++; |
1698 | break; | 1698 | break; |
1699 | } | 1699 | } |
1700 | if (Priv->ReturnInt != 0) { | 1700 | if (Priv->ReturnInt != 0) { |
1701 | entry->Entries[i - j].EntryType = PBK_PictureID; | 1701 | entry->Entries[i - j].EntryType = PBK_PictureID; |
1702 | entry->Entries[i - j].Number = Priv->ReturnInt; | 1702 | entry->Entries[i - j].Number = Priv->ReturnInt; |
1703 | } else { | 1703 | } else { |
1704 | entry->EntriesNum--; | 1704 | entry->EntriesNum--; |
1705 | j++; | 1705 | j++; |
1706 | } | 1706 | } |
1707 | break; | 1707 | break; |
1708 | default: | 1708 | default: |
1709 | entry->EntriesNum--; | 1709 | entry->EntriesNum--; |
1710 | j++; | 1710 | j++; |
1711 | 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); |
1712 | switch (Priv->ReturnType) { | 1712 | switch (Priv->ReturnType) { |
1713 | case Alcatel_date: | 1713 | case Alcatel_date: |
1714 | 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); |
1715 | break; | 1715 | break; |
1716 | case Alcatel_time: | 1716 | case Alcatel_time: |
1717 | 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); |
1718 | break; | 1718 | break; |
1719 | case Alcatel_string: | 1719 | case Alcatel_string: |
1720 | case Alcatel_phone: | 1720 | case Alcatel_phone: |
1721 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 1721 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
1722 | break; | 1722 | break; |
1723 | case Alcatel_enum: | 1723 | case Alcatel_enum: |
1724 | case Alcatel_bool: | 1724 | case Alcatel_bool: |
1725 | case Alcatel_int: | 1725 | case Alcatel_int: |
1726 | case Alcatel_byte: | 1726 | case Alcatel_byte: |
1727 | smprintf(s, "%d", Priv->ReturnInt); | 1727 | smprintf(s, "%d", Priv->ReturnInt); |
1728 | break; | 1728 | break; |
1729 | } | 1729 | } |
1730 | smprintf(s,"\n"); | 1730 | smprintf(s,"\n"); |
1731 | } | 1731 | } |
1732 | } | 1732 | } |
1733 | return ERR_NONE; | 1733 | return ERR_NONE; |
1734 | } else { | 1734 | } else { |
1735 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1735 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1736 | return ATGEN_GetMemory(s, entry); | 1736 | return ATGEN_GetMemory(s, entry); |
1737 | } | 1737 | } |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) | 1740 | static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) |
1741 | { | 1741 | { |
1742 | GSM_Error error; | 1742 | GSM_Error error; |
1743 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1743 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1744 | 1744 | ||
1745 | if (entry->MemoryType == MEM_ME) { | 1745 | if (entry->MemoryType == MEM_ME) { |
1746 | 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; |
1747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 1747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
1748 | if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; | 1748 | if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; |
1749 | 1749 | ||
1750 | if (start) entry->Location = 0; | 1750 | if (start) entry->Location = 0; |
1751 | if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; | 1751 | if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; |
1752 | 1752 | ||
1753 | return ALCATEL_GetMemory(s, entry); | 1753 | return ALCATEL_GetMemory(s, entry); |
1754 | } else { | 1754 | } else { |
1755 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1755 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1756 | return ATGEN_GetNextMemory(s, entry, start); | 1756 | return ATGEN_GetNextMemory(s, entry, start); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1760 | static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1761 | { | 1761 | { |
1762 | GSM_Error error; | 1762 | GSM_Error error; |
1763 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1763 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1764 | int NamePosition = -1; | 1764 | int NamePosition = -1; |
1765 | bool NameSet = false; | 1765 | bool NameSet = false; |
1766 | int i; | 1766 | int i; |
1767 | 1767 | ||
1768 | 1768 | ||
1769 | if (entry->MemoryType == MEM_ME) { | 1769 | if (entry->MemoryType == MEM_ME) { |
1770 | 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; |
1771 | 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; |
1772 | for (i = 0; i < entry->EntriesNum; i++) { | 1772 | for (i = 0; i < entry->EntriesNum; i++) { |
1773 | switch (entry->Entries[i].EntryType) { | 1773 | switch (entry->Entries[i].EntryType) { |
1774 | case PBK_Number_General: | 1774 | case PBK_Number_General: |
1775 | 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; |
1776 | break; | 1776 | break; |
1777 | case PBK_Number_Mobile: | 1777 | case PBK_Number_Mobile: |
1778 | 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; |
1779 | break; | 1779 | break; |
1780 | case PBK_Number_Work: | 1780 | case PBK_Number_Work: |
1781 | 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; |
1782 | break; | 1782 | break; |
1783 | case PBK_Number_Fax: | 1783 | case PBK_Number_Fax: |
1784 | 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; |
1785 | break; | 1785 | break; |
1786 | case PBK_Number_Home: | 1786 | case PBK_Number_Home: |
1787 | 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; |
1788 | break; | 1788 | break; |
1789 | case PBK_Number_Pager: | 1789 | case PBK_Number_Pager: |
1790 | 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; |
1791 | break; | 1791 | break; |
1792 | case PBK_Number_Other: | 1792 | case PBK_Number_Other: |
1793 | 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; |
1794 | break; | 1794 | break; |
1795 | case PBK_Text_Note: | 1795 | case PBK_Text_Note: |
1796 | 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; |
1797 | break; | 1797 | break; |
1798 | case PBK_Text_Email: | 1798 | case PBK_Text_Email: |
1799 | 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; |
1800 | break; | 1800 | break; |
1801 | case PBK_Text_Email2: | 1801 | case PBK_Text_Email2: |
1802 | 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; |
1803 | break; | 1803 | break; |
1804 | case PBK_Text_LastName: | 1804 | case PBK_Text_LastName: |
1805 | 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; |
1806 | NameSet = true; | 1806 | NameSet = true; |
1807 | break; | 1807 | break; |
1808 | case PBK_Text_FirstName: | 1808 | case PBK_Text_FirstName: |
1809 | 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; |
1810 | NameSet = true; | 1810 | NameSet = true; |
1811 | break; | 1811 | break; |
1812 | case PBK_Text_Company: | 1812 | case PBK_Text_Company: |
1813 | 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; |
1814 | break; | 1814 | break; |
1815 | case PBK_Text_JobTitle: | 1815 | case PBK_Text_JobTitle: |
1816 | 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; |
1817 | break; | 1817 | break; |
1818 | case PBK_Category: | 1818 | case PBK_Category: |
1819 | 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; |
1820 | break; | 1820 | break; |
1821 | case PBK_Private: | 1821 | case PBK_Private: |
1822 | 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; |
1823 | break; | 1823 | break; |
1824 | case PBK_Text_StreetAddress: | 1824 | case PBK_Text_StreetAddress: |
1825 | 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; |
1826 | break; | 1826 | break; |
1827 | case PBK_Text_City: | 1827 | case PBK_Text_City: |
1828 | 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; |
1829 | break; | 1829 | break; |
1830 | case PBK_Text_State: | 1830 | case PBK_Text_State: |
1831 | 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; |
1832 | break; | 1832 | break; |
1833 | case PBK_Text_Zip: | 1833 | case PBK_Text_Zip: |
1834 | 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; |
1835 | break; | 1835 | break; |
1836 | case PBK_Text_Country: | 1836 | case PBK_Text_Country: |
1837 | 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; |
1838 | break; | 1838 | break; |
1839 | case PBK_Text_Custom1: | 1839 | case PBK_Text_Custom1: |
1840 | 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; |
1841 | break; | 1841 | break; |
1842 | case PBK_Text_Custom2: | 1842 | case PBK_Text_Custom2: |
1843 | 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; |
1844 | break; | 1844 | break; |
1845 | case PBK_Text_Custom3: | 1845 | case PBK_Text_Custom3: |
1846 | 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; |
1847 | break; | 1847 | break; |
1848 | case PBK_Text_Custom4: | 1848 | case PBK_Text_Custom4: |
1849 | 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; |
1850 | break; | 1850 | break; |
1851 | case PBK_PictureID: | 1851 | case PBK_PictureID: |
1852 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 1852 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
1853 | 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; |
1854 | } else { | 1854 | } else { |
1855 | 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); |
1856 | } | 1856 | } |
1857 | break; | 1857 | break; |
1858 | 1858 | ||
1859 | case PBK_Text_Name: NamePosition = i; break; | 1859 | case PBK_Text_Name: NamePosition = i; break; |
1860 | /* Following fields are not supported: */ | 1860 | /* Following fields are not supported: */ |
1861 | case PBK_Text_UserID: | 1861 | case PBK_Text_UserID: |
1862 | case PBK_SMSListID: | 1862 | case PBK_SMSListID: |
1863 | case PBK_RingtoneFileSystemID: | 1863 | case PBK_RingtoneFileSystemID: |
1864 | case PBK_Date: | 1864 | case PBK_Date: |
1865 | case PBK_Caller_Group: | 1865 | case PBK_Caller_Group: |
1866 | case PBK_RingtoneID: | 1866 | case PBK_RingtoneID: |
1867 | case PBK_Text_Postal: | 1867 | case PBK_Text_Postal: |
1868 | case PBK_Text_URL: | 1868 | case PBK_Text_URL: |
1869 | 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); |
1870 | break; | 1870 | break; |
1871 | } | 1871 | } |
1872 | } | 1872 | } |
1873 | if (NamePosition != -1) { | 1873 | if (NamePosition != -1) { |
1874 | if (NameSet) { | 1874 | if (NameSet) { |
1875 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); | 1875 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); |
1876 | } else { | 1876 | } else { |
1877 | 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; |
1878 | } | 1878 | } |
1879 | } | 1879 | } |
1880 | 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; |
1881 | entry->Location = Priv->CommitedRecord; | 1881 | entry->Location = Priv->CommitedRecord; |
1882 | /* Refresh list */ | 1882 | /* Refresh list */ |
1883 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 1883 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
1884 | return ERR_NONE; | 1884 | return ERR_NONE; |
1885 | } else { | 1885 | } else { |
1886 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1886 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1887 | return ATGEN_AddMemory(s, entry); | 1887 | return ATGEN_AddMemory(s, entry); |
1888 | } | 1888 | } |
1889 | } | 1889 | } |
1890 | 1890 | ||
1891 | static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1891 | static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1892 | { | 1892 | { |
1893 | GSM_Error error; | 1893 | GSM_Error error; |
1894 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1894 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1895 | int NamePosition = -1; | 1895 | int NamePosition = -1; |
1896 | bool NameSet = false; | 1896 | bool NameSet = false; |
1897 | int i; | 1897 | int i; |
1898 | bool UpdatedFields[26]; | 1898 | bool UpdatedFields[26]; |
1899 | 1899 | ||
1900 | if (entry->Location == 0) return ERR_INVALIDLOCATION; | 1900 | if (entry->Location == 0) return ERR_INVALIDLOCATION; |
1901 | 1901 | ||
1902 | if (entry->MemoryType == MEM_ME) { | 1902 | if (entry->MemoryType == MEM_ME) { |
1903 | 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; |
1904 | /* Save modified entry */ | 1904 | /* Save modified entry */ |
1905 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 1905 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
1906 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { | 1906 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { |
1907 | /* Entry doesn't exist, we will create new one */ | 1907 | /* Entry doesn't exist, we will create new one */ |
1908 | return ALCATEL_AddMemory(s, entry); | 1908 | return ALCATEL_AddMemory(s, entry); |
1909 | } | 1909 | } |
1910 | /* Get fields for current item */ | 1910 | /* Get fields for current item */ |
1911 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; | 1911 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; |
1912 | 1912 | ||
1913 | for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } | 1913 | for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } |
1914 | 1914 | ||
1915 | 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; |
1916 | for (i = 0; i < entry->EntriesNum; i++) { | 1916 | for (i = 0; i < entry->EntriesNum; i++) { |
1917 | switch (entry->Entries[i].EntryType) { | 1917 | switch (entry->Entries[i].EntryType) { |
1918 | case PBK_Number_General: | 1918 | case PBK_Number_General: |
1919 | UpdatedFields[8] = true; | 1919 | UpdatedFields[8] = true; |
1920 | 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; |
1921 | break; | 1921 | break; |
1922 | case PBK_Number_Mobile: | 1922 | case PBK_Number_Mobile: |
1923 | UpdatedFields[12] = true; | 1923 | UpdatedFields[12] = true; |
1924 | 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; |
1925 | break; | 1925 | break; |
1926 | case PBK_Number_Work: | 1926 | case PBK_Number_Work: |
1927 | UpdatedFields[7] = true; | 1927 | UpdatedFields[7] = true; |
1928 | 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; |
1929 | break; | 1929 | break; |
1930 | case PBK_Number_Fax: | 1930 | case PBK_Number_Fax: |
1931 | UpdatedFields[9] = true; | 1931 | UpdatedFields[9] = true; |
1932 | 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; |
1933 | break; | 1933 | break; |
1934 | case PBK_Number_Home: | 1934 | case PBK_Number_Home: |
1935 | UpdatedFields[13] = true; | 1935 | UpdatedFields[13] = true; |
1936 | 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; |
1937 | break; | 1937 | break; |
1938 | case PBK_Number_Pager: | 1938 | case PBK_Number_Pager: |
1939 | UpdatedFields[11] = true; | 1939 | UpdatedFields[11] = true; |
1940 | 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; |
1941 | break; | 1941 | break; |
1942 | case PBK_Number_Other: | 1942 | case PBK_Number_Other: |
1943 | UpdatedFields[10] = true; | 1943 | UpdatedFields[10] = true; |
1944 | 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; |
1945 | break; | 1945 | break; |
1946 | case PBK_Text_Note: | 1946 | case PBK_Text_Note: |
1947 | UpdatedFields[4] = true; | 1947 | UpdatedFields[4] = true; |
1948 | 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; |
1949 | break; | 1949 | break; |
1950 | case PBK_Text_Email: | 1950 | case PBK_Text_Email: |
1951 | UpdatedFields[14] = true; | 1951 | UpdatedFields[14] = true; |
1952 | 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; |
1953 | break; | 1953 | break; |
1954 | case PBK_Text_Email2: | 1954 | case PBK_Text_Email2: |
1955 | UpdatedFields[15] = true; | 1955 | UpdatedFields[15] = true; |
1956 | 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; |
1957 | break; | 1957 | break; |
1958 | case PBK_Text_LastName: | 1958 | case PBK_Text_LastName: |
1959 | UpdatedFields[0] = true; | 1959 | UpdatedFields[0] = true; |
1960 | 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; |
1961 | break; | 1961 | break; |
1962 | case PBK_Text_FirstName: | 1962 | case PBK_Text_FirstName: |
1963 | UpdatedFields[1] = true; | 1963 | UpdatedFields[1] = true; |
1964 | 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; |
1965 | break; | 1965 | break; |
1966 | case PBK_Text_Company: | 1966 | case PBK_Text_Company: |
1967 | UpdatedFields[2] = true; | 1967 | UpdatedFields[2] = true; |
1968 | 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; |
1969 | break; | 1969 | break; |
1970 | case PBK_Text_JobTitle: | 1970 | case PBK_Text_JobTitle: |
1971 | UpdatedFields[3] = true; | 1971 | UpdatedFields[3] = true; |
1972 | 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; |
1973 | break; | 1973 | break; |
1974 | case PBK_Category: | 1974 | case PBK_Category: |
1975 | UpdatedFields[5] = true; | 1975 | UpdatedFields[5] = true; |
1976 | 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; |
1977 | break; | 1977 | break; |
1978 | case PBK_Private: | 1978 | case PBK_Private: |
1979 | UpdatedFields[6] = true; | 1979 | UpdatedFields[6] = true; |
1980 | 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; |
1981 | break; | 1981 | break; |
1982 | case PBK_Text_StreetAddress: | 1982 | case PBK_Text_StreetAddress: |
1983 | UpdatedFields[16] = true; | 1983 | UpdatedFields[16] = true; |
1984 | 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; |
1985 | break; | 1985 | break; |
1986 | case PBK_Text_City: | 1986 | case PBK_Text_City: |
1987 | UpdatedFields[17] = true; | 1987 | UpdatedFields[17] = true; |
1988 | 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; |
1989 | break; | 1989 | break; |
1990 | case PBK_Text_State: | 1990 | case PBK_Text_State: |
1991 | UpdatedFields[18] = true; | 1991 | UpdatedFields[18] = true; |
1992 | 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; |
1993 | break; | 1993 | break; |
1994 | case PBK_Text_Zip: | 1994 | case PBK_Text_Zip: |
1995 | UpdatedFields[19] = true; | 1995 | UpdatedFields[19] = true; |
1996 | 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; |
1997 | break; | 1997 | break; |
1998 | case PBK_Text_Country: | 1998 | case PBK_Text_Country: |
1999 | UpdatedFields[20] = true; | 1999 | UpdatedFields[20] = true; |
2000 | 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; |
2001 | break; | 2001 | break; |
2002 | case PBK_Text_Custom1: | 2002 | case PBK_Text_Custom1: |
2003 | UpdatedFields[21] = true; | 2003 | UpdatedFields[21] = true; |
2004 | 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; |
2005 | break; | 2005 | break; |
2006 | case PBK_Text_Custom2: | 2006 | case PBK_Text_Custom2: |
2007 | UpdatedFields[22] = true; | 2007 | UpdatedFields[22] = true; |
2008 | 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; |
2009 | break; | 2009 | break; |
2010 | case PBK_Text_Custom3: | 2010 | case PBK_Text_Custom3: |
2011 | UpdatedFields[23] = true; | 2011 | UpdatedFields[23] = true; |
2012 | 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; |
2013 | break; | 2013 | break; |
2014 | case PBK_Text_Custom4: | 2014 | case PBK_Text_Custom4: |
2015 | UpdatedFields[24] = true; | 2015 | UpdatedFields[24] = true; |
2016 | 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 |
2017 | ; break; | 2017 | ; break; |
2018 | case PBK_PictureID: | 2018 | case PBK_PictureID: |
2019 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 2019 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
2020 | UpdatedFields[25] = true; | 2020 | UpdatedFields[25] = true; |
2021 | 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; |
2022 | } else { | 2022 | } else { |
2023 | 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); |
2024 | } | 2024 | } |
2025 | break; | 2025 | break; |
2026 | 2026 | ||
2027 | case PBK_Text_Name: NamePosition = i; break; | 2027 | case PBK_Text_Name: NamePosition = i; break; |
2028 | /* Following fields are not supported: */ | 2028 | /* Following fields are not supported: */ |
2029 | case PBK_SMSListID: | 2029 | case PBK_SMSListID: |
2030 | case PBK_Text_UserID: | 2030 | case PBK_Text_UserID: |
2031 | case PBK_RingtoneFileSystemID: | 2031 | case PBK_RingtoneFileSystemID: |
2032 | case PBK_Date: | 2032 | case PBK_Date: |
2033 | case PBK_Caller_Group: | 2033 | case PBK_Caller_Group: |
2034 | case PBK_RingtoneID: | 2034 | case PBK_RingtoneID: |
2035 | case PBK_Text_Postal: | 2035 | case PBK_Text_Postal: |
2036 | case PBK_Text_URL: | 2036 | case PBK_Text_URL: |
2037 | 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); |
2038 | break; | 2038 | break; |
2039 | } | 2039 | } |
2040 | } | 2040 | } |
2041 | if (NamePosition != -1) { | 2041 | if (NamePosition != -1) { |
2042 | if (NameSet) { | 2042 | if (NameSet) { |
2043 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); | 2043 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); |
2044 | } else { | 2044 | } else { |
2045 | 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; |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | /* 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... */ |
2049 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 2049 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
2050 | 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; |
2051 | } | 2051 | } |
2052 | 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; |
2053 | entry->Location = Priv->CommitedRecord; | 2053 | entry->Location = Priv->CommitedRecord; |
2054 | return ERR_NONE; | 2054 | return ERR_NONE; |
2055 | } else { | 2055 | } else { |
2056 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2056 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2057 | return ATGEN_SetMemory(s, entry); | 2057 | return ATGEN_SetMemory(s, entry); |
2058 | } | 2058 | } |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 2061 | static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
2062 | { | 2062 | { |
2063 | GSM_Error error; | 2063 | GSM_Error error; |
2064 | 2064 | ||
2065 | if (entry->MemoryType == MEM_ME) { | 2065 | if (entry->MemoryType == MEM_ME) { |
2066 | 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; |
2067 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2067 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2068 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { | 2068 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { |
2069 | /* Entry was empty => no error */ | 2069 | /* Entry was empty => no error */ |
2070 | return ERR_NONE; | 2070 | return ERR_NONE; |
2071 | } | 2071 | } |
2072 | /* Do real delete */ | 2072 | /* Do real delete */ |
2073 | error = ALCATEL_DeleteItem(s, entry->Location); | 2073 | error = ALCATEL_DeleteItem(s, entry->Location); |
2074 | if (error != ERR_NONE) return error; | 2074 | if (error != ERR_NONE) return error; |
2075 | 2075 | ||
2076 | /* Refresh list */ | 2076 | /* Refresh list */ |
2077 | 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; |
2078 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2078 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2079 | 2079 | ||
2080 | return ERR_NONE; | 2080 | return ERR_NONE; |
2081 | } else { | 2081 | } else { |
2082 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2082 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2083 | return ATGEN_DeleteMemory(s, entry); | 2083 | return ATGEN_DeleteMemory(s, entry); |
2084 | } | 2084 | } |
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) | 2087 | static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) |
2088 | { | 2088 | { |
2089 | GSM_Error error; | 2089 | GSM_Error error; |
2090 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2090 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2091 | int i; | 2091 | int i; |
2092 | 2092 | ||
2093 | if (type == MEM_ME) { | 2093 | if (type == MEM_ME) { |
2094 | 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; |
2095 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2095 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2096 | 2096 | ||
2097 | for (i=0; i<Priv->ContactsItemsCount; i++) { | 2097 | for (i=0; i<Priv->ContactsItemsCount; i++) { |
2098 | error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]); | 2098 | error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]); |
2099 | if (error != ERR_NONE) return error; | 2099 | if (error != ERR_NONE) return error; |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | /* Refresh list */ | 2102 | /* Refresh list */ |
2103 | 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; |
2104 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2104 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2105 | 2105 | ||
2106 | return ERR_NONE; | 2106 | return ERR_NONE; |
2107 | } else { | 2107 | } else { |
2108 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2108 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2109 | return ATGEN_DeleteAllMemory(s, type); | 2109 | return ATGEN_DeleteAllMemory(s, type); |
2110 | } | 2110 | } |
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) | 2113 | static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) |
2114 | { | 2114 | { |
2115 | GSM_Error error; | 2115 | GSM_Error error; |
2116 | 2116 | ||
2117 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2117 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2118 | return ATGEN_GetSMSC(s, smsc); | 2118 | return ATGEN_GetSMSC(s, smsc); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | 2121 | ||
2122 | static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) | 2122 | static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) |
2123 | { | 2123 | { |
2124 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 2124 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
2125 | GSM_Error error; | 2125 | GSM_Error error; |
2126 | 2126 | ||
2127 | if (Status->MemoryType == MEM_ME) { | 2127 | if (Status->MemoryType == MEM_ME) { |
2128 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2128 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2129 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2129 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2130 | Status->MemoryUsed = Priv->ContactsItemsCount; | 2130 | Status->MemoryUsed = Priv->ContactsItemsCount; |
2131 | Status->MemoryFree = ALCATEL_FREE_MEMORY; | 2131 | Status->MemoryFree = ALCATEL_FREE_MEMORY; |
2132 | return ERR_NONE; | 2132 | return ERR_NONE; |
2133 | } else { | 2133 | } else { |
2134 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2134 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2135 | return ATGEN_GetMemoryStatus(s, Status); | 2135 | return ATGEN_GetMemoryStatus(s, Status); |
2136 | } | 2136 | } |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | static GSM_Error ALCATEL_GetSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms) | 2139 | static GSM_Error ALCATEL_GetSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms) |
2140 | { | 2140 | { |
2141 | GSM_Error error; | 2141 | GSM_Error error; |
2142 | 2142 | ||
2143 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2143 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2144 | return ATGEN_GetSMS(s, sms); | 2144 | return ATGEN_GetSMS(s, sms); |
2145 | } | 2145 | } |
2146 | 2146 | ||
2147 | static GSM_Error ALCATEL_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) | 2147 | static GSM_Error ALCATEL_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) |
2148 | { | 2148 | { |
2149 | GSM_Error error; | 2149 | GSM_Error error; |
2150 | 2150 | ||
2151 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2151 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2152 | return ATGEN_DeleteSMS(s, sms); | 2152 | return ATGEN_DeleteSMS(s, sms); |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | static GSM_Error ALCATEL_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) | 2155 | static GSM_Error ALCATEL_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) |
2156 | { | 2156 | { |
2157 | GSM_Error error; | 2157 | GSM_Error error; |
2158 | 2158 | ||
2159 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2159 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2160 | return ATGEN_AddSMS(s, sms); | 2160 | return ATGEN_AddSMS(s, sms); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | static GSM_Error ALCATEL_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat) | 2163 | static GSM_Error ALCATEL_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat) |
2164 | { | 2164 | { |
2165 | GSM_Error error; | 2165 | GSM_Error error; |
2166 | 2166 | ||
2167 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2167 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2168 | return ATGEN_GetBatteryCharge(s, bat); | 2168 | return ATGEN_GetBatteryCharge(s, bat); |
2169 | } | 2169 | } |
2170 | 2170 | ||
2171 | static GSM_Error ALCATEL_GetSignalStrength(GSM_StateMachine *s, GSM_SignalQuality *sig) | 2171 | static GSM_Error ALCATEL_GetSignalStrength(GSM_StateMachine *s, GSM_SignalQuality *sig) |
2172 | { | 2172 | { |
2173 | GSM_Error error; | 2173 | GSM_Error error; |
2174 | 2174 | ||
2175 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2175 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2176 | return ATGEN_GetSignalQuality(s, sig); | 2176 | return ATGEN_GetSignalQuality(s, sig); |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | static GSM_Error ALCATEL_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) | 2179 | static GSM_Error ALCATEL_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) |
2180 | { | 2180 | { |
2181 | GSM_Error error; | 2181 | GSM_Error error; |
2182 | 2182 | ||
2183 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2183 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2184 | return ATGEN_GetSMSFolders(s, folders); | 2184 | return ATGEN_GetSMSFolders(s, folders); |
2185 | } | 2185 | } |
2186 | 2186 | ||
2187 | static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) | 2187 | static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) |
2188 | { | 2188 | { |
2189 | GSM_Error error; | 2189 | GSM_Error error; |
2190 | 2190 | ||
2191 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2191 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2192 | return ATGEN_GetNextSMS(s, sms, start); | 2192 | return ATGEN_GetNextSMS(s, sms, start); |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) | 2195 | static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) |
2196 | { | 2196 | { |
2197 | GSM_Error error; | 2197 | GSM_Error error; |
2198 | 2198 | ||
2199 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2199 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2200 | return ATGEN_GetSMSStatus(s, status); | 2200 | return ATGEN_GetSMSStatus(s, status); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) | 2203 | static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) |
2204 | { | 2204 | { |
2205 | GSM_Error error; | 2205 | GSM_Error error; |
2206 | 2206 | ||
2207 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2207 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2208 | return ATGEN_DialVoice(s, number, ShowNumber); | 2208 | return ATGEN_DialVoice(s, number, ShowNumber); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all) | 2211 | static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all) |
2212 | { | 2212 | { |
2213 | GSM_Error error; | 2213 | GSM_Error error; |
2214 | 2214 | ||
2215 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2215 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2216 | return ATGEN_AnswerCall(s,ID,all); | 2216 | return ATGEN_AnswerCall(s,ID,all); |
2217 | } | 2217 | } |
2218 | 2218 | ||
2219 | static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) | 2219 | static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) |
2220 | { | 2220 | { |
2221 | GSM_Error error; | 2221 | GSM_Error error; |
2222 | 2222 | ||
2223 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2223 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2224 | return ATGEN_GetNetworkInfo(s, netinfo); | 2224 | return ATGEN_GetNetworkInfo(s, netinfo); |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) | 2227 | static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) |
2228 | { | 2228 | { |
2229 | GSM_Error error; | 2229 | GSM_Error error; |
2230 | 2230 | ||
2231 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2231 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2232 | return ATGEN_GetDisplayStatus(s, features); | 2232 | return ATGEN_GetDisplayStatus(s, features); |
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) | 2235 | static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) |
2236 | { | 2236 | { |
2237 | GSM_Error error; | 2237 | GSM_Error error; |
2238 | 2238 | ||
2239 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2239 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2240 | return ATGEN_SetAutoNetworkLogin(s); | 2240 | return ATGEN_SetAutoNetworkLogin(s); |
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) | 2243 | static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) |
2244 | { | 2244 | { |
2245 | GSM_Error error; | 2245 | GSM_Error error; |
2246 | 2246 | ||
2247 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2247 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2248 | return ATGEN_PressKey(s, Key, Press); | 2248 | return ATGEN_PressKey(s, Key, Press); |
2249 | } | 2249 | } |
2250 | 2250 | ||
2251 | static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard) | 2251 | static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard) |
2252 | { | 2252 | { |
2253 | GSM_Error error; | 2253 | GSM_Error error; |
2254 | 2254 | ||
2255 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2255 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2256 | return ATGEN_Reset(s, hard); | 2256 | return ATGEN_Reset(s, hard); |
2257 | } | 2257 | } |
2258 | 2258 | ||
2259 | static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all) | 2259 | static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all) |
2260 | { | 2260 | { |
2261 | GSM_Error error; | 2261 | GSM_Error error; |
2262 | 2262 | ||
2263 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2263 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2264 | return ATGEN_CancelCall(s,ID,all); | 2264 | return ATGEN_CancelCall(s,ID,all); |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location) | 2267 | static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location) |
2268 | { | 2268 | { |
2269 | GSM_Error error; | 2269 | GSM_Error error; |
2270 | 2270 | ||
2271 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2271 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2272 | return ATGEN_SendSavedSMS(s, Folder, Location); | 2272 | return ATGEN_SendSavedSMS(s, Folder, Location); |
2273 | } | 2273 | } |
2274 | 2274 | ||
2275 | static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) | 2275 | static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) |
2276 | { | 2276 | { |
2277 | GSM_Error error; | 2277 | GSM_Error error; |
2278 | 2278 | ||
2279 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2279 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2280 | return ATGEN_SendSMS(s, sms); | 2280 | return ATGEN_SendSMS(s, sms); |
2281 | } | 2281 | } |
2282 | 2282 | ||
2283 | static GSM_Error ALCATEL_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) | 2283 | static GSM_Error ALCATEL_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) |
2284 | { | 2284 | { |
2285 | GSM_Error error; | 2285 | GSM_Error error; |
2286 | 2286 | ||
2287 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2287 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2288 | return ATGEN_SetDateTime(s, date_time); | 2288 | return ATGEN_SetDateTime(s, date_time); |
2289 | } | 2289 | } |
2290 | 2290 | ||
2291 | static GSM_Error ALCATEL_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) | 2291 | static GSM_Error ALCATEL_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) |
2292 | { | 2292 | { |
2293 | GSM_Error error; | 2293 | GSM_Error error; |
2294 | 2294 | ||
2295 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2295 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2296 | return ATGEN_SetSMSC(s, smsc); | 2296 | return ATGEN_SetSMSC(s, smsc); |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) | 2299 | static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) |
2300 | { | 2300 | { |
2301 | GSM_Error error; | 2301 | GSM_Error error; |
2302 | 2302 | ||
2303 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2303 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2304 | return ATGEN_EnterSecurityCode(s, Code); | 2304 | return ATGEN_EnterSecurityCode(s, Code); |
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) | 2307 | static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) |
2308 | { | 2308 | { |
2309 | GSM_Error error; | 2309 | GSM_Error error; |
2310 | 2310 | ||
2311 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2311 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2312 | return ATGEN_GetSecurityStatus(s, Status); | 2312 | return ATGEN_GetSecurityStatus(s, Status); |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type) | 2315 | static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type) |
2316 | { | 2316 | { |
2317 | GSM_Error error; | 2317 | GSM_Error error; |
2318 | 2318 | ||
2319 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2319 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2320 | return ATGEN_ResetPhoneSettings(s, Type); | 2320 | return ATGEN_ResetPhoneSettings(s, Type); |
2321 | } | 2321 | } |
2322 | 2322 | ||
2323 | static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence) | 2323 | static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence) |
2324 | { | 2324 | { |
2325 | GSM_Error error; | 2325 | GSM_Error error; |
2326 | 2326 | ||
2327 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2327 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2328 | return ATGEN_SendDTMF(s, sequence); | 2328 | return ATGEN_SendDTMF(s, sequence); |
2329 | } | 2329 | } |
2330 | 2330 | ||
2331 | static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) | 2331 | static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) |
2332 | { | 2332 | { |
2333 | GSM_Error error; | 2333 | GSM_Error error; |
2334 | 2334 | ||
2335 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2335 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2336 | return ATGEN_GetSIMIMSI(s, IMSI); | 2336 | return ATGEN_GetSIMIMSI(s, IMSI); |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) | 2339 | static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) |
2340 | { | 2340 | { |
2341 | GSM_Error error; | 2341 | GSM_Error error; |
2342 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2342 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2343 | 2343 | ||
2344 | status->Used = 0; | 2344 | status->Used = 0; |
2345 | 2345 | ||
2346 | 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; |
2347 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2347 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2348 | 2348 | ||
2349 | status->Used = Priv->CalendarItemsCount; | 2349 | status->Used = Priv->CalendarItemsCount; |
2350 | return ERR_NONE; | 2350 | return ERR_NONE; |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2353 | static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2354 | { | 2354 | { |
2355 | GSM_Error error; | 2355 | GSM_Error error; |
2356 | GSM_DateTime *dt = NULL; | 2356 | GSM_DateTime *dt = NULL; |
2357 | GSM_DateTime evdate; | 2357 | GSM_DateTime evdate; |
2358 | bool evdateused = true; | 2358 | bool evdateused = true; |
2359 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2359 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2360 | int i; | 2360 | int i; |
2361 | int j=0; | 2361 | int j=0; |
2362 | 2362 | ||
2363 | 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; |
2364 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2364 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2365 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2365 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2366 | Note->EntriesNum = 0; | 2366 | Note->EntriesNum = 0; |
2367 | return error; | 2367 | return error; |
2368 | } | 2368 | } |
2369 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; | 2369 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; |
2370 | 2370 | ||
2371 | Note->EntriesNum = Priv->CurrentFieldsCount; | 2371 | Note->EntriesNum = Priv->CurrentFieldsCount; |
2372 | 2372 | ||
2373 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 2373 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
2374 | 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; |
2375 | switch (Priv->CurrentFields[i]) { | 2375 | switch (Priv->CurrentFields[i]) { |
2376 | case 0: | 2376 | case 0: |
2377 | if (Priv->ReturnType != Alcatel_date) { | 2377 | if (Priv->ReturnType != Alcatel_date) { |
2378 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2378 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2379 | Note->EntriesNum--; | 2379 | Note->EntriesNum--; |
2380 | j++; | 2380 | j++; |
2381 | break; | 2381 | break; |
2382 | } | 2382 | } |
2383 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2383 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2384 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2384 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2385 | Note->EntriesNum--; | 2385 | Note->EntriesNum--; |
2386 | j++; | 2386 | j++; |
2387 | break; | 2387 | break; |
2388 | } | 2388 | } |
2389 | j++; | 2389 | j++; |
2390 | Note->EntriesNum--; | 2390 | Note->EntriesNum--; |
2391 | evdate = Priv->ReturnDateTime; | 2391 | evdate = Priv->ReturnDateTime; |
2392 | evdateused = false; | 2392 | evdateused = false; |
2393 | break; | 2393 | break; |
2394 | case 1: | 2394 | case 1: |
2395 | if (Priv->ReturnType != Alcatel_time) { | 2395 | if (Priv->ReturnType != Alcatel_time) { |
2396 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2396 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2397 | Note->EntriesNum--; | 2397 | Note->EntriesNum--; |
2398 | j++; | 2398 | j++; |
2399 | break; | 2399 | break; |
2400 | } | 2400 | } |
2401 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 2401 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
2402 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 2402 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
2403 | Note->EntriesNum--; | 2403 | Note->EntriesNum--; |
2404 | j++; | 2404 | j++; |
2405 | break; | 2405 | break; |
2406 | } | 2406 | } |
2407 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; | 2407 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; |
2408 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2408 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2409 | Note->Entries[i-j].Date.Day = evdate.Day; | 2409 | Note->Entries[i-j].Date.Day = evdate.Day; |
2410 | Note->Entries[i-j].Date.Month = evdate.Month; | 2410 | Note->Entries[i-j].Date.Month = evdate.Month; |
2411 | Note->Entries[i-j].Date.Year = evdate.Year; | 2411 | Note->Entries[i-j].Date.Year = evdate.Year; |
2412 | Note->Entries[i-j].Date.Timezone = evdate.Timezone; | 2412 | Note->Entries[i-j].Date.Timezone = evdate.Timezone; |
2413 | evdateused = true; | 2413 | evdateused = true; |
2414 | break; | 2414 | break; |
2415 | case 2: | 2415 | case 2: |
2416 | if (Priv->ReturnType != Alcatel_time) { | 2416 | if (Priv->ReturnType != Alcatel_time) { |
2417 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2417 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2418 | Note->EntriesNum--; | 2418 | Note->EntriesNum--; |
2419 | j++; | 2419 | j++; |
2420 | break; | 2420 | break; |
2421 | } | 2421 | } |
2422 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 2422 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
2423 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 2423 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
2424 | Note->EntriesNum--; | 2424 | Note->EntriesNum--; |
2425 | j++; | 2425 | j++; |
2426 | break; | 2426 | break; |
2427 | } | 2427 | } |
2428 | Note->Entries[i-j].EntryType = CAL_END_DATETIME; | 2428 | Note->Entries[i-j].EntryType = CAL_END_DATETIME; |
2429 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2429 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2430 | Note->Entries[i-j].Date.Day = evdate.Day; | 2430 | Note->Entries[i-j].Date.Day = evdate.Day; |
2431 | Note->Entries[i-j].Date.Month = evdate.Month; | 2431 | Note->Entries[i-j].Date.Month = evdate.Month; |
2432 | Note->Entries[i-j].Date.Year = evdate.Year; | 2432 | Note->Entries[i-j].Date.Year = evdate.Year; |
2433 | Note->Entries[i-j].Date.Timezone = evdate.Timezone; | 2433 | Note->Entries[i-j].Date.Timezone = evdate.Timezone; |
2434 | evdateused = true; | 2434 | evdateused = true; |
2435 | break; | 2435 | break; |
2436 | case 3: | 2436 | case 3: |
2437 | if (Priv->ReturnType != Alcatel_date) { | 2437 | if (Priv->ReturnType != Alcatel_date) { |
2438 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2438 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2439 | Note->EntriesNum--; | 2439 | Note->EntriesNum--; |
2440 | j++; | 2440 | j++; |
2441 | break; | 2441 | break; |
2442 | } | 2442 | } |
2443 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2443 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2444 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2444 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2445 | Note->EntriesNum--; | 2445 | Note->EntriesNum--; |
2446 | j++; | 2446 | j++; |
2447 | break; | 2447 | break; |
2448 | } | 2448 | } |
2449 | if (dt == NULL) { | 2449 | if (dt == NULL) { |
2450 | Note->Entries[i-j].EntryType = CAL_ALARM_DATETIME; | 2450 | Note->Entries[i-j].EntryType = CAL_ALARM_DATETIME; |
2451 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2451 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2452 | dt = &(Note->Entries[i-j].Date); | 2452 | dt = &(Note->Entries[i-j].Date); |
2453 | } else { | 2453 | } else { |
2454 | j++; | 2454 | j++; |
2455 | Note->EntriesNum--; | 2455 | Note->EntriesNum--; |
2456 | dt->Day = Priv->ReturnDateTime.Day; | 2456 | dt->Day = Priv->ReturnDateTime.Day; |
2457 | dt->Month = Priv->ReturnDateTime.Month; | 2457 | dt->Month = Priv->ReturnDateTime.Month; |
2458 | dt->Year = Priv->ReturnDateTime.Year; | 2458 | dt->Year = Priv->ReturnDateTime.Year; |
2459 | dt->Timezone = Priv->ReturnDateTime.Timezone; | 2459 | dt->Timezone = Priv->ReturnDateTime.Timezone; |
2460 | dt = NULL; | 2460 | dt = NULL; |
2461 | } | 2461 | } |
2462 | break; | 2462 | break; |
2463 | case 4: | 2463 | case 4: |
2464 | if (Priv->ReturnType != Alcatel_time) { | 2464 | if (Priv->ReturnType != Alcatel_time) { |
2465 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2465 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2466 | Note->EntriesNum--; | 2466 | Note->EntriesNum--; |
2467 | j++; | 2467 | j++; |
2468 | break; | 2468 | break; |
2469 | } | 2469 | } |
2470 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 2470 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
2471 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 2471 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
2472 | Note->EntriesNum--; | 2472 | Note->EntriesNum--; |
2473 | j++; | 2473 | j++; |
2474 | break; | 2474 | break; |
2475 | } | 2475 | } |
2476 | if (dt == NULL) { | 2476 | if (dt == NULL) { |
2477 | Note->Entries[i-j].EntryType = CAL_ALARM_DATETIME; | 2477 | Note->Entries[i-j].EntryType = CAL_ALARM_DATETIME; |
2478 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2478 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2479 | dt = &(Note->Entries[i-j].Date); | 2479 | dt = &(Note->Entries[i-j].Date); |
2480 | } else { | 2480 | } else { |
2481 | j++; | 2481 | j++; |
2482 | Note->EntriesNum--; | 2482 | Note->EntriesNum--; |
2483 | dt->Hour = Priv->ReturnDateTime.Hour; | 2483 | dt->Hour = Priv->ReturnDateTime.Hour; |
2484 | dt->Minute = Priv->ReturnDateTime.Minute; | 2484 | dt->Minute = Priv->ReturnDateTime.Minute; |
2485 | dt->Second = Priv->ReturnDateTime.Second; | 2485 | dt->Second = Priv->ReturnDateTime.Second; |
2486 | dt = NULL; | 2486 | dt = NULL; |
2487 | } | 2487 | } |
2488 | break; | 2488 | break; |
2489 | case 5: | 2489 | case 5: |
2490 | if (Priv->ReturnType != Alcatel_string) { | 2490 | if (Priv->ReturnType != Alcatel_string) { |
2491 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2491 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2492 | Note->EntriesNum--; | 2492 | Note->EntriesNum--; |
2493 | j++; | 2493 | j++; |
2494 | break; | 2494 | break; |
2495 | } | 2495 | } |
2496 | Note->Entries[i-j].EntryType = CAL_TEXT; | 2496 | Note->Entries[i-j].EntryType = CAL_TEXT; |
2497 | CopyUnicodeString(Note->Entries[i-j].Text, Priv->ReturnString); | 2497 | CopyUnicodeString(Note->Entries[i-j].Text, Priv->ReturnString); |
2498 | break; | 2498 | break; |
2499 | case 6: | 2499 | case 6: |
2500 | if (Priv->ReturnType != Alcatel_bool) { | 2500 | if (Priv->ReturnType != Alcatel_bool) { |
2501 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2501 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2502 | Note->EntriesNum--; | 2502 | Note->EntriesNum--; |
2503 | j++; | 2503 | j++; |
2504 | break; | 2504 | break; |
2505 | } | 2505 | } |
2506 | Note->Entries[i-j].EntryType = CAL_PRIVATE; | 2506 | Note->Entries[i-j].EntryType = CAL_PRIVATE; |
2507 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2507 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2508 | break; | 2508 | break; |
2509 | case 7: | 2509 | case 7: |
2510 | if (Priv->ReturnType != Alcatel_enum) { | 2510 | if (Priv->ReturnType != Alcatel_enum) { |
2511 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2511 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2512 | Note->EntriesNum--; | 2512 | Note->EntriesNum--; |
2513 | j++; | 2513 | j++; |
2514 | break; | 2514 | break; |
2515 | } | 2515 | } |
2516 | switch (Priv->ReturnInt) { | 2516 | switch (Priv->ReturnInt) { |
2517 | case 0: | 2517 | case 0: |
2518 | Note->Type = GSM_CAL_MEETING; | 2518 | Note->Type = GSM_CAL_MEETING; |
2519 | break; | 2519 | break; |
2520 | case 2: | 2520 | case 2: |
2521 | Note->Type = GSM_CAL_BIRTHDAY; | 2521 | Note->Type = GSM_CAL_BIRTHDAY; |
2522 | break; | 2522 | break; |
2523 | case 3: | 2523 | case 3: |
2524 | Note->Type = GSM_CAL_CALL; | 2524 | Note->Type = GSM_CAL_CALL; |
2525 | break; | 2525 | break; |
2526 | case 4: | 2526 | case 4: |
2527 | Note->Type = GSM_CAL_ALARM; | 2527 | Note->Type = GSM_CAL_ALARM; |
2528 | break; | 2528 | break; |
2529 | case 5: | 2529 | case 5: |
2530 | Note->Type = GSM_CAL_DAILY_ALARM; | 2530 | Note->Type = GSM_CAL_DAILY_ALARM; |
2531 | break; | 2531 | break; |
2532 | case 9: | 2532 | case 9: |
2533 | /* I'd call this repeating event, but it makes no sense creating one more type ... */ | 2533 | /* I'd call this repeating event, but it makes no sense creating one more type ... */ |
2534 | Note->Type = GSM_CAL_MEETING; | 2534 | Note->Type = GSM_CAL_MEETING; |
2535 | break; | 2535 | break; |
2536 | default: | 2536 | default: |
2537 | smprintf(s,"WARNING: Received unknown event type %02X!\n", Priv->ReturnInt); | 2537 | smprintf(s,"WARNING: Received unknown event type %02X!\n", Priv->ReturnInt); |
2538 | break; | 2538 | break; |
2539 | } | 2539 | } |
2540 | j++; | 2540 | j++; |
2541 | Note->EntriesNum--; | 2541 | Note->EntriesNum--; |
2542 | break; | 2542 | break; |
2543 | case 8: | 2543 | case 8: |
2544 | if (Priv->ReturnType != Alcatel_int) { | 2544 | if (Priv->ReturnType != Alcatel_int) { |
2545 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2545 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2546 | Note->EntriesNum--; | 2546 | Note->EntriesNum--; |
2547 | j++; | 2547 | j++; |
2548 | break; | 2548 | break; |
2549 | } | 2549 | } |
2550 | /* 0xffffffff indicates that there is phone (BF5), 0 means none (BF5, BE5)*/ | 2550 | /* 0xffffffff indicates that there is phone (BF5), 0 means none (BF5, BE5)*/ |
2551 | if (Priv->ReturnInt == 0xffffffff || Priv->ReturnInt == 0) { | 2551 | if (Priv->ReturnInt == 0xffffffff || Priv->ReturnInt == 0) { |
2552 | j++; | 2552 | j++; |
2553 | Note->EntriesNum--; | 2553 | Note->EntriesNum--; |
2554 | } else { | 2554 | } else { |
2555 | Note->Entries[i-j].EntryType = CAL_CONTACTID; | 2555 | Note->Entries[i-j].EntryType = CAL_CONTACTID; |
2556 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2556 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2557 | } | 2557 | } |
2558 | break; | 2558 | break; |
2559 | case 9: | 2559 | case 9: |
2560 | if (Priv->ReturnType != Alcatel_phone) { | 2560 | if (Priv->ReturnType != Alcatel_phone) { |
2561 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2561 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2562 | Note->EntriesNum--; | 2562 | Note->EntriesNum--; |
2563 | j++; | 2563 | j++; |
2564 | break; | 2564 | break; |
2565 | } | 2565 | } |
2566 | Note->Entries[i-j].EntryType = CAL_PHONE; | 2566 | Note->Entries[i-j].EntryType = CAL_PHONE; |
2567 | CopyUnicodeString(Note->Entries[i-j].Text, Priv->ReturnString); | 2567 | CopyUnicodeString(Note->Entries[i-j].Text, Priv->ReturnString); |
2568 | break; | 2568 | break; |
2569 | case 10: | 2569 | case 10: |
2570 | if (Priv->ReturnType != Alcatel_byte) { | 2570 | if (Priv->ReturnType != Alcatel_byte) { |
2571 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2571 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2572 | Note->EntriesNum--; | 2572 | Note->EntriesNum--; |
2573 | j++; | 2573 | j++; |
2574 | break; | 2574 | break; |
2575 | } | 2575 | } |
2576 | Note->Entries[i-j].EntryType = CAL_REPEAT_DAYOFWEEK; | 2576 | Note->Entries[i-j].EntryType = CAL_REPEAT_DAYOFWEEK; |
2577 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2577 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2578 | break; | 2578 | break; |
2579 | case 11: | 2579 | case 11: |
2580 | if (Priv->ReturnType != Alcatel_byte) { | 2580 | if (Priv->ReturnType != Alcatel_byte) { |
2581 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2581 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2582 | Note->EntriesNum--; | 2582 | Note->EntriesNum--; |
2583 | j++; | 2583 | j++; |
2584 | break; | 2584 | break; |
2585 | } | 2585 | } |
2586 | Note->Entries[i-j].EntryType = CAL_REPEAT_DAY; | 2586 | Note->Entries[i-j].EntryType = CAL_REPEAT_DAY; |
2587 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2587 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2588 | break; | 2588 | break; |
2589 | case 12: | 2589 | case 12: |
2590 | if (Priv->ReturnType != Alcatel_byte) { | 2590 | if (Priv->ReturnType != Alcatel_byte) { |
2591 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2591 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2592 | Note->EntriesNum--; | 2592 | Note->EntriesNum--; |
2593 | j++; | 2593 | j++; |
2594 | break; | 2594 | break; |
2595 | } | 2595 | } |
2596 | Note->Entries[i-j].EntryType = CAL_REPEAT_WEEKOFMONTH; | 2596 | Note->Entries[i-j].EntryType = CAL_REPEAT_WEEKOFMONTH; |
2597 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2597 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2598 | break; | 2598 | break; |
2599 | case 13: | 2599 | case 13: |
2600 | if (Priv->ReturnType != Alcatel_byte) { | 2600 | if (Priv->ReturnType != Alcatel_byte) { |
2601 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2601 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2602 | Note->EntriesNum--; | 2602 | Note->EntriesNum--; |
2603 | j++; | 2603 | j++; |
2604 | break; | 2604 | break; |
2605 | } | 2605 | } |
2606 | Note->Entries[i-j].EntryType = CAL_REPEAT_MONTH; | 2606 | Note->Entries[i-j].EntryType = CAL_REPEAT_MONTH; |
2607 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2607 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2608 | break; | 2608 | break; |
2609 | case 17: | 2609 | case 17: |
2610 | if (Priv->ReturnType != Alcatel_byte) { | 2610 | if (Priv->ReturnType != Alcatel_byte) { |
2611 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2611 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2612 | Note->EntriesNum--; | 2612 | Note->EntriesNum--; |
2613 | j++; | 2613 | j++; |
2614 | break; | 2614 | break; |
2615 | } | 2615 | } |
2616 | /* In BF5 birthday has frequency = 1 */ | 2616 | /* In BF5 birthday has frequency = 1 */ |
2617 | if (Note->Type == GSM_CAL_BIRTHDAY) { | 2617 | if (Note->Type == GSM_CAL_BIRTHDAY) { |
2618 | Note->EntriesNum--; | 2618 | Note->EntriesNum--; |
2619 | j++; | 2619 | j++; |
2620 | } else { | 2620 | } else { |
2621 | Note->Entries[i-j].EntryType = CAL_REPEAT_FREQUENCY; | 2621 | Note->Entries[i-j].EntryType = CAL_REPEAT_FREQUENCY; |
2622 | Note->Entries[i-j].Number = Priv->ReturnInt; | 2622 | Note->Entries[i-j].Number = Priv->ReturnInt; |
2623 | } | 2623 | } |
2624 | break; | 2624 | break; |
2625 | case 18: | 2625 | case 18: |
2626 | if (Priv->ReturnType != Alcatel_date) { | 2626 | if (Priv->ReturnType != Alcatel_date) { |
2627 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2627 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2628 | Note->EntriesNum--; | 2628 | Note->EntriesNum--; |
2629 | j++; | 2629 | j++; |
2630 | break; | 2630 | break; |
2631 | } | 2631 | } |
2632 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2632 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2633 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2633 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2634 | Note->EntriesNum--; | 2634 | Note->EntriesNum--; |
2635 | j++; | 2635 | j++; |
2636 | break; | 2636 | break; |
2637 | } | 2637 | } |
2638 | Note->Entries[i-j].EntryType = CAL_REPEAT_STARTDATE; | 2638 | Note->Entries[i-j].EntryType = CAL_REPEAT_STARTDATE; |
2639 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2639 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2640 | break; | 2640 | break; |
2641 | case 19: | 2641 | case 19: |
2642 | if (Priv->ReturnType != Alcatel_date) { | 2642 | if (Priv->ReturnType != Alcatel_date) { |
2643 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2643 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2644 | Note->EntriesNum--; | 2644 | Note->EntriesNum--; |
2645 | j++; | 2645 | j++; |
2646 | break; | 2646 | break; |
2647 | } | 2647 | } |
2648 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2648 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2649 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2649 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2650 | Note->EntriesNum--; | 2650 | Note->EntriesNum--; |
2651 | j++; | 2651 | j++; |
2652 | break; | 2652 | break; |
2653 | } | 2653 | } |
2654 | Note->Entries[i-j].EntryType = CAL_REPEAT_STOPDATE; | 2654 | Note->Entries[i-j].EntryType = CAL_REPEAT_STOPDATE; |
2655 | Note->Entries[i-j].Date = Priv->ReturnDateTime; | 2655 | Note->Entries[i-j].Date = Priv->ReturnDateTime; |
2656 | break; | 2656 | break; |
2657 | case 20: | 2657 | case 20: |
2658 | if (Priv->ReturnType != Alcatel_date) { | 2658 | if (Priv->ReturnType != Alcatel_date) { |
2659 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2659 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2660 | Note->EntriesNum--; | 2660 | Note->EntriesNum--; |
2661 | j++; | 2661 | j++; |
2662 | break; | 2662 | break; |
2663 | } | 2663 | } |
2664 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2664 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2665 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2665 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2666 | Note->EntriesNum--; | 2666 | Note->EntriesNum--; |
2667 | j++; | 2667 | j++; |
2668 | break; | 2668 | break; |
2669 | } | 2669 | } |
2670 | /* This entry had always same value as the 3rd (alarm date) */ | 2670 | /* This entry had always same value as the 3rd (alarm date) */ |
2671 | j++; | 2671 | j++; |
2672 | Note->EntriesNum--; | 2672 | Note->EntriesNum--; |
2673 | break; | 2673 | break; |
2674 | case 21: | 2674 | case 21: |
2675 | if (Priv->ReturnType != Alcatel_time) { | 2675 | if (Priv->ReturnType != Alcatel_time) { |
2676 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2676 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2677 | Note->EntriesNum--; | 2677 | Note->EntriesNum--; |
2678 | j++; | 2678 | j++; |
2679 | break; | 2679 | break; |
2680 | } | 2680 | } |
2681 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 2681 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
2682 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 2682 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
2683 | Note->EntriesNum--; | 2683 | Note->EntriesNum--; |
2684 | j++; | 2684 | j++; |
2685 | break; | 2685 | break; |
2686 | } | 2686 | } |
2687 | /* This entry had always same value as the 4th (alarm time) */ | 2687 | /* This entry had always same value as the 4th (alarm time) */ |
2688 | j++; | 2688 | j++; |
2689 | Note->EntriesNum--; | 2689 | Note->EntriesNum--; |
2690 | break; | 2690 | break; |
2691 | default: | 2691 | default: |
2692 | Note->EntriesNum--; | 2692 | Note->EntriesNum--; |
2693 | j++; | 2693 | j++; |
2694 | 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); |
2695 | switch (Priv->ReturnType) { | 2695 | switch (Priv->ReturnType) { |
2696 | case Alcatel_date: | 2696 | case Alcatel_date: |
2697 | 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); |
2698 | break; | 2698 | break; |
2699 | case Alcatel_time: | 2699 | case Alcatel_time: |
2700 | 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); |
2701 | break; | 2701 | break; |
2702 | case Alcatel_string: | 2702 | case Alcatel_string: |
2703 | case Alcatel_phone: | 2703 | case Alcatel_phone: |
2704 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 2704 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
2705 | break; | 2705 | break; |
2706 | case Alcatel_enum: | 2706 | case Alcatel_enum: |
2707 | case Alcatel_bool: | 2707 | case Alcatel_bool: |
2708 | case Alcatel_int: | 2708 | case Alcatel_int: |
2709 | case Alcatel_byte: | 2709 | case Alcatel_byte: |
2710 | smprintf(s, "%d", Priv->ReturnInt); | 2710 | smprintf(s, "%d", Priv->ReturnInt); |
2711 | break; | 2711 | break; |
2712 | } | 2712 | } |
2713 | smprintf(s,"\n"); | 2713 | smprintf(s,"\n"); |
2714 | } | 2714 | } |
2715 | } | 2715 | } |
2716 | /* 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 */ |
2717 | if (!evdateused) { | 2717 | if (!evdateused) { |
2718 | Note->EntriesNum++; | 2718 | Note->EntriesNum++; |
2719 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; | 2719 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; |
2720 | Note->Entries[i-j].Date = evdate; | 2720 | Note->Entries[i-j].Date = evdate; |
2721 | } | 2721 | } |
2722 | return ERR_NONE; | 2722 | return ERR_NONE; |
2723 | } | 2723 | } |
2724 | 2724 | ||
2725 | static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) | 2725 | static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) |
2726 | { | 2726 | { |
2727 | GSM_Error error; | 2727 | GSM_Error error; |
2728 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2728 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2729 | 2729 | ||
2730 | 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; |
2731 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2731 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2732 | if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; | 2732 | if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; |
2733 | 2733 | ||
2734 | if (start) Note->Location = 0; | 2734 | if (start) Note->Location = 0; |
2735 | if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; | 2735 | if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; |
2736 | 2736 | ||
2737 | return ALCATEL_GetCalendar(s, Note); | 2737 | return ALCATEL_GetCalendar(s, Note); |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | 2740 | ||
2741 | static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2741 | static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2742 | { | 2742 | { |
2743 | GSM_Error error; | 2743 | GSM_Error error; |
2744 | 2744 | ||
2745 | 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; |
2746 | /* Delete Calendar */ | 2746 | /* Delete Calendar */ |
2747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2748 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2748 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2749 | /* Entry was empty => no error */ | 2749 | /* Entry was empty => no error */ |
2750 | return ERR_NONE; | 2750 | return ERR_NONE; |
2751 | } | 2751 | } |
2752 | error = ALCATEL_DeleteItem(s, Note->Location); | 2752 | error = ALCATEL_DeleteItem(s, Note->Location); |
2753 | if (error != ERR_NONE) return error; | 2753 | if (error != ERR_NONE) return error; |
2754 | /* Refresh list */ | 2754 | /* Refresh list */ |
2755 | 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; |
2756 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2756 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2757 | return ERR_NONE; | 2757 | return ERR_NONE; |
2758 | } | 2758 | } |
2759 | 2759 | ||
2760 | 2760 | ||
2761 | static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2761 | static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2762 | { | 2762 | { |
2763 | GSM_Error error; | 2763 | GSM_Error error; |
2764 | unsigned int val; | 2764 | unsigned int val; |
2765 | bool contact_set = false; | 2765 | bool contact_set = false; |
2766 | bool phone_set = false; | 2766 | bool phone_set = false; |
2767 | bool date_set = false; | 2767 | bool date_set = false; |
2768 | bool repeating = false; | 2768 | bool repeating = false; |
2769 | int i; | 2769 | int i; |
2770 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2770 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2771 | 2771 | ||
2772 | 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; |
2773 | 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; |
2774 | 2774 | ||
2775 | for (i = 0; i < Note->EntriesNum; i++) { | 2775 | for (i = 0; i < Note->EntriesNum; i++) { |
2776 | switch (Note->Entries[i].EntryType) { | 2776 | switch (Note->Entries[i].EntryType) { |
2777 | case CAL_START_DATETIME: | 2777 | case CAL_START_DATETIME: |
2778 | if (!date_set) { | 2778 | if (!date_set) { |
2779 | 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; |
2780 | date_set = true; | 2780 | date_set = true; |
2781 | } | 2781 | } |
2782 | 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; |
2783 | break; | 2783 | break; |
2784 | case CAL_END_DATETIME: | 2784 | case CAL_END_DATETIME: |
2785 | if (!date_set) { | 2785 | if (!date_set) { |
2786 | 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; |
2787 | date_set = true; | 2787 | date_set = true; |
2788 | } | 2788 | } |
2789 | 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; |
2790 | break; | 2790 | break; |
2791 | case CAL_ALARM_DATETIME: | 2791 | case CAL_ALARM_DATETIME: |
2792 | 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; |
2793 | 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; |
2794 | 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) { |
2795 | 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; |
2796 | 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; |
2797 | } | 2797 | } |
2798 | break; | 2798 | break; |
2799 | case CAL_TEXT: | 2799 | case CAL_TEXT: |
2800 | 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; |
2801 | break; | 2801 | break; |
2802 | case CAL_PRIVATE: | 2802 | case CAL_PRIVATE: |
2803 | 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; |
2804 | break; | 2804 | break; |
2805 | case CAL_CONTACTID: | 2805 | case CAL_CONTACTID: |
2806 | 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; |
2807 | contact_set = true; | 2807 | contact_set = true; |
2808 | break; | 2808 | break; |
2809 | case CAL_PHONE: | 2809 | case CAL_PHONE: |
2810 | 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; |
2811 | phone_set = true; | 2811 | phone_set = true; |
2812 | break; | 2812 | break; |
2813 | case CAL_REPEAT_DAYOFWEEK: | 2813 | case CAL_REPEAT_DAYOFWEEK: |
2814 | 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; |
2815 | repeating = true; | 2815 | repeating = true; |
2816 | break; | 2816 | break; |
2817 | case CAL_REPEAT_DAY: | 2817 | case CAL_REPEAT_DAY: |
2818 | 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; |
2819 | repeating = true; | 2819 | repeating = true; |
2820 | break; | 2820 | break; |
2821 | case CAL_REPEAT_WEEKOFMONTH: | 2821 | case CAL_REPEAT_WEEKOFMONTH: |
2822 | 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; |
2823 | repeating = true; | 2823 | repeating = true; |
2824 | break; | 2824 | break; |
2825 | case CAL_REPEAT_MONTH: | 2825 | case CAL_REPEAT_MONTH: |
2826 | 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; |
2827 | repeating = true; | 2827 | repeating = true; |
2828 | break; | 2828 | break; |
2829 | case CAL_REPEAT_FREQUENCY: | 2829 | case CAL_REPEAT_FREQUENCY: |
2830 | 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; |
2831 | repeating = true; | 2831 | repeating = true; |
2832 | break; | 2832 | break; |
2833 | case CAL_REPEAT_STARTDATE: | 2833 | case CAL_REPEAT_STARTDATE: |
2834 | 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; |
2835 | repeating = true; | 2835 | repeating = true; |
2836 | break; | 2836 | break; |
2837 | case CAL_REPEAT_STOPDATE: | 2837 | case CAL_REPEAT_STOPDATE: |
2838 | 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; |
2839 | repeating = true; | 2839 | repeating = true; |
2840 | break; | 2840 | break; |
2841 | case CAL_SILENT_ALARM_DATETIME: | 2841 | case CAL_SILENT_ALARM_DATETIME: |
2842 | case CAL_RECURRANCE: | 2842 | case CAL_RECURRANCE: |
2843 | case CAL_LOCATION: | 2843 | case CAL_LOCATION: |
2844 | 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); |
2845 | break; | 2845 | break; |
2846 | } | 2846 | } |
2847 | } | 2847 | } |
2848 | 2848 | ||
2849 | switch (Note->Type) { | 2849 | switch (Note->Type) { |
2850 | case GSM_CAL_CALL: | 2850 | case GSM_CAL_CALL: |
2851 | val = 3; | 2851 | val = 3; |
2852 | break; | 2852 | break; |
2853 | case GSM_CAL_BIRTHDAY: | 2853 | case GSM_CAL_BIRTHDAY: |
2854 | val = 2; | 2854 | val = 2; |
2855 | break; | 2855 | break; |
2856 | case GSM_CAL_ALARM: | 2856 | case GSM_CAL_ALARM: |
2857 | val = 4; | 2857 | val = 4; |
2858 | break; | 2858 | break; |
2859 | case GSM_CAL_DAILY_ALARM: | 2859 | case GSM_CAL_DAILY_ALARM: |
2860 | val = 5; | 2860 | val = 5; |
2861 | break; | 2861 | break; |
2862 | default: | 2862 | default: |
2863 | if (repeating) { | 2863 | if (repeating) { |
2864 | val = 9; | 2864 | val = 9; |
2865 | } else { | 2865 | } else { |
2866 | val = 0; | 2866 | val = 0; |
2867 | } | 2867 | } |
2868 | } | 2868 | } |
2869 | 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; |
2870 | 2870 | ||
2871 | if (!contact_set) { | 2871 | if (!contact_set) { |
2872 | if (phone_set) { | 2872 | if (phone_set) { |
2873 | val = 0xffffffff; | 2873 | val = 0xffffffff; |
2874 | } else { | 2874 | } else { |
2875 | val = 0; | 2875 | val = 0; |
2876 | } | 2876 | } |
2877 | 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; |
2878 | } | 2878 | } |
2879 | 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; |
2880 | Note->Location = Priv->CommitedRecord; | 2880 | Note->Location = Priv->CommitedRecord; |
2881 | /* Refresh list */ | 2881 | /* Refresh list */ |
2882 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2882 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2883 | return ERR_NONE; | 2883 | return ERR_NONE; |
2884 | } | 2884 | } |
2885 | 2885 | ||
2886 | static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2886 | static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2887 | { | 2887 | { |
2888 | GSM_Error error; | 2888 | GSM_Error error; |
2889 | unsigned int val; | 2889 | unsigned int val; |
2890 | bool contact_set = false; | 2890 | bool contact_set = false; |
2891 | bool phone_set = false; | 2891 | bool phone_set = false; |
2892 | bool date_set = false; | 2892 | bool date_set = false; |
2893 | bool repeating = false; | 2893 | bool repeating = false; |
2894 | int i; | 2894 | int i; |
2895 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2895 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2896 | bool UpdatedFields[22]; | 2896 | bool UpdatedFields[22]; |
2897 | 2897 | ||
2898 | 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; |
2899 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2899 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2900 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2900 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2901 | /* Entry doesn't exist, we will create new one */ | 2901 | /* Entry doesn't exist, we will create new one */ |
2902 | return ALCATEL_AddCalendar(s, Note); | 2902 | return ALCATEL_AddCalendar(s, Note); |
2903 | } | 2903 | } |
2904 | /* Get fields for current item */ | 2904 | /* Get fields for current item */ |
2905 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; | 2905 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; |
2906 | 2906 | ||
2907 | for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } | 2907 | for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } |
2908 | 2908 | ||
2909 | 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; |
2910 | 2910 | ||
2911 | for (i = 0; i < Note->EntriesNum; i++) { | 2911 | for (i = 0; i < Note->EntriesNum; i++) { |
2912 | switch (Note->Entries[i].EntryType) { | 2912 | switch (Note->Entries[i].EntryType) { |
2913 | case CAL_START_DATETIME: | 2913 | case CAL_START_DATETIME: |
2914 | if (!date_set) { | 2914 | if (!date_set) { |
2915 | UpdatedFields[0] = true; | 2915 | UpdatedFields[0] = true; |
2916 | 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; |
2917 | date_set = true; | 2917 | date_set = true; |
2918 | } | 2918 | } |
2919 | UpdatedFields[1] = true; | 2919 | UpdatedFields[1] = true; |
2920 | 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; |
2921 | break; | 2921 | break; |
2922 | case CAL_END_DATETIME: | 2922 | case CAL_END_DATETIME: |
2923 | if (!date_set) { | 2923 | if (!date_set) { |
2924 | UpdatedFields[0] = true; | 2924 | UpdatedFields[0] = true; |
2925 | 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; |
2926 | date_set = true; | 2926 | date_set = true; |
2927 | } | 2927 | } |
2928 | 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; |
2929 | break; | 2929 | break; |
2930 | case CAL_ALARM_DATETIME: | 2930 | case CAL_ALARM_DATETIME: |
2931 | UpdatedFields[3] = true; | 2931 | UpdatedFields[3] = true; |
2932 | 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; |
2933 | UpdatedFields[4] = true; | 2933 | UpdatedFields[4] = true; |
2934 | 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; |
2935 | 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) { |
2936 | UpdatedFields[20] = true; | 2936 | UpdatedFields[20] = true; |
2937 | 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; |
2938 | UpdatedFields[21] = true; | 2938 | UpdatedFields[21] = true; |
2939 | 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; |
2940 | } | 2940 | } |
2941 | break; | 2941 | break; |
2942 | case CAL_TEXT: | 2942 | case CAL_TEXT: |
2943 | UpdatedFields[5] = true; | 2943 | UpdatedFields[5] = true; |
2944 | 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; |
2945 | break; | 2945 | break; |
2946 | case CAL_PRIVATE: | 2946 | case CAL_PRIVATE: |
2947 | UpdatedFields[6] = true; | 2947 | UpdatedFields[6] = true; |
2948 | 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; |
2949 | break; | 2949 | break; |
2950 | case CAL_CONTACTID: | 2950 | case CAL_CONTACTID: |
2951 | UpdatedFields[8] = true; | 2951 | UpdatedFields[8] = true; |
2952 | 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; |
2953 | contact_set = true; | 2953 | contact_set = true; |
2954 | break; | 2954 | break; |
2955 | case CAL_PHONE: | 2955 | case CAL_PHONE: |
2956 | UpdatedFields[9] = true; | 2956 | UpdatedFields[9] = true; |
2957 | 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; |
2958 | phone_set = true; | 2958 | phone_set = true; |
2959 | break; | 2959 | break; |
2960 | case CAL_REPEAT_DAYOFWEEK: | 2960 | case CAL_REPEAT_DAYOFWEEK: |
2961 | UpdatedFields[10] = true; | 2961 | UpdatedFields[10] = true; |
2962 | 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; |
2963 | repeating = true; | 2963 | repeating = true; |
2964 | break; | 2964 | break; |
2965 | case CAL_REPEAT_DAY: | 2965 | case CAL_REPEAT_DAY: |
2966 | UpdatedFields[11] = true; | 2966 | UpdatedFields[11] = true; |
2967 | 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; |
2968 | repeating = true; | 2968 | repeating = true; |
2969 | break; | 2969 | break; |
2970 | case CAL_REPEAT_WEEKOFMONTH: | 2970 | case CAL_REPEAT_WEEKOFMONTH: |
2971 | UpdatedFields[12] = true; | 2971 | UpdatedFields[12] = true; |
2972 | 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; |
2973 | repeating = true; | 2973 | repeating = true; |
2974 | break; | 2974 | break; |
2975 | case CAL_REPEAT_MONTH: | 2975 | case CAL_REPEAT_MONTH: |
2976 | UpdatedFields[13] = true; | 2976 | UpdatedFields[13] = true; |
2977 | 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; |
2978 | repeating = true; | 2978 | repeating = true; |
2979 | break; | 2979 | break; |
2980 | case CAL_REPEAT_FREQUENCY: | 2980 | case CAL_REPEAT_FREQUENCY: |
2981 | UpdatedFields[17] = true; | 2981 | UpdatedFields[17] = true; |
2982 | 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; |
2983 | repeating = true; | 2983 | repeating = true; |
2984 | break; | 2984 | break; |
2985 | case CAL_REPEAT_STARTDATE: | 2985 | case CAL_REPEAT_STARTDATE: |
2986 | UpdatedFields[18] = true; | 2986 | UpdatedFields[18] = true; |
2987 | 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; |
2988 | repeating = true; | 2988 | repeating = true; |
2989 | break; | 2989 | break; |
2990 | case CAL_REPEAT_STOPDATE: | 2990 | case CAL_REPEAT_STOPDATE: |
2991 | UpdatedFields[19] = true; | 2991 | UpdatedFields[19] = true; |
2992 | 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; |
2993 | repeating = true; | 2993 | repeating = true; |
2994 | break; | 2994 | break; |
2995 | case CAL_SILENT_ALARM_DATETIME: | 2995 | case CAL_SILENT_ALARM_DATETIME: |
2996 | case CAL_RECURRANCE: | 2996 | case CAL_RECURRANCE: |
2997 | case CAL_LOCATION: | 2997 | case CAL_LOCATION: |
2998 | 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); |
2999 | break; | 2999 | break; |
3000 | } | 3000 | } |
3001 | } | 3001 | } |
3002 | 3002 | ||
3003 | switch (Note->Type) { | 3003 | switch (Note->Type) { |
3004 | case GSM_CAL_CALL: | 3004 | case GSM_CAL_CALL: |
3005 | val = 3; | 3005 | val = 3; |
3006 | break; | 3006 | break; |
3007 | case GSM_CAL_BIRTHDAY: | 3007 | case GSM_CAL_BIRTHDAY: |
3008 | val = 2; | 3008 | val = 2; |
3009 | break; | 3009 | break; |
3010 | case GSM_CAL_ALARM: | 3010 | case GSM_CAL_ALARM: |
3011 | val = 4; | 3011 | val = 4; |
3012 | break; | 3012 | break; |
3013 | case GSM_CAL_DAILY_ALARM: | 3013 | case GSM_CAL_DAILY_ALARM: |
3014 | val = 5; | 3014 | val = 5; |
3015 | break; | 3015 | break; |
3016 | default: | 3016 | default: |
3017 | if (repeating) { | 3017 | if (repeating) { |
3018 | val = 9; | 3018 | val = 9; |
3019 | } else { | 3019 | } else { |
3020 | val = 0; | 3020 | val = 0; |
3021 | } | 3021 | } |
3022 | } | 3022 | } |
3023 | UpdatedFields[7] = true; | 3023 | UpdatedFields[7] = true; |
3024 | 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; |
3025 | 3025 | ||
3026 | if (!contact_set) { | 3026 | if (!contact_set) { |
3027 | if (phone_set) { | 3027 | if (phone_set) { |
3028 | val = 0xffffffff; | 3028 | val = 0xffffffff; |
3029 | } else { | 3029 | } else { |
3030 | val = 0; | 3030 | val = 0; |
3031 | } | 3031 | } |
3032 | UpdatedFields[8] = true; | 3032 | UpdatedFields[8] = true; |
3033 | 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; |
3034 | } | 3034 | } |
3035 | /* 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... */ |
3036 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 3036 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
3037 | 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; |
3038 | } | 3038 | } |
3039 | 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; |
3040 | return ERR_NONE; | 3040 | return ERR_NONE; |
3041 | } | 3041 | } |
3042 | 3042 | ||
3043 | static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s) | 3043 | static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s) |
3044 | { | 3044 | { |
3045 | GSM_Error error; | 3045 | GSM_Error error; |
3046 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3046 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3047 | int i; | 3047 | int i; |
3048 | 3048 | ||
3049 | 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; |
3050 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3050 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3051 | 3051 | ||
3052 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3052 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3053 | error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]); | 3053 | error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]); |
3054 | if (error != ERR_NONE) return error; | 3054 | if (error != ERR_NONE) return error; |
3055 | } | 3055 | } |
3056 | 3056 | ||
3057 | /* Refresh list */ | 3057 | /* Refresh list */ |
3058 | 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; |
3059 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3059 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3060 | 3060 | ||
3061 | return ERR_NONE; | 3061 | return ERR_NONE; |
3062 | } | 3062 | } |
3063 | 3063 | ||
3064 | 3064 | ||
3065 | static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) | 3065 | static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) |
3066 | { | 3066 | { |
3067 | GSM_Error error; | 3067 | GSM_Error error; |
3068 | GSM_CalendarEntryNote; | 3068 | GSM_CalendarEntryNote; |
3069 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3069 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3070 | int i; | 3070 | int i; |
3071 | bool Found = false; | 3071 | bool Found = false; |
3072 | bool DateSet = false; | 3072 | bool DateSet = false; |
3073 | int alarm_number = alarm->Location; | 3073 | int alarm_number = alarm->Location; |
3074 | static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; | 3074 | static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; |
3075 | 3075 | ||
3076 | 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; |
3077 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3077 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3078 | 3078 | ||
3079 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3079 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3080 | 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; |
3081 | if (Priv->ReturnType != Alcatel_enum) { | 3081 | if (Priv->ReturnType != Alcatel_enum) { |
3082 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3082 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3083 | continue; | 3083 | continue; |
3084 | } | 3084 | } |
3085 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { | 3085 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { |
3086 | alarm_number--; | 3086 | alarm_number--; |
3087 | if (alarm_number == 0) { | 3087 | if (alarm_number == 0) { |
3088 | Found = true; | 3088 | Found = true; |
3089 | break; | 3089 | break; |
3090 | } | 3090 | } |
3091 | } | 3091 | } |
3092 | } | 3092 | } |
3093 | 3093 | ||
3094 | if (!Found) return ERR_EMPTY; | 3094 | if (!Found) return ERR_EMPTY; |
3095 | 3095 | ||
3096 | Note.Location = Priv->CalendarItems[i]; | 3096 | Note.Location = Priv->CalendarItems[i]; |
3097 | 3097 | ||
3098 | if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; | 3098 | if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; |
3099 | 3099 | ||
3100 | if (Note.Type == GSM_CAL_ALARM) { | 3100 | if (Note.Type == GSM_CAL_ALARM) { |
3101 | alarm->Repeating = false; | 3101 | alarm->Repeating = false; |
3102 | } else { | 3102 | } else { |
3103 | alarm->Repeating = true; | 3103 | alarm->Repeating = true; |
3104 | } | 3104 | } |
3105 | 3105 | ||
3106 | alarm->Text[0] = 0; alarm->Text[1] = 0; | 3106 | alarm->Text[0] = 0; alarm->Text[1] = 0; |
3107 | 3107 | ||
3108 | 3108 | ||
3109 | for (i = 0; i < Note.EntriesNum; i++) { | 3109 | for (i = 0; i < Note.EntriesNum; i++) { |
3110 | if (Note.Entries[i].EntryType == CAL_TEXT) { | 3110 | if (Note.Entries[i].EntryType == CAL_TEXT) { |
3111 | CopyUnicodeString(alarm->Text, Note.Entries[i].Text); | 3111 | CopyUnicodeString(alarm->Text, Note.Entries[i].Text); |
3112 | } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { | 3112 | } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { |
3113 | alarm->DateTime = Note.Entries[i].Date; | 3113 | alarm->DateTime = Note.Entries[i].Date; |
3114 | DateSet = false; | 3114 | DateSet = false; |
3115 | } | 3115 | } |
3116 | } | 3116 | } |
3117 | if (!DateSet) { | 3117 | if (!DateSet) { |
3118 | alarm->DateTime = nulldt; | 3118 | alarm->DateTime = nulldt; |
3119 | } | 3119 | } |
3120 | 3120 | ||
3121 | return ERR_NONE; | 3121 | return ERR_NONE; |
3122 | } | 3122 | } |
3123 | 3123 | ||
3124 | 3124 | ||
3125 | static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) | 3125 | static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) |
3126 | { | 3126 | { |
3127 | GSM_Error error; | 3127 | GSM_Error error; |
3128 | GSM_CalendarEntryNote; | 3128 | GSM_CalendarEntryNote; |
3129 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3129 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3130 | GSM_DateTime dt; | 3130 | GSM_DateTime dt; |
3131 | int i; | 3131 | int i; |
3132 | bool Found = false; | 3132 | bool Found = false; |
3133 | int alarm_number = alarm->Location; | 3133 | int alarm_number = alarm->Location; |
3134 | 3134 | ||
3135 | 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; |
3136 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3136 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3137 | 3137 | ||
3138 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3138 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3139 | 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; |
3140 | if (Priv->ReturnType != Alcatel_enum) { | 3140 | if (Priv->ReturnType != Alcatel_enum) { |
3141 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3141 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3142 | continue; | 3142 | continue; |
3143 | } | 3143 | } |
3144 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { | 3144 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { |
3145 | alarm_number--; | 3145 | alarm_number--; |
3146 | if (alarm_number == 0) { | 3146 | if (alarm_number == 0) { |
3147 | Found = true; | 3147 | Found = true; |
3148 | break; | 3148 | break; |
3149 | } | 3149 | } |
3150 | } | 3150 | } |
3151 | } | 3151 | } |
3152 | 3152 | ||
3153 | if (Found) { | 3153 | if (Found) { |
3154 | Note.Location = Priv->CalendarItems[i]; | 3154 | Note.Location = Priv->CalendarItems[i]; |
3155 | } | 3155 | } |
3156 | 3156 | ||
3157 | Note.EntriesNum = 1; | 3157 | Note.EntriesNum = 1; |
3158 | 3158 | ||
3159 | Note.Entries[0].EntryType = CAL_ALARM_DATETIME; | 3159 | Note.Entries[0].EntryType = CAL_ALARM_DATETIME; |
3160 | Note.Entries[0].Date = alarm->DateTime; | 3160 | Note.Entries[0].Date = alarm->DateTime; |
3161 | 3161 | ||
3162 | if (alarm->Repeating) { | 3162 | if (alarm->Repeating) { |
3163 | Note.Type = GSM_CAL_DAILY_ALARM; | 3163 | Note.Type = GSM_CAL_DAILY_ALARM; |
3164 | GSM_GetCurrentDateTime(&dt); | 3164 | GSM_GetCurrentDateTime(&dt); |
3165 | Note.Entries[0].Date.Day = dt.Day; | 3165 | Note.Entries[0].Date.Day = dt.Day; |
3166 | Note.Entries[0].Date.Month = dt.Month; | 3166 | Note.Entries[0].Date.Month = dt.Month; |
3167 | Note.Entries[0].Date.Year = dt.Year; | 3167 | Note.Entries[0].Date.Year = dt.Year; |
3168 | } else { | 3168 | } else { |
3169 | Note.Type = GSM_CAL_ALARM; | 3169 | Note.Type = GSM_CAL_ALARM; |
3170 | } | 3170 | } |
3171 | 3171 | ||
3172 | if (alarm->Text[0] != 0 || alarm->Text[1] != 0) { | 3172 | if (alarm->Text[0] != 0 || alarm->Text[1] != 0) { |
3173 | Note.EntriesNum++; | 3173 | Note.EntriesNum++; |
3174 | Note.Entries[1].EntryType = CAL_TEXT; | 3174 | Note.Entries[1].EntryType = CAL_TEXT; |
3175 | CopyUnicodeString(Note.Entries[1].Text, alarm->Text); | 3175 | CopyUnicodeString(Note.Entries[1].Text, alarm->Text); |
3176 | } | 3176 | } |
3177 | 3177 | ||
3178 | if (Found) { | 3178 | if (Found) { |
3179 | return ALCATEL_SetCalendar(s, &Note); | 3179 | return ALCATEL_SetCalendar(s, &Note); |
3180 | } else { | 3180 | } else { |
3181 | return ALCATEL_AddCalendar(s, &Note); | 3181 | return ALCATEL_AddCalendar(s, &Note); |
3182 | } | 3182 | } |
3183 | } | 3183 | } |
3184 | 3184 | ||
3185 | 3185 | ||
3186 | static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) | 3186 | static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) |
3187 | { | 3187 | { |
3188 | GSM_Error error; | 3188 | GSM_Error error; |
3189 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3189 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3190 | 3190 | ||
3191 | status->Used = 0; | 3191 | status->Used = 0; |
3192 | 3192 | ||
3193 | 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; |
3194 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3194 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3195 | 3195 | ||
3196 | status->Used = Priv->ToDoItemsCount; | 3196 | status->Used = Priv->ToDoItemsCount; |
3197 | return ERR_NONE; | 3197 | return ERR_NONE; |
3198 | } | 3198 | } |
3199 | 3199 | ||
3200 | static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3200 | static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3201 | { | 3201 | { |
3202 | GSM_Error error; | 3202 | GSM_Error error; |
3203 | GSM_DateTime *dt = NULL; | 3203 | GSM_DateTime *dt = NULL; |
3204 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3204 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3205 | int i; | 3205 | int i; |
3206 | int j=0; | 3206 | int j=0; |
3207 | 3207 | ||
3208 | 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; |
3209 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3209 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3210 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3210 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3211 | ToDo->EntriesNum = 0; | 3211 | ToDo->EntriesNum = 0; |
3212 | return error; | 3212 | return error; |
3213 | } | 3213 | } |
3214 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; | 3214 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; |
3215 | 3215 | ||
3216 | ToDo->EntriesNum = Priv->CurrentFieldsCount; | 3216 | ToDo->EntriesNum = Priv->CurrentFieldsCount; |
3217 | 3217 | ||
3218 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 3218 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
3219 | 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; |
3220 | switch (Priv->CurrentFields[i]) { | 3220 | switch (Priv->CurrentFields[i]) { |
3221 | case 0: | 3221 | case 0: |
3222 | if (Priv->ReturnType != Alcatel_date) { | 3222 | if (Priv->ReturnType != Alcatel_date) { |
3223 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3223 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3224 | ToDo->EntriesNum--; | 3224 | ToDo->EntriesNum--; |
3225 | j++; | 3225 | j++; |
3226 | break; | 3226 | break; |
3227 | } | 3227 | } |
3228 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 3228 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
3229 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 3229 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
3230 | ToDo->EntriesNum--; | 3230 | ToDo->EntriesNum--; |
3231 | j++; | 3231 | j++; |
3232 | break; | 3232 | break; |
3233 | } | 3233 | } |
3234 | ToDo->Entries[i-j].EntryType = TODO_END_DATETIME; | 3234 | ToDo->Entries[i-j].EntryType = TODO_END_DATETIME; |
3235 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; | 3235 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; |
3236 | break; | 3236 | break; |
3237 | case 1: | 3237 | case 1: |
3238 | if (Priv->ReturnType != Alcatel_bool) { | 3238 | if (Priv->ReturnType != Alcatel_bool) { |
3239 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3239 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3240 | ToDo->EntriesNum--; | 3240 | ToDo->EntriesNum--; |
3241 | j++; | 3241 | j++; |
3242 | break; | 3242 | break; |
3243 | } | 3243 | } |
3244 | ToDo->Entries[i-j].EntryType = TODO_COMPLETED; | 3244 | ToDo->Entries[i-j].EntryType = TODO_COMPLETED; |
3245 | ToDo->Entries[i-j].Number = Priv->ReturnInt; | 3245 | ToDo->Entries[i-j].Number = Priv->ReturnInt; |
3246 | break; | 3246 | break; |
3247 | case 2: | 3247 | case 2: |
3248 | if (Priv->ReturnType != Alcatel_date) { | 3248 | if (Priv->ReturnType != Alcatel_date) { |
3249 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3249 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3250 | ToDo->EntriesNum--; | 3250 | ToDo->EntriesNum--; |
3251 | j++; | 3251 | j++; |
3252 | break; | 3252 | break; |
3253 | } | 3253 | } |
3254 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 3254 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
3255 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 3255 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
3256 | ToDo->EntriesNum--; | 3256 | ToDo->EntriesNum--; |
3257 | j++; | 3257 | j++; |
3258 | break; | 3258 | break; |
3259 | } | 3259 | } |
3260 | if (dt == NULL) { | 3260 | if (dt == NULL) { |
3261 | ToDo->Entries[i-j].EntryType = TODO_ALARM_DATETIME; | 3261 | ToDo->Entries[i-j].EntryType = TODO_ALARM_DATETIME; |
3262 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; | 3262 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; |
3263 | dt = &(ToDo->Entries[i-j].Date); | 3263 | dt = &(ToDo->Entries[i-j].Date); |
3264 | } else { | 3264 | } else { |
3265 | j++; | 3265 | j++; |
3266 | ToDo->EntriesNum--; | 3266 | ToDo->EntriesNum--; |
3267 | dt->Day = Priv->ReturnDateTime.Day; | 3267 | dt->Day = Priv->ReturnDateTime.Day; |
3268 | dt->Month = Priv->ReturnDateTime.Month; | 3268 | dt->Month = Priv->ReturnDateTime.Month; |
3269 | dt->Year = Priv->ReturnDateTime.Year; | 3269 | dt->Year = Priv->ReturnDateTime.Year; |
3270 | dt->Timezone = Priv->ReturnDateTime.Timezone; | 3270 | dt->Timezone = Priv->ReturnDateTime.Timezone; |
3271 | dt = NULL; | 3271 | dt = NULL; |
3272 | } | 3272 | } |
3273 | break; | 3273 | break; |
3274 | case 3: | 3274 | case 3: |
3275 | if (Priv->ReturnType != Alcatel_time) { | 3275 | if (Priv->ReturnType != Alcatel_time) { |
3276 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3276 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3277 | ToDo->EntriesNum--; | 3277 | ToDo->EntriesNum--; |
3278 | j++; | 3278 | j++; |
3279 | break; | 3279 | break; |
3280 | } | 3280 | } |
3281 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 3281 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
3282 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 3282 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
3283 | ToDo->EntriesNum--; | 3283 | ToDo->EntriesNum--; |
3284 | j++; | 3284 | j++; |
3285 | break; | 3285 | break; |
3286 | } | 3286 | } |
3287 | if (dt == NULL) { | 3287 | if (dt == NULL) { |
3288 | ToDo->Entries[i-j].EntryType = TODO_ALARM_DATETIME; | 3288 | ToDo->Entries[i-j].EntryType = TODO_ALARM_DATETIME; |
3289 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; | 3289 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; |
3290 | dt = &(ToDo->Entries[i-j].Date); | 3290 | dt = &(ToDo->Entries[i-j].Date); |
3291 | } else { | 3291 | } else { |
3292 | j++; | 3292 | j++; |
3293 | ToDo->EntriesNum--; | 3293 | ToDo->EntriesNum--; |
3294 | dt->Hour = Priv->ReturnDateTime.Hour; | 3294 | dt->Hour = Priv->ReturnDateTime.Hour; |
3295 | dt->Minute = Priv->ReturnDateTime.Minute; | 3295 | dt->Minute = Priv->ReturnDateTime.Minute; |
3296 | dt->Second = Priv->ReturnDateTime.Second; | 3296 | dt->Second = Priv->ReturnDateTime.Second; |
3297 | dt = NULL; | 3297 | dt = NULL; |
3298 | } | 3298 | } |
3299 | break; | 3299 | break; |
3300 | case 4: | 3300 | case 4: |
3301 | if (Priv->ReturnType != Alcatel_string) { | 3301 | if (Priv->ReturnType != Alcatel_string) { |
3302 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3302 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3303 | ToDo->EntriesNum--; | 3303 | ToDo->EntriesNum--; |
3304 | j++; | 3304 | j++; |
3305 | break; | 3305 | break; |
3306 | } | 3306 | } |
3307 | ToDo->Entries[i-j].EntryType = TODO_TEXT; | 3307 | ToDo->Entries[i-j].EntryType = TODO_TEXT; |
3308 | CopyUnicodeString(ToDo->Entries[i-j].Text, Priv->ReturnString); | 3308 | CopyUnicodeString(ToDo->Entries[i-j].Text, Priv->ReturnString); |
3309 | break; | 3309 | break; |
3310 | case 5: | 3310 | case 5: |
3311 | if (Priv->ReturnType != Alcatel_bool) { | 3311 | if (Priv->ReturnType != Alcatel_bool) { |
3312 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3312 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3313 | ToDo->EntriesNum--; | 3313 | ToDo->EntriesNum--; |
3314 | j++; | 3314 | j++; |
3315 | break; | 3315 | break; |
3316 | } | 3316 | } |
3317 | ToDo->Entries[i-j].EntryType = TODO_PRIVATE; | 3317 | ToDo->Entries[i-j].EntryType = TODO_PRIVATE; |
3318 | ToDo->Entries[i-j].Number = Priv->ReturnInt; | 3318 | ToDo->Entries[i-j].Number = Priv->ReturnInt; |
3319 | break; | 3319 | break; |
3320 | case 6: | 3320 | case 6: |
3321 | if (Priv->ReturnType != Alcatel_byte) { | 3321 | if (Priv->ReturnType != Alcatel_byte) { |
3322 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3322 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3323 | ToDo->EntriesNum--; | 3323 | ToDo->EntriesNum--; |
3324 | j++; | 3324 | j++; |
3325 | break; | 3325 | break; |
3326 | } | 3326 | } |
3327 | if (Priv->ReturnInt == 255) { | 3327 | if (Priv->ReturnInt == 255) { |
3328 | /* 255 means no category */ | 3328 | /* 255 means no category */ |
3329 | j++; | 3329 | j++; |
3330 | ToDo->EntriesNum--; | 3330 | ToDo->EntriesNum--; |
3331 | } else { | 3331 | } else { |
3332 | ToDo->Entries[i-j].EntryType = TODO_CATEGORY; | 3332 | ToDo->Entries[i-j].EntryType = TODO_CATEGORY; |
3333 | ToDo->Entries[i-j].Number = Priv->ReturnInt; | 3333 | ToDo->Entries[i-j].Number = Priv->ReturnInt; |
3334 | } | 3334 | } |
3335 | break; | 3335 | break; |
3336 | case 7: | 3336 | case 7: |
3337 | /* This one seems to be byte for BF5 and enum for BE5 */ | 3337 | /* This one seems to be byte for BF5 and enum for BE5 */ |
3338 | if (Priv->ReturnType != Alcatel_enum && Priv->ReturnType != Alcatel_byte) { | 3338 | if (Priv->ReturnType != Alcatel_enum && Priv->ReturnType != Alcatel_byte) { |
3339 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3339 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3340 | ToDo->EntriesNum--; | 3340 | ToDo->EntriesNum--; |
3341 | j++; | 3341 | j++; |
3342 | break; | 3342 | break; |
3343 | } | 3343 | } |
3344 | switch (Priv->ReturnInt) { | 3344 | switch (Priv->ReturnInt) { |
3345 | case 0: | 3345 | case 0: |
3346 | ToDo->Priority = GSM_Priority_High; | 3346 | ToDo->Priority = GSM_Priority_High; |
3347 | break; | 3347 | break; |
3348 | case 1: | 3348 | case 1: |
3349 | ToDo->Priority = GSM_Priority_Medium; | 3349 | ToDo->Priority = GSM_Priority_Medium; |
3350 | break; | 3350 | break; |
3351 | case 2: | 3351 | case 2: |
3352 | ToDo->Priority = GSM_Priority_Low; | 3352 | ToDo->Priority = GSM_Priority_Low; |
3353 | break; | 3353 | break; |
3354 | default: | 3354 | default: |
3355 | ToDo->Priority = 0; | 3355 | ToDo->Priority = 0; |
3356 | smprintf(s,"WARNING: Received unexpected priority %02X, ignoring\n", Priv->ReturnInt); | 3356 | smprintf(s,"WARNING: Received unexpected priority %02X, ignoring\n", Priv->ReturnInt); |
3357 | } | 3357 | } |
3358 | j++; | 3358 | j++; |
3359 | ToDo->EntriesNum--; | 3359 | ToDo->EntriesNum--; |
3360 | break; | 3360 | break; |
3361 | case 8: | 3361 | case 8: |
3362 | if (Priv->ReturnType != Alcatel_int) { | 3362 | if (Priv->ReturnType != Alcatel_int) { |
3363 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3363 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3364 | ToDo->EntriesNum--; | 3364 | ToDo->EntriesNum--; |
3365 | j++; | 3365 | j++; |
3366 | break; | 3366 | break; |
3367 | } | 3367 | } |
3368 | /* 0xffffffff indicates that there is phone, 0 means none */ | 3368 | /* 0xffffffff indicates that there is phone, 0 means none */ |
3369 | if (Priv->ReturnInt == 0xffffffff || Priv->ReturnInt == 0) { | 3369 | if (Priv->ReturnInt == 0xffffffff || Priv->ReturnInt == 0) { |
3370 | j++; | 3370 | j++; |
3371 | ToDo->EntriesNum--; | 3371 | ToDo->EntriesNum--; |
3372 | } else { | 3372 | } else { |
3373 | ToDo->Entries[i-j].EntryType = TODO_CONTACTID; | 3373 | ToDo->Entries[i-j].EntryType = TODO_CONTACTID; |
3374 | ToDo->Entries[i-j].Number = Priv->ReturnInt; | 3374 | ToDo->Entries[i-j].Number = Priv->ReturnInt; |
3375 | } | 3375 | } |
3376 | break; | 3376 | break; |
3377 | case 9: | 3377 | case 9: |
3378 | if (Priv->ReturnType != Alcatel_phone) { | 3378 | if (Priv->ReturnType != Alcatel_phone) { |
3379 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3379 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3380 | ToDo->EntriesNum--; | 3380 | ToDo->EntriesNum--; |
3381 | j++; | 3381 | j++; |
3382 | break; | 3382 | break; |
3383 | } | 3383 | } |
3384 | ToDo->Entries[i-j].EntryType = TODO_PHONE; | 3384 | ToDo->Entries[i-j].EntryType = TODO_PHONE; |
3385 | CopyUnicodeString(ToDo->Entries[i-j].Text, Priv->ReturnString); | 3385 | CopyUnicodeString(ToDo->Entries[i-j].Text, Priv->ReturnString); |
3386 | break; | 3386 | break; |
3387 | case 10: | 3387 | case 10: |
3388 | if (Priv->ReturnType != Alcatel_date) { | 3388 | if (Priv->ReturnType != Alcatel_date) { |
3389 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3389 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3390 | ToDo->EntriesNum--; | 3390 | ToDo->EntriesNum--; |
3391 | j++; | 3391 | j++; |
3392 | break; | 3392 | break; |
3393 | } | 3393 | } |
3394 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 3394 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
3395 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 3395 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
3396 | ToDo->EntriesNum--; | 3396 | ToDo->EntriesNum--; |
3397 | j++; | 3397 | j++; |
3398 | break; | 3398 | break; |
3399 | } | 3399 | } |
3400 | /* This entry had always same value as the 2nd (alarm date) */ | 3400 | /* This entry had always same value as the 2nd (alarm date) */ |
3401 | j++; | 3401 | j++; |
3402 | ToDo->EntriesNum--; | 3402 | ToDo->EntriesNum--; |
3403 | break; | 3403 | break; |
3404 | case 11: | 3404 | case 11: |
3405 | if (Priv->ReturnType != Alcatel_time) { | 3405 | if (Priv->ReturnType != Alcatel_time) { |
3406 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3406 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3407 | ToDo->EntriesNum--; | 3407 | ToDo->EntriesNum--; |
3408 | j++; | 3408 | j++; |
3409 | break; | 3409 | break; |
3410 | } | 3410 | } |
3411 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 3411 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
3412 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 3412 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
3413 | ToDo->EntriesNum--; | 3413 | ToDo->EntriesNum--; |
3414 | j++; | 3414 | j++; |
3415 | break; | 3415 | break; |
3416 | } | 3416 | } |
3417 | /* This entry had always same value as the 3rd (alarm time) */ | 3417 | /* This entry had always same value as the 3rd (alarm time) */ |
3418 | j++; | 3418 | j++; |
3419 | ToDo->EntriesNum--; | 3419 | ToDo->EntriesNum--; |
3420 | break; | 3420 | break; |
3421 | default: | 3421 | default: |
3422 | ToDo->EntriesNum--; | 3422 | ToDo->EntriesNum--; |
3423 | j++; | 3423 | j++; |
3424 | 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); |
3425 | switch (Priv->ReturnType) { | 3425 | switch (Priv->ReturnType) { |
3426 | case Alcatel_date: | 3426 | case Alcatel_date: |
3427 | 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); |
3428 | break; | 3428 | break; |
3429 | case Alcatel_time: | 3429 | case Alcatel_time: |
3430 | 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); |
3431 | break; | 3431 | break; |
3432 | case Alcatel_string: | 3432 | case Alcatel_string: |
3433 | case Alcatel_phone: | 3433 | case Alcatel_phone: |
3434 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 3434 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
3435 | break; | 3435 | break; |
3436 | case Alcatel_enum: | 3436 | case Alcatel_enum: |
3437 | case Alcatel_bool: | 3437 | case Alcatel_bool: |
3438 | case Alcatel_int: | 3438 | case Alcatel_int: |
3439 | case Alcatel_byte: | 3439 | case Alcatel_byte: |
3440 | smprintf(s, "%d", Priv->ReturnInt); | 3440 | smprintf(s, "%d", Priv->ReturnInt); |
3441 | break; | 3441 | break; |
3442 | } | 3442 | } |
3443 | smprintf(s,"\n"); | 3443 | smprintf(s,"\n"); |
3444 | } | 3444 | } |
3445 | } | 3445 | } |
3446 | return ERR_NONE; | 3446 | return ERR_NONE; |
3447 | } | 3447 | } |
3448 | 3448 | ||
3449 | static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) | 3449 | static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) |
3450 | { | 3450 | { |
3451 | GSM_Error error; | 3451 | GSM_Error error; |
3452 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3452 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3453 | 3453 | ||
3454 | 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; |
3455 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3455 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3456 | if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; | 3456 | if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; |
3457 | 3457 | ||
3458 | if (start) ToDo->Location = 0; | 3458 | if (start) ToDo->Location = 0; |
3459 | if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; | 3459 | if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; |
3460 | 3460 | ||
3461 | return ALCATEL_GetToDo(s, ToDo); | 3461 | return ALCATEL_GetToDo(s, ToDo); |
3462 | } | 3462 | } |
3463 | 3463 | ||
3464 | static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) | 3464 | static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) |
3465 | { | 3465 | { |
3466 | GSM_Error error; | 3466 | GSM_Error error; |
3467 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3467 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3468 | int i; | 3468 | int i; |
3469 | 3469 | ||
3470 | 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; |
3471 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3471 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3472 | 3472 | ||
3473 | for (i=0; i<Priv->ToDoItemsCount; i++) { | 3473 | for (i=0; i<Priv->ToDoItemsCount; i++) { |
3474 | error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]); | 3474 | error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]); |
3475 | if (error != ERR_NONE) return error; | 3475 | if (error != ERR_NONE) return error; |
3476 | } | 3476 | } |
3477 | 3477 | ||
3478 | /* Refresh list */ | 3478 | /* Refresh list */ |
3479 | 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; |
3480 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3480 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3481 | 3481 | ||
3482 | return ERR_NONE; | 3482 | return ERR_NONE; |
3483 | } | 3483 | } |
3484 | 3484 | ||
3485 | static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3485 | static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3486 | { | 3486 | { |
3487 | GSM_Error error; | 3487 | GSM_Error error; |
3488 | unsigned int val; | 3488 | unsigned int val; |
3489 | bool contact_set = false; | 3489 | bool contact_set = false; |
3490 | bool phone_set = false; | 3490 | bool phone_set = false; |
3491 | int i; | 3491 | int i; |
3492 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3492 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3493 | 3493 | ||
3494 | 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; |
3495 | 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; |
3496 | 3496 | ||
3497 | switch (ToDo->Priority) { | 3497 | switch (ToDo->Priority) { |
3498 | case GSM_Priority_High: | 3498 | case GSM_Priority_High: |
3499 | val = 0; | 3499 | val = 0; |
3500 | break; | 3500 | break; |
3501 | case GSM_Priority_Low: | 3501 | case GSM_Priority_Low: |
3502 | val = 2; | 3502 | val = 2; |
3503 | break; | 3503 | break; |
3504 | case GSM_Priority_Medium: | 3504 | case GSM_Priority_Medium: |
3505 | default: | 3505 | default: |
3506 | val = 1; | 3506 | val = 1; |
3507 | break; | 3507 | break; |
3508 | } | 3508 | } |
3509 | /* 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 */ |
3510 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 3510 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
3511 | 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; |
3512 | } else { | 3512 | } else { |
3513 | 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; |
3514 | } | 3514 | } |
3515 | 3515 | ||
3516 | for (i = 0; i < ToDo->EntriesNum; i++) { | 3516 | for (i = 0; i < ToDo->EntriesNum; i++) { |
3517 | switch (ToDo->Entries[i].EntryType) { | 3517 | switch (ToDo->Entries[i].EntryType) { |
3518 | case TODO_END_DATETIME: | 3518 | case TODO_END_DATETIME: |
3519 | 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; |
3520 | break; | 3520 | break; |
3521 | case TODO_COMPLETED: | 3521 | case TODO_COMPLETED: |
3522 | 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; |
3523 | break; | 3523 | break; |
3524 | case TODO_ALARM_DATETIME: | 3524 | case TODO_ALARM_DATETIME: |
3525 | 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; |
3526 | 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; |
3527 | 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; |
3528 | 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; |
3529 | break; | 3529 | break; |
3530 | case TODO_TEXT: | 3530 | case TODO_TEXT: |
3531 | 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; |
3532 | break; | 3532 | break; |
3533 | case TODO_PRIVATE: | 3533 | case TODO_PRIVATE: |
3534 | 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; |
3535 | break; | 3535 | break; |
3536 | case TODO_CATEGORY: | 3536 | case TODO_CATEGORY: |
3537 | 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; |
3538 | break; | 3538 | break; |
3539 | case TODO_CONTACTID: | 3539 | case TODO_CONTACTID: |
3540 | 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; |
3541 | contact_set = true; | 3541 | contact_set = true; |
3542 | break; | 3542 | break; |
3543 | case TODO_PHONE: | 3543 | case TODO_PHONE: |
3544 | 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; |
3545 | phone_set = true; | 3545 | phone_set = true; |
3546 | break; | 3546 | break; |
3547 | default: | 3547 | default: |
3548 | break; | 3548 | break; |
3549 | } | 3549 | } |
3550 | } | 3550 | } |
3551 | if (!contact_set) { | 3551 | if (!contact_set) { |
3552 | if (phone_set) { | 3552 | if (phone_set) { |
3553 | val = 0xffffffff; | 3553 | val = 0xffffffff; |
3554 | } else { | 3554 | } else { |
3555 | val = 0; | 3555 | val = 0; |
3556 | } | 3556 | } |
3557 | 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; |
3558 | } | 3558 | } |
3559 | 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; |
3560 | ToDo->Location = Priv->CommitedRecord; | 3560 | ToDo->Location = Priv->CommitedRecord; |
3561 | /* Refresh list */ | 3561 | /* Refresh list */ |
3562 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3562 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3563 | return ERR_NONE; | 3563 | return ERR_NONE; |
3564 | } | 3564 | } |
3565 | 3565 | ||
3566 | static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3566 | static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3567 | { | 3567 | { |
3568 | GSM_Error error; | 3568 | GSM_Error error; |
3569 | unsigned int val; | 3569 | unsigned int val; |
3570 | bool contact_set = false; | 3570 | bool contact_set = false; |
3571 | bool phone_set = false; | 3571 | bool phone_set = false; |
3572 | bool UpdatedFields[12]; | 3572 | bool UpdatedFields[12]; |
3573 | int i; | 3573 | int i; |
3574 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3574 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3575 | 3575 | ||
3576 | 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; |
3577 | /* Save modified ToDo */ | 3577 | /* Save modified ToDo */ |
3578 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3578 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3579 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3579 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3580 | /* Entry doesn't exist, we will create new one */ | 3580 | /* Entry doesn't exist, we will create new one */ |
3581 | return ALCATEL_AddToDo(s, ToDo); | 3581 | return ALCATEL_AddToDo(s, ToDo); |
3582 | } | 3582 | } |
3583 | /* Get fields for current item */ | 3583 | /* Get fields for current item */ |
3584 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; | 3584 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; |
3585 | 3585 | ||
3586 | for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } | 3586 | for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } |
3587 | 3587 | ||
3588 | 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; |
3589 | 3589 | ||
3590 | switch (ToDo->Priority) { | 3590 | switch (ToDo->Priority) { |
3591 | case GSM_Priority_High: | 3591 | case GSM_Priority_High: |
3592 | val = 0; | 3592 | val = 0; |
3593 | break; | 3593 | break; |
3594 | case GSM_Priority_Low: | 3594 | case GSM_Priority_Low: |
3595 | val = 2; | 3595 | val = 2; |
3596 | break; | 3596 | break; |
3597 | case GSM_Priority_Medium: | 3597 | case GSM_Priority_Medium: |
3598 | default: | 3598 | default: |
3599 | val = 1; | 3599 | val = 1; |
3600 | break; | 3600 | break; |
3601 | } | 3601 | } |
3602 | /* 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 */ |
3603 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 3603 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
3604 | 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; |
3605 | } else { | 3605 | } else { |
3606 | 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; |
3607 | } | 3607 | } |
3608 | UpdatedFields[7] = true; | 3608 | UpdatedFields[7] = true; |
3609 | 3609 | ||
3610 | for (i = 0; i < ToDo->EntriesNum; i++) { | 3610 | for (i = 0; i < ToDo->EntriesNum; i++) { |
3611 | switch (ToDo->Entries[i].EntryType) { | 3611 | switch (ToDo->Entries[i].EntryType) { |
3612 | case TODO_END_DATETIME: | 3612 | case TODO_END_DATETIME: |
3613 | 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; |
3614 | UpdatedFields[0] = true; | 3614 | UpdatedFields[0] = true; |
3615 | break; | 3615 | break; |
3616 | case TODO_COMPLETED: | 3616 | case TODO_COMPLETED: |
3617 | 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; |
3618 | UpdatedFields[1] = true; | 3618 | UpdatedFields[1] = true; |
3619 | break; | 3619 | break; |
3620 | case TODO_ALARM_DATETIME: | 3620 | case TODO_ALARM_DATETIME: |
3621 | 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; |
3622 | UpdatedFields[2] = true; | 3622 | UpdatedFields[2] = true; |
3623 | 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; |
3624 | UpdatedFields[3] = true; | 3624 | UpdatedFields[3] = true; |
3625 | 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; |
3626 | UpdatedFields[10] = true; | 3626 | UpdatedFields[10] = true; |
3627 | 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; |
3628 | UpdatedFields[11] = true; | 3628 | UpdatedFields[11] = true; |
3629 | break; | 3629 | break; |
3630 | case TODO_TEXT: | 3630 | case TODO_TEXT: |
3631 | 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; |
3632 | UpdatedFields[4] = true; | 3632 | UpdatedFields[4] = true; |
3633 | break; | 3633 | break; |
3634 | case TODO_PRIVATE: | 3634 | case TODO_PRIVATE: |
3635 | 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; |
3636 | UpdatedFields[5] = true; | 3636 | UpdatedFields[5] = true; |
3637 | break; | 3637 | break; |
3638 | case TODO_CATEGORY: | 3638 | case TODO_CATEGORY: |
3639 | 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; |
3640 | UpdatedFields[6] = true; | 3640 | UpdatedFields[6] = true; |
3641 | break; | 3641 | break; |
3642 | case TODO_CONTACTID: | 3642 | case TODO_CONTACTID: |
3643 | 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; |
3644 | UpdatedFields[8] = true; | 3644 | UpdatedFields[8] = true; |
3645 | contact_set = true; | 3645 | contact_set = true; |
3646 | break; | 3646 | break; |
3647 | case TODO_PHONE: | 3647 | case TODO_PHONE: |
3648 | 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; |
3649 | UpdatedFields[9] = true; | 3649 | UpdatedFields[9] = true; |
3650 | phone_set = true; | 3650 | phone_set = true; |
3651 | break; | 3651 | break; |
3652 | default: | 3652 | default: |
3653 | break; | 3653 | break; |
3654 | } | 3654 | } |
3655 | } | 3655 | } |
3656 | if (!contact_set) { | 3656 | if (!contact_set) { |
3657 | if (phone_set) { | 3657 | if (phone_set) { |
3658 | val = 0xffffffff; | 3658 | val = 0xffffffff; |
3659 | } else { | 3659 | } else { |
3660 | val = 0; | 3660 | val = 0; |
3661 | } | 3661 | } |
3662 | 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; |
3663 | UpdatedFields[8] = true; | 3663 | UpdatedFields[8] = true; |
3664 | } | 3664 | } |
3665 | 3665 | ||
3666 | 3666 | ||
3667 | /* 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... */ |
3668 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 3668 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
3669 | 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; |
3670 | } | 3670 | } |
3671 | 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; |
3672 | return ERR_NONE; | 3672 | return ERR_NONE; |
3673 | } | 3673 | } |
3674 | 3674 | ||
3675 | static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3675 | static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3676 | { | 3676 | { |
3677 | GSM_Error error; | 3677 | GSM_Error error; |
3678 | 3678 | ||
3679 | 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; |
3680 | /* Delete ToDo */ | 3680 | /* Delete ToDo */ |
3681 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3681 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3682 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3682 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3683 | /* Entry was empty => no error */ | 3683 | /* Entry was empty => no error */ |
3684 | return ERR_NONE; | 3684 | return ERR_NONE; |
3685 | } | 3685 | } |
3686 | error = ALCATEL_DeleteItem(s, ToDo->Location); | 3686 | error = ALCATEL_DeleteItem(s, ToDo->Location); |
3687 | if (error != ERR_NONE) return error; | 3687 | if (error != ERR_NONE) return error; |
3688 | /* Refresh list */ | 3688 | /* Refresh list */ |
3689 | 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; |
3690 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3690 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3691 | return ERR_NONE; | 3691 | return ERR_NONE; |
3692 | } | 3692 | } |
3693 | 3693 | ||
3694 | static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) | 3694 | static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) |
3695 | { | 3695 | { |
3696 | GSM_Alcatel_BinaryTypetype; | 3696 | GSM_Alcatel_BinaryTypetype; |
3697 | GSM_Error error; | 3697 | GSM_Error error; |
3698 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3698 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3699 | 3699 | ||
3700 | switch (Status->Type) { | 3700 | switch (Status->Type) { |
3701 | case Category_ToDo: type = TypeToDo; break; | 3701 | case Category_ToDo: type = TypeToDo; break; |
3702 | case Category_Phonebook: type = TypeContacts; break; | 3702 | case Category_Phonebook: type = TypeContacts; break; |
3703 | default: return ERR_NOTSUPPORTED; | 3703 | default: return ERR_NOTSUPPORTED; |
3704 | } | 3704 | } |
3705 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; | 3705 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; |
3706 | if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; | 3706 | if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; |
3707 | 3707 | ||
3708 | Status->Used = Priv->CurrentCategoriesCount; | 3708 | Status->Used = Priv->CurrentCategoriesCount; |
3709 | 3709 | ||
3710 | return ERR_NONE; | 3710 | return ERR_NONE; |
3711 | } | 3711 | } |
3712 | 3712 | ||
3713 | static GSM_Error ALCATEL_GetCategory(GSM_StateMachine *s, GSM_Category *Category) | 3713 | static GSM_Error ALCATEL_GetCategory(GSM_StateMachine *s, GSM_Category *Category) |
3714 | { | 3714 | { |
3715 | GSM_Alcatel_BinaryTypetype; | 3715 | GSM_Alcatel_BinaryTypetype; |
3716 | GSM_Error error; | 3716 | GSM_Error error; |
3717 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3717 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3718 | 3718 | ||
3719 | switch (Category->Type) { | 3719 | switch (Category->Type) { |
3720 | case Category_ToDo: type = TypeToDo; break; | 3720 | case Category_ToDo: type = TypeToDo; break; |
3721 | case Category_Phonebook: type = TypeContacts; break; | 3721 | case Category_Phonebook: type = TypeContacts; break; |
3722 | default: return ERR_NOTSUPPORTED; | 3722 | default: return ERR_NOTSUPPORTED; |
3723 | } | 3723 | } |
3724 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; | 3724 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; |
3725 | if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; | 3725 | if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; |
3726 | if ((error = ALCATEL_IsCategoryIdAvailable(s, Category->Location))!= ERR_NONE) return error; | 3726 | if ((error = ALCATEL_IsCategoryIdAvailable(s, Category->Location))!= ERR_NONE) return error; |
3727 | if ((error = ALCATEL_GetCategoryText(s, Category->Location))!= ERR_NONE) return error; | 3727 | if ((error = ALCATEL_GetCategoryText(s, Category->Location))!= ERR_NONE) return error; |
3728 | 3728 | ||
3729 | CopyUnicodeString(Category->Name, Priv->ReturnString); | 3729 | CopyUnicodeString(Category->Name, Priv->ReturnString); |
3730 | 3730 | ||
3731 | return ERR_NONE; | 3731 | return ERR_NONE; |
3732 | } | 3732 | } |
3733 | 3733 | ||
3734 | static GSM_Error ALCATEL_AddCategory(GSM_StateMachine *s, GSM_Category *Category) | 3734 | static GSM_Error ALCATEL_AddCategory(GSM_StateMachine *s, GSM_Category *Category) |
3735 | { | 3735 | { |
3736 | GSM_Alcatel_BinaryTypetype; | 3736 | GSM_Alcatel_BinaryTypetype; |
3737 | GSM_Error error; | 3737 | GSM_Error error; |
3738 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3738 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3739 | 3739 | ||
3740 | switch (Category->Type) { | 3740 | switch (Category->Type) { |
3741 | case Category_ToDo: type = TypeToDo; break; | 3741 | case Category_ToDo: type = TypeToDo; break; |
3742 | case Category_Phonebook: type = TypeContacts; break; | 3742 | case Category_Phonebook: type = TypeContacts; break; |
3743 | default: return ERR_NOTSUPPORTED; | 3743 | default: return ERR_NOTSUPPORTED; |
3744 | } | 3744 | } |
3745 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; | 3745 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; |
3746 | if ((error = ALCATEL_AddCategoryText(s, Category->Name))!= ERR_NONE) return error; | 3746 | if ((error = ALCATEL_AddCategoryText(s, Category->Name))!= ERR_NONE) return error; |
3747 | 3747 | ||
3748 | Category->Location = Priv->ReturnInt; | 3748 | Category->Location = Priv->ReturnInt; |
3749 | 3749 | ||
3750 | return ERR_NONE; | 3750 | return ERR_NONE; |
3751 | } | 3751 | } |
3752 | 3752 | ||
3753 | static GSM_Error ALCATEL_GetProductCode(GSM_StateMachine *s, char *value) | 3753 | static GSM_Error ALCATEL_GetProductCode(GSM_StateMachine *s, char *value) |
3754 | { | 3754 | { |
3755 | strcpy(value, s->Phone.Data.ModelInfo->model); | 3755 | strcpy(value, s->Phone.Data.ModelInfo->model); |
3756 | return ERR_NONE; | 3756 | return ERR_NONE; |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | static GSM_Error ALCATEL_DispatchMessage(GSM_StateMachine *s) | 3759 | static GSM_Error ALCATEL_DispatchMessage(GSM_StateMachine *s) |
3760 | { | 3760 | { |
3761 | if (s->Phone.Data.Priv.ALCATEL.Mode == ModeBinary) { | 3761 | if (s->Phone.Data.Priv.ALCATEL.Mode == ModeBinary) { |
3762 | return GSM_DispatchMessage(s); | 3762 | return GSM_DispatchMessage(s); |
3763 | } else { | 3763 | } else { |
3764 | return ATGEN_DispatchMessage(s); | 3764 | return ATGEN_DispatchMessage(s); |
3765 | } | 3765 | } |
3766 | } | 3766 | } |
3767 | 3767 | ||
3768 | static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine *s) | 3768 | static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine *s) |
3769 | { | 3769 | { |
3770 | /* All error values are just VERY wild guesses, but these seems to work | 3770 | /* All error values are just VERY wild guesses, but these seems to work |
3771 | * almost as expected ... | 3771 | * almost as expected ... |
3772 | */ | 3772 | */ |
3773 | switch (msg.Buffer[8]) { | 3773 | switch (msg.Buffer[8]) { |
3774 | case 0x00: /* no error */ | 3774 | case 0x00: /* no error */ |
3775 | return ERR_NONE; | 3775 | return ERR_NONE; |
3776 | case 0x10: /* same thing opened in phone menus */ | 3776 | case 0x10: /* same thing opened in phone menus */ |
3777 | return ERR_INSIDEPHONEMENU; | 3777 | return ERR_INSIDEPHONEMENU; |
3778 | case 0x13: | 3778 | case 0x13: |
3779 | /* This appears in more cases: | 3779 | /* This appears in more cases: |
3780 | *- phone needs PIN code | 3780 | *- phone needs PIN code |
3781 | *- we want to close not opened session | 3781 | *- we want to close not opened session |
3782 | * For normal users the second case shouldn't occur... | 3782 | * For normal users the second case shouldn't occur... |
3783 | */ | 3783 | */ |
3784 | return ERR_SECURITYERROR; | 3784 | return ERR_SECURITYERROR; |
3785 | case 0x14: /* Bad data */ | 3785 | case 0x14: /* Bad data */ |
3786 | case 0x2f: /* Closing session when not opened */ | 3786 | case 0x2f: /* Closing session when not opened */ |
3787 | case 0x1f: /* Bad in/out counter in packet/ack */ | 3787 | case 0x1f: /* Bad in/out counter in packet/ack */ |
3788 | case 0x0e: /* Openning session when not closed */ | 3788 | case 0x0e: /* Openning session when not closed */ |
3789 | case 0x0C: /* Bad id (item/database) */ | 3789 | case 0x0C: /* Bad id (item/database) */ |
3790 | case 0x11: /* Bad list id */ | 3790 | case 0x11: /* Bad list id */ |
3791 | case 0x2A: /* Nonexistant field/item id */ | 3791 | case 0x2A: /* Nonexistant field/item id */ |
3792 | case 0x35: /* Too long text */ | 3792 | case 0x35: /* Too long text */ |
3793 | return ERR_BUG; | 3793 | return ERR_BUG; |
3794 | case 0x23: /* Session opened */ | 3794 | case 0x23: /* Session opened */ |
3795 | case 0x80: /* Transfer started */ | 3795 | case 0x80: /* Transfer started */ |
3796 | return ERR_NONE; | 3796 | return ERR_NONE; |
3797 | case 0x82: /* Transfer canceled */ | 3797 | case 0x82: /* Transfer canceled */ |
3798 | return ERR_CANCELED; | 3798 | return ERR_CANCELED; |
3799 | default: | 3799 | default: |
3800 | 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]); |
3801 | return ERR_NONE; | 3801 | return ERR_NONE; |
3802 | } | 3802 | } |
3803 | } | 3803 | } |
3804 | 3804 | ||
3805 | static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) | 3805 | static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) |
3806 | { | 3806 | { |
3807 | 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); |
3808 | 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); |
3809 | return ERR_NONE; | 3809 | return ERR_NONE; |
3810 | } | 3810 | } |
3811 | 3811 | ||
3812 | static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) | 3812 | static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) |
3813 | { | 3813 | { |
3814 | GSM_Error error; | 3814 | GSM_Error error; |
3815 | 3815 | ||
3816 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 3816 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
3817 | return ATGEN_SetIncomingCB(s, enable); | 3817 | return ATGEN_SetIncomingCB(s, enable); |
3818 | } | 3818 | } |
3819 | 3819 | ||
3820 | static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) | 3820 | static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) |
3821 | { | 3821 | { |
3822 | GSM_Error error; | 3822 | GSM_Error error; |
3823 | 3823 | ||
3824 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 3824 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
3825 | return ATGEN_SetIncomingSMS(s, enable); | 3825 | return ATGEN_SetIncomingSMS(s, enable); |
3826 | } | 3826 | } |
3827 | 3827 | ||
3828 | static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable) | 3828 | static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable) |
3829 | { | 3829 | { |
3830 | GSM_Error error; | 3830 | GSM_Error error; |
3831 | 3831 | ||
3832 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 3832 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
3833 | return ATGEN_SetFastSMSSending(s, enable); | 3833 | return ATGEN_SetFastSMSSending(s, enable); |
3834 | } | 3834 | } |
3835 | 3835 | ||
3836 | static GSM_Reply_Function ALCATELReplyFunctions[] = { | 3836 | static GSM_Reply_Function ALCATELReplyFunctions[] = { |
3837 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, | 3837 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, |
3838 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, | 3838 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, |
3839 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, | 3839 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, |
3840 | {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, | 3840 | {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, |
3841 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, | 3841 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, |
3842 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, | 3842 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, |
3843 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, | 3843 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, |
3844 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, | 3844 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, |
3845 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, | 3845 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, |
3846 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, | 3846 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, |
3847 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, | 3847 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, |
3848 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, | 3848 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, |
3849 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, | 3849 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, |
3850 | {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, | 3850 | {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, |
3851 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, | 3851 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, |
3852 | {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, | 3852 | {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, |
3853 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, | 3853 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, |
3854 | {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, | 3854 | {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, |
3855 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, | 3855 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, |
3856 | {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, | 3856 | {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, |
3857 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, | 3857 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, |
3858 | {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, | 3858 | {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, |
3859 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, | 3859 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, |
3860 | {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, | 3860 | {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, |
3861 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, | 3861 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, |
3862 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, | 3862 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, |
3863 | {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, | 3863 | {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, |
3864 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, | 3864 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, |
3865 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, | 3865 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, |
3866 | {NULL, "\x00",0x00,0x00, ID_None } | 3866 | {NULL, "\x00",0x00,0x00, ID_None } |
3867 | }; | 3867 | }; |
3868 | 3868 | ||
3869 | GSM_Phone_Functions ALCATELPhone = { | 3869 | GSM_Phone_Functions ALCATELPhone = { |
3870 | /* 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 |
3871 | * they were ever really released, if yes add them here also. | 3871 | * they were ever really released, if yes add them here also. |
3872 | */ | 3872 | */ |
3873 | "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", | 3873 | "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", |
3874 | ALCATELReplyFunctions, | 3874 | ALCATELReplyFunctions, |
3875 | ALCATEL_Initialise, | 3875 | ALCATEL_Initialise, |
3876 | ALCATEL_Terminate, | 3876 | ALCATEL_Terminate, |
3877 | ALCATEL_DispatchMessage, | 3877 | ALCATEL_DispatchMessage, |
3878 | NOTSUPPORTED, /* ShowStartInfo */ | 3878 | NOTSUPPORTED, /* ShowStartInfo */ |
3879 | ALCATEL_GetManufacturer, | 3879 | ALCATEL_GetManufacturer, |
3880 | ALCATEL_GetModel, | 3880 | ALCATEL_GetModel, |
3881 | ALCATEL_GetFirmware, | 3881 | ALCATEL_GetFirmware, |
3882 | ALCATEL_GetIMEI, | 3882 | ALCATEL_GetIMEI, |
3883 | NOTSUPPORTED, /* GetOriginalIMEI */ | 3883 | NOTSUPPORTED, /* GetOriginalIMEI */ |
3884 | NOTSUPPORTED, /* GetManufactureMonth*/ | 3884 | NOTSUPPORTED, /* GetManufactureMonth*/ |
3885 | ALCATEL_GetProductCode, | 3885 | ALCATEL_GetProductCode, |
3886 | NOTSUPPORTED, /* GetHardware */ | 3886 | NOTSUPPORTED, /* GetHardware */ |
3887 | NOTSUPPORTED, /* GetPPM */ | 3887 | NOTSUPPORTED, /* GetPPM */ |
3888 | ALCATEL_GetSIMIMSI, | 3888 | ALCATEL_GetSIMIMSI, |
3889 | ALCATEL_GetDateTime, | 3889 | ALCATEL_GetDateTime, |
3890 | ALCATEL_SetDateTime, | 3890 | ALCATEL_SetDateTime, |
3891 | ALCATEL_GetAlarm, | 3891 | ALCATEL_GetAlarm, |
3892 | ALCATEL_SetAlarm, | 3892 | ALCATEL_SetAlarm, |
3893 | NOTSUPPORTED, /* GetLocale */ | 3893 | NOTSUPPORTED, /* GetLocale */ |
3894 | NOTSUPPORTED, /* SetLocale */ | 3894 | NOTSUPPORTED, /* SetLocale */ |
3895 | ALCATEL_PressKey, | 3895 | ALCATEL_PressKey, |
3896 | ALCATEL_Reset, | 3896 | ALCATEL_Reset, |
3897 | ALCATEL_ResetPhoneSettings, | 3897 | ALCATEL_ResetPhoneSettings, |
3898 | ALCATEL_EnterSecurityCode, | 3898 | ALCATEL_EnterSecurityCode, |
3899 | ALCATEL_GetSecurityStatus, | 3899 | ALCATEL_GetSecurityStatus, |
3900 | ALCATEL_GetDisplayStatus, | 3900 | ALCATEL_GetDisplayStatus, |
3901 | ALCATEL_SetAutoNetworkLogin, | 3901 | ALCATEL_SetAutoNetworkLogin, |
3902 | ALCATEL_GetBatteryCharge, | 3902 | ALCATEL_GetBatteryCharge, |
3903 | ALCATEL_GetSignalStrength, | 3903 | ALCATEL_GetSignalStrength, |
3904 | ALCATEL_GetNetworkInfo, | 3904 | ALCATEL_GetNetworkInfo, |
3905 | ALCATEL_GetCategory, | 3905 | ALCATEL_GetCategory, |
3906 | ALCATEL_AddCategory, | 3906 | ALCATEL_AddCategory, |
3907 | ALCATEL_GetCategoryStatus, | 3907 | ALCATEL_GetCategoryStatus, |
3908 | ALCATEL_GetMemoryStatus, | 3908 | ALCATEL_GetMemoryStatus, |
3909 | ALCATEL_GetMemory, | 3909 | ALCATEL_GetMemory, |
3910 | ALCATEL_GetNextMemory, | 3910 | ALCATEL_GetNextMemory, |
3911 | ALCATEL_SetMemory, | 3911 | ALCATEL_SetMemory, |
3912 | ALCATEL_AddMemory, | 3912 | ALCATEL_AddMemory, |
3913 | ALCATEL_DeleteMemory, | 3913 | ALCATEL_DeleteMemory, |
3914 | ALCATEL_DeleteAllMemory, | 3914 | ALCATEL_DeleteAllMemory, |
3915 | NOTSUPPORTED, /* GetSpeedDial */ | 3915 | NOTSUPPORTED, /* GetSpeedDial */ |
3916 | NOTSUPPORTED, /* SetSpeedDial */ | 3916 | NOTSUPPORTED, /* SetSpeedDial */ |
3917 | ALCATEL_GetSMSC, | 3917 | ALCATEL_GetSMSC, |
3918 | ALCATEL_SetSMSC, | 3918 | ALCATEL_SetSMSC, |
3919 | ALCATEL_GetSMSStatus, | 3919 | ALCATEL_GetSMSStatus, |
3920 | ALCATEL_GetSMS, | 3920 | ALCATEL_GetSMS, |
3921 | ALCATEL_GetNextSMS, | 3921 | ALCATEL_GetNextSMS, |
3922 | NOTSUPPORTED, /* SetSMS */ | 3922 | NOTSUPPORTED, /* SetSMS */ |
3923 | ALCATEL_AddSMS, | 3923 | ALCATEL_AddSMS, |
3924 | ALCATEL_DeleteSMS, | 3924 | ALCATEL_DeleteSMS, |
3925 | ALCATEL_SendSMS, | 3925 | ALCATEL_SendSMS, |
3926 | ALCATEL_SendSavedSMS, | 3926 | ALCATEL_SendSavedSMS, |
3927 | ALCATEL_SetFastSMSSending, | 3927 | ALCATEL_SetFastSMSSending, |
3928 | ALCATEL_SetIncomingSMS, | 3928 | ALCATEL_SetIncomingSMS, |
3929 | ALCATEL_SetIncomingCB, | 3929 | ALCATEL_SetIncomingCB, |
3930 | ALCATEL_GetSMSFolders, | 3930 | ALCATEL_GetSMSFolders, |
3931 | NOTSUPPORTED, /* AddSMSFolder */ | 3931 | NOTSUPPORTED, /* AddSMSFolder */ |
3932 | NOTSUPPORTED, /* DeleteSMSFolder */ | 3932 | NOTSUPPORTED, /* DeleteSMSFolder */ |
3933 | ALCATEL_DialVoice, | 3933 | ALCATEL_DialVoice, |
3934 | ALCATEL_AnswerCall, | 3934 | ALCATEL_AnswerCall, |
3935 | ALCATEL_CancelCall, | 3935 | ALCATEL_CancelCall, |
3936 | NOTSUPPORTED, /* HoldCall */ | 3936 | NOTSUPPORTED, /* HoldCall */ |
3937 | NOTSUPPORTED, /* UnholdCall */ | 3937 | NOTSUPPORTED, /* UnholdCall */ |
3938 | NOTSUPPORTED, /* ConferenceCall */ | 3938 | NOTSUPPORTED, /* ConferenceCall */ |
3939 | NOTSUPPORTED, /* SplitCall */ | 3939 | NOTSUPPORTED, /* SplitCall */ |
3940 | NOTSUPPORTED, /* TransferCall */ | 3940 | NOTSUPPORTED, /* TransferCall */ |
3941 | NOTSUPPORTED, /* SwitchCall */ | 3941 | NOTSUPPORTED, /* SwitchCall */ |
3942 | NOTSUPPORTED, /* GetCallDivert */ | 3942 | NOTSUPPORTED, /* GetCallDivert */ |
3943 | NOTSUPPORTED, /* SetCallDivert */ | 3943 | NOTSUPPORTED, /* SetCallDivert */ |
3944 | NOTSUPPORTED, /* CancelAllDiverts*/ | 3944 | NOTSUPPORTED, /* CancelAllDiverts*/ |
3945 | NONEFUNCTION, /* SetIncomingCall */ | 3945 | NONEFUNCTION, /* SetIncomingCall */ |
3946 | NOTSUPPORTED, /* SetIncomingUSSD */ | 3946 | NOTSUPPORTED, /* SetIncomingUSSD */ |
3947 | ALCATEL_SendDTMF, | 3947 | ALCATEL_SendDTMF, |
3948 | NOTSUPPORTED, /* GetRingtone */ | 3948 | NOTSUPPORTED, /* GetRingtone */ |
3949 | NOTSUPPORTED, /* SetRingtone */ | 3949 | NOTSUPPORTED, /* SetRingtone */ |
3950 | NOTSUPPORTED, /* GetRingtonesInfo*/ | 3950 | NOTSUPPORTED, /* GetRingtonesInfo*/ |
3951 | NOTSUPPORTED, /* DeleteUserRingtones*/ | 3951 | NOTSUPPORTED, /* DeleteUserRingtones*/ |
3952 | NOTSUPPORTED, /* PlayTone */ | 3952 | NOTSUPPORTED, /* PlayTone */ |
3953 | NOTSUPPORTED, /* GetWAPBookmark */ | 3953 | NOTSUPPORTED, /* GetWAPBookmark */ |
3954 | NOTSUPPORTED, /* SetWAPBookmark */ | 3954 | NOTSUPPORTED, /* SetWAPBookmark */ |
3955 | NOTSUPPORTED, /* DeleteWAPBookmark*/ | 3955 | NOTSUPPORTED, /* DeleteWAPBookmark*/ |
3956 | NOTSUPPORTED, /* GetWAPSettings */ | 3956 | NOTSUPPORTED, /* GetWAPSettings */ |
3957 | NOTSUPPORTED, /* SetWAPSettings */ | 3957 | NOTSUPPORTED, /* SetWAPSettings */ |
3958 | NOTSUPPORTED, /* GetMMSSettings */ | 3958 | NOTSUPPORTED, /* GetMMSSettings */ |
3959 | NOTSUPPORTED, /* SetMMSSettings */ | 3959 | NOTSUPPORTED, /* SetMMSSettings */ |
3960 | NOTSUPPORTED, /* GetSyncMLSettings*/ | 3960 | NOTSUPPORTED, /* GetSyncMLSettings*/ |
3961 | NOTSUPPORTED, /* SetSyncMLSettings*/ | 3961 | NOTSUPPORTED, /* SetSyncMLSettings*/ |
3962 | NOTSUPPORTED, /* GetChatSettings */ | 3962 | NOTSUPPORTED, /* GetChatSettings */ |
3963 | NOTSUPPORTED, /* SetChatSettings */ | 3963 | NOTSUPPORTED, /* SetChatSettings */ |
3964 | NOTSUPPORTED, /* GetBitmap */ | 3964 | NOTSUPPORTED, /* GetBitmap */ |
3965 | NOTSUPPORTED, /* SetBitmap */ | 3965 | NOTSUPPORTED, /* SetBitmap */ |
3966 | ALCATEL_GetToDoStatus, | 3966 | ALCATEL_GetToDoStatus, |
3967 | ALCATEL_GetToDo, | 3967 | ALCATEL_GetToDo, |
3968 | ALCATEL_GetNextToDo, | 3968 | ALCATEL_GetNextToDo, |
3969 | ALCATEL_SetToDo, | 3969 | ALCATEL_SetToDo, |
3970 | ALCATEL_AddToDo, | 3970 | ALCATEL_AddToDo, |
3971 | ALCATEL_DeleteToDo, | 3971 | ALCATEL_DeleteToDo, |
3972 | ALCATEL_DeleteAllToDo, | 3972 | ALCATEL_DeleteAllToDo, |
3973 | ALCATEL_GetCalendarStatus, | 3973 | ALCATEL_GetCalendarStatus, |
3974 | ALCATEL_GetCalendar, | 3974 | ALCATEL_GetCalendar, |
3975 | ALCATEL_GetNextCalendar, | 3975 | ALCATEL_GetNextCalendar, |
3976 | ALCATEL_SetCalendar, | 3976 | ALCATEL_SetCalendar, |
3977 | ALCATEL_AddCalendar, | 3977 | ALCATEL_AddCalendar, |
3978 | ALCATEL_DeleteCalendar, | 3978 | ALCATEL_DeleteCalendar, |
3979 | ALCATEL_DeleteAllCalendar, | 3979 | ALCATEL_DeleteAllCalendar, |
3980 | NOTSUPPORTED, /* GetCalendarSettings*/ | 3980 | NOTSUPPORTED, /* GetCalendarSettings*/ |
3981 | NOTSUPPORTED, /* SetCalendarSettings*/ | 3981 | NOTSUPPORTED, /* SetCalendarSettings*/ |
3982 | NOTSUPPORTED, /* GetNoteStatus */ | 3982 | NOTSUPPORTED, /* GetNoteStatus */ |
3983 | NOTSUPPORTED, /* GetNote */ | 3983 | NOTSUPPORTED, /* GetNote */ |
3984 | NOTSUPPORTED, /* GetNextNote */ | 3984 | NOTSUPPORTED, /* GetNextNote */ |
3985 | NOTSUPPORTED, /* SetNote */ | 3985 | NOTSUPPORTED, /* SetNote */ |
3986 | NOTSUPPORTED, /* AddNote */ | 3986 | NOTSUPPORTED, /* AddNote */ |
3987 | NOTSUPPORTED, /* DeleteNote */ | 3987 | NOTSUPPORTED, /* DeleteNote */ |
3988 | NOTSUPPORTED, /* DeleteAllNotes */ | 3988 | NOTSUPPORTED, /* DeleteAllNotes */ |
3989 | NOTSUPPORTED, /* GetProfile */ | 3989 | NOTSUPPORTED, /* GetProfile */ |
3990 | NOTSUPPORTED, /* SetProfile */ | 3990 | NOTSUPPORTED, /* SetProfile */ |
3991 | NOTSUPPORTED, /* GetFMStation */ | 3991 | NOTSUPPORTED, /* GetFMStation */ |
3992 | NOTSUPPORTED, /* SetFMStation */ | 3992 | NOTSUPPORTED, /* SetFMStation */ |
3993 | NOTSUPPORTED, /* ClearFMStations */ | 3993 | NOTSUPPORTED, /* ClearFMStations */ |
3994 | NOTSUPPORTED, /* GetNextFileFolder*/ | 3994 | NOTSUPPORTED, /* GetNextFileFolder*/ |
3995 | NOTSUPPORTED, /* GetFilePart */ | 3995 | NOTSUPPORTED, /* GetFilePart */ |
3996 | NOTSUPPORTED, /* AddFilePart */ | 3996 | NOTSUPPORTED, /* AddFilePart */ |
3997 | NOTSUPPORTED, /* GetFileSystemStatus*/ | 3997 | NOTSUPPORTED, /* GetFileSystemStatus*/ |
3998 | NOTSUPPORTED, /* DeleteFile */ | 3998 | NOTSUPPORTED, /* DeleteFile */ |
3999 | NOTSUPPORTED, /* AddFolder */ | 3999 | NOTSUPPORTED, /* AddFolder */ |
4000 | NOTSUPPORTED, /* GetGPRSAccessPoint*/ | 4000 | NOTSUPPORTED, /* GetGPRSAccessPoint*/ |
4001 | NOTSUPPORTED /* SetGPRSAccessPoint*/ | 4001 | NOTSUPPORTED /* SetGPRSAccessPoint*/ |
4002 | }; | 4002 | }; |
4003 | 4003 | ||
4004 | #endif | 4004 | #endif |
4005 | #endif | 4005 | #endif |
4006 | 4006 | ||
4007 | /* How should editor hadle tabs in this file? Add editor commands here. | 4007 | /* How should editor hadle tabs in this file? Add editor commands here. |
4008 | * vim: noexpandtab sw=8 ts=8 sts=8: | 4008 | * vim: noexpandtab sw=8 ts=8 sts=8: |
4009 | */ | 4009 | */ |
diff --git a/gammu/emb/gammu/depend/nokia/dct3.c b/gammu/emb/gammu/depend/nokia/dct3.c index b9e47ea..bda7532 100644 --- a/gammu/emb/gammu/depend/nokia/dct3.c +++ b/gammu/emb/gammu/depend/nokia/dct3.c | |||
@@ -1,807 +1,807 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | /* MSID by Walek */ | 2 | /* MSID by Walek */ |
3 | 3 | ||
4 | #include "../../../common/gsmstate.h" | 4 | #include "../../../common/gsmstate.h" |
5 | 5 | ||
6 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 6 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <signal.h> | 9 | #include <signal.h> |
10 | 10 | ||
11 | #include "../../../common/misc/coding/coding.h" | 11 | #include "../../../common/misc/coding/coding.h" |
12 | #include "../../../common/gsmcomon.h" | 12 | #include "../../../common/gsmcomon.h" |
13 | #include "../../../common/service/gsmpbk.h" | 13 | #include "../../../common/service/gsmpbk.h" |
14 | #include "../../../common/phone/nokia/dct3/dct3func.h" | 14 | #include "../../../common/phone/nokia/dct3/dct3func.h" |
15 | #include "../../../common/phone/pfunc.h" | 15 | #include "../../../common/phone/pfunc.h" |
16 | #include "../../gammu.h" | 16 | #include "../../gammu.h" |
17 | 17 | ||
18 | extern GSM_Reply_Function UserReplyFunctions3[]; | 18 | static GSM_Reply_Function UserReplyFunctions3[]; |
19 | 19 | ||
20 | /* ------- some usefull functions ----------------------------------------- */ | 20 | /* ------- some usefull functions ----------------------------------------- */ |
21 | 21 | ||
22 | GSM_Error CheckDCT3Only() | 22 | GSM_Error CheckDCT3Only() |
23 | { | 23 | { |
24 | bool found = false; | 24 | bool found = false; |
25 | 25 | ||
26 | /* Checking if phone is DCT3 */ | 26 | /* Checking if phone is DCT3 */ |
27 | #ifdef GSM_ENABLE_NOKIA6110 | 27 | #ifdef GSM_ENABLE_NOKIA6110 |
28 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 28 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
29 | #endif | 29 | #endif |
30 | #ifdef GSM_ENABLE_NOKIA7110 | 30 | #ifdef GSM_ENABLE_NOKIA7110 |
31 | if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 31 | if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
32 | #endif | 32 | #endif |
33 | #ifdef GSM_ENABLE_NOKIA9210 | 33 | #ifdef GSM_ENABLE_NOKIA9210 |
34 | if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 34 | if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
35 | #endif | 35 | #endif |
36 | if (!found) return ERR_NOTSUPPORTED; | 36 | if (!found) return ERR_NOTSUPPORTED; |
37 | 37 | ||
38 | if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && | 38 | if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && |
39 | s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_FBUS2BLUE && | 39 | s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_FBUS2BLUE && |
40 | s.ConnectionType!=GCT_FBUS2IRDA && s.ConnectionType!=GCT_IRDAPHONET && | 40 | s.ConnectionType!=GCT_FBUS2IRDA && s.ConnectionType!=GCT_IRDAPHONET && |
41 | s.ConnectionType!=GCT_BLUEFBUS2) { | 41 | s.ConnectionType!=GCT_BLUEFBUS2) { |
42 | return ERR_OTHERCONNECTIONREQUIRED; | 42 | return ERR_OTHERCONNECTIONREQUIRED; |
43 | } | 43 | } |
44 | return ERR_NONE; | 44 | return ERR_NONE; |
45 | } | 45 | } |
46 | 46 | ||
47 | static void CheckDCT3() | 47 | static void CheckDCT3() |
48 | { | 48 | { |
49 | GSM_Error error; | 49 | GSM_Error error; |
50 | 50 | ||
51 | error = CheckDCT3Only(); | 51 | error = CheckDCT3Only(); |
52 | switch (error) { | 52 | switch (error) { |
53 | case ERR_NOTSUPPORTED: | 53 | case ERR_NOTSUPPORTED: |
54 | Print_Error(ERR_NOTSUPPORTED); | 54 | Print_Error(ERR_NOTSUPPORTED); |
55 | break; | 55 | break; |
56 | case ERR_OTHERCONNECTIONREQUIRED: | 56 | case ERR_OTHERCONNECTIONREQUIRED: |
57 | printf("Can't do it with current phone protocol\n"); | 57 | printf("Can't do it with current phone protocol\n"); |
58 | GSM_TerminateConnection(&s); | 58 | GSM_TerminateConnection(&s); |
59 | exit(-1); | 59 | exit(-1); |
60 | default: | 60 | default: |
61 | break; | 61 | break; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | static bool answer_yes3(char *text) | 65 | static bool answer_yes3(char *text) |
66 | { | 66 | { |
67 | int len; | 67 | int len; |
68 | char ans[99]; | 68 | char ans[99]; |
69 | 69 | ||
70 | while (1) { | 70 | while (1) { |
71 | printf("%s (yes/no) ? ",text); | 71 | printf("%s (yes/no) ? ",text); |
72 | len=GetLine(stdin, ans, 99); | 72 | len=GetLine(stdin, ans, 99); |
73 | if (len==-1) exit(-1); | 73 | if (len==-1) exit(-1); |
74 | if (mystrncasecmp(ans, "yes",0)) return true; | 74 | if (mystrncasecmp(ans, "yes",0)) return true; |
75 | if (mystrncasecmp(ans, "no" ,0)) return false; | 75 | if (mystrncasecmp(ans, "no" ,0)) return false; |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | /* ------------------- functions ------------------------------------------- */ | 79 | /* ------------------- functions ------------------------------------------- */ |
80 | 80 | ||
81 | static FILE *DCT3T9File; | 81 | static FILE *DCT3T9File; |
82 | 82 | ||
83 | static GSM_Error DCT3_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s) | 83 | static GSM_Error DCT3_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s) |
84 | { | 84 | { |
85 | int DCT3T9Size; | 85 | int DCT3T9Size; |
86 | 86 | ||
87 | DCT3T9Size = msg.Length - 6; | 87 | DCT3T9Size = msg.Length - 6; |
88 | fwrite(msg.Buffer+6,1,DCT3T9Size,DCT3T9File); | 88 | fwrite(msg.Buffer+6,1,DCT3T9Size,DCT3T9File); |
89 | return ERR_NONE; | 89 | return ERR_NONE; |
90 | } | 90 | } |
91 | 91 | ||
92 | void DCT3GetT9(int argc, char *argv[]) | 92 | void DCT3GetT9(int argc, char *argv[]) |
93 | { | 93 | { |
94 | int i; | 94 | int i; |
95 | unsigned char req[] = {0x00, 0x01, 0xAE, 0x02, 0x00, | 95 | unsigned char req[] = {0x00, 0x01, 0xAE, 0x02, 0x00, |
96 | 0x00};/* Part number */ | 96 | 0x00};/* Part number */ |
97 | 97 | ||
98 | //"00 01 AE 00" gets some control values | 98 | //"00 01 AE 00" gets some control values |
99 | 99 | ||
100 | if (CheckDCT3Only()!=ERR_NONE) return; | 100 | if (CheckDCT3Only()!=ERR_NONE) return; |
101 | 101 | ||
102 | DCT3T9File = fopen("T9", "w"); | 102 | DCT3T9File = fopen("T9", "w"); |
103 | if (DCT3T9File == NULL) return; | 103 | if (DCT3T9File == NULL) return; |
104 | 104 | ||
105 | s.User.UserReplyFunctions=UserReplyFunctions3; | 105 | s.User.UserReplyFunctions=UserReplyFunctions3; |
106 | 106 | ||
107 | for (i=0;i<5;i++) { | 107 | for (i=0;i<5;i++) { |
108 | req[5] = i; | 108 | req[5] = i; |
109 | error=GSM_WaitFor (&s, req, 6, 0x40, 4, ID_User3); | 109 | error=GSM_WaitFor (&s, req, 6, 0x40, 4, ID_User3); |
110 | Print_Error(error); | 110 | Print_Error(error); |
111 | } | 111 | } |
112 | 112 | ||
113 | fclose(DCT3T9File); | 113 | fclose(DCT3T9File); |
114 | } | 114 | } |
115 | 115 | ||
116 | void DCT3VibraTest(int argc, char *argv[]) | 116 | void DCT3VibraTest(int argc, char *argv[]) |
117 | { | 117 | { |
118 | unsigned char ans[200]; | 118 | unsigned char ans[200]; |
119 | unsigned char SetLevel[4] = {0x00, 0x01, 0xA3, | 119 | unsigned char SetLevel[4] = {0x00, 0x01, 0xA3, |
120 | 0xff};/* Level */ | 120 | 0xff};/* Level */ |
121 | 121 | ||
122 | if (CheckDCT3Only()!=ERR_NONE) return; | 122 | if (CheckDCT3Only()!=ERR_NONE) return; |
123 | 123 | ||
124 | s.User.UserReplyFunctions=UserReplyFunctions3; | 124 | s.User.UserReplyFunctions=UserReplyFunctions3; |
125 | 125 | ||
126 | error=DCT3_EnableSecurity (&s, 0x01); | 126 | error=DCT3_EnableSecurity (&s, 0x01); |
127 | Print_Error(error); | 127 | Print_Error(error); |
128 | 128 | ||
129 | error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3); | 129 | error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3); |
130 | Print_Error(error); | 130 | Print_Error(error); |
131 | 131 | ||
132 | printf("Press any key to continue...\n"); | 132 | printf("Press any key to continue...\n"); |
133 | GetLine(stdin, ans, 99); | 133 | GetLine(stdin, ans, 99); |
134 | 134 | ||
135 | SetLevel[3] = 0x00; | 135 | SetLevel[3] = 0x00; |
136 | error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3); | 136 | error=GSM_WaitFor (&s, SetLevel, 4, 0x40, 4, ID_User3); |
137 | } | 137 | } |
138 | 138 | ||
139 | static GSM_Error DCT3_ReplyPhoneTests(GSM_Protocol_Message msg, GSM_StateMachine *s) | 139 | static GSM_Error DCT3_ReplyPhoneTests(GSM_Protocol_Message msg, GSM_StateMachine *s) |
140 | { | 140 | { |
141 | int i; | 141 | int i; |
142 | 142 | ||
143 | for (i=0;i<msg.Buffer[3];i++) { | 143 | for (i=0;i<msg.Buffer[3];i++) { |
144 | switch (i) { | 144 | switch (i) { |
145 | case 0: printf("Unknown(%02i) ",i);break; | 145 | case 0: printf("Unknown(%02i) ",i);break; |
146 | case 1: printf("MCU ROM checksum (startup)");break; | 146 | case 1: printf("MCU ROM checksum (startup)");break; |
147 | case 2: printf("MCU RAM interface (startup)");break; | 147 | case 2: printf("MCU RAM interface (startup)");break; |
148 | case 3: printf("MCU RAM component ");break; | 148 | case 3: printf("MCU RAM component ");break; |
149 | case 4: printf("MCU EEPROM interface (startup)");break; | 149 | case 4: printf("MCU EEPROM interface (startup)");break; |
150 | case 5: printf("MCU EEPROM component ");break; | 150 | case 5: printf("MCU EEPROM component ");break; |
151 | case 6: printf("Real Time Clock battery (startup)");break; | 151 | case 6: printf("Real Time Clock battery (startup)");break; |
152 | case 7: printf("CCONT interface (startup)");break; | 152 | case 7: printf("CCONT interface (startup)");break; |
153 | case 8: printf("AD converter (startup)");break; | 153 | case 8: printf("AD converter (startup)");break; |
154 | case 9: printf("SW Reset ");break; | 154 | case 9: printf("SW Reset ");break; |
155 | case 10:printf("Power Off ");break; | 155 | case 10:printf("Power Off ");break; |
156 | case 11:printf("Security Data ");break; | 156 | case 11:printf("Security Data ");break; |
157 | case 12:printf("EEPROM Tune checksum (startup)");break; | 157 | case 12:printf("EEPROM Tune checksum (startup)");break; |
158 | case 13:printf("PPM checksum (startup)");break; | 158 | case 13:printf("PPM checksum (startup)");break; |
159 | case 14:printf("MCU download DSP (startup)");break; | 159 | case 14:printf("MCU download DSP (startup)");break; |
160 | case 15:printf("DSP alive (startup)");break; | 160 | case 15:printf("DSP alive (startup)");break; |
161 | case 16:printf("COBBA serial (startup)");break; | 161 | case 16:printf("COBBA serial (startup)");break; |
162 | case 17:printf("COBBA paraller (startup)");break; | 162 | case 17:printf("COBBA paraller (startup)");break; |
163 | case 18:printf("EEPROM security checksum (startup)");break; | 163 | case 18:printf("EEPROM security checksum (startup)");break; |
164 | case 19:printf("PPM validity (startup)");break; | 164 | case 19:printf("PPM validity (startup)");break; |
165 | case 20:printf("Warranty state (startup)");break; | 165 | case 20:printf("Warranty state (startup)");break; |
166 | case 21:printf("Simlock check/SW version (startup)");break; | 166 | case 21:printf("Simlock check/SW version (startup)");break; |
167 | case 22:printf("IMEI check? ");break;/*from PC-Locals1.3.is OK?*/ | 167 | case 22:printf("IMEI check? ");break;/*from PC-Locals1.3.is OK?*/ |
168 | default:printf("Unknown(%02i) ",i);break; | 168 | default:printf("Unknown(%02i) ",i);break; |
169 | } | 169 | } |
170 | switch (msg.Buffer[4+i]) { | 170 | switch (msg.Buffer[4+i]) { |
171 | case 0: printf(" : passed"); break; | 171 | case 0: printf(" : passed"); break; |
172 | case 0xff:printf(" : not executed"); break; | 172 | case 0xff:printf(" : not executed"); break; |
173 | case 254: printf(" : fail"); break; | 173 | case 254: printf(" : fail"); break; |
174 | default: printf(" : result unknown(%i)",msg.Buffer[4+i]);break; | 174 | default: printf(" : result unknown(%i)",msg.Buffer[4+i]);break; |
175 | } | 175 | } |
176 | printf("\n"); | 176 | printf("\n"); |
177 | } | 177 | } |
178 | 178 | ||
179 | return ERR_NONE; | 179 | return ERR_NONE; |
180 | } | 180 | } |
181 | 181 | ||
182 | void DCT3SelfTests(int argc, char *argv[]) | 182 | void DCT3SelfTests(int argc, char *argv[]) |
183 | { | 183 | { |
184 | unsigned char buffer[3] = {0x00,0x01,0xcf}; | 184 | unsigned char buffer[3] = {0x00,0x01,0xcf}; |
185 | unsigned char buffer3[8] = {0x00,0x01,0xce,0x1d,0xfe,0x23,0x00,0x00}; | 185 | unsigned char buffer3[8] = {0x00,0x01,0xce,0x1d,0xfe,0x23,0x00,0x00}; |
186 | int i; | 186 | int i; |
187 | 187 | ||
188 | if (CheckDCT3Only()!=ERR_NONE) return; | 188 | if (CheckDCT3Only()!=ERR_NONE) return; |
189 | 189 | ||
190 | error=DCT3_EnableSecurity (&s, 0x01); | 190 | error=DCT3_EnableSecurity (&s, 0x01); |
191 | Print_Error(error); | 191 | Print_Error(error); |
192 | 192 | ||
193 | if (answer_yes3("Run all tests now ?")) { | 193 | if (answer_yes3("Run all tests now ?")) { |
194 | /* make almost all tests */ | 194 | /* make almost all tests */ |
195 | error = s.Protocol.Functions->WriteMessage(&s, buffer3, 8, 0x40); | 195 | error = s.Protocol.Functions->WriteMessage(&s, buffer3, 8, 0x40); |
196 | Print_Error(error); | 196 | Print_Error(error); |
197 | 197 | ||
198 | GSM_Terminate(); | 198 | GSM_Terminate(); |
199 | 199 | ||
200 | while (!false) { | 200 | while (!false) { |
201 | GSM_Init(false); | 201 | GSM_Init(false); |
202 | if (error==ERR_NONE) break; | 202 | if (error==ERR_NONE) break; |
203 | GSM_Terminate(); | 203 | GSM_Terminate(); |
204 | } | 204 | } |
205 | 205 | ||
206 | my_sleep(400); | 206 | my_sleep(400); |
207 | } | 207 | } |
208 | 208 | ||
209 | s.User.UserReplyFunctions=UserReplyFunctions3; | 209 | s.User.UserReplyFunctions=UserReplyFunctions3; |
210 | 210 | ||
211 | for (i=0;i<10;i++) { | 211 | for (i=0;i<10;i++) { |
212 | error=GSM_WaitFor (&s, buffer, 3, 0x40, 4, ID_User1); | 212 | error=GSM_WaitFor (&s, buffer, 3, 0x40, 4, ID_User1); |
213 | if (error == ERR_NONE) break; | 213 | if (error == ERR_NONE) break; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | struct DCT3ADCInfo { | 217 | struct DCT3ADCInfo { |
218 | char *name; | 218 | char *name; |
219 | char *unit; | 219 | char *unit; |
220 | int x; | 220 | int x; |
221 | intpos1; | 221 | intpos1; |
222 | intpos2; | 222 | intpos2; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static struct DCT3ADCInfo DCT3ADC[] = { | 225 | static struct DCT3ADCInfo DCT3ADC[] = { |
226 | {"Battery voltage:", "mV", 1, 3, 2}, | 226 | {"Battery voltage:", "mV", 1, 3, 2}, |
227 | // {"Charger voltage:", "mV", 1, -1, 7}, | 227 | // {"Charger voltage:", "mV", 1, -1, 7}, |
228 | // {"Charger current:", "mA", 1, -1, 5}, | 228 | // {"Charger current:", "mA", 1, -1, 5}, |
229 | {"Battery type:", "mAh", 1, 4, 3}, | 229 | {"Battery type:", "mAh", 1, 4, 3}, |
230 | {"Battery temperature:", "mK", 10, 5, 4}, | 230 | {"Battery temperature:", "mK", 10, 5, 4}, |
231 | // {"Accessory detection:", "mV", 1, -1, -1}, | 231 | // {"Accessory detection:", "mV", 1, -1, -1}, |
232 | {"RSSI:", "", 1, 2, -1}, | 232 | {"RSSI:", "", 1, 2, -1}, |
233 | // {"VCXO temperature:", "mV", 1, -1, -1}, | 233 | // {"VCXO temperature:", "mV", 1, -1, -1}, |
234 | // {"Hook information:", "mV", 1, -1, -1}, | 234 | // {"Hook information:", "mV", 1, -1, -1}, |
235 | 235 | ||
236 | {"", "", 1, -1, -1} | 236 | {"", "", 1, -1, -1} |
237 | }; | 237 | }; |
238 | 238 | ||
239 | unsigned char DCT3ADCBuf[200]; | 239 | unsigned char DCT3ADCBuf[200]; |
240 | int DCT3ADCInt; | 240 | int DCT3ADCInt; |
241 | 241 | ||
242 | static GSM_Error DCT3_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s) | 242 | static GSM_Error DCT3_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s) |
243 | { | 243 | { |
244 | switch (msg.Buffer[2]) { | 244 | switch (msg.Buffer[2]) { |
245 | case 0x68: | 245 | case 0x68: |
246 | memcpy(DCT3ADCBuf,msg.Buffer+4,msg.Length-4); | 246 | memcpy(DCT3ADCBuf,msg.Buffer+4,msg.Length-4); |
247 | return ERR_NONE; | 247 | return ERR_NONE; |
248 | case 0x91: | 248 | case 0x91: |
249 | DCT3ADCInt = msg.Buffer[4]*256+msg.Buffer[5]; | 249 | DCT3ADCInt = msg.Buffer[4]*256+msg.Buffer[5]; |
250 | return ERR_NONE; | 250 | return ERR_NONE; |
251 | } | 251 | } |
252 | return ERR_UNKNOWNRESPONSE; | 252 | return ERR_UNKNOWNRESPONSE; |
253 | } | 253 | } |
254 | 254 | ||
255 | void DCT3GetADC(int argc, char *argv[]) | 255 | void DCT3GetADC(int argc, char *argv[]) |
256 | { | 256 | { |
257 | int i = 0; | 257 | int i = 0; |
258 | unsigned charGetRaw[] = {0x00, 0x01, 0x68}; | 258 | unsigned charGetRaw[] = {0x00, 0x01, 0x68}; |
259 | unsigned charGetUnit[] = {0x00, 0x01, 0x91, | 259 | unsigned charGetUnit[] = {0x00, 0x01, 0x91, |
260 | 0x02}; /* Test number */ | 260 | 0x02}; /* Test number */ |
261 | 261 | ||
262 | if (CheckDCT3Only()!=ERR_NONE) return; | 262 | if (CheckDCT3Only()!=ERR_NONE) return; |
263 | 263 | ||
264 | s.User.UserReplyFunctions=UserReplyFunctions3; | 264 | s.User.UserReplyFunctions=UserReplyFunctions3; |
265 | 265 | ||
266 | error=DCT3_EnableSecurity (&s, 0x02); | 266 | error=DCT3_EnableSecurity (&s, 0x02); |
267 | Print_Error(error); | 267 | Print_Error(error); |
268 | 268 | ||
269 | error=GSM_WaitFor (&s, GetRaw, 3, 0x40, 6, ID_User3); | 269 | error=GSM_WaitFor (&s, GetRaw, 3, 0x40, 6, ID_User3); |
270 | Print_Error(error); | 270 | Print_Error(error); |
271 | 271 | ||
272 | while (1) { | 272 | while (1) { |
273 | printf(" %30s ",DCT3ADC[i].name); | 273 | printf(" %30s ",DCT3ADC[i].name); |
274 | if (DCT3ADC[i].pos1 != -1) { | 274 | if (DCT3ADC[i].pos1 != -1) { |
275 | printf("raw "); | 275 | printf("raw "); |
276 | printf("%10i ", | 276 | printf("%10i ", |
277 | DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2]*256+ | 277 | DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2]*256+ |
278 | DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2+1]); | 278 | DCT3ADCBuf[(DCT3ADC[i].pos1-1)*2+1]); |
279 | } | 279 | } |
280 | if (DCT3ADC[i].pos2 != -1) { | 280 | if (DCT3ADC[i].pos2 != -1) { |
281 | printf("unit result "); | 281 | printf("unit result "); |
282 | GetUnit[3] = DCT3ADC[i].pos2; | 282 | GetUnit[3] = DCT3ADC[i].pos2; |
283 | error=GSM_WaitFor (&s, GetUnit, 6, 0x40, 4, ID_User3); | 283 | error=GSM_WaitFor (&s, GetUnit, 6, 0x40, 4, ID_User3); |
284 | Print_Error(error); | 284 | Print_Error(error); |
285 | printf("%10i ",DCT3ADCInt*DCT3ADC[i].x); | 285 | printf("%10i ",DCT3ADCInt*DCT3ADC[i].x); |
286 | printf("%s\n",DCT3ADC[i].unit); | 286 | printf("%s\n",DCT3ADC[i].unit); |
287 | } | 287 | } |
288 | i++; | 288 | i++; |
289 | if (DCT3ADC[i].name[0] == 0x00) break; | 289 | if (DCT3ADC[i].name[0] == 0x00) break; |
290 | } | 290 | } |
291 | 291 | ||
292 | error=DCT3_EnableSecurity (&s, 0x01); | 292 | error=DCT3_EnableSecurity (&s, 0x01); |
293 | Print_Error(error); | 293 | Print_Error(error); |
294 | } | 294 | } |
295 | 295 | ||
296 | void DCT3DisplayTest(int argc, char *argv[]) | 296 | void DCT3DisplayTest(int argc, char *argv[]) |
297 | { | 297 | { |
298 | unsigned char ans[200]; | 298 | unsigned char ans[200]; |
299 | unsigned char req[] = {0x00, 0x01, 0xD3, | 299 | unsigned char req[] = {0x00, 0x01, 0xD3, |
300 | 0x03, /* 3=set, 2=clear */ | 300 | 0x03, /* 3=set, 2=clear */ |
301 | 0x03}; /* test number */ | 301 | 0x03}; /* test number */ |
302 | 302 | ||
303 | if (CheckDCT3Only()!=ERR_NONE) return; | 303 | if (CheckDCT3Only()!=ERR_NONE) return; |
304 | 304 | ||
305 | if (atoi(argv[2]) != 1 && atoi(argv[2]) != 2) { | 305 | if (atoi(argv[2]) != 1 && atoi(argv[2]) != 2) { |
306 | printf("Give 1 or 2 as test number\n"); | 306 | printf("Give 1 or 2 as test number\n"); |
307 | } | 307 | } |
308 | 308 | ||
309 | s.User.UserReplyFunctions=UserReplyFunctions3; | 309 | s.User.UserReplyFunctions=UserReplyFunctions3; |
310 | 310 | ||
311 | req[4] = atoi(argv[2]); | 311 | req[4] = atoi(argv[2]); |
312 | s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40); | 312 | s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40); |
313 | 313 | ||
314 | printf("Press any key to continue...\n"); | 314 | printf("Press any key to continue...\n"); |
315 | GetLine(stdin, ans, 99); | 315 | GetLine(stdin, ans, 99); |
316 | 316 | ||
317 | req[3] = 0x02; | 317 | req[3] = 0x02; |
318 | req[4] = 0x03; | 318 | req[4] = 0x03; |
319 | s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40); | 319 | s.Protocol.Functions->WriteMessage(&s, req, 5, 0x40); |
320 | 320 | ||
321 | error=DCT3_EnableSecurity (&s, 0x03); | 321 | error=DCT3_EnableSecurity (&s, 0x03); |
322 | Print_Error(error); | 322 | Print_Error(error); |
323 | } | 323 | } |
324 | 324 | ||
325 | void DCT3netmonitor(int argc, char *argv[]) | 325 | void DCT3netmonitor(int argc, char *argv[]) |
326 | { | 326 | { |
327 | char value[100]; | 327 | char value[100]; |
328 | 328 | ||
329 | GSM_Init(true); | 329 | GSM_Init(true); |
330 | 330 | ||
331 | CheckDCT3(); | 331 | CheckDCT3(); |
332 | 332 | ||
333 | error=DCT3_Netmonitor(&s, atoi(argv[2]), value); | 333 | error=DCT3_Netmonitor(&s, atoi(argv[2]), value); |
334 | Print_Error(error); | 334 | Print_Error(error); |
335 | 335 | ||
336 | printf("%s\n",value); | 336 | printf("%s\n",value); |
337 | #ifdef GSM_ENABLE_BEEP | 337 | #ifdef GSM_ENABLE_BEEP |
338 | if (atoi(argv[2]) == 243) GSM_PhoneBeep(); | 338 | if (atoi(argv[2]) == 243) GSM_PhoneBeep(); |
339 | #endif | 339 | #endif |
340 | GSM_Terminate(); | 340 | GSM_Terminate(); |
341 | } | 341 | } |
342 | 342 | ||
343 | static GSM_Error DCT3_ReplyGetMSID(GSM_Protocol_Message msg, GSM_StateMachine *s) | 343 | static GSM_Error DCT3_ReplyGetMSID(GSM_Protocol_Message msg, GSM_StateMachine *s) |
344 | { | 344 | { |
345 | int i; | 345 | int i; |
346 | 346 | ||
347 | printf("MSID : "); | 347 | printf("MSID : "); |
348 | for (i=5;i<18;i++) printf("%02x",msg.Buffer[i]); | 348 | for (i=5;i<18;i++) printf("%02x",msg.Buffer[i]); |
349 | printf("\n"); | 349 | printf("\n"); |
350 | return ERR_NONE; | 350 | return ERR_NONE; |
351 | } | 351 | } |
352 | 352 | ||
353 | static GSM_Error DCT3_ReplyGetDSPROM(GSM_Protocol_Message msg, GSM_StateMachine *s) | 353 | static GSM_Error DCT3_ReplyGetDSPROM(GSM_Protocol_Message msg, GSM_StateMachine *s) |
354 | { | 354 | { |
355 | printf("DSP ROM : %c\n",msg.Buffer[5]); | 355 | printf("DSP ROM : %c\n",msg.Buffer[5]); |
356 | return ERR_NONE; | 356 | return ERR_NONE; |
357 | } | 357 | } |
358 | 358 | ||
359 | static GSM_Error DCT3_ReplySimlockInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) | 359 | static GSM_Error DCT3_ReplySimlockInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) |
360 | { | 360 | { |
361 | inti, j; | 361 | inti, j; |
362 | charuni[100], buffer[50]; | 362 | charuni[100], buffer[50]; |
363 | 363 | ||
364 | j=0; | 364 | j=0; |
365 | for (i=0; i < 12; i++) { | 365 | for (i=0; i < 12; i++) { |
366 | if (j<24) { | 366 | if (j<24) { |
367 | uni[j]='0' + (msg.Buffer[9+i] >> 4); | 367 | uni[j]='0' + (msg.Buffer[9+i] >> 4); |
368 | j++; | 368 | j++; |
369 | } | 369 | } |
370 | if (j!=15) { | 370 | if (j!=15) { |
371 | if (j<24) { | 371 | if (j<24) { |
372 | uni[j]='0' + (msg.Buffer[9+i] & 0x0f); | 372 | uni[j]='0' + (msg.Buffer[9+i] & 0x0f); |
373 | j++; | 373 | j++; |
374 | } | 374 | } |
375 | } else j++; | 375 | } else j++; |
376 | } | 376 | } |
377 | 377 | ||
378 | strncpy(buffer,uni,5); | 378 | strncpy(buffer,uni,5); |
379 | buffer[5]=0; | 379 | buffer[5]=0; |
380 | printf("Simlock 1 : MCC+MNC %10s, %s, %s, counter %i\n", | 380 | printf("Simlock 1 : MCC+MNC %10s, %s, %s, counter %i\n", |
381 | buffer, | 381 | buffer, |
382 | ((msg.Buffer[6] & 1) == 1)==0?"opened":"CLOSED", | 382 | ((msg.Buffer[6] & 1) == 1)==0?"opened":"CLOSED", |
383 | ((msg.Buffer[5] & 1) != 1)==0?"user ":"factory", | 383 | ((msg.Buffer[5] & 1) != 1)==0?"user ":"factory", |
384 | msg.Buffer[21]); | 384 | msg.Buffer[21]); |
385 | 385 | ||
386 | strncpy(buffer,uni+16,4); | 386 | strncpy(buffer,uni+16,4); |
387 | buffer[4]=0; | 387 | buffer[4]=0; |
388 | printf("Simlock 2 : GID1 %10s, %s, %s, counter %i\n", | 388 | printf("Simlock 2 : GID1 %10s, %s, %s, counter %i\n", |
389 | buffer, | 389 | buffer, |
390 | ((msg.Buffer[6] & 4) == 4)==0?"opened":"CLOSED", | 390 | ((msg.Buffer[6] & 4) == 4)==0?"opened":"CLOSED", |
391 | ((msg.Buffer[5] & 4) != 4)==0?"user ":"factory", | 391 | ((msg.Buffer[5] & 4) != 4)==0?"user ":"factory", |
392 | msg.Buffer[23]); | 392 | msg.Buffer[23]); |
393 | 393 | ||
394 | strncpy(buffer,uni+20,4); | 394 | strncpy(buffer,uni+20,4); |
395 | buffer[4]=0; | 395 | buffer[4]=0; |
396 | printf("Simlock 3 : GID2 %10s, %s, %s, counter %i\n", | 396 | printf("Simlock 3 : GID2 %10s, %s, %s, counter %i\n", |
397 | buffer, | 397 | buffer, |
398 | ((msg.Buffer[6] & 8) == 8)==0?"opened":"CLOSED", | 398 | ((msg.Buffer[6] & 8) == 8)==0?"opened":"CLOSED", |
399 | ((msg.Buffer[5] & 8) != 8)==0?"user ":"factory", | 399 | ((msg.Buffer[5] & 8) != 8)==0?"user ":"factory", |
400 | msg.Buffer[24]); | 400 | msg.Buffer[24]); |
401 | 401 | ||
402 | strncpy(buffer,uni+5,10); | 402 | strncpy(buffer,uni+5,10); |
403 | buffer[10]=0; | 403 | buffer[10]=0; |
404 | printf("Simlock 4 : MSIN %10s, %s, %s, counter %i\n", | 404 | printf("Simlock 4 : MSIN %10s, %s, %s, counter %i\n", |
405 | buffer, | 405 | buffer, |
406 | ((msg.Buffer[6] & 2) == 2)==0?"opened":"CLOSED", | 406 | ((msg.Buffer[6] & 2) == 2)==0?"opened":"CLOSED", |
407 | ((msg.Buffer[5] & 2) != 2)==0?"user ":"factory", | 407 | ((msg.Buffer[5] & 2) != 2)==0?"user ":"factory", |
408 | msg.Buffer[22]); | 408 | msg.Buffer[22]); |
409 | 409 | ||
410 | return ERR_NONE; | 410 | return ERR_NONE; |
411 | } | 411 | } |
412 | 412 | ||
413 | static GSM_Error DCT3_ReplyGetMCUchkSum(GSM_Protocol_Message msg, GSM_StateMachine *s) | 413 | static GSM_Error DCT3_ReplyGetMCUchkSum(GSM_Protocol_Message msg, GSM_StateMachine *s) |
414 | { | 414 | { |
415 | int i; | 415 | int i; |
416 | 416 | ||
417 | if (msg.Buffer[3] == 0x12) printf("Language Pack: %c\n",msg.Buffer[5]); | 417 | if (msg.Buffer[3] == 0x12) printf("Language Pack: %c\n",msg.Buffer[5]); |
418 | if (msg.Buffer[3] == 0x02) { | 418 | if (msg.Buffer[3] == 0x02) { |
419 | printf("MCU checksum : "); | 419 | printf("MCU checksum : "); |
420 | for (i=5;i<9;i++) printf("%c",msg.Buffer[i]); | 420 | for (i=5;i<9;i++) printf("%c",msg.Buffer[i]); |
421 | printf("\n"); | 421 | printf("\n"); |
422 | } | 422 | } |
423 | return ERR_NONE; | 423 | return ERR_NONE; |
424 | } | 424 | } |
425 | 425 | ||
426 | static unsigned char MSID1; | 426 | static unsigned char MSID1; |
427 | 427 | ||
428 | GSM_Error DCT3_ReplyEnableSecurity2(GSM_Protocol_Message msg, GSM_StateMachine *s) | 428 | GSM_Error DCT3_ReplyEnableSecurity2(GSM_Protocol_Message msg, GSM_StateMachine *s) |
429 | { | 429 | { |
430 | smprintf(s, "State of security commands set\n"); | 430 | smprintf(s, "State of security commands set\n"); |
431 | MSID1 = msg.Buffer[5]; | 431 | MSID1 = msg.Buffer[5]; |
432 | return ERR_NONE; | 432 | return ERR_NONE; |
433 | } | 433 | } |
434 | 434 | ||
435 | void DCT3Info(int argc, char *argv[]) | 435 | void DCT3Info(int argc, char *argv[]) |
436 | { | 436 | { |
437 | unsigned char req[] = {0x00, 0x01, 0x8A, 0x00}; /* Get simlock info */ | 437 | unsigned char req[] = {0x00, 0x01, 0x8A, 0x00}; /* Get simlock info */ |
438 | unsigned char req2[] = {0x00, 0x01, 0xb4, 0x00, 0x00}; /* Get MSID */ | 438 | unsigned char req2[] = {0x00, 0x01, 0xb4, 0x00, 0x00}; /* Get MSID */ |
439 | unsigned char req3[] = {0x00, 0x01, 0xc8, 0x02}; /* Get MCU chksum */ | 439 | unsigned char req3[] = {0x00, 0x01, 0xc8, 0x02}; /* Get MCU chksum */ |
440 | unsigned char req4[] = {0x00, 0x01, 0xc8, 0x09}; /* Get DSP ROM */ | 440 | unsigned char req4[] = {0x00, 0x01, 0xc8, 0x09}; /* Get DSP ROM */ |
441 | 441 | ||
442 | if (CheckDCT3Only()!=ERR_NONE) return; | 442 | if (CheckDCT3Only()!=ERR_NONE) return; |
443 | 443 | ||
444 | s.User.UserReplyFunctions=UserReplyFunctions3; | 444 | s.User.UserReplyFunctions=UserReplyFunctions3; |
445 | 445 | ||
446 | error=DCT3_EnableSecurity (&s, 0x01); | 446 | error=DCT3_EnableSecurity (&s, 0x01); |
447 | Print_Error(error); | 447 | Print_Error(error); |
448 | 448 | ||
449 | error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User3); | 449 | error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User3); |
450 | Print_Error(error); | 450 | Print_Error(error); |
451 | 451 | ||
452 | req2[3] = MSID1; | 452 | req2[3] = MSID1; |
453 | req2[4] = req2[2] + req2[3]; | 453 | req2[4] = req2[2] + req2[3]; |
454 | error=GSM_WaitFor (&s, req2, 5, 0x40, 4, ID_User8); | 454 | error=GSM_WaitFor (&s, req2, 5, 0x40, 4, ID_User8); |
455 | Print_Error(error); | 455 | Print_Error(error); |
456 | 456 | ||
457 | error=GSM_WaitFor (&s, req3, 4, 0x40, 4, ID_User9); | 457 | error=GSM_WaitFor (&s, req3, 4, 0x40, 4, ID_User9); |
458 | Print_Error(error); | 458 | Print_Error(error); |
459 | 459 | ||
460 | error=GSM_WaitFor (&s, req4, 4, 0x40, 4, ID_User10); | 460 | error=GSM_WaitFor (&s, req4, 4, 0x40, 4, ID_User10); |
461 | Print_Error(error); | 461 | Print_Error(error); |
462 | } | 462 | } |
463 | 463 | ||
464 | static GSM_Error DCT3_ReplyResetTest36(GSM_Protocol_Message msg, GSM_StateMachine *s) | 464 | static GSM_Error DCT3_ReplyResetTest36(GSM_Protocol_Message msg, GSM_StateMachine *s) |
465 | { | 465 | { |
466 | printf("Netmonitor test 36 cleaned OK\n"); | 466 | printf("Netmonitor test 36 cleaned OK\n"); |
467 | return ERR_NONE; | 467 | return ERR_NONE; |
468 | } | 468 | } |
469 | 469 | ||
470 | void DCT3ResetTest36(int argc, char *argv[]) | 470 | void DCT3ResetTest36(int argc, char *argv[]) |
471 | { | 471 | { |
472 | unsigned char req[] = {0x00, 0x01, 0x65, 0x40, 0x00}; /* Reset test 36 in netmon */ | 472 | unsigned char req[] = {0x00, 0x01, 0x65, 0x40, 0x00}; /* Reset test 36 in netmon */ |
473 | 473 | ||
474 | GSM_Init(true); | 474 | GSM_Init(true); |
475 | 475 | ||
476 | CheckDCT3(); | 476 | CheckDCT3(); |
477 | 477 | ||
478 | error=DCT3_EnableSecurity (&s, 0x01); | 478 | error=DCT3_EnableSecurity (&s, 0x01); |
479 | Print_Error(error); | 479 | Print_Error(error); |
480 | 480 | ||
481 | s.User.UserReplyFunctions=UserReplyFunctions3; | 481 | s.User.UserReplyFunctions=UserReplyFunctions3; |
482 | 482 | ||
483 | error=GSM_WaitFor (&s, req, 5, 0x40, 4, ID_User2); | 483 | error=GSM_WaitFor (&s, req, 5, 0x40, 4, ID_User2); |
484 | Print_Error(error); | 484 | Print_Error(error); |
485 | 485 | ||
486 | #ifdef GSM_ENABLE_BEEP | 486 | #ifdef GSM_ENABLE_BEEP |
487 | GSM_PhoneBeep(); | 487 | GSM_PhoneBeep(); |
488 | #endif | 488 | #endif |
489 | GSM_Terminate(); | 489 | GSM_Terminate(); |
490 | } | 490 | } |
491 | 491 | ||
492 | static unsigned char PPS[32]; /* Product Profile Settings */ | 492 | static unsigned char PPS[32]; /* Product Profile Settings */ |
493 | 493 | ||
494 | static GSM_Error DCT3_ReplyGetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) | 494 | static GSM_Error DCT3_ReplyGetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) |
495 | { | 495 | { |
496 | int i,j,z; | 496 | int i,j,z; |
497 | 497 | ||
498 | #ifdef DEBUG | 498 | #ifdef DEBUG |
499 | dbgprintf("Product Profile Settings received -"); | 499 | dbgprintf("Product Profile Settings received -"); |
500 | for (i=0;i<4;i++) dbgprintf(" %02x",msg.Buffer[3+i]); | 500 | for (i=0;i<4;i++) dbgprintf(" %02x",msg.Buffer[3+i]); |
501 | dbgprintf("\n"); | 501 | dbgprintf("\n"); |
502 | #endif | 502 | #endif |
503 | j=128;z=0; | 503 | j=128;z=0; |
504 | for (i=0;i<32;i++) { | 504 | for (i=0;i<32;i++) { |
505 | PPS[i]='0'; | 505 | PPS[i]='0'; |
506 | if (msg.Buffer[z+3]&j) PPS[i]='1'; | 506 | if (msg.Buffer[z+3]&j) PPS[i]='1'; |
507 | if (j==1) { | 507 | if (j==1) { |
508 | j=128; | 508 | j=128; |
509 | z++; | 509 | z++; |
510 | } else j=j/2; | 510 | } else j=j/2; |
511 | } | 511 | } |
512 | #ifdef DEBUG | 512 | #ifdef DEBUG |
513 | dbgprintf("After decoding: "); | 513 | dbgprintf("After decoding: "); |
514 | for (i=0;i<32;i++) dbgprintf("%c",PPS[i]); | 514 | for (i=0;i<32;i++) dbgprintf("%c",PPS[i]); |
515 | dbgprintf("\n"); | 515 | dbgprintf("\n"); |
516 | #endif | 516 | #endif |
517 | return ERR_NONE; | 517 | return ERR_NONE; |
518 | } | 518 | } |
519 | 519 | ||
520 | static GSM_Error DCT3_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) | 520 | static GSM_Error DCT3_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) |
521 | { | 521 | { |
522 | printf("Setting done OK\n"); | 522 | printf("Setting done OK\n"); |
523 | return ERR_NONE; | 523 | return ERR_NONE; |
524 | } | 524 | } |
525 | 525 | ||
526 | void DCT3SetPhoneMenus(int argc, char *argv[]) | 526 | void DCT3SetPhoneMenus(int argc, char *argv[]) |
527 | { | 527 | { |
528 | char value[100]; | 528 | char value[100]; |
529 | int i,j,z; | 529 | int i,j,z; |
530 | unsigned char reqGet[] = {0x00, 0x01, 0x6a}; | 530 | unsigned char reqGet[] = {0x00, 0x01, 0x6a}; |
531 | unsigned char reqSet[] = { | 531 | unsigned char reqSet[] = { |
532 | 0x00, 0x01, 0x6b, | 532 | 0x00, 0x01, 0x6b, |
533 | 0x00, 0x00, 0x00, 0x00 }; /* bytes with Product Profile Setings */ | 533 | 0x00, 0x00, 0x00, 0x00 }; /* bytes with Product Profile Setings */ |
534 | 534 | ||
535 | if (CheckDCT3Only()!=ERR_NONE) return; | 535 | if (CheckDCT3Only()!=ERR_NONE) return; |
536 | 536 | ||
537 | error=DCT3_EnableSecurity (&s, 0x01); | 537 | error=DCT3_EnableSecurity (&s, 0x01); |
538 | Print_Error(error); | 538 | Print_Error(error); |
539 | 539 | ||
540 | s.User.UserReplyFunctions=UserReplyFunctions3; | 540 | s.User.UserReplyFunctions=UserReplyFunctions3; |
541 | 541 | ||
542 | error=GSM_WaitFor (&s, reqGet, 3, 0x40, 4, ID_User4); | 542 | error=GSM_WaitFor (&s, reqGet, 3, 0x40, 4, ID_User4); |
543 | Print_Error(error); | 543 | Print_Error(error); |
544 | 544 | ||
545 | printf("ALS : enabling menu\n"); | 545 | printf("ALS : enabling menu\n"); |
546 | PPS[10] = '1'; | 546 | PPS[10] = '1'; |
547 | 547 | ||
548 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.87) { | 548 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.87) { |
549 | printf("3310: enabling control of SMS charsets\n"); | 549 | printf("3310: enabling control of SMS charsets\n"); |
550 | PPS[11] = '0';//0 = ON, 1 = OFF | 550 | PPS[11] = '0';//0 = ON, 1 = OFF |
551 | } | 551 | } |
552 | if (!strcmp(s.Phone.Data.ModelInfo->model,"6150")) { | 552 | if (!strcmp(s.Phone.Data.ModelInfo->model,"6150")) { |
553 | printf("6150: enabling WellMate menu\n"); | 553 | printf("6150: enabling WellMate menu\n"); |
554 | PPS[18] = '1'; | 554 | PPS[18] = '1'; |
555 | } | 555 | } |
556 | /* FIXME */ | 556 | /* FIXME */ |
557 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3210")) { | 557 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3210")) { |
558 | printf("3210: enabling vibra menu\n"); | 558 | printf("3210: enabling vibra menu\n"); |
559 | PPS[24] = '1'; | 559 | PPS[24] = '1'; |
560 | } | 560 | } |
561 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.13) { | 561 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3310") && s.Phone.Data.VerNum>5.13) { |
562 | printf("3310: enabling 3315 features\n"); | 562 | printf("3310: enabling 3315 features\n"); |
563 | PPS[25] = '1'; | 563 | PPS[25] = '1'; |
564 | } | 564 | } |
565 | /* FIXME */ | 565 | /* FIXME */ |
566 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3210") && s.Phone.Data.VerNum>=5.31) { | 566 | if (!strcmp(s.Phone.Data.ModelInfo->model,"3210") && s.Phone.Data.VerNum>=5.31) { |
567 | printf("3210: enabling React and Logic game\n"); | 567 | printf("3210: enabling React and Logic game\n"); |
568 | PPS[26] = '1'; | 568 | PPS[26] = '1'; |
569 | } | 569 | } |
570 | 570 | ||
571 | #ifdef DEBUG | 571 | #ifdef DEBUG |
572 | dbgprintf("After settings: "); | 572 | dbgprintf("After settings: "); |
573 | for (i=0;i<32;i++) dbgprintf("%c",PPS[i]); | 573 | for (i=0;i<32;i++) dbgprintf("%c",PPS[i]); |
574 | dbgprintf("\n"); | 574 | dbgprintf("\n"); |
575 | #endif | 575 | #endif |
576 | 576 | ||
577 | j=128;z=0; | 577 | j=128;z=0; |
578 | for (i=0;i<32;i++) { | 578 | for (i=0;i<32;i++) { |
579 | if (PPS[i]=='1') reqSet[z+3]=reqSet[z+3]+j; | 579 | if (PPS[i]=='1') reqSet[z+3]=reqSet[z+3]+j; |
580 | if (j==1) { | 580 | if (j==1) { |
581 | j=128; | 581 | j=128; |
582 | z++; | 582 | z++; |
583 | } else j=j/2; | 583 | } else j=j/2; |
584 | } | 584 | } |
585 | 585 | ||
586 | //reqSet[3]=0xe7; | 586 | //reqSet[3]=0xe7; |
587 | //reqSet[4]=0x25; | 587 | //reqSet[4]=0x25; |
588 | //reqSet[5]=0x00; | 588 | //reqSet[5]=0x00; |
589 | //reqSet[6]=0xe0; | 589 | //reqSet[6]=0xe0; |
590 | 590 | ||
591 | error=GSM_WaitFor (&s, reqSet, 7, 0x40, 4, ID_User4); | 591 | error=GSM_WaitFor (&s, reqSet, 7, 0x40, 4, ID_User4); |
592 | Print_Error(error); | 592 | Print_Error(error); |
593 | 593 | ||
594 | printf("Enabling netmonitor\n"); | 594 | printf("Enabling netmonitor\n"); |
595 | error=DCT3_Netmonitor(&s, 243, value); | 595 | error=DCT3_Netmonitor(&s, 243, value); |
596 | Print_Error(error); | 596 | Print_Error(error); |
597 | } | 597 | } |
598 | 598 | ||
599 | static GSM_Error DCT3_Reply61GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) | 599 | static GSM_Error DCT3_Reply61GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) |
600 | { | 600 | { |
601 | printf("Security Code is \"%s\"\n",msg.Buffer+5); | 601 | printf("Security Code is \"%s\"\n",msg.Buffer+5); |
602 | return ERR_NONE; | 602 | return ERR_NONE; |
603 | } | 603 | } |
604 | 604 | ||
605 | static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) | 605 | static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) |
606 | { | 606 | { |
607 | printf("Security Code is \"%s\"\n",msg.Buffer+6); | 607 | printf("Security Code is \"%s\"\n",msg.Buffer+6); |
608 | return ERR_NONE; | 608 | return ERR_NONE; |
609 | } | 609 | } |
610 | 610 | ||
611 | void DCT3GetSecurityCode(int argc, char *argv[]) | 611 | void DCT3GetSecurityCode(int argc, char *argv[]) |
612 | { | 612 | { |
613 | #ifdef GSM_ENABLE_NOKIA6110 | 613 | #ifdef GSM_ENABLE_NOKIA6110 |
614 | unsigned char req6110[] = {0x00, 0x01, 0x6e, | 614 | unsigned char req6110[] = {0x00, 0x01, 0x6e, |
615 | 0x01};/* Code type */ | 615 | 0x01};/* Code type */ |
616 | #endif | 616 | #endif |
617 | #if defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210) | 617 | #if defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210) |
618 | unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee, | 618 | unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee, |
619 | 0x1c};/* Setting */ | 619 | 0x1c};/* Setting */ |
620 | #endif | 620 | #endif |
621 | 621 | ||
622 | if (CheckDCT3Only()!=ERR_NONE) return; | 622 | if (CheckDCT3Only()!=ERR_NONE) return; |
623 | 623 | ||
624 | error=DCT3_EnableSecurity (&s, 0x01); | 624 | error=DCT3_EnableSecurity (&s, 0x01); |
625 | Print_Error(error); | 625 | Print_Error(error); |
626 | 626 | ||
627 | s.User.UserReplyFunctions=UserReplyFunctions3; | 627 | s.User.UserReplyFunctions=UserReplyFunctions3; |
628 | 628 | ||
629 | #ifdef GSM_ENABLE_NOKIA6110 | 629 | #ifdef GSM_ENABLE_NOKIA6110 |
630 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { | 630 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { |
631 | error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6); | 631 | error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6); |
632 | } | 632 | } |
633 | #endif | 633 | #endif |
634 | #ifdef GSM_ENABLE_NOKIA7110 | 634 | #ifdef GSM_ENABLE_NOKIA7110 |
635 | if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { | 635 | if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { |
636 | error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6); | 636 | error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6); |
637 | } | 637 | } |
638 | #endif | 638 | #endif |
639 | #ifdef GSM_ENABLE_NOKIA9210 | 639 | #ifdef GSM_ENABLE_NOKIA9210 |
640 | if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { | 640 | if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { |
641 | error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6); | 641 | error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6); |
642 | } | 642 | } |
643 | #endif | 643 | #endif |
644 | Print_Error(error); | 644 | Print_Error(error); |
645 | } | 645 | } |
646 | 646 | ||
647 | #ifdef GSM_ENABLE_NOKIA6110 | 647 | #ifdef GSM_ENABLE_NOKIA6110 |
648 | 648 | ||
649 | static GSM_Error DCT3_ReplyGetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s) | 649 | static GSM_Error DCT3_ReplyGetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s) |
650 | { | 650 | { |
651 | unsigned char buffer[10]; | 651 | unsigned char buffer[10]; |
652 | 652 | ||
653 | NOKIA_DecodeNetworkCode(msg.Buffer+5, buffer); | 653 | NOKIA_DecodeNetworkCode(msg.Buffer+5, buffer); |
654 | buffer[6] = 0; | 654 | buffer[6] = 0; |
655 | printf("Network : %s (%s ",buffer,DecodeUnicodeString(GSM_GetNetworkName(buffer))); | 655 | printf("Network : %s (%s ",buffer,DecodeUnicodeString(GSM_GetNetworkName(buffer))); |
656 | printf(", %s)\n", DecodeUnicodeString(GSM_GetCountryName(buffer))); | 656 | printf(", %s)\n", DecodeUnicodeString(GSM_GetCountryName(buffer))); |
657 | printf("Name : \"%s\"\n",msg.Buffer+8); | 657 | printf("Name : \"%s\"\n",msg.Buffer+8); |
658 | 658 | ||
659 | return ERR_NONE; | 659 | return ERR_NONE; |
660 | } | 660 | } |
661 | 661 | ||
662 | void DCT3GetOperatorName(int argc, char *argv[]) | 662 | void DCT3GetOperatorName(int argc, char *argv[]) |
663 | { | 663 | { |
664 | unsigned char req[] = {0x00,0x01,0x8c,0x00}; | 664 | unsigned char req[] = {0x00,0x01,0x8c,0x00}; |
665 | 665 | ||
666 | GSM_Init(true); | 666 | GSM_Init(true); |
667 | 667 | ||
668 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); | 668 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); |
669 | CheckDCT3(); | 669 | CheckDCT3(); |
670 | 670 | ||
671 | error=DCT3_EnableSecurity (&s, 0x01); | 671 | error=DCT3_EnableSecurity (&s, 0x01); |
672 | Print_Error(error); | 672 | Print_Error(error); |
673 | 673 | ||
674 | s.User.UserReplyFunctions=UserReplyFunctions3; | 674 | s.User.UserReplyFunctions=UserReplyFunctions3; |
675 | 675 | ||
676 | error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User5); | 676 | error=GSM_WaitFor (&s, req, 4, 0x40, 4, ID_User5); |
677 | Print_Error(error); | 677 | Print_Error(error); |
678 | 678 | ||
679 | GSM_Terminate(); | 679 | GSM_Terminate(); |
680 | } | 680 | } |
681 | 681 | ||
682 | static GSM_Error DCT3_ReplySetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s) | 682 | static GSM_Error DCT3_ReplySetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s) |
683 | { | 683 | { |
684 | printf("Operator name set OK\n"); | 684 | printf("Operator name set OK\n"); |
685 | return ERR_NONE; | 685 | return ERR_NONE; |
686 | } | 686 | } |
687 | 687 | ||
688 | void DCT3SetOperatorName(int argc, char *argv[]) | 688 | void DCT3SetOperatorName(int argc, char *argv[]) |
689 | { | 689 | { |
690 | int i = 0; | 690 | int i = 0; |
691 | unsigned char req[256] = {0x00,0x01,0x8b,0x00, | 691 | unsigned char req[256] = {0x00,0x01,0x8b,0x00, |
692 | 0x00,0x00, /* MCC */ | 692 | 0x00,0x00, /* MCC */ |
693 | 0x00}; /* MNC */ | 693 | 0x00}; /* MNC */ |
694 | 694 | ||
695 | GSM_Init(true); | 695 | GSM_Init(true); |
696 | 696 | ||
697 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); | 697 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); |
698 | CheckDCT3(); | 698 | CheckDCT3(); |
699 | 699 | ||
700 | error=DCT3_EnableSecurity (&s, 0x01); | 700 | error=DCT3_EnableSecurity (&s, 0x01); |
701 | Print_Error(error); | 701 | Print_Error(error); |
702 | 702 | ||
703 | s.User.UserReplyFunctions=UserReplyFunctions3; | 703 | s.User.UserReplyFunctions=UserReplyFunctions3; |
704 | 704 | ||
705 | switch (argc) { | 705 | switch (argc) { |
706 | case 2: | 706 | case 2: |
707 | case 3:NOKIA_EncodeNetworkCode(req+4,"000 00"); | 707 | case 3:NOKIA_EncodeNetworkCode(req+4,"000 00"); |
708 | req[7] = 0x00; | 708 | req[7] = 0x00; |
709 | i = 1; | 709 | i = 1; |
710 | break; | 710 | break; |
711 | case 4: NOKIA_EncodeNetworkCode(req+4,argv[2]); | 711 | case 4: NOKIA_EncodeNetworkCode(req+4,argv[2]); |
712 | strncpy(req+7,argv[3],200); | 712 | strncpy(req+7,argv[3],200); |
713 | i = strlen(argv[3]); | 713 | i = strlen(argv[3]); |
714 | } | 714 | } |
715 | 715 | ||
716 | error=GSM_WaitFor (&s, req, 8+i, 0x40, 4, ID_User7); | 716 | error=GSM_WaitFor (&s, req, 8+i, 0x40, 4, ID_User7); |
717 | Print_Error(error); | 717 | Print_Error(error); |
718 | 718 | ||
719 | GSM_Terminate(); | 719 | GSM_Terminate(); |
720 | } | 720 | } |
721 | 721 | ||
722 | static GSM_Error DCT3_ReplyDisplayOutput(GSM_Protocol_Message msg, GSM_StateMachine *s) | 722 | static GSM_Error DCT3_ReplyDisplayOutput(GSM_Protocol_Message msg, GSM_StateMachine *s) |
723 | { | 723 | { |
724 | unsigned char buf[100]; | 724 | unsigned char buf[100]; |
725 | 725 | ||
726 | switch (msg.Buffer[3]) { | 726 | switch (msg.Buffer[3]) { |
727 | case 0x50: | 727 | case 0x50: |
728 | dbgprintf("Display string received\n"); | 728 | dbgprintf("Display string received\n"); |
729 | memcpy(buf,msg.Buffer+8,msg.Buffer[7]*2); | 729 | memcpy(buf,msg.Buffer+8,msg.Buffer[7]*2); |
730 | buf[msg.Buffer[7]*2] = 0; | 730 | buf[msg.Buffer[7]*2] = 0; |
731 | buf[msg.Buffer[7]*2+1] = 0; | 731 | buf[msg.Buffer[7]*2+1] = 0; |
732 | printf("X=%i, Y=%i, Text=\"%s\"\n",msg.Buffer[6],msg.Buffer[5],DecodeUnicodeString(buf)); | 732 | printf("X=%i, Y=%i, Text=\"%s\"\n",msg.Buffer[6],msg.Buffer[5],DecodeUnicodeString(buf)); |
733 | return ERR_NONE; | 733 | return ERR_NONE; |
734 | case 0x54: | 734 | case 0x54: |
735 | dbgprintf("Display output set\n"); | 735 | dbgprintf("Display output set\n"); |
736 | return ERR_NONE; | 736 | return ERR_NONE; |
737 | } | 737 | } |
738 | return ERR_UNKNOWNRESPONSE; | 738 | return ERR_UNKNOWNRESPONSE; |
739 | } | 739 | } |
740 | 740 | ||
741 | void DCT3DisplayOutput(int argc, char *argv[]) | 741 | void DCT3DisplayOutput(int argc, char *argv[]) |
742 | { | 742 | { |
743 | unsigned char req[] = {N6110_FRAME_HEADER, 0x53, | 743 | unsigned char req[] = {N6110_FRAME_HEADER, 0x53, |
744 | 0x01}; //1 = enable, 2 = disable | 744 | 0x01}; //1 = enable, 2 = disable |
745 | 745 | ||
746 | GSM_Init(true); | 746 | GSM_Init(true); |
747 | 747 | ||
748 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); | 748 | if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED); |
749 | CheckDCT3(); | 749 | CheckDCT3(); |
750 | 750 | ||
751 | s.User.UserReplyFunctions=UserReplyFunctions3; | 751 | s.User.UserReplyFunctions=UserReplyFunctions3; |
752 | 752 | ||
753 | error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7); | 753 | error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7); |
754 | Print_Error(error); | 754 | Print_Error(error); |
755 | 755 | ||
756 | signal(SIGINT, interrupt); | 756 | signal(SIGINT, interrupt); |
757 | printf("Press Ctrl+C to break...\n"); | 757 | printf("Press Ctrl+C to break...\n"); |
758 | printf("Entering monitor mode...\n\n"); | 758 | printf("Entering monitor mode...\n\n"); |
759 | 759 | ||
760 | while (!gshutdown) { | 760 | while (!gshutdown) { |
761 | GSM_ReadDevice(&s,true); | 761 | GSM_ReadDevice(&s,true); |
762 | my_sleep(10); | 762 | my_sleep(10); |
763 | } | 763 | } |
764 | 764 | ||
765 | req[4] = 0x02; | 765 | req[4] = 0x02; |
766 | error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7); | 766 | error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7); |
767 | Print_Error(error); | 767 | Print_Error(error); |
768 | 768 | ||
769 | GSM_Terminate(); | 769 | GSM_Terminate(); |
770 | } | 770 | } |
771 | #endif | 771 | #endif |
772 | 772 | ||
773 | static GSM_Reply_Function UserReplyFunctions3[] = { | 773 | static GSM_Reply_Function UserReplyFunctions3[] = { |
774 | #ifdef GSM_ENABLE_NOKIA6110 | 774 | #ifdef GSM_ENABLE_NOKIA6110 |
775 | {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame}, | 775 | {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame}, |
776 | {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 }, | 776 | {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 }, |
777 | #endif | 777 | #endif |
778 | 778 | ||
779 | {DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity}, | 779 | {DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity}, |
780 | {DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 }, | 780 | {DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 }, |
781 | {DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 }, | 781 | {DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 }, |
782 | {DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 }, | 782 | {DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 }, |
783 | {DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 }, | 783 | {DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 }, |
784 | {DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 }, | 784 | {DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 }, |
785 | {DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 }, | 785 | {DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 }, |
786 | #ifdef GSM_ENABLE_NOKIA6110 | 786 | #ifdef GSM_ENABLE_NOKIA6110 |
787 | {DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 }, | 787 | {DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 }, |
788 | {DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 }, | 788 | {DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 }, |
789 | #endif | 789 | #endif |
790 | {DCT3_ReplyGetADC, "\x40",0x02,0x91,ID_User3 }, | 790 | {DCT3_ReplyGetADC, "\x40",0x02,0x91,ID_User3 }, |
791 | {NoneReply, "\x40",0x02,0xA3,ID_User3 }, | 791 | {NoneReply, "\x40",0x02,0xA3,ID_User3 }, |
792 | {DCT3_ReplyGetT9, "\x40",0x02,0xAE,ID_User3 }, | 792 | {DCT3_ReplyGetT9, "\x40",0x02,0xAE,ID_User3 }, |
793 | {DCT3_ReplyGetMSID, "\x40",0x02,0xb5,ID_User8 }, | 793 | {DCT3_ReplyGetMSID, "\x40",0x02,0xb5,ID_User8 }, |
794 | {DCT3_ReplyGetDSPROM, "\x40",0x02,0xC8,ID_User10 }, | 794 | {DCT3_ReplyGetDSPROM, "\x40",0x02,0xC8,ID_User10 }, |
795 | {DCT3_ReplyGetMCUchkSum, "\x40",0x02,0xC8,ID_User9 }, | 795 | {DCT3_ReplyGetMCUchkSum, "\x40",0x02,0xC8,ID_User9 }, |
796 | {DCT3_ReplyPhoneTests, "\x40",0x02,0xCF,ID_User1 }, | 796 | {DCT3_ReplyPhoneTests, "\x40",0x02,0xCF,ID_User1 }, |
797 | 797 | ||
798 | {DCT3_Reply7191GetSecurityCode, "\x7a",0x04,0x1C,ID_User6 }, | 798 | {DCT3_Reply7191GetSecurityCode, "\x7a",0x04,0x1C,ID_User6 }, |
799 | 799 | ||
800 | {NULL, "\x00",0x00,0x00,ID_None } | 800 | {NULL, "\x00",0x00,0x00,ID_None } |
801 | }; | 801 | }; |
802 | 802 | ||
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | /* How should editor hadle tabs in this file? Add editor commands here. | 805 | /* How should editor hadle tabs in this file? Add editor commands here. |
806 | * vim: noexpandtab sw=8 ts=8 sts=8: | 806 | * vim: noexpandtab sw=8 ts=8 sts=8: |
807 | */ | 807 | */ |
diff --git a/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c index 64eda37..e46d9dd 100644 --- a/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c +++ b/gammu/emb/gammu/depend/nokia/dct3trac/wmx.c | |||
@@ -1,480 +1,480 @@ | |||
1 | /** | 1 | /** |
2 | * Nokia DCT3 Firmware Debug Trace Monitor | 2 | * Nokia DCT3 Firmware Debug Trace Monitor |
3 | * wumpus 2003 -- www.blacksphere.tk | 3 | * wumpus 2003 -- www.blacksphere.tk |
4 | * SIM stuff by The Monty | 4 | * SIM stuff by The Monty |
5 | * | 5 | * |
6 | * Command line arguments: | 6 | * Command line arguments: |
7 | * gammu --nokiadebug v00-0F,20,21 | 7 | * gammu --nokiadebug v00-0F,20,21 |
8 | * (v=verbose) | 8 | * (v=verbose) |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "../../../../common/gsmstate.h" | 11 | #include "../../../../common/gsmstate.h" |
12 | 12 | ||
13 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 13 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
14 | 14 | ||
15 | #include <string.h> | 15 | #include <string.h> |
16 | #include <signal.h> | 16 | #include <signal.h> |
17 | 17 | ||
18 | #include "../../../../common/misc/coding/coding.h" | 18 | #include "../../../../common/misc/coding/coding.h" |
19 | #include "../../../../common/gsmcomon.h" | 19 | #include "../../../../common/gsmcomon.h" |
20 | #include "../../../../common/gsmstate.h" | 20 | #include "../../../../common/gsmstate.h" |
21 | #include "../../../../common/service/gsmpbk.h" | 21 | #include "../../../../common/service/gsmpbk.h" |
22 | #include "../../../../common/phone/nokia/dct3/dct3func.h" | 22 | #include "../../../../common/phone/nokia/dct3/dct3func.h" |
23 | #include "../../../gammu.h" | 23 | #include "../../../gammu.h" |
24 | #include "../dct3.h" | 24 | #include "../dct3.h" |
25 | #include "wmx.h" | 25 | #include "wmx.h" |
26 | #include "wmx-util.h" | 26 | #include "wmx-util.h" |
27 | #include "wmx-gsm.h" | 27 | #include "wmx-gsm.h" |
28 | #include "wmx-sim.h" | 28 | #include "wmx-sim.h" |
29 | #include "wmx-list.h" | 29 | #include "wmx-list.h" |
30 | 30 | ||
31 | extern GSM_Reply_Function UserReplyFunctionsX[]; | 31 | static GSM_Reply_Function UserReplyFunctionsX[]; |
32 | 32 | ||
33 | /* Global variables suck */ | 33 | /* Global variables suck */ |
34 | GSMDecoder *gsmdec; | 34 | GSMDecoder *gsmdec; |
35 | struct wmx_tracestruct *traces; | 35 | struct wmx_tracestruct *traces; |
36 | 36 | ||
37 | static GSM_Error DCT3_ReplySwitchDebug(GSM_Protocol_Message msg, GSM_StateMachine *s) | 37 | static GSM_Error DCT3_ReplySwitchDebug(GSM_Protocol_Message msg, GSM_StateMachine *s) |
38 | { | 38 | { |
39 | switch(msg.Buffer[2]) { | 39 | switch(msg.Buffer[2]) { |
40 | case 0x70: | 40 | case 0x70: |
41 | printf("Debug Trace Enabled\n"); | 41 | printf("Debug Trace Enabled\n"); |
42 | break; | 42 | break; |
43 | case 0x71: | 43 | case 0x71: |
44 | printf("Debug Trace Disabled\n"); | 44 | printf("Debug Trace Disabled\n"); |
45 | break; | 45 | break; |
46 | } | 46 | } |
47 | return ERR_NONE; | 47 | return ERR_NONE; |
48 | } | 48 | } |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * RPC confirmation/reply | 51 | * RPC confirmation/reply |
52 | */ | 52 | */ |
53 | static GSM_Error DCT3_ReplyRPC(GSM_Protocol_Message msg, GSM_StateMachine *s) | 53 | static GSM_Error DCT3_ReplyRPC(GSM_Protocol_Message msg, GSM_StateMachine *s) |
54 | { | 54 | { |
55 | printf("RPC Reply "); | 55 | printf("RPC Reply "); |
56 | printf("call=%02x rettype=%02x data=", msg.Buffer[2], msg.Buffer[3]); | 56 | printf("call=%02x rettype=%02x data=", msg.Buffer[2], msg.Buffer[3]); |
57 | if(msg.Buffer[3] == 3) { | 57 | if(msg.Buffer[3] == 3) { |
58 | /* string */ | 58 | /* string */ |
59 | printf("%s", &msg.Buffer[4]); | 59 | printf("%s", &msg.Buffer[4]); |
60 | } else { | 60 | } else { |
61 | dumpraw("RPC Reply data", &msg.Buffer[4], msg.Length-4); | 61 | dumpraw("RPC Reply data", &msg.Buffer[4], msg.Length-4); |
62 | } | 62 | } |
63 | printf("\n"); | 63 | printf("\n"); |
64 | return ERR_NONE; | 64 | return ERR_NONE; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* disassemble mdisnd (0x18xx) packet */ | 67 | /* disassemble mdisnd (0x18xx) packet */ |
68 | static void mdisnd_data(unsigned char type, unsigned char *buffer, size_t length) | 68 | static void mdisnd_data(unsigned char type, unsigned char *buffer, size_t length) |
69 | { | 69 | { |
70 | GSMDecoder_l1l2data dat; | 70 | GSMDecoder_l1l2data dat; |
71 | size_t x; | 71 | size_t x; |
72 | int ch; | 72 | int ch; |
73 | 73 | ||
74 | if(type==0x1B && length>2) { | 74 | if(type==0x1B && length>2) { |
75 | /* channel packet */ | 75 | /* channel packet */ |
76 | ch = buffer[1]; | 76 | ch = buffer[1]; |
77 | dat.tx = GSMDECODER_SEND; | 77 | dat.tx = GSMDECODER_SEND; |
78 | dat.ch = ch; | 78 | dat.ch = ch; |
79 | printf("%02X ch=%02X ",buffer[0],ch); | 79 | printf("%02X ch=%02X ",buffer[0],ch); |
80 | if (ch == 0x80 || ch == 0xB0) { | 80 | if (ch == 0x80 || ch == 0xB0) { |
81 | printf("\n"); | 81 | printf("\n"); |
82 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[2], length-2); | 82 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[2], length-2); |
83 | } else if (ch == 0x70) { | 83 | } else if (ch == 0x70) { |
84 | dumpraw("MDI send ch70 prefix", &buffer[2], 2); | 84 | dumpraw("MDI send ch70 prefix", &buffer[2], 2); |
85 | printf("\n"); | 85 | printf("\n"); |
86 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[4], length-4); | 86 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[4], length-4); |
87 | } else { | 87 | } else { |
88 | dumpraw("MDI recv 1B packet", &buffer[2], length-2); | 88 | dumpraw("MDI recv 1B packet", &buffer[2], length-2); |
89 | } | 89 | } |
90 | } else { | 90 | } else { |
91 | /* hex */ | 91 | /* hex */ |
92 | for(x=0; x<length; x++) { | 92 | for(x=0; x<length; x++) { |
93 | printf("%02x ",buffer[x]&0xFF); | 93 | printf("%02x ",buffer[x]&0xFF); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | /* disassemble mdircv (0x19xx) packet */ | 98 | /* disassemble mdircv (0x19xx) packet */ |
99 | static void mdircv_data(unsigned char type, unsigned char *buffer, size_t length) | 99 | static void mdircv_data(unsigned char type, unsigned char *buffer, size_t length) |
100 | { | 100 | { |
101 | size_t x; | 101 | size_t x; |
102 | int ch; | 102 | int ch; |
103 | GSMDecoder_l1l2data dat; | 103 | GSMDecoder_l1l2data dat; |
104 | 104 | ||
105 | if (type==0x80 && length>1) { | 105 | if (type==0x80 && length>1) { |
106 | // buffer[0] channel | 106 | // buffer[0] channel |
107 | // buffer[1] flag1 | 107 | // buffer[1] flag1 |
108 | // buffer[2] flag2 | 108 | // buffer[2] flag2 |
109 | // buffer[3..5] timestamp | 109 | // buffer[3..5] timestamp |
110 | // buffer[6..7] unknown_hw1 | 110 | // buffer[6..7] unknown_hw1 |
111 | // buffer[8..9] unknown_hw2 | 111 | // buffer[8..9] unknown_hw2 |
112 | ch = buffer[0]; | 112 | ch = buffer[0]; |
113 | dat.tx = GSMDECODER_RECEIVE; | 113 | dat.tx = GSMDECODER_RECEIVE; |
114 | dat.ch = ch; | 114 | dat.ch = ch; |
115 | dat.bsic = buffer[1]; | 115 | dat.bsic = buffer[1]; |
116 | dat.err = buffer[2]; | 116 | dat.err = buffer[2]; |
117 | dat.seq = (buffer[3]<<16)|(buffer[4]<<8)|(buffer[5]); | 117 | dat.seq = (buffer[3]<<16)|(buffer[4]<<8)|(buffer[5]); |
118 | dat.arfcn = (buffer[6]<<8)|buffer[7]; | 118 | dat.arfcn = (buffer[6]<<8)|buffer[7]; |
119 | dat.timeshift = (buffer[8]<<8)|buffer[9]; | 119 | dat.timeshift = (buffer[8]<<8)|buffer[9]; |
120 | 120 | ||
121 | printf("ch=%02X bsic=%i err=%i t=%06X arfcn=%i shift=%i", | 121 | printf("ch=%02X bsic=%i err=%i t=%06X arfcn=%i shift=%i", |
122 | ch, buffer[1], buffer[2], | 122 | ch, buffer[1], buffer[2], |
123 | dat.seq, dat.arfcn, dat.timeshift | 123 | dat.seq, dat.arfcn, dat.timeshift |
124 | ); | 124 | ); |
125 | 125 | ||
126 | //dumpraw("MDI recv 80 header", &buffer[6], 4); | 126 | //dumpraw("MDI recv 80 header", &buffer[6], 4); |
127 | printf(" "); | 127 | printf(" "); |
128 | if(buffer[2] == 0) { /* unencrypted */ | 128 | if(buffer[2] == 0) { /* unencrypted */ |
129 | if(ch == 0x70) { | 129 | if(ch == 0x70) { |
130 | /* Normal header + 2b prefix */ | 130 | /* Normal header + 2b prefix */ |
131 | dumpraw("MDI recv ch70 prefix", &buffer[10], 2); | 131 | dumpraw("MDI recv ch70 prefix", &buffer[10], 2); |
132 | printf("\n"); | 132 | printf("\n"); |
133 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[12], length-12); | 133 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[12], length-12); |
134 | } else if (ch == 0x80 || ch == 0xB0) { | 134 | } else if (ch == 0x80 || ch == 0xB0) { |
135 | /* Normal header */ | 135 | /* Normal header */ |
136 | printf("\n"); | 136 | printf("\n"); |
137 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[10], length-10); | 137 | GSMDecoder_L2packet(gsmdec, &dat, &buffer[10], length-10); |
138 | } else if (ch == 0x50 || ch == 0x60) { | 138 | } else if (ch == 0x50 || ch == 0x60) { |
139 | /* Short header */ | 139 | /* Short header */ |
140 | 140 | ||
141 | printf("\n"); | 141 | printf("\n"); |
142 | GSMDecoder_L2short_packet(gsmdec, &dat, &buffer[10], length-10); | 142 | GSMDecoder_L2short_packet(gsmdec, &dat, &buffer[10], length-10); |
143 | } else { | 143 | } else { |
144 | dumpraw("MDI send 80 packet", &buffer[10], length-10); | 144 | dumpraw("MDI send 80 packet", &buffer[10], length-10); |
145 | } | 145 | } |
146 | } else { | 146 | } else { |
147 | /* Encrypted (?) */ | 147 | /* Encrypted (?) */ |
148 | dumpraw("MDI send err 80", &buffer[10], length-10); | 148 | dumpraw("MDI send err 80", &buffer[10], length-10); |
149 | } | 149 | } |
150 | } else { | 150 | } else { |
151 | /* hex */ | 151 | /* hex */ |
152 | for(x=0; x<length; x++) { | 152 | for(x=0; x<length; x++) { |
153 | printf("%02x ",buffer[x]&0xFF); | 153 | printf("%02x ",buffer[x]&0xFF); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | static GSM_Error DCT3_ReplyDebugTrace(GSM_Protocol_Message msg, GSM_StateMachine *s) | 158 | static GSM_Error DCT3_ReplyDebugTrace(GSM_Protocol_Message msg, GSM_StateMachine *s) |
159 | { | 159 | { |
160 | int x; | 160 | int x; |
161 | int id,timestamp,number,length; | 161 | int id,timestamp,number,length; |
162 | struct wmx_tracetype *minor; | 162 | struct wmx_tracetype *minor; |
163 | char *desc; | 163 | char *desc; |
164 | 164 | ||
165 | //printf("Debug Trace Received\n"); | 165 | //printf("Debug Trace Received\n"); |
166 | /* parse frame | 166 | /* parse frame |
167 | Debug trace packet: | 167 | Debug trace packet: |
168 | packet type 0x00 | 168 | packet type 0x00 |
169 | source subsystem 0x01 (LOCAL) | 169 | source subsystem 0x01 (LOCAL) |
170 | verder formaat zie notebook | 170 | verder formaat zie notebook |
171 | 0x08 ID (payload=offset 0x02 here) | 171 | 0x08 ID (payload=offset 0x02 here) |
172 | 0x0A timestamp | 172 | 0x0A timestamp |
173 | 0x0C seq nr | 173 | 0x0C seq nr |
174 | 0x0D .. parameters | 174 | 0x0D .. parameters |
175 | */ | 175 | */ |
176 | id = ((msg.Buffer[2]&0xFF)<<8)|(msg.Buffer[3]&0xFF); | 176 | id = ((msg.Buffer[2]&0xFF)<<8)|(msg.Buffer[3]&0xFF); |
177 | timestamp = ((msg.Buffer[4]&0xFF)<<8)|(msg.Buffer[5]&0xFF); | 177 | timestamp = ((msg.Buffer[4]&0xFF)<<8)|(msg.Buffer[5]&0xFF); |
178 | number = msg.Buffer[6]&0xFF; | 178 | number = msg.Buffer[6]&0xFF; |
179 | length = msg.Buffer[7]&0xFF; | 179 | length = msg.Buffer[7]&0xFF; |
180 | 180 | ||
181 | /* filter */ | 181 | /* filter */ |
182 | //if((id&0xFF00)==0x1900 && id != 0x1980) | 182 | //if((id&0xFF00)==0x1900 && id != 0x1980) |
183 | //return GE_NONE; | 183 | //return GE_NONE; |
184 | //printf("%02x\n",msg.Buffer[10]); | 184 | //printf("%02x\n",msg.Buffer[10]); |
185 | //if(msg.Buffer[10]!=0x40) | 185 | //if(msg.Buffer[10]!=0x40) |
186 | //return GE_NONE; | 186 | //return GE_NONE; |
187 | /* Query trace type name */ | 187 | /* Query trace type name */ |
188 | desc = "Unknown"; | 188 | desc = "Unknown"; |
189 | if(traces != NULL) { | 189 | if(traces != NULL) { |
190 | minor = wmx_tracestruct_queryminor(traces, id); | 190 | minor = wmx_tracestruct_queryminor(traces, id); |
191 | if(minor != NULL) desc = minor->desc; | 191 | if(minor != NULL) desc = minor->desc; |
192 | } | 192 | } |
193 | printf("<%04X> %s\n", id, desc); | 193 | printf("<%04X> %s\n", id, desc); |
194 | printf("t=%04x nr=%02x: ", timestamp, number); | 194 | printf("t=%04x nr=%02x: ", timestamp, number); |
195 | 195 | ||
196 | /* TODO -- decode debug types on phone type */ | 196 | /* TODO -- decode debug types on phone type */ |
197 | switch(id>>8) { | 197 | switch(id>>8) { |
198 | case 0x33: | 198 | case 0x33: |
199 | case 0x34: | 199 | case 0x34: |
200 | case 0x35: | 200 | case 0x35: |
201 | case 0x37: | 201 | case 0x37: |
202 | case 0x38: | 202 | case 0x38: |
203 | case 0x39: | 203 | case 0x39: |
204 | case 0x3A: | 204 | case 0x3A: |
205 | case 0x3B: | 205 | case 0x3B: |
206 | case 0x3C: | 206 | case 0x3C: |
207 | case 0x5F: | 207 | case 0x5F: |
208 | /* text */ | 208 | /* text */ |
209 | /* skip length byte */ | 209 | /* skip length byte */ |
210 | printf("\""); | 210 | printf("\""); |
211 | for(x=8; x<msg.Length; x++) { | 211 | for(x=8; x<msg.Length; x++) { |
212 | printf("%c",msg.Buffer[x]&0xFF); | 212 | printf("%c",msg.Buffer[x]&0xFF); |
213 | } | 213 | } |
214 | printf("\""); | 214 | printf("\""); |
215 | break; | 215 | break; |
216 | /* | 216 | /* |
217 | case 0x6801: | 217 | case 0x6801: |
218 | for(x=8; x<msg.Length; x++) { | 218 | for(x=8; x<msg.Length; x++) { |
219 | printf("%02x%c ",msg.Buffer[x]&0xFF,msg.Buffer[x]&0xFF); | 219 | printf("%02x%c ",msg.Buffer[x]&0xFF,msg.Buffer[x]&0xFF); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | */ | 222 | */ |
223 | case 0x18: /* MDISND */ | 223 | case 0x18: /* MDISND */ |
224 | 224 | ||
225 | /* skip these: | 225 | /* skip these: |
226 | +00 length | 226 | +00 length |
227 | +01 type (also xx in 0x18xx) | 227 | +01 type (also xx in 0x18xx) |
228 | */ | 228 | */ |
229 | if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) { | 229 | if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) { |
230 | printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]); | 230 | printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]); |
231 | } else { | 231 | } else { |
232 | //printf("D %02X: ", id&0xFF); | 232 | //printf("D %02X: ", id&0xFF); |
233 | printf("D %02X: ", id&0xFF); | 233 | printf("D %02X: ", id&0xFF); |
234 | mdisnd_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); | 234 | mdisnd_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | case 0x19: /* MDIRCV */ | 237 | case 0x19: /* MDIRCV */ |
238 | if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) { | 238 | if(msg.Length<10 || msg.Buffer[9]!=(id&0xFF)) { |
239 | printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]); | 239 | printf("C %02X: param:%02x", id&0xFF, msg.Buffer[8]); |
240 | } else { | 240 | } else { |
241 | printf("D %02X: ", id&0xFF); | 241 | printf("D %02X: ", id&0xFF); |
242 | mdircv_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); | 242 | mdircv_data((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); |
243 | //dumpraw((unsigned char*)&msg.Buffer[10], msg.Length-10); | 243 | //dumpraw((unsigned char*)&msg.Buffer[10], msg.Length-10); |
244 | } | 244 | } |
245 | break; | 245 | break; |
246 | case 0x20: /* 0x25 SIM commands */ | 246 | case 0x20: /* 0x25 SIM commands */ |
247 | /* | 247 | /* |
248 | for(x=8;x<msg.Length;x++) | 248 | for(x=8;x<msg.Length;x++) |
249 | printf("%02x ", msg.Buffer[x]&0xFF); | 249 | printf("%02x ", msg.Buffer[x]&0xFF); |
250 | */ | 250 | */ |
251 | printf("SIM command "); | 251 | printf("SIM command "); |
252 | if(msg.Buffer[8]==0xa0) { // check if valid (class=a0) | 252 | if(msg.Buffer[8]==0xa0) { // check if valid (class=a0) |
253 | simCommand_data(msg.Buffer[9], (unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); | 253 | simCommand_data(msg.Buffer[9], (unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[10], msg.Length-10); |
254 | // TODO: pass the msg.Buffer[9] and skip 1rst arg | 254 | // TODO: pass the msg.Buffer[9] and skip 1rst arg |
255 | } else { | 255 | } else { |
256 | printf("Unknown 0x25 packet (NOT SIM cmd): "); | 256 | printf("Unknown 0x25 packet (NOT SIM cmd): "); |
257 | for(x=8;x<msg.Length;x++) printf("%02x ", msg.Buffer[x]&0xFF); | 257 | for(x=8;x<msg.Length;x++) printf("%02x ", msg.Buffer[x]&0xFF); |
258 | printf("\n"); | 258 | printf("\n"); |
259 | } | 259 | } |
260 | break; | 260 | break; |
261 | case 0x22: /* 0x27 SIM answer to command (error/ok/etc..) */ | 261 | case 0x22: /* 0x27 SIM answer to command (error/ok/etc..) */ |
262 | if(msg.Length<10) { | 262 | if(msg.Length<10) { |
263 | // Unknown response | 263 | // Unknown response |
264 | for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF); | 264 | for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF); |
265 | printf(" (Unknown 0x27 packet ? ? )\n"); | 265 | printf(" (Unknown 0x27 packet ? ? )\n"); |
266 | } else { | 266 | } else { |
267 | simAnswer_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length); | 267 | simAnswer_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length); |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | case 0x23: /* 0x28 SIM response data to commands */ | 270 | case 0x23: /* 0x28 SIM response data to commands */ |
271 | if(msg.Length<10) { | 271 | if(msg.Length<10) { |
272 | // Unknown response | 272 | // Unknown response |
273 | for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF); | 273 | for(x=0;x<msg.Length-10;x++) printf("%02x ", msg.Buffer[x]&0xFF); |
274 | printf(" (Unknown 0x28 packet)\n"); | 274 | printf(" (Unknown 0x28 packet)\n"); |
275 | } else { | 275 | } else { |
276 | simResponse_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length); | 276 | simResponse_Process((unsigned char)(id&0xFF), (unsigned char*)&msg.Buffer[8], length); |
277 | } | 277 | } |
278 | break; | 278 | break; |
279 | default: | 279 | default: |
280 | /* hex */ | 280 | /* hex */ |
281 | for(x=8; x<msg.Length; x++) { | 281 | for(x=8; x<msg.Length; x++) { |
282 | printf("%02x ",msg.Buffer[x]&0xFF); | 282 | printf("%02x ",msg.Buffer[x]&0xFF); |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | printf("\n"); | 286 | printf("\n"); |
287 | return ERR_NONE; | 287 | return ERR_NONE; |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | static GSM_Error DCT3_ReplyMyPacket(GSM_Protocol_Message msg, GSM_StateMachine *s) | 291 | static GSM_Error DCT3_ReplyMyPacket(GSM_Protocol_Message msg, GSM_StateMachine *s) |
292 | { | 292 | { |
293 | int x; | 293 | int x; |
294 | 294 | ||
295 | printf("MyPacket "); | 295 | printf("MyPacket "); |
296 | for(x=0; x<msg.Length; x++) { | 296 | for(x=0; x<msg.Length; x++) { |
297 | printf("%02x ",msg.Buffer[x]&0xFF); | 297 | printf("%02x ",msg.Buffer[x]&0xFF); |
298 | } | 298 | } |
299 | printf("\n"); | 299 | printf("\n"); |
300 | return ERR_NONE; | 300 | return ERR_NONE; |
301 | } | 301 | } |
302 | 302 | ||
303 | #define ID_DebugTrace 0x666 | 303 | #define ID_DebugTrace 0x666 |
304 | #define ID_DebugSwitch 0x667 | 304 | #define ID_DebugSwitch 0x667 |
305 | #define ID_RPC 0x668 | 305 | #define ID_RPC 0x668 |
306 | 306 | ||
307 | void DCT3SetDebug(int argc, char *argv[]) | 307 | void DCT3SetDebug(int argc, char *argv[]) |
308 | { | 308 | { |
309 | int x,count; | 309 | int x,count; |
310 | unsigned int y; | 310 | unsigned int y; |
311 | unsigned char reqDisable[] = {0x01, 0x01, 0x71}; | 311 | unsigned char reqDisable[] = {0x01, 0x01, 0x71}; |
312 | // unsigned char reqTest[] = {0x01, 0x01, 0x96, 0xFF, 0xFF}; | 312 | // unsigned char reqTest[] = {0x01, 0x01, 0x96, 0xFF, 0xFF}; |
313 | 313 | ||
314 | /* RPC testing packets: */ | 314 | /* RPC testing packets: */ |
315 | 315 | ||
316 | /* RPC: Get version */ | 316 | /* RPC: Get version */ |
317 | //unsigned char reqTest2[] = {0x01, 0x01, 0x00, 0x03, 0x00}; | 317 | //unsigned char reqTest2[] = {0x01, 0x01, 0x00, 0x03, 0x00}; |
318 | /* RPC: read I/O 0x6D mask 0xFF */ | 318 | /* RPC: read I/O 0x6D mask 0xFF */ |
319 | //unsigned char reqTest2[] = {0x01, 0x01, 0x02, 0x01, 0x02, 0x6D, 0xFF}; /* */ | 319 | //unsigned char reqTest2[] = {0x01, 0x01, 0x02, 0x01, 0x02, 0x6D, 0xFF}; /* */ |
320 | /* RPC: write I/O 0x03 mask 0xFF value 0x31 */ | 320 | /* RPC: write I/O 0x03 mask 0xFF value 0x31 */ |
321 | //unsigned char reqTest2[] = {0x01, 0x01, 0x01, 0x01, 0x07, 0x03, 0xFF, 0x31}; /* write I/O */ | 321 | //unsigned char reqTest2[] = {0x01, 0x01, 0x01, 0x01, 0x07, 0x03, 0xFF, 0x31}; /* write I/O */ |
322 | 322 | ||
323 | /* RPC: write forged FBUS packet to MDISND */ | 323 | /* RPC: write forged FBUS packet to MDISND */ |
324 | // unsigned char reqTest2[] = {0x01, 0x01, 0x16, 0x01, 0x06, | 324 | // unsigned char reqTest2[] = {0x01, 0x01, 0x16, 0x01, 0x06, |
325 | //0x14, // R0 -- length | 325 | //0x14, // R0 -- length |
326 | //0x05, // R1 -- MDI type identifier 0x05(FBUS) | 326 | //0x05, // R1 -- MDI type identifier 0x05(FBUS) |
327 | //0x1e, 0x0c, 0x00, 0x66, | 327 | //0x1e, 0x0c, 0x00, 0x66, |
328 | //0x00, 0x0e, 0x01, 0x01, | 328 | //0x00, 0x0e, 0x01, 0x01, |
329 | //0x66, 0x55, 0x44, 0x33, | 329 | //0x66, 0x55, 0x44, 0x33, |
330 | //0x0d, 0x01, 0x01, 0x01, | 330 | //0x0d, 0x01, 0x01, 0x01, |
331 | //0x1b, 0x58, 0x01, 0x44}; | 331 | //0x1b, 0x58, 0x01, 0x44}; |
332 | //1805 t=cb37 nr=e2 :D 05: | 332 | //1805 t=cb37 nr=e2 :D 05: |
333 | 333 | ||
334 | /* debug enable packet */ | 334 | /* debug enable packet */ |
335 | unsigned char reqEnable[] = { | 335 | unsigned char reqEnable[] = { |
336 | 0x00, 0x01, 0x70, | 336 | 0x00, 0x01, 0x70, |
337 | /* Debug bits | 337 | /* Debug bits |
338 | byte[bit>>3]&(1<<(7-(bit&7))) | 338 | byte[bit>>3]&(1<<(7-(bit&7))) |
339 | */ | 339 | */ |
340 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */ | 340 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */ |
341 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */ | 341 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */ |
342 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */ | 342 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */ |
343 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ | 343 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ |
344 | /* Debug verbose bits | 344 | /* Debug verbose bits |
345 | byte[bit>>3]&(1<<(7-(bit&7))) | 345 | byte[bit>>3]&(1<<(7-(bit&7))) |
346 | */ | 346 | */ |
347 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 347 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
348 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 348 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
349 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 349 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
350 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 350 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
351 | }; | 351 | }; |
352 | 352 | ||
353 | #define ENABLE_BIT(bit,verbose) reqEnable[3 + (bit>>3)] |= 1<<(7-(bit&7)); if(verbose){reqEnable[3 + 32 + (bit>>3)] |= 1<<(7-(bit&7));} | 353 | #define ENABLE_BIT(bit,verbose) reqEnable[3 + (bit>>3)] |= 1<<(7-(bit&7)); if(verbose){reqEnable[3 + 32 + (bit>>3)] |= 1<<(7-(bit&7));} |
354 | 354 | ||
355 | /* Enable some bit | 355 | /* Enable some bit |
356 | TODO command line or GUI interface | 356 | TODO command line or GUI interface |
357 | */ | 357 | */ |
358 | //ENABLE_BIT(0x18, 1);/* Enable MDISND debugging */ | 358 | //ENABLE_BIT(0x18, 1);/* Enable MDISND debugging */ |
359 | //ENABLE_BIT(0x19, 1);/* Enable MDIRCV debugging */ | 359 | //ENABLE_BIT(0x19, 1);/* Enable MDIRCV debugging */ |
360 | //ENABLE_BIT(0x31, 1); | 360 | //ENABLE_BIT(0x31, 1); |
361 | 361 | ||
362 | gsmdec = GSMDecoder_new(); | 362 | gsmdec = GSMDecoder_new(); |
363 | /* Open XML file .. needs to be argument */ | 363 | /* Open XML file .. needs to be argument */ |
364 | { | 364 | { |
365 | FILE *xout = fopen("out.xml", "w"); | 365 | FILE *xout = fopen("out.xml", "w"); |
366 | GSMDecoder_xmlout(gsmdec, xout); | 366 | GSMDecoder_xmlout(gsmdec, xout); |
367 | } | 367 | } |
368 | printf("Debug Trace Mode -- wumpus 2003\n"); | 368 | printf("Debug Trace Mode -- wumpus 2003\n"); |
369 | traces = wmx_tracestruct_load(argv[2]); | 369 | traces = wmx_tracestruct_load(argv[2]); |
370 | if(traces == NULL) | 370 | if(traces == NULL) |
371 | printf("Warning: could not load trace description file %s\n", argv[2]); | 371 | printf("Warning: could not load trace description file %s\n", argv[2]); |
372 | printf("Activating ranges:\n"); | 372 | printf("Activating ranges:\n"); |
373 | count = 0; | 373 | count = 0; |
374 | for(x=3; x<argc; x++) { | 374 | for(x=3; x<argc; x++) { |
375 | char *ptr = argv[x]; | 375 | char *ptr = argv[x]; |
376 | unsigned from,to,verbose; | 376 | unsigned from,to,verbose; |
377 | 377 | ||
378 | while(*ptr) { | 378 | while(*ptr) { |
379 | verbose = 0; | 379 | verbose = 0; |
380 | if(*ptr == 'v') { | 380 | if(*ptr == 'v') { |
381 | verbose = 1; | 381 | verbose = 1; |
382 | ptr++; | 382 | ptr++; |
383 | } | 383 | } |
384 | to = from = strtol(ptr, &ptr, 16); | 384 | to = from = strtol(ptr, &ptr, 16); |
385 | if(*ptr == '-') { | 385 | if(*ptr == '-') { |
386 | ptr ++; | 386 | ptr ++; |
387 | to = strtol(ptr, &ptr, 16); | 387 | to = strtol(ptr, &ptr, 16); |
388 | } | 388 | } |
389 | if(*ptr != ',' && *ptr != 0) { | 389 | if(*ptr != ',' && *ptr != 0) { |
390 | printf("Invalid parameter '%s'\n", argv[x]); | 390 | printf("Invalid parameter '%s'\n", argv[x]); |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | if(*ptr == ',') | 393 | if(*ptr == ',') |
394 | ptr++; | 394 | ptr++; |
395 | if(from > 0xFF) from=0xFF; | 395 | if(from > 0xFF) from=0xFF; |
396 | if(to > 0xFF) to=0xFF; | 396 | if(to > 0xFF) to=0xFF; |
397 | printf(" %02x-%02x verbose=%i\n",from,to,verbose); | 397 | printf(" %02x-%02x verbose=%i\n",from,to,verbose); |
398 | for(y=from; y<=to; y++) { | 398 | for(y=from; y<=to; y++) { |
399 | ENABLE_BIT(y, verbose); | 399 | ENABLE_BIT(y, verbose); |
400 | count++; | 400 | count++; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | } | 403 | } |
404 | if(count == 0) { | 404 | if(count == 0) { |
405 | printf("Nothing activated -- bailing out\n"); | 405 | printf("Nothing activated -- bailing out\n"); |
406 | return; | 406 | return; |
407 | } | 407 | } |
408 | //ENABLE_BIT(0x20, 1); /* SIM commands (literal) */ | 408 | //ENABLE_BIT(0x20, 1); /* SIM commands (literal) */ |
409 | //ENABLE_BIT(0x21, 1); /* SIML2 commands (literal) */ | 409 | //ENABLE_BIT(0x21, 1); /* SIML2 commands (literal) */ |
410 | //ENABLE_BIT(0x22, 1); /* SIM commands (literal) */ | 410 | //ENABLE_BIT(0x22, 1); /* SIM commands (literal) */ |
411 | //ENABLE_BIT(0x3B, 1);/* PHCTRL state */ | 411 | //ENABLE_BIT(0x3B, 1);/* PHCTRL state */ |
412 | 412 | ||
413 | GSM_Init(true); | 413 | GSM_Init(true); |
414 | 414 | ||
415 | /* We Need DCT3 */ | 415 | /* We Need DCT3 */ |
416 | if (CheckDCT3Only()!=ERR_NONE) return; | 416 | if (CheckDCT3Only()!=ERR_NONE) return; |
417 | 417 | ||
418 | error=DCT3_EnableSecurity (&s, 0x01); | 418 | error=DCT3_EnableSecurity (&s, 0x01); |
419 | Print_Error(error); | 419 | Print_Error(error); |
420 | 420 | ||
421 | s.User.UserReplyFunctions=UserReplyFunctionsX; | 421 | s.User.UserReplyFunctions=UserReplyFunctionsX; |
422 | 422 | ||
423 | //error=GSM_WaitFor (&s, reqTest, sizeof(reqTest), 0x40, 1, ID_DebugSwitch); | 423 | //error=GSM_WaitFor (&s, reqTest, sizeof(reqTest), 0x40, 1, ID_DebugSwitch); |
424 | 424 | ||
425 | //error=GSM_WaitFor (&s, reqTest2, sizeof(reqTest2), 0xD1, 4, ID_RPC); | 425 | //error=GSM_WaitFor (&s, reqTest2, sizeof(reqTest2), 0xD1, 4, ID_RPC); |
426 | 426 | ||
427 | /* Enable Debug Mode */ | 427 | /* Enable Debug Mode */ |
428 | error=GSM_WaitFor (&s, reqEnable, sizeof(reqEnable), 0x40, 4, ID_DebugSwitch); | 428 | error=GSM_WaitFor (&s, reqEnable, sizeof(reqEnable), 0x40, 4, ID_DebugSwitch); |
429 | 429 | ||
430 | Print_Error(error); | 430 | Print_Error(error); |
431 | signal(SIGINT, interrupt); | 431 | signal(SIGINT, interrupt); |
432 | printf("Press Ctrl+C to interrupt...\n"); | 432 | printf("Press Ctrl+C to interrupt...\n"); |
433 | x=0; | 433 | x=0; |
434 | 434 | ||
435 | /* | 435 | /* |
436 | while(x<100) { | 436 | while(x<100) { |
437 | //printf(": %02x\n",x); | 437 | //printf(": %02x\n",x); |
438 | s.Phone.Data.RequestID= ID_DebugTrace; | 438 | s.Phone.Data.RequestID= ID_DebugTrace; |
439 | res = s.Device.Functions->ReadDevice(&s, buff, 255); | 439 | res = s.Device.Functions->ReadDevice(&s, buff, 255); |
440 | if(res) { | 440 | if(res) { |
441 | printf("%02x\n",x); | 441 | printf("%02x\n",x); |
442 | for(y=0;y<res;y++) { | 442 | for(y=0;y<res;y++) { |
443 | //printf("%02x\n",x,buff[y]&0xFF); | 443 | //printf("%02x\n",x,buff[y]&0xFF); |
444 | s.Protocol.Functions->StateMachine(&s,buff[y]); | 444 | s.Protocol.Functions->StateMachine(&s,buff[y]); |
445 | x++; | 445 | x++; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | } | 448 | } |
449 | */ | 449 | */ |
450 | ; | 450 | ; |
451 | 451 | ||
452 | /* todo: wait and dump for some time */ | 452 | /* todo: wait and dump for some time */ |
453 | while (!gshutdown) { | 453 | while (!gshutdown) { |
454 | GSM_ReadDevice(&s,true); | 454 | GSM_ReadDevice(&s,true); |
455 | my_sleep(10); | 455 | my_sleep(10); |
456 | } | 456 | } |
457 | signal(SIGINT, SIG_DFL); | 457 | signal(SIGINT, SIG_DFL); |
458 | printf("Disabling\n"); | 458 | printf("Disabling\n"); |
459 | error=GSM_WaitFor (&s, reqDisable, sizeof(reqDisable), 0x40, 10, ID_DebugSwitch); | 459 | error=GSM_WaitFor (&s, reqDisable, sizeof(reqDisable), 0x40, 10, ID_DebugSwitch); |
460 | Print_Error(error); | 460 | Print_Error(error); |
461 | 461 | ||
462 | GSMDecoder_free(gsmdec); | 462 | GSMDecoder_free(gsmdec); |
463 | } | 463 | } |
464 | 464 | ||
465 | static GSM_Reply_Function UserReplyFunctionsX[] = { | 465 | static GSM_Reply_Function UserReplyFunctionsX[] = { |
466 | {DCT3_ReplySwitchDebug, "\x40",0x02,0x70,ID_DebugSwitch }, | 466 | {DCT3_ReplySwitchDebug, "\x40",0x02,0x70,ID_DebugSwitch }, |
467 | {DCT3_ReplySwitchDebug, "\x40",0x02,0x71,ID_DebugSwitch }, | 467 | {DCT3_ReplySwitchDebug, "\x40",0x02,0x71,ID_DebugSwitch }, |
468 | {DCT3_ReplyDebugTrace, "\x00",0x00,0x00,ID_IncomingFrame}, | 468 | {DCT3_ReplyDebugTrace, "\x00",0x00,0x00,ID_IncomingFrame}, |
469 | {DCT3_ReplyMyPacket, "\x40",0x00,0x00,ID_IncomingFrame}, | 469 | {DCT3_ReplyMyPacket, "\x40",0x00,0x00,ID_IncomingFrame}, |
470 | 470 | ||
471 | {DCT3_ReplyRPC, "\xD2",0x00,0x00,ID_RPC }, | 471 | {DCT3_ReplyRPC, "\xD2",0x00,0x00,ID_RPC }, |
472 | 472 | ||
473 | {NULL, "\x00",0x00,0x00,ID_None } | 473 | {NULL, "\x00",0x00,0x00,ID_None } |
474 | }; | 474 | }; |
475 | 475 | ||
476 | #endif | 476 | #endif |
477 | 477 | ||
478 | /* How should editor hadle tabs in this file? Add editor commands here. | 478 | /* How should editor hadle tabs in this file? Add editor commands here. |
479 | * vim: noexpandtab sw=8 ts=8 sts=8: | 479 | * vim: noexpandtab sw=8 ts=8 sts=8: |
480 | */ | 480 | */ |
diff --git a/gammu/emb/gammu/depend/nokia/dct4.c b/gammu/emb/gammu/depend/nokia/dct4.c index 4bf958d..43d8f09 100644 --- a/gammu/emb/gammu/depend/nokia/dct4.c +++ b/gammu/emb/gammu/depend/nokia/dct4.c | |||
@@ -1,1350 +1,1350 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include "../../../common/gsmstate.h" | 3 | #include "../../../common/gsmstate.h" |
4 | 4 | ||
5 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 5 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
6 | 6 | ||
7 | #include <string.h> | 7 | #include <string.h> |
8 | 8 | ||
9 | #include "dct4.h" | 9 | #include "dct4.h" |
10 | #include "../../gammu.h" | 10 | #include "../../gammu.h" |
11 | #include "../../../common/phone/pfunc.h" | 11 | #include "../../../common/phone/pfunc.h" |
12 | #include "../../../common/phone/nokia/nfunc.h" | 12 | #include "../../../common/phone/nokia/nfunc.h" |
13 | #include "../../../common/phone/nokia/dct4/dct4func.h" | 13 | #include "../../../common/phone/nokia/dct4/dct4func.h" |
14 | #include "../../../common/misc/coding/coding.h" | 14 | #include "../../../common/misc/coding/coding.h" |
15 | 15 | ||
16 | extern GSM_Reply_Function UserReplyFunctions4[]; | 16 | static GSM_Reply_Function UserReplyFunctions4[]; |
17 | 17 | ||
18 | /* ------- some usefull functions ----------------------------------------- */ | 18 | /* ------- some usefull functions ----------------------------------------- */ |
19 | 19 | ||
20 | GSM_Error CheckDCT4Only() | 20 | GSM_Error CheckDCT4Only() |
21 | { | 21 | { |
22 | bool found = false; | 22 | bool found = false; |
23 | 23 | ||
24 | /* Checking if phone is DCT4 */ | 24 | /* Checking if phone is DCT4 */ |
25 | #ifdef GSM_ENABLE_NOKIA3650 | 25 | #ifdef GSM_ENABLE_NOKIA3650 |
26 | if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 26 | if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
27 | #endif | 27 | #endif |
28 | #ifdef GSM_ENABLE_NOKIA6510 | 28 | #ifdef GSM_ENABLE_NOKIA6510 |
29 | if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 29 | if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
30 | #endif | 30 | #endif |
31 | #ifdef GSM_ENABLE_NOKIA3320 | 31 | #ifdef GSM_ENABLE_NOKIA3320 |
32 | if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; | 32 | if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; |
33 | #endif | 33 | #endif |
34 | if (!found) return ERR_NOTSUPPORTED; | 34 | if (!found) return ERR_NOTSUPPORTED; |
35 | 35 | ||
36 | if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && | 36 | if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && |
37 | s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE && | 37 | s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE && |
38 | s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET && | 38 | s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET && |
39 | s.ConnectionType!=GCT_FBUS2DKU5) { | 39 | s.ConnectionType!=GCT_FBUS2DKU5) { |
40 | return ERR_OTHERCONNECTIONREQUIRED; | 40 | return ERR_OTHERCONNECTIONREQUIRED; |
41 | } | 41 | } |
42 | return ERR_NONE; | 42 | return ERR_NONE; |
43 | } | 43 | } |
44 | 44 | ||
45 | static void CheckDCT4() | 45 | static void CheckDCT4() |
46 | { | 46 | { |
47 | GSM_Error error; | 47 | GSM_Error error; |
48 | 48 | ||
49 | error = CheckDCT4Only(); | 49 | error = CheckDCT4Only(); |
50 | switch (error) { | 50 | switch (error) { |
51 | case ERR_NOTSUPPORTED: | 51 | case ERR_NOTSUPPORTED: |
52 | Print_Error(ERR_NOTSUPPORTED); | 52 | Print_Error(ERR_NOTSUPPORTED); |
53 | break; | 53 | break; |
54 | case ERR_OTHERCONNECTIONREQUIRED: | 54 | case ERR_OTHERCONNECTIONREQUIRED: |
55 | printf("Can't do it with current phone protocol\n"); | 55 | printf("Can't do it with current phone protocol\n"); |
56 | GSM_TerminateConnection(&s); | 56 | GSM_TerminateConnection(&s); |
57 | exit(-1); | 57 | exit(-1); |
58 | default: | 58 | default: |
59 | break; | 59 | break; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | static bool answer_yes2(char *text) | 63 | static bool answer_yes2(char *text) |
64 | { | 64 | { |
65 | int len; | 65 | int len; |
66 | char ans[99]; | 66 | char ans[99]; |
67 | 67 | ||
68 | while (1) { | 68 | while (1) { |
69 | printf("%s (yes/no) ? ",text); | 69 | printf("%s (yes/no) ? ",text); |
70 | len=GetLine(stdin, ans, 99); | 70 | len=GetLine(stdin, ans, 99); |
71 | if (len==-1) exit(-1); | 71 | if (len==-1) exit(-1); |
72 | if (mystrncasecmp(ans, "yes",0)) return true; | 72 | if (mystrncasecmp(ans, "yes",0)) return true; |
73 | if (mystrncasecmp(ans, "no" ,0)) return false; | 73 | if (mystrncasecmp(ans, "no" ,0)) return false; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | /* ------------------- functions ------------------------------------------- */ | 77 | /* ------------------- functions ------------------------------------------- */ |
78 | 78 | ||
79 | static DCT4_Feature DCT4Features[] = { | 79 | static DCT4_Feature DCT4Features[] = { |
80 | {DCT4_ALWAYS_ONLINE, "GPRS Always Online", {{0,"on (Context)"},{1,"off (Attach)"},{0,""}}},///?? | 80 | {DCT4_ALWAYS_ONLINE, "GPRS Always Online", {{0,"on (Context)"},{1,"off (Attach)"},{0,""}}},///?? |
81 | {DCT4_GPRS_PCCH, "PCCH support for GPRS", {{1,"on"},{0,"off"},{0,""}}}, | 81 | {DCT4_GPRS_PCCH, "PCCH support for GPRS", {{1,"on"},{0,"off"},{0,""}}}, |
82 | {DCT4_GEA1, "GEA1 support indication", {{1,"on"},{0,"off"},{0,""}}}, | 82 | {DCT4_GEA1, "GEA1 support indication", {{1,"on"},{0,"off"},{0,""}}}, |
83 | {DCT4_EOTD, "EOTD support", {{1,"on"},{0,"off"},{0,""}}}, | 83 | {DCT4_EOTD, "EOTD support", {{1,"on"},{0,"off"},{0,""}}}, |
84 | {DCT4_WAP_PUSH, "WAP push", {{1,"on"},{0,"off"},{0,""}}}, | 84 | {DCT4_WAP_PUSH, "WAP push", {{1,"on"},{0,"off"},{0,""}}}, |
85 | {DCT4_USE_PREF_SIM_NET, "Use SIM preffered network list",{{1,"on"},{0,"off"},{0,""}}}, | 85 | {DCT4_USE_PREF_SIM_NET, "Use SIM preffered network list",{{1,"on"},{0,"off"},{0,""}}}, |
86 | {DCT4_JAVA_TCK, "Java TCK support", {{1,"on"},{0,"off"},{0,""}}}, | 86 | {DCT4_JAVA_TCK, "Java TCK support", {{1,"on"},{0,"off"},{0,""}}}, |
87 | 87 | ||
88 | {DCT4_ALS, "Alternate Line Service (ALS)", {{1,"on"},{0,"off"},{0,""}}}, | 88 | {DCT4_ALS, "Alternate Line Service (ALS)", {{1,"on"},{0,"off"},{0,""}}}, |
89 | {DCT4_A52, "Ciphering alghoritm A52", {{1,"on"},{0,"off"},{0,""}}}, | 89 | {DCT4_A52, "Ciphering alghoritm A52", {{1,"on"},{0,"off"},{0,""}}}, |
90 | {DCT4_CSP, "Customer Service Profile", {{0,"off"},{1,"on"},{0,""}}}, | 90 | {DCT4_CSP, "Customer Service Profile", {{0,"off"},{1,"on"},{0,""}}}, |
91 | {DCT4_EONS, "EONS support", {{1,"on"},{0,"off"},{0,""}}}, | 91 | {DCT4_EONS, "EONS support", {{1,"on"},{0,"off"},{0,""}}}, |
92 | {DCT4_3GINDICATOR, "3G indicator", {{1,"on"},{0,"off"},{0,""}}}, | 92 | {DCT4_3GINDICATOR, "3G indicator", {{1,"on"},{0,"off"},{0,""}}}, |
93 | {DCT4_DISPLAY_PHONE_NAME, "Display both number and name for incoming calls",{{1,"on"},{0,"off"},{0,""}}}, | 93 | {DCT4_DISPLAY_PHONE_NAME, "Display both number and name for incoming calls",{{1,"on"},{0,"off"},{0,""}}}, |
94 | {DCT4_DISPLAY_WAP_PROFILE, "Display selected WAP profile name instead of Home option menu in Services",{{1,"on"},{0,"off"},{0,""}}}, | 94 | {DCT4_DISPLAY_WAP_PROFILE, "Display selected WAP profile name instead of Home option menu in Services",{{1,"on"},{0,"off"},{0,""}}}, |
95 | 95 | ||
96 | {DCT4_GAMES_WAP_DOWNLOAD, "Games WAP download", {{1,"on"},{0,"off"},{0,""}}}, | 96 | {DCT4_GAMES_WAP_DOWNLOAD, "Games WAP download", {{1,"on"},{0,"off"},{0,""}}}, |
97 | {DCT4_GAMES_SCORE_SEND, "Games WAP score send", {{1,"on"},{0,"off"},{0,""}}}, | 97 | {DCT4_GAMES_SCORE_SEND, "Games WAP score send", {{1,"on"},{0,"off"},{0,""}}}, |
98 | {DCT4_GAMES_URL_CHECK, "Games URL check", {{1,"on"},{0,"off"},{0,""}}}, | 98 | {DCT4_GAMES_URL_CHECK, "Games URL check", {{1,"on"},{0,"off"},{0,""}}}, |
99 | 99 | ||
100 | {DCT4_BLUETOOTH_MENU, "Bluetooth menu", {{1,"on"},{0,"off"},{0,""}}}, | 100 | {DCT4_BLUETOOTH_MENU, "Bluetooth menu", {{1,"on"},{0,"off"},{0,""}}}, |
101 | {DCT4_WAP_BOOKMARKS_MENU, "Bookmarks menu in Services", {{1,"on"},{0,"off"},{0,""}}}, | 101 | {DCT4_WAP_BOOKMARKS_MENU, "Bookmarks menu in Services", {{1,"on"},{0,"off"},{0,""}}}, |
102 | {DCT4_WAP_BOOKMARKS_MENU2, "Bookmarks menu in Services", {{3,"bookmarks & download"},{0,"off"},{0,""}}}, | 102 | {DCT4_WAP_BOOKMARKS_MENU2, "Bookmarks menu in Services", {{3,"bookmarks & download"},{0,"off"},{0,""}}}, |
103 | {DCT4_WAP_GOTO_MENU, "GoTo menu in Services", {{0,"on"},{1,"off"},{0,""}}}, | 103 | {DCT4_WAP_GOTO_MENU, "GoTo menu in Services", {{0,"on"},{1,"off"},{0,""}}}, |
104 | {DCT4_WAP_SETTINGS_MENU, "Profiles menu in Services", {{0,"on"},{1,"off"},{0,""}}}, | 104 | {DCT4_WAP_SETTINGS_MENU, "Profiles menu in Services", {{0,"on"},{1,"off"},{0,""}}}, |
105 | {DCT4_SERVICES_GAMES_APP_GALLERY,"Services menu in Games/Apps/Gallery",{{1,"on"},{0,"off"},{0,""}}}, | 105 | {DCT4_SERVICES_GAMES_APP_GALLERY,"Services menu in Games/Apps/Gallery",{{1,"on"},{0,"off"},{0,""}}}, |
106 | {DCT4_JAVA_GAMES_MENU, "Java games menu in Games", {{1,"on"},{0,"off"},{0,""}}}, | 106 | {DCT4_JAVA_GAMES_MENU, "Java games menu in Games", {{1,"on"},{0,"off"},{0,""}}}, |
107 | {DCT4_SAT_CONFIRM_MENU, "Can use confirming SIM service actions", {{1,"on"},{0,"off"},{0,""}}}, | 107 | {DCT4_SAT_CONFIRM_MENU, "Can use confirming SIM service actions", {{1,"on"},{0,"off"},{0,""}}}, |
108 | {DCT4_INSTANT_MESS_MENU, "Instant Messaging in Messages",{{1,"on"},{0,"off"},{0,""}}}, | 108 | {DCT4_INSTANT_MESS_MENU, "Instant Messaging in Messages",{{1,"on"},{0,"off"},{0,""}}}, |
109 | {DCT4_CONFIRM_ALS, "Confirm using ALS", {{1,"on"},{0,"off"},{0,""}}}, | 109 | {DCT4_CONFIRM_ALS, "Confirm using ALS", {{1,"on"},{0,"off"},{0,""}}}, |
110 | {DCT4_BOOKMARK_GOTO_MENU, "Bookmarks in GoTo menu", {{1,"on"},{0,"off"},{0,""}}}, | 110 | {DCT4_BOOKMARK_GOTO_MENU, "Bookmarks in GoTo menu", {{1,"on"},{0,"off"},{0,""}}}, |
111 | 111 | ||
112 | {DCT4_5100_IDENTIFY, "Phone identification", {{1,"NPM-6U"},{0,"NPM-6"},{0,""}}}, | 112 | {DCT4_5100_IDENTIFY, "Phone identification", {{1,"NPM-6U"},{0,"NPM-6"},{0,""}}}, |
113 | 113 | ||
114 | #ifdef DEBUG | 114 | #ifdef DEBUG |
115 | {DCT4_TEST,"",{{1,"1"},{0,"0"}}}, | 115 | {DCT4_TEST,"",{{1,"1"},{0,"0"}}}, |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | {0, "", {{0,""}}} | 118 | {0, "", {{0,""}}} |
119 | }; | 119 | }; |
120 | 120 | ||
121 | static DCT4_Phone_Features DCT4PhoneFeatures[] = { | 121 | static DCT4_Phone_Features DCT4PhoneFeatures[] = { |
122 | /*3100*/ {"RH-19",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,8}, | 122 | /*3100*/ {"RH-19",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,8}, |
123 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 123 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
124 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 124 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
125 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 125 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
126 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 126 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
127 | {DCT4_EONS,28},{DCT4_3GINDICATOR,30},{DCT4_INSTANT_MESS_MENU,33}, | 127 | {DCT4_EONS,28},{DCT4_3GINDICATOR,30},{DCT4_INSTANT_MESS_MENU,33}, |
128 | {DCT4_CONFIRM_ALS,35}, | 128 | {DCT4_CONFIRM_ALS,35}, |
129 | {0,0}}}, | 129 | {0,0}}}, |
130 | /*3200*/ {"RH-30",{{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14}, | 130 | /*3200*/ {"RH-30",{{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14}, |
131 | {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20}, | 131 | {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20}, |
132 | {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23}, | 132 | {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23}, |
133 | {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28}, | 133 | {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28}, |
134 | {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33}, | 134 | {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33}, |
135 | {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45}, | 135 | {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45}, |
136 | {0,0}}}, | 136 | {0,0}}}, |
137 | /*3200*/ {"RH-31",{{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14}, | 137 | /*3200*/ {"RH-31",{{DCT4_ALS,2},{DCT4_A52,4},{DCT4_CSP,5},{DCT4_GPRS_PCCH,14}, |
138 | {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20}, | 138 | {DCT4_GEA1,15},{DCT4_EOTD,18},{DCT4_WAP_SETTINGS_MENU,20}, |
139 | {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23}, | 139 | {DCT4_DISPLAY_PHONE_NAME,21},{DCT4_WAP_GOTO_MENU,23}, |
140 | {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28}, | 140 | {DCT4_SERVICES_GAMES_APP_GALLERY,26},{DCT4_3GINDICATOR,28}, |
141 | {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33}, | 141 | {DCT4_DISPLAY_WAP_PROFILE,31},{DCT4_SAT_CONFIRM_MENU,33}, |
142 | {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45}, | 142 | {DCT4_CONFIRM_ALS,34},{DCT4_EONS,40},{DCT4_ALWAYS_ONLINE,45}, |
143 | {0,0}}}, | 143 | {0,0}}}, |
144 | /*3300*/ {"NEM-1",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 144 | /*3300*/ {"NEM-1",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
145 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 145 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
146 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 146 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
147 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 147 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
148 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 148 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
149 | /*MORE*/ {0,0}}}, | 149 | /*MORE*/ {0,0}}}, |
150 | /*3510*/ {"NHM-8",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6}, | 150 | /*3510*/ {"NHM-8",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6}, |
151 | {DCT4_GAMES_WAP_DOWNLOAD,7},{DCT4_GAMES_SCORE_SEND,8}, | 151 | {DCT4_GAMES_WAP_DOWNLOAD,7},{DCT4_GAMES_SCORE_SEND,8}, |
152 | {DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13}, | 152 | {DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13}, |
153 | {DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, | 153 | {DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, |
154 | /*3510i*/{"RH-9",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,9}, | 154 | /*3510i*/{"RH-9",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4},{DCT4_GPRS_PCCH,9}, |
155 | {DCT4_DISPLAY_PHONE_NAME,14},{DCT4_WAP_GOTO_MENU,15}, | 155 | {DCT4_DISPLAY_PHONE_NAME,14},{DCT4_WAP_GOTO_MENU,15}, |
156 | {DCT4_WAP_SETTINGS_MENU,16},{DCT4_SERVICES_GAMES_APP_GALLERY,19}, | 156 | {DCT4_WAP_SETTINGS_MENU,16},{DCT4_SERVICES_GAMES_APP_GALLERY,19}, |
157 | {DCT4_DISPLAY_WAP_PROFILE,25},{0,0}}}, | 157 | {DCT4_DISPLAY_WAP_PROFILE,25},{0,0}}}, |
158 | /*3650*/ {"NHL-8",{{DCT4_ALS,1},{0,0}}}, | 158 | /*3650*/ {"NHL-8",{{DCT4_ALS,1},{0,0}}}, |
159 | /*5100*/ {"NPM-6",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 159 | /*5100*/ {"NPM-6",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
160 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 160 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
161 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 161 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
162 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 162 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
163 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 163 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
164 | {DCT4_EONS,28}, | 164 | {DCT4_EONS,28}, |
165 | // {DCT4_5100_IDENTIFY,10}, | 165 | // {DCT4_5100_IDENTIFY,10}, |
166 | {0,0}}}, | 166 | {0,0}}}, |
167 | /*5100*/ {"NPM-6U",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 167 | /*5100*/ {"NPM-6U",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
168 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 168 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
169 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 169 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
170 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 170 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
171 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 171 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
172 | {DCT4_EONS,28}, | 172 | {DCT4_EONS,28}, |
173 | // {DCT4_5100_IDENTIFY,10}, | 173 | // {DCT4_5100_IDENTIFY,10}, |
174 | {0,0}}}, | 174 | {0,0}}}, |
175 | /*6100*/ {"NPL-2",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 175 | /*6100*/ {"NPL-2",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
176 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 176 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
177 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 177 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
178 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 178 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
179 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 179 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
180 | {0,0}}}, | 180 | {0,0}}}, |
181 | /*6220*/ {"RH-20",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4}, | 181 | /*6220*/ {"RH-20",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,4}, |
182 | {DCT4_GEA1,14},{DCT4_EOTD,17},{DCT4_WAP_SETTINGS_MENU,19}, | 182 | {DCT4_GEA1,14},{DCT4_EOTD,17},{DCT4_WAP_SETTINGS_MENU,19}, |
183 | {DCT4_DISPLAY_PHONE_NAME,20},{DCT4_WAP_GOTO_MENU,22}, | 183 | {DCT4_DISPLAY_PHONE_NAME,20},{DCT4_WAP_GOTO_MENU,22}, |
184 | {DCT4_WAP_BOOKMARKS_MENU2,24},{DCT4_SERVICES_GAMES_APP_GALLERY,25}, | 184 | {DCT4_WAP_BOOKMARKS_MENU2,24},{DCT4_SERVICES_GAMES_APP_GALLERY,25}, |
185 | {DCT4_3GINDICATOR,27},{DCT4_DISPLAY_WAP_PROFILE,30},{DCT4_SAT_CONFIRM_MENU,32}, | 185 | {DCT4_3GINDICATOR,27},{DCT4_DISPLAY_WAP_PROFILE,30},{DCT4_SAT_CONFIRM_MENU,32}, |
186 | {DCT4_CONFIRM_ALS,33},{DCT4_JAVA_TCK,36},{DCT4_BOOKMARK_GOTO_MENU,37}, | 186 | {DCT4_CONFIRM_ALS,33},{DCT4_JAVA_TCK,36},{DCT4_BOOKMARK_GOTO_MENU,37}, |
187 | {0,0}}}, | 187 | {0,0}}}, |
188 | /*6310*/ {"NPE-4",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, | 188 | /*6310*/ {"NPE-4",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, |
189 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_BLUETOOTH_MENU,10}, | 189 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_BLUETOOTH_MENU,10}, |
190 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, | 190 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, |
191 | /*6310i*/{"NPL-1",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, | 191 | /*6310i*/{"NPL-1",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, |
192 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9}, | 192 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9}, |
193 | {DCT4_BLUETOOTH_MENU,10},{DCT4_USE_PREF_SIM_NET,11}, | 193 | {DCT4_BLUETOOTH_MENU,10},{DCT4_USE_PREF_SIM_NET,11}, |
194 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_EOTD,16}, | 194 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_EOTD,16}, |
195 | {DCT4_ALWAYS_ONLINE,17},{DCT4_JAVA_GAMES_MENU,18}, | 195 | {DCT4_ALWAYS_ONLINE,17},{DCT4_JAVA_GAMES_MENU,18}, |
196 | {DCT4_WAP_BOOKMARKS_MENU,20},{DCT4_WAP_SETTINGS_MENU,21}, | 196 | {DCT4_WAP_BOOKMARKS_MENU,20},{DCT4_WAP_SETTINGS_MENU,21}, |
197 | {DCT4_WAP_PUSH,28},{DCT4_WAP_GOTO_MENU,29},{0,0}}}, | 197 | {DCT4_WAP_PUSH,28},{DCT4_WAP_GOTO_MENU,29},{0,0}}}, |
198 | /*6510*/ {"NPM-9",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, | 198 | /*6510*/ {"NPM-9",{{DCT4_ALS,1},{DCT4_A52,3},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, |
199 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9}, | 199 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9}, |
200 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, | 200 | {DCT4_GPRS_PCCH,13},{DCT4_GEA1,15},{DCT4_ALWAYS_ONLINE,18},{0,0}}}, |
201 | /*6610*/ {"NHL-4U",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 201 | /*6610*/ {"NHL-4U",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
202 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 202 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
203 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 203 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
204 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 204 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
205 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 205 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
206 | {0,0}}}, | 206 | {0,0}}}, |
207 | /*6800*/ {"NHL-6",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 207 | /*6800*/ {"NHL-6",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
208 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 208 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
209 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 209 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
210 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 210 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
211 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 211 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
212 | /*MORE*/ {0,0}}}, | 212 | /*MORE*/ {0,0}}}, |
213 | /*7210*/ {"NHL-4",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 213 | /*7210*/ {"NHL-4",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
214 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 214 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
215 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 215 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
216 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 216 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
217 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 217 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
218 | {0,0}}}, | 218 | {0,0}}}, |
219 | /*7250*/ {"NHL-4J",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 219 | /*7250*/ {"NHL-4J",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
220 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 220 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
221 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 221 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
222 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 222 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
223 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 223 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
224 | {0,0}}}, | 224 | {0,0}}}, |
225 | /*7250i*/{"NHL-4JX",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, | 225 | /*7250i*/{"NHL-4JX",{{DCT4_ALS,1},{DCT4_CSP,4},{DCT4_GAMES_URL_CHECK,5},{DCT4_GPRS_PCCH,8}, |
226 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, | 226 | {DCT4_GEA1,9},{DCT4_ALWAYS_ONLINE,11},{DCT4_EOTD,12}, |
227 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, | 227 | {DCT4_DISPLAY_PHONE_NAME,17},{DCT4_WAP_GOTO_MENU,18}, |
228 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, | 228 | {DCT4_WAP_SETTINGS_MENU,19},{DCT4_SERVICES_GAMES_APP_GALLERY,22}, |
229 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, | 229 | {DCT4_DISPLAY_WAP_PROFILE,26},{DCT4_SAT_CONFIRM_MENU,27}, |
230 | /*MORE*/ {0,0}}}, | 230 | /*MORE*/ {0,0}}}, |
231 | /*8310*/{"NHM-7",{{DCT4_ALS,1},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, | 231 | /*8310*/{"NHM-7",{{DCT4_ALS,1},{DCT4_CSP,6},{DCT4_GAMES_WAP_DOWNLOAD,7}, |
232 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13}, | 232 | {DCT4_GAMES_SCORE_SEND,8},{DCT4_GAMES_URL_CHECK,9},{DCT4_GPRS_PCCH,13}, |
233 | {DCT4_ALWAYS_ONLINE,18},{0,0}}}, | 233 | {DCT4_ALWAYS_ONLINE,18},{0,0}}}, |
234 | {"", {{0,0}}} | 234 | {"", {{0,0}}} |
235 | }; | 235 | }; |
236 | 236 | ||
237 | static GSM_Error DCT4_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) | 237 | static GSM_Error DCT4_ReplySetPPS(GSM_Protocol_Message msg, GSM_StateMachine *s) |
238 | { | 238 | { |
239 | printf("Setting done OK\n"); | 239 | printf("Setting done OK\n"); |
240 | return ERR_NONE; | 240 | return ERR_NONE; |
241 | } | 241 | } |
242 | 242 | ||
243 | void DCT4SetPhoneMenus(int argc, char *argv[]) | 243 | void DCT4SetPhoneMenus(int argc, char *argv[]) |
244 | { | 244 | { |
245 | int current = 10,i=0,j,z; | 245 | int current = 10,i=0,j,z; |
246 | unsigned char reqSet[200] = { | 246 | unsigned char reqSet[200] = { |
247 | N7110_FRAME_HEADER,0x04,0x00,0x01,0x47,0x48,0x02, | 247 | N7110_FRAME_HEADER,0x04,0x00,0x01,0x47,0x48,0x02, |
248 | 0x00}; /* Number of changed features */ | 248 | 0x00}; /* Number of changed features */ |
249 | 249 | ||
250 | if (CheckDCT4Only()!=ERR_NONE) return; | 250 | if (CheckDCT4Only()!=ERR_NONE) return; |
251 | 251 | ||
252 | s.User.UserReplyFunctions=UserReplyFunctions4; | 252 | s.User.UserReplyFunctions=UserReplyFunctions4; |
253 | 253 | ||
254 | while (DCT4PhoneFeatures[i].Model[0] != 0x00) { | 254 | while (DCT4PhoneFeatures[i].Model[0] != 0x00) { |
255 | if (!strcmp(DCT4PhoneFeatures[i].Model,s.Phone.Data.Model)) { | 255 | if (!strcmp(DCT4PhoneFeatures[i].Model,s.Phone.Data.Model)) { |
256 | j = 0; | 256 | j = 0; |
257 | while (DCT4PhoneFeatures[i].Features[j].Name != 0x00) { | 257 | while (DCT4PhoneFeatures[i].Features[j].Name != 0x00) { |
258 | z = 0; | 258 | z = 0; |
259 | while (DCT4Features[z].Name != 0x00) { | 259 | while (DCT4Features[z].Name != 0x00) { |
260 | if (DCT4Features[z].Name == DCT4PhoneFeatures[i].Features[j].Name) { | 260 | if (DCT4Features[z].Name == DCT4PhoneFeatures[i].Features[j].Name) { |
261 | printf("%s : %s\n",DCT4Features[z].Text,DCT4Features[z].Values[0].Text); | 261 | printf("%s : %s\n",DCT4Features[z].Text,DCT4Features[z].Values[0].Text); |
262 | reqSet[9]++; /* Number of features */ | 262 | reqSet[9]++; /* Number of features */ |
263 | reqSet[current++] = DCT4PhoneFeatures[i].Features[j].Number; /* Feature number */ | 263 | reqSet[current++] = DCT4PhoneFeatures[i].Features[j].Number; /* Feature number */ |
264 | reqSet[current++] = DCT4Features[z].Values[0].Value; /* Value */ | 264 | reqSet[current++] = DCT4Features[z].Values[0].Value; /* Value */ |
265 | break; | 265 | break; |
266 | } | 266 | } |
267 | z++; | 267 | z++; |
268 | } | 268 | } |
269 | j++; | 269 | j++; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | i++; | 272 | i++; |
273 | } | 273 | } |
274 | 274 | ||
275 | if (current == 10) { | 275 | if (current == 10) { |
276 | printf("Sorry, but configuration matrix for this model is not added yet. Please report\n"); | 276 | printf("Sorry, but configuration matrix for this model is not added yet. Please report\n"); |
277 | return; | 277 | return; |
278 | } | 278 | } |
279 | 279 | ||
280 | reqSet[current++] = 0x00; | 280 | reqSet[current++] = 0x00; |
281 | reqSet[current++] = 0x00; | 281 | reqSet[current++] = 0x00; |
282 | 282 | ||
283 | error=GSM_WaitFor (&s, reqSet, current, 0x1b, 4, ID_User1); | 283 | error=GSM_WaitFor (&s, reqSet, current, 0x1b, 4, ID_User1); |
284 | Print_Error(error); | 284 | Print_Error(error); |
285 | } | 285 | } |
286 | 286 | ||
287 | DCT4_Phone_Tests DCT4Tests; | 287 | DCT4_Phone_Tests DCT4Tests; |
288 | 288 | ||
289 | static GSM_Error DCT4_ReplyTestsNames(GSM_Protocol_Message msg, GSM_StateMachine *s) | 289 | static GSM_Error DCT4_ReplyTestsNames(GSM_Protocol_Message msg, GSM_StateMachine *s) |
290 | { | 290 | { |
291 | int i,pos; | 291 | int i,pos; |
292 | 292 | ||
293 | DCT4Tests.Num = msg.Buffer[5]; | 293 | DCT4Tests.Num = msg.Buffer[5]; |
294 | pos = 6; | 294 | pos = 6; |
295 | 295 | ||
296 | smprintf(s,"%i names for phone tests received\n",msg.Buffer[5]); | 296 | smprintf(s,"%i names for phone tests received\n",msg.Buffer[5]); |
297 | for (i=0;i<msg.Buffer[5];i++) { | 297 | for (i=0;i<msg.Buffer[5];i++) { |
298 | strcpy(DCT4Tests.Tests[i].Name,msg.Buffer+pos+4); | 298 | strcpy(DCT4Tests.Tests[i].Name,msg.Buffer+pos+4); |
299 | DCT4Tests.Tests[i].ID = msg.Buffer[pos+2]; | 299 | DCT4Tests.Tests[i].ID = msg.Buffer[pos+2]; |
300 | smprintf(s,"%x.\"%s\"\n",DCT4Tests.Tests[i].ID,DCT4Tests.Tests[i].Name); | 300 | smprintf(s,"%x.\"%s\"\n",DCT4Tests.Tests[i].ID,DCT4Tests.Tests[i].Name); |
301 | pos+=msg.Buffer[pos+1]; | 301 | pos+=msg.Buffer[pos+1]; |
302 | } | 302 | } |
303 | 303 | ||
304 | return ERR_NONE; | 304 | return ERR_NONE; |
305 | } | 305 | } |
306 | 306 | ||
307 | static GSM_Error DCT4_ReplyTestsStartup(GSM_Protocol_Message msg, GSM_StateMachine *s) | 307 | static GSM_Error DCT4_ReplyTestsStartup(GSM_Protocol_Message msg, GSM_StateMachine *s) |
308 | { | 308 | { |
309 | int i,pos,j; | 309 | int i,pos,j; |
310 | bool found; | 310 | bool found; |
311 | 311 | ||
312 | pos = 10; | 312 | pos = 10; |
313 | 313 | ||
314 | for (i=0;i<msg.Buffer[8];i++) { | 314 | for (i=0;i<msg.Buffer[8];i++) { |
315 | found = false; | 315 | found = false; |
316 | for (j=0;j<DCT4Tests.Num;j++) { | 316 | for (j=0;j<DCT4Tests.Num;j++) { |
317 | if (DCT4Tests.Tests[j].ID == msg.Buffer[pos]) { | 317 | if (DCT4Tests.Tests[j].ID == msg.Buffer[pos]) { |
318 | DCT4Tests.Tests[j].Startup = true; | 318 | DCT4Tests.Tests[j].Startup = true; |
319 | found = true; | 319 | found = true; |
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | if (!found) printf("%x ",msg.Buffer[pos]); | 323 | if (!found) printf("%x ",msg.Buffer[pos]); |
324 | pos++; | 324 | pos++; |
325 | } | 325 | } |
326 | 326 | ||
327 | return ERR_NONE; | 327 | return ERR_NONE; |
328 | } | 328 | } |
329 | 329 | ||
330 | static GSM_Error DCT4_ReplyTestsStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) | 330 | static GSM_Error DCT4_ReplyTestsStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) |
331 | { | 331 | { |
332 | int i,pos,j; | 332 | int i,pos,j; |
333 | 333 | ||
334 | pos = 6; | 334 | pos = 6; |
335 | 335 | ||
336 | smprintf(s,"%i status entries for phone tests received\n",msg.Buffer[5]); | 336 | smprintf(s,"%i status entries for phone tests received\n",msg.Buffer[5]); |
337 | for (i=0;i<msg.Buffer[5];i++) { | 337 | for (i=0;i<msg.Buffer[5];i++) { |
338 | for (j=0;j<DCT4Tests.Num;j++) { | 338 | for (j=0;j<DCT4Tests.Num;j++) { |
339 | if (DCT4Tests.Tests[j].ID == msg.Buffer[pos+2]) { | 339 | if (DCT4Tests.Tests[j].ID == msg.Buffer[pos+2]) { |
340 | printf("\"%40s\" : ",DCT4Tests.Tests[j].Name); | 340 | printf("\"%40s\" : ",DCT4Tests.Tests[j].Name); |
341 | switch(msg.Buffer[pos+3]) { | 341 | switch(msg.Buffer[pos+3]) { |
342 | case 0x00: printf("Passed"); break; | 342 | case 0x00: printf("Passed"); break; |
343 | case 0x01: printf("Fail"); break; | 343 | case 0x01: printf("Fail"); break; |
344 | case 0x03: printf("Not executed"); break; | 344 | case 0x03: printf("Not executed"); break; |
345 | case 0x06: printf("No signal"); break; | 345 | case 0x06: printf("No signal"); break; |
346 | case 0x0D: printf("Timeout"); break; | 346 | case 0x0D: printf("Timeout"); break; |
347 | default : printf("Unknown (%x)",msg.Buffer[pos+3]); | 347 | default : printf("Unknown (%x)",msg.Buffer[pos+3]); |
348 | } | 348 | } |
349 | if (DCT4Tests.Tests[j].Startup) printf(" (startup)"); | 349 | if (DCT4Tests.Tests[j].Startup) printf(" (startup)"); |
350 | printf("\n"); | 350 | printf("\n"); |
351 | break; | 351 | break; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | pos+=msg.Buffer[pos+1]; | 354 | pos+=msg.Buffer[pos+1]; |
355 | } | 355 | } |
356 | 356 | ||
357 | return ERR_NONE; | 357 | return ERR_NONE; |
358 | } | 358 | } |
359 | 359 | ||
360 | void DCT4SelfTests(int argc, char *argv[]) | 360 | void DCT4SelfTests(int argc, char *argv[]) |
361 | { | 361 | { |
362 | int j; | 362 | int j; |
363 | unsigned char GetDoneST[6] = {0x00, 0x08, 0x01, 0x04, 0x01, 0x00}; | 363 | unsigned char GetDoneST[6] = {0x00, 0x08, 0x01, 0x04, 0x01, 0x00}; |
364 | unsigned char GetDoneST2[6] = {0x00, 0x08, 0x02, 0x04, 0x02, 0x00}; | 364 | unsigned char GetDoneST2[6] = {0x00, 0x08, 0x02, 0x04, 0x02, 0x00}; |
365 | unsigned char GetNames[6] = {0x00, 0x08, 0x03, 0x06, 0x03, 0x00}; | 365 | unsigned char GetNames[6] = {0x00, 0x08, 0x03, 0x06, 0x03, 0x00}; |
366 | unsigned char GetStatus[6] = {0x00, 0x08, 0x04, 0x02, 0x03, 0x00}; | 366 | unsigned char GetStatus[6] = {0x00, 0x08, 0x04, 0x02, 0x03, 0x00}; |
367 | 367 | ||
368 | unsigned char RunALL[6] = {0x00, 0x06, 0x04, 0x00, 0x03, 0x00}; | 368 | unsigned char RunALL[6] = {0x00, 0x06, 0x04, 0x00, 0x03, 0x00}; |
369 | 369 | ||
370 | //unsigned char GetID[6] = {0x00, 0x08, 0x00, 0x04, 0x03, 0x00};//tests ID | 370 | //unsigned char GetID[6] = {0x00, 0x08, 0x00, 0x04, 0x03, 0x00};//tests ID |
371 | 371 | ||
372 | if (CheckDCT4Only()!=ERR_NONE) return; | 372 | if (CheckDCT4Only()!=ERR_NONE) return; |
373 | 373 | ||
374 | s.User.UserReplyFunctions=UserReplyFunctions4; | 374 | s.User.UserReplyFunctions=UserReplyFunctions4; |
375 | 375 | ||
376 | if (answer_yes2("Run all tests now ?")) { | 376 | if (answer_yes2("Run all tests now ?")) { |
377 | error=GSM_WaitFor (&s, RunALL, 6, 0x35, 4, ID_User1); | 377 | error=GSM_WaitFor (&s, RunALL, 6, 0x35, 4, ID_User1); |
378 | Print_Error(error); | 378 | Print_Error(error); |
379 | } | 379 | } |
380 | 380 | ||
381 | error=GSM_WaitFor (&s, GetNames, 6, 0x35, 4, ID_User1); | 381 | error=GSM_WaitFor (&s, GetNames, 6, 0x35, 4, ID_User1); |
382 | Print_Error(error); | 382 | Print_Error(error); |
383 | 383 | ||
384 | for (j=0;j<DCT4Tests.Num;j++) DCT4Tests.Tests[j].Startup = false; | 384 | for (j=0;j<DCT4Tests.Num;j++) DCT4Tests.Tests[j].Startup = false; |
385 | 385 | ||
386 | error=GSM_WaitFor (&s, GetDoneST, 6, 0x35, 4, ID_User3); | 386 | error=GSM_WaitFor (&s, GetDoneST, 6, 0x35, 4, ID_User3); |
387 | Print_Error(error); | 387 | Print_Error(error); |
388 | 388 | ||
389 | error=GSM_WaitFor (&s, GetDoneST2, 6, 0x35, 4, ID_User3); | 389 | error=GSM_WaitFor (&s, GetDoneST2, 6, 0x35, 4, ID_User3); |
390 | Print_Error(error); | 390 | Print_Error(error); |
391 | 391 | ||
392 | error=GSM_WaitFor (&s, GetStatus, 6, 0x35, 4, ID_User2); | 392 | error=GSM_WaitFor (&s, GetStatus, 6, 0x35, 4, ID_User2); |
393 | Print_Error(error); | 393 | Print_Error(error); |
394 | } | 394 | } |
395 | 395 | ||
396 | static GSM_Error DCT4_ReplyVibra(GSM_Protocol_Message msg, GSM_StateMachine *s) | 396 | static GSM_Error DCT4_ReplyVibra(GSM_Protocol_Message msg, GSM_StateMachine *s) |
397 | { | 397 | { |
398 | #ifdef DEBUG | 398 | #ifdef DEBUG |
399 | switch (msg.Buffer[3]) { | 399 | switch (msg.Buffer[3]) { |
400 | case 0x0D : dbgprintf("Vibra state set OK\n"); break; | 400 | case 0x0D : dbgprintf("Vibra state set OK\n"); break; |
401 | case 0x0F : dbgprintf("Vibra power set OK\n"); break; | 401 | case 0x0F : dbgprintf("Vibra power set OK\n"); break; |
402 | } | 402 | } |
403 | #endif | 403 | #endif |
404 | return ERR_NONE; | 404 | return ERR_NONE; |
405 | } | 405 | } |
406 | 406 | ||
407 | static GSM_Error DCT4EnableVibra(GSM_StateMachine *s, bool enable) | 407 | static GSM_Error DCT4EnableVibra(GSM_StateMachine *s, bool enable) |
408 | { | 408 | { |
409 | /* Enables or disables vibra */ | 409 | /* Enables or disables vibra */ |
410 | unsigned char Control[6] = {N7110_FRAME_HEADER,0x0C, | 410 | unsigned char Control[6] = {N7110_FRAME_HEADER,0x0C, |
411 | 0x01, /* 0x01 = On, 0x00 = Off */ | 411 | 0x01, /* 0x01 = On, 0x00 = Off */ |
412 | 0x00}; | 412 | 0x00}; |
413 | 413 | ||
414 | if (!enable) Control[4] = 0x00; | 414 | if (!enable) Control[4] = 0x00; |
415 | return GSM_WaitFor (s, Control, 6, 0x1C, 4, ID_User3); | 415 | return GSM_WaitFor (s, Control, 6, 0x1C, 4, ID_User3); |
416 | } | 416 | } |
417 | 417 | ||
418 | void DCT4SetVibraLevel(int argc, char *argv[]) | 418 | void DCT4SetVibraLevel(int argc, char *argv[]) |
419 | { | 419 | { |
420 | GSM_DateTimeDate; | 420 | GSM_DateTimeDate; |
421 | unsigned inti,j; | 421 | unsigned inti,j; |
422 | 422 | ||
423 | /* Set vibra level */ | 423 | /* Set vibra level */ |
424 | unsigned char SetLevel[6] = {N7110_FRAME_HEADER,0x0E, | 424 | unsigned char SetLevel[6] = {N7110_FRAME_HEADER,0x0E, |
425 | 0x64,/* Vibra power (in percent) */ | 425 | 0x64,/* Vibra power (in percent) */ |
426 | 0x00}; | 426 | 0x00}; |
427 | 427 | ||
428 | GSM_Init(true); | 428 | GSM_Init(true); |
429 | 429 | ||
430 | CheckDCT4(); | 430 | CheckDCT4(); |
431 | 431 | ||
432 | s.User.UserReplyFunctions=UserReplyFunctions4; | 432 | s.User.UserReplyFunctions=UserReplyFunctions4; |
433 | 433 | ||
434 | SetLevel[4] = atoi(argv[2]); | 434 | SetLevel[4] = atoi(argv[2]); |
435 | error=GSM_WaitFor (&s, SetLevel, 6, 0x1C, 4, ID_User3); | 435 | error=GSM_WaitFor (&s, SetLevel, 6, 0x1C, 4, ID_User3); |
436 | Print_Error(error); | 436 | Print_Error(error); |
437 | 437 | ||
438 | error=DCT4EnableVibra(&s, true); | 438 | error=DCT4EnableVibra(&s, true); |
439 | Print_Error(error); | 439 | Print_Error(error); |
440 | 440 | ||
441 | for (i=0;i<3;i++) { | 441 | for (i=0;i<3;i++) { |
442 | GSM_GetCurrentDateTime (&Date); | 442 | GSM_GetCurrentDateTime (&Date); |
443 | j=Date.Second; | 443 | j=Date.Second; |
444 | while (j==Date.Second) { | 444 | while (j==Date.Second) { |
445 | my_sleep(10); | 445 | my_sleep(10); |
446 | GSM_GetCurrentDateTime(&Date); | 446 | GSM_GetCurrentDateTime(&Date); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | error=DCT4EnableVibra(&s, false); | 450 | error=DCT4EnableVibra(&s, false); |
451 | Print_Error(error); | 451 | Print_Error(error); |
452 | 452 | ||
453 | GSM_Terminate(); | 453 | GSM_Terminate(); |
454 | } | 454 | } |
455 | 455 | ||
456 | void DCT4VibraTest(int argc, char *argv[]) | 456 | void DCT4VibraTest(int argc, char *argv[]) |
457 | { | 457 | { |
458 | unsigned char ans[200]; | 458 | unsigned char ans[200]; |
459 | 459 | ||
460 | if (CheckDCT4Only()!=ERR_NONE) return; | 460 | if (CheckDCT4Only()!=ERR_NONE) return; |
461 | 461 | ||
462 | s.User.UserReplyFunctions=UserReplyFunctions4; | 462 | s.User.UserReplyFunctions=UserReplyFunctions4; |
463 | 463 | ||
464 | error=DCT4EnableVibra(&s, true); | 464 | error=DCT4EnableVibra(&s, true); |
465 | Print_Error(error); | 465 | Print_Error(error); |
466 | 466 | ||
467 | printf("Press any key to continue...\n"); | 467 | printf("Press any key to continue...\n"); |
468 | GetLine(stdin, ans, 99); | 468 | GetLine(stdin, ans, 99); |
469 | 469 | ||
470 | error=DCT4EnableVibra(&s, false); | 470 | error=DCT4EnableVibra(&s, false); |
471 | Print_Error(error); | 471 | Print_Error(error); |
472 | } | 472 | } |
473 | 473 | ||
474 | #ifdef DEBUG | 474 | #ifdef DEBUG |
475 | static GSM_Error DCT4_ReplyResetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) | 475 | static GSM_Error DCT4_ReplyResetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) |
476 | { | 476 | { |
477 | switch (msg.Buffer[3]) { | 477 | switch (msg.Buffer[3]) { |
478 | case 0x05: | 478 | case 0x05: |
479 | printf("Security code set to \"12345\"\n"); | 479 | printf("Security code set to \"12345\"\n"); |
480 | return ERR_NONE; | 480 | return ERR_NONE; |
481 | case 0x06: | 481 | case 0x06: |
482 | printf("Unknown reason. Can't reset your security code\n"); | 482 | printf("Unknown reason. Can't reset your security code\n"); |
483 | return ERR_UNKNOWN; | 483 | return ERR_UNKNOWN; |
484 | } | 484 | } |
485 | return ERR_UNKNOWNRESPONSE; | 485 | return ERR_UNKNOWNRESPONSE; |
486 | } | 486 | } |
487 | 487 | ||
488 | void DCT4ResetSecurityCode(int argc, char *argv[]) | 488 | void DCT4ResetSecurityCode(int argc, char *argv[]) |
489 | { | 489 | { |
490 | unsigned inti; | 490 | unsigned inti; |
491 | unsigned char ResetCode[30] = {0x00,0x06,0x03,0x04,0x01, | 491 | unsigned char ResetCode[30] = {0x00,0x06,0x03,0x04,0x01, |
492 | '1','2','3','4','5','6','7','8','9','0',/* Old code */ | 492 | '1','2','3','4','5','6','7','8','9','0',/* Old code */ |
493 | 0x00, | 493 | 0x00, |
494 | '1','2','3','4','5',0x00,0x00,0x00,0x00,0x00, /* New code */ | 494 | '1','2','3','4','5',0x00,0x00,0x00,0x00,0x00, /* New code */ |
495 | 0x00}; | 495 | 0x00}; |
496 | 496 | ||
497 | if (CheckDCT4Only()!=ERR_NONE) return; | 497 | if (CheckDCT4Only()!=ERR_NONE) return; |
498 | 498 | ||
499 | s.User.UserReplyFunctions=UserReplyFunctions4; | 499 | s.User.UserReplyFunctions=UserReplyFunctions4; |
500 | 500 | ||
501 | error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2); | 501 | error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2); |
502 | if (error == ERR_UNKNOWN) { | 502 | if (error == ERR_UNKNOWN) { |
503 | if (answer_yes2("Try brutal force ?")) { | 503 | if (answer_yes2("Try brutal force ?")) { |
504 | for (i=10000;i<9999999;i++) { | 504 | for (i=10000;i<9999999;i++) { |
505 | printf("Trying %i\n",i); | 505 | printf("Trying %i\n",i); |
506 | memset(ResetCode+6,0,22); | 506 | memset(ResetCode+6,0,22); |
507 | sprintf(ResetCode+5,"%i",i); | 507 | sprintf(ResetCode+5,"%i",i); |
508 | sprintf(ResetCode+16,"12345"); | 508 | sprintf(ResetCode+16,"12345"); |
509 | error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2); | 509 | error=GSM_WaitFor (&s, ResetCode, 27, 0x08, 4, ID_User2); |
510 | if (error == ERR_NONE) break; | 510 | if (error == ERR_NONE) break; |
511 | } | 511 | } |
512 | } | 512 | } |
513 | } else Print_Error(error); | 513 | } else Print_Error(error); |
514 | } | 514 | } |
515 | #endif | 515 | #endif |
516 | 516 | ||
517 | char SecLength; | 517 | char SecLength; |
518 | 518 | ||
519 | static GSM_Error DCT4_ReplyGetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) | 519 | static GSM_Error DCT4_ReplyGetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) |
520 | { | 520 | { |
521 | if (msg.Length > 12) { | 521 | if (msg.Length > 12) { |
522 | SecLength = msg.Buffer[13]; | 522 | SecLength = msg.Buffer[13]; |
523 | if ((msg.Buffer[17]+18) == msg.Length) { | 523 | if ((msg.Buffer[17]+18) == msg.Length) { |
524 | printf("Security code is %s\n",msg.Buffer+18); | 524 | printf("Security code is %s\n",msg.Buffer+18); |
525 | // DumpMessage(stdout, msg.Buffer, msg.Length); | 525 | // DumpMessage(stdout, msg.Buffer, msg.Length); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | return ERR_NONE; | 528 | return ERR_NONE; |
529 | } | 529 | } |
530 | 530 | ||
531 | void DCT4GetSecurityCode(int argc, char *argv[]) | 531 | void DCT4GetSecurityCode(int argc, char *argv[]) |
532 | { | 532 | { |
533 | GSM_Error error; | 533 | GSM_Error error; |
534 | unsigned char getlen[]={0x00, 0x08, 0x01, 0x0C, | 534 | unsigned char getlen[]={0x00, 0x08, 0x01, 0x0C, |
535 | 0x00, 0x23, //ID | 535 | 0x00, 0x23, //ID |
536 | 0x00, 0x00, //Index | 536 | 0x00, 0x00, //Index |
537 | 0x00, 0x00}; | 537 | 0x00, 0x00}; |
538 | unsigned char read[]={0x00, 0x08, 0x02, 0x04, | 538 | unsigned char read[]={0x00, 0x08, 0x02, 0x04, |
539 | 0x00, 0x23, //ID | 539 | 0x00, 0x23, //ID |
540 | 0x00, 0x00, //Index | 540 | 0x00, 0x00, //Index |
541 | 0x00, 0x00, 0x00, 0x00, 0x00, | 541 | 0x00, 0x00, 0x00, 0x00, 0x00, |
542 | 0x00, 0x00, 0x00, 0x00, | 542 | 0x00, 0x00, 0x00, 0x00, |
543 | 0x00}; //Length | 543 | 0x00}; //Length |
544 | 544 | ||
545 | if (CheckDCT4Only()!=ERR_NONE) return; | 545 | if (CheckDCT4Only()!=ERR_NONE) return; |
546 | 546 | ||
547 | s.User.UserReplyFunctions=UserReplyFunctions4; | 547 | s.User.UserReplyFunctions=UserReplyFunctions4; |
548 | 548 | ||
549 | SecLength = 0; | 549 | SecLength = 0; |
550 | error=GSM_WaitFor (&s, getlen, sizeof(getlen), 0x23, 1, ID_User1); | 550 | error=GSM_WaitFor (&s, getlen, sizeof(getlen), 0x23, 1, ID_User1); |
551 | Print_Error(error); | 551 | Print_Error(error); |
552 | if (SecLength != 0) { | 552 | if (SecLength != 0) { |
553 | read[17] = SecLength; | 553 | read[17] = SecLength; |
554 | error=GSM_WaitFor (&s, read, sizeof(read), 0x23, 5, ID_User1); | 554 | error=GSM_WaitFor (&s, read, sizeof(read), 0x23, 5, ID_User1); |
555 | Print_Error(error); | 555 | Print_Error(error); |
556 | } | 556 | } |
557 | } | 557 | } |
558 | 558 | ||
559 | static GSM_Error DCT4_ReplyGetVoiceRecord(GSM_Protocol_Message msg, GSM_StateMachine *s) | 559 | static GSM_Error DCT4_ReplyGetVoiceRecord(GSM_Protocol_Message msg, GSM_StateMachine *s) |
560 | { | 560 | { |
561 | int i=18,j; | 561 | int i=18,j; |
562 | unsigned charBuffer[100]; | 562 | unsigned charBuffer[100]; |
563 | 563 | ||
564 | switch (msg.Buffer[3]) { | 564 | switch (msg.Buffer[3]) { |
565 | case 0x05: | 565 | case 0x05: |
566 | dbgprintf("Part of voice record received\n"); | 566 | dbgprintf("Part of voice record received\n"); |
567 | if (msg.Length == 6) { | 567 | if (msg.Length == 6) { |
568 | dbgprintf("Empty\n"); | 568 | dbgprintf("Empty\n"); |
569 | return ERR_EMPTY; | 569 | return ERR_EMPTY; |
570 | } | 570 | } |
571 | *s->Phone.Data.VoiceRecord = 0; | 571 | *s->Phone.Data.VoiceRecord = 0; |
572 | while (i<msg.Length) { | 572 | while (i<msg.Length) { |
573 | s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i+1]; | 573 | s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i+1]; |
574 | s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i]; | 574 | s->Phone.Data.PhoneString[(*s->Phone.Data.VoiceRecord)++] = msg.Buffer[i]; |
575 | i += 2; | 575 | i += 2; |
576 | } | 576 | } |
577 | return ERR_NONE; | 577 | return ERR_NONE; |
578 | case 0x0D: | 578 | case 0x0D: |
579 | dbgprintf("Last part of voice record is %02x %02x\n",msg.Buffer[11],msg.Buffer[12]); | 579 | dbgprintf("Last part of voice record is %02x %02x\n",msg.Buffer[11],msg.Buffer[12]); |
580 | dbgprintf("Token is %02x\n",msg.Buffer[13]); | 580 | dbgprintf("Token is %02x\n",msg.Buffer[13]); |
581 | s->Phone.Data.PhoneString[0] = msg.Buffer[11]; | 581 | s->Phone.Data.PhoneString[0] = msg.Buffer[11]; |
582 | s->Phone.Data.PhoneString[1] = msg.Buffer[12]; | 582 | s->Phone.Data.PhoneString[1] = msg.Buffer[12]; |
583 | s->Phone.Data.PhoneString[2] = msg.Buffer[13]; | 583 | s->Phone.Data.PhoneString[2] = msg.Buffer[13]; |
584 | return ERR_NONE; | 584 | return ERR_NONE; |
585 | break; | 585 | break; |
586 | case 0x31: | 586 | case 0x31: |
587 | dbgprintf("Names of voice records received\n"); | 587 | dbgprintf("Names of voice records received\n"); |
588 | j = 33; | 588 | j = 33; |
589 | for (i=0;i<msg.Buffer[9];i++) { | 589 | for (i=0;i<msg.Buffer[9];i++) { |
590 | memcpy(Buffer,msg.Buffer+(j+1),msg.Buffer[j]); | 590 | memcpy(Buffer,msg.Buffer+(j+1),msg.Buffer[j]); |
591 | Buffer[msg.Buffer[j]] = 0; | 591 | Buffer[msg.Buffer[j]] = 0; |
592 | Buffer[msg.Buffer[j]+1] = 0; | 592 | Buffer[msg.Buffer[j]+1] = 0; |
593 | dbgprintf("%i. \"%s\"\n",i+1,DecodeUnicodeString(Buffer)); | 593 | dbgprintf("%i. \"%s\"\n",i+1,DecodeUnicodeString(Buffer)); |
594 | if (i==*s->Phone.Data.VoiceRecord) { | 594 | if (i==*s->Phone.Data.VoiceRecord) { |
595 | sprintf(s->Phone.Data.PhoneString,"%s.wav",DecodeUnicodeString(Buffer)); | 595 | sprintf(s->Phone.Data.PhoneString,"%s.wav",DecodeUnicodeString(Buffer)); |
596 | return ERR_NONE; | 596 | return ERR_NONE; |
597 | } | 597 | } |
598 | if (i != msg.Buffer[9] - 1) { | 598 | if (i != msg.Buffer[9] - 1) { |
599 | j+=msg.Buffer[j] + 1; | 599 | j+=msg.Buffer[j] + 1; |
600 | if (msg.Buffer[j] == 0x00 && msg.Buffer[j+1]==0x00) j+=2; | 600 | if (msg.Buffer[j] == 0x00 && msg.Buffer[j+1]==0x00) j+=2; |
601 | j+=23; | 601 | j+=23; |
602 | } | 602 | } |
603 | } | 603 | } |
604 | return ERR_EMPTY; | 604 | return ERR_EMPTY; |
605 | } | 605 | } |
606 | return ERR_UNKNOWNRESPONSE; | 606 | return ERR_UNKNOWNRESPONSE; |
607 | } | 607 | } |
608 | 608 | ||
609 | void DCT4GetVoiceRecord(int argc, char *argv[]) | 609 | void DCT4GetVoiceRecord(int argc, char *argv[]) |
610 | { | 610 | { |
611 | /* Voice records names */ | 611 | /* Voice records names */ |
612 | unsigned char ReqNames[200] = { | 612 | unsigned char ReqNames[200] = { |
613 | N7110_FRAME_HEADER, | 613 | N7110_FRAME_HEADER, |
614 | 0x30,0x01,0x55,0x00,0x00,0xFF,0xFF,0x01,0x01,0x55,0x55}; | 614 | 0x30,0x01,0x55,0x00,0x00,0xFF,0xFF,0x01,0x01,0x55,0x55}; |
615 | /* Voice record token */ | 615 | /* Voice record token */ |
616 | unsigned char ReqToken[200] = { | 616 | unsigned char ReqToken[200] = { |
617 | N7110_FRAME_HEADER,0x0C,0x00,0x44,0x00, | 617 | N7110_FRAME_HEADER,0x0C,0x00,0x44,0x00, |
618 | 0x00, /* Location: 0, 1, ... */ | 618 | 0x00, /* Location: 0, 1, ... */ |
619 | 0x55,0x55}; | 619 | 0x55,0x55}; |
620 | /* Voice record part */ | 620 | /* Voice record part */ |
621 | unsigned char ReqGet[200] = { | 621 | unsigned char ReqGet[200] = { |
622 | N7110_FRAME_HEADER,0x04,0x00,0x44, | 622 | N7110_FRAME_HEADER,0x04,0x00,0x44, |
623 | 0x00,0x00,/* Location: 0, 1, ... */ | 623 | 0x00,0x00,/* Location: 0, 1, ... */ |
624 | 0x55,0x55,0x00, | 624 | 0x55,0x55,0x00, |
625 | 625 | ||
626 | 0x00,0x00, /* Part Location*/ | 626 | 0x00,0x00, /* Part Location*/ |
627 | 0x00,0x00,0x00, | 627 | 0x00,0x00,0x00, |
628 | 628 | ||
629 | 0x04, /* ??? */ | 629 | 0x04, /* ??? */ |
630 | 630 | ||
631 | 0x00}; /* Token */ | 631 | 0x00}; /* Token */ |
632 | 632 | ||
633 | /* WAV file headers */ | 633 | /* WAV file headers */ |
634 | unsigned char WAV_Header[] = { | 634 | unsigned char WAV_Header[] = { |
635 | 'R','I','F','F', | 635 | 'R','I','F','F', |
636 | 0x00,0x00,0x00,0x00,/* Length */ | 636 | 0x00,0x00,0x00,0x00,/* Length */ |
637 | 'W','A','V','E'}; | 637 | 'W','A','V','E'}; |
638 | unsigned char FMT_Header[] = {'f','m','t',' ', | 638 | unsigned char FMT_Header[] = {'f','m','t',' ', |
639 | 0x14,0x00,0x00,0x00,0x31,0x00,0x01,0x00,0x40,0x1f, | 639 | 0x14,0x00,0x00,0x00,0x31,0x00,0x01,0x00,0x40,0x1f, |
640 | 0x00,0x00,0x59,0x06,0x00,0x00,0x41,0x00,0x00,0x00, | 640 | 0x00,0x00,0x59,0x06,0x00,0x00,0x41,0x00,0x00,0x00, |
641 | 0x02,0x00,0x40,0x01,'f', 'a', 'c', 't', 0x04,0x00, | 641 | 0x02,0x00,0x40,0x01,'f', 'a', 'c', 't', 0x04,0x00, |
642 | 0x00,0x00, | 642 | 0x00,0x00, |
643 | 0x00,0x73,0x00,0x00};/* Seems to be some length */ | 643 | 0x00,0x73,0x00,0x00};/* Seems to be some length */ |
644 | unsigned char DATA_Header[] = { | 644 | unsigned char DATA_Header[] = { |
645 | 'd','a','t','a', | 645 | 'd','a','t','a', |
646 | 0x00,0x00,0x00,0x00};/* Length */ | 646 | 0x00,0x00,0x00,0x00};/* Length */ |
647 | 647 | ||
648 | long wavfilesize=0; | 648 | long wavfilesize=0; |
649 | unsigned charFileName[100], Buffer[10000], Token; | 649 | unsigned charFileName[100], Buffer[10000], Token; |
650 | unsigned int Location, size=0, CurrentLocation = 0, TokenLocation; | 650 | unsigned int Location, size=0, CurrentLocation = 0, TokenLocation; |
651 | int i; | 651 | int i; |
652 | FILE *WAVFile; | 652 | FILE *WAVFile; |
653 | 653 | ||
654 | Location = atoi(argv[2]); | 654 | Location = atoi(argv[2]); |
655 | if (Location == 0x00) { | 655 | if (Location == 0x00) { |
656 | printf("Please numerate locations from 1\n"); | 656 | printf("Please numerate locations from 1\n"); |
657 | return; | 657 | return; |
658 | } | 658 | } |
659 | Location--; | 659 | Location--; |
660 | 660 | ||
661 | GSM_Init(true); | 661 | GSM_Init(true); |
662 | 662 | ||
663 | CheckDCT4(); | 663 | CheckDCT4(); |
664 | 664 | ||
665 | s.User.UserReplyFunctions=UserReplyFunctions4; | 665 | s.User.UserReplyFunctions=UserReplyFunctions4; |
666 | 666 | ||
667 | s.Phone.Data.VoiceRecord = &Location; | 667 | s.Phone.Data.VoiceRecord = &Location; |
668 | s.Phone.Data.PhoneString = FileName; | 668 | s.Phone.Data.PhoneString = FileName; |
669 | dbgprintf("Getting voice record name\n"); | 669 | dbgprintf("Getting voice record name\n"); |
670 | error=GSM_WaitFor (&s, ReqNames, 14, 0x4A, 4, ID_User4); | 670 | error=GSM_WaitFor (&s, ReqNames, 14, 0x4A, 4, ID_User4); |
671 | Print_Error(error); | 671 | Print_Error(error); |
672 | 672 | ||
673 | s.Phone.Data.PhoneString = Buffer; | 673 | s.Phone.Data.PhoneString = Buffer; |
674 | ReqToken[7] = Location; | 674 | ReqToken[7] = Location; |
675 | dbgprintf("Getting voice record token\n"); | 675 | dbgprintf("Getting voice record token\n"); |
676 | error=GSM_WaitFor (&s, ReqToken, 10, 0x23, 4, ID_User4); | 676 | error=GSM_WaitFor (&s, ReqToken, 10, 0x23, 4, ID_User4); |
677 | Print_Error(error); | 677 | Print_Error(error); |
678 | TokenLocation = Buffer[0] * 256 + Buffer[1]; | 678 | TokenLocation = Buffer[0] * 256 + Buffer[1]; |
679 | Token = Buffer[2]; | 679 | Token = Buffer[2]; |
680 | 680 | ||
681 | WAVFile = fopen(FileName, "wb"); | 681 | WAVFile = fopen(FileName, "wb"); |
682 | 682 | ||
683 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),WAVFile); | 683 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),WAVFile); |
684 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),WAVFile); | 684 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),WAVFile); |
685 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),WAVFile); | 685 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),WAVFile); |
686 | 686 | ||
687 | s.Phone.Data.VoiceRecord = &size; | 687 | s.Phone.Data.VoiceRecord = &size; |
688 | s.Phone.Data.PhoneString = Buffer; | 688 | s.Phone.Data.PhoneString = Buffer; |
689 | ReqGet[7] = Location; | 689 | ReqGet[7] = Location; |
690 | fprintf(stderr,"Getting voice record and saving to \"%s\": ",FileName); | 690 | fprintf(stderr,"Getting voice record and saving to \"%s\": ",FileName); |
691 | while (1) { | 691 | while (1) { |
692 | dbgprintf("Getting next part of voice record\n"); | 692 | dbgprintf("Getting next part of voice record\n"); |
693 | fprintf(stderr,"."); | 693 | fprintf(stderr,"."); |
694 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); | 694 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); |
695 | if (error == ERR_NONE) { | 695 | if (error == ERR_NONE) { |
696 | wavfilesize += size; | 696 | wavfilesize += size; |
697 | fwrite(Buffer,1,size,WAVFile); | 697 | fwrite(Buffer,1,size,WAVFile); |
698 | } | 698 | } |
699 | if (error == ERR_EMPTY) break; | 699 | if (error == ERR_EMPTY) break; |
700 | Print_Error(error); | 700 | Print_Error(error); |
701 | CurrentLocation += 4; | 701 | CurrentLocation += 4; |
702 | ReqGet[11] = CurrentLocation / 256; | 702 | ReqGet[11] = CurrentLocation / 256; |
703 | ReqGet[12] = CurrentLocation % 256; | 703 | ReqGet[12] = CurrentLocation % 256; |
704 | if (CurrentLocation+4 > TokenLocation) break; | 704 | if (CurrentLocation+4 > TokenLocation) break; |
705 | } | 705 | } |
706 | dbgprintf("Getting first part in last sequence of voice record\n"); | 706 | dbgprintf("Getting first part in last sequence of voice record\n"); |
707 | for (i=255;i>=0;i--) { | 707 | for (i=255;i>=0;i--) { |
708 | ReqGet[16] = i; | 708 | ReqGet[16] = i; |
709 | ReqGet[17] = Token; | 709 | ReqGet[17] = Token; |
710 | fprintf(stderr,"."); | 710 | fprintf(stderr,"."); |
711 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); | 711 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); |
712 | if (error == ERR_NONE) { | 712 | if (error == ERR_NONE) { |
713 | wavfilesize += size; | 713 | wavfilesize += size; |
714 | fwrite(Buffer,1,size,WAVFile); | 714 | fwrite(Buffer,1,size,WAVFile); |
715 | break; | 715 | break; |
716 | } | 716 | } |
717 | if (error != ERR_EMPTY) Print_Error(error); | 717 | if (error != ERR_EMPTY) Print_Error(error); |
718 | } | 718 | } |
719 | while (1) { | 719 | while (1) { |
720 | dbgprintf("Getting next part of last sequence in voice record\n"); | 720 | dbgprintf("Getting next part of last sequence in voice record\n"); |
721 | CurrentLocation += 4; | 721 | CurrentLocation += 4; |
722 | ReqGet[11] = CurrentLocation / 256; | 722 | ReqGet[11] = CurrentLocation / 256; |
723 | ReqGet[12] = CurrentLocation % 256; | 723 | ReqGet[12] = CurrentLocation % 256; |
724 | fprintf(stderr,"."); | 724 | fprintf(stderr,"."); |
725 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); | 725 | error=GSM_WaitFor (&s, ReqGet, 18, 0x23, 4, ID_User4); |
726 | if (error == ERR_NONE) { | 726 | if (error == ERR_NONE) { |
727 | wavfilesize += size; | 727 | wavfilesize += size; |
728 | fwrite(Buffer,1,size,WAVFile); | 728 | fwrite(Buffer,1,size,WAVFile); |
729 | } | 729 | } |
730 | if (error == ERR_EMPTY) break; | 730 | if (error == ERR_EMPTY) break; |
731 | Print_Error(error); | 731 | Print_Error(error); |
732 | } | 732 | } |
733 | fprintf(stderr,"\n"); | 733 | fprintf(stderr,"\n"); |
734 | 734 | ||
735 | wavfilesize += sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header); | 735 | wavfilesize += sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header); |
736 | WAV_Header[4] = (unsigned char)(wavfilesize % 256); | 736 | WAV_Header[4] = (unsigned char)(wavfilesize % 256); |
737 | WAV_Header[5] = (unsigned char)(wavfilesize / 256); | 737 | WAV_Header[5] = (unsigned char)(wavfilesize / 256); |
738 | WAV_Header[6] = (unsigned char)(wavfilesize / (256*256)); | 738 | WAV_Header[6] = (unsigned char)(wavfilesize / (256*256)); |
739 | WAV_Header[7] = (unsigned char)(wavfilesize / (256*256*256)); | 739 | WAV_Header[7] = (unsigned char)(wavfilesize / (256*256*256)); |
740 | 740 | ||
741 | /* FIXME */ | 741 | /* FIXME */ |
742 | FMT_Header[36]= (unsigned char)(((wavfilesize - 238) * 5 ) % 256); | 742 | FMT_Header[36]= (unsigned char)(((wavfilesize - 238) * 5 ) % 256); |
743 | FMT_Header[37]= (unsigned char)(((wavfilesize - 238) * 5 ) / 256); | 743 | FMT_Header[37]= (unsigned char)(((wavfilesize - 238) * 5 ) / 256); |
744 | FMT_Header[38]= (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256)); | 744 | FMT_Header[38]= (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256)); |
745 | FMT_Header[39]= (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256*256)); | 745 | FMT_Header[39]= (unsigned char)(((wavfilesize - 238) * 5 ) / (256*256*256)); |
746 | 746 | ||
747 | wavfilesize = wavfilesize - 54 - 6; | 747 | wavfilesize = wavfilesize - 54 - 6; |
748 | DATA_Header[4] = (unsigned char)(wavfilesize % 256); | 748 | DATA_Header[4] = (unsigned char)(wavfilesize % 256); |
749 | DATA_Header[5] = (unsigned char)(wavfilesize / 256); | 749 | DATA_Header[5] = (unsigned char)(wavfilesize / 256); |
750 | DATA_Header[6] = (unsigned char)(wavfilesize / (256*256)); | 750 | DATA_Header[6] = (unsigned char)(wavfilesize / (256*256)); |
751 | DATA_Header[7] = (unsigned char)(wavfilesize / (256*256*256)); | 751 | DATA_Header[7] = (unsigned char)(wavfilesize / (256*256*256)); |
752 | 752 | ||
753 | fseek( WAVFile, 0, SEEK_SET); | 753 | fseek( WAVFile, 0, SEEK_SET); |
754 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),WAVFile); | 754 | fwrite(&WAV_Header, 1, sizeof(WAV_Header),WAVFile); |
755 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),WAVFile); | 755 | fwrite(&FMT_Header, 1, sizeof(FMT_Header),WAVFile); |
756 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),WAVFile); | 756 | fwrite(&DATA_Header, 1, sizeof(DATA_Header),WAVFile); |
757 | 757 | ||
758 | fclose(WAVFile); | 758 | fclose(WAVFile); |
759 | 759 | ||
760 | GSM_Terminate(); | 760 | GSM_Terminate(); |
761 | } | 761 | } |
762 | 762 | ||
763 | static GSM_Error DCT4_ReplyGetBTInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) | 763 | static GSM_Error DCT4_ReplyGetBTInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) |
764 | { | 764 | { |
765 | printf("device address %02x%02x%02x%02x%02x%02x\n", | 765 | printf("device address %02x%02x%02x%02x%02x%02x\n", |
766 | msg.Buffer[9],msg.Buffer[10],msg.Buffer[11], | 766 | msg.Buffer[9],msg.Buffer[10],msg.Buffer[11], |
767 | msg.Buffer[12],msg.Buffer[13],msg.Buffer[14]); | 767 | msg.Buffer[12],msg.Buffer[13],msg.Buffer[14]); |
768 | return ERR_NONE; | 768 | return ERR_NONE; |
769 | } | 769 | } |
770 | 770 | ||
771 | static GSM_Error DCT4_ReplyGetSimlock(GSM_Protocol_Message msg, GSM_StateMachine *s) | 771 | static GSM_Error DCT4_ReplyGetSimlock(GSM_Protocol_Message msg, GSM_StateMachine *s) |
772 | { | 772 | { |
773 | int i; | 773 | int i; |
774 | 774 | ||
775 | switch (msg.Buffer[3]) { | 775 | switch (msg.Buffer[3]) { |
776 | case 0x0D: | 776 | case 0x0D: |
777 | dbgprintf("Simlock info received\n"); | 777 | dbgprintf("Simlock info received\n"); |
778 | dbgprintf("Config_Data: "); | 778 | dbgprintf("Config_Data: "); |
779 | for (i=14;i<22;i++) { | 779 | for (i=14;i<22;i++) { |
780 | dbgprintf("%02x",msg.Buffer[i]); | 780 | dbgprintf("%02x",msg.Buffer[i]); |
781 | } | 781 | } |
782 | dbgprintf("\n"); | 782 | dbgprintf("\n"); |
783 | dbgprintf("Profile_Bits: "); | 783 | dbgprintf("Profile_Bits: "); |
784 | for (i=22;i<30;i++) { | 784 | for (i=22;i<30;i++) { |
785 | dbgprintf("%02x",msg.Buffer[i]); | 785 | dbgprintf("%02x",msg.Buffer[i]); |
786 | } | 786 | } |
787 | dbgprintf("\n"); | 787 | dbgprintf("\n"); |
788 | return ERR_NONE; | 788 | return ERR_NONE; |
789 | case 0x13: | 789 | case 0x13: |
790 | dbgprintf("Simlock info received\n"); | 790 | dbgprintf("Simlock info received\n"); |
791 | if (msg.Buffer[58] == 0x05 && msg.Buffer[59] == 0x02) { | 791 | if (msg.Buffer[58] == 0x05 && msg.Buffer[59] == 0x02) { |
792 | dbgprintf("SIM_PATH: "); | 792 | dbgprintf("SIM_PATH: "); |
793 | for (i=44;i<52;i++) { | 793 | for (i=44;i<52;i++) { |
794 | dbgprintf("%02x",msg.Buffer[i]); | 794 | dbgprintf("%02x",msg.Buffer[i]); |
795 | } | 795 | } |
796 | dbgprintf("\n"); | 796 | dbgprintf("\n"); |
797 | printf("Simlock data : "); | 797 | printf("Simlock data : "); |
798 | for (i=60;i<63;i++) { | 798 | for (i=60;i<63;i++) { |
799 | printf("%02x",msg.Buffer[i]); | 799 | printf("%02x",msg.Buffer[i]); |
800 | } | 800 | } |
801 | printf("\n"); | 801 | printf("\n"); |
802 | } | 802 | } |
803 | return ERR_NONE; | 803 | return ERR_NONE; |
804 | } | 804 | } |
805 | return ERR_UNKNOWNRESPONSE; | 805 | return ERR_UNKNOWNRESPONSE; |
806 | } | 806 | } |
807 | 807 | ||
808 | void DCT4Info(int argc, char *argv[]) | 808 | void DCT4Info(int argc, char *argv[]) |
809 | { | 809 | { |
810 | unsigned char GetBTAddress[8] = {N6110_FRAME_HEADER, 0x09, 0x19, 0x01, 0x03, 0x06}; | 810 | unsigned char GetBTAddress[8] = {N6110_FRAME_HEADER, 0x09, 0x19, 0x01, 0x03, 0x06}; |
811 | unsigned char GetSimlock[5] = {N6110_FRAME_HEADER, 0x12, 0x0D}; | 811 | unsigned char GetSimlock[5] = {N6110_FRAME_HEADER, 0x12, 0x0D}; |
812 | unsigned char value[10]; | 812 | unsigned char value[10]; |
813 | 813 | ||
814 | if (CheckDCT4Only()!=ERR_NONE) return; | 814 | if (CheckDCT4Only()!=ERR_NONE) return; |
815 | 815 | ||
816 | s.User.UserReplyFunctions=UserReplyFunctions4; | 816 | s.User.UserReplyFunctions=UserReplyFunctions4; |
817 | 817 | ||
818 | if (IsPhoneFeatureAvailable(s.Phone.Data.ModelInfo, F_BLUETOOTH)) { | 818 | if (IsPhoneFeatureAvailable(s.Phone.Data.ModelInfo, F_BLUETOOTH)) { |
819 | printf("Bluetooth : "); | 819 | printf("Bluetooth : "); |
820 | 820 | ||
821 | error=GSM_WaitFor (&s, GetBTAddress, 8, 0xD7, 4, ID_User6); | 821 | error=GSM_WaitFor (&s, GetBTAddress, 8, 0xD7, 4, ID_User6); |
822 | Print_Error(error); | 822 | Print_Error(error); |
823 | } | 823 | } |
824 | 824 | ||
825 | error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6); | 825 | error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6); |
826 | Print_Error(error); | 826 | Print_Error(error); |
827 | GetSimlock[4] = 0x0E; | 827 | GetSimlock[4] = 0x0E; |
828 | error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6); | 828 | error=GSM_WaitFor (&s, GetSimlock, 5, 0x53, 4, ID_User6); |
829 | Print_Error(error); | 829 | Print_Error(error); |
830 | GetSimlock[3] = 0x0C; | 830 | GetSimlock[3] = 0x0C; |
831 | error=GSM_WaitFor (&s, GetSimlock, 4, 0x53, 4, ID_User6); | 831 | error=GSM_WaitFor (&s, GetSimlock, 4, 0x53, 4, ID_User6); |
832 | Print_Error(error); | 832 | Print_Error(error); |
833 | error=NOKIA_GetPhoneString(&s,"\x00\x03\x02\x07\x00\x08",6,0x1b,value,ID_User6,10); | 833 | error=NOKIA_GetPhoneString(&s,"\x00\x03\x02\x07\x00\x08",6,0x1b,value,ID_User6,10); |
834 | Print_Error(error); | 834 | Print_Error(error); |
835 | printf("UEM : %s\n",value); | 835 | printf("UEM : %s\n",value); |
836 | } | 836 | } |
837 | 837 | ||
838 | static FILE *T9File; | 838 | static FILE *T9File; |
839 | int T9Size; | 839 | int T9Size; |
840 | int T9FullSize; | 840 | int T9FullSize; |
841 | 841 | ||
842 | static GSM_Error DCT4_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s) | 842 | static GSM_Error DCT4_ReplyGetT9(GSM_Protocol_Message msg, GSM_StateMachine *s) |
843 | { | 843 | { |
844 | T9FullSize = msg.Buffer[18] * 256 + msg.Buffer[19]; | 844 | T9FullSize = msg.Buffer[18] * 256 + msg.Buffer[19]; |
845 | T9Size = msg.Length - 18; | 845 | T9Size = msg.Length - 18; |
846 | fwrite(msg.Buffer+18,1,T9Size,T9File); | 846 | fwrite(msg.Buffer+18,1,T9Size,T9File); |
847 | return ERR_NONE; | 847 | return ERR_NONE; |
848 | } | 848 | } |
849 | 849 | ||
850 | void DCT4GetT9(int argc, char *argv[]) | 850 | void DCT4GetT9(int argc, char *argv[]) |
851 | { | 851 | { |
852 | int i,T9Dictionary=0; | 852 | int i,T9Dictionary=0; |
853 | unsigned char req[] = {N7110_FRAME_HEADER, 0x04, 0x00, 0x5B, | 853 | unsigned char req[] = {N7110_FRAME_HEADER, 0x04, 0x00, 0x5B, |
854 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 854 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
855 | 0x00, 0x00,/* Start position */ | 855 | 0x00, 0x00,/* Start position */ |
856 | 0x00, 0x00, | 856 | 0x00, 0x00, |
857 | 0x02, 0xBC};/* How many bytes to read */ | 857 | 0x02, 0xBC};/* How many bytes to read */ |
858 | 858 | ||
859 | if (CheckDCT4Only()!=ERR_NONE) return; | 859 | if (CheckDCT4Only()!=ERR_NONE) return; |
860 | 860 | ||
861 | T9File = fopen("T9", "w"); | 861 | T9File = fopen("T9", "w"); |
862 | if (T9File == NULL) return; | 862 | if (T9File == NULL) return; |
863 | 863 | ||
864 | s.User.UserReplyFunctions=UserReplyFunctions4; | 864 | s.User.UserReplyFunctions=UserReplyFunctions4; |
865 | 865 | ||
866 | i = 0; | 866 | i = 0; |
867 | while (1) { | 867 | while (1) { |
868 | req[12] = i / 256; | 868 | req[12] = i / 256; |
869 | req[13] = i % 256; | 869 | req[13] = i % 256; |
870 | if (i != 0) { | 870 | if (i != 0) { |
871 | if (T9Dictionary - i < req[16]*256+req[17]) { | 871 | if (T9Dictionary - i < req[16]*256+req[17]) { |
872 | req[16] = (T9Dictionary - i) / 256; | 872 | req[16] = (T9Dictionary - i) / 256; |
873 | req[17] = (T9Dictionary - i) % 256; | 873 | req[17] = (T9Dictionary - i) % 256; |
874 | } | 874 | } |
875 | if (T9Dictionary - i == 0) break; | 875 | if (T9Dictionary - i == 0) break; |
876 | } | 876 | } |
877 | error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3); | 877 | error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3); |
878 | Print_Error(error); | 878 | Print_Error(error); |
879 | if (i==0) { | 879 | if (i==0) { |
880 | T9Dictionary = T9FullSize; | 880 | T9Dictionary = T9FullSize; |
881 | dbgprintf("T9 dictionary size is %i\n",T9Dictionary); | 881 | dbgprintf("T9 dictionary size is %i\n",T9Dictionary); |
882 | } | 882 | } |
883 | i+=T9Size; | 883 | i+=T9Size; |
884 | } | 884 | } |
885 | 885 | ||
886 | fclose(T9File); | 886 | fclose(T9File); |
887 | } | 887 | } |
888 | 888 | ||
889 | #ifdef GSM_ENABLE_NOKIA6510 | 889 | #ifdef GSM_ENABLE_NOKIA6510 |
890 | 890 | ||
891 | extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable); | 891 | extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable); |
892 | 892 | ||
893 | void DCT4SetLight(int argc, char *argv[]) | 893 | void DCT4SetLight(int argc, char *argv[]) |
894 | { | 894 | { |
895 | int i; | 895 | int i; |
896 | N6510_PHONE_LIGHTS type; | 896 | N6510_PHONE_LIGHTS type; |
897 | bool enable; | 897 | bool enable; |
898 | 898 | ||
899 | if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY; | 899 | if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY; |
900 | } else if (mystrncasecmp(argv[2],"keypad",0)) {type = N6510_LIGHT_KEYPAD; | 900 | } else if (mystrncasecmp(argv[2],"keypad",0)) {type = N6510_LIGHT_KEYPAD; |
901 | } else if (mystrncasecmp(argv[2],"torch",0)) {type = N6510_LIGHT_TORCH; | 901 | } else if (mystrncasecmp(argv[2],"torch",0)) {type = N6510_LIGHT_TORCH; |
902 | } else { | 902 | } else { |
903 | printf("What lights should I enable (\"%s\") ?\n",argv[2]); | 903 | printf("What lights should I enable (\"%s\") ?\n",argv[2]); |
904 | exit(-1); | 904 | exit(-1); |
905 | } | 905 | } |
906 | 906 | ||
907 | if (mystrncasecmp(argv[3],"on",0)) { enable = true; | 907 | if (mystrncasecmp(argv[3],"on",0)) { enable = true; |
908 | } else if (mystrncasecmp(argv[3],"off",0)) {enable = false; | 908 | } else if (mystrncasecmp(argv[3],"off",0)) {enable = false; |
909 | } else { | 909 | } else { |
910 | printf("What should I do (\"%s\") ?\n",argv[3]); | 910 | printf("What should I do (\"%s\") ?\n",argv[3]); |
911 | exit(-1); | 911 | exit(-1); |
912 | } | 912 | } |
913 | 913 | ||
914 | for (i=0;i<s.ConfigNum;i++) { | 914 | for (i=0;i<s.ConfigNum;i++) { |
915 | s.Config[i].StartInfo = "false"; | 915 | s.Config[i].StartInfo = "false"; |
916 | } | 916 | } |
917 | 917 | ||
918 | GSM_Init(true); | 918 | GSM_Init(true); |
919 | 919 | ||
920 | CheckDCT4(); | 920 | CheckDCT4(); |
921 | 921 | ||
922 | error=N6510_SetLight(&s, type, enable); | 922 | error=N6510_SetLight(&s, type, enable); |
923 | Print_Error(error); | 923 | Print_Error(error); |
924 | 924 | ||
925 | GSM_Terminate(); | 925 | GSM_Terminate(); |
926 | } | 926 | } |
927 | #endif | 927 | #endif |
928 | 928 | ||
929 | void DCT4DisplayTest(int argc, char *argv[]) | 929 | void DCT4DisplayTest(int argc, char *argv[]) |
930 | { | 930 | { |
931 | unsigned char ans[200]; | 931 | unsigned char ans[200]; |
932 | unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00}; | 932 | unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00}; |
933 | unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04, | 933 | unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04, |
934 | 0x09, /* test number */ | 934 | 0x09, /* test number */ |
935 | 0x00}; | 935 | 0x00}; |
936 | 936 | ||
937 | if (CheckDCT4Only()!=ERR_NONE) return; | 937 | if (CheckDCT4Only()!=ERR_NONE) return; |
938 | 938 | ||
939 | s.User.UserReplyFunctions=UserReplyFunctions4; | 939 | s.User.UserReplyFunctions=UserReplyFunctions4; |
940 | 940 | ||
941 | DCT4_SetPhoneMode(&s, DCT4_MODE_TEST); | 941 | DCT4_SetPhoneMode(&s, DCT4_MODE_TEST); |
942 | 942 | ||
943 | s.Protocol.Functions->WriteMessage(&s, req0, 6, 0x40); | 943 | s.Protocol.Functions->WriteMessage(&s, req0, 6, 0x40); |
944 | 944 | ||
945 | req[8] = atoi(argv[2]); | 945 | req[8] = atoi(argv[2]); |
946 | s.Protocol.Functions->WriteMessage(&s, req, 10, 0x40); | 946 | s.Protocol.Functions->WriteMessage(&s, req, 10, 0x40); |
947 | 947 | ||
948 | printf("Press any key to continue...\n"); | 948 | printf("Press any key to continue...\n"); |
949 | GetLine(stdin, ans, 99); | 949 | GetLine(stdin, ans, 99); |
950 | 950 | ||
951 | DCT4_SetPhoneMode(&s, DCT4_MODE_NORMAL); | 951 | DCT4_SetPhoneMode(&s, DCT4_MODE_NORMAL); |
952 | } | 952 | } |
953 | 953 | ||
954 | int ADC; | 954 | int ADC; |
955 | 955 | ||
956 | static GSM_Error DCT4_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s) | 956 | static GSM_Error DCT4_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s) |
957 | { | 957 | { |
958 | if (msg.Buffer[6] == 0xff && msg.Buffer[7] == 0xff) return ERR_NONE; | 958 | if (msg.Buffer[6] == 0xff && msg.Buffer[7] == 0xff) return ERR_NONE; |
959 | switch (msg.Buffer[3]) { | 959 | switch (msg.Buffer[3]) { |
960 | case 0x10: | 960 | case 0x10: |
961 | printf("raw "); | 961 | printf("raw "); |
962 | printf("%10i ",msg.Buffer[8]*256+msg.Buffer[9]); | 962 | printf("%10i ",msg.Buffer[8]*256+msg.Buffer[9]); |
963 | break; | 963 | break; |
964 | case 0x12: | 964 | case 0x12: |
965 | printf("unit result "); | 965 | printf("unit result "); |
966 | printf("%10i ",(msg.Buffer[8]*256+msg.Buffer[9])*ADC); | 966 | printf("%10i ",(msg.Buffer[8]*256+msg.Buffer[9])*ADC); |
967 | break; | 967 | break; |
968 | } | 968 | } |
969 | return ERR_NONE; | 969 | return ERR_NONE; |
970 | } | 970 | } |
971 | 971 | ||
972 | struct DCT4ADCInfo { | 972 | struct DCT4ADCInfo { |
973 | char *name; | 973 | char *name; |
974 | char *unit; | 974 | char *unit; |
975 | int x; | 975 | int x; |
976 | }; | 976 | }; |
977 | 977 | ||
978 | static struct DCT4ADCInfo DCT4ADC[] = { | 978 | static struct DCT4ADCInfo DCT4ADC[] = { |
979 | {"Battery voltage, divided:", "mV", 1}, | 979 | {"Battery voltage, divided:", "mV", 1}, |
980 | {"Battery voltage, scaled:", "mV", 1}, | 980 | {"Battery voltage, scaled:", "mV", 1}, |
981 | {"Charger voltage:", "mV", 1}, | 981 | {"Charger voltage:", "mV", 1}, |
982 | {"Charger current:", "mA", 1}, | 982 | {"Charger current:", "mA", 1}, |
983 | {"Battery size indicator:", "Ohms",100}, | 983 | {"Battery size indicator:", "Ohms",100}, |
984 | {"Battery temperature:", "K", 1}, | 984 | {"Battery temperature:", "K", 1}, |
985 | {"Headset interconnection:", "mV", 1}, | 985 | {"Headset interconnection:", "mV", 1}, |
986 | {"Hook interconnection:", "mV", 1}, | 986 | {"Hook interconnection:", "mV", 1}, |
987 | {"Light sensor:", "mV", 1}, | 987 | {"Light sensor:", "mV", 1}, |
988 | {"Power amplifier temperature:","K", 1}, | 988 | {"Power amplifier temperature:","K", 1}, |
989 | {"VCXO temperature:", "K", 1}, | 989 | {"VCXO temperature:", "K", 1}, |
990 | {"Resistive keyboard 1/headint2:","mV", 1}, | 990 | {"Resistive keyboard 1/headint2:","mV", 1}, |
991 | {"Resistive keyboard 1/auxdet:","mV", 1}, | 991 | {"Resistive keyboard 1/auxdet:","mV", 1}, |
992 | {"Initial battery voltage:", "mV", 1}, | 992 | {"Initial battery voltage:", "mV", 1}, |
993 | {"Battery Current:", "mA", 1}, | 993 | {"Battery Current:", "mA", 1}, |
994 | {"Battery Current Fast:", "mA", 1}, | 994 | {"Battery Current Fast:", "mA", 1}, |
995 | 995 | ||
996 | {"", "", 1} | 996 | {"", "", 1} |
997 | }; | 997 | }; |
998 | 998 | ||
999 | void DCT4GetADC(int argc, char *argv[]) | 999 | void DCT4GetADC(int argc, char *argv[]) |
1000 | { | 1000 | { |
1001 | int i = 0; | 1001 | int i = 0; |
1002 | unsigned char GetRaw[] = {N6110_FRAME_HEADER, 0x0F, | 1002 | unsigned char GetRaw[] = {N6110_FRAME_HEADER, 0x0F, |
1003 | 0x00, /* Test number */ | 1003 | 0x00, /* Test number */ |
1004 | 0x01}; | 1004 | 0x01}; |
1005 | unsigned char GetUnit[] = {N6110_FRAME_HEADER, 0x11, | 1005 | unsigned char GetUnit[] = {N6110_FRAME_HEADER, 0x11, |
1006 | 0x00, /* Test number */ | 1006 | 0x00, /* Test number */ |
1007 | 0x01}; | 1007 | 0x01}; |
1008 | 1008 | ||
1009 | if (CheckDCT4Only()!=ERR_NONE) return; | 1009 | if (CheckDCT4Only()!=ERR_NONE) return; |
1010 | 1010 | ||
1011 | s.User.UserReplyFunctions=UserReplyFunctions4; | 1011 | s.User.UserReplyFunctions=UserReplyFunctions4; |
1012 | 1012 | ||
1013 | while (1) { | 1013 | while (1) { |
1014 | printf(" %30s ",DCT4ADC[i].name); | 1014 | printf(" %30s ",DCT4ADC[i].name); |
1015 | GetRaw[4] = i; | 1015 | GetRaw[4] = i; |
1016 | error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3); | 1016 | error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3); |
1017 | Print_Error(error); | 1017 | Print_Error(error); |
1018 | GetUnit[4] = i; | 1018 | GetUnit[4] = i; |
1019 | ADC = DCT4ADC[i].x; | 1019 | ADC = DCT4ADC[i].x; |
1020 | error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3); | 1020 | error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3); |
1021 | Print_Error(error); | 1021 | Print_Error(error); |
1022 | printf("%s\n",DCT4ADC[i].unit); | 1022 | printf("%s\n",DCT4ADC[i].unit); |
1023 | i++; | 1023 | i++; |
1024 | if (DCT4ADC[i].name[0] == 0x00) break; | 1024 | if (DCT4ADC[i].name[0] == 0x00) break; |
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | #ifdef GSM_ENABLE_NOKIA6510 | 1028 | #ifdef GSM_ENABLE_NOKIA6510 |
1029 | 1029 | ||
1030 | static double RadioFreq; | 1030 | static double RadioFreq; |
1031 | static unsigned char RadioName[100]; | 1031 | static unsigned char RadioName[100]; |
1032 | 1032 | ||
1033 | static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1033 | static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1034 | { | 1034 | { |
1035 | int length; | 1035 | int length; |
1036 | unsigned char name[100]; | 1036 | unsigned char name[100]; |
1037 | 1037 | ||
1038 | switch (msg.Buffer[3]) { | 1038 | switch (msg.Buffer[3]) { |
1039 | case 0x09: | 1039 | case 0x09: |
1040 | N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16); | 1040 | N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16); |
1041 | 1041 | ||
1042 | length = msg.Buffer[8]; | 1042 | length = msg.Buffer[8]; |
1043 | memcpy(name,msg.Buffer+18,length*2); | 1043 | memcpy(name,msg.Buffer+18,length*2); |
1044 | name[length*2] = 0x00; | 1044 | name[length*2] = 0x00; |
1045 | name[length*2+1] = 0x00; | 1045 | name[length*2+1] = 0x00; |
1046 | CopyUnicodeString(RadioName,name); | 1046 | CopyUnicodeString(RadioName,name); |
1047 | smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName)); | 1047 | smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName)); |
1048 | return ERR_NONE; | 1048 | return ERR_NONE; |
1049 | case 0x15: | 1049 | case 0x15: |
1050 | case 0x16: | 1050 | case 0x16: |
1051 | smprintf(s,"Response for enabling radio/headset status received\n"); | 1051 | smprintf(s,"Response for enabling radio/headset status received\n"); |
1052 | if (msg.Buffer[5] == 0) { | 1052 | if (msg.Buffer[5] == 0) { |
1053 | smprintf(s,"Connected\n"); | 1053 | smprintf(s,"Connected\n"); |
1054 | return ERR_NONE; | 1054 | return ERR_NONE; |
1055 | } | 1055 | } |
1056 | smprintf(s,"Probably not connected\n"); | 1056 | smprintf(s,"Probably not connected\n"); |
1057 | return ERR_PERMISSION; | 1057 | return ERR_PERMISSION; |
1058 | } | 1058 | } |
1059 | return ERR_UNKNOWNRESPONSE; | 1059 | return ERR_UNKNOWNRESPONSE; |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void DCT4TuneRadio(int argc, char *argv[]) | 1062 | void DCT4TuneRadio(int argc, char *argv[]) |
1063 | { | 1063 | { |
1064 | double Freq, diff; | 1064 | double Freq, diff; |
1065 | GSM_FMStation FMStation[50],FMStat; | 1065 | GSM_FMStation FMStation[50],FMStat; |
1066 | int i, j, num; | 1066 | int i, j, num; |
1067 | bool found; | 1067 | bool found; |
1068 | 1068 | ||
1069 | unsigned char Enable[] = {N6110_FRAME_HEADER, 0x00, 0x00, 0x00}; | 1069 | unsigned char Enable[] = {N6110_FRAME_HEADER, 0x00, 0x00, 0x00}; |
1070 | unsigned char Disable[] = {N6110_FRAME_HEADER, 0x01, 0x0E, 0x00}; | 1070 | unsigned char Disable[] = {N6110_FRAME_HEADER, 0x01, 0x0E, 0x00}; |
1071 | //unsigned char SetVolume[] = {N6110_FRAME_HEADER, 0x14, | 1071 | //unsigned char SetVolume[] = {N6110_FRAME_HEADER, 0x14, |
1072 | // 0x00,/* Volume level */ | 1072 | // 0x00,/* Volume level */ |
1073 | // 0x00}; | 1073 | // 0x00}; |
1074 | //unsigned char MuteUnMute[] = {N6110_FRAME_HEADER, 0x0F, | 1074 | //unsigned char MuteUnMute[] = {N6110_FRAME_HEADER, 0x0F, |
1075 | // 0x0C,/* 0x0B = mute, 0x0C = unmute */ | 1075 | // 0x0C,/* 0x0B = mute, 0x0C = unmute */ |
1076 | // 0x00}; | 1076 | // 0x00}; |
1077 | unsigned char SetFreq[] = {N6110_FRAME_HEADER, 0x08, | 1077 | unsigned char SetFreq[] = {N6110_FRAME_HEADER, 0x08, |
1078 | 0x08, 0x14, 0x00, 0x01, | 1078 | 0x08, 0x14, 0x00, 0x01, |
1079 | 0x9A, 0x28}; /* Frequency */ | 1079 | 0x9A, 0x28}; /* Frequency */ |
1080 | // unsigned char Find1[] = {N6110_FRAME_HEADER, 0x08, | 1080 | // unsigned char Find1[] = {N6110_FRAME_HEADER, 0x08, |
1081 | // 0x04, 0x14, 0x00, 0x00, 0x00, 0x00}; | 1081 | // 0x04, 0x14, 0x00, 0x00, 0x00, 0x00}; |
1082 | unsigned char Find2[] = {N6110_FRAME_HEADER, 0x08, | 1082 | unsigned char Find2[] = {N6110_FRAME_HEADER, 0x08, |
1083 | 0x05, 0x14, 0x00, 0x00, 0x00, 0x00}; | 1083 | 0x05, 0x14, 0x00, 0x00, 0x00, 0x00}; |
1084 | //unsigned char SetStereo[] = {N6110_FRAME_HEADER, 0x19, | 1084 | //unsigned char SetStereo[] = {N6110_FRAME_HEADER, 0x19, |
1085 | // 0x0A, 0x00, 0x15}; | 1085 | // 0x0A, 0x00, 0x15}; |
1086 | //unsigned char SetMono[] = {N6110_FRAME_HEADER, 0x19, | 1086 | //unsigned char SetMono[] = {N6110_FRAME_HEADER, 0x19, |
1087 | // 0x09, 0x00, 0x96}; | 1087 | // 0x09, 0x00, 0x96}; |
1088 | 1088 | ||
1089 | GSM_Init(true); | 1089 | GSM_Init(true); |
1090 | 1090 | ||
1091 | CheckDCT4(); | 1091 | CheckDCT4(); |
1092 | 1092 | ||
1093 | s.User.UserReplyFunctions=UserReplyFunctions4; | 1093 | s.User.UserReplyFunctions=UserReplyFunctions4; |
1094 | 1094 | ||
1095 | FMStat.Location = 1; | 1095 | FMStat.Location = 1; |
1096 | error = Phone->GetFMStation(&s,&FMStat); | 1096 | error = Phone->GetFMStation(&s,&FMStat); |
1097 | if (error != ERR_NONE && error != ERR_EMPTY) { | 1097 | if (error != ERR_NONE && error != ERR_EMPTY) { |
1098 | printf("Phone seems not to support radio\n"); | 1098 | printf("Phone seems not to support radio\n"); |
1099 | GSM_Terminate(); | 1099 | GSM_Terminate(); |
1100 | exit(-1); | 1100 | exit(-1); |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | error=GSM_WaitFor (&s, Enable, 6, 0x3E, 4, ID_User3); | 1103 | error=GSM_WaitFor (&s, Enable, 6, 0x3E, 4, ID_User3); |
1104 | if (error == ERR_PERMISSION) { | 1104 | if (error == ERR_PERMISSION) { |
1105 | printf("Please connect headset. Required as antenna\n"); | 1105 | printf("Please connect headset. Required as antenna\n"); |
1106 | GSM_Terminate(); | 1106 | GSM_Terminate(); |
1107 | exit(-1); | 1107 | exit(-1); |
1108 | } | 1108 | } |
1109 | Print_Error(error); | 1109 | Print_Error(error); |
1110 | 1110 | ||
1111 | num=0; | 1111 | num=0; |
1112 | for (i=88;i<108;i++) { | 1112 | for (i=88;i<108;i++) { |
1113 | fprintf(stderr,"%cSearching: %i percent",13,(i-88)*100/(108-88)); | 1113 | fprintf(stderr,"%cSearching: %i percent",13,(i-88)*100/(108-88)); |
1114 | Freq = i; | 1114 | Freq = i; |
1115 | N6510_EncodeFMFrequency(Freq, SetFreq+8); | 1115 | N6510_EncodeFMFrequency(Freq, SetFreq+8); |
1116 | error=GSM_WaitFor (&s, SetFreq, 10, 0x3E, 4, ID_User3); | 1116 | error=GSM_WaitFor (&s, SetFreq, 10, 0x3E, 4, ID_User3); |
1117 | Print_Error(error); | 1117 | Print_Error(error); |
1118 | 1118 | ||
1119 | error=GSM_WaitFor (&s, Find2, 10, 0x3E, 4, ID_User3); | 1119 | error=GSM_WaitFor (&s, Find2, 10, 0x3E, 4, ID_User3); |
1120 | Print_Error(error); | 1120 | Print_Error(error); |
1121 | found = false; | 1121 | found = false; |
1122 | for (j=0;j<num;j++) { | 1122 | for (j=0;j<num;j++) { |
1123 | if (FMStation[j].Frequency > RadioFreq) { | 1123 | if (FMStation[j].Frequency > RadioFreq) { |
1124 | diff = FMStation[j].Frequency - RadioFreq; | 1124 | diff = FMStation[j].Frequency - RadioFreq; |
1125 | } else { | 1125 | } else { |
1126 | diff = RadioFreq - FMStation[j].Frequency; | 1126 | diff = RadioFreq - FMStation[j].Frequency; |
1127 | } | 1127 | } |
1128 | if (diff <= 0.2) { | 1128 | if (diff <= 0.2) { |
1129 | dbgprintf("diff is %f\n",diff); | 1129 | dbgprintf("diff is %f\n",diff); |
1130 | found = true; | 1130 | found = true; |
1131 | break; | 1131 | break; |
1132 | } | 1132 | } |
1133 | } | 1133 | } |
1134 | if (!found) { | 1134 | if (!found) { |
1135 | dbgprintf("Adding %f, num %i\n",RadioFreq,num); | 1135 | dbgprintf("Adding %f, num %i\n",RadioFreq,num); |
1136 | FMStation[num].Frequency = RadioFreq; | 1136 | FMStation[num].Frequency = RadioFreq; |
1137 | CopyUnicodeString(FMStation[num].StationName,RadioName); | 1137 | CopyUnicodeString(FMStation[num].StationName,RadioName); |
1138 | num++; | 1138 | num++; |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | fprintf(stderr,"%cSearching: %i percent",13,100); | 1141 | fprintf(stderr,"%cSearching: %i percent",13,100); |
1142 | fprintf(stderr,"\n\n"); | 1142 | fprintf(stderr,"\n\n"); |
1143 | 1143 | ||
1144 | i=0; | 1144 | i=0; |
1145 | while(1) { | 1145 | while(1) { |
1146 | if (i==num || i==num-1) break; | 1146 | if (i==num || i==num-1) break; |
1147 | if (FMStation[i].Frequency > FMStation[i+1].Frequency) { | 1147 | if (FMStation[i].Frequency > FMStation[i+1].Frequency) { |
1148 | memcpy(&FMStat,&FMStation[i],sizeof(GSM_FMStation)); | 1148 | memcpy(&FMStat,&FMStation[i],sizeof(GSM_FMStation)); |
1149 | memcpy(&FMStation[i],&FMStation[i+1],sizeof(GSM_FMStation)); | 1149 | memcpy(&FMStation[i],&FMStation[i+1],sizeof(GSM_FMStation)); |
1150 | memcpy(&FMStation[i+1],&FMStat,sizeof(GSM_FMStation)); | 1150 | memcpy(&FMStation[i+1],&FMStat,sizeof(GSM_FMStation)); |
1151 | i = 0; | 1151 | i = 0; |
1152 | continue; | 1152 | continue; |
1153 | } | 1153 | } |
1154 | i++; | 1154 | i++; |
1155 | } | 1155 | } |
1156 | for (i=0;i<num;i++) { | 1156 | for (i=0;i<num;i++) { |
1157 | fprintf(stderr,"%02i.",i+1); | 1157 | fprintf(stderr,"%02i.",i+1); |
1158 | if (FMStation[i].Frequency < 100) fprintf(stderr," "); | 1158 | if (FMStation[i].Frequency < 100) fprintf(stderr," "); |
1159 | fprintf(stderr,"%.1f MHz - \"%s\" \n", | 1159 | fprintf(stderr,"%.1f MHz - \"%s\" \n", |
1160 | FMStation[i].Frequency, | 1160 | FMStation[i].Frequency, |
1161 | DecodeUnicodeString(FMStation[i].StationName)); | 1161 | DecodeUnicodeString(FMStation[i].StationName)); |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | if (answer_yes2("Do you want to save found stations")) { | 1164 | if (answer_yes2("Do you want to save found stations")) { |
1165 | fprintf(stderr,"Deleting old FM stations: "); | 1165 | fprintf(stderr,"Deleting old FM stations: "); |
1166 | error=Phone->ClearFMStations(&s); | 1166 | error=Phone->ClearFMStations(&s); |
1167 | Print_Error(error); | 1167 | Print_Error(error); |
1168 | fprintf(stderr,"Done\n"); | 1168 | fprintf(stderr,"Done\n"); |
1169 | for (i=0;i<num;i++) { | 1169 | for (i=0;i<num;i++) { |
1170 | FMStation[i].Location = i+1; | 1170 | FMStation[i].Location = i+1; |
1171 | error=Phone->SetFMStation(&s,&FMStation[i]); | 1171 | error=Phone->SetFMStation(&s,&FMStation[i]); |
1172 | Print_Error(error); | 1172 | Print_Error(error); |
1173 | fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num); | 1173 | fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num); |
1174 | } | 1174 | } |
1175 | fprintf(stderr,"\n"); | 1175 | fprintf(stderr,"\n"); |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3); | 1178 | error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3); |
1179 | Print_Error(error); | 1179 | Print_Error(error); |
1180 | 1180 | ||
1181 | GSM_Terminate(); | 1181 | GSM_Terminate(); |
1182 | } | 1182 | } |
1183 | #endif | 1183 | #endif |
1184 | 1184 | ||
1185 | void DCT4PlaySavedRingtone(int argc, char *argv[]) | 1185 | void DCT4PlaySavedRingtone(int argc, char *argv[]) |
1186 | { | 1186 | { |
1187 | unsigned char req[] = {N6110_FRAME_HEADER, | 1187 | unsigned char req[] = {N6110_FRAME_HEADER, |
1188 | 0x01, | 1188 | 0x01, |
1189 | 0x00,0x64,//id | 1189 | 0x00,0x64,//id |
1190 | 0x01, //group | 1190 | 0x01, //group |
1191 | 0x01,0x00,0x00, | 1191 | 0x01,0x00,0x00, |
1192 | 0x0A, //volume | 1192 | 0x0A, //volume |
1193 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00}; | 1193 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
1194 | GSM_AllRingtonesInfo Info; | 1194 | GSM_AllRingtonesInfo Info; |
1195 | 1195 | ||
1196 | GSM_Init(true); | 1196 | GSM_Init(true); |
1197 | 1197 | ||
1198 | CheckDCT4(); | 1198 | CheckDCT4(); |
1199 | 1199 | ||
1200 | s.User.UserReplyFunctions=UserReplyFunctions4; | 1200 | s.User.UserReplyFunctions=UserReplyFunctions4; |
1201 | 1201 | ||
1202 | error=Phone->GetRingtonesInfo(&s,&Info); | 1202 | error=Phone->GetRingtonesInfo(&s,&Info); |
1203 | Print_Error(error); | 1203 | Print_Error(error); |
1204 | 1204 | ||
1205 | if (atoi(argv[2]) > Info.Number-1) { | 1205 | if (atoi(argv[2]) > Info.Number-1) { |
1206 | GSM_Terminate(); | 1206 | GSM_Terminate(); |
1207 | return; | 1207 | return; |
1208 | } | 1208 | } |
1209 | req[4] = Info.Ringtone[atoi(argv[2])].ID / 256; | 1209 | req[4] = Info.Ringtone[atoi(argv[2])].ID / 256; |
1210 | req[5] = Info.Ringtone[atoi(argv[2])].ID % 256; | 1210 | req[5] = Info.Ringtone[atoi(argv[2])].ID % 256; |
1211 | req[6] = Info.Ringtone[atoi(argv[2])].Group; | 1211 | req[6] = Info.Ringtone[atoi(argv[2])].Group; |
1212 | 1212 | ||
1213 | error=GSM_WaitFor (&s, req, 18, 0x1F, 4, ID_User3); | 1213 | error=GSM_WaitFor (&s, req, 18, 0x1F, 4, ID_User3); |
1214 | Print_Error(error); | 1214 | Print_Error(error); |
1215 | 1215 | ||
1216 | //for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); | 1216 | //for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); |
1217 | 1217 | ||
1218 | GSM_Terminate(); | 1218 | GSM_Terminate(); |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | static GSM_Error DCT4_ReplyMakeCameraShoot(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1221 | static GSM_Error DCT4_ReplyMakeCameraShoot(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1222 | { | 1222 | { |
1223 | return ERR_NONE; | 1223 | return ERR_NONE; |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | void DCT4MakeCameraShoot(int argc, char *argv[]) | 1226 | void DCT4MakeCameraShoot(int argc, char *argv[]) |
1227 | { | 1227 | { |
1228 | unsigned char SetCamera[] = {N6110_FRAME_HEADER, 0x09, 0x01, 0x02}; | 1228 | unsigned char SetCamera[] = {N6110_FRAME_HEADER, 0x09, 0x01, 0x02}; |
1229 | unsigned char CameraON[] = {N6110_FRAME_HEADER, 0x02, 0x01, 0x00, 0x00, 0x00 , 0x00, 0x00}; | 1229 | unsigned char CameraON[] = {N6110_FRAME_HEADER, 0x02, 0x01, 0x00, 0x00, 0x00 , 0x00, 0x00}; |
1230 | unsigned char CameraON2[] = {N6110_FRAME_HEADER, 0xF0, 0x02, 0x00}; | 1230 | unsigned char CameraON2[] = {N6110_FRAME_HEADER, 0xF0, 0x02, 0x00}; |
1231 | unsigned char MakeShot[200] = {N6110_FRAME_HEADER, 0x06, 0x01, 0x06, | 1231 | unsigned char MakeShot[200] = {N6110_FRAME_HEADER, 0x06, 0x01, 0x06, |
1232 | 0x01, 0x00, 0x00, 0x02, 0x00, 0x04, 0x32, 0x00, 0x01, | 1232 | 0x01, 0x00, 0x00, 0x02, 0x00, 0x04, 0x32, 0x00, 0x01, |
1233 | 0x1D, //length of rest | 1233 | 0x1D, //length of rest |
1234 | 0x00, 0x00, 0x00, 0x01, | 1234 | 0x00, 0x00, 0x00, 0x01, |
1235 | 0x00, 0x02,//master folder id | 1235 | 0x00, 0x02,//master folder id |
1236 | 0x00, 0x14}; //length | 1236 | 0x00, 0x14}; //length |
1237 | unsigned char CameraOFF[] = {N6110_FRAME_HEADER, 0x04, 0x01, 0x00}; | 1237 | unsigned char CameraOFF[] = {N6110_FRAME_HEADER, 0x04, 0x01, 0x00}; |
1238 | 1238 | ||
1239 | GSM_Init(true); | 1239 | GSM_Init(true); |
1240 | 1240 | ||
1241 | CheckDCT4(); | 1241 | CheckDCT4(); |
1242 | 1242 | ||
1243 | s.User.UserReplyFunctions=UserReplyFunctions4; | 1243 | s.User.UserReplyFunctions=UserReplyFunctions4; |
1244 | 1244 | ||
1245 | error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3); | 1245 | error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3); |
1246 | Print_Error(error); | 1246 | Print_Error(error); |
1247 | error=GSM_WaitFor (&s, CameraON, 10, 0x61, 4, ID_User3); | 1247 | error=GSM_WaitFor (&s, CameraON, 10, 0x61, 4, ID_User3); |
1248 | Print_Error(error); | 1248 | Print_Error(error); |
1249 | error=GSM_WaitFor (&s, CameraON2, 6, 0x61, 4, ID_User3); | 1249 | error=GSM_WaitFor (&s, CameraON2, 6, 0x61, 4, ID_User3); |
1250 | Print_Error(error); | 1250 | Print_Error(error); |
1251 | EncodeUnicode(MakeShot+24,"GammuShot",9); | 1251 | EncodeUnicode(MakeShot+24,"GammuShot",9); |
1252 | MakeShot[15] = 9+9*2; | 1252 | MakeShot[15] = 9+9*2; |
1253 | MakeShot[23] = 9*2; | 1253 | MakeShot[23] = 9*2; |
1254 | error=GSM_WaitFor (&s, MakeShot, 24+MakeShot[23], 0x61, 4, ID_User3); | 1254 | error=GSM_WaitFor (&s, MakeShot, 24+MakeShot[23], 0x61, 4, ID_User3); |
1255 | Print_Error(error); | 1255 | Print_Error(error); |
1256 | error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3); | 1256 | error=GSM_WaitFor (&s, SetCamera, 6, 0x61, 4, ID_User3); |
1257 | Print_Error(error); | 1257 | Print_Error(error); |
1258 | error=GSM_WaitFor (&s, CameraOFF, 6, 0x61, 4, ID_User3); | 1258 | error=GSM_WaitFor (&s, CameraOFF, 6, 0x61, 4, ID_User3); |
1259 | Print_Error(error); | 1259 | Print_Error(error); |
1260 | 1260 | ||
1261 | GSM_Terminate(); | 1261 | GSM_Terminate(); |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | int len; | 1264 | int len; |
1265 | 1265 | ||
1266 | static GSM_Error DCT4_ReplyGetScreenDump(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1266 | static GSM_Error DCT4_ReplyGetScreenDump(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1267 | { | 1267 | { |
1268 | if (msg.Buffer[7] == 0x0C) len = 1; | 1268 | if (msg.Buffer[7] == 0x0C) len = 1; |
1269 | return ERR_NONE; | 1269 | return ERR_NONE; |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | void DCT4GetScreenDump(int argc, char *argv[]) | 1272 | void DCT4GetScreenDump(int argc, char *argv[]) |
1273 | { | 1273 | { |
1274 | unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x00}; | 1274 | unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x00}; |
1275 | //n6110_frameheader 06//screen info | 1275 | //n6110_frameheader 06//screen info |
1276 | 1276 | ||
1277 | GSM_Init(true); | 1277 | GSM_Init(true); |
1278 | 1278 | ||
1279 | CheckDCT4(); | 1279 | CheckDCT4(); |
1280 | 1280 | ||
1281 | s.User.UserReplyFunctions=UserReplyFunctions4; | 1281 | s.User.UserReplyFunctions=UserReplyFunctions4; |
1282 | 1282 | ||
1283 | error=GSM_WaitFor (&s, req, 6, 0x0E, 4, ID_User3); | 1283 | error=GSM_WaitFor (&s, req, 6, 0x0E, 4, ID_User3); |
1284 | Print_Error(error); | 1284 | Print_Error(error); |
1285 | len = 2000; | 1285 | len = 2000; |
1286 | while (len >= 200) GSM_ReadDevice(&s,true); | 1286 | while (len >= 200) GSM_ReadDevice(&s,true); |
1287 | 1287 | ||
1288 | GSM_Terminate(); | 1288 | GSM_Terminate(); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | static GSM_Reply_Function UserReplyFunctions4[] = { | 1291 | static GSM_Reply_Function UserReplyFunctions4[] = { |
1292 | 1292 | ||
1293 | #ifdef DEBUG | 1293 | #ifdef DEBUG |
1294 | {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x05,ID_User2}, | 1294 | {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x05,ID_User2}, |
1295 | {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x06,ID_User2}, | 1295 | {DCT4_ReplyResetSecurityCode, "\x08",0x03,0x06,ID_User2}, |
1296 | #endif | 1296 | #endif |
1297 | 1297 | ||
1298 | {DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_User3}, | 1298 | {DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_User3}, |
1299 | {DCT4_ReplyGetScreenDump,"\x0E",0x00,0x00,ID_IncomingFrame}, | 1299 | {DCT4_ReplyGetScreenDump,"\x0E",0x00,0x00,ID_IncomingFrame}, |
1300 | 1300 | ||
1301 | {DCT4_ReplyGetADC, "\x17",0x03,0x10,ID_User3}, | 1301 | {DCT4_ReplyGetADC, "\x17",0x03,0x10,ID_User3}, |
1302 | {DCT4_ReplyGetADC, "\x17",0x03,0x12,ID_User3}, | 1302 | {DCT4_ReplyGetADC, "\x17",0x03,0x12,ID_User3}, |
1303 | 1303 | ||
1304 | {DCT4_ReplySetPPS, "\x1b",0x03,0x05,ID_User1}, | 1304 | {DCT4_ReplySetPPS, "\x1b",0x03,0x05,ID_User1}, |
1305 | {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_User6}, | 1305 | {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_User6}, |
1306 | 1306 | ||
1307 | {DCT4_ReplyVibra, "\x1C",0x03,0x0D,ID_User3}, | 1307 | {DCT4_ReplyVibra, "\x1C",0x03,0x0D,ID_User3}, |
1308 | {DCT4_ReplyVibra, "\x1C",0x03,0x0F,ID_User3}, | 1308 | {DCT4_ReplyVibra, "\x1C",0x03,0x0F,ID_User3}, |
1309 | 1309 | ||
1310 | {NoneReply, "\x1F",0x03,0x02,ID_User3}, | 1310 | {NoneReply, "\x1F",0x03,0x02,ID_User3}, |
1311 | 1311 | ||
1312 | {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1}, | 1312 | {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1}, |
1313 | {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3}, | 1313 | {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3}, |
1314 | {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4}, | 1314 | {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4}, |
1315 | {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4}, | 1315 | {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4}, |
1316 | {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1}, | 1316 | {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1}, |
1317 | 1317 | ||
1318 | {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3}, | 1318 | {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3}, |
1319 | {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3}, | 1319 | {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3}, |
1320 | {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1}, | 1320 | {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1}, |
1321 | {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2}, | 1321 | {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2}, |
1322 | 1322 | ||
1323 | #ifdef GSM_ENABLE_NOKIA6510 | 1323 | #ifdef GSM_ENABLE_NOKIA6510 |
1324 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3}, | 1324 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3}, |
1325 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3}, | 1325 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3}, |
1326 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation}, | 1326 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation}, |
1327 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3}, | 1327 | {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3}, |
1328 | #endif | 1328 | #endif |
1329 | 1329 | ||
1330 | {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4}, | 1330 | {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4}, |
1331 | 1331 | ||
1332 | {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6}, | 1332 | {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6}, |
1333 | {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6}, | 1333 | {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6}, |
1334 | 1334 | ||
1335 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3}, | 1335 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3}, |
1336 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3}, | 1336 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3}, |
1337 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3}, | 1337 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3}, |
1338 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3}, | 1338 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3}, |
1339 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3}, | 1339 | {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3}, |
1340 | 1340 | ||
1341 | {DCT4_ReplyGetBTInfo, "\xD7",0x03,0x0A,ID_User6}, | 1341 | {DCT4_ReplyGetBTInfo, "\xD7",0x03,0x0A,ID_User6}, |
1342 | 1342 | ||
1343 | {NULL, "\x00",0x00,0x00,ID_None} | 1343 | {NULL, "\x00",0x00,0x00,ID_None} |
1344 | }; | 1344 | }; |
1345 | 1345 | ||
1346 | #endif | 1346 | #endif |
1347 | 1347 | ||
1348 | /* How should editor hadle tabs in this file? Add editor commands here. | 1348 | /* How should editor hadle tabs in this file? Add editor commands here. |
1349 | * vim: noexpandtab sw=8 ts=8 sts=8: | 1349 | * vim: noexpandtab sw=8 ts=8 sts=8: |
1350 | */ | 1350 | */ |
diff --git a/gammu/emb/gammu/depend/siemens/dsiemens.c b/gammu/emb/gammu/depend/siemens/dsiemens.c index dc54102..a34bc3b 100644 --- a/gammu/emb/gammu/depend/siemens/dsiemens.c +++ b/gammu/emb/gammu/depend/siemens/dsiemens.c | |||
@@ -1,363 +1,363 @@ | |||
1 | /* (c) by Walek */ | 1 | /* (c) by Walek */ |
2 | 2 | ||
3 | #include "../../../common/gsmstate.h" | 3 | #include "../../../common/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 | 8 | ||
9 | #include "../../../common/misc/coding/coding.h" | 9 | #include "../../../common/misc/coding/coding.h" |
10 | #include "../../../common/gsmcomon.h" | 10 | #include "../../../common/gsmcomon.h" |
11 | #include "../../../common/service/gsmnet.h" | 11 | #include "../../../common/service/gsmnet.h" |
12 | #include "../../../common/phone/at/atgen.h" | 12 | #include "../../../common/phone/at/atgen.h" |
13 | #include "../../gammu.h" | 13 | #include "../../gammu.h" |
14 | #include "dsiemens.h" | 14 | #include "dsiemens.h" |
15 | #include "chiffre.h" | 15 | #include "chiffre.h" |
16 | 16 | ||
17 | extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); | 17 | extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); |
18 | extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *status); | 18 | extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *status); |
19 | extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *pbk); | 19 | extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *pbk); |
20 | extern GSM_Reply_Function UserReplyFunctionsAtS[]; | 20 | static GSM_Reply_Function UserReplyFunctionsAtS[]; |
21 | 21 | ||
22 | bool new_variable; | 22 | bool new_variable; |
23 | GSM_Error CheckSiemens() | 23 | GSM_Error CheckSiemens() |
24 | { | 24 | { |
25 | if (s.Phone.Data.Priv.ATGEN.Manufacturer != AT_Siemens) return ERR_NOTSUPPORTED; | 25 | if (s.Phone.Data.Priv.ATGEN.Manufacturer != AT_Siemens) return ERR_NOTSUPPORTED; |
26 | return ERR_NONE; | 26 | return ERR_NONE; |
27 | } | 27 | } |
28 | 28 | ||
29 | GSM_Error ATSIEMENS_Reply_GetSAT(GSM_Protocol_Message msg, GSM_StateMachine *s) | 29 | GSM_Error ATSIEMENS_Reply_GetSAT(GSM_Protocol_Message msg, GSM_StateMachine *s) |
30 | { | 30 | { |
31 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; | 31 | GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; |
32 | GSM_SAT_Measure_results MeasureResult; | 32 | GSM_SAT_Measure_results MeasureResult; |
33 | unsigned char buf[256]; | 33 | unsigned char buf[256]; |
34 | int length,i,rep,ChNo=1,j=0,result=0,origARFCN=0; | 34 | int length,i,rep,ChNo=1,j=0,result=0,origARFCN=0; |
35 | int freq_tmp,frequency[24]; | 35 | int freq_tmp,frequency[24]; |
36 | GSM_NetworkInfo Network; | 36 | GSM_NetworkInfo Network; |
37 | 37 | ||
38 | if (Priv->ReplyState!=AT_Reply_OK) return ERR_UNKNOWN; | 38 | if (Priv->ReplyState!=AT_Reply_OK) return ERR_UNKNOWN; |
39 | if (s->Protocol.Data.AT.EditMode) s->Protocol.Data.AT.EditMode = false; | 39 | if (s->Protocol.Data.AT.EditMode) s->Protocol.Data.AT.EditMode = false; |
40 | if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"SSTK")) { | 40 | if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"SSTK")) { |
41 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,2))-7; | 41 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,2))-7; |
42 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,2)+7,length); | 42 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,2)+7,length); |
43 | if (buf[0]==0x7f) { | 43 | if (buf[0]==0x7f) { |
44 | new_variable=true; | 44 | new_variable=true; |
45 | return ERR_NONE; | 45 | return ERR_NONE; |
46 | } | 46 | } |
47 | else return ERR_UNKNOWN; | 47 | else return ERR_UNKNOWN; |
48 | } | 48 | } |
49 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,3),"SSTK")) return ERR_UNKNOWN; | 49 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,3),"SSTK")) return ERR_UNKNOWN; |
50 | 50 | ||
51 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,3))-7; | 51 | length = strlen(GetLineString(msg.Buffer,Priv->Lines,3))-7; |
52 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,3)+7,length); | 52 | DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,3)+7,length); |
53 | 53 | ||
54 | if (buf[3]!=0x26) return ERR_UNKNOWN; | 54 | if (buf[3]!=0x26) return ERR_UNKNOWN; |
55 | 55 | ||
56 | #ifdef DEBUG | 56 | #ifdef DEBUG |
57 | dbgprintf ("SAT command: Provide Local Information\nFunction: "); | 57 | dbgprintf ("SAT command: Provide Local Information\nFunction: "); |
58 | switch (buf[4]) { | 58 | switch (buf[4]) { |
59 | case 00: dbgprintf ("Loc Info\n"); break; | 59 | case 00: dbgprintf ("Loc Info\n"); break; |
60 | case 01: dbgprintf ("IMEI\n"); break; | 60 | case 01: dbgprintf ("IMEI\n"); break; |
61 | case 02: dbgprintf ("Network Measure\n"); break; | 61 | case 02: dbgprintf ("Network Measure\n"); break; |
62 | case 03: dbgprintf ("Date time and timezone\n");break; | 62 | case 03: dbgprintf ("Date time and timezone\n");break; |
63 | case 04: dbgprintf ("Language setting\n"); break; | 63 | case 04: dbgprintf ("Language setting\n"); break; |
64 | case 05: dbgprintf ("Timing advance\n"); break; | 64 | case 05: dbgprintf ("Timing advance\n"); break; |
65 | } | 65 | } |
66 | #endif | 66 | #endif |
67 | /* Loc Info (MCC, MNC, LAC, Cell ID) */ | 67 | /* Loc Info (MCC, MNC, LAC, Cell ID) */ |
68 | if (buf[4]==00) { | 68 | if (buf[4]==00) { |
69 | DecodeBCD (Network.NetworkCode,buf+14,2); | 69 | DecodeBCD (Network.NetworkCode,buf+14,2); |
70 | Network.NetworkCode[3] = ' '; | 70 | Network.NetworkCode[3] = ' '; |
71 | DecodeBCD (Network.NetworkCode+4,buf+16,1); | 71 | DecodeBCD (Network.NetworkCode+4,buf+16,1); |
72 | EncodeHexBin (Network.LAC,buf+17,2); | 72 | EncodeHexBin (Network.LAC,buf+17,2); |
73 | EncodeHexBin (Network.CID,buf+19,2); | 73 | EncodeHexBin (Network.CID,buf+19,2); |
74 | 74 | ||
75 | printf(" Network code : %s\n",Network.NetworkCode); | 75 | printf(" Network code : %s\n",Network.NetworkCode); |
76 | printf(" Network name for Gammu : %s\n", | 76 | printf(" Network name for Gammu : %s\n", |
77 | DecodeUnicodeString(GSM_GetNetworkName(Network.NetworkCode))); | 77 | DecodeUnicodeString(GSM_GetNetworkName(Network.NetworkCode))); |
78 | printf(" CID : %s\n",Network.CID); | 78 | printf(" CID : %s\n",Network.CID); |
79 | printf(" LAC : %s\n",Network.LAC); | 79 | printf(" LAC : %s\n",Network.LAC); |
80 | } | 80 | } |
81 | 81 | ||
82 | /* Network Measure */ | 82 | /* Network Measure */ |
83 | if (buf[4]==02) { | 83 | if (buf[4]==02) { |
84 | 84 | ||
85 | for (i=0;i<24;i++) frequency[i]=0; | 85 | for (i=0;i<24;i++) frequency[i]=0; |
86 | if (!new_variable) { | 86 | if (!new_variable) { |
87 | GetBufferI(buf+32,&j,&result,7); | 87 | GetBufferI(buf+32,&j,&result,7); |
88 | result &= 0x67; | 88 | result &= 0x67; |
89 | if (result !=0x47) return ERR_NOTSUPPORTED; | 89 | if (result !=0x47) return ERR_NOTSUPPORTED; |
90 | } | 90 | } |
91 | #ifdef DEBUG | 91 | #ifdef DEBUG |
92 | if (new_variable)dbgprintf ("New variable Bitmap format\n"); | 92 | if (new_variable)dbgprintf ("New variable Bitmap format\n"); |
93 | else dbgprintf ("Old variable Bitmap format\n"); | 93 | else dbgprintf ("Old variable Bitmap format\n"); |
94 | #endif | 94 | #endif |
95 | GetBufferI(buf+32,&j,&origARFCN,10); | 95 | GetBufferI(buf+32,&j,&origARFCN,10); |
96 | /* 10 bit origin ARFCN or first frequency (new variable format) */ | 96 | /* 10 bit origin ARFCN or first frequency (new variable format) */ |
97 | #ifdef DEBUG | 97 | #ifdef DEBUG |
98 | dbgprintf("Origin BCCH = %i\n",origARFCN); | 98 | dbgprintf("Origin BCCH = %i\n",origARFCN); |
99 | #endif | 99 | #endif |
100 | rep = buf[31]*8; | 100 | rep = buf[31]*8; |
101 | if (!new_variable ){ | 101 | if (!new_variable ){ |
102 | for (i=0;i<rep;i++){ | 102 | for (i=0;i<rep;i++){ |
103 | result = 0; | 103 | result = 0; |
104 | GetBufferI(buf+32,&j,&result,1); | 104 | GetBufferI(buf+32,&j,&result,1); |
105 | if (result) { | 105 | if (result) { |
106 | frequency[ChNo]=i+origARFCN+1; | 106 | frequency[ChNo]=i+origARFCN+1; |
107 | ChNo++; | 107 | ChNo++; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | else { | 111 | else { |
112 | frequency[ChNo++]=origARFCN; | 112 | frequency[ChNo++]=origARFCN; |
113 | for (i=0; i<rep; i+=10){ | 113 | for (i=0; i<rep; i+=10){ |
114 | result = 0; | 114 | result = 0; |
115 | GetBufferI(buf+32,&j,&result,10); | 115 | GetBufferI(buf+32,&j,&result,10); |
116 | if (!result) break; | 116 | if (!result) break; |
117 | frequency[ChNo++]=result; | 117 | frequency[ChNo++]=result; |
118 | } | 118 | } |
119 | j=1; | 119 | j=1; |
120 | while (j) { | 120 | while (j) { |
121 | j=0; | 121 | j=0; |
122 | for (i=0; i<ChNo-1; i++){ | 122 | for (i=0; i<ChNo-1; i++){ |
123 | if (frequency[i] > frequency[i+1]){ | 123 | if (frequency[i] > frequency[i+1]){ |
124 | freq_tmp=frequency[i]; | 124 | freq_tmp=frequency[i]; |
125 | frequency[i]=frequency[i+1]; | 125 | frequency[i]=frequency[i+1]; |
126 | frequency[i+1]=freq_tmp; | 126 | frequency[i+1]=freq_tmp; |
127 | j=1; | 127 | j=1; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | }; | 131 | }; |
132 | #ifdef DEBUG | 132 | #ifdef DEBUG |
133 | dbgprintf("Neighbor BCCH list: "); | 133 | dbgprintf("Neighbor BCCH list: "); |
134 | for (i=1;i<ChNo;i++) dbgprintf ("%d ",frequency[i]); | 134 | for (i=1;i<ChNo;i++) dbgprintf ("%d ",frequency[i]); |
135 | dbgprintf ("\n"); | 135 | dbgprintf ("\n"); |
136 | #endif | 136 | #endif |
137 | j= 0; | 137 | j= 0; |
138 | result= 0; | 138 | result= 0; |
139 | GetBufferI(buf+14,&j,&result,1); | 139 | GetBufferI(buf+14,&j,&result,1); |
140 | if (result) MeasureResult.BA_used=true; | 140 | if (result) MeasureResult.BA_used=true; |
141 | else MeasureResult.BA_used=false; | 141 | else MeasureResult.BA_used=false; |
142 | 142 | ||
143 | result= 0; | 143 | result= 0; |
144 | GetBufferI(buf+14,&j,&result,1); | 144 | GetBufferI(buf+14,&j,&result,1); |
145 | if (result) MeasureResult.DTX_used=true; | 145 | if (result) MeasureResult.DTX_used=true; |
146 | else MeasureResult.DTX_used=false; | 146 | else MeasureResult.DTX_used=false; |
147 | 147 | ||
148 | result= 0; | 148 | result= 0; |
149 | GetBufferI(buf+14,&j,&result,6); | 149 | GetBufferI(buf+14,&j,&result,6); |
150 | MeasureResult.RXLEV_FullServicingCell=result-110; | 150 | MeasureResult.RXLEV_FullServicingCell=result-110; |
151 | 151 | ||
152 | j++;//skip spare bit | 152 | j++;//skip spare bit |
153 | result= 0; | 153 | result= 0; |
154 | GetBufferI(buf+14,&j,&result,1); | 154 | GetBufferI(buf+14,&j,&result,1); |
155 | if (result) MeasureResult.MeasValid=true; | 155 | if (result) MeasureResult.MeasValid=true; |
156 | else MeasureResult.MeasValid=false; | 156 | else MeasureResult.MeasValid=false; |
157 | 157 | ||
158 | result= 0; | 158 | result= 0; |
159 | GetBufferI(buf+14,&j,&result,6); | 159 | GetBufferI(buf+14,&j,&result,6); |
160 | MeasureResult.RXLEV_SubServicingCell=result-110; | 160 | MeasureResult.RXLEV_SubServicingCell=result-110; |
161 | 161 | ||
162 | j++;//skip spare bit | 162 | j++;//skip spare bit |
163 | result= 0; | 163 | result= 0; |
164 | GetBufferI(buf+14,&j,&result,3); | 164 | GetBufferI(buf+14,&j,&result,3); |
165 | MeasureResult.RXQUAL_FullServicingCell=result; | 165 | MeasureResult.RXQUAL_FullServicingCell=result; |
166 | 166 | ||
167 | result= 0; | 167 | result= 0; |
168 | GetBufferI(buf+14,&j,&result,3); | 168 | GetBufferI(buf+14,&j,&result,3); |
169 | MeasureResult.RXQUAL_SubServicingCell=result; | 169 | MeasureResult.RXQUAL_SubServicingCell=result; |
170 | 170 | ||
171 | printf ("RX Level FULL Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell); | 171 | printf ("RX Level FULL Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell); |
172 | printf ("RX Level Sub Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell); | 172 | printf ("RX Level Sub Servicing Cell = %i\n",MeasureResult.RXLEV_FullServicingCell); |
173 | 173 | ||
174 | printf ("RX Quality Full Servicing Cell = %i\n",MeasureResult.RXQUAL_FullServicingCell); | 174 | printf ("RX Quality Full Servicing Cell = %i\n",MeasureResult.RXQUAL_FullServicingCell); |
175 | printf ("RX Quality Sub Servicing Cell = %i\n",MeasureResult.RXQUAL_SubServicingCell); | 175 | printf ("RX Quality Sub Servicing Cell = %i\n",MeasureResult.RXQUAL_SubServicingCell); |
176 | 176 | ||
177 | result= 0; | 177 | result= 0; |
178 | GetBufferI(buf+14,&j,&result,3); | 178 | GetBufferI(buf+14,&j,&result,3); |
179 | MeasureResult.NO_NCELL_M=result; | 179 | MeasureResult.NO_NCELL_M=result; |
180 | 180 | ||
181 | rep=MeasureResult.NO_NCELL_M; | 181 | rep=MeasureResult.NO_NCELL_M; |
182 | 182 | ||
183 | for (i=0;i<MeasureResult.NO_NCELL_M;i++) { | 183 | for (i=0;i<MeasureResult.NO_NCELL_M;i++) { |
184 | result= 0; | 184 | result= 0; |
185 | GetBufferI(buf+14,&j,&result,6); | 185 | GetBufferI(buf+14,&j,&result,6); |
186 | MeasureResult.NeighbourCell[i].RxLev = result-110; | 186 | MeasureResult.NeighbourCell[i].RxLev = result-110; |
187 | 187 | ||
188 | result= 0; | 188 | result= 0; |
189 | GetBufferI(buf+14,&j,&result,5); | 189 | GetBufferI(buf+14,&j,&result,5); |
190 | if (new_variable) | 190 | if (new_variable) |
191 | MeasureResult.NeighbourCell[i].ChFreq = frequency[result+1]; | 191 | MeasureResult.NeighbourCell[i].ChFreq = frequency[result+1]; |
192 | else MeasureResult.NeighbourCell[i].ChFreq = frequency[result]; | 192 | else MeasureResult.NeighbourCell[i].ChFreq = frequency[result]; |
193 | 193 | ||
194 | result= 0; | 194 | result= 0; |
195 | GetBufferI(buf+14,&j,&result,3); | 195 | GetBufferI(buf+14,&j,&result,3); |
196 | MeasureResult.NeighbourCell[i].NB = 10 * result; | 196 | MeasureResult.NeighbourCell[i].NB = 10 * result; |
197 | result= 0; | 197 | result= 0; |
198 | GetBufferI(buf+14,&j,&result,3); | 198 | GetBufferI(buf+14,&j,&result,3); |
199 | MeasureResult.NeighbourCell[i].NB += result; | 199 | MeasureResult.NeighbourCell[i].NB += result; |
200 | 200 | ||
201 | if (MeasureResult.NeighbourCell[i].ChFreq) | 201 | if (MeasureResult.NeighbourCell[i].ChFreq) |
202 | printf("CH = %i,\t",MeasureResult.NeighbourCell[i].ChFreq); | 202 | printf("CH = %i,\t",MeasureResult.NeighbourCell[i].ChFreq); |
203 | else | 203 | else |
204 | printf("CH = Unknown\t"); | 204 | printf("CH = Unknown\t"); |
205 | printf("RX Lev = %i dBm\t",MeasureResult.NeighbourCell[i].RxLev); | 205 | printf("RX Lev = %i dBm\t",MeasureResult.NeighbourCell[i].RxLev); |
206 | printf("BSIC CELL = %i\n",MeasureResult.NeighbourCell[i].NB); | 206 | printf("BSIC CELL = %i\n",MeasureResult.NeighbourCell[i].NB); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #ifdef DEBUG | 209 | #ifdef DEBUG |
210 | if (buf[4]==05) { //Timing Advance | 210 | if (buf[4]==05) { //Timing Advance |
211 | if (buf[11]) dbgprintf ("Unknown Timing Advance\n"); | 211 | if (buf[11]) dbgprintf ("Unknown Timing Advance\n"); |
212 | else dbgprintf ("Timing Advance = %i\n",buf[14] & 0x3f); | 212 | else dbgprintf ("Timing Advance = %i\n",buf[14] & 0x3f); |
213 | } | 213 | } |
214 | #endif | 214 | #endif |
215 | return ERR_NONE; | 215 | return ERR_NONE; |
216 | } | 216 | } |
217 | 217 | ||
218 | GSM_Error ATSIEMENS_Reply_GetNetmon(GSM_Protocol_Message msg, GSM_StateMachine *s) | 218 | GSM_Error ATSIEMENS_Reply_GetNetmon(GSM_Protocol_Message msg, GSM_StateMachine *s) |
219 | { | 219 | { |
220 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 220 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
221 | int i=2; | 221 | int i=2; |
222 | 222 | ||
223 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,1),"AT^S^MI")) return ERR_UNKNOWN; | 223 | if (!strstr(GetLineString(msg.Buffer,Priv->Lines,1),"AT^S^MI")) return ERR_UNKNOWN; |
224 | while (strlen(GetLineString(msg.Buffer,Priv->Lines,i+1))) | 224 | while (strlen(GetLineString(msg.Buffer,Priv->Lines,i+1))) |
225 | printf("%s\n",GetLineString(msg.Buffer,Priv->Lines,i++)); | 225 | printf("%s\n",GetLineString(msg.Buffer,Priv->Lines,i++)); |
226 | printf("\n"); | 226 | printf("\n"); |
227 | return ERR_NONE; | 227 | return ERR_NONE; |
228 | } | 228 | } |
229 | 229 | ||
230 | GSM_Error ATSIEMENS_GetSAT(GSM_StateMachine *s) | 230 | GSM_Error ATSIEMENS_GetSAT(GSM_StateMachine *s) |
231 | { | 231 | { |
232 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 232 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
233 | GSM_Error error; | 233 | GSM_Error error; |
234 | unsigned char *reqSAT[]= {"D009810301260082028182", | 234 | unsigned char *reqSAT[]= {"D009810301260082028182", |
235 | "D009810301260282028182", | 235 | "D009810301260282028182", |
236 | "D009810301260582028182"},req[32]; | 236 | "D009810301260582028182"},req[32]; |
237 | int i,len; | 237 | int i,len; |
238 | 238 | ||
239 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 239 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
240 | 240 | ||
241 | sprintf(req, "AT^SSTK=?\r"); | 241 | sprintf(req, "AT^SSTK=?\r"); |
242 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1); | 242 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1); |
243 | 243 | ||
244 | for (i=0;i<3;i++){ | 244 | for (i=0;i<3;i++){ |
245 | len = strlen(reqSAT[i]); | 245 | len = strlen(reqSAT[i]); |
246 | s->Protocol.Data.AT.EditMode = true; | 246 | s->Protocol.Data.AT.EditMode = true; |
247 | sprintf(req, "AT^SSTK=%i,1\r",len/2); | 247 | sprintf(req, "AT^SSTK=%i,1\r",len/2); |
248 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1); | 248 | error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_User1); |
249 | s->Phone.Data.DispatchError= ERR_TIMEOUT; | 249 | s->Phone.Data.DispatchError= ERR_TIMEOUT; |
250 | s->Phone.Data.RequestID = ID_User1; | 250 | s->Phone.Data.RequestID = ID_User1; |
251 | error = s->Protocol.Functions->WriteMessage(s, reqSAT[i], len, 0x00); | 251 | error = s->Protocol.Functions->WriteMessage(s, reqSAT[i], len, 0x00); |
252 | if (error!=ERR_NONE) return error; | 252 | if (error!=ERR_NONE) return error; |
253 | error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); | 253 | error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); |
254 | if (error!=ERR_NONE) return error; | 254 | if (error!=ERR_NONE) return error; |
255 | error = GSM_WaitForOnce (s, NULL,0x00, 0x00, 4); | 255 | error = GSM_WaitForOnce (s, NULL,0x00, 0x00, 4); |
256 | if (error!=ERR_NONE) return error; | 256 | if (error!=ERR_NONE) return error; |
257 | } | 257 | } |
258 | return ERR_NONE; | 258 | return ERR_NONE; |
259 | } | 259 | } |
260 | 260 | ||
261 | GSM_Error ATSIEMENS_GetNetmon(GSM_StateMachine *s,int test_no) | 261 | GSM_Error ATSIEMENS_GetNetmon(GSM_StateMachine *s,int test_no) |
262 | { | 262 | { |
263 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 263 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
264 | unsigned char req[32]; | 264 | unsigned char req[32]; |
265 | 265 | ||
266 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 266 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
267 | sprintf(req, "AT^S^MI=%d\r",test_no); | 267 | sprintf(req, "AT^S^MI=%d\r",test_no); |
268 | printf ("Siemens NetMonitor test #%i\n",test_no); | 268 | printf ("Siemens NetMonitor test #%i\n",test_no); |
269 | return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2); | 269 | return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2); |
270 | } | 270 | } |
271 | 271 | ||
272 | GSM_Error ATSIEMENS_ActivateNetmon (GSM_StateMachine *s,int netmon_type) | 272 | GSM_Error ATSIEMENS_ActivateNetmon (GSM_StateMachine *s,int netmon_type) |
273 | { | 273 | { |
274 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; | 274 | GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; |
275 | unsigned char req[32]; | 275 | unsigned char req[32]; |
276 | 276 | ||
277 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; | 277 | if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; |
278 | 278 | ||
279 | sprintf(req, "AT\r"); | 279 | sprintf(req, "AT\r"); |
280 | printf ("Activate Siemens NetMonitor\n"); | 280 | printf ("Activate Siemens NetMonitor\n"); |
281 | siemens_code (req,req,2); | 281 | siemens_code (req,req,2); |
282 | 282 | ||
283 | return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2); | 283 | return GSM_WaitFor(s, req, strlen(req), 0x00, 3, ID_User2); |
284 | } | 284 | } |
285 | 285 | ||
286 | void ATSIEMENSActivateNetmon(int argc, char *argv[]) | 286 | void ATSIEMENSActivateNetmon(int argc, char *argv[]) |
287 | { | 287 | { |
288 | GSM_MemoryStatus status; | 288 | GSM_MemoryStatus status; |
289 | GSM_MemoryEntry pbk; | 289 | GSM_MemoryEntry pbk; |
290 | int netmon_type, pbk_maxlocation; | 290 | int netmon_type, pbk_maxlocation; |
291 | char imsi[15], NetMonCode[32]; | 291 | char imsi[15], NetMonCode[32]; |
292 | 292 | ||
293 | GSM_Init(true); | 293 | GSM_Init(true); |
294 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); | 294 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); |
295 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; | 295 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; |
296 | 296 | ||
297 | printf ("Activate NetMonitor...\n"); | 297 | printf ("Activate NetMonitor...\n"); |
298 | netmon_type = atoi(argv[2]); | 298 | netmon_type = atoi(argv[2]); |
299 | 299 | ||
300 | if ((netmon_type==1) || (netmon_type==2)) { | 300 | if ((netmon_type==1) || (netmon_type==2)) { |
301 | error = ATGEN_GetSIMIMSI (&s,imsi); | 301 | error = ATGEN_GetSIMIMSI (&s,imsi); |
302 | Print_Error(error); | 302 | Print_Error(error); |
303 | siemens_code(imsi,NetMonCode,netmon_type); | 303 | siemens_code(imsi,NetMonCode,netmon_type); |
304 | 304 | ||
305 | status.MemoryType = MEM_SM; | 305 | status.MemoryType = MEM_SM; |
306 | error = ATGEN_GetMemoryStatus (&s,&status); | 306 | error = ATGEN_GetMemoryStatus (&s,&status); |
307 | Print_Error(error); | 307 | Print_Error(error); |
308 | 308 | ||
309 | pbk_maxlocation = status.MemoryUsed+status.MemoryFree; | 309 | pbk_maxlocation = status.MemoryUsed+status.MemoryFree; |
310 | pbk.MemoryType = MEM_SM; | 310 | pbk.MemoryType = MEM_SM; |
311 | pbk.Location = pbk_maxlocation; | 311 | pbk.Location = pbk_maxlocation; |
312 | pbk.EntriesNum = 2; | 312 | pbk.EntriesNum = 2; |
313 | pbk.Entries[0].EntryType = PBK_Number_General; | 313 | pbk.Entries[0].EntryType = PBK_Number_General; |
314 | EncodeUnicode (pbk.Entries[0].Text,NetMonCode,strlen(NetMonCode)); | 314 | EncodeUnicode (pbk.Entries[0].Text,NetMonCode,strlen(NetMonCode)); |
315 | pbk.Entries[1].EntryType = PBK_Text_Name; | 315 | pbk.Entries[1].EntryType = PBK_Text_Name; |
316 | sprintf (NetMonCode,"Net Monitor"); | 316 | sprintf (NetMonCode,"Net Monitor"); |
317 | EncodeUnicode (pbk.Entries[1].Text,NetMonCode,strlen(NetMonCode)); | 317 | EncodeUnicode (pbk.Entries[1].Text,NetMonCode,strlen(NetMonCode)); |
318 | error = ATGEN_SetMemory (&s, &pbk); | 318 | error = ATGEN_SetMemory (&s, &pbk); |
319 | Print_Error(error); | 319 | Print_Error(error); |
320 | } | 320 | } |
321 | else printf ("NetMonitor type should be:\n1 - full Netmon\n2 - simple NetMon\n"); | 321 | else printf ("NetMonitor type should be:\n1 - full Netmon\n2 - simple NetMon\n"); |
322 | 322 | ||
323 | GSM_Terminate(); | 323 | GSM_Terminate(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void ATSIEMENSSATNetmon(int argc, char *argv[]) | 326 | void ATSIEMENSSATNetmon(int argc, char *argv[]) |
327 | { | 327 | { |
328 | GSM_Init(true); | 328 | GSM_Init(true); |
329 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); | 329 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); |
330 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; | 330 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; |
331 | 331 | ||
332 | printf ("Getting Siemens Sim Aplication Toolkit NetMonitor...\n"); | 332 | printf ("Getting Siemens Sim Aplication Toolkit NetMonitor...\n"); |
333 | 333 | ||
334 | error=ATSIEMENS_GetSAT(&s); | 334 | error=ATSIEMENS_GetSAT(&s); |
335 | Print_Error(error); | 335 | Print_Error(error); |
336 | GSM_Terminate(); | 336 | GSM_Terminate(); |
337 | } | 337 | } |
338 | 338 | ||
339 | void ATSIEMENSNetmonitor(int argc, char *argv[]) | 339 | void ATSIEMENSNetmonitor(int argc, char *argv[]) |
340 | { | 340 | { |
341 | int test_no; | 341 | int test_no; |
342 | 342 | ||
343 | GSM_Init(true); | 343 | GSM_Init(true); |
344 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); | 344 | if (CheckSiemens()==ERR_NOTSUPPORTED) Print_Error(ERR_NOTSUPPORTED); |
345 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; | 345 | s.User.UserReplyFunctions=UserReplyFunctionsAtS; |
346 | 346 | ||
347 | printf ("Getting Siemens NetMonitor...\n"); | 347 | printf ("Getting Siemens NetMonitor...\n"); |
348 | test_no = atoi(argv[2]); | 348 | test_no = atoi(argv[2]); |
349 | error = ATSIEMENS_GetNetmon (&s,test_no+1); | 349 | error = ATSIEMENS_GetNetmon (&s,test_no+1); |
350 | Print_Error(error); | 350 | Print_Error(error); |
351 | GSM_Terminate(); | 351 | GSM_Terminate(); |
352 | } | 352 | } |
353 | 353 | ||
354 | static GSM_Reply_Function UserReplyFunctionsAtS[] = { | 354 | static GSM_Reply_Function UserReplyFunctionsAtS[] = { |
355 | {ATSIEMENS_Reply_GetSAT, "AT^SSTK", 0x00,0x00,ID_User1}, | 355 | {ATSIEMENS_Reply_GetSAT, "AT^SSTK", 0x00,0x00,ID_User1}, |
356 | {ATSIEMENS_Reply_GetNetmon, "AT^S^MI", 0x00,0x00,ID_User2}, | 356 | {ATSIEMENS_Reply_GetNetmon, "AT^S^MI", 0x00,0x00,ID_User2}, |
357 | {NULL, "\x00", 0x00,0x00,ID_None} | 357 | {NULL, "\x00", 0x00,0x00,ID_None} |
358 | }; | 358 | }; |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | /* How should editor hadle tabs in this file? Add editor commands here. | 361 | /* How should editor hadle tabs in this file? Add editor commands here. |
362 | * vim: noexpandtab sw=8 ts=8 sts=8: | 362 | * vim: noexpandtab sw=8 ts=8 sts=8: |
363 | */ | 363 | */ |