view src/g23m-gprs/grr/grr_measp.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents fa8dc04885d8
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  GPRS (8441)
|  Modul   :  GRR
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This module implements primitive handler functions for service
|             MEAS of entity GRR.
+----------------------------------------------------------------------------- 
*/ 

#ifndef GRR_MEASP_C
#define GRR_MEASP_C
#endif

#define ENTITY_GRR

/*==== INCLUDES =============================================================*/

#include "typedefs.h"   /* to get Condat data types */
#include <string.h>
#include "vsi.h"        /* to get a lot of macros */
#include "macdef.h"  
#include "gprs.h"  
#include "gsm.h"        /* to get a lot of macros */
#include "ccdapi.h"     /* to get CCD API */
#include "cnf_grr.h"    /* to get cnf-definitions */
#include "mon_grr.h"    /* to get mon-definitions */
#include "prim.h"       /* to get the definitions of used SAP and directions */
#include "message.h"  
#include "grr.h"        /* to get the global entity definitions */
#include "grr_f.h"
#include "grr_measf.h"  /* to get the definitions for interference measurements */
#include "grr_css.h"

/*==== CONST ================================================================*/

/*==== LOCAL VARS ===========================================================*/

/*==== PRIVATE FUNCTIONS ====================================================*/
/*
+------------------------------------------------------------------------------
| Function    : meas_p_meas_order_ind
+------------------------------------------------------------------------------
| Description : ...
|
| Parameters  : *d_meas_order - Ptr to packet measurement order message
|
+------------------------------------------------------------------------------
*/
GLOBAL void meas_p_meas_order_ind ( T_D_MEAS_ORDER *d_meas_order )
{ 
  T_NC_ORDER ctrl_order;
  UBYTE      valid_pars;

  TRACE_FUNCTION( "meas_p_meas_order_ind" );
  
  switch( GET_STATE( MEAS ) )
  {
    case MEAS_NULL     :
    case MEAS_IDLE     :
    case MEAS_ACCESS   :
    case MEAS_TRANSFER :
      valid_pars = meas_em_prcs_meas_order( d_meas_order, &ctrl_order );

      if( ( valid_pars & PMO_EXT_VLD ) EQ PMO_EXT_VLD )
      {
        switch( GET_STATE( MEAS_EM ) )
        {
          case MEAS_EM_REP_REQ:
            meas_em_stop_req( );
           
            /*lint -fallthrough*/

          default:
            meas_em_valid_pmo( );
            meas_em_process_t3178( );
            break;
        }
      }
      if( ( valid_pars & PMO_NC_VLD ) EQ PMO_NC_VLD )
      {
        sig_meas_cs_meas_order( ctrl_order );
      }
      break;

    default:
      TRACE_ERROR( "PACKET MEASUREMENT ORDER unexpected 2" );
      break;
  }
} /* meas_p_meas_order_ind() */

/*==== PUBLIC FUNCTIONS =====================================================*/

/*
+------------------------------------------------------------------------------
| Function    : meas_t_im_sync
+------------------------------------------------------------------------------
| Description : Handles the timeout of timer T_IM_SYNC
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void meas_t_im_sync ( void )
{ 
  TRACE_FUNCTION( "meas_t_im_sync" );
  
  meas_im_timer_elapsed( );
} /* meas_t_im_sync() */

/*
+------------------------------------------------------------------------------
| Function    : meas_t3178
+------------------------------------------------------------------------------
| Description : Handles the timeout of timer T3178
|
| Parameters  : void
|
+------------------------------------------------------------------------------
*/
GLOBAL void meas_t3178 ( void )
{ 
  TRACE_FUNCTION( "meas_t3178" );

  TRACE_EVENT( "T3178 timeout" );

  switch( GET_STATE( MEAS ) )
  {
    case MEAS_IDLE:
      switch( GET_STATE( MEAS_EM ) )
      {
        case MEAS_EM_NULL:
          meas_em_start( );
          
          SET_STATE( MEAS_EM, MEAS_EM_REP_REQ );
          break;

        default:
          meas_em_process_t3178( );
          break;
      }
      break;

    case MEAS_ACCESS:
    case MEAS_TRANSFER:
      /*
       * if the MS is in packet transfer mode when the measurement shall start,
       * the MS shall wait until it returns to packet idle mode
       */
      switch( GET_STATE( MEAS_EM ) )
      {
        case MEAS_EM_NULL:
        case MEAS_EM_REP_REQ:
          SET_STATE( MEAS_EM, MEAS_EM_PENDING );

          meas_em_process_t3178( );
          break;
        
        case MEAS_EM_PMR_SENDING:
        case MEAS_EM_PENDING:
          meas_em_process_t3178( );
          break;
      }
      break;

    default:
      TRACE_ERROR( "T3178 timeout unexpected 3" );
      break;
  }  
} /* meas_t3178() */

/*
+------------------------------------------------------------------------------
| Function    : meas_tb_rxlev_sc_req
+------------------------------------------------------------------------------
| Description : Handles the primitive TB_RXLEV_SC_REQ
|
| Parameters  : *tb_rxlev_sc_req - Ptr to primitive payload
|
+------------------------------------------------------------------------------
*/
GLOBAL void meas_tb_rxlev_sc_req ( T_TB_RXLEV_SC_REQ *tb_rxlev_sc_req )
{ 
  TRACE_FUNCTION( "meas_tb_rxlev_sc_req" );
  
  switch( GET_STATE( MEAS ) )
  {
    case MEAS_NULL:
      break;

    case MEAS_IDLE:
    case MEAS_ACCESS:
      if( grr_is_pbcch_present( ) EQ FALSE )
      {
        meas_c_val_update_pim( tb_rxlev_sc_req->sc_rxlev );
        grr_cgrlc_pwr_ctrl_req( TRUE );
      }
      break;

    default:
      TRACE_ERROR( "TB_RXLEV_SC_REQ unexpected" );
      break;
  }

  PFREE( tb_rxlev_sc_req );

} /* meas_tb_rxlev_sc_req() */