form_WiFI.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:191k
- //--------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- // form
- #ifndef _FORM_WiFI_H_
- #include "form_WiFI.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- #ifndef _FORM_WIFITXPROFILE_H_
- #include "form_wifitxprofile.h"
- #endif
- #ifndef _FORM_WIFIALC2400M_H_
- #include "form_WiFiALC2400M.h"
- #endif
- #ifndef _FORM_WIFIBBCR_H_
- #include "form_wifibbcr.h"
- #endif
- #ifndef _FORM_WIFIMCR_H_
- #include "form_wifimcr.h"
- #endif
- #ifndef _FORM_WIFIEEPROM_H_
- #include "form_WiFiEEPROM.h"
- #endif
- // WiFi
- #ifndef _WIFI_COMMON_H_
- #include "wifi_common.h"
- #endif
- #ifndef _MT5911_COMMON_H_
- #include "mt5911_common.h"
- #endif
- // man
- #ifndef _MAN_FDM_H_
- #include "man_fdm.h"
- #endif
- // Misc.
- #ifndef _MISC_WIFI_H_
- #include "misc_wifi.h"
- #endif
- // message
- #ifndef _META_LAB_MSG_H_
- #include "meta_lab_msg.h"
- #endif
- #define WIFI_DBM_MAX 0
- #define WIFI_DBM_0 1
- #define WIFI_DBM_5 2
- #define WIFI_DBM_10 3
- // bit pattern
- #define WIFI_IDX_ALL_0 0
- #define WIFI_IDX_ALL_1 1
- #define WIFI_IDX_ALTERNATE 2
- #define WIFI_IDX_RANDOM 3
- enum
- {
- PAGEIDX_TXALL=0,
- PAGEIDX_CPRX,
- PAGEIDX_PS,
- PAGEIDX_BB,
- PAGEIDX_MAC,
- PAGEIDX_EE,
- PAGEIDX_SC,
- PAGEIDX_NONE
- };
- enum
- {
- TYPEIDX_CPTX=0,
- TYPEIDX_TXOP,
- TYPEIDX_TXCS,
- TYPEIDX_LF
- };
- enum
- {
- IDX_TX_FILTER_NORTH_AMERICA=0,
- IDX_TX_FILTER_JAPAN
- };
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmWiFi *frmWiFi;
- extern bool g_bHideEnable;
- //===========================================================================
- void ConfirmCallback_QueryChannelList( void )
- { frmWiFi->ConfirmCallback_QueryChannelList();
- }
- //--------------------------------------------------------------------------
- static void ConfirmCallback_CPT( void )
- { frmWiFi->ConfirmCallback_CPT();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_QueryTxStatus( void )
- { frmWiFi->ConfirmCallback_QueryTxStatus();
- }
- //---------------------------------------------------------------------------
- static void CNF_CPTX_ReadTxPower2400MFromNVRAM( void )
- { frmWiFi->CPTX_UploadTxPower2400MFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_CPTX_WriteTxPower2400MToNVRAM( void )
- { frmWiFi->CPTX_DownloadTxPower2400MToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_CPTX_ReadTxPower5000MFromNVRAM( void )
- { frmWiFi->CPTX_UploadTxPower5000MFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadTxDCFromNVRAM( void )
- { frmWiFi->UploadTxDCFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_CPTX_WriteTxPower5000MToNVRAM( void )
- { frmWiFi->CPTX_DownloadTxPower5000MToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_ReadTxPower2400MFromNVRAM( void )
- { frmWiFi->TXOP_UploadTxPower2400MFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_WriteTxPower2400MToNVRAM( void )
- { frmWiFi->TXOP_DownloadTxPower2400MToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_ReadTxPower5000MFromNVRAM( void )
- { frmWiFi->TXOP_UploadTxPower5000MFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_WriteTxPower5000MToNVRAM( void )
- { frmWiFi->TXOP_DownloadTxPower5000MToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteTxDCToNVRAM( void )
- { frmWiFi->DownloadTxDCToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_CPRX( void )
- { frmWiFi->ConfirmCallback_CPRX();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_QueryOriRxStatus( void )
- { frmWiFi->ConfirmCallback_QueryOriRxStatus();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_QueryRxStatus( void )
- { frmWiFi->ConfirmCallback_QueryRxStatus();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_QueryRxCounter( void )
- { frmWiFi->ConfirmCallback_QueryRxCounter();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_TxDcOffsetCal( void )
- { frmWiFi->ConfirmCallback_TxDcOffsetCal();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_TXOP( void )
- { frmWiFi->ConfirmCallback_TXOP();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_TXCS( void )
- { frmWiFi->ConfirmCallback_TXCS();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_LF( void )
- { frmWiFi->ConfirmCallback_LF();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_PS( void )
- { frmWiFi->ConfirmCallback_PS();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadBBReg( void )
- { frmWiFi->ConfirmCallback_ReadBBReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadAllBBReg( void )
- { frmWiFi->ConfirmCallback_ReadAllBBReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_WriteBBReg( void )
- { frmWiFi->ConfirmCallback_WriteBBReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadMACReg( void )
- { frmWiFi->ConfirmCallback_ReadMACReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadAllMACReg( void )
- { frmWiFi->ConfirmCallback_ReadAllMACReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_WriteMACReg( void )
- { frmWiFi->ConfirmCallback_WriteMACReg();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadEE( void )
- { frmWiFi->ConfirmCallback_ReadEE();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadAllEE( void )
- { frmWiFi->ConfirmCallback_ReadAllEE();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_WriteEE( void )
- { frmWiFi->ConfirmCallback_WriteEE();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_SetDbmToDac( void )
- { frmWiFi->CNF_TXOP_SetDbmToDac();
- }
- //---------------------------------------------------------------------------
- static void CNF_TXOP_QueryDbmToDac( void )
- { frmWiFi->CNF_TXOP_QueryDbmToDac();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_SC( void )
- { frmWiFi->ConfirmCallback_SC();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadTxPowerFromEE( void )
- { frmWiFi->ConfirmCallback_ReadTxPowerFromEE();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_ReadTxDcOffsetFromEE( void )
- { frmWiFi->ConfirmCallback_ReadTxDcOffsetFromEE();
- }
- //===========================================================================
- __fastcall TfrmWiFi::TfrmWiFi(TComponent* Owner)
- : TForm(Owner)
- {
- Init();
- m_bFirstCPTXShow = true;
- m_bFirstCPRXShow = true;
- m_bFirstTXOPShow = true;
- m_bFirstTXCSShow = true;
- m_bFirstLFShow = true;
- m_bFirstCSShow = true;
- m_bFirstBBShow = true;
- m_bFirstMACShow = true;
- // TX
- edtTXFramCtrl[0] = edtTXFramCtrl0; edtTXDuration[0] = edtTXDuration0; edtTXSeqCtrl[0] = edtTXSeqCtrl0;
- edtTXFramCtrl[1] = edtTXFramCtrl1; edtTXDuration[1] = edtTXDuration1; edtTXSeqCtrl[1] = edtTXSeqCtrl1;
- edtTXAddress1[0] = edtTXAddress10; edtTXAddress2[0] = edtTXAddress20; edtTXAddress3[0] = edtTXAddress30;
- edtTXAddress1[1] = edtTXAddress11; edtTXAddress2[1] = edtTXAddress21; edtTXAddress3[1] = edtTXAddress31;
- edtTXAddress1[2] = edtTXAddress12; edtTXAddress2[2] = edtTXAddress22; edtTXAddress3[2] = edtTXAddress32;
- edtTXAddress1[3] = edtTXAddress13; edtTXAddress2[3] = edtTXAddress23; edtTXAddress3[3] = edtTXAddress33;
- edtTXAddress1[4] = edtTXAddress14; edtTXAddress2[4] = edtTXAddress24; edtTXAddress3[4] = edtTXAddress34;
- edtTXAddress1[5] = edtTXAddress15; edtTXAddress2[5] = edtTXAddress25; edtTXAddress3[5] = edtTXAddress35;
- // Continuous packet RX
- stCPRSum[0] = stCPR1MSum; stCPRGood[0] = stCPR1MGood; stCPRBad[0] = stCPR1MBad; stCPRFer[0] = stCPR1MFer;
- stCPRSum[1] = stCPR2MSum; stCPRGood[1] = stCPR2MGood; stCPRBad[1] = stCPR2MBad; stCPRFer[1] = stCPR2MFer;
- stCPRSum[2] = stCPR5_5MSum; stCPRGood[2] = stCPR5_5MGood; stCPRBad[2] = stCPR5_5MBad; stCPRFer[2] = stCPR5_5MFer;
- stCPRSum[3] = stCPR11MSum; stCPRGood[3] = stCPR11MGood; stCPRBad[3] = stCPR11MBad; stCPRFer[3] = stCPR11MFer;
- stCPRSum[4] = stCPR6MSum; stCPRGood[4] = stCPR6MGood; stCPRBad[4] = stCPR6MBad; stCPRFer[4] = stCPR6MFer;
- stCPRSum[5] = stCPR9MSum; stCPRGood[5] = stCPR9MGood; stCPRBad[5] = stCPR9MBad; stCPRFer[5] = stCPR9MFer;
- stCPRSum[6] = stCPR12MSum; stCPRGood[6] = stCPR12MGood; stCPRBad[6] = stCPR12MBad; stCPRFer[6] = stCPR12MFer;
- stCPRSum[7] = stCPR18MSum; stCPRGood[7] = stCPR18MGood; stCPRBad[7] = stCPR18MBad; stCPRFer[7] = stCPR18MFer;
- stCPRSum[8] = stCPR24MSum; stCPRGood[8] = stCPR24MGood; stCPRBad[8] = stCPR24MBad; stCPRFer[8] = stCPR24MFer;
- stCPRSum[9] = stCPR36MSum; stCPRGood[9] = stCPR36MGood; stCPRBad[9] = stCPR36MBad; stCPRFer[9] = stCPR36MFer;
- stCPRSum[10] = stCPR48MSum; stCPRGood[10] = stCPR48MGood; stCPRBad[10] = stCPR48MBad; stCPRFer[10] = stCPR48MFer;
- stCPRSum[11] = stCPR54MSum; stCPRGood[11] = stCPR54MGood; stCPRBad[11] = stCPR54MBad; stCPRFer[11] = stCPR54MFer;
- m_pvBBCRDisp = NULL;
- m_pvMCRDisp = NULL;
- m_pvMCR16Disp = NULL;
- m_pvEEDisp = NULL;
- WindowProc = SubClassWndProc;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::Init( void )
- {
- m_bInit = true;
- }
- //==============================================================================
- void _fastcall TfrmWiFi::SubClassWndProc( Messages::TMessage &Message)
- {
- switch ( Message.Msg )
- {
- case WM_ML_WIFI_PRINT_MSG:
- {
- FillSCResult();
- }
- break;
-
- default:
- this->WndProc( Message );
- break;
- }
- }
- //==========================================================================
- //////////////////////////// Form event handler ////////////////////////
- //==========================================================================
- void __fastcall TfrmWiFi::FormCreate(TObject *Sender)
- {
- // Initialize
- m_uiBBIdx = 0;
- m_ucBBValue = 0;
- m_uiBBBeginIdx = 0;
- m_uiBBEndIdx = 0;
- m_uiMacAddr = 0;
- m_uiMacBeginAddr = 0;
- m_uiMacEndAddr = 0;
- m_uiMacData = 0;
- m_usMac16Data = 0;
- // eeprom
- m_uiEEPROMIdx = 0;
- m_uiEEPROMBeginIdx = 0;
- m_uiEEPROMEndIdx = 0;
- m_usEEPROMData = 0;
- m_iTestPageIndex = PAGEIDX_NONE;
- m_iLastPageIndex = pctlToolSel->ActivePageIndex;
- // dynamic allocate
- m_pSCLog = new TStringList;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::FormDestroy(TObject *Sender)
- {
- delete m_pSCLog;
- DeAllocateBBCRVector();
- DeAllocateMCRVector();
- DeAllocateMCR16Vector();
- DeAllocateEEPROMVector();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::FormShow(TObject *Sender)
- {
- ApplyHideProperty();
- frmWiFiTxProfile->WIFI_APC_Obj(&m_WIFI_APC_Obj);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::ToggleHideExecute(TObject *Sender)
- {
- g_bHideEnable = g_bHideEnable ? false : true;
-
- ApplyHideProperty();
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ApplyHideProperty( void )
- {
- bool visible = g_bHideEnable ? false : true;
- btnBBRegSetting->Visible = visible;
- btnMACRegSetting->Visible = visible;
- btnEEPROMSetting->Visible = visible;
- tsSC->Visible = visible;
- tsSC->TabVisible = visible;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::pctlToolSelChange(TObject *Sender)
- {
- if( PAGEIDX_NONE != m_iTestPageIndex )
- {
- if(m_iTestPageIndex != pctlToolSel->ActivePageIndex &&
- PAGEIDX_BB != pctlToolSel->ActivePageIndex &&
- PAGEIDX_MAC != pctlToolSel->ActivePageIndex &&
- PAGEIDX_EE != pctlToolSel->ActivePageIndex
- )
- {
- pctlToolSel->ActivePageIndex = m_iLastPageIndex;
- Application->MessageBox( "Cannot change page because test is progressing", "Notice", MB_OK );
- return;
- }
- }
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_TXALL:
- {
- // if( ! m_bFirstCPTXShow )
- // {
- // m_bFirstCPTXShow = false;
- // Display_CPTXChannelId();
- // }
- }
- break;
- case PAGEIDX_CPRX:
- break;
- case PAGEIDX_PS:
- break;
- case PAGEIDX_BB:
- break;
- case PAGEIDX_MAC:
- break;
- case PAGEIDX_EE:
- break;
- }
- m_iLastPageIndex = pctlToolSel->ActivePageIndex;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawFields( int page_idx )
- {
- switch( page_idx )
- {
- case PAGEIDX_TXALL:
- ReDrawTXFields();
- break;
- case PAGEIDX_CPRX:
- break;
- case PAGEIDX_PS:
- break;
- case PAGEIDX_BB:
- ReDrawBBFields();
- break;
- case PAGEIDX_MAC:
- ReDrawMACFields();
- break;
- case PAGEIDX_EE:
- ReDrawEEFields();
- break;
- case PAGEIDX_SC:
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawTXFields(void)
- {
- char str[256];
- E_WIFI_GENERATION wifi_802_11_idx;
- unsigned int chan_idx;
- if(! GetWiFiChannelIndexFromStr( cbTXChannelID->Text, cbTXTxRate->Text, wifi_802_11_idx, chan_idx ) )
- {
- return;
- }
- if( 0 == btnTXTxPowerDac->Tag ) // Dec
- {
- btnTXTxPowerDac->Caption = "TX power DAC (Dec)";
- lblTXTxPowerDac0X->Visible = false;
- if( WIFI_802_11A_IDX == wifi_802_11_idx )
- {
- edtTXTxPowerDAC->Text = IntToStr( m_sTxPwr5000M.TxPWR[chan_idx] );
- }
- else if( WIFI_802_11B_IDX == wifi_802_11_idx )
- {
- edtTXTxPowerDAC->Text = IntToStr( m_sTxPwr2400M.CCKTxPWR[chan_idx] );
- }
- else // 802.11G
- { edtTXTxPowerDAC->Text = IntToStr( m_sTxPwr2400M.OFDMTxPWR[chan_idx] );
- }
- }
- else // Hex
- {
- btnTXTxPowerDac->Caption = "TX power DAC (Hex)";
- lblTXTxPowerDac0X->Visible = true;
- if( WIFI_802_11A_IDX == wifi_802_11_idx )
- {
- sprintf( str, "%X", (int)m_sTxPwr5000M.TxPWR[chan_idx] );
- }
- else if( WIFI_802_11B_IDX == wifi_802_11_idx )
- {
- sprintf( str, "%X", (int)m_sTxPwr2400M.CCKTxPWR[chan_idx] );
- }
- else // 802.11G
- {
- sprintf( str, "%X", (int)m_sTxPwr2400M.OFDMTxPWR[chan_idx] );
- }
- edtTXTxPowerDAC->Text = str;
- }
- // TX DC offset
- if( 0 == btnTXIDC->Tag ) // Dec
- {
- btnTXIDC->Caption = "I_DC (Dec)";
- lblTXIDC0x->Visible = false;
- edtTXIDC->Text = IntToStr( m_sTxDcOffset.i_ch_offset );
- }
- else // Hex
- {
- btnTXIDC->Caption = "I_DC (Hex)";
- lblTXIDC0x->Visible = true;
- sprintf( str, "%X", (int)m_sTxDcOffset.i_ch_offset );
- edtTXIDC->Text = str;
- }
- if( 0 == btnTXQDC->Tag ) // Dec
- {
- btnTXQDC->Caption = "Q_DC (Dec)";
- lblTXQDC0x->Visible = false;
- edtTXQDC->Text = IntToStr( m_sTxDcOffset.q_ch_offset );
- }
- else // Hex
- {
- btnTXQDC->Caption = "Q_DC (Hex)";
- lblTXQDC0x->Visible = true;
- sprintf( str, "%X", (int)m_sTxDcOffset.q_ch_offset );
- edtTXQDC->Text = str;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawTXOPFields( void )
- {
- #if 0
- char str[256];
- E_WIFI_GENERATION wifi_802_11_idx;
- unsigned int chan_idx;
- if(! GetWiFiChannelIndexFromStr( cbTXOPChannelID->Text, cbTXOPTXRate->Text, wifi_802_11_idx, chan_idx ) )
- {
- return;
- }
- if( 0 == btnTXOPTxPowerDac->Tag ) // Dec
- {
- btnTXOPTxPowerDac->Caption = "TX power DAC (Dec)";
- lblTXOPTxPowerDac0X->Visible = false;
- if( WIFI_802_11A_IDX == wifi_802_11_idx )
- {
- edtTXOPTxPowerDAC->Text = m_sTxPwr5000M.TxPWR[chan_idx];
- }
- else if( WIFI_802_11B_IDX == wifi_802_11_idx )
- {
- edtTXOPTxPowerDAC->Text = m_sTxPwr2400M.CCKTxPWR[chan_idx];
- }
- else
- {
- edtTXOPTxPowerDAC->Text = m_sTxPwr2400M.OFDMTxPWR[chan_idx];
- }
- }
- else // Hex
- {
- btnTXOPTxPowerDac->Caption = "TX power DAC (Hex)";
- lblTXOPTxPowerDac0X->Visible = true;
- if( WIFI_802_11A_IDX == wifi_802_11_idx )
- {
- sprintf( str, "%X", (int)m_sTxPwr5000M.TxPWR[chan_idx] );
- }
- else if( WIFI_802_11B_IDX == wifi_802_11_idx )
- {
- sprintf( str, "%X", (int)m_sTxPwr2400M.CCKTxPWR[chan_idx] );
- }
- else // 802.11g
- {
- sprintf( str, "%X", (int)m_sTxPwr2400M.OFDMTxPWR[chan_idx] );
- }
- edtTXOPTxPowerDAC->Text = str;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawBBFields( void )
- {
- char str[256];
- //sprintf(str, "%08lx", m_ucBBAddr);
- //sprintf(str, "%04lx", m_ucBBAddr);
- //edtBBCRIndex->Text = str;
- edtBBCRIndex->Text = m_uiBBIdx;
- if( 0 == btnBBCRData->Tag ) // Dec
- {
- btnBBCRData->Caption = "CR Data (Dec)";
- lblBBCRData0X->Visible = false;
- edtBBCRData->Text = m_ucBBValue;
- }
- else // Hex
- {
- btnBBCRData->Caption = "CR Data (Hex)";
- lblBBCRData0X->Visible = true;
- sprintf( str, "%X", (int)m_ucBBValue );
- edtBBCRData->Text = str;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawMACFields( void )
- {
- char str[256];
- //sprintf(str, "%08lx", m_ucBBAddr);
- sprintf(str, "%04lx", m_uiMacAddr);
- edtMACMCRAddress->Text = str;
- if( btnMACMCRData->Tag==0 ) // Dec
- {
- btnMACMCRData->Caption = "CR Data (Dec)";
- lblMACMCRData0X->Visible = false;
- if( rbMAC16bits->Checked )
- {
- edtMACMCRData->Text = m_usMac16Data;
- }
- else
- { edtMACMCRData->Text = m_uiMacData;
- }
- }
- else // Hex
- {
- btnMACMCRData->Caption = "CR Data (Hex)";
- lblMACMCRData0X->Visible = true;
- if( rbMAC16bits->Checked )
- { sprintf( str, "%X", m_usMac16Data );
- }
- else
- { sprintf( str, "%X", m_uiMacData );
- }
- edtMACMCRData->Text = str;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ReDrawEEFields( void )
- {
- char str[256];
- sprintf(str, "%04lx", m_uiEEPROMIdx);
- // sprintf(str, "%04lx", m_sEE.eeprom[0].index);
- edtEEIndex->Text = str;
- if( 0 == btnEEData->Tag ) // Dec
- {
- btnEEData->Caption = "EEPRom data (Dec)";
- lblEEData0X->Visible = false;
- edtEEData->Text = IntToStr( m_sEE.eeprom[0].eeprom_data16 );
- }
- else // Hex
- {
- btnEEData->Caption = "EEPRom data (Hex)";
- lblEEData0X->Visible = true;
- sprintf( str, "%X", m_sEE.eeprom[0].eeprom_data16 );
- edtEEData->Text = str;
- }
- }
- //----------------------------------------------------------------------------
- void TfrmWiFi::FillBBResult( bool is_title )
- {
- char str[256];
- if( is_title )
- {
- memBBResult->Lines->Clear();
- sprintf( str, " BB BB " );
- memBBResult->Lines->Add(str);
- sprintf( str, " index data " );
- memBBResult->Lines->Add(str);
- sprintf( str, "=======================================================" );
- memBBResult->Lines->Add(str);
- }
- else
- {
- AnsiString as_bbinfo;
- unsigned int bb_addr;
- unsigned char bb_value;
- vector<WiFi_BBReg8_S>:: iterator iter;
- WiFi_BBReg8_S bbcr_first = *m_pvBBCRDisp->begin();
- for( iter = m_pvBBCRDisp->begin(); iter != m_pvBBCRDisp->end(); iter++ )
- // for( int i=0; i<m_sBBCR.count; i++ )
- {
- bb_addr = iter->index;
- bb_value = iter->bbcr_data8;
- if( (bb_addr-bbcr_first.index) % 8 == 0 )
- {
- sprintf(str, "%04ld: ", bb_addr);
- as_bbinfo = str;
- }
- sprintf(str, "%02lx ", bb_value);
- as_bbinfo += str;
- // if( bb_addr % 8 == 0 && bb_addr != 0 )
- if( (bb_addr-bbcr_first.index) % 8 == 7 )
- {
- strcpy( str, as_bbinfo.c_str() );
- memBBResult->Lines->Add(str);
- }
- }
- if( (bb_addr-bbcr_first.index) % 8 != 7 )
- {
- strcpy( str, as_bbinfo.c_str() );
- memBBResult->Lines->Add(str);
- }
- }
- }
- //----------------------------------------------------------------------------
- void TfrmWiFi::FillMACResult( bool is_title )
- {
- char str[256];
- if( is_title )
- {
- memMACResult->Lines->Clear();
- sprintf( str, " MAC MAC " );
- memMACResult->Lines->Add(str);
- sprintf( str, " address data " );
- memMACResult->Lines->Add(str);
- sprintf( str, "=======================================================" );
- memMACResult->Lines->Add(str);
- }
- else
- {
- AnsiString as_macinfo;
- unsigned int mac_addr;
- if( rbMAC16bits->Checked )
- {
- unsigned int mac16_value;
- vector<WiFi_MACReg16_S>:: iterator iter;
- WiFi_MACReg16_S mcr16_first = *m_pvMCR16Disp->begin();
- // for( int i=0; i<m_sMCR16.count; i++ )
- for( iter = m_pvMCR16Disp->begin(); iter != m_pvMCR16Disp->end(); iter++ )
- {
- mac_addr = iter->index;
- mac16_value = iter->mcr_data16;
- if( (mac_addr-mcr16_first.index) % 0x10 == 0 )
- {
- sprintf(str, "%04lx: ", mac_addr);
- as_macinfo = str;
- }
- sprintf(str, "%04lx ", mac16_value);
- as_macinfo += str;
- if( (mac_addr-mcr16_first.index) % 0x10 == 0x0E )
- {
- strcpy( str, as_macinfo.c_str() );
- memMACResult->Lines->Add(str);
- }
- }
- if( (mac_addr-mcr16_first.index) % 0x10 != 0x0E )
- {
- strcpy( str, as_macinfo.c_str() );
- memMACResult->Lines->Add(str);
- }
- }
- else // MAC32
- {
- unsigned int mac32_value;
- vector<WiFi_MACReg32_S>:: iterator iter;
- WiFi_MACReg32_S mcr32_first = *m_pvMCRDisp->begin();
- //for( int i=0; i<m_sMCR.count; i++ )
- for( iter = m_pvMCRDisp->begin(); iter != m_pvMCRDisp->end(); iter++ )
- {
- mac_addr = iter->index;
- mac32_value = iter->mcr_data32;
- if( (mac_addr-mcr32_first.index) % 0x10 == 0 )
- {
- sprintf(str, "%04lx: ", mac_addr);
- as_macinfo = str;
- }
- sprintf(str, "%08lx ", mac32_value);
- as_macinfo += str;
- if( (mac_addr-mcr32_first.index) % 0x10 == 0x0C )
- {
- strcpy( str, as_macinfo.c_str() );
- memMACResult->Lines->Add(str);
- }
- }
- if( (mac_addr-mcr32_first.index) % 0x10 != 0x0C )
- {
- strcpy( str, as_macinfo.c_str() );
- memMACResult->Lines->Add(str);
- }
- }
- }
- }
- //----------------------------------------------------------------------------
- void TfrmWiFi::FillEEResult( bool is_title )
- {
- char str[256];
- if( is_title )
- {
- memEEResult->Lines->Clear();
- sprintf( str, " EEProm EEPRom " );
- memEEResult->Lines->Add(str);
- sprintf( str, " address data " );
- memEEResult->Lines->Add(str);
- if( rbEEWord->Checked )
- sprintf( str, "=======================================================================================" );
- else
- sprintf( str, "=====================================================================================================" );
- memEEResult->Lines->Add(str);
- }
- else
- {
- AnsiString as_eeinfo;
- unsigned int ee_addr;
- unsigned short ee_value;
- vector<WiFi_EEPROM_S>:: iterator iter;
- WiFi_EEPROM_S eeprom_first = *m_pvEEDisp->begin();
- if( rbEEByte->Checked )
- {
- for( iter = m_pvEEDisp->begin(); iter != m_pvEEDisp->end(); iter++ )
- //for( int i=0; i<m_sEE.count; i++ )
- {
- //WiFi_EEPROM_S eeprom;
- //eeprom = *iter;
- ee_addr = iter->index;
- ee_value = iter->eeprom_data16;
- if( (ee_addr-eeprom_first.index) % 0x10 == 0 )
- {
- sprintf(str, "%04lx: ", ee_addr);
- as_eeinfo = str;
- }
- sprintf(str, "%02lx ", ee_value & 0x00FF );
- as_eeinfo += str;
- sprintf(str, "%02lx ", (ee_value & 0xFF00)>>8 );
- as_eeinfo += str;
- if( (ee_addr-eeprom_first.index) % 0x10 == 0x0F )
- {
- strcpy( str, as_eeinfo.c_str() );
- memEEResult->Lines->Add(str);
- }
- }
- if( (ee_addr-eeprom_first.index) % 0x10 != 0x0F )
- {
- strcpy( str, as_eeinfo.c_str() );
- memEEResult->Lines->Add(str);
- }
- }
- else
- {
- //for( int i=0; i<m_sEEDisp.count; i++ )
- for( iter = m_pvEEDisp->begin(); iter != m_pvEEDisp->end(); iter++ )
- {
- // WiFi_EEPROM_S eeprom;
- // eeprom = *iter;
- ee_addr = iter->index;
- ee_value = iter->eeprom_data16;
- if( (ee_addr-eeprom_first.index) % 0x10 == 0 )
- {
- sprintf(str, "%04lx: ", ee_addr);
- as_eeinfo = str;
- }
- sprintf(str, "%04lx ", ee_value);
- as_eeinfo += str;
- if( (ee_addr-eeprom_first.index) % 0x10 == 0x0F )
- {
- strcpy( str, as_eeinfo.c_str() );
- memEEResult->Lines->Add(str);
- }
- }
- if( (ee_addr-eeprom_first.index) % 0x10 != 0x0F )
- {
- strcpy( str, as_eeinfo.c_str() );
- memEEResult->Lines->Add(str);
- }
- } // word
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool TfrmWiFi::CheckFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
- {
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_TXALL:
- {
- }
- break;
- case PAGEIDX_CPRX:
- break;
- case PAGEIDX_PS:
- break;
- case PAGEIDX_BB:
- if( ! CheckBBFields( access_type, op_type ) ) return false;
- break;
- case PAGEIDX_MAC:
- if( ! CheckMACFields( access_type, op_type ) ) return false;
- break;
- case PAGEIDX_EE:
- if( ! CheckEEFields( access_type, op_type ) ) return false;
- break;
- case PAGEIDX_SC:
- break;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmWiFi::CheckBBFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
- {
- unsigned int uidata;
- AnsiString text;
- if( ACCESS_SINGLE == access_type )
- {
- text = edtBBCRIndex->Text; if( !IsValidDecWiFiBBRegAddr( text, uidata ) ) { edtBBCRIndexCheck(edtBBCRIndex); return false; }
- m_uiBBIdx = uidata;
- if( op_type == OP_WRITE )
- {
- unsigned char ucdata;
- text = edtBBCRData->Text;
- if( btnBBCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiBBRegValue( text, ucdata ) )
- {
- edtBBCRDataCheck( edtBBCRData );
- return false;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiBBRegValue( text, ucdata ) )
- {
- edtBBCRDataCheck( edtBBCRData );
- return false;
- }
- }
- m_ucBBValue = ucdata;
- }
- }
- else // dump
- {
- text = edtBBBeginCRIndex->Text; if( !IsValidDecWiFiBBRegAddr( text, uidata ) ) { edtBBBeginCRIndexCheck(edtBBBeginCRIndex); return false; }
- m_uiBBBeginIdx = uidata;
- text = edtBBEndCRIndex->Text; if( !IsValidDecWiFiBBRegAddr( text, uidata ) ) { edtBBEndCRIndexCheck(edtBBEndCRIndex); return false; }
- m_uiBBEndIdx = uidata;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmWiFi::CheckMACFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
- {
- unsigned int uidata;
- AnsiString text;
- if( ACCESS_SINGLE == access_type )
- {
- text = edtMACMCRAddress->Text; if( !IsValidHexWiFiMacRegAddr( text, uidata ) ) { edtMACMCRAddressCheck(edtMACMCRAddress); return false; }
- m_uiMacAddr = uidata;
- text = edtMACMCRData->Text;
- if( rbMAC16bits->Checked )
- {
- unsigned short usdata;
- if( btnMACMCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiMacReg16Value( text, usdata ) )
- {
- edtMACMCRDataCheck( edtMACMCRData );
- return false;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiMacReg16Value( text, usdata ) )
- {
- edtMACMCRDataCheck( edtMACMCRData );
- return false;
- }
- }
- m_usMac16Data = usdata;
- }
- else
- {
- if( btnMACMCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiMacRegValue( text, uidata ) )
- {
- edtMACMCRDataCheck( edtMACMCRData );
- return false;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiMacRegValue( text, uidata ) )
- {
- edtMACMCRDataCheck( edtMACMCRData );
- return false;
- }
- }
- m_uiMacData = uidata;
- }
- }
- else // dump
- {
- if( rbMAC16bits->Checked )
- {
- text = edtMACBeginMCRAddr->Text; if( !IsValidHexWiFiMacRegAddr( text, uidata ) ) { edtMACBeginMCRAddrCheck(edtMACBeginMCRAddr); return false; }
- m_uiMacBeginAddr = uidata;
- text = edtMACEndMCRAddr->Text; if( !IsValidHexWiFiMacRegAddr( text, uidata ) ) { edtMACBeginMCRAddrCheck(edtMACEndMCRAddr); return false; }
- m_uiMacEndAddr = uidata;
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmWiFi::CheckEEFields( E_ACCESS_TYPE access_type, E_OPERATION_TYPE op_type )
- {
- unsigned int uidata;
- unsigned short usdata;
- AnsiString text;
- if( ACCESS_SINGLE == access_type )
- {
- text = edtEEIndex->Text; if( !IsValidHexWiFiEERegAddr( text, uidata ) ) { edtMACMCRAddressCheck(edtMACMCRAddress); return false; }
- m_uiEEPROMIdx = uidata;
- text = edtEEData->Text;
- if( 0 == btnEEData->Tag ) // Dec
- {
- if( !IsValidDecWiFiEERegValue( text, usdata ) )
- {
- edtEEDataCheck( edtEEData );
- return false;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiEERegValue( text, usdata ) )
- {
- edtEEDataCheck( edtEEData );
- return false;
- }
- }
- m_usEEPROMData = usdata;
- }
- else
- {
- text = edtEEBeginIndex->Text; if( !IsValidHexWiFiEERegAddr( text, uidata ) ) { edtBeginEEIndexCheck(edtEEBeginIndex); return false; }
- m_uiEEPROMBeginIdx = uidata;
- text = edtEEEndIndex->Text; if( !IsValidHexWiFiEERegAddr( text, uidata ) ) { edtEndEEIndexCheck(edtEEEndIndex); return false; }
- m_uiEEPROMEndIdx = uidata;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmWiFi::CheckTXOPFields( void )
- {
- return true;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::EnableCPTUIComponent( void )
- {
- // ALC
- m_edtTXTargetAlc->Enabled = true;
- m_cbTXTargetGain->Enabled = true;
- m_cbTXAlcTracking->Enabled = true;
- m_cbTargetAlc->Enabled = true;
- // MAC header
- edtTXFramCtrl1->Enabled = true;
- edtTXFramCtrl0->Enabled = true;
- edtTXDuration1->Enabled = true;
- edtTXDuration0->Enabled = true;
- edtTXAddress15->Enabled = true;
- edtTXAddress14->Enabled = true;
- edtTXAddress13->Enabled = true;
- edtTXAddress12->Enabled = true;
- edtTXAddress11->Enabled = true;
- edtTXAddress10->Enabled = true;
- edtTXAddress25->Enabled = true;
- edtTXAddress24->Enabled = true;
- edtTXAddress23->Enabled = true;
- edtTXAddress22->Enabled = true;
- edtTXAddress21->Enabled = true;
- edtTXAddress20->Enabled = true;
- edtTXAddress35->Enabled = true;
- edtTXAddress34->Enabled = true;
- edtTXAddress33->Enabled = true;
- edtTXAddress32->Enabled = true;
- edtTXAddress31->Enabled = true;
- edtTXAddress30->Enabled = true;
- edtTXSeqCtrl1->Enabled = true;
- edtTXSeqCtrl0->Enabled = true;
- edtTXPacketLength->Enabled = true;
- edtTXPacketCount->Enabled = true;
- edtTXPacketInterval->Enabled = true;
- cbTXPreamble->Enabled = true;
- cbTXBitPattern->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::DisableCPTUIComponent(void)
- {
- // ALC
- m_edtTXTargetAlc->Enabled = false;
- m_cbTXTargetGain->Enabled = false;
- m_cbTXAlcTracking->Enabled = false;
- m_cbTargetAlc->Enabled = false;
- // MAC header
- edtTXFramCtrl1->Enabled = false;
- edtTXFramCtrl0->Enabled = false;
- edtTXDuration1->Enabled = false;
- edtTXDuration0->Enabled = false;
- edtTXAddress15->Enabled = false;
- edtTXAddress14->Enabled = false;
- edtTXAddress13->Enabled = false;
- edtTXAddress12->Enabled = false;
- edtTXAddress11->Enabled = false;
- edtTXAddress10->Enabled = false;
- edtTXAddress25->Enabled = false;
- edtTXAddress24->Enabled = false;
- edtTXAddress23->Enabled = false;
- edtTXAddress22->Enabled = false;
- edtTXAddress21->Enabled = false;
- edtTXAddress20->Enabled = false;
- edtTXAddress35->Enabled = false;
- edtTXAddress34->Enabled = false;
- edtTXAddress33->Enabled = false;
- edtTXAddress32->Enabled = false;
- edtTXAddress31->Enabled = false;
- edtTXAddress30->Enabled = false;
- edtTXSeqCtrl1->Enabled = false;
- edtTXSeqCtrl0->Enabled = false;
- edtTXPacketLength->Enabled = false;
- edtTXPacketCount->Enabled = false;
- edtTXPacketInterval->Enabled = false;
- cbTXPreamble->Enabled = false;
- cbTXBitPattern->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CurrentPageReset( void )
- {
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_TXALL:
- {
- m_iTestPageIndex = PAGEIDX_NONE;
- // cbTXChannelID->Enabled = true;
- // cbTXTxFilter->Enabled = true;
- // cbTXTxRate->Enabled = true;
- // btnTXTxPowerDac->Enabled = true;
- // edtTXTxPowerDAC->Enabled = true;
- rbTXOP->Enabled = true;
- rbTXCS->Enabled = true;
- rbCPT->Enabled = true;
- rbTXLF->Enabled = true;
- // TX DC offset
- //edtTXIDC->Enabled = true;
- //edtTXQDC->Enabled = true;
- btnTXCalTxDC->Enabled = true;
- btnTXUploadFromFlash->Enabled = true;
- btnTXDownloadToFlash->Enabled = true;
- btnTXChangeDB->Enabled = true;
- //btnTXLoadFromFile->Enabled = true;
- //btnTXSaveToFile->Enabled = true;
- btnLoadTxPowerFromEE->Enabled = true;
- btnTXTxChannelPower->Enabled = true;
- m_btnTxAlc->Enabled = true;
- btnTXStart->Enabled = true;
- btnTXStart->Tag = 0;
- if( rbCPT->Checked )
- {
- EnableCPTUIComponent();
- }
- }
- break;
- case PAGEIDX_CPRX:
- {
- m_iTestPageIndex = PAGEIDX_NONE;
- cbCPRChannelID->Enabled = true;
- // cbCPRRxAntenna->Enabled = true;
- cbCPRRxAntenna->Enabled = true;
- btnCPRReset->Enabled = true;
- btnCPRQueryRxCounter->Enabled = true;
- btnCPRStart->Enabled = true;
- btnCPRStart->Tag = 0;
- }
- break;
- case PAGEIDX_PS:
- {
- m_iTestPageIndex = PAGEIDX_NONE;
- cbPSPowerMode->Enabled = true;
- btnPSStart->Enabled = true;
- btnPSStart->Tag = 0;
- }
- break;
- case PAGEIDX_BB:
- {
- edtBBCRIndex->Enabled = true;
- edtBBCRData->Enabled = true;
- btnBBRead->Enabled = true;
- btnBBWrite->Enabled = true;
- btnBBCRData->Enabled = true;
- btnBBDumpBBReg->Enabled = true;
- btnBBRead->Tag = 0;
- btnBBWrite->Tag = 0;
- }
- break;
- case PAGEIDX_MAC:
- {
- edtMACMCRAddress->Enabled = true;
- edtMACMCRData->Enabled = true;
- btnMACRead->Enabled = true;
- btnMACWrite->Enabled = true;
- btnMACMCRData->Enabled = true;
- btnMACDumpAllMacReg->Enabled = true;
- btnMACRead->Tag = 0;
- btnMACWrite->Tag = 0;
- }
- break;
- case PAGEIDX_EE:
- {
- edtEEIndex->Enabled = true;
- edtEEData->Enabled = true;
- btnEERead->Enabled = true;
- btnEEWrite->Enabled = true;
- btnEEData->Enabled = true;
- btnEE->Enabled = true;
- btnEERead->Tag = 0;
- btnEEWrite->Tag = 0;
- }
- break;
- case PAGEIDX_SC:
- {
- btnSCScriptFile->Enabled = true;
- btnSCStart->Enabled = true;
- btnSCStart->Tag = 0;
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CurrentPageLock( void )
- {
- switch(pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_TXALL:
- {
- m_iTestPageIndex = PAGEIDX_TXALL;
- // cbTXChannelID->Enabled = false;
- // cbTXTxFilter->Enabled = false;
- // cbTXTxRate->Enabled = false;
- // btnTXTxPowerDac->Enabled = false;
- // edtTXTxPowerDAC->Enabled = false;
- // edtTXPacketInterval->Enabled = false;
- // edtTXPacketLength->Enabled = false;
- // edtTXPacketCount->Enabled = false;
- // cbTXBitPattern->Enabled = false;
- // DisableCPTUIComponent();
- rbTXOP->Enabled = false;
- rbTXCS->Enabled = false;
- rbCPT->Enabled = false;
- rbTXLF->Enabled = false;
- // TX DC offset
- btnTXCalTxDC->Enabled = false;
- btnTXUploadFromFlash->Enabled = false;
- btnTXDownloadToFlash->Enabled = false;
- btnTXChangeDB->Enabled = false;
- btnLoadTxPowerFromEE->Enabled = false;
- btnTXTxChannelPower->Enabled = false;
- m_btnTxAlc->Enabled = false;
- btnTXStart->Enabled = false;
- btnTXStart->Tag = 1;
- }
- break;
- case PAGEIDX_CPRX:
- {
- m_iTestPageIndex = PAGEIDX_CPRX;
- cbCPRChannelID->Enabled = false;
- cbCPRRxAntenna->Enabled = false;
- // cbCPRRxAntenna->Enabled = false;
- btnCPRReset->Enabled = false;
- btnCPRQueryRxCounter->Enabled = false;
- btnCPRStart->Enabled = false;
- btnCPRStart->Tag = 1;
- }
- break;
- case PAGEIDX_PS:
- {
- m_iTestPageIndex = PAGEIDX_PS;
- cbPSPowerMode->Enabled = false;
- btnPSStart->Enabled = false;
- btnPSStart->Tag = 1;
- }
- break;
- case PAGEIDX_BB:
- {
- // m_iTestPageIndex = PAGEIDX_BB;
- edtBBCRIndex->Enabled = false;
- edtBBCRData->Enabled = false;
- btnBBRead->Enabled = false;
- btnBBWrite->Enabled = false;
- btnBBCRData->Enabled = false;
- btnBBDumpBBReg->Enabled = false;
- btnBBRead->Tag = 1;
- btnBBWrite->Tag = 1;
- }
- break;
- case PAGEIDX_MAC:
- {
- // m_iTestPageIndex = PAGEIDX_MAC;
- edtMACMCRAddress->Enabled = false;
- edtMACMCRData->Enabled = false;
- btnMACRead->Enabled = false;
- btnMACWrite->Enabled = false;
- btnMACMCRData->Enabled = false;
- btnMACDumpAllMacReg->Enabled = false;
- btnMACRead->Tag = 1;
- btnMACWrite->Tag = 1;
- }
- break;
- case PAGEIDX_EE:
- {
- // m_iTestPageIndex = PAGEIDX_EE;
- edtEEIndex->Enabled = false;
- edtEEData->Enabled = false;
- btnEERead->Enabled = false;
- btnEEWrite->Enabled = false;
- btnEEData->Enabled = false;
- btnEE->Enabled = false;
- btnEERead->Tag = 1;
- btnEEWrite->Tag = 1;
- }
- break;
- case PAGEIDX_SC:
- {
- btnSCScriptFile->Enabled = false;
- btnSCStart->Enabled = false;
- btnSCStart->Tag = 1;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXStartClick(TObject *Sender)
- {
- if( rbTXOP->Checked )
- {
- TXOPExecute();
- }
- else if( rbTXCS->Checked )
- {
- TXCSExecute();
- }
- else if( rbCPT->Checked )
- {
- CPTExecute();
- }
- else
- {
- LFExecute();
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::CPTExecute(void)
- {
- int i;
- AnsiString text;
- S_WIFICPT m_sWiFiCPT;
- m_sWiFiCPT.bAlcSupport = m_bAlcSupport;
- m_sWiFiCPT.wifi_id = m_final_WiFiId;
- m_sWiFiCPT.channel_freq = GetWiFiChannelFreqFromStr( cbTXChannelID->Text );
- if( IDX_TX_FILTER_NORTH_AMERICA == cbTXTxFilter->ItemIndex )
- {
- m_sWiFiCPT.reg_domain.country_code[0] = 'U';
- m_sWiFiCPT.reg_domain.country_code[1] = 'S';
- }
- else
- {
- m_sWiFiCPT.reg_domain.country_code[0] = 'J';
- m_sWiFiCPT.reg_domain.country_code[1] = 'P';
- }
- m_sWiFiCPT.tx_rate = (WiFi_TestRate_E) GetWiFiTxRateFromStr( cbTXTxRate->Text );
- text = edtTXPacketLength->Text; if( !IsValidWiFiPacketLength( text, m_sWiFiCPT.pkt_length ) ) { edtCPTPacketLengthCheck(edtTXPacketLength); return; }
- text = edtTXPacketCount->Text; if( !IsValidWiFiPacketCount( text, m_sWiFiCPT.pkt_count ) ) { edtCPTPacketCountCheck(edtTXPacketCount); return; }
- text = edtTXPacketInterval->Text; if( !IsValidWiFiPacketInterval( text, m_sWiFiCPT.pkt_interval ) ) { edtCPTPacketIntervalCheck(edtTXPacketInterval); return; }
- if( 0 == btnTXTxPowerDac->Tag )
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidDecWiFiTxPowerDac( text, m_sWiFiCPT.tx_pwr_dac ) ) { edtCPTTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- else
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidHexWiFiTxPowerDac( text, m_sWiFiCPT.tx_pwr_dac ) ) { edtCPTTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- switch (cbTXBitPattern->ItemIndex)
- {
- case WIFI_IDX_ALL_0:
- {
- m_sWiFiCPT.pattern = WIFI_TX_ALL_ZEROS;
- }
- break;
- case WIFI_IDX_ALL_1:
- {
- m_sWiFiCPT.pattern = WIFI_TX_ALL_ONES;
- }
- break;
- case WIFI_IDX_ALTERNATE:
- {
- m_sWiFiCPT.pattern = WIFI_TX_ALTERNATE_BITS;
- }
- break;
- case WIFI_IDX_RANDOM:
- {
- m_sWiFiCPT.pattern = WIFI_TX_PSEUDO_RANDOM;
- }
- break;
- default:
- {
- }
- break;
- }
- m_sWiFiCPT.is_short_preamble = cbTXPreamble->ItemIndex;
- // MAC header
- for( i=0; i<WIFI_MAC_HEAD_FRAME_CTRL_LEN; i++ )
- { text = edtTXFramCtrl[i]->Text; if( !IsValidHexWiFiMacHeaderFrameCtrl( text, m_sWiFiCPT.s_mac_header.frame_ctrl[i] ) ) { edtTXFramCtrlCheck(edtTXFramCtrl[i]); return; }
- }
- for( i=0; i<WIFI_MAC_HEAD_DURATION_LEN; i++ )
- { text = edtTXDuration[i]->Text; if( !IsValidHexWiFiMacHeaderDuration( text, m_sWiFiCPT.s_mac_header.duration[i] ) ) { edtTXDurationCheck(edtTXDuration[i]); return; }
- }
- for( i=0; i<WIFI_MAC_HEAD_ADDRESS_LEN; i++ )
- { text = edtTXAddress1[i]->Text; if( !IsValidHexWiFiMacHeaderAddress( text, m_sWiFiCPT.s_mac_header.address1[i] ) ) { edtTXAddress1Check(edtTXAddress1[i]); return; }
- }
- for( i=0; i<WIFI_MAC_HEAD_ADDRESS_LEN; i++ )
- { text = edtTXAddress2[i]->Text; if( !IsValidHexWiFiMacHeaderAddress( text, m_sWiFiCPT.s_mac_header.address2[i] ) ) { edtTXAddress2Check(edtTXAddress2[i]); return; }
- }
- for( i=0; i<WIFI_MAC_HEAD_ADDRESS_LEN; i++ )
- { text = edtTXAddress3[i]->Text; if( !IsValidHexWiFiMacHeaderAddress( text, m_sWiFiCPT.s_mac_header.address3[i] ) ) { edtTXAddress3Check(edtTXAddress3[i]); return; }
- }
- for( i=0; i<WIFI_MAC_HEAD_SEQ_CTRL_LEN; i++ )
- { text = edtTXSeqCtrl[i]->Text; if( !IsValidHexWiFiMacHeaderAddress( text, m_sWiFiCPT.s_mac_header.seq_ctrl[i] ) ) { edtTXSeqCtrlCheck(edtTXSeqCtrl[i]); return; }
- }
- if (m_bAlcSupport)
- {
- m_sWiFiCPT.ui_txFlags = 0;
- if (!m_cbTXTargetGain->Checked)
- {
- m_sWiFiCPT.ui_txFlags |= WIFI_TX_FLAG_NO_TXGAIN;
- }
- if (m_cbTXAlcTracking->Checked)
- {
- m_sWiFiCPT.ui_txFlags |= WIFI_TX_FLAG_ENABLE_ALC_TRACK;
- }
- if (m_cbTargetAlc->Checked)
- {
- m_sWiFiCPT.ui_txFlags |= WIFI_TX_FLAG_TARGET_ALC_PROVIDE;
- }
- m_sWiFiCPT.ui_targetAlc = m_edtTXTargetAlc->Text.ToInt();
- }
- CurrentPageLock();
- sbTX->Panels->Items[0]->Text = (AnsiString) " Continuos packet TX progressing";
- m_WIFI_CPT_Obj.ConfirmCallback = ::ConfirmCallback_CPT;
- m_WIFI_CPT_Obj.REQ_Start(m_sWiFiCPT);
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_CPT(void)
- {
- int state = m_WIFI_CPT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- TimerWiFi->Enabled = true;
- sbTX->Panels->Items[0]->Text = (AnsiString)" Continuous packet TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Continuous packet TX fail";
- Application->MessageBox( "Execution Failure : Continuous packet TX", "FAILURE", MB_OK );
- Application->BringToFront();
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Continuous packet TX timeout";
- Application->MessageBox( "Execution Timeout : Continuous packet TX", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Continuous packet TX stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXUploadFromFlashClick(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;
- }
- // m_WIFI_CPT_Obj.ConfirmCallback = ::CNF_CPTX_ReadFromNVRAM;
- // m_WIFI_CPT_Obj.REQ_Read_From_NVRAM();
- if( m_sWiFiCap.support_802_11g || m_sWiFiCap.support_802_11b )
- {
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_CPTX_ReadTxPower2400MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower2400M_From_NVRAM_Start();
- }
- else if( m_sWiFiCap.support_802_11a )
- {
- m_WIFI_APC_Obj.ConfirmCallback = ::CNF_CPTX_ReadTxPower5000MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower5000M_From_NVRAM_Start();
- }
- CurrentPageLock();
-
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CPTX_UploadTxPower2400MFromFlashDone( void )
- {
- 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_CPTX_ReadTxPower5000MFromNVRAM;
- m_WIFI_APC_Obj.REQ_Read_TxPower5000M_From_NVRAM_Start();
- }
- else
- {
- ReDrawFields( PAGEIDX_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting from flash successful";
- //CurrentPageReset();
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_ReadTxDCFromNVRAM;
- m_WIFI_TXDC_Obj.REQ_Read_From_NVRAM_Start();
- }
- }
- 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;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CPTX_UploadTxPower5000MFromFlashDone( void )
- {
- 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_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX channel power setting from flash successful";
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_ReadTxDCFromNVRAM;
- m_WIFI_TXDC_Obj.REQ_Read_From_NVRAM_Start();
- }
- 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;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmWiFi::UploadTxDCFromFlashDone( void )
- {
- E_METAAPP_RESULT_T state = m_WIFI_TXDC_Obj.Get_ConfirmState();
- char str[20];
- float fdata;
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sTxDcOffset = m_WIFI_TXDC_Obj.Get_TxDcOffset();
- ReDrawFields( PAGEIDX_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Upload TX DC offset 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();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmWiFi::btnTXDownloadToFlashClick(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;
- }
- 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_CPTX_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_CPTX_WriteTxPower5000MToNVRAM;
- m_WIFI_APC_Obj.REQ_Write_TxPower5000M_To_NVRAM_Start();
- }
- CurrentPageLock();
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::CPTX_DownloadTxPower2400MToFlashDone( void )
- {
- int state = m_WIFI_CPT_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_CPTX_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();
- m_WIFI_TXDC_Obj.Set_TxDcOffset( m_sTxDcOffset );
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_WriteTxDCToNVRAM;
- m_WIFI_TXDC_Obj.REQ_Write_To_NVRAM_Start();
- }
- }
- 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::CPTX_DownloadTxPower5000MToFlashDone( void )
- {
- int state = m_WIFI_CPT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX channel power setting to flash successful";
- m_WIFI_TXDC_Obj.Set_TxDcOffset( m_sTxDcOffset );
- m_WIFI_TXDC_Obj.ConfirmCallback = ::CNF_WriteTxDCToNVRAM;
- m_WIFI_TXDC_Obj.REQ_Write_To_NVRAM_Start();
- }
- 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::DownloadTxDCToFlashDone( void )
- {
- int state = m_WIFI_CPT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX DC offset to flash successful";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX DC offset to flash fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Download TX DC offset 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 DC offset to flash timeout";
- Application->MessageBox( "Execution Timeout : Download TX DC offset to flash", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Download TX DC offset to flash stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXChangeDBClick(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::btnTXLoadFromFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- float fdata;
- ok = OpenDialog->Execute();
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load WiFi TX 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 WiFi TX setting from file fail";
- Application->MessageBox( "Execution Failure : Load WiFi TX 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 WiFi TX setting from file fail";
- Application->MessageBox( "Execution Failure : Load WiFi TX setting from file", "FAILURE", MB_OK );
- }
- }
- // load TX DC offset from file
- ok = m_WIFI_TXDC_Obj.REQ_Read_From_File( str );
- if( ok )
- {
- m_sTxDcOffset = m_WIFI_TXDC_Obj.Get_TxDcOffset();
- }
- else
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load WiFi TX setting from file fail";
- Application->MessageBox( "Execution Failure : Load WiFi TX setting from file", "FAILURE", MB_OK );
- }
- ReDrawFields( PAGEIDX_TXALL );
- sbTX->Panels->Items[0]->Text = (AnsiString) " Load WiFi TX setting from file successfully";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXSaveToFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- ok = SaveDialog->Execute();
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save WiFi TX 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 WiFi TX setting to file fail";
- Application->MessageBox( "Execution Failure : Save WiFi TX 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 WiFi TX setting to file fail";
- Application->MessageBox( "Execution Failure : Save WiFi TX setting to file", "FAILURE", MB_OK );
- return;
- }
- }
- // save TX DC offset to file
- m_WIFI_TXDC_Obj.Set_TxDcOffset( m_sTxDcOffset );
- ok = m_WIFI_TXDC_Obj.REQ_Write_To_File( str );
- if( !ok )
- {
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save WiFi TX setting to file fail";
- Application->MessageBox( "Execution Failure : Save WiFi TX setting to file", "FAILURE", MB_OK );
- return;
- }
- sbTX->Panels->Items[0]->Text = (AnsiString) " Save WiFi TX setting to file successfully";
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtCPTPacketCountCheck(TObject *Sender)
- {
- unsigned int ui_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " packet count is invalid "
- };
- text = edit->Text;
- if( !IsValidWiFiPacketCount( text, ui_data ) )
- {
- edit->Text = 1000;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtCPTPacketLengthCheck(TObject *Sender)
- {
- unsigned int ui_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " packet length shall be 24~1500 "
- };
- text = edit->Text;
- if( !IsValidWiFiPacketLength( text, ui_data ) )
- {
- edit->Text = 128;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtCPTPacketIntervalCheck(TObject *Sender)
- {
- unsigned int ui_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " packet interval is invalid "
- };
- text = edit->Text;
- if( !IsValidWiFiPacketLength( text, ui_data ) )
- {
- edit->Text = 100;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtCPTTxPowerDACCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value should be 0~63 ";
- 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;
- }
- }
- if( uc_data > 63 )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- E_WIFI_GENERATION wifi_802_11_idx;
- unsigned int chan_idx;
- if(! GetWiFiChannelIndexFromStr( cbTXChannelID->Text, cbTXTxRate->Text, wifi_802_11_idx, chan_idx ) )
- {
- return;
- }
- if( WIFI_802_11A_IDX == wifi_802_11_idx )
- {
- m_sTxPwr5000M.TxPWR[chan_idx] = uc_data;
- }
- else if( WIFI_802_11B_IDX == wifi_802_11_idx )
- {
- m_sTxPwr2400M.CCKTxPWR[chan_idx] = uc_data;
- }
- else // 802.11G
- {
- m_sTxPwr2400M.OFDMTxPWR[chan_idx] = uc_data;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXTxFilterChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXTxRateChange(TObject *Sender)
- {
- ReDrawFields( PAGEIDX_TXALL );
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbCPTRxAntennaChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXChannelIDChange(TObject *Sender)
- {
- ReDrawFields( PAGEIDX_TXALL );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ShowHintLabel( TControl *sender, char* hint )
- {
- TPoint pt0 = this->ClientOrigin;
- TPoint pt1 = sender->ClientOrigin;
- lblHint->Left = (pt1.x-pt0.x);
- lblHint->Top = (pt1.y-pt0.y)+sender->Height+3;
- lblHint->Caption = hint;
- lblHint->Visible = true;
- HintTimer->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXStopClick(TObject *Sender)
- {
- if( 1 == btnTXStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbTX->Panels->Items[0]->Text = (AnsiString)" Stop continuous packet TX successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbCPRChannelIDChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbCPRRxAntennaChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnCPRResetClick(TObject *Sender)
- {
- // General RX
- int i;
- stCPRTotal->Caption = IntToStr( 0 );
- stCPRSuccess->Caption = IntToStr( 0 );
- stCPRFER->Caption = IntToStr( 0 );
- stCPRCRCErr->Caption = IntToStr( 0 );
- stCPRint_rx_ok_num->Caption = IntToStr( 0 );
- stCPRint_crc_err_num->Caption = IntToStr( 0 );
- stCPRpau_rx_ok_count->Caption = IntToStr( 0 );
- stCPRpau_crc_err_count->Caption = IntToStr( 0 );
- stCPRpau_cca_count->Caption = IntToStr( 0 );
- stCPRpau_rx_fifo_full_count->Caption = IntToStr( 0 );
- for( i=0; i<WIFI_TEST_RATE_COUNT; i++ )
- {
- stCPRSum[i]->Caption = IntToStr( 0 );
- stCPRGood[i]->Caption = IntToStr( 0 );
- stCPRBad[i]->Caption = IntToStr( 0 );
- stCPRFer[i]->Caption = IntToStr( 0 );
- }
- // RSSI
- stCPRMin->Caption = IntToStr( 0 );
- stCPRMax->Caption = IntToStr( 0 );
- stCPRMean->Caption = IntToStr( 0 );
- stCPRVariance->Caption = IntToStr( 0 );
- // Preamble
- stCPRLong->Caption = IntToStr( 0 );
- stCPRShort->Caption = IntToStr( 0 );
- m_WIFI_CPRX_Obj.ConfirmCallback = ::ConfirmCallback_QueryOriRxStatus;
- m_WIFI_CPRX_Obj.REQ_QueryRxStatus_Start();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnCPRStartClick(TObject *Sender)
- {
- unsigned int channel_freq = GetWiFiChannelFreqFromStr( cbCPRChannelID->Text );
- WiFi_RxAntSel_E rx_ant = (WiFi_RxAntSel_E) cbCPRRxAntenna->ItemIndex;
- CurrentPageLock();
- m_WIFI_CPRX_Obj.ConfirmCallback = ::ConfirmCallback_CPRX;
- m_WIFI_CPRX_Obj.REQ_Start( channel_freq, rx_ant );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_CPRX( void )
- {
- int state = m_WIFI_CPRX_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_CPRX_OK:
- {
- m_WIFI_CPRX_Obj.ConfirmCallback = ::ConfirmCallback_QueryOriRxStatus;
- m_WIFI_CPRX_Obj.REQ_QueryRxStatus_Start();
- TimerWiFi->Enabled = true;
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Continuous packet RX progressing";
- }
- break;
- case STATE_CPRX_FAIL:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Continuous packet RX fail";
- Application->MessageBox( "Execution Failure : Continuous packet RX", "FAILURE", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_CPRX_TIMEOUT:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Continuous packet RX timeout";
- Application->MessageBox( "Execution Timeout : Continuous packet RX", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_CPRX_STOP:
- {
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Continuous packet RX stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_QueryOriRxStatus( void )
- {
- int state = m_WIFI_CPRX_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_CPRX_OK:
- {
- WiFi_RxStatus_S rx_status;
- m_sOriRxStatus = m_WIFI_CPRX_Obj.Get_RxStatus();
- // stCPRSuccess->Caption = IntToStr( rx_status.int_rx_ok_num - m_sOriRxStatus.int_rx_ok_num );
- // stCPRCRCErr->Caption = IntToStr( rx_status.int_crc_err_num - m_sOriRxStatus.int_crc_err_num );
- // stCPRTotal->Caption = IntToStr( stCPRSuccess->Caption.ToInt() + stCPRCRCErr->Caption.ToInt() );
- // if( stCPRTotal->Caption.ToInt() != 0 )
- // {
- // stCPRFER->Caption = Double_To_AnsiString( stCPRCRCErr->Caption.ToInt() * 100.0 / stCPRTotal->Caption.ToInt() );
- // }
- 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;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnCPRStopClick(TObject *Sender)
- {
- if( btnCPRStart->Tag==1 )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbCPR->Panels->Items[0]->Text = (AnsiString)" Stop continuous packet RX successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXOPChannelIDChange(TObject *Sender)
- {
- // ReDrawFields( PAGEIDX_TXOP );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXOPTXFilterChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXOPTXRateChange(TObject *Sender)
- {
- // ReDrawFields( PAGEIDX_TXOP );
- }
- //---------------------------------------------------------------------------
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::TXOPExecute( void )
- {
- AnsiString text;
- S_WIFITXOP wifitxop;
- wifitxop.wifi_id = m_final_WiFiId;
- if( IDX_TX_FILTER_NORTH_AMERICA == cbTXTxFilter->ItemIndex )
- {
- wifitxop.reg_domain.country_code[0] = 'U';
- wifitxop.reg_domain.country_code[1] = 'S';
- }
- else
- {
- wifitxop.reg_domain.country_code[0] = 'J';
- wifitxop.reg_domain.country_code[1] = 'P';
- }
- wifitxop.channel_freq = GetWiFiChannelFreqFromStr( cbTXChannelID->Text );
- wifitxop.tx_rate = (WiFi_TestRate_E) GetWiFiTxRateFromStr( cbTXTxRate->Text );
- if( 0 == btnTXTxPowerDac->Tag )
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidDecWiFiTxPowerDac( text, wifitxop.tx_pwr_dac ) ) { edtTXOPTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- else
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidHexWiFiTxPowerDac( text, wifitxop.tx_pwr_dac ) ) { edtTXOPTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- CurrentPageLock();
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX output power progressing";
- m_WIFI_TXOP_Obj.ConfirmCallback = ::ConfirmCallback_TXOP;
- m_WIFI_TXOP_Obj.REQ_Start( wifitxop );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_TXOP( void )
- {
- int state = m_WIFI_TXOP_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_TXOP_OK:
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX output power progressing";
- break;
- case STATE_TXOP_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX output power fail";
- Application->MessageBox( "Execution Timeout : TX output power", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_TXOP_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX output power timeout";
- Application->MessageBox( "Execution Timeout : TX output power", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_TXOP_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX output power stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXOPStopClick(TObject *Sender)
- {
- if( 1 == btnTXStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbTX->Panels->Items[0]->Text = (AnsiString)" Stop TX output power successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXCSChannelIDChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbTXCSTXFilterChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::TXCSExecute( void )
- {
- AnsiString text;
- S_WIFITXCS wifitxcs;
- wifitxcs.wifi_id = m_final_WiFiId;
- wifitxcs.channel_freq = GetWiFiChannelFreqFromStr( cbTXChannelID->Text );
- if( IDX_TX_FILTER_NORTH_AMERICA == cbTXTxFilter->ItemIndex )
- {
- wifitxcs.reg_domain.country_code[0] = 'U';
- wifitxcs.reg_domain.country_code[1] = 'S';
- }
- else
- {
- wifitxcs.reg_domain.country_code[0] = 'J';
- wifitxcs.reg_domain.country_code[1] = 'P';
- }
- wifitxcs.tx_rate = (WiFi_TestRate_E) GetWiFiTxRateFromStr( cbTXTxRate->Text );
- if( 0 == btnTXTxPowerDac->Tag )
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidDecWiFiTxPowerDac( text, wifitxcs.tx_pwr_dac ) ) { edtTXCSTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- else
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidHexWiFiTxPowerDac( text, wifitxcs.tx_pwr_dac ) ) { edtTXCSTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- CurrentPageLock();
- sbTX->Panels->Items[0]->Text = (AnsiString) " TX Carrier suppression progressing";
- m_WIFI_TXCS_Obj.ConfirmCallback = ::ConfirmCallback_TXCS;
- m_WIFI_TXCS_Obj.REQ_Start( wifitxcs );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_TXCS( void )
- {
- int state = m_WIFI_TXCS_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_TXCS_OK:
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX carrier suppression progressing";
- break;
- case STATE_TXCS_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX carrier suppression fail";
- Application->MessageBox( "Execution Timeout : TX carrier suppression", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_TXCS_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX carrier suppression timeout";
- Application->MessageBox( "Execution Timeout : TX carrier suppression", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_TXCS_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" TX carrier suppression stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnTXCSStopClick(TObject *Sender)
- {
- if( 1 == btnTXStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbTX->Panels->Items[0]->Text = (AnsiString)" Stop TX carrier suppression successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbLFChannelIDChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::cbLFTXFilterChange(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmWiFi::LFExecute( void )
- {
- AnsiString text;
- S_WIFILF wifilf;
- wifilf.wifi_id = m_final_WiFiId;
- wifilf.channel_freq = GetWiFiChannelFreqFromStr( cbTXChannelID->Text );
- if( IDX_TX_FILTER_NORTH_AMERICA == cbTXTxFilter->ItemIndex )
- {
- wifilf.reg_domain.country_code[0] = 'U';
- wifilf.reg_domain.country_code[1] = 'S';
- }
- else
- {
- wifilf.reg_domain.country_code[0] = 'J';
- wifilf.reg_domain.country_code[1] = 'P';
- }
- wifilf.tx_rate = (WiFi_TestRate_E) GetWiFiTxRateFromStr( cbTXTxRate->Text );
- if( 0 == btnTXTxPowerDac->Tag )
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidDecWiFiTxPowerDac( text, wifilf.tx_pwr_dac ) ) { edtLFTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- else
- {
- text = edtTXTxPowerDAC->Text; if( !IsValidHexWiFiTxPowerDac( text, wifilf.tx_pwr_dac ) ) { edtLFTxPowerDACCheck(edtTXTxPowerDAC); return; }
- }
- CurrentPageLock();
- sbTX->Panels->Items[0]->Text = (AnsiString) " Local frequency test progressing";
- m_WIFI_LF_Obj.ConfirmCallback = ::ConfirmCallback_LF;
- m_WIFI_LF_Obj.REQ_Start( wifilf );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_LF( void )
- {
- int state = m_WIFI_LF_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_LF_OK:
- sbTX->Panels->Items[0]->Text = (AnsiString)" Local frequency test progressing";
- break;
- case STATE_LF_FAIL:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Local frequency test fail";
- Application->MessageBox( "Execution Timeout : Local frequency test", "FAIL", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_LF_TIMEOUT:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Local frequency test timeout";
- Application->MessageBox( "Execution Timeout : Local frequency test", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- CurrentPageReset();
- }
- break;
- case STATE_LF_STOP:
- {
- sbTX->Panels->Items[0]->Text = (AnsiString)" Local frequency test stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnLFStopClick(TObject *Sender)
- {
- if( 1 == btnTXStart->Tag )
- {
- Force_WiFi_Stop();
- CurrentPageReset();
- sbTX->Panels->Items[0]->Text = (AnsiString)" Stop local frequency test successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnPSStandbyClick(TObject *Sender)
- {
- m_WIFI_PS_Obj.ConfirmCallback = ::ConfirmCallback_PS;
- m_WIFI_PS_Obj.REQ_Start( WIFI_POWER_MODE_IDLE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnPSSleepClick(TObject *Sender)
- {
- m_WIFI_PS_Obj.ConfirmCallback = ::ConfirmCallback_PS;
- m_WIFI_PS_Obj.REQ_Start( WIFI_POWER_MODE_SLEEP );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtBBCRIndexCheck(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_uiBBIdx = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtBBCRDataCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- int band;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " character is not valid ";
- text = edit->Text;
- if( btnBBCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiBBRegValue( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiBBRegValue( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_ucBBValue = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBReadClick(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- if( !CheckFields( ACCESS_SINGLE, OP_READ ) )
- {
- sbBB->Panels->Items[0]->Text = (AnsiString) " Read baseband register fail";
- Application->MessageBox( "Execution Failure : Read baseband register", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- Compose_BBCR_Parameter( ACCESS_SINGLE );
-
- m_WIFI_BB_Obj.ConfirmCallback = ::ConfirmCallback_ReadBBReg;
- m_WIFI_BB_Obj.REQ_Read_BBCR_Setting_From_Reg_Start( m_sBBCR );
- // m_WIFI_BB_Obj.REQ_Read_From_Reg_Start( m_ucBBAddr );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadBBReg( void )
- {
- int state = m_WIFI_BB_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_BB_OK:
- {
- m_sBBCR = m_WIFI_BB_Obj.Get_BBCR();
- DeCompose_BBCR_Data( ACCESS_SINGLE );
- ReDrawFields( PAGEIDX_BB );
- sbBB->Panels->Items[0]->Text = (AnsiString)" Read baseband register successfully";
- }
- break;
- case STATE_BB_FAIL:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Read baseband register fail";
- Application->MessageBox( "Execution Timeout : Read baseband register", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_BB_TIMEOUT:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Read baseband register timeout";
- Application->MessageBox( "Execution Timeout : Read baseband register", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_BB_STOP:
- sbBB->Panels->Items[0]->Text = (AnsiString)" Read baseband register stop";
- break;
- }
- CurrentPageReset();
-
- }
- //-----------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnBBWriteClick(TObject *Sender)
- {
- AnsiString text;
- // unsigned char bb_reg_addr, bb_reg_data;
- // text = edtBBCRIndex->Text; if( !IsValidHexWiFiBBRegAddr( text, bb_reg_addr ) ) { edtBBCRIndexCheck(edtBBCRIndex); return; }
- // text = edtBBCRData->Text; if( !IsValidHexWiFiBBRegValue( text, bb_reg_data ) ) { edtBBCRDataCheck(edtBBCRData); return; }
- if( !CheckFields( ACCESS_SINGLE, OP_WRITE ) )
- {
- sbBB->Panels->Items[0]->Text = (AnsiString) " Write baseband register fail";
- Application->MessageBox( "Execution Failure : Write baseband register", "FAILURE", MB_OK );
- return;
- }
- Compose_BBCR_Parameter( ACCESS_SINGLE );
- Compose_BBCR_Data( ACCESS_SINGLE );
- m_WIFI_BB_Obj.ConfirmCallback = ::ConfirmCallback_WriteBBReg;
- m_WIFI_BB_Obj.REQ_Write_BBCR_Setting_To_Reg_Start( m_sBBCR );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_WriteBBReg( void )
- {
- int state = m_WIFI_BB_Obj.Get_ConfirmState();
- switch( state )
- {
- case STATE_BB_OK:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Write baseband register successfully";
- }
- break;
- case STATE_BB_FAIL:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Write baseband register fail";
- Application->MessageBox( "Execution Timeout : Write baseband register", "FAIL", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_BB_TIMEOUT:
- {
- sbBB->Panels->Items[0]->Text = (AnsiString)" Write baseband register timeout";
- Application->MessageBox( "Execution Timeout : Write baseband register", "TIMEOUT", MB_OK );
- Force_WiFi_Stop();
- }
- break;
- case STATE_BB_STOP:
- sbBB->Panels->Items[0]->Text = (AnsiString)" Write baseband register stop";
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtMACMCRAddressCheck(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_uiMacAddr = uidata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::edtMACMCRDataCheck(TObject *Sender)
- {
- AnsiString text;
- int band;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value is not valid ";
- text = edit->Text;
- if( rbMAC16bits->Checked )
- {
- unsigned short usdata;
- if( btnMACMCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiMacReg16Value( text, usdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiMacReg16Value( text, usdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_usMac16Data = usdata;
- }
- else
- {
- unsigned int uidata;
- if( btnMACMCRData->Tag==0 ) // Dec
- {
- if( !IsValidDecWiFiMacRegValue( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else // Hex
- {
- if( !IsValidHexWiFiMacRegValue( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- m_uiMacData = uidata;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmWiFi::btnMACReadClick(TObject *Sender)
- {
- AnsiString text;
- unsigned int mac_reg_addr;
- text = edtMACMCRAddress->Text; if( !IsValidHexWiFiMacRegAddr( text, mac_reg_addr ) ) { edtMACMCRAddressCheck(edtMACMCRAddress); return; }
- m_uiMacAddr = mac_reg_addr;
- CurrentPageLock();
- m_WIFI_MAC_Obj.ConfirmCallback = ::ConfirmCallback_ReadMACReg;
- if( rbMAC16bits->Checked )
- {
- Compose_MCR16_Parameter( ACCESS_SINGLE );
- m_WIFI_MAC_Obj.REQ_Read_MCR16_Setting_From_Reg_Start( m_sMCR16 );
- }
- else
- {
- Compose_MCR_Parameter( ACCESS_SINGLE );
- m_WIFI_MAC_Obj.REQ_Read_MCR_Setting_From_Reg_Start( m_sMCR );
- }
- sbMAC->Panels->Items[0]->Text = (AnsiString)" Read MAC register progressing";
- //m_WIFI_MAC_Obj.REQ_Read_From_Reg_Start( m_uiMacAddr );
- }
- //---------------------------------------------------------------------------
- void TfrmWiFi::ConfirmCallback_ReadMACReg( void )
- {
- int state = m_WIFI_MAC_Obj.Get_ConfirmState();