FreeCalypso > hg > fc-tourmaline
comparison src/ui/bmi/mmiHomezone.c @ 151:60f8c8e710f4
mmiHomezone.c: bogotab fixes
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 16 Nov 2020 06:57:28 +0000 |
| parents | c0052fe355d3 |
| children |
comparison
equal
deleted
inserted
replaced
| 150:abaee5bdfdc9 | 151:60f8c8e710f4 |
|---|---|
| 1 /******************************************************************************* | 1 /******************************************************************************* |
| 2 | 2 |
| 3 CONDAT (UK) | 3 CONDAT (UK) |
| 4 | 4 |
| 5 ******************************************************************************** | 5 ******************************************************************************** |
| 6 | 6 |
| 7 This software product is the property of Condat (UK) Ltd and may not be | 7 This software product is the property of Condat (UK) Ltd and may not be |
| 8 disclosed to any third party without the express permission of the owner. | 8 disclosed to any third party without the express permission of the owner. |
| 9 | 9 |
| 10 ******************************************************************************** | 10 ******************************************************************************** |
| 11 | 11 |
| 12 $Project name: Basic MMI | 12 $Project name: Basic MMI |
| 13 $Project code: BMI | 13 $Project code: BMI |
| 14 $Module: | 14 $Module: |
| 15 $File: MmiHomezone.c | 15 $File: MmiHomezone.c |
| 16 $Revision: 1.0 | 16 $Revision: 1.0 |
| 17 | 17 |
| 18 $Author: Condat(UK) | 18 $Author: Condat(UK) |
| 19 $Date: 15/02/02 | 19 $Date: 15/02/02 |
| 20 | 20 |
| 21 ******************************************************************************** | 21 ******************************************************************************** |
| 22 | 22 |
| 23 Description: Homezone functionality in MMI | 23 Description: Homezone functionality in MMI |
| 24 | 24 |
| 25 | 25 |
| 26 | |
| 27 ******************************************************************************** | 26 ******************************************************************************** |
| 28 | 27 |
| 29 $History: MmiHomezone.c | 28 $History: MmiHomezone.c |
| 30 | 29 |
| 31 15/02/02 Original Condat(UK) BMI version. | 30 15/02/02 Original Condat(UK) BMI version. |
| 32 28/05/02 Latest Condat(UK) BMI version | 31 28/05/02 Latest Condat(UK) BMI version |
| 33 | 32 |
| 34 Sep 14, 2007 REF: OMAPS00145865 Adrian Salido | 33 Sep 14, 2007 REF: OMAPS00145865 Adrian Salido |
| 35 Description: FT - MMI: Wrong trace class | 34 Description: FT - MMI: Wrong trace class |
| 36 Solution: changed some event traces to function traces because the information content of | 35 Solution: changed some event traces to function traces because the information content of |
| 37 this is low for non-MMI people and against TI coding convention. | 36 this is low for non-MMI people and against TI coding convention. |
| 38 | 37 |
| 39 Mar 14, 2006 DR: OMAPS00061468 - x0035544. | 38 Mar 14, 2006 DR: OMAPS00061468 - x0035544. |
| 40 Description: SAT 27.22.4.22.2 SET UP IDLE MODE TEXT (Icon support) fails | 39 Description: SAT 27.22.4.22.2 SET UP IDLE MODE TEXT (Icon support) fails |
| 41 Solution : In the function homezoneUpdateDisplay(), additional parameter has been added to the | 40 Solution : In the function homezoneUpdateDisplay(), additional parameter has been added to the |
| 42 function call addSatMessage() under the flag FF_MMI_SAT_ICON to support SAT Icon for IDLE TEXT display. | 41 function call addSatMessage() under the flag FF_MMI_SAT_ICON to support SAT Icon for IDLE TEXT display. |
| 43 | 42 |
| 44 Dec 15, 2005 REF: MMI-FIX-OMAPS00058684 x0035544 | 43 Dec 15, 2005 REF: MMI-FIX-OMAPS00058684 x0035544 |
| 45 Description: OMAPS00045726 / MMI-FIX-30439 Follow-Up : ifdef for FF Home Zone forgotten. | 44 Description: OMAPS00045726 / MMI-FIX-30439 Follow-Up : ifdef for FF Home Zone forgotten. |
| 46 Solution: Added Feature flag FF_HOMEZONE for the function sms_homezoneCBToggle(U8 Activate_CB) | 45 Solution: Added Feature flag FF_HOMEZONE for the function sms_homezoneCBToggle(U8 Activate_CB) |
| 47 in this file as it has got the prototype for this function. | 46 in this file as it has got the prototype for this function. |
| 48 | 47 |
| 49 Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 48 Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 50 Description: The homezone/cityzone tags were not being displayed properly. | 49 Description: The homezone/cityzone tags were not being displayed properly. |
| 51 Solution: Modified to save the tags properly in caches and also made the | 50 Solution: Modified to save the tags properly in caches and also made the |
| 52 appropriate modifications to update the same properly during mobility. | 51 appropriate modifications to update the same properly during mobility. |
| 53 | 52 |
| 54 $End | 53 $End |
| 55 | 54 |
| 56 *******************************************************************************/ | 55 *******************************************************************************/ |
| 57 #include <string.h> | 56 #include <string.h> |
| 128 #endif | 127 #endif |
| 129 | 128 |
| 130 | 129 |
| 131 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 130 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 132 // enable HZ trace | 131 // enable HZ trace |
| 133 //#undef TRACE_MMIHOMEZONE | 132 //#undef TRACE_MMIHOMEZONE |
| 134 #define TRACE_MMIHOMEZONE 1 | 133 #define TRACE_MMIHOMEZONE 1 |
| 135 | 134 |
| 136 T_homezone_data homezoneData; | 135 T_homezone_data homezoneData; |
| 137 extern T_SMSCB_DATASTORE g_smscb_data; /* storage for Cell Broadcast lists */ | 136 extern T_SMSCB_DATASTORE g_smscb_data; /* storage for Cell Broadcast lists */ |
| 138 static int hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 137 static int hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 139 | 138 |
| 140 //Dec 14, 2005 REF: MMI-FIX-OMAPS00058684 x0035544 | 139 //Dec 14, 2005 REF: MMI-FIX-OMAPS00058684 x0035544 |
| 141 #ifdef FF_HOMEZONE | 140 #ifdef FF_HOMEZONE |
| 145 #endif | 144 #endif |
| 146 | 145 |
| 147 /* x0039928 - Lint warning fix */ | 146 /* x0039928 - Lint warning fix */ |
| 148 static char *homezoneMNC_MCC[HZ_PERMITTED_NETWORKS] = | 147 static char *homezoneMNC_MCC[HZ_PERMITTED_NETWORKS] = |
| 149 { | 148 { |
| 150 "26207", /* VIAG Interkom */ | 149 "26207", /* VIAG Interkom */ |
| 151 }; | 150 }; |
| 152 | 151 |
| 153 //void sms_homezoneCBToggle(U8 Activate_CB); | 152 //void sms_homezoneCBToggle(U8 Activate_CB); |
| 154 | 153 |
| 155 /******************************************************************************* | 154 /******************************************************************************* |
| 156 | 155 |
| 157 LOCALLY REFERENCED FUNCTIONS | 156 LOCALLY REFERENCED FUNCTIONS |
| 158 | 157 |
| 159 *******************************************************************************/ | 158 *******************************************************************************/ |
| 160 | 159 |
| 161 void homezoneReadParams(); | 160 void homezoneReadParams(); |
| 162 void homezoneLocate(); | 161 void homezoneLocate(); |
| 163 static U32 calculateDecimal( char *string, int length ); | 162 static U32 calculateDecimal( char *string, int length ); |
| 164 static U32 readHexFromSimfile( UBYTE *simFile, int length ); | 163 static U32 readHexFromSimfile( UBYTE *simFile, int length ); |
| 165 static void writeHexToSimfile( UBYTE *simFile, U32 value, int length ); | 164 static void writeHexToSimfile( UBYTE *simFile, U32 value, int length ); |
| 166 | 165 |
| 167 /******************************************************************************* | 166 /******************************************************************************* |
| 168 | 167 |
| 169 $Function: homezoneInit | 168 $Function: homezoneInit |
| 170 | 169 |
| 171 $Description: Initialise homezone data structure. Reset the recent cache. | 170 $Description: Initialise homezone data structure. Reset the recent cache. |
| 172 | 171 |
| 173 $Returns: | 172 $Returns: |
| 174 | 173 |
| 175 $Arguments: | 174 $Arguments: |
| 176 *******************************************************************************/ | 175 *******************************************************************************/ |
| 177 | 176 |
| 178 void homezoneInit() | 177 void homezoneInit() |
| 179 { | 178 { |
| 180 T_homezone_data *data = &homezoneData; | 179 T_homezone_data *data = &homezoneData; |
| 181 USHORT cacheIndex; | 180 USHORT cacheIndex; |
| 182 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 181 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 183 // Added the following local variables. | 182 // Added the following local variables. |
| 184 //begin 30439 | 183 //begin 30439 |
| 185 UBYTE version; | 184 UBYTE version; |
| 186 USHORT max_rcd; | 185 USHORT max_rcd; |
| 187 EF_HZCACHE cache; | 186 EF_HZCACHE cache; |
| 188 //end 30439 | 187 //end 30439 |
| 189 | 188 |
| 190 TRACE_FUNCTION("homezoneInit()"); | 189 TRACE_FUNCTION("homezoneInit()"); |
| 191 | 190 |
| 192 /* Set all data to 0 */ | 191 /* Set all data to 0 */ |
| 193 | 192 |
| 194 memset((UBYTE *)data, 0, sizeof(T_homezone_data)); | 193 memset((UBYTE *)data, 0, sizeof(T_homezone_data)); |
| 195 | 194 |
| 196 data->current_zone = HZ_NOT_IN_ZONE; // 0xFF = not in a homezone | 195 data->current_zone = HZ_NOT_IN_ZONE; // 0xFF = not in a homezone |
| 197 data->recent_cell_index = HZ_RECENT_MAX-1; // Next entry will loop round & be at start of cache | 196 data->recent_cell_index = HZ_RECENT_MAX-1; // Next entry will loop round & be at start of cache |
| 198 | 197 |
| 199 /* Set up recent cell cache */ | 198 /* Set up recent cell cache */ |
| 200 | 199 |
| 201 for (cacheIndex = 0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) | 200 for (cacheIndex = 0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) |
| 202 { | 201 { |
| 203 data->recent_cell[cacheIndex] = 0; | 202 data->recent_cell[cacheIndex] = 0; |
| 204 data->recent_cell_zone[cacheIndex] = HZ_NOT_IN_ZONE; | 203 data->recent_cell_zone[cacheIndex] = HZ_NOT_IN_ZONE; |
| 205 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 204 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 206 //begin 30439 | 205 //begin 30439 |
| 207 /* Read cache from PCM */ | 206 /* Read cache from PCM */ |
| 208 if (pcm_ReadRecord((UBYTE *)EF_HZCACHE_ID, | 207 if (pcm_ReadRecord((UBYTE *)EF_HZCACHE_ID, |
| 209 (USHORT)(cacheIndex+1), | 208 (USHORT)(cacheIndex+1), |
| 210 SIZE_EF_HZCACHE, | 209 SIZE_EF_HZCACHE, |
| 211 (UBYTE *)&cache, | 210 (UBYTE *)&cache, |
| 212 &version, | 211 &version, |
| 213 &max_rcd) NEQ DRV_OK) | 212 &max_rcd) NEQ DRV_OK) |
| 214 { | 213 { |
| 215 TRACE_EVENT ("Init cache read from PCM wrong"); | 214 TRACE_EVENT ("Init cache read from PCM wrong"); |
| 216 break; /* read error */ | 215 break; /* read error */ |
| 217 } | 216 } |
| 218 else | 217 else |
| 219 { | 218 { |
| 220 if (cache.cid[0] != 0xFF AND cache.cid[1] != 0xFF) | 219 if (cache.cid[0] != 0xFF AND cache.cid[1] != 0xFF) |
| 221 { | 220 { |
| 222 data->recent_cell[cacheIndex] = readHexFromSimfile(&cache.cid[0],2); | 221 data->recent_cell[cacheIndex] = readHexFromSimfile(&cache.cid[0],2); |
| 223 data->recent_cell_zone[cacheIndex] = cache.zone; | 222 data->recent_cell_zone[cacheIndex] = cache.zone; |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 TRACE_EVENT_P3("Init cache %d: CID %X, zone %X",cacheIndex, data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); | 225 TRACE_EVENT_P3("Init cache %d: CID %X, zone %X",cacheIndex, data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); |
| 227 //end 30439 | 226 //end 30439 |
| 228 } | 227 } |
| 229 | 228 |
| 230 data->new_cell_res = FALSE; | 229 data->new_cell_res = FALSE; |
| 231 | 230 |
| 232 return; | 231 return; |
| 233 } | 232 } |
| 234 | 233 |
| 235 | 234 |
| 236 /******************************************************************************* | 235 /******************************************************************************* |
| 237 | 236 |
| 238 $Function: homezoneReadSim | 237 $Function: homezoneReadSim |
| 239 | 238 |
| 240 $Description: Read homezone data in from SIM. Checks to see if conditions (SIM, | 239 $Description: Read homezone data in from SIM. Checks to see if conditions (SIM, |
| 241 network) are correct for homezone; switches it off if not. | 240 network) are correct for homezone; switches it off if not. |
| 242 | 241 |
| 243 $Returns: None. | 242 $Returns: None. |
| 244 | 243 |
| 245 $Arguments: read_again - if this is HZ_READ_ONCE_ONLY, then SIM fields will not | 244 $Arguments: read_again - if this is HZ_READ_ONCE_ONLY, then SIM fields will not |
| 246 be read in again if they have already been read in once. | 245 be read in again if they have already been read in once. |
| 247 If this is HZ_READ_SIM_AGAIN, they will be read in anyway. | 246 If this is HZ_READ_SIM_AGAIN, they will be read in anyway. |
| 248 | 247 |
| 249 *******************************************************************************/ | 248 *******************************************************************************/ |
| 250 | 249 |
| 251 void homezoneReadSim(UBYTE read_again) | 250 void homezoneReadSim(UBYTE read_again) |
| 252 { | 251 { |
| 253 T_homezone_data *data = &homezoneData; | 252 T_homezone_data *data = &homezoneData; |
| 254 char IMSI[17]; | 253 char IMSI[17]; |
| 255 char MNC_MCC[6]; | 254 char MNC_MCC[6]; |
| 256 | 255 |
| 257 USHORT networkIndex; | 256 USHORT networkIndex; |
| 258 UBYTE networkOK; | 257 UBYTE networkOK; |
| 259 USHORT tries; | 258 USHORT tries; |
| 260 | 259 |
| 261 /* Check if homezone is switched off */ | 260 /* Check if homezone is switched off */ |
| 262 | 261 |
| 263 if (data->received == HZ_RECEIVED_HZ_OFF) | 262 if (data->received == HZ_RECEIVED_HZ_OFF) |
| 264 return; | 263 return; |
| 265 | 264 |
| 266 /* SPR877 - If read_again specifies that SIM data should not be re-read, exit from function | 265 /* SPR877 - If read_again specifies that SIM data should not be re-read, exit from function |
| 267 * provided we have read it once. */ | 266 * provided we have read it once. */ |
| 268 | 267 |
| 269 if (read_again == HZ_READ_ONCE_ONLY && data->received & HZ_RECEIVED_SIMDATA) | 268 if (read_again == HZ_READ_ONCE_ONLY && data->received & HZ_RECEIVED_SIMDATA) |
| 270 return; | 269 return; |
| 271 | 270 |
| 272 TRACE_FUNCTION("homezoneReadSim()"); | 271 TRACE_FUNCTION("homezoneReadSim()"); |
| 273 | 272 |
| 274 /* Check if network operator is in list */ | 273 /* Check if network operator is in list */ |
| 275 | 274 |
| 276 networkOK = FALSE; | 275 networkOK = FALSE; |
| 277 | 276 |
| 278 tries = 0; | 277 tries = 0; |
| 279 | 278 |
| 280 while ((qAT_PlusCIMI(CMD_SRC_LCL, IMSI)) != AT_CMPL && tries < 5) | 279 while ((qAT_PlusCIMI(CMD_SRC_LCL, IMSI)) != AT_CMPL && tries < 5) |
| 281 { | 280 { |
| 282 tries++; | 281 tries++; |
| 283 } | 282 } |
| 284 | 283 |
| 285 strncpy(MNC_MCC, IMSI, 5); | 284 strncpy(MNC_MCC, IMSI, 5); |
| 286 MNC_MCC[5] =0; //terminate string | 285 MNC_MCC[5] =0; //terminate string |
| 287 | 286 |
| 288 #ifdef TRACE_MMIHOMEZONE | 287 #ifdef TRACE_MMIHOMEZONE |
| 289 TRACE_EVENT_P1("MNC_MCC: %s", (char *)MNC_MCC); | 288 TRACE_EVENT_P1("MNC_MCC: %s", (char *)MNC_MCC); |
| 290 #endif | 289 #endif |
| 291 | 290 |
| 292 for (networkIndex=0; networkIndex<HZ_PERMITTED_NETWORKS; networkIndex++) | 291 for (networkIndex=0; networkIndex<HZ_PERMITTED_NETWORKS; networkIndex++) |
| 293 { | 292 { |
| 294 if (!strncmp((char *)MNC_MCC, homezoneMNC_MCC[networkIndex],5)) | 293 if (!strncmp((char *)MNC_MCC, homezoneMNC_MCC[networkIndex],5)) |
| 295 { | 294 { |
| 296 #ifdef TRACE_MMIHOMEZONE | 295 #ifdef TRACE_MMIHOMEZONE |
| 297 TRACE_EVENT_P1("Matches entry %d", networkIndex); | 296 TRACE_EVENT_P1("Matches entry %d", networkIndex); |
| 298 #endif | 297 #endif |
| 299 networkOK = TRUE; | 298 networkOK = TRUE; |
| 300 } | 299 } |
| 301 } | 300 } |
| 302 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 301 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 303 //begin 30439 | 302 //begin 30439 |
| 304 /* Attempt to read first sim field */ | 303 /* Attempt to read first sim field */ |
| 305 if (read_again == HZ_READ_SIM_AGAIN) | 304 if (read_again == HZ_READ_SIM_AGAIN) |
| 306 hzFlag = 1; | 305 hzFlag = 1; |
| 307 //end 30439 | 306 //end 30439 |
| 308 | 307 |
| 309 if (networkOK) | 308 if (networkOK) |
| 310 { | 309 { |
| 311 if (!Read_Sim(HZ_SIM_PARAMETERS, 0, HZ_SIM_PARAMETERS_SIZE, data->buffer)) | 310 if (!Read_Sim(HZ_SIM_PARAMETERS, 0, HZ_SIM_PARAMETERS_SIZE, data->buffer)) |
| 312 { | 311 { |
| 313 TRACE_EVENT("SIM read error 1: Homezone OFF"); /* SIM field not present, switch off homezone */ | 312 TRACE_EVENT("SIM read error 1: Homezone OFF"); /* SIM field not present, switch off homezone */ |
| 314 data->received = HZ_RECEIVED_HZ_OFF; | 313 data->received = HZ_RECEIVED_HZ_OFF; |
| 315 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 - Seting the variable | 314 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 - Seting the variable |
| 316 } | 315 } |
| 317 } | 316 } |
| 318 else | 317 else |
| 319 { | 318 { |
| 320 TRACE_EVENT("Wrong network: Homezone OFF"); /* Network not in list, switch off homezone */ | 319 TRACE_EVENT("Wrong network: Homezone OFF"); /* Network not in list, switch off homezone */ |
| 321 data->received = HZ_RECEIVED_HZ_OFF; | 320 data->received = HZ_RECEIVED_HZ_OFF; |
| 322 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 - Seting the variable | 321 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 - Seting the variable |
| 323 } | 322 } |
| 324 | 323 |
| 325 return; | 324 return; |
| 326 } | 325 } |
| 327 | 326 |
| 328 | 327 |
| 329 /******************************************************************************* | 328 /******************************************************************************* |
| 330 | 329 |
| 331 $Function: homezoneReadSimCb | 330 $Function: homezoneReadSimCb |
| 332 | 331 |
| 333 $Description: Callback, called when read sim has occurred. Fills up the homezone | 332 $Description: Callback, called when read sim has occurred. Fills up the homezone |
| 334 data structure with the appropriate values retrieved from SIM. | 333 data structure with the appropriate values retrieved from SIM. |
| 335 | 334 |
| 336 $Returns: None. | 335 $Returns: None. |
| 337 | 336 |
| 338 $Arguments: field - the SIM field that was just read | 337 $Arguments: field - the SIM field that was just read |
| 339 record - the record in the SIM field that was read | 338 record - the record in the SIM field that was read |
| 340 result - the result code returned - 0 for successful. | 339 result - the result code returned - 0 for successful. |
| 341 *******************************************************************************/ | 340 *******************************************************************************/ |
| 342 | 341 |
| 343 void homezoneReadSimCb(USHORT field, USHORT record, USHORT result) | 342 void homezoneReadSimCb(USHORT field, USHORT record, USHORT result) |
| 344 { | 343 { |
| 345 T_homezone_data *data = &homezoneData; | 344 T_homezone_data *data = &homezoneData; |
| 346 T_homezone *homezone = data->homezone; | 345 T_homezone *homezone = data->homezone; |
| 347 UBYTE *simFile; | 346 UBYTE *simFile; |
| 348 USHORT fileIndex; | 347 USHORT fileIndex; |
| 349 USHORT hzIndex; | 348 USHORT hzIndex; |
| 350 UBYTE keepLooking; | 349 UBYTE keepLooking; |
| 351 U8 Activate_cb =0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 350 U8 Activate_cb =0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 352 //To activate/deactivate homezoneCB | 351 //To activate/deactivate homezoneCB |
| 353 TRACE_FUNCTION("homezoneReadSimCb()"); | 352 TRACE_FUNCTION("homezoneReadSimCb()"); |
| 354 | 353 |
| 355 #ifdef TRACE_MMIHOMEZONE | 354 #ifdef TRACE_MMIHOMEZONE |
| 356 TRACE_EVENT_P2("Have just read SIM file: %x record %d", field, record); | 355 TRACE_EVENT_P2("Have just read SIM file: %x record %d", field, record); |
| 357 #endif | 356 #endif |
| 358 | 357 |
| 359 /* Read in general homezone data. If reading first SIM field fails, switch homezone off */ | 358 /* Read in general homezone data. If reading first SIM field fails, switch homezone off */ |
| 360 | 359 |
| 361 if (field==HZ_SIM_PARAMETERS) | 360 if (field==HZ_SIM_PARAMETERS) |
| 362 { | 361 { |
| 363 /* check SIM read result for homezone parameter */ | 362 /* check SIM read result for homezone parameter */ |
| 364 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 363 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 365 //begin 30439 | 364 //begin 30439 |
| 366 //Modified the conditional statement | 365 //Modified the conditional statement |
| 367 //if (result) | 366 //if (result) |
| 368 if (result != 0x80FF) | 367 if (result != 0x80FF) |
| 369 //end 30439 | 368 //end 30439 |
| 370 { | 369 { |
| 371 TRACE_EVENT("SIM read error 2: Homezone OFF"); | 370 TRACE_EVENT("SIM read error 2: Homezone OFF"); |
| 372 data->received = HZ_RECEIVED_HZ_OFF; | 371 data->received = HZ_RECEIVED_HZ_OFF; |
| 373 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 -Setting the variable | 372 hzFlag = 0; //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 -Setting the variable |
| 374 return; | 373 return; |
| 375 } | 374 } |
| 376 homezoneReadParams(); | 375 homezoneReadParams(); |
| 377 /*homezoneActivateCB();*/ /* Switch on cell broadcast */ | 376 /*homezoneActivateCB();*/ /* Switch on cell broadcast */ |
| 378 /* SH - this is already done at startup */ | 377 /* SH - this is already done at startup */ |
| 379 record = HZ_CACHE_MAX; | 378 record = HZ_CACHE_MAX; |
| 380 } | 379 } |
| 381 | 380 |
| 382 /* Read in records for each homezone cache */ | 381 /* Read in records for each homezone cache */ |
| 383 | 382 |
| 384 /* check SIM read result for hoemzone cache */ | 383 /* check SIM read result for hoemzone cache */ |
| 385 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 384 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 386 //begin 30439 | 385 //begin 30439 |
| 387 //Modified the conditional statement | 386 //Modified the conditional statement |
| 388 //if (field>HZ_SIM_PARAMETERS && !result) | 387 //if (field>HZ_SIM_PARAMETERS && !result) |
| 389 if (field>HZ_SIM_PARAMETERS && (result == 0x80FF)) | 388 if (field>HZ_SIM_PARAMETERS && (result == 0x80FF)) |
| 390 //end 30439 | 389 //end 30439 |
| 391 { | 390 { |
| 392 hzIndex = field - HZ_SIM_CELL_CACHE; | 391 hzIndex = field - HZ_SIM_CELL_CACHE; |
| 393 simFile = data->buffer2; | 392 simFile = data->buffer2; |
| 394 fileIndex = 0; | 393 fileIndex = 0; |
| 395 | 394 |
| 396 homezone[hzIndex].lac[record-1] = readHexFromSimfile(&simFile[fileIndex],2); | 395 homezone[hzIndex].lac[record-1] = readHexFromSimfile(&simFile[fileIndex],2); |
| 397 fileIndex+=2; | 396 fileIndex+=2; |
| 398 homezone[hzIndex].cid[record-1] = readHexFromSimfile(&simFile[fileIndex],2); | 397 homezone[hzIndex].cid[record-1] = readHexFromSimfile(&simFile[fileIndex],2); |
| 399 | 398 |
| 400 #ifdef TRACE_MMIHOMEZONE | 399 #ifdef TRACE_MMIHOMEZONE |
| 401 TRACE_EVENT_P2("read lac = %x, cid = %x", homezone[hzIndex].lac[record-1], homezone[hzIndex].cid[record-1]); | 400 TRACE_EVENT_P2("read lac = %x, cid = %x", homezone[hzIndex].lac[record-1], homezone[hzIndex].cid[record-1]); |
| 402 #endif | 401 #endif |
| 403 } | 402 } |
| 404 | 403 |
| 405 /* Read in the next record */ | 404 /* Read in the next record */ |
| 406 | 405 |
| 407 keepLooking = TRUE; | 406 keepLooking = TRUE; |
| 408 | 407 |
| 409 while (keepLooking) | 408 while (keepLooking) |
| 410 { | 409 { |
| 411 /* check SIM read result for hoemzone cache */ | 410 /* check SIM read result for hoemzone cache */ |
| 412 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 411 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 413 //begin 30439 | 412 //begin 30439 |
| 414 //Modified the conditional statement | 413 //Modified the conditional statement |
| 415 //if (record==HZ_CACHE_MAX || result) | 414 //if (record==HZ_CACHE_MAX || result) |
| 416 if (record==HZ_CACHE_MAX || (result != 0x80FF)) | 415 if (record==HZ_CACHE_MAX || (result != 0x80FF)) |
| 417 //end 30439 | 416 //end 30439 |
| 418 { | 417 { |
| 419 field++; // Look at next field | 418 field++; // Look at next field |
| 420 record = 1; | 419 record = 1; |
| 421 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 420 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 422 // Print the current feild. | 421 // Print the current feild. |
| 423 TRACE_EVENT_P1("current field = %x", field); | 422 TRACE_EVENT_P1("current field = %x", field); |
| 424 } | 423 } |
| 425 else | 424 else |
| 426 record++; | 425 record++; |
| 427 | 426 |
| 428 hzIndex = field-HZ_SIM_CELL_CACHE; | 427 hzIndex = field-HZ_SIM_CELL_CACHE; |
| 429 | 428 |
| 430 if (hzIndex==HZ_ZONES_MAX) | 429 if (hzIndex==HZ_ZONES_MAX) |
| 431 { | 430 { |
| 432 keepLooking = FALSE; | 431 keepLooking = FALSE; |
| 433 /* Have read all sim data, set flag so icon etc will be updated */ | 432 /* Have read all sim data, set flag so icon etc will be updated */ |
| 434 data->received |= HZ_RECEIVED_SIMDATA; | 433 data->received |= HZ_RECEIVED_SIMDATA; |
| 435 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 434 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 436 //begin 30439 | 435 //begin 30439 |
| 437 /* homezone display update after SIM REFRESH (when hzFlag set to 1) */ | 436 /* homezone display update after SIM REFRESH (when hzFlag set to 1) */ |
| 438 TRACE_EVENT_P1("hzFlag = %d", hzFlag); | 437 TRACE_EVENT_P1("hzFlag = %d", hzFlag); |
| 439 if (hzFlag) | 438 if (hzFlag) |
| 440 { | 439 { |
| 441 // hzFlag = 0; | 440 // hzFlag = 0; |
| 442 homezoneUpdate(0, 0, 1); | 441 homezoneUpdate(0, 0, 1); |
| 443 } | 442 } |
| 444 else | 443 else |
| 445 { | 444 { |
| 446 | 445 |
| 447 TRACE_EVENT("activate homezone CB"); | 446 TRACE_EVENT("activate homezone CB"); |
| 448 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 447 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 449 //Call to activate the Homezone CB. | 448 //Call to activate the Homezone CB. |
| 450 Activate_cb = 1; | 449 Activate_cb = 1; |
| 451 | 450 |
| 452 #ifdef FF_HOMEZONE | 451 #ifdef FF_HOMEZONE |
| 453 sms_homezoneCBToggle(Activate_cb); | 452 sms_homezoneCBToggle(Activate_cb); |
| 454 #endif | 453 #endif |
| 455 homezoneUpdate(0, 0, 1); /* new VO : speed up update */ | 454 homezoneUpdate(0, 0, 1); /* new VO : speed up update */ |
| 456 } | 455 } |
| 457 //end 30439 | 456 //end 30439 |
| 458 | 457 |
| 459 } | 458 } |
| 460 else if (homezone[hzIndex].active) | 459 else if (homezone[hzIndex].active) |
| 461 { | 460 { |
| 462 keepLooking = FALSE; | 461 keepLooking = FALSE; |
| 463 | 462 |
| 464 #ifdef TRACE_MMIHOMEZONE | 463 #ifdef TRACE_MMIHOMEZONE |
| 465 //TRACE_EVENT_P3("HZ READ HZ %d field %X record %d", hzIndex, field, record); | 464 //TRACE_EVENT_P3("HZ READ HZ %d field %X record %d", hzIndex, field, record); |
| 466 #endif | 465 #endif |
| 467 if (!Read_Sim_Record(field, record, HZ_SIM_CELL_CACHE_SIZE, data->buffer2)) | 466 if (!Read_Sim_Record(field, record, HZ_SIM_CELL_CACHE_SIZE, data->buffer2)) |
| 468 { | 467 { |
| 469 TRACE_EVENT("SIM reading error!"); | 468 TRACE_EVENT("SIM reading error!"); |
| 470 } | 469 } |
| 471 } | 470 } |
| 472 } | 471 } |
| 473 | 472 |
| 474 return; | 473 return; |
| 475 } | 474 } |
| 476 | 475 |
| 477 | 476 |
| 478 /******************************************************************************* | 477 /******************************************************************************* |
| 479 | 478 |
| 480 $Function: homezoneReadParams | 479 $Function: homezoneReadParams |
| 481 | 480 |
| 482 $Description: Decode the homezone parameters from the first SIM field | 481 $Description: Decode the homezone parameters from the first SIM field |
| 483 | 482 |
| 484 $Returns: None. | 483 $Returns: None. |
| 485 | 484 |
| 486 $Arguments: None. | 485 $Arguments: None. |
| 487 *******************************************************************************/ | 486 *******************************************************************************/ |
| 488 | 487 |
| 489 void homezoneReadParams() | 488 void homezoneReadParams() |
| 490 { | 489 { |
| 491 T_homezone_data *data = &homezoneData; | 490 T_homezone_data *data = &homezoneData; |
| 492 T_homezone *homezone = data->homezone; | 491 T_homezone *homezone = data->homezone; |
| 493 UBYTE *simFile; | 492 UBYTE *simFile; |
| 494 USHORT fileIndex; | 493 USHORT fileIndex; |
| 495 USHORT tagIndex; | 494 USHORT tagIndex; |
| 496 USHORT hzIndex; | 495 USHORT hzIndex; |
| 497 char character; | 496 char character; |
| 498 | 497 |
| 499 TRACE_FUNCTION("homezoneReadParams()"); | 498 TRACE_FUNCTION("homezoneReadParams()"); |
| 500 | 499 |
| 501 simFile = data->buffer; | 500 simFile = data->buffer; |
| 502 fileIndex = HZ_SIM_FIRST_ZONE; // Point to the first homezone data | 501 fileIndex = HZ_SIM_FIRST_ZONE; // Point to the first homezone data |
| 503 | 502 |
| 504 for (hzIndex=0; hzIndex<HZ_ZONES_MAX; hzIndex++) // For each homezone... | 503 for (hzIndex=0; hzIndex<HZ_ZONES_MAX; hzIndex++) // For each homezone... |
| 505 { | 504 { |
| 506 homezone[hzIndex].zoneID = simFile[fileIndex]; // Read in the various parameters | 505 homezone[hzIndex].zoneID = simFile[fileIndex]; // Read in the various parameters |
| 507 fileIndex++; | 506 fileIndex++; |
| 508 | 507 |
| 509 homezone[hzIndex].X = readHexFromSimfile(&simFile[fileIndex],4); | 508 homezone[hzIndex].X = readHexFromSimfile(&simFile[fileIndex],4); |
| 510 fileIndex += 4; | 509 fileIndex += 4; |
| 511 homezone[hzIndex].Y = readHexFromSimfile(&simFile[fileIndex],4); | 510 homezone[hzIndex].Y = readHexFromSimfile(&simFile[fileIndex],4); |
| 512 fileIndex += 4; | 511 fileIndex += 4; |
| 513 homezone[hzIndex].Rsquared = readHexFromSimfile(&simFile[fileIndex],4); | 512 homezone[hzIndex].Rsquared = readHexFromSimfile(&simFile[fileIndex],4); |
| 514 fileIndex += 4; | 513 fileIndex += 4; |
| 515 | 514 |
| 516 homezone[hzIndex].active = (BOOL) (simFile[fileIndex] & HZ_ACTIVE_FLAG)/HZ_ACTIVE_FLAG; | 515 homezone[hzIndex].active = (BOOL) (simFile[fileIndex] & HZ_ACTIVE_FLAG)/HZ_ACTIVE_FLAG; |
| 517 homezone[hzIndex].cityzone = (BOOL) (simFile[fileIndex] & HZ_CITYZONE_FLAG)/HZ_CITYZONE_FLAG; | 516 homezone[hzIndex].cityzone = (BOOL) (simFile[fileIndex] & HZ_CITYZONE_FLAG)/HZ_CITYZONE_FLAG; |
| 518 fileIndex++; | 517 fileIndex++; |
| 519 | 518 |
| 520 /* Read in the 12-character tag name */ | 519 /* Read in the 12-character tag name */ |
| 521 | 520 |
| 522 for (tagIndex = 0; tagIndex<HZ_NAME_LENGTH; tagIndex++) | 521 for (tagIndex = 0; tagIndex<HZ_NAME_LENGTH; tagIndex++) |
| 523 { | 522 { |
| 524 character = (char) simFile[fileIndex]; | 523 character = (char) simFile[fileIndex]; |
| 525 fileIndex++; | 524 fileIndex++; |
| 526 if (character<32 /*|| character>127*/) /*a0393213 - lint warnings removal - 'Relational operator '>' always evaluates to 'false'*/ | 525 if (character<32 /*|| character>127*/) /*a0393213 - lint warnings removal - 'Relational operator '>' always evaluates to 'false'*/ |
| 527 character = 0; | 526 character = 0; |
| 528 homezone[hzIndex].Tag[tagIndex] = character; | 527 homezone[hzIndex].Tag[tagIndex] = character; |
| 529 } | 528 } |
| 530 homezone[hzIndex].Tag[HZ_NAME_LENGTH] = 0; // Make sure tag is null-terminated | 529 homezone[hzIndex].Tag[HZ_NAME_LENGTH] = 0; // Make sure tag is null-terminated |
| 531 | 530 |
| 532 #ifdef TRACE_MMIHOMEZONE | 531 #ifdef TRACE_MMIHOMEZONE |
| 533 TRACE_EVENT_P1("Homezone %d:", hzIndex); | 532 TRACE_EVENT_P1("Homezone %d:", hzIndex); |
| 534 TRACE_EVENT_P1("ID: %d", homezone[hzIndex].zoneID); | 533 TRACE_EVENT_P1("ID: %d", homezone[hzIndex].zoneID); |
| 535 TRACE_EVENT_P1("Active: %d", (UBYTE)homezone[hzIndex].active); | 534 TRACE_EVENT_P1("Active: %d", (UBYTE)homezone[hzIndex].active); |
| 536 TRACE_EVENT_P1("Cityzone: %d", (UBYTE)homezone[hzIndex].cityzone); | 535 TRACE_EVENT_P1("Cityzone: %d", (UBYTE)homezone[hzIndex].cityzone); |
| 537 TRACE_EVENT_P1("X: %X", homezone[hzIndex].X); | 536 TRACE_EVENT_P1("X: %X", homezone[hzIndex].X); |
| 538 TRACE_EVENT_P1("Y: %X", homezone[hzIndex].Y); | 537 TRACE_EVENT_P1("Y: %X", homezone[hzIndex].Y); |
| 539 TRACE_EVENT_P1("Rsquared: %X", homezone[hzIndex].Rsquared); | 538 TRACE_EVENT_P1("Rsquared: %X", homezone[hzIndex].Rsquared); |
| 540 TRACE_EVENT_P1("Homezone name: %s", homezone[hzIndex].Tag); | 539 TRACE_EVENT_P1("Homezone name: %s", homezone[hzIndex].Tag); |
| 541 #endif | 540 #endif |
| 542 | 541 |
| 543 } | 542 } |
| 544 | 543 |
| 545 return; | 544 return; |
| 546 } | 545 } |
| 547 | 546 |
| 548 | 547 |
| 549 /******************************************************************************* | 548 /******************************************************************************* |
| 550 | 549 |
| 551 $Function: homezoneWriteSim | 550 $Function: homezoneWriteSim |
| 552 | 551 |
| 553 $Description: Write homezone data to the SIM | 552 $Description: Write homezone data to the SIM |
| 554 SPR 877 - SH - now just writes a single record | 553 SPR 877 - SH - now just writes a single record |
| 555 | 554 |
| 556 $Returns: None. | 555 $Returns: None. |
| 557 | 556 |
| 558 $Arguments: cache, record | 557 $Arguments: cache, record |
| 559 ********************************************************************************/ | 558 ********************************************************************************/ |
| 560 | 559 |
| 561 void homezoneWriteSim(USHORT field, USHORT record) | 560 void homezoneWriteSim(USHORT field, USHORT record) |
| 562 { | 561 { |
| 563 T_homezone_data *data = &homezoneData; | 562 T_homezone_data *data = &homezoneData; |
| 564 USHORT hzIndex; | 563 USHORT hzIndex; |
| 565 UBYTE *simFile; | 564 UBYTE *simFile; |
| 566 USHORT fileIndex; | 565 USHORT fileIndex; |
| 567 | 566 |
| 568 /* Check if homezone is already switched off */ | 567 /* Check if homezone is already switched off */ |
| 569 | 568 |
| 570 if (data->received==HZ_RECEIVED_HZ_OFF) | 569 if (data->received==HZ_RECEIVED_HZ_OFF) |
| 571 return; | 570 return; |
| 572 | 571 |
| 573 TRACE_FUNCTION("homezoneWriteSim()"); | 572 TRACE_FUNCTION("homezoneWriteSim()"); |
| 574 | 573 |
| 575 hzIndex = field-HZ_SIM_CELL_CACHE; | 574 hzIndex = field-HZ_SIM_CELL_CACHE; |
| 576 | 575 |
| 577 #ifdef TRACE_MMIHOMEZONE | 576 #ifdef TRACE_MMIHOMEZONE |
| 578 TRACE_EVENT_P4("HZ WRITE field: %X record %d lac %X cid %X", field, record, data->homezone[hzIndex].lac[record-1], data->homezone[hzIndex].cid[record-1]); | 577 TRACE_EVENT_P4("HZ WRITE field: %X record %d lac %X cid %X", field, record, data->homezone[hzIndex].lac[record-1], data->homezone[hzIndex].cid[record-1]); |
| 579 #endif | 578 #endif |
| 580 | 579 |
| 581 if (data->homezone[hzIndex].active) | 580 if (data->homezone[hzIndex].active) |
| 582 { | 581 { |
| 583 simFile = data->buffer2; | 582 simFile = data->buffer2; |
| 584 fileIndex = 0; | 583 fileIndex = 0; |
| 585 writeHexToSimfile(&simFile[fileIndex], data->homezone[hzIndex].lac[record-1], 2 ); | 584 writeHexToSimfile(&simFile[fileIndex], data->homezone[hzIndex].lac[record-1], 2 ); |
| 586 fileIndex += 2; | 585 fileIndex += 2; |
| 587 writeHexToSimfile(&simFile[fileIndex], data->homezone[hzIndex].cid[record-1], 2 ); | 586 writeHexToSimfile(&simFile[fileIndex], data->homezone[hzIndex].cid[record-1], 2 ); |
| 588 } | 587 } |
| 589 | 588 |
| 590 if (!Write_Sim_Record(field, record, HZ_SIM_CELL_CACHE_SIZE, data->buffer2)) | 589 if (!Write_Sim_Record(field, record, HZ_SIM_CELL_CACHE_SIZE, data->buffer2)) |
| 591 { | 590 { |
| 592 TRACE_EVENT("SIM writing error!"); | 591 TRACE_EVENT("SIM writing error!"); |
| 593 } | 592 } |
| 594 return; | 593 return; |
| 595 } | 594 } |
| 596 | 595 |
| 597 | 596 |
| 598 /******************************************************************************* | 597 /******************************************************************************* |
| 599 | 598 |
| 600 $Function: homezoneWriteSimCb | 599 $Function: homezoneWriteSimCb |
| 601 | 600 |
| 602 $Description: Write homezone data to the SIM. This function is called after a previous | 601 $Description: Write homezone data to the SIM. This function is called after a previous |
| 603 SIM write (or, in the initial case, by homezoneWriteSim above). | 602 SIM write (or, in the initial case, by homezoneWriteSim above). |
| 604 SPR877 - SH - Previous functionality no longer required here. | 603 SPR877 - SH - Previous functionality no longer required here. |
| 605 | 604 |
| 606 $Returns: None. | 605 $Returns: None. |
| 607 | 606 |
| 608 $Arguments: field - the SIM field that is to be written | 607 $Arguments: field - the SIM field that is to be written |
| 609 record - the SIM record that is to be written | 608 record - the SIM record that is to be written |
| 610 result - the result of the last write attempt | 609 result - the result of the last write attempt |
| 611 *******************************************************************************/ | 610 *******************************************************************************/ |
| 612 | 611 |
| 613 void homezoneWriteSimCb(USHORT field, USHORT record, USHORT result) | 612 void homezoneWriteSimCb(USHORT field, USHORT record, USHORT result) |
| 614 { | 613 { |
| 615 TRACE_FUNCTION("homezoneWriteSimCb()"); | 614 TRACE_FUNCTION("homezoneWriteSimCb()"); |
| 616 | 615 |
| 617 #ifdef TRACE_MMIHOMEZONE | 616 #ifdef TRACE_MMIHOMEZONE |
| 618 TRACE_EVENT_P1("RESULT: %d", result); | 617 TRACE_EVENT_P1("RESULT: %d", result); |
| 619 #endif | 618 #endif |
| 620 | 619 |
| 621 return; | 620 return; |
| 622 } | 621 } |
| 623 | 622 |
| 624 | 623 |
| 625 /******************************************************************************* | 624 /******************************************************************************* |
| 626 | 625 |
| 627 $Function: homezoneCBData | 626 $Function: homezoneCBData |
| 628 | 627 |
| 629 $Description: Make sure correct homezone CB channel is set up and activate CB | 628 $Description: Make sure correct homezone CB channel is set up and activate CB |
| 630 | 629 |
| 631 $Returns: None. | 630 $Returns: None. |
| 632 | 631 |
| 633 $Arguments: message - The text of the cell broadcast message | 632 $Arguments: message - The text of the cell broadcast message |
| 634 *******************************************************************************/ | 633 *******************************************************************************/ |
| 635 | 634 |
| 636 void homezoneActivateCB(void) | 635 void homezoneActivateCB(void) |
| 637 { | 636 { |
| 638 T_homezone_data *data = &homezoneData; | 637 T_homezone_data *data = &homezoneData; |
| 639 USHORT index; | 638 USHORT index; |
| 640 UBYTE stopSearch; | 639 UBYTE stopSearch; |
| 641 USHORT emptyID; | 640 USHORT emptyID; |
| 642 | 641 |
| 643 /* Check if homezone is already switched off */ | 642 /* Check if homezone is already switched off */ |
| 644 | 643 |
| 645 if (data->received==HZ_RECEIVED_HZ_OFF) | 644 if (data->received==HZ_RECEIVED_HZ_OFF) |
| 646 return; | 645 return; |
| 647 | 646 |
| 648 TRACE_FUNCTION("homezoneActivateCB()"); | 647 TRACE_FUNCTION("homezoneActivateCB()"); |
| 649 | 648 |
| 650 /* Check table to see if correct channel is included */ | 649 /* Check table to see if correct channel is included */ |
| 651 | 650 |
| 652 stopSearch = FALSE; | 651 stopSearch = FALSE; |
| 653 emptyID = 0xFFFF; | 652 emptyID = 0xFFFF; |
| 654 | 653 |
| 655 for (index=0; index<MAX_MIDS && !stopSearch; index++) | 654 for (index=0; index<MAX_MIDS && !stopSearch; index++) |
| 656 { | 655 { |
| 657 TRACE_EVENT_P2("Mid %d is %X", index, g_smscb_data.CBTopics.entry[index].msg_id); | 656 TRACE_EVENT_P2("Mid %d is %X", index, g_smscb_data.CBTopics.entry[index].msg_id); |
| 658 if (g_smscb_data.CBTopics.entry[index].msg_id==HZ_IDENTIFIER) | 657 if (g_smscb_data.CBTopics.entry[index].msg_id==HZ_IDENTIFIER) |
| 659 { | 658 { |
| 660 stopSearch = TRUE; | 659 stopSearch = TRUE; |
| 661 } | 660 } |
| 662 else if (g_smscb_data.CBTopics.entry[index].msg_id==NO_MID) | 661 else if (g_smscb_data.CBTopics.entry[index].msg_id==NO_MID) |
| 663 { | 662 { |
| 664 emptyID = index; | 663 emptyID = index; |
| 665 stopSearch = TRUE; | 664 stopSearch = TRUE; |
| 666 } | 665 } |
| 667 } | 666 } |
| 668 | 667 |
| 669 TRACE_EVENT_P1("Emtpy ID %d", emptyID); | 668 TRACE_EVENT_P1("Emtpy ID %d", emptyID); |
| 670 | 669 |
| 671 if (emptyID!=0xFFFF && emptyID<MAX_MIDS-1) | 670 if (emptyID!=0xFFFF && emptyID<MAX_MIDS-1) |
| 672 { | 671 { |
| 673 strncpy (g_smscb_data.CBTopics.entry[emptyID].name, HZ_CB_NAME, CB_TAG_LENGTH); | 672 strncpy (g_smscb_data.CBTopics.entry[emptyID].name, HZ_CB_NAME, CB_TAG_LENGTH); |
| 674 g_smscb_data.CBTopics.entry[emptyID].msg_id = HZ_IDENTIFIER; | 673 g_smscb_data.CBTopics.entry[emptyID].msg_id = HZ_IDENTIFIER; |
| 675 g_smscb_data.CBTopics.entry[emptyID].dcs = 0; | 674 g_smscb_data.CBTopics.entry[emptyID].dcs = 0; |
| 676 | 675 |
| 677 // add a new entry | 676 // add a new entry |
| 678 emptyID += 1; | 677 emptyID += 1; |
| 679 g_smscb_data.CBTopics.length = emptyID; | 678 g_smscb_data.CBTopics.length = emptyID; |
| 680 } | 679 } |
| 681 | 680 |
| 682 smscb_setCBsettings(SMSCB_SWITCH_ON); | 681 smscb_setCBsettings(SMSCB_SWITCH_ON); |
| 683 return; | 682 return; |
| 684 } | 683 } |
| 685 | 684 |
| 686 | 685 |
| 687 /******************************************************************************* | 686 /******************************************************************************* |
| 688 | 687 |
| 689 $Function: homezoneCBData | 688 $Function: homezoneCBData |
| 690 | 689 |
| 691 $Description: A cell broadcast message has been received, containing information about | 690 $Description: A cell broadcast message has been received, containing information about |
| 692 the location of the current cell | 691 the location of the current cell |
| 693 | 692 |
| 694 $Returns: None. | 693 $Returns: None. |
| 695 | 694 |
| 696 $Arguments: message - The text of the cell broadcast message | 695 $Arguments: message - The text of the cell broadcast message |
| 697 *******************************************************************************/ | 696 *******************************************************************************/ |
| 698 | 697 |
| 699 void homezoneCBData(char *message) | 698 void homezoneCBData(char *message) |
| 700 { | 699 { |
| 701 T_homezone_data *data = &homezoneData; | 700 T_homezone_data *data = &homezoneData; |
| 702 | 701 |
| 703 /* Check if homezone is already switched off */ | 702 /* Check if homezone is already switched off */ |
| 704 | 703 |
| 705 if (data->received==HZ_RECEIVED_HZ_OFF) | 704 if (data->received==HZ_RECEIVED_HZ_OFF) |
| 706 return; | 705 return; |
| 707 | 706 |
| 708 TRACE_FUNCTION("homezoneCellData()"); | 707 TRACE_FUNCTION("homezoneCellData()"); |
| 709 | 708 |
| 710 /* Calculate the current position from the text of the message */ | 709 /* Calculate the current position from the text of the message */ |
| 711 | 710 |
| 712 data->current_X = calculateDecimal( &message[0], HZ_COORD_DIGITS ); | 711 data->current_X = calculateDecimal( &message[0], HZ_COORD_DIGITS ); |
| 713 data->current_Y = calculateDecimal( &message[HZ_COORD_DIGITS], HZ_COORD_DIGITS ); | 712 data->current_Y = calculateDecimal( &message[HZ_COORD_DIGITS], HZ_COORD_DIGITS ); |
| 714 | 713 |
| 715 #ifdef TRACE_MMIHOMEZONE | 714 #ifdef TRACE_MMIHOMEZONE |
| 716 TRACE_EVENT_P2("current_X: %X, current_Y: %X", data->current_X, data->current_Y); | 715 TRACE_EVENT_P2("current_X: %X, current_Y: %X", data->current_X, data->current_Y); |
| 717 #endif | 716 #endif |
| 718 | 717 |
| 719 data->received |= HZ_RECEIVED_CB; // We now have received cell broadcast message. | 718 data->received |= HZ_RECEIVED_CB; // We now have received cell broadcast message. |
| 720 | 719 |
| 721 /* SPR877 - SH - now only call HZ algorithm if a cell res has recently taken place */ | 720 /* SPR877 - SH - now only call HZ algorithm if a cell res has recently taken place */ |
| 722 | 721 |
| 723 if (data->received==HZ_RECEIVED_ALL && data->new_cell_res) // If we've received everything, call algorithm. | 722 if (data->received==HZ_RECEIVED_ALL && data->new_cell_res) // If we've received everything, call algorithm. |
| 724 { | 723 { |
| 725 homezoneLocate(); | 724 homezoneLocate(); |
| 726 data->new_cell_res = FALSE; | 725 data->new_cell_res = FALSE; |
| 727 } | 726 } |
| 728 | 727 |
| 729 return; | 728 return; |
| 730 } | 729 } |
| 731 | 730 |
| 732 | 731 |
| 733 /******************************************************************************* | 732 /******************************************************************************* |
| 734 | 733 |
| 735 $Function: homezoneLocate | 734 $Function: homezoneLocate |
| 736 | 735 |
| 737 $Description: Looks at coordinates from cell broadcast message and calculates if | 736 $Description: Looks at coordinates from cell broadcast message and calculates if |
| 738 they are in a homezone | 737 they are in a homezone |
| 739 | 738 |
| 740 $Returns: None | 739 $Returns: None |
| 741 | 740 |
| 742 $Arguments: None | 741 $Arguments: None |
| 743 | 742 |
| 744 *******************************************************************************/ | 743 *******************************************************************************/ |
| 745 | 744 |
| 746 void homezoneLocate() | 745 void homezoneLocate() |
| 747 { | 746 { |
| 748 T_homezone_data *data = &homezoneData; | 747 T_homezone_data *data = &homezoneData; |
| 749 T_homezone *homezone = data->homezone; | 748 T_homezone *homezone = data->homezone; |
| 750 long deltaX; | 749 long deltaX; |
| 751 long deltaY; | 750 long deltaY; |
| 752 USHORT hzIndex; | 751 USHORT hzIndex; |
| 753 USHORT cacheIndex=0; | 752 USHORT cacheIndex=0; |
| 754 U32 Dsquared; | 753 U32 Dsquared; |
| 755 BOOL foundInCache; | 754 BOOL foundInCache; |
| 756 USHORT cacheFreeSpace=0; | 755 USHORT cacheFreeSpace=0; |
| 757 USHORT field; | 756 USHORT field; |
| 758 USHORT record=0; | 757 USHORT record=0; |
| 759 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 758 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 760 //begin 30439 | 759 //begin 30439 |
| 761 EF_HZCACHE cache; | 760 EF_HZCACHE cache; |
| 762 UBYTE exist = 0; | 761 UBYTE exist = 0; |
| 763 //end 30439 | 762 //end 30439 |
| 764 | 763 |
| 765 /* Check if homezone is already switched off */ | 764 /* Check if homezone is already switched off */ |
| 766 | 765 |
| 767 if (data->received==HZ_RECEIVED_HZ_OFF) | 766 if (data->received==HZ_RECEIVED_HZ_OFF) |
| 768 return; | 767 return; |
| 769 | 768 |
| 770 TRACE_FUNCTION("homezoneLocate()"); | 769 TRACE_FUNCTION("homezoneLocate()"); |
| 771 | 770 |
| 772 data->current_zone = HZ_NOT_IN_ZONE; // We don't know if we're in a homezone yet (homezones = 0 to 3) | 771 data->current_zone = HZ_NOT_IN_ZONE; // We don't know if we're in a homezone yet (homezones = 0 to 3) |
| 773 field = HZ_NOT_IN_ZONE; // The cache to update | 772 field = HZ_NOT_IN_ZONE; // The cache to update |
| 774 | 773 |
| 775 /* Work out if we're in a homezone using current_X and current_Y, received from CB message */ | 774 /* Work out if we're in a homezone using current_X and current_Y, received from CB message */ |
| 776 | 775 |
| 777 if (data->received == HZ_RECEIVED_ALL) | 776 if (data->received == HZ_RECEIVED_ALL) |
| 778 { | 777 { |
| 779 #ifdef TRACE_MMIHOMEZONE | 778 #ifdef TRACE_MMIHOMEZONE |
| 780 TRACE_EVENT_P2("Current cell X: %X, Y: %X", data->current_X,data->current_Y); | 779 TRACE_EVENT_P2("Current cell X: %X, Y: %X", data->current_X,data->current_Y); |
| 781 #endif | 780 #endif |
| 782 | 781 |
| 783 /* Check to see if (current_X,current_Y) is in any of the defined homezones */ | 782 /* Check to see if (current_X,current_Y) is in any of the defined homezones */ |
| 784 | 783 |
| 785 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... | 784 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... |
| 786 { | 785 { |
| 787 #ifdef TRACE_MMIHOMEZONE | 786 #ifdef TRACE_MMIHOMEZONE |
| 788 TRACE_EVENT_P1("Homezone %d...", hzIndex); | 787 TRACE_EVENT_P1("Homezone %d...", hzIndex); |
| 789 TRACE_EVENT_P3("Has coords X: %X, Y: %X, R2: %X", homezone[hzIndex].X, homezone[hzIndex].Y, homezone[hzIndex].Rsquared); | 788 TRACE_EVENT_P3("Has coords X: %X, Y: %X, R2: %X", homezone[hzIndex].X, homezone[hzIndex].Y, homezone[hzIndex].Rsquared); |
| 790 #endif | 789 #endif |
| 791 | 790 |
| 792 if (homezone[hzIndex].active) // Provided the homezone is active | 791 if (homezone[hzIndex].active) // Provided the homezone is active |
| 793 { | 792 { |
| 794 #ifdef TRACE_MMIHOMEZONE // Calculate X and Y distance | 793 #ifdef TRACE_MMIHOMEZONE // Calculate X and Y distance |
| 795 TRACE_EVENT("Is active."); | 794 TRACE_EVENT("Is active."); |
| 796 #endif | 795 #endif |
| 797 deltaX = labs(data->current_X-homezone[hzIndex].X); // between centre of current cell | 796 deltaX = labs(data->current_X-homezone[hzIndex].X); // between centre of current cell |
| 798 deltaY = labs(data->current_Y-homezone[hzIndex].Y); // and centre of the homezone | 797 deltaY = labs(data->current_Y-homezone[hzIndex].Y); // and centre of the homezone |
| 799 #ifdef TRACE_MMIHOMEZONE | 798 #ifdef TRACE_MMIHOMEZONE |
| 800 TRACE_EVENT_P1("deltaX = %d",deltaX); | 799 TRACE_EVENT_P1("deltaX = %d",deltaX); |
| 801 TRACE_EVENT_P1("deltaY = %d",deltaY); | 800 TRACE_EVENT_P1("deltaY = %d",deltaY); |
| 802 #endif | 801 #endif |
| 803 if (deltaX<=HZ_DISTANCE_MAX && deltaY<=HZ_DISTANCE_MAX) // If not too far... | 802 if (deltaX<=HZ_DISTANCE_MAX && deltaY<=HZ_DISTANCE_MAX) // If not too far... |
| 804 { | 803 { |
| 805 Dsquared = deltaX*deltaX+deltaY*deltaY; // Calculate the resultant distance squared | 804 Dsquared = deltaX*deltaX+deltaY*deltaY; // Calculate the resultant distance squared |
| 806 #ifdef TRACE_MMIHOMEZONE | 805 #ifdef TRACE_MMIHOMEZONE |
| 807 TRACE_EVENT_P1("Dsquared = %d",Dsquared); | 806 TRACE_EVENT_P1("Dsquared = %d",Dsquared); |
| 808 #endif | 807 #endif |
| 809 if (Dsquared <= homezone[hzIndex].Rsquared) // If within radius of homezone squared | 808 if (Dsquared <= homezone[hzIndex].Rsquared) // If within radius of homezone squared |
| 810 { | 809 { |
| 811 #ifdef TRACE_MMIHOMEZONE | 810 #ifdef TRACE_MMIHOMEZONE |
| 812 TRACE_EVENT("Contains the current cell."); | 811 TRACE_EVENT("Contains the current cell."); |
| 813 #endif | 812 #endif |
| 814 data->current_zone = hzIndex; // Current zone is this homezone | 813 data->current_zone = hzIndex; // Current zone is this homezone |
| 815 | 814 |
| 816 if (!homezone[hzIndex].cityzone) // Then: if it's not a cityzone | 815 if (!homezone[hzIndex].cityzone) // Then: if it's not a cityzone |
| 817 { | 816 { |
| 818 #ifdef TRACE_MMIHOMEZONE | 817 #ifdef TRACE_MMIHOMEZONE |
| 819 TRACE_EVENT("Is not a cityzone."); | 818 TRACE_EVENT("Is not a cityzone."); |
| 820 #endif | 819 #endif |
| 821 foundInCache = FALSE; // Look through the cache for this | 820 foundInCache = FALSE; // Look through the cache for this |
| 822 cacheFreeSpace = HZ_CACHE_MAX; // homezone to see if cell is listed | 821 cacheFreeSpace = HZ_CACHE_MAX; // homezone to see if cell is listed |
| 823 | 822 |
| 824 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && !foundInCache; cacheIndex++) | 823 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && !foundInCache; cacheIndex++) |
| 825 { | 824 { |
| 826 if (data->cid==homezone[hzIndex].cid[cacheIndex]) | 825 if (data->cid==homezone[hzIndex].cid[cacheIndex]) |
| 827 { | 826 { |
| 828 foundInCache = TRUE; // We've found it! | 827 foundInCache = TRUE; // We've found it! |
| 829 } | 828 } |
| 830 if (homezone[hzIndex].cid[cacheIndex]==0 && cacheFreeSpace==HZ_CACHE_MAX) | 829 if (homezone[hzIndex].cid[cacheIndex]==0 && cacheFreeSpace==HZ_CACHE_MAX) |
| 831 cacheFreeSpace = cacheIndex; // Or we've found an empty space | 830 cacheFreeSpace = cacheIndex; // Or we've found an empty space |
| 832 } | 831 } |
| 833 | 832 |
| 834 if (!foundInCache) // If not there, need to add it | 833 if (!foundInCache) // If not there, need to add it |
| 835 { | 834 { |
| 836 #ifdef TRACE_MMIHOMEZONE | 835 #ifdef TRACE_MMIHOMEZONE |
| 837 TRACE_EVENT("Is not in the cache."); | 836 TRACE_EVENT("Is not in the cache."); |
| 838 #endif | 837 #endif |
| 839 if (cacheFreeSpace==HZ_CACHE_MAX) // If we didn't find a free space... | 838 if (cacheFreeSpace==HZ_CACHE_MAX) // If we didn't find a free space... |
| 840 { | 839 { |
| 841 cacheFreeSpace = rand() % HZ_CACHE_MAX; // Choose a random entry | 840 cacheFreeSpace = rand() % HZ_CACHE_MAX; // Choose a random entry |
| 842 } | 841 } |
| 843 homezone[hzIndex].cid[cacheFreeSpace] = data->cid; // And store current cell there | 842 homezone[hzIndex].cid[cacheFreeSpace] = data->cid; // And store current cell there |
| 844 homezone[hzIndex].lac[cacheFreeSpace] = data->lac; // with its location area code | 843 homezone[hzIndex].lac[cacheFreeSpace] = data->lac; // with its location area code |
| 845 | 844 |
| 846 field = hzIndex+HZ_SIM_CELL_CACHE; // We've changed the cache | 845 field = hzIndex+HZ_SIM_CELL_CACHE; // We've changed the cache |
| 847 record = cacheFreeSpace+1; | 846 record = cacheFreeSpace+1; |
| 848 | 847 |
| 849 #ifdef TRACE_MMIHOMEZONE | 848 #ifdef TRACE_MMIHOMEZONE |
| 850 TRACE_EVENT_P1("Have added to cache, entry %d.",cacheFreeSpace); | 849 TRACE_EVENT_P1("Have added to cache, entry %d.",cacheFreeSpace); |
| 851 #endif | 850 #endif |
| 852 } | 851 } |
| 853 } | 852 } |
| 854 } | 853 } |
| 855 else // If we're not in the homezone... | 854 else // If we're not in the homezone... |
| 856 { | 855 { |
| 857 foundInCache = FALSE; // Look through the cache for this | 856 foundInCache = FALSE; // Look through the cache for this |
| 858 // homezone to see if cell is listed | 857 // homezone to see if cell is listed |
| 859 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && !foundInCache; cacheIndex++) | 858 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && !foundInCache; cacheIndex++) |
| 860 { | 859 { |
| 861 if (data->cid==homezone[hzIndex].cid[cacheIndex]) | 860 if (data->cid==homezone[hzIndex].cid[cacheIndex]) |
| 862 { | 861 { |
| 863 foundInCache = TRUE; // We've found it! | 862 foundInCache = TRUE; // We've found it! |
| 864 cacheFreeSpace = cacheIndex; // Record where it is | 863 cacheFreeSpace = cacheIndex; // Record where it is |
| 865 break; | 864 break; |
| 866 } | 865 } |
| 867 } | 866 } |
| 868 | 867 |
| 869 if (foundInCache) // If it's there... | 868 if (foundInCache) // If it's there... |
| 870 { | 869 { |
| 871 #ifdef TRACE_MMIHOMEZONE | 870 #ifdef TRACE_MMIHOMEZONE |
| 872 TRACE_EVENT("Is in the cache and shouldn't be."); | 871 TRACE_EVENT("Is in the cache and shouldn't be."); |
| 873 #endif | 872 #endif |
| 874 homezone[hzIndex].cid[cacheFreeSpace] = 0; // ...remove it | 873 homezone[hzIndex].cid[cacheFreeSpace] = 0; // ...remove it |
| 875 field = hzIndex+HZ_SIM_CELL_CACHE; // We've changed the cache | 874 field = hzIndex+HZ_SIM_CELL_CACHE; // We've changed the cache |
| 876 record = cacheFreeSpace+1; | 875 record = cacheFreeSpace+1; |
| 877 data->current_zone = HZ_NOT_IN_ZONE; // We're not in this zone | 876 data->current_zone = HZ_NOT_IN_ZONE; // We're not in this zone |
| 878 } | 877 } |
| 879 #ifdef TRACE_MMIHOMEZONE | 878 #ifdef TRACE_MMIHOMEZONE |
| 880 else | 879 else |
| 881 { | 880 { |
| 882 TRACE_EVENT("Isn't in the cache and shouldn't be."); | 881 TRACE_EVENT("Isn't in the cache and shouldn't be."); |
| 883 } | 882 } |
| 884 #endif | 883 #endif |
| 885 } | 884 } |
| 886 | 885 |
| 887 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 886 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 888 //begin 30439 | 887 //begin 30439 |
| 889 /* check if the cid is already in cache */ | 888 /* check if the cid is already in cache */ |
| 890 for (cacheIndex=0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) /*a0393213 - lint warnings removal - HZ_CACHE_MAX changed to HZ_RECENT_MAX*/ | 889 for (cacheIndex=0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) /*a0393213 - lint warnings removal - HZ_CACHE_MAX changed to HZ_RECENT_MAX*/ |
| 891 { | 890 { |
| 892 if (data->recent_cell[cacheIndex] == data->cid) | 891 if (data->recent_cell[cacheIndex] == data->cid) |
| 893 exist = 1; | 892 exist = 1; |
| 894 } | 893 } |
| 895 /* Replace oldest cell in dynamic cache with new cell */ | 894 /* Replace oldest cell in dynamic cache with new cell */ |
| 896 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 895 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 897 //begin 30439 | 896 //begin 30439 |
| 898 //Added a conditional statement | 897 //Added a conditional statement |
| 899 if (!exist) | 898 if (!exist) |
| 900 { | 899 { |
| 901 data->recent_cell_index++; | 900 data->recent_cell_index++; |
| 902 if (data->recent_cell_index>=HZ_RECENT_MAX) | 901 if (data->recent_cell_index>=HZ_RECENT_MAX) |
| 903 data->recent_cell_index = 0; | 902 data->recent_cell_index = 0; |
| 904 #ifdef TRACE_MMIHOMEZONE | 903 #ifdef TRACE_MMIHOMEZONE |
| 905 TRACE_EVENT_P1("Adding to recent list, index = %d", data->recent_cell_index); | 904 TRACE_EVENT_P1("Adding to recent list, index = %d", data->recent_cell_index); |
| 906 #endif | 905 #endif |
| 907 data->recent_cell[data->recent_cell_index] = data->cid; | 906 data->recent_cell[data->recent_cell_index] = data->cid; |
| 908 data->recent_cell_zone[data->recent_cell_index] = data->current_zone; | 907 data->recent_cell_zone[data->recent_cell_index] = data->current_zone; |
| 909 | 908 |
| 910 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 909 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 911 //begin 30439 | 910 //begin 30439 |
| 912 /* write cache to PCM */ | 911 /* write cache to PCM */ |
| 913 writeHexToSimfile(&cache.cid[0], data->recent_cell[data->recent_cell_index], 2 ); | 912 writeHexToSimfile(&cache.cid[0], data->recent_cell[data->recent_cell_index], 2 ); |
| 914 cache.zone = data->recent_cell_zone[data->recent_cell_index]; | 913 cache.zone = data->recent_cell_zone[data->recent_cell_index]; |
| 915 /* write cache to PCM */ | 914 /* write cache to PCM */ |
| 916 pcm_WriteRecord((UBYTE *)EF_HZCACHE_ID, | 915 pcm_WriteRecord((UBYTE *)EF_HZCACHE_ID, |
| 917 (USHORT)(data->recent_cell_index+1), | 916 (USHORT)(data->recent_cell_index+1), |
| 918 SIZE_EF_HZCACHE, | 917 SIZE_EF_HZCACHE, |
| 919 &cache.cid[0]); | 918 &cache.cid[0]); |
| 920 | 919 |
| 921 } | 920 } |
| 922 //end 30439 | 921 //end 30439 |
| 923 #ifdef TRACE_MMIHOMEZONE | 922 #ifdef TRACE_MMIHOMEZONE |
| 924 for (cacheIndex = 0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) | 923 for (cacheIndex = 0; cacheIndex<HZ_RECENT_MAX; cacheIndex++) |
| 925 { | 924 { |
| 926 TRACE_EVENT_P3("Recent cache %d: CID %X, zone %X",cacheIndex, data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); | 925 TRACE_EVENT_P3("Recent cache %d: CID %X, zone %X",cacheIndex, data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); |
| 927 } | 926 } |
| 928 #endif | 927 #endif |
| 929 } | 928 } |
| 930 | 929 |
| 931 } | 930 } |
| 932 | 931 |
| 933 } | 932 } |
| 934 | 933 |
| 935 } | 934 } |
| 936 | 935 |
| 937 #ifdef TRACE_MMIHOMEZONE | 936 #ifdef TRACE_MMIHOMEZONE |
| 938 TRACE_EVENT("CACHES AFTER UPDATE"); | 937 TRACE_EVENT("CACHES AFTER UPDATE"); |
| 939 for (hzIndex=0; hzIndex<HZ_ZONES_MAX; hzIndex++) // For each homezone... | 938 for (hzIndex=0; hzIndex<HZ_ZONES_MAX; hzIndex++) // For each homezone... |
| 940 { | 939 { |
| 941 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ | 940 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ |
| 942 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); | 941 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); |
| 943 | 942 |
| 944 if (homezone[hzIndex].active && !homezone[hzIndex].cityzone) // If it's active, and not a cityzone | 943 if (homezone[hzIndex].active && !homezone[hzIndex].cityzone) // If it's active, and not a cityzone |
| 945 { | 944 { |
| 946 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX; cacheIndex++) // Check the cache. | 945 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX; cacheIndex++) // Check the cache. |
| 947 { | 946 { |
| 948 TRACE_EVENT_P3("Cache %d: lac %X, cid %X", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex]); | 947 TRACE_EVENT_P3("Cache %d: lac %X, cid %X", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex]); |
| 949 } | 948 } |
| 950 } | 949 } |
| 951 } | 950 } |
| 952 #endif | 951 #endif |
| 953 /* Update icon/text tag. */ | 952 /* Update icon/text tag. */ |
| 954 | 953 |
| 955 homezoneUpdateDisplay(); | 954 homezoneUpdateDisplay(); |
| 956 | 955 |
| 957 /* Write data back to SIM if cache has changed & SIM files present */ | 956 /* Write data back to SIM if cache has changed & SIM files present */ |
| 958 | 957 |
| 959 if (field!=HZ_NOT_IN_ZONE && (data->received & HZ_RECEIVED_SIMDATA)) | 958 if (field!=HZ_NOT_IN_ZONE && (data->received & HZ_RECEIVED_SIMDATA)) |
| 960 { | 959 { |
| 961 homezoneWriteSim(field, record); | 960 homezoneWriteSim(field, record); |
| 962 } | 961 } |
| 963 | 962 |
| 964 return; | 963 return; |
| 965 } | 964 } |
| 966 | 965 |
| 967 | 966 |
| 968 /******************************************************************************* | 967 /******************************************************************************* |
| 969 | 968 |
| 970 $Function: homezoneUpdate | 969 $Function: homezoneUpdate |
| 971 | 970 |
| 972 $Description: Main homezone function; check whether MS is in a homezone or not | 971 $Description: Main homezone function; check whether MS is in a homezone or not |
| 973 | 972 |
| 974 $Returns: | 973 $Returns: |
| 975 | 974 |
| 976 $Arguments: lac - the location area code of the current cell (on cell reselection) | 975 $Arguments: lac - the location area code of the current cell (on cell reselection) |
| 977 cid - the ID of the current cell (on cell reselection) | 976 cid - the ID of the current cell (on cell reselection) |
| 978 keep - 1: no change in lac and cid | 977 keep - 1: no change in lac and cid |
| 979 *******************************************************************************/ | 978 *******************************************************************************/ |
| 980 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 979 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 981 //begin 30439 | 980 //begin 30439 |
| 982 //Added an extra argument in the function -- "keep" | 981 //Added an extra argument in the function -- "keep" |
| 983 void homezoneUpdate(USHORT lac, USHORT cid, UBYTE keep) | 982 void homezoneUpdate(USHORT lac, USHORT cid, UBYTE keep) |
| 984 { | 983 { |
| 985 T_homezone_data *data = &homezoneData; | 984 T_homezone_data *data = &homezoneData; |
| 986 T_homezone *homezone = data->homezone; | 985 T_homezone *homezone = data->homezone; |
| 987 USHORT hzIndex; | 986 USHORT hzIndex; |
| 988 USHORT cacheIndex; | 987 USHORT cacheIndex; |
| 989 UBYTE inCache = 0; | 988 UBYTE inCache = 0; |
| 990 | 989 |
| 991 /* Check if homezone is already switched off */ | 990 /* Check if homezone is already switched off */ |
| 992 | 991 |
| 993 TRACE_EVENT_P1("Data received: %d", data->received); | 992 TRACE_EVENT_P1("Data received: %d", data->received); |
| 994 | 993 |
| 995 if (data->received==HZ_RECEIVED_HZ_OFF) | 994 if (data->received==HZ_RECEIVED_HZ_OFF) |
| 996 return; | 995 return; |
| 997 | 996 |
| 998 TRACE_FUNCTION("homezoneUpdate()"); | 997 TRACE_FUNCTION("homezoneUpdate()"); |
| 999 | 998 |
| 1000 data->current_zone = HZ_NOT_IN_ZONE; // We don't know if we're in a homezone yet (homezones = 0 to 3) | 999 data->current_zone = HZ_NOT_IN_ZONE; // We don't know if we're in a homezone yet (homezones = 0 to 3) |
| 1001 data->received |= HZ_RECEIVED_CELLRES; // Have received this event | 1000 data->received |= HZ_RECEIVED_CELLRES; // Have received this event |
| 1002 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 1001 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 1003 //Modified to add a conditional statement | 1002 //Modified to add a conditional statement |
| 1004 //begin 30439 | 1003 //begin 30439 |
| 1005 if (!keep) | 1004 if (!keep) |
| 1006 { | 1005 { |
| 1007 data->lac = lac; | 1006 data->lac = lac; |
| 1008 data->cid = cid; | 1007 data->cid = cid; |
| 1009 } | 1008 } |
| 1010 /* keep the current lac and cid */ | 1009 /* keep the current lac and cid */ |
| 1011 else | 1010 else |
| 1012 { | 1011 { |
| 1013 lac = data->lac; | 1012 lac = data->lac; |
| 1014 cid = data->cid; | 1013 cid = data->cid; |
| 1015 } | 1014 } |
| 1016 //end 30439 | 1015 //end 30439 |
| 1017 | 1016 |
| 1018 #ifdef TRACE_MMIHOMEZONE | 1017 #ifdef TRACE_MMIHOMEZONE |
| 1019 TRACE_EVENT_P3("lac: %X, cid: %X, received: %d", lac, cid, data->received); | 1018 TRACE_EVENT_P3("lac: %X, cid: %X, received: %d", lac, cid, data->received); |
| 1020 #endif | 1019 #endif |
| 1021 | 1020 |
| 1022 /* If either are zero or -1, the reselection data is invalid */ | 1021 /* If either are zero or -1, the reselection data is invalid */ |
| 1023 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 1022 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 1024 //Modified to add a conditional statement | 1023 //Modified to add a conditional statement |
| 1025 if (((lac==0 || cid==0) || (lac==0xFFFF || cid==0xFFFF)) AND !keep) | 1024 if (((lac==0 || cid==0) || (lac==0xFFFF || cid==0xFFFF)) AND !keep) |
| 1026 { | 1025 { |
| 1027 TRACE_EVENT_P1("homezoneUpdateDisplay ~HZ_RECEIVED_CELLRES keep=%d", keep); | 1026 TRACE_EVENT_P1("homezoneUpdateDisplay ~HZ_RECEIVED_CELLRES keep=%d", keep); |
| 1028 //end 30439 | 1027 //end 30439 |
| 1029 data->received &= (~HZ_RECEIVED_CELLRES); | 1028 data->received &= (~HZ_RECEIVED_CELLRES); |
| 1030 homezoneUpdateDisplay(); | 1029 homezoneUpdateDisplay(); |
| 1031 return; | 1030 return; |
| 1032 } | 1031 } |
| 1033 | 1032 |
| 1034 data->new_cell_res = TRUE; // Cell res just occurred | 1033 data->new_cell_res = TRUE; // Cell res just occurred |
| 1035 | 1034 |
| 1036 /* Must have received SIM data to continue*/ | 1035 /* Must have received SIM data to continue*/ |
| 1037 | 1036 |
| 1038 if (!(data->received & HZ_RECEIVED_SIMDATA)) | 1037 if (!(data->received & HZ_RECEIVED_SIMDATA)) |
| 1039 return; | 1038 return; |
| 1040 | 1039 |
| 1041 /* Check homezone cache for each homezone */ | 1040 /* Check homezone cache for each homezone */ |
| 1042 /* Can do this even if we haven't received the CB message */ | 1041 /* Can do this even if we haven't received the CB message */ |
| 1043 | 1042 |
| 1044 #ifdef TRACE_MMIHOMEZONE | 1043 #ifdef TRACE_MMIHOMEZONE |
| 1045 TRACE_EVENT("Checking zone caches..."); | 1044 TRACE_EVENT("Checking zone caches..."); |
| 1046 #endif | 1045 #endif |
| 1047 | 1046 |
| 1048 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... | 1047 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... |
| 1049 { | 1048 { |
| 1050 #ifdef TRACE_MMIHOMEZONE | 1049 #ifdef TRACE_MMIHOMEZONE |
| 1051 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ | 1050 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ |
| 1052 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); | 1051 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); |
| 1053 #endif | 1052 #endif |
| 1054 | 1053 |
| 1055 if (homezone[hzIndex].active && !homezone[hzIndex].cityzone) // If it's active, and not a cityzone | 1054 if (homezone[hzIndex].active && !homezone[hzIndex].cityzone) // If it's active, and not a cityzone |
| 1056 { | 1055 { |
| 1057 #ifdef TRACE_MMIHOMEZONE | 1056 #ifdef TRACE_MMIHOMEZONE |
| 1058 TRACE_EVENT("Is Active."); | 1057 TRACE_EVENT("Is Active."); |
| 1059 #endif | 1058 #endif |
| 1060 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && data->current_zone==HZ_NOT_IN_ZONE; cacheIndex++) // Check the cache. | 1059 for (cacheIndex=0; cacheIndex<HZ_CACHE_MAX && data->current_zone==HZ_NOT_IN_ZONE; cacheIndex++) // Check the cache. |
| 1061 { | 1060 { |
| 1062 #ifdef TRACE_MMIHOMEZONE | 1061 #ifdef TRACE_MMIHOMEZONE |
| 1063 TRACE_EVENT_P3("Cache %d: lac %X, cid %X", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex]); | 1062 TRACE_EVENT_P3("Cache %d: lac %X, cid %X", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex]); |
| 1064 #endif | 1063 #endif |
| 1065 | 1064 |
| 1066 if (cid==homezone[hzIndex].cid[cacheIndex]) // If the current cell is in the cache.... | 1065 if (cid==homezone[hzIndex].cid[cacheIndex]) // If the current cell is in the cache.... |
| 1067 { | 1066 { |
| 1068 #ifdef TRACE_MMIHOMEZONE | 1067 #ifdef TRACE_MMIHOMEZONE |
| 1069 TRACE_EVENT_P1("Cell found in cache %d.",cacheIndex); | 1068 TRACE_EVENT_P1("Cell found in cache %d.",cacheIndex); |
| 1070 #endif | 1069 #endif |
| 1071 data->current_zone = hzIndex; // Then this is our current homezone! | 1070 data->current_zone = hzIndex; // Then this is our current homezone! |
| 1072 inCache = 1; | 1071 inCache = 1; |
| 1073 } | 1072 } |
| 1074 } | 1073 } |
| 1075 if (!inCache AND hzFlag) | 1074 if (!inCache AND hzFlag) |
| 1076 { | 1075 { |
| 1077 hzFlag = 0; | 1076 hzFlag = 0; |
| 1078 TRACE_EVENT ("not in cache, caculate needed"); | 1077 TRACE_EVENT ("not in cache, caculate needed"); |
| 1079 homezoneLocate(); | 1078 homezoneLocate(); |
| 1080 return; | 1079 return; |
| 1081 } | 1080 } |
| 1082 else | 1081 else |
| 1083 inCache = 0; | 1082 inCache = 0; |
| 1084 } | 1083 } |
| 1085 } | 1084 } |
| 1086 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 1085 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 1087 //added a conditional statement | 1086 //added a conditional statement |
| 1088 //begin 30439 | 1087 //begin 30439 |
| 1089 /* If we didn't find a homezone, check recent cells cache to see if we're in a cityzone */ | 1088 /* If we didn't find a homezone, check recent cells cache to see if we're in a cityzone */ |
| 1090 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... | 1089 for (hzIndex=0; hzIndex<HZ_ZONES_MAX && data->current_zone==HZ_NOT_IN_ZONE; hzIndex++) // For each homezone... |
| 1091 { | 1090 { |
| 1092 #ifdef TRACE_MMIHOMEZONE | 1091 #ifdef TRACE_MMIHOMEZONE |
| 1093 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ | 1092 /* x0083025 on Sep 14, 2007 for OMAPS00145865 (adrian) */ |
| 1094 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); | 1093 MMI_TRACE_EVENT_P2("Zone %d (%s)", hzIndex, homezone[hzIndex].Tag); |
| 1095 #endif | 1094 #endif |
| 1096 | 1095 |
| 1097 if (homezone[hzIndex].active && homezone[hzIndex].cityzone) // If it's active, and not a cityzone | 1096 if (homezone[hzIndex].active && homezone[hzIndex].cityzone) // If it's active, and not a cityzone |
| 1098 { | 1097 { |
| 1099 #ifdef TRACE_MMIHOMEZONE | 1098 #ifdef TRACE_MMIHOMEZONE |
| 1100 TRACE_EVENT("Is Active."); | 1099 TRACE_EVENT("Is Active."); |
| 1101 #endif | 1100 #endif |
| 1102 | 1101 |
| 1103 for (cacheIndex=0; cacheIndex<HZ_RECENT_MAX && data->current_zone==HZ_NOT_IN_ZONE; cacheIndex++) // Check the cache. | 1102 for (cacheIndex=0; cacheIndex<HZ_RECENT_MAX && data->current_zone==HZ_NOT_IN_ZONE; cacheIndex++) // Check the cache. |
| 1104 { | 1103 { |
| 1105 #ifdef TRACE_MMIHOMEZONE | 1104 #ifdef TRACE_MMIHOMEZONE |
| 1106 TRACE_EVENT_P5("Cache %d: lac %X, cid %X, data->recent_cell %X, data->recent_cell_zone %d", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex], data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); | 1105 TRACE_EVENT_P5("Cache %d: lac %X, cid %X, data->recent_cell %X, data->recent_cell_zone %d", cacheIndex, homezone[hzIndex].lac[cacheIndex], homezone[hzIndex].cid[cacheIndex], data->recent_cell[cacheIndex], data->recent_cell_zone[cacheIndex]); |
| 1107 #endif | 1106 #endif |
| 1108 | 1107 |
| 1109 if (cid==data->recent_cell[cacheIndex] && data->recent_cell_zone[cacheIndex]!=HZ_NOT_IN_ZONE) // If we're in that cell | 1108 if (cid==data->recent_cell[cacheIndex] && data->recent_cell_zone[cacheIndex]!=HZ_NOT_IN_ZONE) // If we're in that cell |
| 1110 { | 1109 { |
| 1111 #ifdef TRACE_MMIHOMEZONE | 1110 #ifdef TRACE_MMIHOMEZONE |
| 1112 TRACE_EVENT_P1("FOUND cityzone in cache %d.",cacheIndex); | 1111 TRACE_EVENT_P1("FOUND cityzone in cache %d.",cacheIndex); |
| 1113 #endif | 1112 #endif |
| 1114 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 | 1113 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858 |
| 1115 //Modified to directly assign value | 1114 //Modified to directly assign value |
| 1116 data->current_zone = hzIndex; // Then this is our current homezone! | 1115 data->current_zone = hzIndex; // Then this is our current homezone! |
| 1117 inCache = 1; | 1116 inCache = 1; |
| 1118 } | 1117 } |
| 1119 if (!inCache AND hzFlag) | 1118 if (!inCache AND hzFlag) |
| 1120 { | 1119 { |
| 1121 hzFlag = 0; | 1120 hzFlag = 0; |
| 1122 TRACE_EVENT ("not in cache, caculate needed"); | 1121 TRACE_EVENT ("not in cache, caculate needed"); |
| 1123 homezoneLocate(); | 1122 homezoneLocate(); |
| 1124 return; | 1123 return; |
| 1125 } | 1124 } |
| 1126 else | 1125 else |
| 1127 inCache = 0; | 1126 inCache = 0; |
| 1128 } | 1127 } |
| 1129 } | 1128 } |
| 1130 } | 1129 } |
| 1131 | 1130 |
| 1132 homezoneUpdateDisplay(); // Update icon/text tag. | 1131 homezoneUpdateDisplay(); // Update icon/text tag. |
| 1133 | 1132 |
| 1134 return; | 1133 return; |
| 1135 } | 1134 } |
| 1136 | 1135 |
| 1137 | 1136 |
| 1138 /******************************************************************************* | 1137 /******************************************************************************* |
| 1139 | 1138 |
| 1140 $Function: homezoneUpdateDisplay | 1139 $Function: homezoneUpdateDisplay |
| 1141 | 1140 |
| 1142 $Description: | 1141 $Description: |
| 1143 | 1142 |
| 1144 $Returns: Updates the homezone icon and text string appropriately | 1143 $Returns: Updates the homezone icon and text string appropriately |
| 1145 | 1144 |
| 1146 $Arguments: none | 1145 $Arguments: none |
| 1147 *******************************************************************************/ | 1146 *******************************************************************************/ |
| 1148 | 1147 |
| 1149 void homezoneUpdateDisplay(void) | 1148 void homezoneUpdateDisplay(void) |
| 1150 { | 1149 { |
| 1151 T_homezone_data *data = &homezoneData; | 1150 T_homezone_data *data = &homezoneData; |
| 1152 | 1151 |
| 1153 TRACE_FUNCTION("homezoneUpdateDisplay()"); | 1152 TRACE_FUNCTION("homezoneUpdateDisplay()"); |
| 1154 | 1153 |
| 1155 iconsDeleteState(iconIdHomezone); | 1154 iconsDeleteState(iconIdHomezone); |
| 1156 | 1155 |
| 1157 #ifdef FF_MMI_SAT_ICON | 1156 #ifdef FF_MMI_SAT_ICON |
| 1158 addSatMessage(NULL, 0, 0, NULL, FALSE, SAT_ICON_NONE); | 1157 addSatMessage(NULL, 0, 0, NULL, FALSE, SAT_ICON_NONE); |
| 1159 #else | 1158 #else |
| 1160 addSatMessage(NULL); | 1159 addSatMessage(NULL); |
| 1161 #endif | 1160 #endif |
| 1162 | 1161 |
| 1163 if (data->current_zone!=HZ_NOT_IN_ZONE) // If not in a homezone, leave blank | 1162 if (data->current_zone!=HZ_NOT_IN_ZONE) // If not in a homezone, leave blank |
| 1164 { | 1163 { |
| 1165 //x0035544 Mar 14, 2006 DR:OMAPS00061468 | 1164 //x0035544 Mar 14, 2006 DR:OMAPS00061468 |
| 1166 #ifdef FF_MMI_SAT_ICON | 1165 #ifdef FF_MMI_SAT_ICON |
| 1167 addSatMessage(data->homezone[data->current_zone].Tag, 0, 0, NULL, FALSE, SAT_ICON_NONE); | 1166 addSatMessage(data->homezone[data->current_zone].Tag, 0, 0, NULL, FALSE, SAT_ICON_NONE); |
| 1168 #else | 1167 #else |
| 1169 addSatMessage(data->homezone[data->current_zone].Tag); | 1168 addSatMessage(data->homezone[data->current_zone].Tag); |
| 1170 #endif | 1169 #endif |
| 1171 if (!data->homezone[data->current_zone].cityzone) // Display icon if homezone rather than cityzone | 1170 if (!data->homezone[data->current_zone].cityzone) // Display icon if homezone rather than cityzone |
| 1172 { | 1171 { |
| 1173 iconsSetState(iconIdHomezone); | 1172 iconsSetState(iconIdHomezone); |
| 1174 } | 1173 } |
| 1175 } | 1174 } |
| 1176 | 1175 |
| 1177 return; | 1176 return; |
| 1178 } | 1177 } |
| 1179 | 1178 |
| 1180 | 1179 |
| 1181 /******************************************************************************* | 1180 /******************************************************************************* |
| 1182 | 1181 |
| 1183 $Function: calculateDecimal | 1182 $Function: calculateDecimal |
| 1184 | 1183 |
| 1185 $Description: | 1184 $Description: |
| 1186 | 1185 |
| 1187 $Returns: Returns a decimal number from a string of ascii digits | 1186 $Returns: Returns a decimal number from a string of ascii digits |
| 1188 | 1187 |
| 1189 $Arguments: none | 1188 $Arguments: none |
| 1190 *******************************************************************************/ | 1189 *******************************************************************************/ |
| 1191 | 1190 |
| 1192 static U32 calculateDecimal( char *string, int length ) | 1191 static U32 calculateDecimal( char *string, int length ) |
| 1193 { | 1192 { |
| 1194 U32 total = 0; | 1193 U32 total = 0; |
| 1195 int index; | 1194 int index; |
| 1196 | 1195 |
| 1197 /* decode each decimal character in turn */ | 1196 /* decode each decimal character in turn */ |
| 1198 for (index = 0; index < length; index++ ) | 1197 for (index = 0; index < length; index++ ) |
| 1199 { | 1198 { |
| 1200 if (string[index]>='0' && string[index]<='9') | 1199 if (string[index]>='0' && string[index]<='9') |
| 1201 { | 1200 { |
| 1202 total = ( total * 10 ) + ( string[index] - '0' ); | 1201 total = ( total * 10 ) + ( string[index] - '0' ); |
| 1203 } | 1202 } |
| 1204 } | 1203 } |
| 1205 | 1204 |
| 1206 return total; | 1205 return total; |
| 1207 } | 1206 } |
| 1208 | 1207 |
| 1209 /******************************************************************************* | 1208 /******************************************************************************* |
| 1210 | 1209 |
| 1211 $Function: readHexFromSimfile | 1210 $Function: readHexFromSimfile |
| 1212 | 1211 |
| 1213 $Description: Reads a hex string (MSB first) from a sim file | 1212 $Description: Reads a hex string (MSB first) from a sim file |
| 1214 | 1213 |
| 1215 $Returns: The hex number | 1214 $Returns: The hex number |
| 1216 | 1215 |
| 1217 $Arguments: simFile - the point in the simFile at which the string occurs | 1216 $Arguments: simFile - the point in the simFile at which the string occurs |
| 1218 length - the length of the string | 1217 length - the length of the string |
| 1219 *******************************************************************************/ | 1218 *******************************************************************************/ |
| 1220 | 1219 |
| 1221 static U32 readHexFromSimfile( UBYTE *simFile, int length ) | 1220 static U32 readHexFromSimfile( UBYTE *simFile, int length ) |
| 1222 { | 1221 { |
| 1223 U32 total = 0; | 1222 U32 total = 0; |
| 1224 int index; | 1223 int index; |
| 1225 | 1224 |
| 1226 for ( index = 0; index < length; index++ ) | 1225 for ( index = 0; index < length; index++ ) |
| 1227 { | 1226 { |
| 1228 total = ( total << 8 ) + simFile[index]; | 1227 total = ( total << 8 ) + simFile[index]; |
| 1229 } | 1228 } |
| 1230 | 1229 |
| 1231 return total; | 1230 return total; |
| 1232 } | 1231 } |
| 1233 | 1232 |
| 1234 /******************************************************************************* | 1233 /******************************************************************************* |
| 1235 | 1234 |
| 1236 $Function: writeHexToSimfile | 1235 $Function: writeHexToSimfile |
| 1237 | 1236 |
| 1238 $Description: Writes a hex string (MSB first) to a sim file | 1237 $Description: Writes a hex string (MSB first) to a sim file |
| 1239 | 1238 |
| 1240 $Returns: None | 1239 $Returns: None |
| 1241 | 1240 |
| 1242 $Arguments: simFile - the point in the simFile at which the string occurs | 1241 $Arguments: simFile - the point in the simFile at which the string occurs |
| 1243 length - the length of the string | 1242 length - the length of the string |
| 1244 *******************************************************************************/ | 1243 *******************************************************************************/ |
| 1245 | 1244 |
| 1246 static void writeHexToSimfile( UBYTE *simFile, U32 value, int length ) | 1245 static void writeHexToSimfile( UBYTE *simFile, U32 value, int length ) |
| 1247 { | 1246 { |
| 1248 int index; | 1247 int index; |
| 1249 | 1248 |
| 1250 #ifdef TRACE_MMIHOMEZONE | 1249 #ifdef TRACE_MMIHOMEZONE |
| 1251 TRACE_EVENT_P1("Hex of %X is:", value); | 1250 TRACE_EVENT_P1("Hex of %X is:", value); |
| 1252 #endif | 1251 #endif |
| 1253 | 1252 |
| 1254 /* Note: '-1' below clarification: | 1253 /* Note: '-1' below clarification: |
| 1255 * E.g. index=0, length=4: most significant byte is number shifted 3 bytes right. */ | 1254 * E.g. index=0, length=4: most significant byte is number shifted 3 bytes right. */ |
| 1256 | 1255 |
| 1257 for ( index = 0; index < length; index++ ) | 1256 for ( index = 0; index < length; index++ ) |
| 1258 { | 1257 { |
| 1259 simFile[index] = (value >> ((length-index-1)*8)) & 0xFF; /* SPR877 - SH - wrong before, added *8 */ | 1258 simFile[index] = (value >> ((length-index-1)*8)) & 0xFF; /* SPR877 - SH - wrong before, added *8 */ |
| 1260 #ifdef TRACE_MMIHOMEZONE | 1259 #ifdef TRACE_MMIHOMEZONE |
| 1261 TRACE_EVENT_P2("Simfile %d is %X", index, simFile[index]); | 1260 TRACE_EVENT_P2("Simfile %d is %X", index, simFile[index]); |
| 1262 #endif | 1261 #endif |
| 1263 } | 1262 } |
| 1264 | 1263 |
| 1265 return; | 1264 return; |
| 1266 } | 1265 } |
