⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smi_reg.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/* 
+----------------------------------------------------------------------------- 
|  Project :  GSM-F&D (8411)
|  Modul   :  SMI_REG
+----------------------------------------------------------------------------- 
|  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 Modul defines the registration/deregestration
|             handling for the component SMI of the mobile station
+----------------------------------------------------------------------------- 
*/ 

#ifndef SMI_REG_C
#define SMI_REG_C
#endif

#define ENTITY_SMI

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

#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"

#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"

/*==== CONSTANTS ==================================================*/

/*==== EXPORT =====================================================*/
/*EXTERN GLOBAL void reg_CfunCnf (T_ACI_AT_CMD cmdId);*/
/*==== VARIABLES ==================================================*/

LOCAL T_ACI_AT_CMD currRegCmd   = AT_CMD_NONE;
LOCAL T_ACI_AT_CMD currAbrtCmd  = AT_CMD_NONE;

LOCAL BOOL pinCnf  = FALSE;
LOCAL BOOL pinNeed = FALSE;

LOCAL T_ACI_COPS_MOD  COPSmode;     /* holds cops mode             */
LOCAL T_ACI_COPS_FRMT COPSfrmt;     /* holds cops format           */
LOCAL CHAR*           COPSoper;     /* holds cops operator         */
LOCAL SHORT           COPSstartidx; /* start index of operator list*/
LOCAL SHORT           COPSlastidx;  /* last index of operator list */
LOCAL T_ACI_COPS_LST  COPSlst;      /* operator list               */
LOCAL T_ACA_RSN       COPSqryrsn;   /* reason for query cops param.*/

LOCAL T_ACI_CREG_STAT CREGstat;     /* registration status         */

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

