comparison g23m/condat/ms/src/alr/alr_gprs.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : ALR_GPRS
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module implements the necessary funtionality
18 | for switching to and from GPRS mode and also
19 | the handling if determining if GPRS is supported
20 | by the cell.
21 +-----------------------------------------------------------------------------
22 */
23 #ifndef ALR_GPRS_C
24 #define ALR_GPRS_C
25
26
27 #define ENTITY_PL
28
29 /*==== INCLUDES ===================================================*/
30 #include <string.h>
31 #include <stdlib.h>
32 #include <ctype.h>
33 #include "typedefs.h"
34 #include "pconst.cdg"
35 #include "mconst.cdg"
36 #include "message.h"
37 #include "ccdapi.h"
38 #include "vsi.h"
39 #include "custom.h"
40 #include "gsm.h"
41 #include "prim.h"
42 #include "cnf_alr.h"
43 #include "mon_alr.h"
44 #include "pei.h"
45 #include "tok.h"
46 #include "pcm.h"
47 #include "alr_gprs.h"
48 #define TRACING
49 #include "alr.h"
50 #define TRACING
51
52 #define TRACING
53
54 #if defined (TRACING)
55 #define ALR_TRACE_GPRS(a) ALR_TRACE(a)
56 #else
57 #define ALR_TRACE_GPRS(a)
58 #endif
59
60 LOCAL BOOL gprs_read_si13 (UBYTE si13_position);
61 LOCAL void gprs_alr_nc_enter_ptm (void);
62 LOCAL void gprs_alr_tb_meas_ind (T_TB_MEAS_IND* report);
63
64 LOCAL const T_FUNC tb_table[] = {
65 MAK_FUNC_0( gprs_alr_tb_meas_ind, TB_MEAS_IND ) /* 0 */
66 };
67
68 #define ONLY_BCC 7
69 static UBYTE gprs_support = 0;
70
71 /*
72 +--------------------------------------------------------------------+
73 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
74 | STATE : code ROUTINE : gprs_alr_get_table |
75 +--------------------------------------------------------------------+
76
77 PURPOSE :
78
79 */
80 void gprs_alr_get_table(const T_FUNC **tab, USHORT *n)
81 {
82 *tab = tb_table;
83 *n = TAB_SIZE (tb_table);
84 }
85
86 /*
87 +--------------------------------------------------------------------+
88 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
89 | STATE : code ROUTINE : gprs_alr_mon_ctrl_req |
90 +--------------------------------------------------------------------+
91
92 PURPOSE :
93
94 */
95 /*
96 * required for TESTMODE A/B
97 */
98 EXTERN UBYTE grlc_test_mode_active(void);
99 void gprs_alr_mon_ctrl_req(T_MPH_MON_CTRL_REQ* ctrl_req)
100 {
101 ALR_TRACE_GPRS("mon_ctrl_req");
102
103 switch(GET_STATE(STATE_MA))
104 {
105 case MA_CELL_SELECTION:
106 switch(ctrl_req->action)
107 {
108 case START_MON_EBCCH:
109 if(ctrl_req->si_to_read EQ UPDATE_SI13)
110 {
111 PALLOC(req, MPHC_SCELL_EBCCH_REQ);
112 req->schedule_array_size = 1;
113 req->schedule_array[0].modulus = 8;
114 req->schedule_array[0].relative_position = 0;
115
116 ma_scell_ebcch_req(req);
117 }
118 break;
119 default:
120 break;
121 }
122 break;
123 case MA_CELL_RESELECTION:
124 switch(ctrl_req->action)
125 {
126 case START_MON_EBCCH:
127 /*for SI13 reading control*/
128 if(ctrl_req->si_to_read EQ UPDATE_SI13)
129 {
130 PALLOC(req, MPHC_SCELL_EBCCH_REQ);
131 req->schedule_array_size = 1;
132 req->schedule_array[0].modulus = 8;
133 req->schedule_array[0].relative_position = 0;
134
135 ma_scell_ebcch_req(req);
136 }
137 break;
138 default:
139 break;
140 }
141 break;
142 case MA_IDLE:
143 switch(ctrl_req->action)
144 {
145 case START_MON_EBCCH:
146 /*for SI13 reading control*/
147 if(ctrl_req->si_to_read EQ UPDATE_SI13)
148 {
149 PALLOC(req, MPHC_SCELL_EBCCH_REQ);
150 req->schedule_array_size = 1;
151 req->schedule_array[0].modulus = 8;
152 req->schedule_array[0].relative_position = 0;
153
154 ma_scell_ebcch_req(req);
155 }
156 break;
157 case START_MON_NBCCH:
158 {
159 USHORT si_mask = 0;
160 UBYTE tc = 0; /* refer to GSM Spec 05.02, clause 6.3.1.3 Mapping of BCCH data */
161 UBYTE i,k;
162
163 switch(ctrl_req->si_to_read)
164 {
165 case UPDATE_SI13:
166 gprs_read_si13(SI13_ON_NBCCH);
167 break;
168
169 case UPDATE_SI13_GSM:
170 {
171 PALLOC(scell_bcch_req, MPHC_SCELL_NBCCH_REQ);
172
173 scell_bcch_req->schedule_array_size = 1;
174 scell_bcch_req->schedule_array[0].modulus = 8;
175 scell_bcch_req->schedule_array[0].relative_position = 4;
176 ma_scell_nbcch_req(scell_bcch_req);
177 }
178 break;
179
180 case UNSPECIFIED_SI:
181 case COMPLETE_SI:
182 ma_clean_sys_buffer (IND_ALL_IDLE_SI);
183 ma_scell_full_nbcch();
184 break;
185
186 case UPDATE_SI1:
187 si_mask = IND_SI_1;
188 tc = (1<<0);
189 break;
190 case UPDATE_SI2_SI2BIS_OR_SI2TER:
191 si_mask = IND_SI_2 | IND_SI_2BIS | IND_SI_2TER;
192 tc = (1<<1) | (1<<4) | (1<<5);
193 break;
194 case UPDATE_SI3_SI4_SI7_OR_SI8:
195 si_mask = IND_SI_3 | IND_SI_4;
196 tc = (1<<2) | (1<<3) | (1<<6) | (1<<7);
197 break;
198 case UPDATE_SI9:
199 break;
200 }
201
202 if ( si_mask )
203 {
204 PALLOC(scell_bcch_req, MPHC_SCELL_NBCCH_REQ);
205 k = 0;
206 scell_bcch_req->schedule_array_size = k;
207 for ( i = 0; i < 8; i++ )
208 {
209 if ( (tc & (1 << i)) != 0 )
210 {
211 scell_bcch_req->schedule_array[k].modulus = 8;
212 scell_bcch_req->schedule_array[k].relative_position = i;
213 k++;
214 scell_bcch_req->schedule_array_size = k;
215 }
216 }
217 ma_clean_sys_buffer ( si_mask );
218 ma_scell_nbcch_req ( scell_bcch_req );
219 }
220 }
221 break;
222 case STOP_MON_CCCH:
223 /* PBCCH is present, stop all activities */
224 /*ma_stop_active_procs(STOP_PCH_READING | STOP_MEASUREMENTS);*/
225 pch_stop();
226 /*alr_data->gprs_data.pbcch = 1;*/
227 break;
228 case START_MON_CCCH:
229 if(alr_data->gprs_data.pbcch EQ TRUE)
230 {
231 pch_configure (NULL, PGM_NORMAL);
232 pch_save_pgm(PGM_NORMAL); /* reset saved pgm to REORG_CS */
233 pch_start_ccch_req();
234 }
235 break;
236
237 case LEAVING_PIM_PBCCH:
238 /* we are about to enter PAM or PTM */
239 if(alr_data->gprs_data.pbcch EQ TRUE)
240 {
241 TRACE_EVENT("leave pim");
242 alr_data->gprs_data.pim = FALSE;
243 pch_stop();
244 cb_stop();
245 nc_suspend();
246 }
247 else
248 {
249 TRACE_EVENT("huch pim");
250 }
251 break;
252 case LEAVING_PAM_PBCCH:
253 /* we are about to enter PTM or PIM */
254 if(alr_data->gprs_data.pbcch EQ TRUE)
255 {
256 /* do nothing, nothing should be active */
257 alr_data->gprs_data.pim = FALSE;
258 TRACE_EVENT("leave pam");
259 }
260 else
261 {
262 TRACE_EVENT("huch pam");
263 }
264 break;
265 case LEAVING_PTM_PBCCH:
266 /* we are about to enter PIM */
267 if(alr_data->gprs_data.pbcch EQ TRUE)
268 {
269 TRACE_EVENT("leave ptm");
270 alr_data->gprs_data.pim = FALSE;
271 pch_stop();
272 nc_suspend();
273 alr_data->gprs_data.ptm = FALSE;
274 }
275 else
276 {
277 TRACE_EVENT("huch ptm");
278 }
279 break;
280 case ENTER_PTM_PBCCH:
281 if(alr_data->gprs_data.pbcch EQ TRUE)
282 {
283 alr_data->gprs_data.ptm = TRUE;
284 alr_data->gprs_data.pim = FALSE;
285 nc_start_pbcch();
286 }
287 break;
288 case ENTER_PIM_PBCCH:
289 if(alr_data->gprs_data.pbcch EQ TRUE)
290 {
291 alr_data->gprs_data.pim = TRUE;
292 alr_data->gprs_data.ptm = FALSE;
293 nc_start_pbcch();
294 cb_start();
295 }
296 break;
297 case ENTER_PTM_BCCH:
298 /*
299 * convert counters and set NC process to IDLE
300 */
301 alr_data->gprs_data.pim = FALSE;
302 gprs_alr_nc_enter_ptm();
303 break;
304 default:
305 break;
306 }
307 break;
308 case MA_PTM:
309 switch(ctrl_req->action)
310 {
311 case START_MON_EBCCH:
312 /*for SI13 reading control*/
313 if(ctrl_req->si_to_read EQ UPDATE_SI13)
314 {
315 PALLOC(req, MPHC_SCELL_EBCCH_REQ);
316 req->schedule_array_size = 1;
317 req->schedule_array[0].modulus = 8;
318 req->schedule_array[0].relative_position = 0;
319
320 ma_scell_ebcch_req(req);
321 }
322 break;
323 case START_MON_NBCCH:
324 gprs_read_si13(SI13_ON_NBCCH);
325 break;
326 case START_MON_CCCH:
327 pch_configure (NULL, PGM_NORMAL);
328 if(alr_data->gprs_data.pbcch EQ TRUE)
329 pch_save_pgm(PGM_NORMAL); /* reset saved pgm to REORG_CS */
330 else
331 {
332 pch_save_pgm(PGM_REORG_CS); /* reset saved pgm to REORG_CS */
333 alr_data->pch_data.last_start_ccch_req.bs_pa_mfrms = NOT_PRESENT_8BIT;
334 }
335
336 pch_start_ccch_req();
337 break;
338 /*
339 * This case is necessary to stop ccch monitoring in MA_PTM
340 * This is required for Testmode A/B
341 */
342 case STOP_MON_CCCH:
343 if(grlc_test_mode_active())
344 {
345 ma_stop_active_procs(STOP_PCH_READING | STOP_MEASUREMENTS);
346 TRACE_EVENT("STOP_MON_CCCH: TESTMODE A/B is running !!!!");
347 }
348 break;
349 case ENTER_PTM_BCCH:
350 /*
351 * convert counters and set NC process to IDLE
352 */
353 gprs_alr_nc_enter_ptm();
354 break;
355 default:
356 break;
357 }
358 break;
359
360 case MA_CON_EST:
361 switch(ctrl_req->action)
362 {
363 case ENTER_PTM_BCCH:
364 /*
365 * convert counters and set NC process to IDLE
366 */
367 gprs_alr_nc_enter_ptm();
368 break;
369 default:
370 break;
371 }
372 break;
373 default:
374 break;
375 }
376 PFREE (ctrl_req);
377
378 }
379 /*
380 +--------------------------------------------------------------------+
381 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
382 | STATE : code ROUTINE : gprs_alr_check_packet_paging
383 +--------------------------------------------------------------------+
384
385 PURPOSE :
386
387 */
388
389 #define P1_REST_OCTET_LEN 5
390 #define GSM408_SPARE_PADDING 0x2b
391
392 /*lint -e749 (Info -- local enumeration constant not referenced) */
393 enum t_p1_ie { NLN = 0,
394 PRIO1,
395 PRIO2,
396 GRCI,
397 PPI1,
398 PPI2
399 };
400 /*lint +e749 (Info -- local enumeration constant not referenced) */
401
402 #define NEXT_BIT(bit_pos,byte_pos) if( (bit_pos >>=1) == 0 ) { bit_pos=0x80; byte_pos++;}
403
404 LOCAL enum t_p1_ie p1_ie;
405 LOCAL UBYTE element_size[PPI2+1] = {
406 3,
407 3,
408 3,
409 0,
410 1,
411 1
412 };
413
414
415
416 BOOL gprs_alr_check_packet_paging(UBYTE* frame, UBYTE which)
417 {
418 UBYTE byte_pos = 0;
419 UBYTE bit = 0x80;
420 UBYTE *frame_ptr = frame;
421
422 ALR_TRACE_GPRS("check packet paging");
423 /* point after Mobile Identity 1 */
424 frame = frame + 4 + frame[4] + 1;
425 /* check if Mobile Identity 2 is present */
426 if (frame[0] EQ 0x17)
427 /* skip Mobile Identity 2 */
428 /* rest octets = start of mob 2 + len of mob 2 + TL */
429 frame= frame + frame[1] + 2;
430
431 if( frame - frame_ptr >= MAX_L2_FRAME_SIZE )
432 return FALSE;
433
434 /* decode packet paging */
435 for(p1_ie = NLN; p1_ie < PPI2+1;p1_ie++)
436 {
437 if((frame[byte_pos] & bit) EQ
438 (GSM408_SPARE_PADDING & bit))
439 {
440 /* L:
441 * - element is not used
442 * - check next bit for next element
443 */
444 if(p1_ie NEQ (which+GRCI))
445 {
446 NEXT_BIT(bit,byte_pos);/*lint!e720 (Info -- Boolean test of assignment) */
447 }
448 else
449 {
450 ALR_TRACE_GPRS("no packet");
451 return FALSE;
452 }
453 }
454 else
455 {
456 /* H:
457 * - element is used
458 * - skip the bits used by this element
459 * except PPIx
460 */
461 ALR_TRACE_GPRS("element used");
462 if(p1_ie NEQ (which+GRCI))
463 {
464 UBYTE i;
465 for(i=element_size[p1_ie]+1; i > 0; i--)
466 {
467 NEXT_BIT(bit,byte_pos);/*lint!e720 (Info -- Boolean test of assignment) */
468 }
469 }
470 else
471 {
472 ALR_TRACE_GPRS("packet paging");
473 return TRUE;
474 }
475 }
476 }
477 return FALSE;
478 }
479
480 /*
481 +--------------------------------------------------------------------+
482 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
483 | STATE : code ROUTINE : gprs_alr_check_packet_paging_2
484 +--------------------------------------------------------------------+
485
486 PURPOSE :
487
488 */
489
490 /*lint -e749 (Info -- local enumeration constant not referenced) */
491 enum t_p2_ie {
492 p2CN3 = 0,
493 p2NLN,
494 p2PRIO1,
495 p2PRIO2,
496 p2PRIO3,
497 p2PPI3
498 };
499 /*lint -e749 (Info -- local enumeration constant not referenced) */
500
501 LOCAL enum t_p2_ie p2_ie;
502 LOCAL UBYTE p2_element_size[p2PPI3+1] = {
503 2,
504 3,
505 3,
506 3,
507 3,
508 1
509 };
510
511 BOOL gprs_alr_check_packet_paging_2(UBYTE* frame, UBYTE which)
512 {
513 UBYTE byte_pos = 0;
514 UBYTE bit = 0x80;
515
516 if(which NEQ 3) return FALSE;
517 ALR_TRACE_GPRS("check packet paging 2");
518 frame += frame[13]+14;
519 /* decode packet paging */
520 for(p2_ie = p2CN3; p2_ie < p2PPI3+1;p2_ie++)
521 {
522 if((frame[byte_pos] & bit) EQ
523 (GSM408_SPARE_PADDING & bit))
524 {
525 /* L:
526 * - element is not used
527 * - check next bit for next element
528 */
529 if(p2_ie NEQ p2PPI3)
530 {
531 NEXT_BIT(bit,byte_pos);/*lint!e720 (Info -- Boolean test of assignment) */
532 }
533 else
534 {
535 ALR_TRACE_GPRS("no packet");
536 return FALSE;
537 }
538 }
539 else
540 {
541 /* H:
542 * - element is used
543 * - skip the bits used by this element
544 * except PPIx
545 */
546 ALR_TRACE_GPRS("element used");
547 if(p2_ie NEQ p2PPI3)
548 {
549 UBYTE i;
550 for(i=p2_element_size[p2_ie]+1; i > 0; i--)
551 {
552 NEXT_BIT(bit,byte_pos);/*lint!e720 (Info -- Boolean test of assignment) */
553 }
554 }
555 else
556 {
557 ALR_TRACE_GPRS("packet paging");
558 return TRUE;
559 }
560 }
561 }
562 return FALSE;
563 }
564
565 /*
566 +--------------------------------------------------------------------+
567 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
568 | STATE : code ROUTINE : gprs_alr_store_ptmsi |
569 +--------------------------------------------------------------------+
570
571 PURPOSE :
572
573 */
574 void gprs_alr_store_ptmsi(UBYTE indic, ULONG tmsi)
575 {
576 alr_data->gprs_data.v_ptmsi = indic;
577 alr_data->gprs_data.ptmsi = tmsi;
578 TRACE_EVENT_P2("v: %d ptmsi: %x", indic, tmsi);
579 }
580
581 /*
582 +--------------------------------------------------------------------+
583 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
584 | STATE : code ROUTINE : gprs_alr_store_ptmsi |
585 +--------------------------------------------------------------------+
586
587 PURPOSE : Store the candidate PTMSI
588
589 */
590 void gprs_alr_store_ptmsi2(UBYTE indic2, ULONG tmsi2)
591 {
592 alr_data->gprs_data.v_ptmsi2 = indic2;
593 alr_data->gprs_data.ptmsi2 = tmsi2;
594 TRACE_EVENT_P2("v: %d ptmsi: %x", indic2, tmsi2);
595 }
596
597 /*
598 +--------------------------------------------------------------------+
599 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
600 | STATE : code ROUTINE : gprs_alr_check_ptmsi |
601 +--------------------------------------------------------------------+
602
603 PURPOSE :
604
605 */
606 BOOL gprs_alr_check_ptmsi(ULONG ptmsi_pag)
607 {
608
609 if((alr_data->gprs_data.v_ptmsi AND
610 alr_data->gprs_data.ptmsi EQ ptmsi_pag) OR
611 (alr_data->gprs_data.v_ptmsi2 AND
612 alr_data->gprs_data.ptmsi2 EQ ptmsi_pag))
613 {
614 ALR_TRACE_GPRS("ptmsi match");
615 ma_pch_paging_ind (ID_PTMSI, CN_PACKET);
616 return TRUE;
617 }
618
619 return FALSE;
620 }
621
622 /*
623 +--------------------------------------------------------------------+
624 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
625 | STATE : code ROUTINE : gprs_alr_check_downlink_assign
626 +--------------------------------------------------------------------+
627
628 PURPOSE :
629
630 */
631 void gprs_alr_check_downlink_assign(T_MPHC_DATA_IND* data_ind)
632 {
633 /* check dl bit */
634 if(data_ind->l2_frame.content[3] & 0x20) {
635 ma_send_unitdata (data_ind);
636 }
637 }
638
639 /*
640 +--------------------------------------------------------------------+
641 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
642 | STATE : code ROUTINE : gprs_read_si13 |
643 +--------------------------------------------------------------------+
644
645 PURPOSE :
646
647 */
648 BOOL gprs_check_read_si13_only(UBYTE si13_position)
649 {
650 if(gprs_support AND
651 si13_position EQ SI13_ON_NBCCH)
652 return FALSE;
653 else
654 return TRUE;
655 }
656
657 LOCAL BOOL gprs_read_si13(UBYTE si13_position)
658 {
659 ALR_TRACE_GPRS("read si13");
660
661 if(gprs_support AND
662 si13_position EQ SI13_ON_NBCCH)
663 {
664 PALLOC(scell_bcch_req, MPHC_SCELL_NBCCH_REQ);
665 /*
666 * we want to read SI13 on TC=4 which has to be send at least
667 * on every 4th consecutive occurence of TC=4
668 */
669 scell_bcch_req->schedule_array_size = 1;
670 scell_bcch_req->schedule_array[0].modulus = 8;
671 scell_bcch_req->schedule_array[0].relative_position = 4;
672 ma_scell_nbcch_req(scell_bcch_req);
673 return FALSE;
674 }
675 else return TRUE;
676 }
677
678 /*
679 +--------------------------------------------------------------------+
680 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
681 | STATE : code ROUTINE : gprs_stop |
682 +--------------------------------------------------------------------+
683
684 PURPOSE :
685
686 */
687 void gprs_alr_init(void)
688 {
689 ALR_TRACE_GPRS("gprs_alr_init");
690 alr_data->gprs_data.ign_pgm = FALSE;
691 alr_data->gprs_data.pbcch = FALSE;
692 alr_data->gprs_data.ptm = FALSE;
693 alr_data->gprs_data.check_bsic = FALSE;
694 alr_data->gprs_data.sync_only = FALSE;
695 alr_data->gprs_data.pcco_active= FALSE;
696 alr_data->nc_sync_with_grr = FALSE;
697 gprs_support = FALSE;
698 }
699
700 /*
701 +--------------------------------------------------------------------+
702 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
703 | STATE : code ROUTINE : gprs_alr_tb_meas_ind |
704 +--------------------------------------------------------------------+
705
706 PURPOSE :
707
708 */
709 LOCAL void gprs_alr_tb_meas_ind (T_TB_MEAS_IND *report)
710 {
711 ALR_TRACE_GPRS("tb_meas_ind");
712 switch(GET_STATE(STATE_MA))
713 {
714 case MA_PTM:
715 /*Measurement Report in Packet Transfer Mode*/
716 {
717 USHORT temp;
718 USHORT index;
719 UBYTE diff;
720 UBYTE i,lim;
721 T_NC* pcell;
722
723 if(report->tb_meas_result[0].arfcn EQ NOT_PRESENT_16BIT)
724 {
725 lim = alr_data->nc_data.c_ba_arfcn;
726 }
727 else
728 {
729 lim = TB_BA_LIST_SIZE;
730 }
731
732 /*
733 * reduce the time for next sync
734 * Decrement the 10sec timer counter variable by 2
735 */
736 alr_data->nc_data.c_ncsync_tim = alr_data->nc_data.c_ncsync_tim-2;
737 if ((signed char)( alr_data->nc_data.c_ncsync_tim) < 0)
738 alr_data->nc_data.c_ncsync_tim = 0;
739
740 if( alr_data->nc_data.c_ncsync_tim==0 )
741 {
742 /* 10 sec have elapsed. Perform all requisite tasks */
743 nc_ncsync_tim_expiry();
744 }
745
746 for (pcell=&alr_data->nc_data.cell[0], i = 0; i < lim; i++,pcell++)
747 {
748 if(lim EQ alr_data->nc_data.c_ba_arfcn)
749 {
750 index = i;
751 }
752 else
753 {
754 /* For all cells look if it is in BA(BCCH) */
755 switch(index = nc_get_index(ARFCN_TO_G23(report->tb_meas_result[i].arfcn)))
756 {
757 case LAST_BSIC_REQ:
758 case NOT_PRESENT_16BIT:
759 continue;
760 default:
761 break;
762 }
763 }
764 /*
765 * the ncell is in the list
766 * so store the rxlev values
767 */
768
769 if (alr_data->nc_data.cell[index].c_rxlev EQ NOT_PRESENT_8BIT)
770 {
771 /*
772 * if it is a new cell, build an average from the first value
773 * to speed up fb sb read
774 */
775 if ((signed short) (report->tb_meas_result[i].rxlev) < 0)
776 {
777 report->tb_meas_result[i].rxlev = 0;
778 }
779
780 alr_data->nc_data.cell[index].rxlev[0] = report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
781 alr_data->nc_data.cell[index].rxlev[1] = report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
782 alr_data->nc_data.cell[index].rxlev[2] = report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
783 alr_data->nc_data.cell[index].rxlev[3] = report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
784 alr_data->nc_data.cell[index].rxlev[4] = report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
785 alr_data->nc_data.cell[index].c_rxlev = 0;
786 }
787 else
788 {
789 if ((signed short) (report->tb_meas_result[i].rxlev) < 0)
790 report->tb_meas_result[i].rxlev = 0;
791
792 alr_data->nc_data.cell[index].rxlev[alr_data->nc_data.cell[index].c_rxlev++] =
793 report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas;
794
795 if (alr_data->nc_data.cell[index].c_rxlev >= 5)
796 alr_data->nc_data.cell[index].c_rxlev = 0;
797 }
798
799 temp = (USHORT)(alr_data->nc_data.cell[index].rxlev[0] +
800 alr_data->nc_data.cell[index].rxlev[1] +
801 alr_data->nc_data.cell[index].rxlev[2] +
802 alr_data->nc_data.cell[index].rxlev[3] +
803 alr_data->nc_data.cell[index].rxlev[4]);
804
805 alr_data->nc_data.cell[index].rxlev_average = (UBYTE)(temp / 5);
806 /*
807 * store the results seperately for averaging when NC=1 or NC=2
808 */
809 #ifdef GPRS
810 if(alr_data->nwctrl_meas_active)
811 {
812 pcell->nc_rxlev += (report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas);
813 pcell->c_nc_rxlev++;
814 }
815 #endif
816
817 TRACE_EVENT_P3("%d %d rx: %d ",i, alr_data->nc_data.cell[i].ba_arfcn,
818 report->tb_meas_result[i].rxlev / report->tb_meas_result[i].num_meas);
819
820 switch (alr_data->nc_data.cell[index].status)
821 {
822 case INACTIVE:
823 nc_set_status (index, IDLE);
824 break;
825 case EXCLUDED:
826 diff = (UBYTE)(alr_data->nc_data.cell[index].rxlev_average -
827 alr_data->nc_data.cell[index].last_rxlev);
828
829 if (diff < 128 AND diff >= 6)
830 {
831 /* result is positive and more than 6 dBm */
832 nc_set_status (index, IDLE);
833 }
834 break;
835 default:
836 break;
837 }
838
839 } /* for all */
840 PFREE(report);
841
842 nc_check_activity();
843 }
844 break;
845 default:
846 PFREE(report);
847 break;
848 }
849 }
850
851
852 /*
853 +--------------------------------------------------------------------+
854 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
855 | STATE : code ROUTINE : gprs_alr_nc_enter_ptm |
856 +--------------------------------------------------------------------+
857
858 PURPOSE : After the Packet Access Phase we enter Packet Transfer
859 Mode and have to do Measurements and Cell Reselection like
860 in Idle Mode.
861 */
862
863 LOCAL void gprs_alr_nc_enter_ptm (void)
864 {
865 nc_resume(); /* set NC_STATE to IDLE */
866
867 alr_data->nc_data.c_reports = (alr_data->nc_data.c_reports*10)/alr_data->nc_data.max_reports;
868 alr_data->nc_data.max_reports = 10;
869 alr_data->nc_data.cell[LAST_BSIC_REQ].status = INACTIVE;
870
871 TRACE_EVENT_P2("glob reps: %d max_report: %d", alr_data->nc_data.c_reports, alr_data->nc_data.max_reports);
872 }
873
874 /*
875 +--------------------------------------------------------------------+
876 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
877 | STATE : code ROUTINE : gprs_check_page_mode |
878 +--------------------------------------------------------------------+
879
880 PURPOSE : Do not change the page mode configuration in L1
881 if ing_pgm is set. ie. we have to stay in REORG.
882
883 */
884 void gprs_check_page_mode(T_MPHC_DATA_IND* data_ind)
885 {
886 if(alr_data->gprs_data.ign_pgm EQ TRUE)
887 {
888 pch_check_page_mode_cr(data_ind);
889 }
890 else
891 {
892 pch_check_page_mode(data_ind);
893 }
894 }
895
896 /*
897 +--------------------------------------------------------------------+
898 | PROJECT : GSM-PS (6103) MODULE : ALR_GPRS |
899 | STATE : code ROUTINE : gprs_alr_is_supported |
900 +--------------------------------------------------------------------+
901
902 PURPOSE : This function returns whether GPRS is supported in
903 the cell.
904
905 */
906 GLOBAL BOOL gprs_alr_is_supported( void )
907 {
908 return( gprs_support EQ TRUE );
909 }
910
911 void set_gprs_support( UBYTE support )
912 {
913 gprs_support = support;
914 }
915
916 #endif /* ALR_GPRS_C */
917
918