form_WiFI.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:191k
- switch( state )
- {
- case STATE_MAC_OK:
- {
- // m_uiMacData = m_WIFI_MAC_Obj.Get_MacData();
- if( rbMAC16bits->Checked )
- {
- m_sMCR16 = m_WIFI_MAC_Obj.Get_MCR16();
- DeCompose_MCR16_Data( ACCESS_SINGLE );
- }
- else
- {
- m_sMCR = m_WIFI_MAC_Obj.Get_MCR();
- DeCompose_MCR_Data( ACCESS_SINGLE );
- }
- ReDrawFields( PAGEIDX_MAC );
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Read MAC register successfully";
- }
- break;
- case STATE_MAC_FAIL:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Read MAC register fail";
- Application->MessageBox( "Execution Timeout : Read MAC register", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_MAC_TIMEOUT:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Read MAC register timeout";
- Application->MessageBox( "Execution Timeout : Read MAC register", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_MAC_STOP:
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Read MAC register stop";
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACWriteClick(TObject *Sender)
- {
- //AnsiString text;
- //unsigned int mac_reg_addr, mac_reg_data;
- //text = edtMACMCRAddress->Text; if( !IsValidHexWiFiMacRegAddr( text, mac_reg_addr ) ) { edtMACMCRAddressCheck(edtMACMCRAddress); return; }
- //text = edtMACMCRData->Text; if( !IsValidHexWiFiMacRegValue( text, mac_reg_data ) ) { edtMACMCRDataCheck(edtMACMCRData); return; }
- if( ! CheckFields( ACCESS_SINGLE, OP_WRITE ) )
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString) " Write MAC register fail";
- Application->MessageBox( "Execution Failure : Write MAC register", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- m_WIFI_MAC_Obj.ConfirmCallback = ::ConfirmCallback_WriteMACReg;
- if( rbMAC16bits->Checked )
- {
- Compose_MCR16_Parameter( ACCESS_SINGLE );
- Compose_MCR16_Data( ACCESS_SINGLE );
- m_WIFI_MAC_Obj.REQ_Write_MCR16_Setting_To_Reg_Start( m_sMCR16 );
- }
- else
- {
- Compose_MCR_Parameter( ACCESS_SINGLE );
- Compose_MCR_Data( ACCESS_SINGLE );
- m_WIFI_MAC_Obj.REQ_Write_MCR_Setting_To_Reg_Start( m_sMCR );
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_WriteMACReg( void )
- {
- int state = m_WIFI_MAC_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_MAC_OK:
- {
-
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Write MAC register successfully";
- }
- break;
- case STATE_MAC_FAIL:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Write MAC register fail";
- Application->MessageBox( "Execution Timeout : Write MAC register", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_MAC_TIMEOUT:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Write MAC register timeout";
- Application->MessageBox( "Execution Timeout : Write MAC register", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_MAC_STOP:
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Write MAC register stop";
- break;
- }
- CurrentPageReset();
- }
- //===========================================================================
- static AnsiString WIFI_802_11B_TX_RATE[] =
- {
- "1",
- "2",
- "5.5",
- "11"
- };
- static AnsiString WIFI_802_11AG_TX_RATE[] =
- {
- "6",
- "9",
- "12",
- "18",
- "24",
- "36",
- "48",
- "54"
- };
- //---------------------------------------------------------------------------
- void TfrmWiFi::DisplayWiFiTxRate( void )
- {
- int i;
- cbTXTxRate->Items->Clear();
- if( m_sWiFiCap.support_802_11b )
- {
- for( i=0; i<sizeof(WIFI_802_11B_TX_RATE)/sizeof(WIFI_802_11B_TX_RATE[0]); i++ )
- {
- cbTXTxRate->Items->Add( WIFI_802_11B_TX_RATE[i] );
- }
- }
- if( m_sWiFiCap.support_802_11a || m_sWiFiCap.support_802_11g )
- {
- for( i=0; i<sizeof(WIFI_802_11AG_TX_RATE)/sizeof(WIFI_802_11AG_TX_RATE[0]); i++ )
- {
- cbTXTxRate->Items->Add( WIFI_802_11AG_TX_RATE[i] );
- }
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static AnsiString WIFI_802_11BG_CHANNEL[] =
- {
- "1 (2412000)",
- "2 (2417000)",
- "3 (2422000)",
- "4 (2427000)",
- "5 (2432000)",
- "6 (2437000)",
- "7 (2442000)",
- "8 (2447000)",
- "9 (2452000)",
- "10 (2457000)",
- "11 (2462000)",
- "12 (2467000)",
- "13 (2472000)",
- "14 (2484000)"
- };
- static AnsiString WIFI_802_11A_CHANNEL[] =
- {
- "8 (5040000)",
- "12 (5060000)",
- "16 (5080000)",
- "34 (5170000)",
- "36 (5180000)",
- "38 (5190000)",
- "40 (5200000)",
- "42 (5210000)",
- "44 (5220000)",
- "46 (5230000)",
- "48 (5240000)",
- "52 (5260000)",
- "56 (5280000)",
- "60 (5300000)",
- "64 (5320000)",
- "100 (5500000)",
- "104 (5520000)",
- "108 (5540000)",
- "112 (5560000)",
- "116 (5580000)",
- "120 (5600000)",
- "124 (5620000)",
- "128 (5640000)",
- "132 (5660000)",
- "136 (5680000)",
- "140 (5700000)",
- "149 (5745000)",
- "153 (5765000)",
- "157 (5785000)",
- "161 (5805000)",
- "240 (4920000)",
- "244 (4940000)",
- "248 (4960000)",
- "252 (4980000)"
- };
- //---------------------------------------------------------------------------
- void TfrmWiFi::DisplayWiFiChannel( void )
- {
- int i;
- cbTXChannelID->Items->Clear();
- cbCPRChannelID->Items->Clear();
- if( m_sWiFiCap.support_802_11b || m_sWiFiCap.support_802_11g )
- {
- for( i=0; i<sizeof(WIFI_802_11BG_CHANNEL)/sizeof(WIFI_802_11BG_CHANNEL[0]); i++ )
- {
- cbTXChannelID->Items->Add( WIFI_802_11BG_CHANNEL[i] );
- cbCPRChannelID->Items->Add( WIFI_802_11BG_CHANNEL[i] );
- }
- }
- if( m_sWiFiCap.support_802_11a )
- {
- for( i=0; i<sizeof(WIFI_802_11A_CHANNEL)/sizeof(WIFI_802_11A_CHANNEL[0]); i++ )
- {
- cbTXChannelID->Items->Add( WIFI_802_11A_CHANNEL[i] );
- cbCPRChannelID->Items->Add( WIFI_802_11A_CHANNEL[i] );
- }
- }
- // m_WIFI_GNRL_Obj.ConfirmCallback = ::ConfirmCallback_QueryChannelList;
- // m_WIFI_GNRL_Obj.REQ_Query_ChannelList_Start( &m_sChannelList );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_QueryChannelList( void )
- {
- // channel ID
- cbTXChannelID->Items->Clear();
- cbCPRChannelID->Items->Clear();
- for (unsigned int i = 0; i <m_sChannelList.channel_num; i++)
- {
- cbTXChannelID->Items->Add(m_sChannelList.channel_list[i]);
- cbCPRChannelID->Items->Add(m_sChannelList.channel_list[i]);
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Display_CPTXTxPower( void )
- {
- //bool bCcks;
- int nTxPwr;
- //if( cbTXTxRate->Text.ToInt() < 4)
- //{
- // bCcks = 1;
- //}
- //else
- //{
- // bCcks = 0;
- //}
- #if 0
- macFunc.ReadTxPowerFromEeprom(m_nCardIndex, m_nChannel, bCcks, &nTxPwr, m_ndBValue, !m_b5GBand);
- m_szHexTxPwr.Format("%x", nTxPwr);
- if(m_szHexTxPwr.GetLength() > 2){
- m_szHexTxPwr = "0";
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Force_WiFi_Stop( void )
- {
- TimerWiFi->Enabled = false;
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_TXALL:
- {
- if( rbTXOP->Checked )
- {
- m_WIFI_TXOP_Obj.REQ_Stop();
- }
- else if( rbTXCS->Checked )
- {
- m_WIFI_TXCS_Obj.REQ_Stop();
- }
- else if( rbCPT->Checked )
- {
- m_WIFI_CPT_Obj.REQ_Stop();
- }
- else
- {
- m_WIFI_LF_Obj.REQ_Stop();
- }
- }
- break;
- case PAGEIDX_CPRX:
- m_WIFI_CPRX_Obj.REQ_Stop();
- break;
- case PAGEIDX_PS:
- m_WIFI_PS_Obj.REQ_Stop();
- break;
- case PAGEIDX_BB:
- m_WIFI_BB_Obj.REQ_Stop();
- break;
- case PAGEIDX_MAC:
- m_WIFI_MAC_Obj.REQ_Stop();
- break;
- case PAGEIDX_EE:
- m_WIFI_EE_Obj.REQ_Stop();
- break;
- case PAGEIDX_SC:
- {
- m_WIFI_SC_Obj.REQ_Stop();
- }
- }
- m_WIFI_STOP_Obj.REQ_Start();
- }
- //---------------------------------------------------------------------------
- unsigned int TfrmWiFi::ChannelID_To_ChannelFreq( unsigned int channel_id )
- {
- unsigned int channel_freq[]=
- {
- 2412000, // 1
- 2417000, // 2
- 2422000, // 3
- 2427000, // 4
- 2432000, // 5
- 2437000, // 6
- 2442000, // 7
- 2447000, // 8
- 2452000, // 9
- 2457000, // 10
- 2462000, // 11
- 2467000, // 12
- 2472000, // 13
- 2484000 // 14
- };
- return channel_freq[channel_id-1];
- }
- //---------------------------------------------------------------------------
- unsigned int TfrmWiFi::ChannelFreq_To_ChannelID( unsigned int channel_freq )
- {
- int channel_id;
- unsigned int channel_freq_arry[]=
- {
- 2412000, // 1
- 2417000, // 2
- 2422000, // 3
- 2427000, // 4
- 2432000, // 5
- 2437000, // 6
- 2442000, // 7
- 2447000, // 8
- 2452000, // 9
- 2457000, // 10
- 2462000, // 11
- 2467000, // 12
- 2472000, // 13
- 2484000 // 14
- };
- for( int i=0; i<sizeof(channel_freq); i++)
- {
- if( channel_freq_arry[i] == channel_freq )
- { channel_id = i+1;
- break;
- }
- }
- return channel_id;
- }
- //==========================================================================
- void __fastcall TfrmWiFi::TimerWiFiTimer(TObject *Sender)
- {
- if (1 == btnTXStart->Tag)
- {
- m_WIFI_CPT_Obj.ConfirmCallback = ::ConfirmCallback_QueryTxStatus;
- m_WIFI_CPT_Obj.REQ_Query_TxStatus_Start(m_bAlcSupport);
- }
- else if (1 == btnCPRStart->Tag)
- {
- m_WIFI_CPRX_Obj.ConfirmCallback = ::ConfirmCallback_QueryRxStatus;
- m_WIFI_CPRX_Obj.REQ_QueryRxStatus_Start();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_QueryTxStatus( void )
- {
- int state = m_WIFI_CPT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- WiFi_TxStatus_Ex_S tx_status;
- tx_status = m_WIFI_CPT_Obj.Get_TxStatus();
- stTXPacketSent->Caption = IntToStr(tx_status.pkt_sent_count);
- stTXAckCount->Caption = IntToStr(tx_status.pkt_sent_acked);
- if (m_bAlcSupport)
- {
- m_stAverageALC->Caption = IntToStr(tx_status.avgAlc);
- m_stTXCCKGainControl->Caption = IntToStr(tx_status.cckGainControl);
- m_stTXOFDMGainControl->Caption = IntToStr(tx_status.ofdmGainControl);
- }
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Query continuous packet TX status fail";
- Application->MessageBox( "Execution Failure : Query continuous packet TX status", "FAILURE", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Query continuous packet TX status timeout";
- Application->MessageBox( "Execution Timeout : Query continuous packet TX status", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Query continuous packet TX status stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_QueryRxStatus( void )
- {
- int state = m_WIFI_CPRX_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_CPRX_OK:
- {
- WiFi_RxStatus_S rx_status;
- rx_status = m_WIFI_CPRX_Obj.Get_RxStatus();
- // if( WIFI_BB_IPN2128 == m_final_WiFiId )
- // {
- // stCPRSuccess->Caption = IntToStr( rx_status.int_rx_ok_num - m_sOriRxStatus.int_rx_ok_num );
- // }
- // else
- {
- stCPRSuccess->Caption = IntToStr( rx_status.pau_rx_pkt_count - m_sOriRxStatus.pau_rx_pkt_count - ( rx_status.pau_crc_err_count - m_sOriRxStatus.pau_crc_err_count ) );
- }
- stCPRCRCErr->Caption = IntToStr( rx_status.pau_crc_err_count - m_sOriRxStatus.pau_crc_err_count );
- stCPRTotal->Caption = IntToStr( stCPRSuccess->Caption.ToInt() + stCPRCRCErr->Caption.ToInt() );
- if( stCPRTotal->Caption.ToInt() != 0 )
- {
- char str[20];
- sprintf(str, "%.2f", (float) stCPRCRCErr->Caption.ToInt() * 100.0 / stCPRTotal->Caption.ToInt() );
- stCPRFER->Caption = (AnsiString) str;
- }
- else
- { stCPRFER->Caption = "0";
- }
- stCPRint_rx_ok_num->Caption = IntToStr( rx_status.int_rx_ok_num );
- stCPRint_crc_err_num->Caption = IntToStr( rx_status.int_crc_err_num );
- stCPRpau_rx_ok_count->Caption = IntToStr( rx_status.pau_rx_pkt_count );
- stCPRpau_crc_err_count->Caption = IntToStr( rx_status.pau_crc_err_count );
- stCPRpau_cca_count->Caption = IntToStr( rx_status.pau_cca_count );
- stCPRpau_rx_fifo_full_count->Caption = IntToStr( rx_status.pau_rx_fifo_full_count );
- for( int i=0; i<WIFI_TEST_RATE_COUNT; i++ )
- {
- stCPRGood[i]->Caption = IntToStr( rx_status.int_rate_ok_num[i] - m_sOriRxStatus.int_rate_ok_num[i] );
- stCPRBad[i]->Caption = IntToStr( rx_status.int_rate_crc_err_num[i] - m_sOriRxStatus.int_rate_crc_err_num[i] );
- stCPRSum[i]->Caption = IntToStr( stCPRGood[i]->Caption.ToInt() + stCPRBad[i]->Caption.ToInt() );
- if( stCPRSum[i]->Caption.ToInt() != 0 )
- {
- char str[20];
- sprintf(str, "%.2f", (float) stCPRBad[i]->Caption.ToInt() * 100.0 / stCPRSum[i]->Caption.ToInt() );
- stCPRFer[i]->Caption = (AnsiString) str;
- }
- else
- { stCPRFer[i]->Caption = "0";
- }
- }
- // RSSI
- stCPRMin->Caption = IntToStr( rx_status.int_rssi_min );
- stCPRMax->Caption = IntToStr( rx_status.int_rssi_max );
- stCPRMean->Caption = IntToStr( rx_status.int_rssi_mean );
- stCPRVariance->Caption = IntToStr( rx_status.int_rssi_variance );
- // Preamble
- stCPRLong->Caption = IntToStr( rx_status.int_long_preamble_num );
- stCPRShort->Caption = IntToStr( rx_status.int_short_preamble_num );
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX status successfully";
- }
- break;
- case STATE_CPRX_FAIL:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX status fail";
- Application->MessageBox( "Execution Failure : Query continuous packet RX status", "FAILURE", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_CPRX_TIMEOUT:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX status timeout";
- Application->MessageBox( "Execution Timeout : Query continuous packet RX status", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_CPRX_STOP:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX status stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //===========================================================================
- ////////////////////////////////// BBCR //////////////////////////////
- //===========================================================================
- void TfrmWiFi::AllocateBBCRVector( void )
- {
- if( NULL == m_pvBBCRDisp )
- {
- m_pvBBCRDisp = new vector<WiFi_BBReg8_S>;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::EraseBBCRVector( void )
- {
- if( NULL == m_pvBBCRDisp )
- {
- if( ! m_pvBBCRDisp->empty() )
- {
- m_pvBBCRDisp->erase( m_pvBBCRDisp->begin(), m_pvBBCRDisp->end() );
- }
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::DeAllocateBBCRVector( void )
- {
- if( m_pvBBCRDisp != NULL )
- {
- if( ! m_pvBBCRDisp->empty() )
- {
- m_pvBBCRDisp->erase( m_pvBBCRDisp->begin(), m_pvBBCRDisp->end() );
- }
- delete m_pvBBCRDisp;
- m_pvBBCRDisp = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBDumpBBRegClick(TObject *Sender)
- {
- if( !CheckFields( ACCESS_DUMP, OP_READ ) )
- {
- sbBB->Panels->Items[0]->Text = (AnsiString) " Dump baseband registers fail";
- Application->MessageBox( "Execution Failure : Dump baseband registers", "FAILURE", MB_OK );
- return;
- }
- FillBBResult(true);
- CurrentPageLock();
- m_uiBBCount=0;
- Compose_BBCR_Parameter( ACCESS_DUMP );
- AllocateBBCRVector();
- EraseBBCRVector();
- m_WIFI_BB_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllBBReg;
- m_WIFI_BB_Obj.REQ_Read_BBCR_Setting_From_Reg_Start( m_sBBCR );
- sbBB->Panels->Items[0]->Text = (AnsiString)" Dump baseband registers progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadAllBBReg( void )
- {
- int state = m_WIFI_BB_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_BB_OK:
- {
- m_sBBCR = m_WIFI_BB_Obj.Get_BBCR();
- for (unsigned int i=0; i<m_sBBCR.count; i++ )
- {
- WiFi_BBReg8_S bbcr;
- bbcr.index = m_sBBCR.bb_reg8[i].index;
- bbcr.bbcr_data8 = m_sBBCR.bb_reg8[i].bbcr_data8;
- m_pvBBCRDisp->push_back( bbcr );
- }
- if( m_sBBCR.bb_reg8[m_sBBCR.count-1].index < m_uiBBEndIdx )
- {
- Compose_BBCR_Parameter( ACCESS_DUMP );
- m_WIFI_BB_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllBBReg;
- m_WIFI_BB_Obj.REQ_Read_BBCR_Setting_From_Reg_Start( m_sBBCR );
- }
- else
- {
- FillBBResult( false );
- sbBB->Panels->Items[0]->Text = (AnsiString)" Dump baseband registers successfully";
- CurrentPageReset();
- }
- }
- break;
- case STATE_BB_FAIL:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Dump baseband registers fail";
- Application->MessageBox( "Execution Timeout : Dump baseband registers", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_BB_TIMEOUT:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Dump baseband registers timeout";
- Application->MessageBox( "Execution Timeout : Dump baseband registers", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_BB_STOP:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Dump baseband registers stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBCRDataClick(TObject *Sender)
- {
- if( btnBBCRData->Tag==0 ) // Dec-->Hex
- { btnBBCRData->Tag = 1;
- }
- else //Hex-->Dec
- { btnBBCRData->Tag = 0;
- }
- ReDrawFields( PAGEIDX_BB );
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACMCRDataClick(TObject *Sender)
- {
- if( btnMACMCRData->Tag==0 ) // Dec-->Hex
- { btnMACMCRData->Tag = 1;
- }
- else //Hex-->Dec
- { btnMACMCRData->Tag = 0;
- }
- ReDrawFields( PAGEIDX_MAC );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEDataClick(TObject *Sender)
- {
- if( 0 == btnEEData->Tag ) // Dec-->Hex
- { btnEEData->Tag = 1;
- }
- else //Hex-->Dec
- { btnEEData->Tag = 0;
- }
- ReDrawFields( PAGEIDX_EE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEReadClick(TObject *Sender)
- {
- AnsiString text;
- unsigned int ee_addr;
- text = edtEEIndex->Text; if( !IsValidHexWiFiEERegAddr( text, ee_addr ) ) { edtMACMCRAddressCheck(edtMACMCRAddress); return; }
- m_uiEEPROMIdx = ee_addr;
- Compose_EEPROM_Parameter( ACCESS_SINGLE );
- CurrentPageLock();
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadEE( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_EE_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- m_sEE = m_WIFI_EE_Obj.Get_EE();
- DeCompose_EEPROM_Data( ACCESS_SINGLE );
- ReDrawFields( PAGEIDX_EE );
- sbEE->Panels->Items[0]->Text = (AnsiString)" Read EEPROM successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Read EEPROM fail";
- Application->MessageBox( "Execution Fail : Read EEPROM", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Read EEPROM timeout";
- Application->MessageBox( "Execution Timeout : Read EEPROM", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_STOP:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Read EEPROM stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEWriteClick(TObject *Sender)
- {
- #if 0
- if( ! CheckFields( ACCESS_SINGLE, OP_WRITE ) )
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString) " Write EEPROM fail";
- Application->MessageBox( "Execution Failure : Write EEPROM", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_WriteEE;
- m_WIFI_EE_Obj.REQ_Write_To_EE_Start( m_sEE );
- #endif
- if( !CheckFields( ACCESS_SINGLE, OP_WRITE ) )
- {
- sbEE->Panels->Items[0]->Text = (AnsiString) " Write EEPROM fail";
- Application->MessageBox( "Execution Failure : Write EEPROM", "FAILURE", MB_OK );
- return;
- }
- Compose_EEPROM_Parameter( ACCESS_SINGLE );
- Compose_EEPROM_Data( ACCESS_SINGLE );
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_WriteEE;
- m_WIFI_EE_Obj.REQ_Write_To_EE_Start( m_sEE );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_WriteEE( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_EE_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Write EEPROM successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Write EEPROM fail";
- Application->MessageBox( "Execution Timeout : Write EEPROM", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Write EEPROM timeout";
- Application->MessageBox( "Execution Timeout : Write EEPROM", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_STOP:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Write EEPROM stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmWiFi::edtEEIndexCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- AnsiString as_hint = " value is not valid ";
- char hint[256];
- strcpy( hint, as_hint.c_str() );
- text = edit->Text;
- if( !IsValidHexWiFiEERegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- // if( usdata > m_sWiFiCap.eeprom_size )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- // if( 0 != uidata%2 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- // if( uidata >= m_sWiFiCap.eeprom_size-1 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- m_uiEEPROMIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtEEDataCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned short usdata;
- int band;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- text = edit->Text;
- if( 0 == btnEEData->Tag ) // Dec
- {
- if( !IsValidDecWiFiEERegValue( text, usdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- if( 1 == btnEEData->Tag ) // Hex
- {
- if( !IsValidHexWiFiEERegValue( text, usdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sEE.eeprom[0].eeprom_data16 = usdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXTxChannelPowerClick(TObject *Sender)
- {
- frmWiFiTxProfile->Top = 152;
- frmWiFiTxProfile->Left = 152;
- frmWiFiTxProfile->Show();
- }
- void __fastcall TfrmWiFi::btnTXOPUploadFromFlashClick(TObject *Sender)
- {
- if( ! NVRAMMan->Get_IsInit() )
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- if( m_sWiFiCap.support_802_11g || m_sWiFiCap.support_802_11b )
- {
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_ReadTxPower2400MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower2400M_From_NVRAM_Start();
- }
- else if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_ReadTxPower5000MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower5000M_From_NVRAM_Start();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::TXOP_UploadTxPower2400MFromFlashDone( void )
- {
- #if 0
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- char str[20];
- float fdata;
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sTxPwr2400M = m_WIFI_APC_Obj.Get_TxChannelDac2400M();
- if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_ReadTxPower5000MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower5000M_From_NVRAM_Start();
- }
- else
- {
- ReDrawFields( PAGEIDX_TXOP );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting from flash successful";
- CurrentPageReset();
- }
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Upload TX channel power setting, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting timeout";
- Application->MessageBox( "Execution Timeout : Upload TX channel power setting", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting stop";
- CurrentPageReset();
- }
- break;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::TXOP_UploadTxPower5000MFromFlashDone( void )
- {
- #if 0
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- char str[20];
- float fdata;
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sTxPwr5000M = m_WIFI_APC_Obj.Get_TxChannelDac5000M();
- ReDrawFields( PAGEIDX_TXOP );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting from flash successful";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Upload TX channel power setting, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting timeout";
- Application->MessageBox( "Execution Timeout : Upload TX channel power setting", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting stop";
- }
- break;
- }
- CurrentPageReset();
- #endif
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPDownloadToFlashClick(TObject *Sender)
- {
- // if( !CheckFields() )
- // {
- // // sbBB->Panels->Items[0]->Text = (AnsiString) " Write baseband register fail";
- // // Application->MessageBox( "Execution Failure : Write baseband register", "FAILURE", MB_OK );
- // return;
- // }
- if( ! NVRAMMan->Get_IsInit())
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- if( m_sWiFiCap.support_802_11g || m_sWiFiCap.support_802_11b )
- {
- m_WIFI_APC_Obj.Set_TxChannelDac2400M( m_sTxPwr2400M );
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_WriteTxPower2400MToNVRAM;
- m_WIFI_APC_Obj.REQ_Write_TxPower2400M_To_NVRAM_Start();
- }
- else if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.Set_TxChannelDac5000M( m_sTxPwr5000M );
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_WriteTxPower5000MToNVRAM;
- m_WIFI_APC_Obj.REQ_Write_TxPower5000M_To_NVRAM_Start();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::TXOP_DownloadTxPower2400MToFlashDone( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.Set_TxChannelDac5000M( m_sTxPwr5000M );
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_WriteTxPower5000MToNVRAM;
- m_WIFI_APC_Obj.REQ_Write_TxPower5000M_To_NVRAM_Start();
- }
- else
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash successful";
- CurrentPageReset();
- }
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Download TX channel power setting to flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash timeout";
- Application->MessageBox( "Execution Timeout : Download TX channel power setting to flash", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::TXOP_DownloadTxPower5000MToFlashDone( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash successful";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Download TX channel power setting to flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash timeout";
- Application->MessageBox( "Execution Timeout : Download TX channel power setting to flash", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPChangeDBClick(TObject *Sender)
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization fail", "FAILURE", MB_OK );
- return;
- }
- sbTX->Panels->Items[0]->Text = (AnsiString) " Change NVRAM database file successfully";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPLoadFromFileClick(TObject *Sender)
- {
- #if 0
- char str[512];
- bool ok;
- float fdata;
- ok = OpenDialog->Execute();
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load TX channel power setting from file fail";
- return;
- }
- strcpy( str, OpenDialog->FileName.c_str() );
- if( m_sWiFiCap.support_802_11g || m_sWiFiCap.support_802_11b )
- {
- ok = m_WIFI_APC_Obj.REQ_Read_TxPower2400M_From_File( str );
- if( ok )
- {
- m_sTxPwr2400M = m_WIFI_APC_Obj.Get_TxChannelDac2400M();
- }
- else
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load TX channel power setting from file fail";
- Application->MessageBox( "Execution Failure : Load TX channel power setting from file", "FAILURE", MB_OK );
- }
- }
- if( m_sWiFiCap.support_802_11a )
- {
- ok = m_WIFI_APC_Obj.REQ_Read_TxPower5000M_From_File( str );
- if( ok )
- {
- m_sTxPwr5000M = m_WIFI_APC_Obj.Get_TxChannelDac5000M();
- }
- else
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load TX channel power setting from file fail";
- Application->MessageBox( "Execution Failure : Load TX channel power setting from file", "FAILURE", MB_OK );
- }
- }
- ReDrawFields( PAGEIDX_TXOP );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load TX channel power setting from file successfully";
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPSaveToFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- ok = SaveDialog->Execute();
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save TX channel power setting to file fail";
- return;
- }
- strcpy( str, SaveDialog->FileName.c_str() );
- if( m_sWiFiCap.support_802_11g || m_sWiFiCap.support_802_11b )
- {
- m_WIFI_APC_Obj.Set_TxChannelDac2400M( m_sTxPwr2400M );
- ok = m_WIFI_APC_Obj.REQ_Write_TxPower2400M_To_File( str );
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save TX channel power setting to file fail";
- Application->MessageBox( "Execution Failure : Save TX channel power setting to file", "FAILURE", MB_OK );
- return;
- }
- }
- if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.Set_TxChannelDac5000M( m_sTxPwr5000M );
- ok = m_WIFI_APC_Obj.REQ_Write_TxPower5000M_To_File( str );
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save TX channel power setting to file fail";
- Application->MessageBox( "Execution Failure : Save TX channel power setting to file", "FAILURE", MB_OK );
- return;
- }
- }
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save TX channel power setting to file successfully";
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::REQ_TXOP_SetDbmToDac( int dbm )
- {
- #if 0
- WiFi_DBM2DAC_Set_S dbm2dac_set;
- dbm2dac_set.ch_freq = ChannelID_To_ChannelFreq( cbTXOPChannelID->Text.ToInt() );
- dbm2dac_set.tx_rate = (WiFi_TestRate_E) (WiFi_TestRate_E) GetWiFiTxRateFromStr( cbTXOPTXRate->Text );
- dbm2dac_set.dbm = dbm;
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_SetDbmToDac;
- m_WIFI_APC_Obj.REQ_SetDbmToDac_Start( dbm2dac_set );
- #endif
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CNF_TXOP_SetDbmToDac( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Set dBm to DAC successful";
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_TXOP_QueryDbmToDac;
- m_WIFI_APC_Obj.REQ_QueryDbmToDac_Start( );
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Set dBm to DAC fail";
- Application->MessageBox( "Execution Failure : Set dBm to DAC", "FAILURE", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Set dBm to DAC timeout";
- Application->MessageBox( "Execution Timeout : Set dBm to DAC", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Set dBm to DAC stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CNF_TXOP_QueryDbmToDac( void )
- {
- #if 0
- E_METAAPP_RESULT_T state = m_WIFI_APC_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- ReDrawFields( PAGEIDX_TXOP );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Query dBm to DAC successful";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Query dBm to DAC fail";
- Application->MessageBox( "Execution Failure : Query dBm to DAC", "FAILURE", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Query dBm to DAC timeout";
- Application->MessageBox( "Execution Timeout : Query dBm to DAC", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Set dBm to DAC stop";
- }
- break;
- }
- CurrentPageReset();
- #endif
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXOPMaxClick(TObject *Sender)
- {
- REQ_TXOP_SetDbmToDac( WIFI_DBM_MAX );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXOP0dBmClick(TObject *Sender)
- {
- REQ_TXOP_SetDbmToDac( WIFI_DBM_0 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXOP5dBmClick(TObject *Sender)
- {
- REQ_TXOP_SetDbmToDac( WIFI_DBM_5 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXOP10dBmClick(TObject *Sender)
- {
- REQ_TXOP_SetDbmToDac( WIFI_DBM_10 );
- }
- //===========================================================================
- ////////////////////////////////// MCR //////////////////////////////
- //===========================================================================
- void TfrmWiFi::AllocateMCRVector( void )
- {
- if( NULL == m_pvMCRDisp )
- {
- m_pvMCRDisp = new vector<WiFi_MACReg32_S>;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::EraseMCRVector( void )
- {
- if( NULL == m_pvMCRDisp )
- {
- if( ! m_pvMCRDisp->empty() )
- {
- m_pvMCRDisp->erase( m_pvMCRDisp->begin(), m_pvMCRDisp->end() );
- }
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::DeAllocateMCRVector( void )
- {
- if( m_pvMCRDisp != NULL )
- {
- if( ! m_pvMCRDisp->empty() )
- {
- m_pvMCRDisp->erase( m_pvMCRDisp->begin(), m_pvMCRDisp->end() );
- }
- delete m_pvMCRDisp;
- m_pvMCRDisp = NULL;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::AllocateMCR16Vector( void )
- {
- if( NULL == m_pvMCR16Disp )
- {
- m_pvMCR16Disp = new vector<WiFi_MACReg16_S>;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::EraseMCR16Vector( void )
- {
- if( NULL == m_pvMCR16Disp )
- {
- if( ! m_pvMCR16Disp->empty() )
- {
- m_pvMCR16Disp->erase( m_pvMCR16Disp->begin(), m_pvMCR16Disp->end() );
- }
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::DeAllocateMCR16Vector( void )
- {
- if( m_pvMCR16Disp != NULL )
- {
- if( ! m_pvMCR16Disp->empty() )
- {
- m_pvMCR16Disp->erase( m_pvMCR16Disp->begin(), m_pvMCR16Disp->end() );
- }
- delete m_pvMCR16Disp;
- m_pvMCR16Disp = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACDumpAllMacRegClick(TObject *Sender)
- {
- if( !CheckFields( ACCESS_DUMP, OP_READ ) )
- {
- sbBB->Panels->Items[0]->Text = (AnsiString) " Dump baseband registers fail";
- Application->MessageBox( "Execution Failure : Dump baseband registers", "FAILURE", MB_OK );
- return;
- }
-
- CurrentPageLock();
- FillMACResult(true);
- m_WIFI_MAC_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllMACReg;
- m_uiMACCount=0;
- if( rbMAC16bits->Checked )
- {
- AllocateMCR16Vector();
- EraseMCR16Vector();
- Compose_MCR16_Parameter( ACCESS_DUMP );
- m_WIFI_MAC_Obj.REQ_Read_MCR16_Setting_From_Reg_Start( m_sMCR16 );
- }
- else
- {
- AllocateMCRVector();
- EraseMCRVector();
- Compose_MCR_Parameter( ACCESS_DUMP );
- m_WIFI_MAC_Obj.REQ_Read_MCR_Setting_From_Reg_Start( m_sMCR );
- }
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump all MAC register progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadAllMACReg( void )
- {
- int state = m_WIFI_MAC_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_MAC_OK:
- {
- if( rbMAC16bits->Checked )
- {
- m_sMCR16 = m_WIFI_MAC_Obj.Get_MCR16();
- for (unsigned int i=0; i<m_sMCR16.count; i++ )
- {
- m_pvMCR16Disp->push_back( m_sMCR16.mac_reg16[i] );
- }
- }
- else
- {
- m_sMCR = m_WIFI_MAC_Obj.Get_MCR();
- for (unsigned int i=0; i<m_sMCR.count; i++)
- {
- m_pvMCRDisp->push_back(m_sMCR.mac_reg32[i]);
- }
- }
- m_WIFI_MAC_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllMACReg;
- if( rbMAC16bits->Checked )
- {
- if( m_sMCR16.mac_reg16[m_sMCR16.count-1].index < m_uiMacEndAddr )
- {
- Compose_MCR16_Parameter( ACCESS_DUMP );
- m_WIFI_MAC_Obj.REQ_Read_MCR16_Setting_From_Reg_Start( m_sMCR16 );
- }
- else
- {
- FillMACResult( false );
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump MAC registers successfully";
- CurrentPageReset();
- }
- }
- else
- {
- if( m_sMCR.mac_reg32[m_sMCR.count-1].index < m_uiMacEndAddr )
- {
- Compose_MCR_Parameter( ACCESS_DUMP );
- m_WIFI_MAC_Obj.REQ_Read_MCR_Setting_From_Reg_Start( m_sMCR );
- }
- else
- {
- FillMACResult( false );
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump MAC registers successfully";
- CurrentPageReset();
- }
- }
- }
- break;
- // case STATE_MAC_SECTION_OK:
- // {
- // FillMACResult( false );
- // m_WIFI_MAC_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllMACReg;
- // // m_WIFI_MAC_Obj.REQ_Read_From_AllReg();
- //
- // // sbBB->Panels->Items[0]->Text = (AnsiString)" Dump all baseband register successfully";
- // }
- // break;
- case STATE_MAC_FAIL:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump MAC registers fail";
- Application->MessageBox( "Execution Timeout : Dump MAC registers", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_MAC_TIMEOUT:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump MAC registers timeout";
- Application->MessageBox( "Execution Timeout : Dump MAC registers", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_MAC_STOP:
- {
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Dump MAC registers stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //============================================================================
- ////////////////////////////////// EEPRM //////////////////////////////
- //============================================================================
- //--------------------------------------------------------------------------
- void TfrmWiFi::AllocateEEPROMVector( void )
- {
- if( NULL == m_pvEEDisp )
- {
- m_pvEEDisp = new vector<WiFi_EEPROM_S>;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::EraseEEPROMVector( void )
- {
- if( NULL == m_pvEEDisp )
- {
- if( ! m_pvEEDisp->empty() )
- {
- m_pvEEDisp->erase( m_pvEEDisp->begin(), m_pvEEDisp->end() );
- }
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::DeAllocateEEPROMVector( void )
- {
- if( m_pvEEDisp != NULL )
- {
- if( ! m_pvEEDisp->empty() )
- {
- m_pvEEDisp->erase( m_pvEEDisp->begin(), m_pvEEDisp->end() );
- }
- delete m_pvEEDisp;
- m_pvEEDisp = NULL;
- }
- }
- //----------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEClick(TObject *Sender)
- {
- if( !CheckFields( ACCESS_DUMP, OP_READ ) )
- {
- sbEE->Panels->Items[0]->Text = (AnsiString) " Dump EEPROM fail";
- Application->MessageBox( "Execution Failure : Dump EEPROM", "FAILURE", MB_OK );
- return;
- }
- FillEEResult(true);
- CurrentPageLock();
- m_uiEEPROMCount = 0;
- Compose_EEPROM_Parameter( ACCESS_DUMP );
- // m_uiDispEEPROMCount = 0;
- AllocateEEPROMVector();
- EraseEEPROMVector();
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- sbEE->Panels->Items[0]->Text = (AnsiString)" Dump EEPROM progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadAllEE( void )
- {
- int state = m_WIFI_EE_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sEE = m_WIFI_EE_Obj.Get_EE();
- for (unsigned int i=0; i<m_sEE.count; i++ )
- {
- WiFi_EEPROM_S eeprom;
- eeprom.index = m_sEE.eeprom[i].index;
- eeprom.eeprom_data16 = m_sEE.eeprom[i].eeprom_data16;
- m_pvEEDisp->push_back( eeprom );
- }
- // m_uiDispEEPROMCount += m_sEE.count;
- //FillEEResult( false );
- if( m_sEE.eeprom[m_sEE.count-1].index < m_uiEEPROMEndIdx )
- {
- Compose_EEPROM_Parameter( ACCESS_DUMP );
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- }
- else
- {
- FillEEResult( false );
- sbEE->Panels->Items[0]->Text = (AnsiString)" Dump all EEPROM successfully";
- CurrentPageReset();
- }
- }
- break;
- // case STATE_EE_SECTION_OK:
- // {
- // FillEEResult( false );
- // m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadAllEE;
- // m_WIFI_EE_Obj.REQ_Read_From_AllEE();
- //
- // sbBB->Panels->Items[0]->Text = (AnsiString)" Dump all baseband register successfully";
- // }
- // break;
- case METAAPP_FAIL:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Dump all EEPROM fail";
- Application->MessageBox( "Execution Timeout : Dump all EEPROM", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Dump all EEPROM timeout";
- Application->MessageBox( "Execution Timeout : Dump all EEPROM", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbEE->Panels->Items[0]->Text = (AnsiString)" Dump all EEPROM stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //----------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnPSStartClick(TObject *Sender)
- {
- CurrentPageLock();
- m_WIFI_PS_Obj.ConfirmCallback = ::ConfirmCallback_PS;
- m_WIFI_PS_Obj.REQ_Start( (WiFi_PowerManagementMode_E) cbPSPowerMode->ItemIndex +1);
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_PS( void )
- {
- int state = m_WIFI_PS_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_PS_OK:
- {
- sbPS->Panels->Items[0]->Text = (AnsiString)" Power saving test progressing";
- }
- break;
- case STATE_PS_FAIL:
- {
- sbPS->Panels->Items[0]->Text = (AnsiString)" Power saving test fail";
- Application->MessageBox( "Execution Timeout : Power saving test ", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_PS_TIMEOUT:
- {
- sbPS->Panels->Items[0]->Text = (AnsiString)" Power saving test timeout";
- Application->MessageBox( "Execution Timeout : Power saving test ", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_PS_STOP:
- {
- sbPS->Panels->Items[0]->Text = (AnsiString)" Power saving test stop";
- CurrentPageReset();
- }
- break;
- }
- }
- void __fastcall TfrmWiFi::btnPSStopClick(TObject *Sender)
- {
- if( 1 == btnPSStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbPS->Panels->Items[0]->Text = (AnsiString)" Stop power saving test successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnCPRQueryRxCounterClick(TObject *Sender)
- {
- CurrentPageLock();
- m_WIFI_CPRX_Obj.ConfirmCallback = ::ConfirmCallback_QueryRxCounter;
- m_WIFI_CPRX_Obj.REQ_QueryRxCounter_Start();
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_QueryRxCounter( void )
- {
- int state = m_WIFI_CPRX_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_CPRX_OK:
- {
- WiFi_RxCounter_S rx_counter;
- rx_counter = m_WIFI_CPRX_Obj.Get_RxCounter();
- stCPRED->Caption = IntToStr( rx_counter.ED );
- stCPROSD->Caption = IntToStr( rx_counter.OSD );
- stCPRSQ1->Caption = IntToStr( rx_counter.SQ1 );
- stCPRSFD->Caption = IntToStr( rx_counter.SFD );
- stCPRCRC16->Caption = IntToStr( rx_counter.CRC16 );
-
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX counter successfully";
- }
- break;
- case STATE_CPRX_FAIL:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX counter fail";
- Application->MessageBox( "Execution Failure : Query continuous packet RX counter", "FAILURE", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_CPRX_TIMEOUT:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX counter timeout";
- Application->MessageBox( "Execution Timeout : Query continuous packet RX counter", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_CPRX_STOP:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Query continuous packet RX status stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXTxPowerDacClick(TObject *Sender)
- {
- if( 0 == btnTXTxPowerDac->Tag ) // Dec-->Hex
- { btnTXTxPowerDac->Tag = 1;
- }
- else //Hex-->Dec
- { btnTXTxPowerDac->Tag = 0;
- }
- ReDrawFields( PAGEIDX_TXALL );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPTxPowerDacClick(TObject *Sender)
- {
- #if 0
- if( 0 == btnTXOPTxPowerDac->Tag ) // Dec-->Hex
- { btnTXOPTxPowerDac->Tag = 1;
- }
- else //Hex-->Dec
- { btnTXOPTxPowerDac->Tag = 0;
- }
- ReDrawFields( PAGEIDX_TXOP );
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXCSTxPowerDacClick(TObject *Sender)
- {
- #if 0
- if( 0 == btnTXTxPowerDac->Tag ) // Dec-->Hex
- { btnTXTxPowerDac->Tag = 1;
- }
- else //Hex-->Dec
- { btnTXTxPowerDac->Tag = 0;
- }
- ReDrawFields( PAGEIDX_TXCS );
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnLFTxPowerDacClick(TObject *Sender)
- {
- #if 0
- if( 0 == btnLFTxPowerDac->Tag ) // Dec-->Hex
- { btnLFTxPowerDac->Tag = 1;
- }
- else //Hex-->Dec
- { btnLFTxPowerDac->Tag = 0;
- }
- ReDrawFields( PAGEIDX_LF );
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXOPTxPowerDACCheck(TObject *Sender)
- {
- #if 0
- unsigned char us_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- text = edit->Text;
- if( 0 == btnTXOPTxPowerDac->Tag ) // Dec
- {
- if( !IsValidDecWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sTxPwr2400M.CCKTxPWR[cbTXOPChannelID->ItemIndex] = uc_data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXCSTxPowerDACCheck(TObject *Sender)
- {
- #if 0
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- text = edit->Text;
- if( 0 == btnTXCSTxPowerDac->Tag ) // Dec
- {
- if( !IsValidDecWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sTxPwr2400M.CCKTxPWR[cbTXCSChannelID->ItemIndex] = uc_data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtLFTxPowerDACCheck(TObject *Sender)
- {
- #if 0
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- text = edit->Text;
- if( 0 == btnTXTxPowerDac->Tag ) // Dec
- {
- if( !IsValidDecWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiTxPowerDac( text, uc_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sTxPwr2400M.CCKTxPWR[cbLFChannelID->ItemIndex] = uc_data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::miCopyClick(TObject *Sender)
- {
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_BB:
- {
- memBBResult->SelectAll();
- memBBResult->CopyToClipboard();
- }
- break;
- case PAGEIDX_MAC:
- {
- memMACResult->SelectAll();
- memMACResult->CopyToClipboard();
- }
- break;
- case PAGEIDX_EE:
- {
- memEEResult->SelectAll();
- memEEResult->CopyToClipboard();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBStopClick(TObject *Sender)
- {
- if( 1 == btnBBRead->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbBB->Panels->Items[0]->Text = (AnsiString)" Stop baseband register read/write successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACStopClick(TObject *Sender)
- {
- if( 1 == btnMACRead->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Stop MAC register read/write successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEStopClick(TObject *Sender)
- {
- if( 1 == btnEERead->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbEE->Panels->Items[0]->Text = (AnsiString)" Stop EEPRom read/write successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXOPClick(TObject *Sender)
- {
- DisableCPTUIComponent();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXCSClick(TObject *Sender)
- {
- DisableCPTUIComponent();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbTXLFClick(TObject *Sender)
- {
- DisableCPTUIComponent();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbCPTClick(TObject *Sender)
- {
- EnableCPTUIComponent();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXCalTxDCClick(TObject *Sender)
- {
- m_WIFI_TXDC_Obj.ConfirmCallback = ::ConfirmCallback_TxDcOffsetCal;
- m_WIFI_TXDC_Obj.REQ_TxDcOffsetCal_Start();
- CurrentPageLock();
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX DC offset calibration progressing";
- }
- //-------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_TxDcOffsetCal( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_TXDC_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sTxDcOffset = m_WIFI_TXDC_Obj.Get_TxDcOffset();
- ReDrawFields( PAGEIDX_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX DC offset calibration successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX DC offset calibration fail";
- Application->MessageBox( "Execution Failure : TX DC offset calibration", "FAILURE", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX DC offset calibration timeout";
- Application->MessageBox( "Execution Timeout : TX DC offset calibration TX", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX DC offset calibration stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXFramCtrlCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderFrameCtrl( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.frame_ctrl[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXDurationCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderDuration( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.duration[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXAddress1Check(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.address1[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXAddress2Check(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.address2[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXAddress3Check(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.address3[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXSeqCtrlCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacHeaderSeqCtrl( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sWiFiCPT.s_mac_header.seq_ctrl[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXIDcOffsetCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( 0 == btnTXIDC->Tag ) // Dec
- {
- if( !IsValidDecWiFiTxDcOffset( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else
- {
- if( !IsValidHexWiFiTxDcOffset( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sTxDcOffset.i_ch_offset = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtTXQDCOffsetCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( 0 == btnTXQDC->Tag ) // Dec
- {
- if( !IsValidDecWiFiTxDcOffset( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else
- {
- if( !IsValidHexWiFiTxDcOffset( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_sTxDcOffset.q_ch_offset = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXIDCClick(TObject *Sender)
- {
- if( 0 == btnTXIDC->Tag ) // Dec-->Hex
- { btnTXIDC->Tag = 1;
- }
- else //Hex-->Dec
- { btnTXIDC->Tag = 0;
- }
- ReDrawFields( PAGEIDX_TXALL );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXQDCClick(TObject *Sender)
- {
- if( 0 == btnTXQDC->Tag ) // Dec-->Hex
- { btnTXQDC->Tag = 1;
- }
- else //Hex-->Dec
- { btnTXQDC->Tag = 0;
- }
- ReDrawFields( PAGEIDX_TXALL );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXDCUploadFromFlashClick(TObject *Sender)
- {
- if( ! NVRAMMan->Get_IsInit() )
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_ReadTxDCFromNVRAM;
- m_WIFI_TXDC_Obj.REQ_Read_From_NVRAM_Start();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXDCDownloadToFlashClick(TObject *Sender)
- {
- if( ! NVRAMMan->Get_IsInit() )
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- m_WIFI_TXDC_Obj.Set_TxDcOffset( m_sTxDcOffset );
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_WriteTxDCToNVRAM;
- m_WIFI_TXDC_Obj.REQ_Write_To_NVRAM_Start();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBRegSettingClick(TObject *Sender)
- {
- frmWiFiBBCR->Top = 1;
- frmWiFiBBCR->Left = 77;
- frmWiFiBBCR->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACRegSettingClick(TObject *Sender)
- {
- frmWiFiMCR->Top = 1;
- frmWiFiMCR->Left = 77;
- frmWiFiMCR->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnSCStartClick(TObject *Sender)
- {
- if( stSCScriptFile->Caption.AnsiCompareIC("") == 0 )
- {
- stSC->Panels->Items[0]->Text = (AnsiString)" Please select script file before start test";
- Application->MessageBox( "Execution Timeout : Please select script file before start test", "FAIL", MB_OK );
- return;
- }
- S_WIFISC wifisc;
- wifisc.hPostMsgDestHandle = this->Handle;
- wifisc.filename = stSCScriptFile->Caption;
- wifisc.log = m_pSCLog;
- CurrentPageLock();
- m_WIFI_SC_Obj.ConfirmCallback = ::ConfirmCallback_SC;
- m_WIFI_SC_Obj.REQ_Start( wifisc );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_SC( void )
- {
- int state = m_WIFI_SC_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_SC_OK:
- {
- stSC->Panels->Items[0]->Text = (AnsiString)" Script test successfully";
- }
- break;
- case STATE_SC_FAIL:
- {
- stSC->Panels->Items[0]->Text = (AnsiString)" Script test fail";
- Application->MessageBox( "Execution Fail : Script test", "FAIL", MB_OK );
- // Force_WiFi_Stop();
- }
- break;
- case STATE_SC_TIMEOUT:
- {
-
- stSC->Panels->Items[0]->Text = (AnsiString)" Script test timeout";
- Application->MessageBox( "Execution Timeout : Script test", "TIMEOUT", MB_OK );
- //Force_WiFi_Stop();
- }
- break;
- case STATE_SC_STOP:
- stSC->Panels->Items[0]->Text = (AnsiString)" Script test stop";
- break;
- }
- FillSCResult();
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnSCStopClick(TObject *Sender)
- {
- if( 1 == btnSCStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- stSC->Panels->Items[0]->Text = (AnsiString)" Stop script test successfully";
- }
- }
- //---------------------------------------------------------------------------
- //===========================================================================
- void __fastcall TfrmWiFi::btnSCScriptFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- ok = dlgOpenScriptFile->Execute();
- if( !ok )
- {
- stSC->Panels->Items[0]->Text = (AnsiString) " Load script file fail";
- return;
- }
- strcpy( str, dlgOpenScriptFile->FileName.c_str() );
- //ok = m_WIFI_SC_Obj.REQ_Open_File( str );
- stSCScriptFile->Caption = str;
- stSC->Panels->Items[0]->Text = (AnsiString) " Setup script file successfully";
-
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::FillSCResult( void )
- {
- for(int i=0; i<m_pSCLog->Count; i++ )
- {
- memSCResult->Lines->Add(m_pSCLog->Strings[i]);
- }
- m_pSCLog->Clear();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnEEPROMSettingClick(TObject *Sender)
- {
- frmWiFiEEPROM->Top = 1;
- frmWiFiEEPROM->Left = 77;
- frmWiFiEEPROM->Show();
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void TfrmWiFi::Compose_BBCR_Parameter( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sBBCR.count = 1;
- m_sBBCR.bb_reg8[0].index = m_uiBBIdx;
- }
- else
- {
- m_sBBCR.count = m_uiBBEndIdx - m_uiBBBeginIdx - m_uiBBCount*WIFI_MAX_COUNT + 1;
- if( m_sBBCR.count > WIFI_MAX_COUNT ) m_sBBCR.count = WIFI_MAX_COUNT;
- for (unsigned int i=0; i<m_sBBCR.count; i++)
- {
- m_sBBCR.bb_reg8[i].index = m_uiBBBeginIdx + i + m_uiBBCount*WIFI_MAX_COUNT;;
- }
- m_uiBBCount++;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Compose_BBCR_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sBBCR.bb_reg8[0].bbcr_data8 = m_ucBBValue;
- }
- else
- {
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::DeCompose_BBCR_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_ucBBValue = m_sBBCR.bb_reg8[0].bbcr_data8;
- }
- else
- {
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::Compose_MCR_Parameter( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sMCR.count = 1;
- m_sMCR.mac_reg32[0].index = m_uiMacAddr;
- }
- else
- {
- int data_size = sizeof(m_sMCR.mac_reg32[0].mcr_data32);
- m_sMCR.count = (m_uiMacEndAddr - m_uiMacBeginAddr)/data_size + 1 - m_uiMACCount*WIFI_MAX_COUNT;
- if( m_sMCR.count > WIFI_MAX_COUNT ) m_sMCR.count = WIFI_MAX_COUNT;
- for (unsigned int i=0; i<m_sMCR.count; i++)
- {
- m_sMCR.mac_reg32[i].index = m_uiMacBeginAddr + (i + m_uiMACCount*WIFI_MAX_COUNT)*data_size;
- }
- m_uiMACCount++;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Compose_MCR_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sMCR.mac_reg32[0].mcr_data32 = m_uiMacData;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::DeCompose_MCR_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_uiMacData = m_sMCR.mac_reg32[0].mcr_data32;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::Compose_MCR16_Parameter( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sMCR16.count = 1;
- m_sMCR16.mac_reg16[0].index = m_uiMacAddr;
- }
- else
- {
- int data_size = sizeof(m_sMCR16.mac_reg16[0].mcr_data16);
- m_sMCR16.count = (m_uiMacEndAddr - m_uiMacBeginAddr)/data_size + 1 - m_uiMACCount*WIFI_MAX_COUNT;
- if( m_sMCR16.count > WIFI_MAX_COUNT ) m_sMCR16.count = WIFI_MAX_COUNT;
- for (unsigned int i=0; i<m_sMCR16.count; i++)
- {
- m_sMCR16.mac_reg16[i].index = m_uiMacBeginAddr + (i + m_uiMACCount*WIFI_MAX_COUNT)*data_size;
- }
- m_uiMACCount++;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Compose_MCR16_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sMCR16.mac_reg16[0].mcr_data16 = m_usMac16Data;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::DeCompose_MCR16_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_usMac16Data = m_sMCR16.mac_reg16[0].mcr_data16;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::Compose_EEPROM_Parameter( E_ACCESS_TYPE type )
- {
- switch( type )
- {
- case ACCESS_SINGLE:
- {
- m_sEE.count = 1;
- m_sEE.eeprom[0].index = m_uiEEPROMIdx;
- }
- break;
- case ACCESS_DUMP:
- {
- // int data_size = sizeof(m_sEE.eeprom[0].eeprom_data16);
- m_sEE.count = (m_uiEEPROMEndIdx - m_uiEEPROMBeginIdx) -m_uiEEPROMCount*WIFI_MAX_COUNT + 1;
- if( m_sEE.count > WIFI_MAX_COUNT ) m_sEE.count = WIFI_MAX_COUNT;
- for (unsigned int i=0; i<m_sEE.count; i++)
- {
- m_sEE.eeprom[i].index = m_uiEEPROMBeginIdx + (i+ m_uiEEPROMCount*WIFI_MAX_COUNT);
- }
- m_uiEEPROMCount++;
- }
- break;
- case ACCESS_TX_POWER:
- {
- m_sEE.count = 14;
- for (unsigned int i=0; i<m_sEE.count; i++)
- {
- m_sEE.eeprom[i].index = ADDR_MT5911_EEPROM_2_4G_CCK_TX_POWER + i;
- }
- }
- break;
- case ACCESS_TX_DC_OFFSET:
- {
- m_sEE.count = 1;
- m_sEE.eeprom[0].index = ADDR_MT5911_EEPROM_DAC_IQ_OFFSET;
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Compose_EEPROM_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_sEE.eeprom[0].eeprom_data16 = m_usEEPROMData;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::DeCompose_EEPROM_Data( E_ACCESS_TYPE type )
- {
- if( ACCESS_SINGLE == type )
- {
- m_usEEPROMData = m_sEE.eeprom[0].eeprom_data16;
- }
- }
- //===========================================================================
- void __fastcall TfrmWiFi::edtBBBeginCRIndexCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value should be 0~127 ";
- text = edit->Text;
- if( !IsValidDecWiFiBBRegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( uidata > 127 )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_uiBBBeginIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtBBEndCRIndexCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value should be 0~127 ";
- text = edit->Text;
- if( !IsValidDecWiFiBBRegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( uidata > 127 )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_uiBBEndIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtMACBeginMCRAddrCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- char hint16[] = " value should be multiple of 2 ";
- char hint32[] = " value should be multiple of 4 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacRegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( rbMAC16bits->Checked )
- {
- if( 0 != uidata%2 )
- {
- ShowHintLabel( edit, hint16 );
- edit->SetFocus();
- return;
- }
- }
- else
- {
- if( 0 != uidata%4 )
- {
- ShowHintLabel( edit, hint32 );
- edit->SetFocus();
- return;
- }
- }
- m_uiMacBeginAddr = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtMACEndMCRAddrCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- char hint16[] = " value should be multiple of 2 ";
- char hint32[] = " value should be multiple of 4 ";
- text = edit->Text;
- if( !IsValidHexWiFiMacRegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( rbMAC16bits->Checked )
- {
- if( 0 != uidata%2 )
- {
- ShowHintLabel( edit, hint16 );
- edit->SetFocus();
- return;
- }
- }
- else
- {
- if( 0 != uidata%4 )
- {
- ShowHintLabel( edit, hint32 );
- edit->SetFocus();
- return;
- }
- }
- m_uiMacEndAddr = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtBeginEEIndexCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- AnsiString as_hint = " value is not valid";
- char hint[256];
- strcpy( hint, as_hint.c_str() );
- text = edit->Text;
- if( !IsValidHexWiFiEERegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- // if( uidata >= m_sWiFiCap.eeprom_size-1 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- // if( 0 != uidata%2 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- m_uiEEPROMBeginIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtEndEEIndexCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- AnsiString as_hint = " value should be multiple of 2, ragne 0~" + IntToStr(m_sWiFiCap.eeprom_size-1);
- char hint[256];
- strcpy( hint, as_hint.c_str() );
- text = edit->Text;
- if( !IsValidHexWiFiEERegAddr( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- // if( uidata >= m_sWiFiCap.eeprom_size-1 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- // if( 0 != uidata%2 )
- // {
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- m_uiEEPROMEndIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbMAC32bitsClick(TObject *Sender)
- {
- edtMACMCRAddressCheck( edtMACMCRAddress );
- edtMACBeginMCRAddrCheck( edtMACBeginMCRAddr );
- edtMACEndMCRAddrCheck( edtMACEndMCRAddr );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbMAC16bitsClick(TObject *Sender)
- {
- edtMACMCRAddressCheck( edtMACMCRAddress );
- edtMACBeginMCRAddrCheck( edtMACBeginMCRAddr );
- edtMACEndMCRAddrCheck( edtMACEndMCRAddr );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnLoadTxPowerFromEEClick(TObject *Sender)
- {
- CurrentPageLock();
- Compose_EEPROM_Parameter( ACCESS_TX_POWER );
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadTxPowerFromEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM progressing";
- }
- //-------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadTxPowerFromEE( void )
- {
- int state = m_WIFI_EE_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sEE = m_WIFI_EE_Obj.Get_EE();
- WiFiTxPowerEEToNVRAM();
- Compose_EEPROM_Parameter( ACCESS_TX_DC_OFFSET );
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadTxDcOffsetFromEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM fail";
- Application->MessageBox( "Execution Timeout : Load WiFi TX power from EEPROM", "FAIL", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM timeout";
- Application->MessageBox( "Execution Timeout : Load WiFi TX power from EEPROM", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //----------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadTxDcOffsetFromEE(void)
- {
- E_METAAPP_RESULT_T state = m_WIFI_EE_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- m_sEE = m_WIFI_EE_Obj.Get_EE();
- WiFiTxDcOffsetEEToNVRAM();
- ReDrawFields( PAGEIDX_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM fail";
- Application->MessageBox( "Execution Timeout : Load WiFi TX power from EEPROM", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM timeout";
- Application->MessageBox( "Execution Timeout : Load WiFi TX power from EEPROM", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX power from EEPROM stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::WiFiTxPowerEEToNVRAM( void )
- {
- int i;
- for(i=0; i<NUM_TX_POWER_2400M_CH/2; i++)
- {
- m_sTxPwr2400M.CCKTxPWR[2*i] = (unsigned char) m_sEE.eeprom[i].eeprom_data16 & 0x00FF;
- m_sTxPwr2400M.CCKTxPWR[2*i+1] = (unsigned char) ( (m_sEE.eeprom[i].eeprom_data16 & 0xFF00)>>8 );
- }
- for(i=0; i<NUM_TX_POWER_2400M_CH/2; i++)
- {
- m_sTxPwr2400M.OFDMTxPWR[2*i] = (unsigned char) m_sEE.eeprom[i+NUM_TX_POWER_2400M_CH/2].eeprom_data16 & 0x00FF;
- m_sTxPwr2400M.OFDMTxPWR[2*i+1] = (unsigned char) ((m_sEE.eeprom[i+NUM_TX_POWER_2400M_CH/2].eeprom_data16 & 0xFF00)>>8);
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::WiFiTxDcOffsetEEToNVRAM( void )
- {
- m_sTxDcOffset.i_ch_offset = (unsigned char) ((m_sEE.eeprom[0].eeprom_data16 >> 8) & 0x001F);
- m_sTxDcOffset.q_ch_offset = (unsigned char) (m_sEE.eeprom[0].eeprom_data16 & 0x001F );
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXLoadTxDcOffsetFromEEClick(TObject *Sender)
- {
- CurrentPageLock();
- Compose_EEPROM_Parameter( ACCESS_TX_DC_OFFSET );
- m_WIFI_EE_Obj.ConfirmCallback = ::ConfirmCallback_ReadTxDcOffsetFromEE;
- m_WIFI_EE_Obj.REQ_Read_From_EE_Start( m_sEE );
- sbTX->Panels->Items[0]->Text = (AnsiString)" Load WiFi TX DC offset from EEPROM progressing";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbEEByteClick(TObject *Sender)
- {
- FillEEResult(true);
- FillEEResult(false);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::rbEEWordClick(TObject *Sender)
- {
- FillEEResult(true);
- FillEEResult(false);
- }
- void __fastcall TfrmWiFi::m_btnTxAlcClick(TObject *Sender)
- {
- frmWiFiALC2400M->Top = 152;
- frmWiFiALC2400M->Left = 152;
- frmWiFiALC2400M->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- m_sWiFiCap = frmMainSel->Get_FinalWiFiCap();
- m_bAlcSupport = m_cWIFI_ALC_Obj.REQ_Query_ALC_Suppport_Start();
- m_btnTxAlc->Visible = m_bAlcSupport;
- m_cbTXTargetGain->Visible = m_bAlcSupport;
- m_cbTXAlcTracking->Visible = m_bAlcSupport;
- m_cbTargetAlc->Visible = m_bAlcSupport;
- m_lblTXTargetAlc->Visible = m_bAlcSupport;
- m_edtTXTargetAlc->Visible = m_bAlcSupport;
- m_lblAverageALC->Visible = m_bAlcSupport;
- m_stAverageALC->Visible = m_bAlcSupport;
- m_lblTXCCKGainControl->Visible = m_bAlcSupport;
- m_stTXCCKGainControl->Visible = m_bAlcSupport;
- m_lblTXOFDMGainControl->Visible = m_bAlcSupport;
- m_stTXOFDMGainControl->Visible = m_bAlcSupport;
- DisplayWiFiChannel();
- DisplayWiFiTxRate();
- }
- }
- //---------------------------------------------------------------------------