GLOBAL T_ACI_RETURN reg_powerOff (void);

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : SMI_REG                  |
| STATE   : code                  ROUTINE : reg_initialize           |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to initialize this modul.
*/
GLOBAL void reg_initialize (BOOL isStartup)
{
  currRegCmd  = AT_CMD_NONE;
  currAbrtCmd = AT_CMD_NONE;

  if (isStartup)
    COPSmode   = COPS_MOD_Auto;

  COPSoper     = NULL;
  COPSstartidx = 0;
  COPSlastidx  = 0;

  {
    USHORT i;

    for (i = 0; i < MAX_OPER; i++)
    {
      COPSlst[i].status     = COPS_STAT_NotPresent;
      COPSlst[i].longOper   = NULL;
      COPSlst[i].shortOper  = NULL;
      COPSlst[i].numOper[0] = NULL_TERM;
    }

    COPSqryrsn = RSN_NONE;
  
    if (ui_isScrnWidthMin ())
      COPSfrmt = COPS_FRMT_Short;
    else
      COPSfrmt = COPS_FRMT_Long;
  }

  CREGstat = CREG_STAT_Unknown;

  pinCnf   = FALSE;
  pinNeed  = FALSE;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : SMI_REG                  |
| STATE   : code                  ROUTINE : reg_powerOn              |
+--------------------------------------------------------------------+

  PURPOSE : Function for handling of the power on signal. It is
            called after initialization of the PS or from the
            keystroke sequence interpreter.
*/
GLOBAL T_ACI_RETURN reg_powerOn ()
{
  T_ACI_RETURN ret = AT_CMPL; /* holds status information */

  TRACE_FUNCTION ("reg_power_on ()");

  if (mmi_data->state EQ MMI_OFF AND
      currRegCmd      EQ AT_CMD_NONE)
  {
    aca_init (FALSE);

    currRegCmd = AT_CMD_CFUN;

    /*
     *---------------------------------------------------------------
     * check if the remote communication partner has switch on the
     * mobile
     *---------------------------------------------------------------
     */
#if 0
    {
      T_ACI_CFUN_FUN  fun;
      T_ACI_CPIN_RSLT code;
      T_ACI_CME_ERR   error;

      qAT_PlusCFUN (CMD_SRC_LCL, &fun);
      qAT_PlusCPIN (CMD_SRC_LCL, &code);

      if (fun EQ CFUN_FUN_Full)
      {
        switch (code)
        {
          case (CPIN_RSLT_SimReady):
            rAT_OK (currRegCmd);
            break;

          case (CPIN_RSLT_NotPresent):
            error = CME_ERR_SimNotIns;
            break;

          case (CPIN_RSLT_SimPinReq):
            error = CME_ERR_SimPinReq;
            break;

          case (CPIN_RSLT_SimPukReq):
            error = CME_ERR_SimPukReq;
            break;

          case (CPIN_RSLT_PhSimPinReq):
            error = CME_ERR_PhSimPinReq;
            break;
        }

        if (code NEQ CPIN_RSLT_SimReady)
          rAT_PlusCME (currRegCmd, code);

        return ret;
      }
    }
#endif

    /*
     *---------------------------------------------------------------
     * the remote communication partner has not switched on the
     * mobile, perform normal processing
     *---------------------------------------------------------------
     */
    ret = sAT_PlusCFUN (CMD_SRC_LCL,
                        CFUN_FUN_Full,
                        CFUN_FUN_NotPresent);

    /*
     *---------------------------------------------------------------
     * process result code of ACI function call
     *---------------------------------------------------------------
     */
    switch (ret)
    {
      case (AT_CMPL):
        rAT_OK (currRegCmd);
        break;

      case (AT_EXCT):
        break;

      default:
        rAT_PlusCME (currRegCmd, CME_ERR_Unknown);
        break;
    }
  }

  return ret;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : SMI_REG                  |
| STATE   : code                  ROUTINE : reg_powerOff             |
+--------------------------------------------------------------------+

  PURPOSE : Function for handling the power off signal. It is called
            after the raise of specific conditions in the keystroke
            sequence interpreter or in the power handling circuit.
*/
GLOBAL T_ACI_RETURN reg_powerOff (void)
{
  T_ACI_RETURN ret = AT_CMPL; /* holds status information */

  TRACE_FUNCTION ("reg_powerOff ()");

  if (mmi_data->state NEQ MMI_OFF AND
      currRegCmd      EQ  AT_CMD_NONE)
  {
    ret = sAT_PlusCFUN (CMD_SRC_LCL,
                        CFUN_FUN_Minimum,
                        CFUN_FUN_NotPresent);

    currRegCmd = AT_CMD_CFUN;

    /*
     *---------------------------------------------------------------
     * process result code of ACI function call
     *---------------------------------------------------------------
     */
    switch (ret)
    {
      case (AT_CMPL):
        rAT_OK (currRegCmd);
        break;

      case (AT_EXCT):
        break;

      default:
        rAT_PlusCME (currRegCmd, CME_ERR_Unknown);
        break;
    }
  }
  else
  {
    switch (currRegCmd)
    {
      case (AT_CMD_COPS):
      case (AT_CMD_CFUN):
        if (currAbrtCmd EQ AT_CMD_ABRT)
        {
          ret = AT_CMPL;
        }
        else
        {
          if (aca_setAbrtCmd (currRegCmd))
          {
            ret = sAT_Abort (CMD_SRC_LCL, currRegCmd);

            currAbrtCmd = AT_CMD_ABRT;

            switch (ret)
            {
              case (AT_EXCT):
                break;

              case (AT_CMPL):
                rAT_OK (currAbrtCmd);
                break;

              default:
                rAT_PlusCME (currAbrtCmd, CME_ERR_FailedToAbort);
                break;
            }
          }
          else
          {
            ui_signal (UI_SIG_UNHND_CME_ERR, CME_ERR_FailedToAbort);
            ret = AT_CMPL;
          }
        }
        break;

      default:
        ui_signal (UI_SIG_UNHND_CME_ERR, CME_ERR_FailedToAbort);
        ret = AT_CMPL;
        break;
    }
  }

  return ret;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : SMI_REG                  |
| STATE   : code                  ROUTINE : reg_CfunCnf              |
+--------------------------------------------------------------------+

  PURPOSE : This function is called to indicate the correct processing
            of the phone functionality request. Network registration
            is started if necessary.
*/
GLOBAL void reg_CfunCnf (T_ACI_AT_CMD cmdId)
{
  TRACE_FUNCTION ("reg_CfunCnf ()");

  if (cmdId EQ currRegCmd)
    currRegCmd = AT_CMD_NONE;
  else
    return;

  if (currAbrtCmd EQ AT_CMD_ABRT)
  {
    currAbrtCmd = AT_CMD_NONE;

    reg_powerOff();
    return;
  }

  if (mmi_data->state EQ MMI_OFF)
  {
    aca_setupVolume (csf_getVolume (VT_AUDIO_IN),
                     csf_getVolume (VT_AUDIO_OUT));

    ui_signal (UI_SIG_POWER_UP);

    /*
     *---------------------------------------------------------------
     * check if the remote communication partner has already
     * registered the mobile
     *---------------------------------------------------------------
     */   
#if 0
    {
      T_ACI_CREG_STAT stat;

      qAT_PlusCREG (CMD_SRC_LCL, &stat);

      if (stat EQ CREG_STAT_Reg OR
          stat EQ CREG_STAT_Roam  )
      {
        if (ui_isScrnWidthMin ())
          COPSfrmt = COPS_FRMT_Short;
        else
          COPSfrmt = COPS_FRMT_Long;

        COPSoper        = NULL;
        currRegCmd      = AT_CMD_COPS;
        mmi_data->state = MMI_WAIT_FOR_REG;

        rAT_OK (currRegCmd);

        return;
      }
    }
#endif
    /*
     *---------------------------------------------------------------
     * the remote communication partner has not yet registered the
     * mobile, perform normal processing
     *---------------------------------------------------------------
     */   
    /*
     *---------------------------------------------------------------
     * manual registration is started via user interface or
     * via keystroke sequences entered using pei_config
     *---------------------------------------------------------------
     */
    /*if (COPSmode EQ COPS_MOD_Auto)*/
      reg_startReg ();
  }
  else
  {
    COPSmode   = COPS_MOD_Auto;
    ui_signal (UI_SIG_POWER_DOWN);
    mmi_data->state = MMI_OFF;
  }
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : SMI_REG                  |
| STATE   : code                  ROUTINE : reg_CfunRej              |
+--------------------------------------------------------------------+

  PURPOSE : This function is called to indicate the incorrect
            processing of the phone functionality request. The
            behaviour of the SMI depends on the transfered error
            code.

            <err>: error code
*/
GLOBAL void reg_CfunRej (T_ACI_AT_CMD cmdId, T_ACI_CME_ERR err)
{
  TRACE_FUNCTION ("reg_CfunRej ()");

  if (cmdId EQ currRegCmd)
    currRegCmd = AT_CMD_NONE;

  if (currAbrtCmd EQ AT_CMD_ABRT)
  {
    currAbrtCmd = AT_CMD_NONE;
    
    ui_signal (UI_SIG_UNHND_CME_ERR, CME_ERR_FailedToAbort);
    return;
  }

  if (mmi_data->state EQ MMI_OFF)
  {
    aca_setupVolume (csf_getVolume (VT_AUDIO_IN),
                     csf_getVolume (VT_AUDIO_OUT));

    ui_signal (UI_SIG_POWER_UP);

    switch (err) 
    {
      case (CME_ERR_SimPinReq):
        ui_signal (UI_SIG_ENTER_PIN);
        pinNeed         = TRUE;
        mmi_data->state = MMI_WAIT_FOR_PIN;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -