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

📄 wap_pei.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
  TRACE_FUNCTION("WAP_Pei_SIGNAL"); 
  return PEI_OK;
}



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_exit            |
+--------------------------------------------------------------------+
 
  PURPOSE : Close Resources and terminate
 
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_exit (void)
#else
GLOBAL T_PEI_RETURN pei_exit (void)
#endif
{
#ifdef WAP_USECACHE
#ifndef WAP_CCACHESIZE
  extern const memSizeType cCacheSize;       /* is initialized in capimem.h*/
#else
  const memSizeType cCacheSize = WAP_CCACHESIZE;
#endif
#endif
  
  TRACE_FUNCTION ("wap pei_exit()")

#ifdef OPTION_MULTIPLE_INSTANCE
    ULONG i;
#endif /* OPTION_MULTIPLE_INSTANCE */


  /*
   * Check and clean AUS and WAP-LIB related stuff
   */ 
  /*XXX  not implemented yet XXX*/
     
  
  /*
   * clean up communication
   */
#ifdef OPTION_MULTIPLE_INSTANCE
  /*
   * close channels for all instances
   * should not be neccessary here..
   */
  for (i=0;i<WAP_INSTANCES;i++)
  {
    if (wap_data_base[i].dti_state NEQ DTI_CLOSED)
    {    
      dti_close
      (
        wap_hDTI,
        i,
        WAP_DTI_DN_INTERFACE,
        WAP_DTI_DN_CHANNEL,
        FALSE
      );
      wap_data_base[i].dti_state = DTI_CLOSED;
    }
  }
#else  /* OPTION_MULTIPLE_INSTANCE */
  if (wap_data_base.dti_state NEQ DTI_CLOSED)
  {    
    dti_close
    (
      wap_hDTI,
      WAP_DTI_DN_DEF_INSTANCE,
      WAP_DTI_DN_INTERFACE,
      WAP_DTI_DN_CHANNEL,
      FALSE
    );
    wap_data_base.dti_state = DTI_CLOSED;
  }
#endif /* OPTION_MULTIPLE_INSTANCE */

  vsi_c_close (VSI_CALLER hCommACI);
  hCommACI = VSI_ERROR;

  vsi_c_close (VSI_CALLER hCommUDP);
  hCommUDP = VSI_ERROR;

  /*
   * Shut down dtilib communication
   */
  dti_deinit(wap_hDTI);

  /*
   * Close WAP timer
   */
  wap_close_timer ();

  exit_flag = TRUE;

  return PEI_OK;
}



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_run             |
+--------------------------------------------------------------------+
 
  PURPOSE : Process Primitives, main loop is located in the
            Protocol Stack Entity
 
*/

#if !defined (NEW_FRAME)
GLOBAL T_PEI_RETURN pei_run (T_VSI_CHANDLE handle)
{
  return PEI_OK;
}
#endif



/*
+------------------------------------------------------------------------------
|  Function    : pei_config
+------------------------------------------------------------------------------
|  Description  : This function is called by the frame when a primitive is
|                 received indicating dynamic configuration.
|
|  Parameters  :  handle            - Communication handle
|
|  Return      :  PEI_OK            - sucessful
|                 PEI_ERROR         - not successful
|
+------------------------------------------------------------------------------
*/
#if !defined (NCONFIG)

  LOCAL KW_DATA kwtab[] = {
#ifdef _SIMULATION_
    UDP_DEF_BIND_REQ,        BIND_REQ,
#endif /* _SIMULATION_ */
    "",                   0
  };

#endif /* !NCONFIG */


LOCAL SHORT pei_config (T_PEI_CONFIG inString)
{
#if !defined (NCONFIG)
  char    *s = inString;
  SHORT    valno;
  SHORT   keyno;
  char    *keyw;
  char    *val [10];
  TRACE_FUNCTION ("wap pei_config()");
  TRACE_EVENT (s);

  tok_init (s);

  /*
   * Parse next keyword and number of variables
   */

  while ((valno = tok_next(&keyw,val)) NEQ TOK_EOCS)
  {
    switch ((keyno = tok_key((KW_DATA *)kwtab, keyw)))
    {
      case TOK_NOT_FOUND:
        TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword");
        break;

#ifdef _SIMULATION_
      case BIND_REQ:
      {
        void udp_bind_req (UBYTE, UBYTE); /* care about this */

        udp_bind_req(1, 2); /* dummy id, channel */
        break;
      }
#endif /* _SIMULATION_ */

      default:
        break;
    }
  }
#endif /* NCONFIG */
  return PEI_OK;
}


/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_monitor         |
+--------------------------------------------------------------------+
 
  PURPOSE : Monitoring of physical Parameters
 
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_monitor (void **monitor)
#else
GLOBAL T_PEI_RETURN pei_monitor (void **monitor)
#endif
{
  TRACE_FUNCTION ("wap pei_monitor()")

  wap_mon.version = VERSION_WAP;

  *monitor = &wap_mon;

  return PEI_OK;
}



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_create          |
+--------------------------------------------------------------------+
 
  PURPOSE : Create the Protocol Stack Entity
 
