wifi_apc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:23k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2001
  8. *
  9. *****************************************************************************/
  10. /*****************************************************************************
  11.  *
  12.  * Filename:
  13.  * ---------
  14.  *   wifi_apc.cpp
  15.  *
  16.  * Project:
  17.  * --------
  18.  *   Maui META APP
  19.  *
  20.  * Description:
  21.  * ------------
  22.  *   WiFi channel power source
  23.  *
  24.  * Author:
  25.  * -------
  26.  *  Andy Ueng (mtk00490)
  27.  *
  28.  *============================================================================
  29.  *             HISTORY
  30.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  31.  *------------------------------------------------------------------------------
  32.  * $Revision$
  33.  * $Modtime$
  34.  * $Log$
  35.  * 
  36.  *------------------------------------------------------------------------------
  37.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  38.  *============================================================================
  39.  ****************************************************************************/
  40. #pragma hdrstop
  41. #ifndef  _WIFI_COMMON_H_
  42. #include "wifi_common.h"
  43. #endif
  44. #ifndef  _WIFI_APC_2400M_H_
  45. #include "wifi_apc_2400m.h"
  46. #endif
  47. // man
  48. #ifndef  _MAN_FDM_H_
  49. #include "man_fdm.h"
  50. #endif
  51. #ifndef  _MAN_ACTIVE_H_
  52. #include "man_active.h"
  53. #endif
  54. // misc
  55. #ifndef  _FT_UTILS_H_
  56. #include "ft_utils.h"
  57. #endif
  58. //===========================================================================
  59. static CWIFIAPC*  wifi_apc_ptr;
  60. static bool g_bIsRunning = false;
  61. //===========================================================================
  62. static  void  REQ_ReadFromNVRAM_TxPower2400M( void )
  63. {
  64.     wifi_apc_ptr->REQ_ReadFromNVRAM_TxPower2400M( );
  65. }
  66. //---------------------------------------------------------------------------
  67. static void  CNF_ReadFromNVRAM_TxPower2400M( void )
  68. {
  69.     wifi_apc_ptr->CNF_ReadFromNVRAM_TxPower2400M();
  70. }
  71. //---------------------------------------------------------------------------
  72. static  void  REQ_WriteToNVRAM_TxPower2400M( void )
  73. {
  74.     wifi_apc_ptr->REQ_WriteToNVRAM_TxPower2400M( );
  75. }
  76. //---------------------------------------------------------------------------
  77. static  void  CNF_WriteToNVRAM_TxPower2400M( void )
  78. {
  79.     wifi_apc_ptr->CNF_WriteToNVRAM_TxPower2400M( );
  80. }
  81. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. static  void  REQ_ReadFromNVRAM_TxPower5000M( void )
  83. {
  84.     wifi_apc_ptr->REQ_ReadFromNVRAM_TxPower5000M( );
  85. }
  86. //---------------------------------------------------------------------------
  87. static void  CNF_ReadFromNVRAM_TxPower5000M( void )
  88. {
  89.     wifi_apc_ptr->CNF_ReadFromNVRAM_TxPower5000M();
  90. }
  91. //---------------------------------------------------------------------------
  92. static  void  REQ_WriteToNVRAM_TxPower5000M( void )
  93. {
  94.     wifi_apc_ptr->REQ_WriteToNVRAM_TxPower5000M( );
  95. }
  96. //---------------------------------------------------------------------------
  97. static  void  CNF_WriteToNVRAM_TxPower5000M( void )
  98. {
  99.     wifi_apc_ptr->CNF_WriteToNVRAM_TxPower5000M( );
  100. }
  101. //---------------------------------------------------------------------------
  102. static void REQ_TimeOut(void)
  103. {
  104.     wifi_apc_ptr->REQ_TimeOut();
  105. }
  106. //---------------------------------------------------------------------------
  107. static void REQ_Finish(void)
  108. {
  109.     wifi_apc_ptr->REQ_Finish();
  110. }
  111. //---------------------------------------------------------------------------
  112. static void REQ_SetDbmToDac(void)
  113. {
  114.     wifi_apc_ptr->REQ_SetDbmToDac();
  115. }
  116. //---------------------------------------------------------------------------
  117. static void REQ_QueryDbmToDac(void)
  118. {
  119.     wifi_apc_ptr->REQ_QueryDbmToDac();
  120. }
  121. //===========================================================================
  122. CWIFIAPC::CWIFIAPC(void)
  123. {
  124.     g_bIsRunning = false;
  125.     ConfirmCallback = NULL;
  126.     m_uiApcBufSize2400M = 0;
  127.     m_cApcBuf2400M = NULL;
  128.     m_uiApcBufSize5000M = 0;
  129.     m_cApcBuf5000M = NULL;
  130. }
  131. //---------------------------------------------------------------------------
  132. CWIFIAPC::~CWIFIAPC()
  133. {
  134.     g_bIsRunning = false;
  135.     ConfirmCallback = NULL;
  136.     if (m_cApcBuf2400M)
  137.     {
  138.         delete [] m_cApcBuf2400M;
  139.         m_cApcBuf2400M = NULL;
  140.     }
  141.     if (m_cApcBuf5000M)
  142.     {
  143.         delete [] m_cApcBuf5000M;
  144.         m_cApcBuf5000M = NULL;
  145.     }
  146. }
  147. //---------------------------------------------------------------------------
  148. void CWIFIAPC::REQ_Finish(void)
  149. {
  150.     if (!g_bIsRunning)
  151.     {
  152.         return;
  153.     }
  154.     Confirm(METAAPP_SUCCESS);
  155. }
  156. //---------------------------------------------------------------------------
  157. void CWIFIAPC::REQ_Stop(void)
  158. {
  159.     if (!g_bIsRunning)
  160.     {
  161.         return;
  162.     }
  163.     NVRAMMan->REQ_Stop();
  164.     Confirm( METAAPP_STOP );
  165. }
  166. //---------------------------------------------------------------------------
  167. void CWIFIAPC::REQ_TimeOut(void)
  168. {
  169.     if( ! g_bIsRunning )  return;
  170.     NVRAMMan->REQ_Stop();
  171.     Confirm( METAAPP_TIMEOUT );
  172. }
  173. //---------------------------------------------------------------------------
  174. void CWIFIAPC::Confirm(E_METAAPP_RESULT_T confirm_state)
  175. {
  176.     if (!g_bIsRunning)
  177.     {
  178.         return;
  179.     }
  180.     g_bIsRunning = false;
  181.     if (NULL == ConfirmCallback)
  182.     {
  183.         return;
  184.     }
  185.     m_eConfirmState = confirm_state;
  186.     ActiveMan->SetActiveFunction(ConfirmCallback);
  187. }
  188. //===========================================================================
  189. void CWIFIAPC::REQ_Read_TxPower2400M_From_NVRAM_Start(void)
  190. {
  191.     wifi_apc_ptr = this;
  192.     g_bIsRunning = true;
  193.     m_bDownloadTrigger = false;
  194.     REQ_ReadFromNVRAM_TxPower2400M();
  195. }
  196. //-------------------------------------
  197. void CWIFIAPC::REQ_ReadFromNVRAM_TxPower2400M(void)
  198. {
  199.     if (!g_bIsRunning)
  200.     {
  201.         return;
  202.     }
  203.     if (NULL == m_cApcBuf2400M)
  204.     {
  205.         META_RESULT  MetaResult;
  206.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_POWER_2400M_LID", (int *) &m_uiApcBufSize2400M);
  207.         if(MetaResult!=META_SUCCESS)
  208.         {  Confirm( METAAPP_FAIL );  return;  }
  209.         m_cApcBuf2400M = new  char[m_uiApcBufSize2400M];
  210.     }
  211.     NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM_TxPower2400M;
  212.     NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_WNDRV_TX_POWER_2400M_LID",
  213.                                             1,
  214.                                             m_uiApcBufSize2400M,
  215.                                             m_cApcBuf2400M );
  216. }
  217. //-------------------------------------
  218. void CWIFIAPC::CNF_ReadFromNVRAM_TxPower2400M(void)
  219. {
  220.     if (!g_bIsRunning )
  221.     {
  222.         return;
  223.     }
  224.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  225.     switch (state)
  226.     {
  227.         case METAAPP_SUCCESS:
  228.         {
  229.             if (m_bDownloadTrigger)
  230.             {
  231.                 REQ_WriteToNVRAM_TxPower2400M();
  232.             }
  233.             else
  234.             {
  235.                 META_RESULT MetaResult;
  236.                 MetaResult = META_NVRAM_WiFi_Decompose_TxPower2400M(&m_sTxChannelDac2400M, m_cApcBuf2400M, m_uiApcBufSize2400M);
  237.                 if (MetaResult != META_SUCCESS)
  238.                 {
  239.                     Confirm(METAAPP_FAIL);
  240.                     return;
  241.                 }
  242.                 ActiveMan->SetActiveFunction(::REQ_Finish);
  243.             }
  244.         }
  245.         break;
  246.         default:
  247.         {
  248.             Confirm(state);
  249.         }
  250.         break;
  251.     }
  252. }
  253. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  254. void CWIFIAPC::REQ_Write_TxPower2400M_To_NVRAM_Start(void)
  255. {
  256.     wifi_apc_ptr = this;
  257.     g_bIsRunning = true;
  258.     m_bDownloadTrigger = true;
  259.     REQ_ReadFromNVRAM_TxPower2400M();
  260. }
  261. //-------------------------------------
  262. void CWIFIAPC::REQ_WriteToNVRAM_TxPower2400M(void)
  263. {
  264.     if (!g_bIsRunning)
  265.     {
  266.         return;
  267.     }
  268.     if (NULL == m_cApcBuf2400M)
  269.     {
  270.         META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_POWER_2400M_LID", (int *) &m_uiApcBufSize2400M);
  271.         if (MetaResult != META_SUCCESS)
  272.         {
  273.             Confirm(METAAPP_FAIL);
  274.             return;
  275.         }
  276.         m_cApcBuf2400M = new char[m_uiApcBufSize2400M];
  277.     }
  278.     META_RESULT  MetaResult;
  279.     MetaResult = META_NVRAM_WiFi_Compose_TxPower2400M(&m_sTxChannelDac2400M,
  280.                                                       m_cApcBuf2400M,
  281.                                                       m_uiApcBufSize2400M);
  282.     if (MetaResult != META_SUCCESS)
  283.     {
  284.         Confirm(METAAPP_FAIL);
  285.         return;
  286.     }
  287.     NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM_TxPower2400M;
  288.     NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_WNDRV_TX_POWER_2400M_LID",
  289.                                    1,
  290.                                    m_uiApcBufSize2400M,
  291.                                    m_cApcBuf2400M);
  292. }
  293. //-------------------------------------
  294. void CWIFIAPC::CNF_WriteToNVRAM_TxPower2400M(void)
  295. {
  296.     if (!g_bIsRunning)
  297.     {
  298.         return;
  299.     }
  300.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  301.     switch (state)
  302.     {
  303.         case METAAPP_SUCCESS:
  304.         {
  305.             ActiveMan->SetActiveFunction(::REQ_Finish);
  306.         }
  307.         break;
  308.         default:
  309.         {
  310.             Confirm(state);
  311.         }
  312.         break;
  313.     }
  314. }
  315. //===========================================================================
  316. void CWIFIAPC::REQ_Read_TxPower5000M_From_NVRAM_Start(void)
  317. {
  318.     wifi_apc_ptr = this;
  319.     g_bIsRunning = true;
  320.     m_bDownloadTrigger = false;
  321.     REQ_ReadFromNVRAM_TxPower5000M();
  322. }
  323. //-------------------------------------
  324. void CWIFIAPC::REQ_ReadFromNVRAM_TxPower5000M(void)
  325. {
  326.     if (!g_bIsRunning)
  327.     {
  328.         return;
  329.     }
  330.     if (NULL == m_cApcBuf5000M)
  331.     {
  332.         META_RESULT  MetaResult;
  333.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_POWER_5000M_LID", (int *) &m_uiApcBufSize5000M);
  334.         if (MetaResult != META_SUCCESS)
  335.         {
  336.             Confirm(METAAPP_FAIL);
  337.             return;
  338.         }
  339.         m_cApcBuf5000M = new char[m_uiApcBufSize5000M];
  340.     }
  341.     NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM_TxPower5000M;
  342.     NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_WNDRV_TX_POWER_5000M_LID",
  343.                                             1,
  344.                                             m_uiApcBufSize5000M,
  345.                                             m_cApcBuf5000M );
  346. }
  347. //-------------------------------------
  348. void CWIFIAPC::CNF_ReadFromNVRAM_TxPower5000M(void)
  349. {
  350.     if (!g_bIsRunning)
  351.     {
  352.         return;
  353.     }
  354.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  355.     switch (state)
  356.     {
  357.         case METAAPP_SUCCESS:
  358.         {
  359.             if (m_bDownloadTrigger)
  360.             {
  361.                 REQ_WriteToNVRAM_TxPower5000M();
  362.             }
  363.             else
  364.             {
  365.                 META_RESULT  MetaResult;
  366.                 MetaResult = META_NVRAM_WiFi_Decompose_TxPower5000M(&m_sTxChannelDac5000M, m_cApcBuf5000M, m_uiApcBufSize5000M);
  367.                 if (MetaResult != META_SUCCESS)
  368.                 {
  369.                     Confirm(METAAPP_FAIL);
  370.                     return;
  371.                 }
  372.                 ActiveMan->SetActiveFunction(::REQ_Finish);
  373.             }
  374.         }
  375.         break;
  376.         default:
  377.         {
  378.             Confirm(state);
  379.         }
  380.         break;
  381.     }
  382. }
  383. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  384. void CWIFIAPC::REQ_Write_TxPower5000M_To_NVRAM_Start(void)
  385. {
  386.     wifi_apc_ptr = this;
  387.     g_bIsRunning = true;
  388.     m_bDownloadTrigger = true;
  389.     REQ_ReadFromNVRAM_TxPower5000M();
  390. }
  391. //-------------------------------------
  392. void CWIFIAPC::REQ_WriteToNVRAM_TxPower5000M(void)
  393. {
  394.     if (!g_bIsRunning)
  395.     {
  396.         return;
  397.     }
  398.     if (NULL == m_cApcBuf5000M)
  399.     {
  400.         META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_POWER_5000M_LID", (int *) &m_uiApcBufSize5000M);
  401.         if (MetaResult != META_SUCCESS)
  402.         {
  403.             Confirm(METAAPP_FAIL);
  404.             return;
  405.         }
  406.         m_cApcBuf5000M = new char[m_uiApcBufSize5000M];
  407.     }
  408.     META_RESULT  MetaResult;
  409.     MetaResult = META_NVRAM_WiFi_Compose_TxPower5000M(&m_sTxChannelDac5000M,
  410.                                                       m_cApcBuf5000M,
  411.                                                       m_uiApcBufSize5000M);
  412.     if (MetaResult != META_SUCCESS)
  413.     {
  414.         Confirm(METAAPP_FAIL);
  415.         return;
  416.     }
  417.     NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM_TxPower5000M;
  418.     NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_WNDRV_TX_POWER_5000M_LID",
  419.                                    1,
  420.                                    m_uiApcBufSize5000M,
  421.                                    m_cApcBuf5000M);
  422. }
  423. //-------------------------------------
  424. void CWIFIAPC::CNF_WriteToNVRAM_TxPower5000M(void)
  425. {
  426.     if (!g_bIsRunning)
  427.     {
  428.         return;
  429.     }
  430.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  431.     Confirm(state);
  432. }
  433. //===========================================================================
  434. static const AnsiString SECTION_NAME_2400M = "WiFi TX power 2.4G";
  435. static const AnsiString SECTION_NAME_5000M = "WiFi TX power 5G";
  436. static const AnsiString KEY_NAME_2400M[] =
  437. {
  438.     "TX power CCK",
  439.     "TX power OFDM"
  440. };
  441. static const AnsiString KEY_NAME_5000M = "TX power";
  442. //----------------------------------------------------------------------------
  443. bool  CWIFIAPC::WiFiTxPower2400MSectionExist( char *filename )
  444. {
  445.     TIniFile   *ini_file;
  446.     ini_file = new TIniFile( filename );
  447.     if( ini_file == NULL ) return false;
  448.     if( ini_file->SectionExists( "WiFi TX power 2.4G" ) )
  449.     {
  450.         return true;
  451.     }
  452.     return false;
  453. }
  454. //----------------------------------------------------------------------------
  455. bool  CWIFIAPC::REQ_Read_TxPower2400M_From_File( char *filename )
  456. {
  457.     TIniFile   *ini_file;
  458.     AnsiString  as_data;
  459.     char        str[2048];
  460.     unsigned char      ucdata[NUM_TX_POWER_2400M_CH];
  461.     int         i, j;
  462.     ini_file = new TIniFile( filename );
  463.     if( ini_file == NULL )  return false;
  464.     for( i=0; i<2; i++ )
  465.     {
  466.         as_data = ini_file->ReadString( SECTION_NAME_2400M,
  467.                                         KEY_NAME_2400M[i],
  468.                                         "0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  469.         strcpy( str, as_data.c_str() );
  470.         String_To_Array_UnsignedChar( str, ucdata, NUM_TX_POWER_2400M_CH );
  471.         if( WIFI_MOD_CCK == i )
  472.         {
  473.             for( j=0; j<NUM_TX_POWER_2400M_CH; j++ )
  474.             {
  475.                 m_sTxChannelDac2400M.CCKTxPWR[j] = ucdata[j];
  476.             }
  477.         }
  478.         else
  479.         {
  480.             for( j=0; j<NUM_TX_POWER_2400M_CH; j++ )
  481.             {
  482.                 m_sTxChannelDac2400M.OFDMTxPWR[j] = ucdata[j];
  483.             }
  484.         }
  485.     }
  486.     delete  ini_file;
  487.     return true;
  488. }
  489. //-----------------------------------------------------------------------------
  490. bool  CWIFIAPC::REQ_Write_TxPower2400M_To_File( char *filename )
  491. {
  492.     TIniFile   *ini_file;
  493.     char        str[2048];
  494.     unsigned char         ucdata[NUM_TX_POWER_2400M_CH];
  495.     int         i, j;
  496.     ini_file = new TIniFile( filename );
  497.     if( ini_file == NULL )  return  false;
  498.     for( i=0; i<2; i++ )
  499.     {
  500.         if( WIFI_MOD_CCK == i )
  501.         {
  502.             for( j=0; j<NUM_TX_POWER_2400M_CH; j++ )
  503.             {  ucdata[j] = m_sTxChannelDac2400M.CCKTxPWR[j];  }
  504.         }
  505.         else
  506.         {
  507.             for( j=0; j<NUM_TX_POWER_2400M_CH; j++ )
  508.             {  ucdata[j] = m_sTxChannelDac2400M.OFDMTxPWR[j];  }
  509.         }
  510.         Array_To_String_UnsignedChar( str, ucdata, NUM_TX_POWER_2400M_CH, ',' );
  511.         ini_file->WriteString( SECTION_NAME_2400M,
  512.                                KEY_NAME_2400M[i],
  513.                                str );
  514.     }
  515.     delete  ini_file;
  516.     return  true;
  517. }
  518. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  519. bool  CWIFIAPC::REQ_Read_TxPower5000M_From_File( char *filename )
  520. {
  521.     TIniFile   *ini_file;
  522.     AnsiString  as_data;
  523.     char        str[2048];
  524.     unsigned char      ucdata[NUM_TX_POWER_5000M_CH];
  525.     int         i;
  526.     ini_file = new TIniFile( filename );
  527.     if( ini_file == NULL )  return false;
  528.     as_data = ini_file->ReadString( SECTION_NAME_5000M,
  529.                                      KEY_NAME_5000M,
  530.                                      "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  531.     strcpy( str, as_data.c_str() );
  532.     String_To_Array_UnsignedChar( str, ucdata, NUM_TX_POWER_5000M_CH );
  533.     for( i=0; i<NUM_TX_POWER_5000M_CH; i++ )
  534.     {  m_sTxChannelDac5000M.TxPWR[i] = ucdata[i];
  535.     }
  536.     delete  ini_file;
  537.     return true;
  538. }
  539. //-----------------------------------------------------------------------------
  540. bool  CWIFIAPC::REQ_Write_TxPower5000M_To_File( char *filename )
  541. {
  542.     TIniFile   *ini_file;
  543.     char        str[2048];
  544.     unsigned char         ucdata[NUM_TX_POWER_5000M_CH];
  545.     int         i;
  546.     ini_file = new TIniFile( filename );
  547.     if( ini_file == NULL )  return  false;
  548.     for( i=0; i<NUM_TX_POWER_5000M_CH; i++ )
  549.     {  ucdata[i] = m_sTxChannelDac5000M.TxPWR[i];  }
  550.     Array_To_String_UnsignedChar( str, ucdata, NUM_TX_POWER_5000M_CH, ',' );
  551.     ini_file->WriteString( SECTION_NAME_5000M,
  552.                            KEY_NAME_5000M,
  553.                            str );
  554.     delete  ini_file;
  555.     return  true;
  556. }
  557. //===========================================================================
  558. void CWIFIAPC::REQ_SetDbmToDac_Start( WiFi_DBM2DAC_Set_S dbm2dac_set )
  559. {
  560.     wifi_apc_ptr = this;
  561.     g_bIsRunning = true;
  562.     m_sDbm2DacSet = dbm2dac_set;
  563.     ActiveMan->SetActiveFunction( ::REQ_SetDbmToDac );
  564. }
  565. //---------------------------------------------------------------------------
  566. void CWIFIAPC::REQ_SetDbmToDac( void )
  567. {
  568.     META_RESULT  MetaResult = META_WiFi_SetDbmToDac_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &m_sDbm2DacSet);
  569.     if(MetaResult!=META_SUCCESS)
  570.     {
  571.         if( MetaResult!=META_TIMEOUT )
  572.         {   Confirm( METAAPP_FAIL );  return;  }
  573.         else
  574.         {   Confirm( METAAPP_TIMEOUT );  return;   }
  575.     }
  576.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  577. }
  578. //===========================================================================
  579. void CWIFIAPC::REQ_QueryDbmToDac_Start( void )
  580. {
  581.     wifi_apc_ptr = this;
  582.     g_bIsRunning = true;
  583.     ActiveMan->SetActiveFunction( ::REQ_QueryDbmToDac );
  584. }
  585. //---------------------------------------------------------------------------
  586. void CWIFIAPC::REQ_QueryDbmToDac( void )
  587. {
  588.     META_RESULT  MetaResult = META_WiFi_QueryDbmToDac_r( m_META_HANDLE_Obj.Get_MainHandle(), 500, &m_sDbm2DacQuery);
  589.     if(MetaResult!=META_SUCCESS)
  590.     {
  591.         if( MetaResult!=META_TIMEOUT )
  592.         {   Confirm( METAAPP_FAIL );  return;  }
  593.         else
  594.         {   Confirm( METAAPP_TIMEOUT );  return;   }
  595.     }
  596.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  597. }
  598. //===========================================================================
  599. /////////////////////////  Global information  //////////////////////////////
  600. //===========================================================================
  601. E_METAAPP_RESULT_T CWIFIAPC::Get_ConfirmState( void )
  602. {
  603.     return  m_eConfirmState;
  604. }
  605. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  606. WiFi_TxPower_2400M_S CWIFIAPC::Get_TxChannelDac2400M( void )
  607. {
  608.     return m_sTxChannelDac2400M;
  609. }
  610. //---------------------------------------------------------------------------
  611. void CWIFIAPC::Set_TxChannelDac2400M( WiFi_TxPower_2400M_S &txpwr )
  612. {
  613.     m_sTxChannelDac2400M = txpwr;
  614. }
  615. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  616. WiFi_TxPower_5000M_S CWIFIAPC::Get_TxChannelDac5000M( void )
  617. {
  618.     return m_sTxChannelDac5000M;
  619. }
  620. //---------------------------------------------------------------------------
  621. void CWIFIAPC::Set_TxChannelDac5000M( WiFi_TxPower_5000M_S &txpwr )
  622. {
  623.     m_sTxChannelDac5000M = txpwr;
  624. }
  625. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626. WiFi_DBM2DAC_Query_S  CWIFIAPC::Get_DbmToDac( void )
  627. {
  628.     return m_sDbm2DacQuery;
  629. }
  630. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  631. unsigned char CWIFIAPC::Get_TxPowerDac(E_WIFI_GENERATION e_802_11_idx, E_WIFI_MOD mod, unsigned int ch_idx )
  632. {
  633.     unsigned char dac;
  634.     switch( e_802_11_idx )
  635.     {
  636.         case WIFI_802_11A_IDX:
  637.              dac = Get_TxPowerDac5000M( ch_idx );
  638.         break;
  639.         case WIFI_802_11B_IDX:
  640.         case WIFI_802_11G_IDX:
  641.              dac = Get_TxPowerDac2400M( mod, ch_idx );
  642.         break;
  643.     }
  644.     return dac;
  645. }
  646. //---------------------------------------------------------------------------
  647. void CWIFIAPC::Set_TxPowerDac(E_WIFI_GENERATION e_802_11_idx, E_WIFI_MOD mod, unsigned int ch_idx, unsigned char dac )
  648. {
  649.     switch( e_802_11_idx )
  650.     {
  651.         case WIFI_802_11A_IDX:
  652.              Set_TxPowerDac5000M( ch_idx, dac );
  653.         break;
  654.         case WIFI_802_11B_IDX:
  655.         case WIFI_802_11G_IDX:
  656.              Set_TxPowerDac2400M( mod, ch_idx, dac );
  657.         break;
  658.     }
  659. }
  660. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  661. unsigned char CWIFIAPC::Get_TxPowerDac2400M( E_WIFI_MOD mod, unsigned int ch_idx )
  662. {
  663.     unsigned char dac;
  664.     if( WIFI_MOD_CCK == mod )
  665.     {
  666.         dac = m_sTxChannelDac2400M.CCKTxPWR[ch_idx];
  667.     }
  668.     else
  669.     {
  670.         dac = m_sTxChannelDac2400M.OFDMTxPWR[ch_idx];
  671.     }
  672.     return dac;
  673. }
  674. //---------------------------------------------------------------------------
  675. void CWIFIAPC::Set_TxPowerDac2400M( E_WIFI_MOD mod, unsigned int ch_idx, unsigned char dac )
  676. {
  677.     if( WIFI_MOD_CCK == mod )
  678.     {
  679.         m_sTxChannelDac2400M.CCKTxPWR[ch_idx] = dac;
  680.     }
  681.     else
  682.     {   m_sTxChannelDac2400M.OFDMTxPWR[ch_idx] = dac;
  683.     }
  684. }
  685. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  686. unsigned char CWIFIAPC::Get_TxPowerDac5000M( unsigned int ch_idx )
  687. {
  688.     return m_sTxChannelDac5000M.TxPWR[ch_idx];
  689. }
  690. //---------------------------------------------------------------------------
  691. void CWIFIAPC::Set_TxPowerDac5000M( unsigned int ch_idx, unsigned char dac )
  692. {
  693.     m_sTxChannelDac5000M.TxPWR[ch_idx] = dac;
  694. }