*/
#if defined (NEW_FRAME)
GLOBAL SHORT wap_pei_create (T_PEI_INFO **info)
{
  static const T_PEI_INFO pei_info =
    {
      "WAP",
      {
        pei_init,
        pei_exit,
        pei_primitive,
        pei_timeout,
        NULL,              /* no signal function  */
        NULL,              /* no run function     */
        pei_config,
        pei_monitor
      },
      6240,                /* stack size          */
      10,                  /* queue entries       */
      179,                 /* priorities          */
      1,                   /* number of timer     */
      0x03                 /* flags               */
    };

  TRACE_FUNCTION ("wap_pei_create()")

  /*
   *  Close Resources if open
   */

  if (first_access)
    first_access = FALSE;
  else
    pei_exit ();

  /*
   *  Export startup configuration data
   */

  * info = (T_PEI_INFO *)&pei_info;

  return PEI_OK;
}

#else

GLOBAL T_PEI_RETURN pei_create (T_VSI_CNAME *name)
{
#ifdef OPTION_RELATIVE
  static T_PEI_RETURN (*compile_addr)() = pei_create;

  offset = (char *)pei_create - (char *)compile_addr;
#endif

  TRACE_FUNCTION ("wap pei_create()")

  /*
  *  Close Resources if open
  */

  if (first_access)
    first_access = FALSE;
  else
    pei_exit ();

  /*
  *  Initialize entity data
  */

  *name = WAP_NAME;

  return PEI_OK;
}

#endif


/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_connect_cnf
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_connect_cnf
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_connect_cnf (
                    T_DTI2_CONNECT_CNF   *dti_connect_cnf
                  )
{
    dti_dti_connect_cnf(wap_hDTI, dti_connect_cnf);  
}

/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_connect_ind
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_connect_ind
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_connect_ind (
                    T_DTI2_CONNECT_IND   *dti_connect_ind
                  )
{
    dti_dti_connect_ind(wap_hDTI, dti_connect_ind);  
}

/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_disconnect_ind
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_disconnect_ind
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_disconnect_ind (
                    T_DTI2_DISCONNECT_IND   *dti_disconnect_ind
                  )
{
    dti_dti_disconnect_ind (wap_hDTI, dti_disconnect_ind);
}

/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_data_ind
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_data_ind
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_data_ind (
                    T_DTI2_DATA_IND   *dti_data_ind
                  )
{
    dti_dti_data_ind (wap_hDTI, dti_data_ind);
}

/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_ready_ind
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_ready_ind
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_ready_ind (
                    T_DTI2_READY_IND   *dti_ready_ind
                  )
{
  dti_dti_ready_ind (wap_hDTI, dti_ready_ind);
}
 
#ifdef _SIMULATION_

/*
+------------------------------------------------------------------------------
|    Function    : pei_dti_dti_data_test_ind
+------------------------------------------------------------------------------
|    PURPOSE : Call the process function dti_dti_data_test_ind
+------------------------------------------------------------------------------
*/

GLOBAL const void pei_dti_dti_data_test_ind (
                    T_DTI2_DATA_TEST_IND   *dti_data_test_ind
                  )
{
  dti_dti_data_test_ind (wap_hDTI, dti_data_test_ind);   
}

#endif /* _SIMULATION_ */


/*
+------------------------------------------------------------------------------
|    Function: pei_sig_callback
+------------------------------------------------------------------------------
|    PURPOSE : Callback function for DTILIB
+------------------------------------------------------------------------------
*/

GLOBAL void pei_sig_callback(U8 instance, U8 interfac, U8 channel, 
                                   U8 reason, T_DTI2_DATA_IND *dti_data_ind)
{
  TRACE_FUNCTION("wap  pei_sig_callback");

#ifdef _SIMULATION_
  if (interfac NEQ WAP_DTI_DN_INTERFACE || channel NEQ WAP_DTI_DN_CHANNEL) 
  {
    TRACE_ERROR("[PEI_SIG_CALLBACK] channel or interface not valid!");
    return; /* error, not found */
  }
#endif /* _SIMULATION_ */

#ifdef OPTION_MULTIPLE_INSTANCE
  wap_data = &wap_data_base[instance];
#else  /* OPTION_MULTIPLE_INSTANCE */
  wap_data = &wap_data_base;
#endif /* OPTION_MULTIPLE_INSTANCE */


  if (wap_hDTI NEQ D_NO_DATA_BASE)
  {
    switch (reason)
    {
      case DTI_REASON_CONNECTION_OPENED:
        sig_dti_udp_connection_opened_ind();
        break;

      case DTI_REASON_CONNECTION_CLOSED:
        sig_dti_udp_connection_closed_ind();
        break;

      case DTI_REASON_DATA_RECEIVED:
        sig_dti_udp_data_received_ind(dti_data_ind);
        break;

      case DTI_REASON_TX_BUFFER_FULL:
        sig_dti_udp_tx_buffer_full_ind();
        break;
      
      case DTI_REASON_TX_BUFFER_READY:
        sig_dti_udp_tx_buffer_ready_ind();
        break;

      default:
        TRACE_ERROR("unknown DTILIB reason parameter");
        break;
    } /* end switch */
  } /* end if */
  else 
  {
    TRACE_ERROR("Pointer to DTILIB database not existing");
  }
} /* pei_sig_callback() */

⌨️ 快捷键说明

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