form_BT.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:232k
- //--------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- // BT
- #ifndef _BT_HCI_COMMON_H_
- #include "bt_hci_common.h"
- #endif
- #ifndef _BT_POWER_H_
- #include "bt_power.h"
- #endif
- // form
- #ifndef _FORM_BT_H_
- #include "form_BT.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- // misc
- #ifndef _MISC_BT_H_
- #include "misc_bt.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _FILE_UTILS_H_
- #include "file_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- // MF_Setup
- #ifndef _MFSETUPUTIL_H_
- #include "mfsetuputil.h"
- #endif
- // message
- #ifndef _META_LAB_MSG_H_
- #include "meta_lab_msg.h"
- #endif
- // security
- #ifndef _SLA_CHALLENGE_H_
- #include "sla_challenge.h"
- #endif
- // EDGE PC card
- #ifndef _PCMCIA_POWER_H_
- #include "pcmcia_power.h"
- #endif
- //---------------------------------------------------------------------------
- #define DRAW_MASK_HCI_CATEGORY 0x01
- #define DRAW_MASK_HCI_GROUP 0x02
- #define DRAW_MASK_HCI_COMMAND 0x04
- #define DRAW_MASK_HCI_PARAMETER 0x08
- #define HCI_NAME_COL_IDX 0
- #define HCI_BYTE_COL_IDX 1
- #define HCI_VALUE_COL_IDX 2
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmBT *frmBT;
- extern bool g_bHideEnable;
- //---------------------------------------------------------------------------
- static void ConfirmCallback_HCI(void)
- {
- frmBT->ConfirmCallback_HCI();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_SetupHCIFile(void)
- {
- frmBT->ConfirmCallback_SetupHCIFile();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_RFTX(void)
- {
- frmBT->ConfirmCallback_RFTX();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_RFRX(void)
- {
- frmBT->ConfirmCallback_RFRX();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_RFEnterTestMode(void)
- {
- frmBT->ConfirmCallback_RFEnterTestMode();
- }
- //---------------------------------------------------------------------------
- static void CNF_PKT(void)
- {
- frmBT->CNF_PKT();
- }
- //---------------------------------------------------------------------------
- static void CNF_PKT_Stop(void)
- {
- frmBT->CNF_PKT_Stop();
- }
- //---------------------------------------------------------------------------
- static void CNF_PKT_TCI(void)
- { frmBT->CNF_PKT_TCI();
- }
- //---------------------------------------------------------------------------
- static void CNF_PKT_Read_TxRxCount( void )
- { frmBT->CNF_PKT_Read_TxRxCount();
- }
- //---------------------------------------------------------------------------
- static void CNF_PKT_Read_EDRTxRxCount(void)
- {
- frmBT->CNF_PKT_Read_EDRTxRxCount();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_SetupSCTFile( void )
- { frmBT->ConfirmCallback_SetupSCTFile();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_SCT( void )
- { frmBT->ConfirmCallback_SCT();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void ConfirmCallback_QueryBDAddress( void )
- { frmBT->ConfirmCallback_QueryBDAddress();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void ConfirmCallback_ChangePCL( void )
- { frmBT->ConfirmCallback_ChangePCL();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_ReadLocalBDAddr( void )
- { frmBT->CNF_CT_ReadLocalBDAddr();
- }
- //---------------------------------------------------------------------------
- static void CNF_CT_WriteLocalBDAddr( void )
- { frmBT->CNF_CT_WriteLocalBDAddr();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_Reset( void )
- { frmBT->CNF_CT_Reset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_Scan( void )
- { frmBT->CNF_CT_Scan();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_AutoAccept( void )
- { frmBT->CNF_CT_AutoAccept();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_Inquiry( void )
- { frmBT->CNF_CT_Inquiry();
- }
- //---------------------------------------------------------------------------
- static void CNF_CT_InquiryCancel( void )
- { frmBT->CNF_CT_InquiryCancel();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_EnterPIN( void )
- { frmBT->CNF_CT_EnterPIN();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_ConnectACL( void )
- { frmBT->CNF_CT_ConnectACL();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_DisconnectACL( void )
- { frmBT->CNF_CT_DisconnectACL();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_ChangeACLPacketType( void )
- { frmBT->CNF_CT_ChangeACLPacketType();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_CT_ConnectSCO(void)
- {
- frmBT->CNF_CT_ConnectSCO();
- }
- //---------------------------------------------------------------------------
- static void CNF_CT_DisconnectSCO(void)
- {
- frmBT->CNF_CT_DisconnectSCO();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void CNF_TT_Scan(void)
- { frmBT->CNF_TT_Scan();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_AutoAccept( void )
- { frmBT->CNF_TT_AutoAccept();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_ConnectACL( void )
- { frmBT->CNF_TT_ConnectACL();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_DisconnectACL( void )
- { frmBT->CNF_TT_DisconnectACL();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_ChangeACLPacketType( void )
- { frmBT->CNF_TT_ChangeACLPacketType();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_TxData( void )
- { frmBT->CNF_TT_TxData();
- }
- //--------------------------------------------------------------------------
- static void CNF_TT_RxData(void)
- { frmBT->CNF_TT_RxData();
- }
- //---------------------------------------------------------------------------
- static void CNF_TT_Stop_RxData(void)
- { frmBT->CNF_TT_Stop_RxData();
- }
- //---------------------------------------------------------------------------
- __fastcall TfrmBT::TfrmBT(TComponent* Owner)
- : TForm(Owner)
- {
- // RF test
- m_edtRFTxAccessCode[0] = edtRFTxAccessCode0;
- m_edtRFTxAccessCode[1] = edtRFTxAccessCode1;
- m_edtRFTxAccessCode[2] = edtRFTxAccessCode2;
- m_edtRFTxAccessCode[3] = edtRFTxAccessCode3;
- m_edtRFTxAccessCode[4] = edtRFTxAccessCode4;
- m_edtRFTxAccessCode[5] = edtRFTxAccessCode5;
- m_edtRFTxAccessCode[6] = edtRFTxAccessCode6;
- m_edtRFTxAccessCode[7] = edtRFTxAccessCode7;
- // m_edtRFNAP[0] = edtRFNAP0;
- // m_edtRFNAP[1] = edtRFNAP1;
- // m_edtRFNAP[2] = edtRFNAP2;
- // m_edtRFNAP[3] = edtRFNAP3;
- // m_edtRFUAP[0] = edtRFUAP0;
- // m_edtRFUAP[1] = edtRFUAP1;
- // m_edtRFLAP[0] = edtRFLAP0;
- // m_edtRFLAP[1] = edtRFLAP1;
- // m_edtRFLAP[2] = edtRFLAP2;
- // m_edtRFLAP[3] = edtRFLAP3;
- // m_edtRFLAP[4] = edtRFLAP4;
- // m_edtRFLAP[5] = edtRFLAP5;
- // Packet test
- m_cbPKTType[0] = cbPKTDM1;
- m_cbPKTType[1] = cbPKTDH1;
- m_cbPKTType[2] = cbPKTDM3;
- m_cbPKTType[3] = cbPKTDH3;
- m_cbPKTType[4] = cbPKTDM5;
- m_cbPKTType[5] = cbPKTDH5;
- m_cbPKTType[6] = cbPKTHV1;
- m_cbPKTType[7] = cbPKTHV2;
- m_cbPKTType[8] = cbPKTHV3;
- m_cbPKTType[9] = cbPKTEV3;
- m_cbPKTType[10] = cbPKTEV4;
- m_cbPKTType[11] = cbPKTEV5;
- m_cbPKTType[12] = cbPK2DH1;
- m_cbPKTType[13] = cbPK2EV3;
- m_cbPKTType[14] = cbPK2DH3;
- m_cbPKTType[15] = cbPK2EV5;
- m_cbPKTType[16] = cbPK2DH5;
- m_cbPKTType[17] = cbPK3EV3;
- m_cbPKTType[18] = cbPK3DH1;
- m_cbPKTType[19] = cbPK3DH3;
- m_cbPKTType[20] = cbPK3EV5;
- m_cbPKTType[21] = cbPK3DH5;
- m_edtPKTDataLen[0] = edtPKTDM1DataLen;
- m_edtPKTDataLen[1] = edtPKTDH1DataLen;
- m_edtPKTDataLen[2] = edtPKTDM3DataLen;
- m_edtPKTDataLen[3] = edtPKTDH3DataLen;
- m_edtPKTDataLen[4] = edtPKTDM5DataLen;
- m_edtPKTDataLen[5] = edtPKTDH5DataLen;
- m_edtPKTPollPeriod[0] = edtPKTDM1PollPeriod;
- m_edtPKTPollPeriod[1] = edtPKTDH1PollPeriod;
- m_edtPKTPollPeriod[2] = edtPKTDM3PollPeriod;
- m_edtPKTPollPeriod[3] = edtPKTDH3PollPeriod;
- m_edtPKTPollPeriod[4] = edtPKTDM5PollPeriod;
- m_edtPKTPollPeriod[5] = edtPKTDH5PollPeriod;
- m_edtPKTPollPeriod[6] = edtPKTHV1PollPeriod;
- m_edtPKTPollPeriod[7] = edtPKTHV2PollPeriod;
- m_edtPKTPollPeriod[8] = edtPKTHV3PollPeriod;
- m_edtPKTPollPeriod[9] = edtPKTEV3PollPeriod;
- m_edtPKTPollPeriod[10] = edtPKTEV4PollPeriod;
- m_edtPKTPollPeriod[11] = edtPKTEV5PollPeriod;
- m_edtPKTPollPeriod[12] = edtPKT2DH1PollPeriod;
- m_edtPKTPollPeriod[13] = edtPKT2EV3PollPeriod;
- m_edtPKTPollPeriod[14] = edtPKT2DH3PollPeriod;
- m_edtPKTPollPeriod[15] = edtPKT2EV5PollPeriod;
- m_edtPKTPollPeriod[16] = edtPKT2DH5PollPeriod;
- m_edtPKTPollPeriod[17] = edtPKT3EV3PollPeriod;
- m_edtPKTPollPeriod[18] = edtPKT3DH1PollPeriod;
- m_edtPKTPollPeriod[19] = edtPKT3DH3PollPeriod;
- m_edtPKTPollPeriod[20] = edtPKT3EV5PollPeriod;
- m_edtPKTPollPeriod[21] = edtPKT3DH5PollPeriod;
- m_edtPKTPktCount[0] = edtPKTDM1PktCount;
- m_edtPKTPktCount[1] = edtPKTDH1PktCount;
- m_edtPKTPktCount[2] = edtPKTDM3PktCount;
- m_edtPKTPktCount[3] = edtPKTDH3PktCount;
- m_edtPKTPktCount[4] = edtPKTDM5PktCount;
- m_edtPKTPktCount[5] = edtPKTDH5PktCount;
- m_edtPKTPktCount[6] = edtPKTHV1PktCount;
- m_edtPKTPktCount[7] = edtPKTHV2PktCount;
- m_edtPKTPktCount[8] = edtPKTHV3PktCount;
- m_edtPKTPktCount[9] = edtPKTEV3PktCount;
- m_edtPKTPktCount[10] = edtPKTEV4PktCount;
- m_edtPKTPktCount[11] = edtPKTEV5PktCount;
- m_edtPKTPktCount[12] = edtPKT2DH1PktCount;
- m_edtPKTPktCount[13] = edtPKT2EV3PktCount;
- m_edtPKTPktCount[14] = edtPKT2DH3PktCount;
- m_edtPKTPktCount[15] = edtPKT2EV5PktCount;
- m_edtPKTPktCount[16] = edtPKT2DH5PktCount;
- m_edtPKTPktCount[17] = edtPKT3EV3PktCount;
- m_edtPKTPktCount[18] = edtPKT3DH1PktCount;
- m_edtPKTPktCount[19] = edtPKT3DH3PktCount;
- m_edtPKTPktCount[20] = edtPKT3EV5PktCount;
- m_edtPKTPktCount[21] = edtPKT3DH5PktCount;
- m_edtPKTTesterTXCount[0] = edtPKTTesterDM1TXCount;
- m_edtPKTTesterTXCount[1] = edtPKTTesterDH1TXCount;
- m_edtPKTTesterTXCount[2] = edtPKTTesterDM3TXCount;
- m_edtPKTTesterTXCount[3] = edtPKTTesterDH3TXCount;
- m_edtPKTTesterTXCount[4] = edtPKTTesterDM5TXCount;
- m_edtPKTTesterTXCount[5] = edtPKTTesterDH5TXCount;
- m_edtPKTTesterTXCount[6] = edtPKTTesterHV1TXCount;
- m_edtPKTTesterTXCount[7] = edtPKTTesterHV2TXCount;
- m_edtPKTTesterTXCount[8] = edtPKTTesterHV3TXCount;
- m_edtPKTTesterTXCount[9] = edtPKTTesterEV3TXCount;
- m_edtPKTTesterTXCount[10] = edtPKTTesterEV4TXCount;
- m_edtPKTTesterTXCount[11] = edtPKTTesterEV5TXCount;
- m_edtPKTTesterTXCount[12] = edtPKTTester2DH1TXCount;
- m_edtPKTTesterTXCount[13] = edtPKTTester2EV3TXCount;
- m_edtPKTTesterTXCount[14] = edtPKTTester2DH3TXCount;
- m_edtPKTTesterTXCount[15] = edtPKTTester2EV5TXCount;
- m_edtPKTTesterTXCount[16] = edtPKTTester2DH5TXCount;
- m_edtPKTTesterTXCount[17] = edtPKTTester3EV3TXCount;
- m_edtPKTTesterTXCount[18] = edtPKTTester3DH1TXCount;
- m_edtPKTTesterTXCount[19] = edtPKTTester3DH3TXCount;
- m_edtPKTTesterTXCount[20] = edtPKTTester3EV5TXCount;
- m_edtPKTTesterTXCount[21] = edtPKTTester3DH5TXCount;
- m_edtPKTTesterRXCount[0] = edtPKTTesterDM1RXCount;
- m_edtPKTTesterRXCount[1] = edtPKTTesterDH1RXCount;
- m_edtPKTTesterRXCount[2] = edtPKTTesterDM3RXCount;
- m_edtPKTTesterRXCount[3] = edtPKTTesterDH3RXCount;
- m_edtPKTTesterRXCount[4] = edtPKTTesterDM5RXCount;
- m_edtPKTTesterRXCount[5] = edtPKTTesterDH5RXCount;
- m_edtPKTTesterRXCount[6] = edtPKTTesterHV1RXCount;
- m_edtPKTTesterRXCount[7] = edtPKTTesterHV2RXCount;
- m_edtPKTTesterRXCount[8] = edtPKTTesterHV3RXCount;
- m_edtPKTTesterRXCount[9] = edtPKTTesterEV3RXCount;
- m_edtPKTTesterRXCount[10] = edtPKTTesterEV4RXCount;
- m_edtPKTTesterRXCount[11] = edtPKTTesterEV5RXCount;
- m_edtPKTTesterRXCount[12] = edtPKTTester2DH1RXCount;
- m_edtPKTTesterRXCount[13] = edtPKTTester2EV3RXCount;
- m_edtPKTTesterRXCount[14] = edtPKTTester2DH3RXCount;
- m_edtPKTTesterRXCount[15] = edtPKTTester2EV5RXCount;
- m_edtPKTTesterRXCount[16] = edtPKTTester2DH5RXCount;
- m_edtPKTTesterRXCount[17] = edtPKTTester3EV3RXCount;
- m_edtPKTTesterRXCount[18] = edtPKTTester3DH1RXCount;
- m_edtPKTTesterRXCount[19] = edtPKTTester3DH3RXCount;
- m_edtPKTTesterRXCount[20] = edtPKTTester3EV5RXCount;
- m_edtPKTTesterRXCount[21] = edtPKTTester3DH5RXCount;
- m_edtPKTDUTTXCount[0] = edtPKTDUTDM1TXCount;
- m_edtPKTDUTTXCount[1] = edtPKTDUTDH1TXCount;
- m_edtPKTDUTTXCount[2] = edtPKTDUTDM3TXCount;
- m_edtPKTDUTTXCount[3] = edtPKTDUTDH3TXCount;
- m_edtPKTDUTTXCount[4] = edtPKTDUTDM5TXCount;
- m_edtPKTDUTTXCount[5] = edtPKTDUTDH5TXCount;
- m_edtPKTDUTTXCount[6] = edtPKTDUTHV1TXCount;
- m_edtPKTDUTTXCount[7] = edtPKTDUTHV2TXCount;
- m_edtPKTDUTTXCount[8] = edtPKTDUTHV3TXCount;
- m_edtPKTDUTTXCount[9] = edtPKTDUTEV3TXCount;
- m_edtPKTDUTTXCount[10] = edtPKTDUTEV4TXCount;
- m_edtPKTDUTTXCount[11] = edtPKTDUTEV5TXCount;
- m_edtPKTDUTTXCount[12] = edtPKTDUT2DH1TXCount;
- m_edtPKTDUTTXCount[13] = edtPKTDUT2EV3TXCount;
- m_edtPKTDUTTXCount[14] = edtPKTDUT2DH3TXCount;
- m_edtPKTDUTTXCount[15] = edtPKTDUT2EV5TXCount;
- m_edtPKTDUTTXCount[16] = edtPKTDUT2DH5TXCount;
- m_edtPKTDUTTXCount[17] = edtPKTDUT3EV3TXCount;
- m_edtPKTDUTTXCount[18] = edtPKTDUT3DH1TXCount;
- m_edtPKTDUTTXCount[19] = edtPKTDUT3DH3TXCount;
- m_edtPKTDUTTXCount[20] = edtPKTDUT3EV5TXCount;
- m_edtPKTDUTTXCount[21] = edtPKTDUT3DH5TXCount;
- m_edtPKTDUTRXCount[0] = edtPKTDUTDM1RXCount;
- m_edtPKTDUTRXCount[1] = edtPKTDUTDH1RXCount;
- m_edtPKTDUTRXCount[2] = edtPKTDUTDM3RXCount;
- m_edtPKTDUTRXCount[3] = edtPKTDUTDH3RXCount;
- m_edtPKTDUTRXCount[4] = edtPKTDUTDM5RXCount;
- m_edtPKTDUTRXCount[5] = edtPKTDUTDH5RXCount;
- m_edtPKTDUTRXCount[6] = edtPKTDUTHV1RXCount;
- m_edtPKTDUTRXCount[7] = edtPKTDUTHV2RXCount;
- m_edtPKTDUTRXCount[8] = edtPKTDUTHV3RXCount;
- m_edtPKTDUTRXCount[9] = edtPKTDUTEV3RXCount;
- m_edtPKTDUTRXCount[10] = edtPKTDUTEV4RXCount;
- m_edtPKTDUTRXCount[11] = edtPKTDUTEV5RXCount;
- m_edtPKTDUTRXCount[12] = edtPKTDUT2DH1RXCount;
- m_edtPKTDUTRXCount[13] = edtPKTDUT2EV3RXCount;
- m_edtPKTDUTRXCount[14] = edtPKTDUT2DH3RXCount;
- m_edtPKTDUTRXCount[15] = edtPKTDUT2EV5RXCount;
- m_edtPKTDUTRXCount[16] = edtPKTDUT2DH5RXCount;
- m_edtPKTDUTRXCount[17] = edtPKTDUT3EV3RXCount;
- m_edtPKTDUTRXCount[18] = edtPKTDUT3DH1RXCount;
- m_edtPKTDUTRXCount[19] = edtPKTDUT3DH3RXCount;
- m_edtPKTDUTRXCount[20] = edtPKTDUT3EV5RXCount;
- m_edtPKTDUTRXCount[21] = edtPKTDUT3DH5RXCount;
- m_pT_CWT = NULL;
- // module test
- lblItem[ 0] = lblItem1; lblItem[10] = lblItem11; lblItem[20] = lblItem21;
- lblItem[ 1] = lblItem2; lblItem[11] = lblItem12; lblItem[21] = lblItem22;
- lblItem[ 2] = lblItem3; lblItem[12] = lblItem13;
- lblItem[ 3] = lblItem4; lblItem[13] = lblItem14; m_rbTestItem[0] = m_rbMTTestItem0;
- lblItem[ 4] = lblItem5; lblItem[14] = lblItem15; m_rbTestItem[1] = m_rbMTTestItem1;
- lblItem[ 5] = lblItem6; lblItem[15] = lblItem16; m_rbTestItem[2] = m_rbMTTestItem2;
- lblItem[ 6] = lblItem7; lblItem[16] = lblItem17; m_rbTestItem[3] = m_rbMTTestItem3;
- lblItem[ 7] = lblItem8; lblItem[17] = lblItem18; m_rbTestItem[4] = m_rbMTTestItem4;
- lblItem[ 8] = lblItem9; lblItem[18] = lblItem19;
- lblItem[ 9] = lblItem10; lblItem[19] = lblItem20;
- for (int n = 0; n < BT_MT_TESTCASE_NUM; n++)
- {
- Script[n] = 0;
- }
- ActIdx = -1;
- m_pvSendHCIPar = NULL;
- m_pvReceiveHCIPar = NULL;
- Init();
- WindowProc = SubClassWndProc;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmBT::AllocateVector( void )
- {
- if( NULL == m_pvSendHCIPar )
- m_pvSendHCIPar = new vector<S_BT_HCI_PARAMETER>;
- if( NULL == m_pvReceiveHCIPar )
- m_pvReceiveHCIPar = new vector<S_BT_HCI_PARAMETER>;
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DeAllocateVector( void )
- {
- if( m_pvSendHCIPar != NULL )
- {
- if( ! m_pvSendHCIPar->empty() )
- {
- m_pvSendHCIPar->erase( m_pvSendHCIPar->begin(), m_pvSendHCIPar->end() );
- }
- delete m_pvSendHCIPar;
- }
- if( m_pvReceiveHCIPar != NULL )
- {
- if( ! m_pvReceiveHCIPar->empty() )
- {
- m_pvReceiveHCIPar->erase( m_pvReceiveHCIPar->begin(), m_pvReceiveHCIPar->end() );
- }
- delete m_pvReceiveHCIPar;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::Init(void)
- {
- m_bInit = true;
- btnHCIStart->Enabled = true;
- btnRFTxStart->Enabled = true;
- // btnRFRxStart->Enabled = true;
- btnPKTStart->Enabled = true;
- btnPKTConnectDUT->Enabled = true;
- m_btnMTConnect->Enabled = m_cbMETAMode->Checked;
- shpPKTConnect->Brush->Color = clRed;
- m_shpMTConnect->Brush->Color = clRed;
- m_bConnectTargetok = false;
- m_bConnectingTarget = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::FormHide(TObject *Sender)
- {
- m_sCWT.iBootStop = BOOT_STOP;
- AbortConnectWithTarget();
- }
- //==============================================================================
- void _fastcall TfrmBT::SubClassWndProc( Messages::TMessage &Message)
- {
- switch ( Message.Msg )
- {
- case WM_ML_BT_BD_ADDRESS_MSG:
- {
- DisplayPKTBDAddress( (E_BT_PACKET_DEVICE_T) Message.WParam );
- }
- break;
- case WM_ML_BT_START_MONITOR_MSG:
- {
- MonitorTimer->Enabled = true;
- }
- break;
- // case WM_ML_BT_DISPLAY_SCT_UI_MSG:
- // {
- // }
- // break;
-
- case WM_ML_BT_PRINT_MSG:
- {
- switch( (E_BT_PAGEIDX) Message.WParam )
- {
- case PAGEIDX_BT_HCI:
- {
- FillHCIResult();
- }
- break;
- case PAGEIDX_BT_RF:
- { FillRFResult();
- }
- break;
- case PAGEIDX_BT_PKT:
- { FillPKTResult();
- }
- break;
- case PAGEIDX_BT_SCT:
- { FillSCTResult();
- }
- break;
- case PAGEIDX_BT_TT:
- { FillTTResult();
- }
- break;
- case PAGEIDX_BT_CT:
- { FillCTResult();
- }
- break;
- }
- }
- break;
- case WM_ML_BT_PIN_MSG:
- {
- btnCTEnterPIN->Enabled = true;
- ShowHintLabel( edtCTPIN, "Please enter PIN code" );
- }
- break;
- case MW_ML_BT_CONNECT_MSG:
- {
- switch( (E_BT_PAGEIDX) Message.WParam )
- {
- case PAGEIDX_BT_CT:
- {
- ReDrawCTFields( DRAM_MASK_CT_DISCOVERED_LIST |
- DRAM_MASK_CT_CONNECT_LIST |
- DRAM_MASK_CT_ACL_STATUS |
- DRAM_MASK_CT_BUTTON );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect from remote BT device";
- }
- break;
- case PAGEIDX_BT_TT:
- {
- m_sBTTTRes = m_cBT_TT_Obj.Get_TTResult();
- ReDrawTTFields( DRAM_MASK_TT_ACL_STATUS |
- DRAM_MASK_TT_BUTTON );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Connect from remote BT device";
- }
- break;
- }
- }
- break;
- case WM_ML_BT_DISCONNECT_MSG:
- {
- switch( (E_BT_PAGEIDX) Message.WParam )
- {
- case PAGEIDX_BT_CT:
- {
- ReDrawCTFields( DRAM_MASK_CT_DISCOVERED_LIST |
- DRAM_MASK_CT_CONNECT_LIST |
- DRAM_MASK_CT_ACL_STATUS |
- DRAM_MASK_CT_BUTTON );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect from remote BT device";
- }
- break;
- case PAGEIDX_BT_TT:
- {
- m_sBTTTRes = m_cBT_TT_Obj.Get_TTResult();
- ReDrawTTFields( DRAM_MASK_TT_ACL_STATUS |
- DRAM_MASK_TT_BUTTON );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Disconnect from remote BT device";
- }
- break;
- }
- }
- break;
- case WM_ML_BT_TT_TX_STATUS:
- {
- unsigned int ui_pkt_length = (unsigned int) Message.WParam;
- unsigned int ui_used_time;
- if (BT_TT_VER_0 == m_eTtVer)
- {
- S_TIME time;
- time = ::Get_CurrentTime();
- int msec = DifferenceMiniSec(&m_sTTTxStartTime, &time);
- ui_used_time = (unsigned int) msec;
- }
- else
- {
- ui_used_time = (unsigned int) Message.LParam;
- }
- if (0 == ui_used_time)
- {
- return;
- }
- int data_len = edtTTDataLen->Text.ToInt();
- float tx_throughput = 1000.0 * ui_pkt_length / ui_used_time;
- int count = ui_pkt_length/data_len;
- char str[64];
- sprintf(str, "%.3f", tx_throughput);
- stTTTxCount->Caption = IntToStr(count);
- stTTTxThroughput->Caption = (AnsiString) str;
- if (count >= edtTTPacketCount->Text.ToInt())
- {
- CurrentPageReset();
- }
- }
- break;
- case WM_ML_BT_TT_RX_STATUS:
- {
- unsigned int ui_pkt_length = (unsigned int) Message.WParam;
- unsigned int ui_used_time;
- if (BT_TT_VER_0 == m_eTtVer)
- {
- S_TIME time;
- time = ::Get_CurrentTime();
- int msec = DifferenceMiniSec(&m_sTTRxStartTime, &time);
- ui_used_time = (unsigned int) msec;
- }
- else
- {
- ui_used_time = (unsigned int) Message.LParam;
- }
- if (0 == ui_used_time)
- {
- return;
- }
- // int data_len = edtTTDataLen->Text.ToInt();
- float rx_throughput = 1000.0 * ui_pkt_length / ui_used_time;
- char str[64];
- sprintf(str, "%.3f", rx_throughput);
- stTTRxBytes->Caption = IntToStr(ui_pkt_length);
- stTTRxThroughput->Caption = (AnsiString) str;
- }
- break;
- default:
- this->WndProc( Message );
- break;
- }
- }
- //===========================================================================
- //////////////////////////// Form event handler //////////////////////////
- //===========================================================================
- void __fastcall TfrmBT::FormCreate(TObject *Sender)
- {
- m_bFirstFormShow = true;
- // allocate memory
- m_pHCILog = new TStringList;
- m_pRFLog = new TStringList;
- m_pPKTLog = new TStringList;
- m_pSCTLog = new TStringList;
- m_pCTLog = new TStringList;
- m_pTTLog = new TStringList;
- AllocateVector();
- if( rbHCICategory->Checked )
- {
- cbHCICategory->Enabled = true;
- cbHCIGroup->Enabled = false;
- }
- else
- {
- cbHCICategory->Enabled = false;
- cbHCIGroup->Enabled = true;
- }
- // RF test
- cbRFTxPattern->ItemIndex = 0;
- // packet test
- cbPKTBaudRate->ItemIndex = 0;
- // throughput test
- m_cbTTScanType->ItemIndex = 3;
- // connection test
- cbCTScanType->ItemIndex = 3;
- m_uiInquiryTimeout = edtCTInquiryTimeout->Text.ToInt() * 1.28 * 1000;
- m_sBTPIN.uc_pin_len = 4;
- for( int i=0; i<m_sBTPIN.uc_pin_len; i++ )
- m_sBTPIN.uc_PIN[i] = '0';
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- ApplyHideProperty();
- BT_ModuleID_S* p_bt_module_id = frmMainSel->Get_BTMoudleID();
- m_cBtId = p_bt_module_id->id;
-
- DisplayBtRfTestUi();
- DisplayBtPktTestUi();
- DisplayBtThroughputTestUi();
- DisplayBtConnectionTestUi();
- CBTPOWER BT_POWER_Obj;
- BT_POWER_Obj.REQ_Power_On_Main_BT_Start();
- m_eTtVer = m_cBT_TT_Obj.Query_TtTestVersion();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::FormClose(TObject *Sender, TCloseAction &Action)
- {
- // HCI file
- SaveHCIFile();
- AbortConnectWithTarget();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::FormDestroy(TObject *Sender)
- {
- // free memory
- if( m_pHCILog )
- delete m_pHCILog;
- if( m_pRFLog )
- delete m_pRFLog;
- if( m_pPKTLog )
- delete m_pPKTLog;
- if( m_pSCTLog )
- delete m_pSCTLog;
- if( m_pTTLog )
- delete m_pTTLog;
- if( m_pCTLog )
- delete m_pCTLog;
-
- DeAllocateVector();
- if( m_bConnectTargetok )
- {
- META_ShutDownTarget_r( m_META_HANDLE_Obj.Get_SecondHandle() );
- META_DisconnectWithTarget_r( m_META_HANDLE_Obj.Get_SecondHandle() );
- m_bConnectTargetok = false;
- }
- if( NULL == m_pT_CWT )
- m_sCWT.iBootStop = BOOT_STOP;
- WaitForSingleObject( m_sCWT.METADLL_Connect_Event, 5000 );
- // release handle
- m_META_HANDLE_Obj.REQ_ReleaseSecondHandle_Start();
- }
- //===========================================================================
- void TfrmBT::DisplayBtRfTestUi(void)
- {
- cbRFTxType->Clear();
- AnsiString as_nonedr_pkt_name[] =
- {
- "NULL",
- "POLL",
- "FHS",
- "DM1",
- "DH1",
- "HV1",
- "HV2",
- "HV3",
- "DV",
- "AUX",
- "DM3",
- "DH3",
- "DM5",
- "DH5",
- "EV3",
- "EV4",
- "EV5"
- };
- for (int i=0; i<BT_RF_TX_NONEDR_IDX_COUNT; i++)
- {
- cbRFTxType->Items->Add(as_nonedr_pkt_name[i]);
- }
- if (BTMODULE_MT6611 == m_cBtId)
- {
- AnsiString as_edr_pkt_name[] =
- {
- "2-DH1",
- "2-EV3",
- "2-DH3",
- "2-EV5",
- "2-DH5",
- "3-EV3",
- "3-DH1",
- "3-DH3",
- "3-EV5",
- "3-DH5"
- };
- for (int i=0; i<BT_RF_TX_IDX_COUNT-BT_RF_TX_NONEDR_IDX_COUNT; i++)
- {
- cbRFTxType->Items->Add(as_edr_pkt_name[i]);
- }
- }
- cbRFTxType->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayBtPktTestUi(void)
- {
- bool b_visible = (BTMODULE_MT6611 == m_cBtId);
- for (int i=BT_PACKET_IDX_2DH1; i<BT_PACKET_IDX_COUNT; i++)
- {
- m_cbPKTType[i]->Visible = b_visible;
- m_edtPKTPollPeriod[i]->Visible = b_visible;
- m_edtPKTPktCount[i]->Visible = b_visible;
- m_edtPKTTesterTXCount[i]->Visible = b_visible;
- m_edtPKTTesterRXCount[i]->Visible = b_visible;
- m_edtPKTDUTTXCount[i]->Visible = b_visible;
- m_edtPKTDUTRXCount[i]->Visible = b_visible;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayBtThroughputTestUi(void)
- {
- bool b_eco_support = (BTMODULE_MT6611 == m_cBtId);
- m_cbTT2DH1->Visible = b_eco_support;
- m_cbTT2DH3->Visible = b_eco_support;
- m_cbTT2DH5->Visible = b_eco_support;
- m_cbTT3DH1->Visible = b_eco_support;
- m_cbTT3DH3->Visible = b_eco_support;
- m_cbTT3DH5->Visible = b_eco_support;
- if (b_eco_support)
- {
- edtTTDataLen->Text = "1021";
- }
- else
- {
- edtTTDataLen->Text = "339";
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayBtConnectionTestUi(void)
- {
- bool b_edr_support = (BTMODULE_MT6611 == m_cBtId);
- cbCT2DH1->Visible = b_edr_support;
- cbCT2DH3->Visible = b_edr_support;
- cbCT2DH5->Visible = b_edr_support;
- cbCT3DH1->Visible = b_edr_support;
- cbCT3DH3->Visible = b_edr_support;
- cbCT3DH5->Visible = b_edr_support;
- AnsiString as_SCO_NONEDR_PKT[] =
- {
- "HV1",
- "HV2",
- "HV3",
- "EV3",
- "EV4",
- "EV5"
- };
- cbCTSCOPktType->Clear();
- for (int i=0; i<SCO_PKT_NONEDR_IDX_COUNT; i++)
- {
- cbCTSCOPktType->Items->Add(as_SCO_NONEDR_PKT[i]);
- }
- if (b_edr_support)
- {
- AnsiString as_SCO_EDR_PKT[] =
- {
- "2-EV3",
- "3-EV3",
- "2-EV5",
- "3-EV5"
- };
- for (int i=0; i<SCO_PKT_IDX_COUNT-SCO_PKT_IDX_2EV3; i++)
- {
- cbCTSCOPktType->Items->Add(as_SCO_EDR_PKT[i]);
- }
- }
- cbCTSCOPktType->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CurrentPageReset( void )
- {
- switch (m_pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_BT_HCI:
- {
- btnHCIStart->Enabled = true;
- btnHCIStart->Tag = 0;
- }
- break;
- case PAGEIDX_BT_RF:
- {
- btnRFTxStart->Enabled = true;
- btnRFTxStart->Tag = 0;
- // btnRFRxStart->Enabled = true;
- // btnRFRxStart->Tag = 0;
- btnRFEnterTestMode->Enabled = true;
- btnRFQueryBdAddr->Enabled = true;
- btnRFChangeLevel->Enabled = false;
- }
- break;
- case PAGEIDX_BT_PKT:
- {
- cbPKTDM1->Enabled = true;
- cbPKTDH1->Enabled = true;
- cbPKTDM3->Enabled = true;
- cbPKTDH3->Enabled = true;
- cbPKTDM5->Enabled = true;
- btnPKTConnectDUT->Enabled = true;
- btnPKTStart->Enabled = true;
- btnPKTStart->Tag = 0;
- }
- break;
- case PAGEIDX_BT_SCT:
- {
- btnSCTStart->Enabled = true;
- btnSCTStart->Tag = 0;
- }
- break;
- case PAGEIDX_BT_TT:
- {
- ReDrawTTFields( DRAM_MASK_TT_BUTTON );
- }
- break;
- case PAGEIDX_BT_CT:
- {
- btnCTLDIRead->Enabled = true;
- btnCTLDIWrite->Enabled = true;
- btnCTEnterPIN->Enabled = true;
- // btnCTConnectSCO->Enabled = true;
- // btnCTScanStart->Enabled = true;
- // btnCTScanStart->Tag = 0;
- btnCTInquiryStart->Enabled = true;
- btnCTInquiryStart->Tag = 0;
- // btnCTConnect->Enabled = true;
- // btnCTDisconnect->Enabled = true;
- // btnCTChangeAclPktType->Enabled = true;
- btnCTResetLD->Enabled = true;
- ReDrawCTFields( DRAM_MASK_CT_BUTTON );
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CurrentPageLock( void )
- {
- switch(m_pctlToolSel->ActivePageIndex)
- {
- case PAGEIDX_BT_HCI:
- { btnHCIStart->Enabled = false;
- btnHCIStart->Tag = 1;
- }
- break;
- case PAGEIDX_BT_RF:
- {
- btnRFTxStart->Enabled = false;
- btnRFTxStart->Tag = 1;
- // btnRFRxStart->Enabled = false;
- // btnRFRxStart->Tag = 1;
- btnRFEnterTestMode->Enabled = false;
- btnRFQueryBdAddr->Enabled = false;
- if( cbRFTxPowerCtrl->Checked )
- {
- btnRFChangeLevel->Enabled = true;
- }
- }
- break;
- case PAGEIDX_BT_PKT:
- {
- btnPKTConnectDUT->Enabled = false;
- btnPKTStart->Enabled = false;
- btnPKTStart->Tag = 1;
- }
- break;
- case PAGEIDX_BT_SCT:
- {
- btnSCTStart->Enabled = false;
- btnSCTStart->Tag = 1;
- }
- break;
- case PAGEIDX_BT_TT:
- {
- btnTTScan->Enabled = false;
- btnTTAutoAccept->Enabled = false;
- btnTTConnect->Enabled = false;
- btnTTDisconnect->Enabled = false;
- btnTTChangeACLPacketType->Enabled = false;
- btnTTTxStart->Enabled = false;
- btnTTTxStart->Tag = 1;
- btnTTRxStart->Enabled = false;
- btnTTRxStart->Tag = 1;
- }
- break;
- case PAGEIDX_BT_CT:
- {
- btnCTLDIRead->Enabled = false;
- btnCTLDIWrite->Enabled = false;
- btnCTScan->Enabled = false;
- btnCTAutoAccept->Enabled = false;
- btnCTEnterPIN->Enabled = false;
- btnCTConnectSCO->Enabled = false;
- btnCTDisconnectSCO->Enabled = false;
- // btnCTScanStart->Enabled = false;
- // btnCTScanStart->Tag = 1;
- btnCTInquiryStart->Enabled = false;
- btnCTInquiryStart->Tag = 1;
- btnCTInquiryStart->Enabled = false;
- btnCTConnectACL->Enabled = false;
- btnCTDisconnectACL->Enabled = false;
- btnCTChangeAclPktType->Enabled = false;
- btnCTResetLD->Enabled = false;
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::CheckHCIFields( void )
- {
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::CheckRFFields( E_CHECK_MASK_RF check_mask )
- {
- AnsiString text;
- if( CHECK_MASK_RF_TX == check_mask )
- {
- // pattern
- if( cbRFTxPattern->Text.AnsiCompareIC("0000") == 0 )
- { m_sBtRf.e_pattern = BT_TX_ALL_ZEROS;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("1111") == 0 )
- { m_sBtRf.e_pattern = BT_TX_ALL_ONES;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("1010") == 0 )
- { m_sBtRf.e_pattern = BT_TX_ALTER_BITS;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("1100") == 0 )
- { m_sBtRf.e_pattern = BT_TX_ONES_ZEROS;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("pseudorandom bit sequence") == 0 )
- { m_sBtRf.e_pattern = BT_TX_PSEUDO_RANDOM;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("loopback ACL with whitening") == 0 )
- { m_sBtRf.e_pattern = BT_TX_LOOPBACK_ACL_WITH_WHITENING;
- }
- else if( cbRFTxPattern->Text.AnsiCompareIC("loopback SCO with whitening") == 0 )
- { m_sBtRf.e_pattern = BT_TX_LOOPBACK_SCO_WITH_WHITENING;
- }
- // else if( cbRFTxPattern->Text.AnsiCompareIC("loopback ACL without whitening") == 0 )
- // { m_sBtRf.e_pattern = BT_TX_LOOPBACK_ACL_WITHOUT_WHITENING;
- // }
- else
- { m_sBtRf.e_pattern = BT_TX_LOOPBACK_SCO_WITHOUT_WHITENING;
- }
- }
- else
- {
- m_sBtRf.e_pattern = BT_RX_TEST;
- }
- // whiten
- if( cbRFTxWhiten->Checked )
- { m_sBtRf.e_whiten = BT_TX_WHITEN_ON;
- }
- else
- { m_sBtRf.e_whiten = BT_TX_WHITEN_OFF;
- }
- // freuency type
- if( rbRFTxSingleFreq->Checked )
- {
- m_sBtRf.e_freq_type = BT_FREQ_SINGLE;
- }
- else
- { m_sBtRf.e_freq_type = BT_FREQ_HOPPING;
- }
- // packet
- if( cbRFTxType->Text.AnsiCompareIC("NULL") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_NULL;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("POLL") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_POLL;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("FHS") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_FHS;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DM1") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DM1;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DH1") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DH1;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("HV1") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_HV1;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("HV2") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_HV2;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("HV3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_HV3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DV") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DV;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("AUX") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_AUX;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DM3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DM3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DH3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DH3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DM5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DM5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("DH5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_DH5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("EV3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_EV3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("EV4") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_EV4;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("EV5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_EV5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("2-DH1") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_2DH1;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("2-EV3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_2EV3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("2-DH3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_2DH3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("2-EV5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_2EV5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("2-DH5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_2DH5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("3-EV3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_3EV3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("3-DH1") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_3DH1;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("3-DH3") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_3DH3;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("3-EV5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_3EV5;
- }
- else if( cbRFTxType->Text.AnsiCompareIC("3-DH5") == 0 )
- { m_sBtRf.e_packet_type = BT_RF_PACKET_3DH5;
- }
- // power control
- #if 0
- }
- else // RX
- {
- // freuency type
- if( rbRFRxSingleFreq->Checked )
- {
- m_sBtRf.e_freq_type = BT_FREQ_SINGLE;
- }
- else
- { m_sBtRf.e_freq_type = BT_FREQ_HOPPING;
- }
- // packet
- if( rbRFRxContRx->Checked )
- { m_sBtRf.e_packet_type = BT_TX_PACKET_CONT_RX;
- }
- else
- { m_sBtRf.e_packet_type = BT_TX_PACKET_BURST_RX;
- }
- }
- #endif
- text = edtRFTxSignleFreq->Text; if( !IsValidBTFreq( text, m_sBtRf.uc_freq ) ) { edtRFTxSignleFreqCheck(edtRFTxSignleFreq); return false; }
- // text = edtRFTxSignleFreq->Text; if( !IsValidBTFreq( text, m_sBtRf.uc_rx_freq ) ) { edtRFRxSignleFreqCheck(edtRFTxSignleFreq); return false; }
- text = edtRFTxDataLen->Text; if( !IsValidBTTxDataLength( text, m_sBtRf.us_data_len, Get_RFTxDataMinLen(cbRFTxType->ItemIndex), Get_RFTxDataMaxLen(cbRFTxType->ItemIndex) ) ) { edtRFTxDataLenCheck(edtRFTxDataLen); return false; }
- text = edtRFTxPollPeriod->Text; if( !IsValidBTTxPollPeriod( text, m_sBtRf.uc_poll_period ) ) { edtRFTxPollPeriodCheck(edtRFTxPollPeriod); return false; }
- // power control
- if( cbRFTxPowerCtrl->Checked )
- { m_sBtRf.e_power_ctrl = BT_TX_POWER_CTRL_ON;
- }
- else
- { m_sBtRf.e_power_ctrl = BT_TX_POWER_CTRL_OFF;
- }
- text = edtRFTxLevel->Text; if( !IsValidBTTxPcl( text, m_sBtRf.uc_pcl ) ) { edtRFTxLevelCheck(edtRFTxLevel); return false; }
- // access code
- for( int i=0; i<(sizeof(m_sBtRf.s_access_code.uc_access_code)/sizeof(m_sBtRf.s_access_code.uc_access_code[0])); i++ )
- { text = m_edtRFTxAccessCode[i]->Text; if( !IsValidHexBTTxAccessCode( text, m_sBtRf.s_access_code.uc_access_code[i] ) ) { edtRFTxAccessCodeCheck(m_edtRFTxAccessCode[i]); return false; }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void TfrmBT::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 TfrmBT::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnHCIFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- ok = dlgOpenHCIFile->Execute();
- if (!::CheckFileExist(dlgOpenHCIFile->FileName))
- {
- ok = false;
- }
-
- if( !ok )
- {
- sbHCI->Panels->Items[0]->Text = (AnsiString) " Load HCI file fail";
- return;
- }
- m_sBTHCI.hPostMsgDestHandle = this->Handle;
- m_sBTHCI.filename = dlgOpenHCIFile->FileName;
- m_sBTHCI.log = m_pHCILog;
- m_BT_HCI_Obj.ConfirmCallback = ::ConfirmCallback_SetupHCIFile;
- m_BT_HCI_Obj.REQ_Read_From_File_Start( m_sBTHCI );
- sbHCI->Panels->Items[0]->Text = (AnsiString) " Setup HCI file progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_SetupHCIFile(void)
- {
- E_METAAPP_RESULT_T state = m_BT_HCI_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- stHCIFile->Caption = m_sBTHCI.filename;
- if( rbHCICategory->Checked )
- {
- m_pvHCICategory = m_BT_HCI_Obj.Get_HciCategoryVector();
- DisplayHCIUI( DRAW_MASK_HCI_CATEGORY | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- else
- {
- m_pvHCIGroup = m_BT_HCI_Obj.Get_HciGroupVector();
- DisplayHCIUI( DRAW_MASK_HCI_GROUP | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Setup HCI file successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Setup HCI file fail";
- Application->MessageBox( "Execution Fail : Setup HCI file", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Setup HCI file timeout";
- Application->MessageBox("Execution Timeout : Setup HCI file", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Setup HCI file stop";
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayHCIUI( int draw_mask, int category_group_idx, int cmd_idx )
- {
- static vector<S_BT_HCI_CATEGORY>:: iterator iter_category;
- static vector<S_BT_HCI_GROUP>:: iterator iter_group;
- vector<S_BT_HCI_COMMAND>:: iterator iter_cmd;
- vector<S_BT_HCI_PARAMETER>:: iterator iter_par;
- S_BT_HCI_CATEGORY category;
- S_BT_HCI_GROUP group;
- S_BT_HCI_COMMAND command;
- S_BT_HCI_PARAMETER parameter;
- if( rbHCICategory->Checked )
- {
- if( draw_mask & DRAW_MASK_HCI_CATEGORY )
- {
- cbHCICategory->Clear();
- // display category
- for( iter_category = m_pvHCICategory->begin(); iter_category != m_pvHCICategory->end(); iter_category++ )
- {
- category = *iter_category;
- cbHCICategory->Items->Add( category.as_category_name );
- }
- iter_category = m_pvHCICategory->begin();
- cbHCICategory->ItemIndex = category_group_idx;
- }
- // display command
- if( draw_mask & DRAW_MASK_HCI_COMMAND )
- {
- for( iter_category = m_pvHCICategory->begin(); iter_category != m_pvHCICategory->end(); iter_category++ )
- {
- category = *iter_category;
- if( category.as_category_name.AnsiCompareIC(cbHCICategory->Text) == 0 )
- {
- break;
- }
- }
- cbHCICommand->Clear();
- for( iter_cmd = iter_category->v_cmd.begin(); iter_cmd != iter_category->v_cmd.end(); iter_cmd++ )
- {
- command = *iter_cmd;
- cbHCICommand->Items->Add( command.as_cmd_name );
- }
- cbHCICommand->ItemIndex = cmd_idx;
- }
- // display parameter
- if( draw_mask & DRAW_MASK_HCI_PARAMETER )
- {
- // sgSendHCI->EditorMode = true;
- for( iter_cmd = iter_category->v_cmd.begin(); iter_cmd != iter_category->v_cmd.end(); iter_cmd++ )
- {
- command = *iter_cmd;
- if( command.as_cmd_name.AnsiCompareIC(cbHCICommand->Text) == 0 )
- {
- if( ! m_pvSendHCIPar->empty() )
- {
- m_pvSendHCIPar->erase( m_pvSendHCIPar->begin(), m_pvSendHCIPar->end() );
- }
- if( ! m_pvReceiveHCIPar->empty() )
- {
- m_pvReceiveHCIPar->erase( m_pvReceiveHCIPar->begin(), m_pvReceiveHCIPar->end() );
- }
- char str[20];
- sprintf( str, "%X", iter_cmd->us_opcode );
- stHCIOpcode->Caption = str;
- sprintf( str, "%X", iter_cmd->uc_last_event );
- stHCILastEvent->Caption = str;
- edtHCITimeout->Text = iter_cmd->ui_ms_timeout;
- // send parameter
- if( 0 == iter_cmd->ui_send_num )
- {
- sgSendHCI->FixedCols = 3;
- sgSendHCI->FixedRows = 1;
- sgSendHCI->ColCount = 4;
- sgSendHCI->RowCount = 2;
- sgSendHCI->Cells[HCI_NAME_COL_IDX][1] = "";
- sgSendHCI->Cells[HCI_BYTE_COL_IDX][1] = "";
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][1] = "";
- }
- else
- {
- sgSendHCI->FixedCols = 2;
- sgSendHCI->FixedRows = 1;
- sgSendHCI->ColCount = 4;
- sgSendHCI->RowCount = iter_cmd->ui_send_num+1;
- for (unsigned int i=0; i<iter_cmd->ui_send_num; i++ )
- {
- iter_par = iter_cmd->v_send_par.begin() + i;
- parameter = *iter_par;
- sgSendHCI->Cells[HCI_NAME_COL_IDX][i+1] = iter_par->as_name;
- sgSendHCI->Cells[HCI_BYTE_COL_IDX][i+1] = IntToStr( iter_par->ui_bytes );
- AnsiString as_value;
- if( rbHCIDec->Checked )
- {
- BTHCIValue_To_AnsiString( iter_par->s_value, as_value );
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][i+1] = as_value;
- }
- else
- {
- BTHCIValue_To_Hex_AnsiString( iter_par->s_value, as_value );
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][i+1] = as_value;
- }
- S_BT_HCI_PARAMETER hci_par;
- // for( int j=0; j<BT_HCI_VALUE_SIZE; j++ )
- // {
- // parameter.s_value.uc_value[j] = 0;
- // }
- // parameter.s_value.uc_nz_byte = 0;
- m_pvSendHCIPar->push_back( parameter );
- }
- }
- // receive parameter
- if( 0 == iter_cmd->ui_receive_num )
- {
- sgReceiveHCI->FixedCols = 3;
- sgReceiveHCI->FixedRows = 1;
- sgReceiveHCI->ColCount = 4;
- sgReceiveHCI->RowCount = 2;
- sgReceiveHCI->Cells[HCI_NAME_COL_IDX][1] = "";
- sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][1] = "";
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][1] = "";
- }
- else
- {
- sgReceiveHCI->FixedCols = 2;
- sgReceiveHCI->FixedRows = 1;
- sgReceiveHCI->ColCount = 4;
- // sgReceiveHCI->RowCount = iter_cmd->ui_receive_num+1;
- int count = 0;
- for (unsigned int i=0; i<iter_cmd->ui_receive_num; i++)
- {
- iter_par = iter_cmd->v_receive_par.begin() + i;
- parameter = *iter_par;
- if( iter_par->b_show )
- {
- sgReceiveHCI->Cells[HCI_NAME_COL_IDX][count+1] = iter_par->as_name;
- sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][count+1] = IntToStr( iter_par->ui_bytes );
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][count+1] = IntToStr( 0 );
- count++;
- }
- for( int j=0; j<BT_HCI_VALUE_SIZE; j++ )
- {
- parameter.s_value.uc_value[j] = 0;
- }
- parameter.s_value.uc_nz_byte = 0;
- m_pvReceiveHCIPar->push_back( parameter );
- }
- sgReceiveHCI->RowCount = count+1;
- }
- break;
- }
- }
- }
- }
- else // group
- {
- if( draw_mask & DRAW_MASK_HCI_GROUP )
- {
- // display group
- cbHCIGroup->Clear();
- for( iter_group = m_pvHCIGroup->begin(); iter_group != m_pvHCIGroup->end(); iter_group++ )
- {
- group = *iter_group;
- cbHCIGroup->Items->Add( group.as_group_name );
- }
- iter_group = m_pvHCIGroup->begin();
- cbHCIGroup->ItemIndex = category_group_idx;
- }
- // display command
- if( draw_mask & DRAW_MASK_HCI_COMMAND )
- {
- for( iter_group = m_pvHCIGroup->begin(); iter_group != m_pvHCIGroup->end(); iter_group++ )
- {
- group = *iter_group;
- if( group.as_group_name.AnsiCompareIC(cbHCIGroup->Text) == 0 )
- {
- break;
- }
- }
- cbHCICommand->Clear();
- for( iter_cmd = iter_group->v_cmd.begin(); iter_cmd != iter_group->v_cmd.end(); iter_cmd++ )
- {
- command = *iter_cmd;
- cbHCICommand->Items->Add( command.as_cmd_name );
- }
- cbHCICommand->ItemIndex = cmd_idx;
- }
- // display parameter
- if( draw_mask & DRAW_MASK_HCI_PARAMETER )
- {
- // sgSendHCI->EditorMode = true;
- for( iter_cmd = iter_group->v_cmd.begin(); iter_cmd != iter_group->v_cmd.end(); iter_cmd++ )
- {
- command = *iter_cmd;
- if( command.as_cmd_name.AnsiCompareIC(cbHCICommand->Text) == 0 )
- {
- if( ! m_pvSendHCIPar->empty() )
- {
- m_pvSendHCIPar->erase( m_pvSendHCIPar->begin(), m_pvSendHCIPar->end() );
- }
- if( ! m_pvReceiveHCIPar->empty() )
- {
- m_pvReceiveHCIPar->erase( m_pvReceiveHCIPar->begin(), m_pvReceiveHCIPar->end() );
- }
- char str[20];
- sprintf( str, "%X", iter_cmd->us_opcode );
- stHCIOpcode->Caption = str;
- sprintf( str, "%X", iter_cmd->uc_last_event );
- stHCILastEvent->Caption = str;
- edtHCITimeout->Text = iter_cmd->ui_ms_timeout;
- // send parameter
- if( 0 == iter_cmd->ui_send_num )
- {
- sgSendHCI->FixedCols = 3;
- sgSendHCI->FixedRows = 1;
- sgSendHCI->ColCount = 4;
- sgSendHCI->RowCount = 2;
- sgSendHCI->Cells[HCI_NAME_COL_IDX][1] = "";
- sgSendHCI->Cells[HCI_BYTE_COL_IDX][1] = "";
- sgSendHCI->Cells[2][1] = "";
- }
- else
- {
- sgSendHCI->FixedCols = 2;
- sgSendHCI->FixedRows = 1;
- sgSendHCI->ColCount = 4;
- sgSendHCI->RowCount = iter_cmd->ui_send_num+1;
- for (unsigned int i=0; i<iter_cmd->ui_send_num; i++)
- {
- iter_par = iter_cmd->v_send_par.begin() + i;
- parameter = *iter_par;
- sgSendHCI->Cells[HCI_NAME_COL_IDX][i+1] = iter_par->as_name;
- sgSendHCI->Cells[HCI_BYTE_COL_IDX][i+1] = IntToStr( iter_par->ui_bytes );
- AnsiString as_value;
- if( rbHCIDec->Checked )
- {
- BTHCIValue_To_AnsiString( iter_par->s_value, as_value );
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][i+1] = as_value;
- }
- else
- {
- BTHCIValue_To_Hex_AnsiString( iter_par->s_value, as_value );
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][i+1] = as_value;
- }
- // for( int j=0; j<BT_HCI_VALUE_SIZE; j++ )
- // {
- //// parameter.s_value.uc_value[j] = 0;
- // }
- // parameter.s_value.uc_nz_byte = 0;
- m_pvSendHCIPar->push_back( parameter );
- }
- }
- // receive parameter
- if( 0 == iter_cmd->ui_receive_num )
- {
- sgReceiveHCI->FixedCols = 3;
- sgReceiveHCI->FixedRows = 1;
- sgReceiveHCI->ColCount = 4;
- sgReceiveHCI->RowCount = 2;
- sgReceiveHCI->Cells[HCI_NAME_COL_IDX][1] = "";
- sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][1] = "";
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][1] = "";
- }
- else
- {
- sgReceiveHCI->FixedCols = 2;
- sgReceiveHCI->FixedRows = 1;
- sgReceiveHCI->ColCount = 4;
- // sgReceiveHCI->RowCount = iter_cmd->ui_receive_num+1;
- int count = 0;
- for (unsigned int i=0; i<iter_cmd->ui_receive_num; i++)
- {
- iter_par = iter_cmd->v_receive_par.begin() + i;
- parameter = *iter_par;
- if( iter_par->b_show )
- {
- sgReceiveHCI->Cells[HCI_NAME_COL_IDX][count+1] = iter_par->as_name;
- sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][count+1] = IntToStr( iter_par->ui_bytes );
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][count+1] = IntToStr( 0 );
- count++;
- }
- for( int j=0; j<BT_HCI_VALUE_SIZE; j++ )
- {
- parameter.s_value.uc_value[j] = 0;
- }
- parameter.s_value.uc_nz_byte = 0;
- m_pvReceiveHCIPar->push_back( parameter );
- }
- sgReceiveHCI->RowCount = count+1;
- }
- break;
- }
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayHCIFile( void )
- {
- AnsiString as_HCI_file = read_HCI_File("MF_setup.txt", Application->ExeName);
- ReadHCIFile( as_HCI_file );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::SaveHCIFile( void )
- {
- if( stHCIFile->Caption.AnsiCompareIC("") != 0 )
- { write_HCI_File( "MF_setup.txt", Application->ExeName, stHCIFile->Caption );
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ReadHCIFile( AnsiString asFileName )
- {
- if( ! CheckFileExist(asFileName) )
- {
- return;
- }
- m_sBTHCI.hPostMsgDestHandle = this->Handle;
- m_sBTHCI.filename = asFileName;
- m_sBTHCI.log = m_pHCILog;
- // m_BT_HCI_Obj.ConfirmCallback = ::ConfirmCallback_SetupHCIFile;
- // m_BT_HCI_Obj.REQ_Read_From_File_Start( m_sBTHCI );
- bool ok = m_BT_HCI_Obj.REQ_Read_Last_HCI_File_Start( m_sBTHCI );
- if( ok )
- {
- stHCIFile->Caption = m_sBTHCI.filename;
- if( rbHCICategory->Checked )
- {
- m_pvHCICategory = m_BT_HCI_Obj.Get_HciCategoryVector();
- DisplayHCIUI( DRAW_MASK_HCI_CATEGORY | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- else
- {
- m_pvHCIGroup = m_BT_HCI_Obj.Get_HciGroupVector();
- DisplayHCIUI( DRAW_MASK_HCI_GROUP | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Setup HCI file successfully";
- }
- }
- //--------------------------------------------------------------------------
- bool TfrmBT::ComposeHCICommand( S_BT_HCI &hci )
- {
- S_BT_HCI_VALUE s_value;
- //unsigned char parameter_len=0;
- int row, byte_idx, str_idx;
- int value;
- // char value_str[256];
- int byte_num;
- int hci_cmd_max_len;
- hci_cmd_max_len = sizeof(hci.s_hci_cmd.m_cmd)/sizeof(hci.s_hci_cmd.m_cmd[0]);
- for( int i=0; i<hci_cmd_max_len; i++ )
- hci.s_hci_cmd.m_cmd[i] = ' ';
- // opcode
- if( ! IsValidHexBTHCIOpcode( stHCIOpcode->Caption, hci.s_hci_cmd.m_opcode ) )
- return false;
- // last event index
- if( ! IsValidHexBTHCIEventIndex( stHCILastEvent->Caption, hci.uc_last_event ) )
- return false;
- // hci.s_hci_cmd.m_cmd[0] = hci.s_hci_cmd.m_opcode & 0x00FF ;
- // hci.s_hci_cmd.m_cmd[1] = (hci.s_hci_cmd.m_opcode & 0xFF00)>>8 ;
- // parameter length
- // for( row=1; row<sgSendHCI->RowCount; row++ )
- // {
- // parameter_len += sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt();
- // }
- // hci.s_hci_cmd.m_cmd[2] = parameter_len;
- // parameter
- hci.s_hci_cmd.m_len = 0;
- for( row=1; row<sgSendHCI->RowCount; row++ )
- {
- if( sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].AnsiCompareIC("") == 0 )
- return true;
- byte_num = sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt();
- if( rbHCIHex->Checked )
- {
- AnsiString_Hex_To_BTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], s_value );
- //itoa( value, value_str, 10 );
- }
- else
- {
- AnsiString_To_BTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], s_value );
- }
- // for( str_idx=0; str_idx<hci_cmd_max_len; str_idx++ )
- // {
- // if( 0 == value_str[str_idx] )
- // {
- // value_str_len = str_idx;
- // break;
- // }
- // }
- for( byte_idx=0; byte_idx<byte_num; byte_idx++ )
- {
- if( byte_idx < s_value.uc_nz_byte )
- {
- hci.s_hci_cmd.m_cmd[hci.s_hci_cmd.m_len] = s_value.uc_value[byte_idx];
- }
- else
- { hci.s_hci_cmd.m_cmd[hci.s_hci_cmd.m_len] = 0;
- }
- hci.s_hci_cmd.m_len++;
- }
- }
- return true;
- }
- //--------------------------------------------------------------------------
- bool TfrmBT::DeComposeHCIEvent( BT_HCI_EVENT &event )
- {
- if( sgReceiveHCI->Cells[HCI_NAME_COL_IDX][1].AnsiCompareIC("") == 0 ) // no event parameter
- return true;
- static vector<S_BT_HCI_CATEGORY>:: iterator iter_category;
- static vector<S_BT_HCI_GROUP>:: iterator iter_group;
- vector<S_BT_HCI_COMMAND>:: iterator iter_cmd;
- vector<S_BT_HCI_PARAMETER>:: iterator iter_par;
- S_BT_HCI_PARAMETER sParameter;
- // int row;
- // vector<S_BT_HCI_PARAMETER>:: iterator iter_par;
- int idx = 0;
- if( ! m_pvReceiveHCIPar->empty() )
- {
- m_pvReceiveHCIPar->erase(m_pvReceiveHCIPar->begin(), m_pvReceiveHCIPar->end() );
- }
- // S_BT_HCI_CATEGORY category;
- // S_BT_HCI_GROUP group;
- // S_BT_HCI_COMMAND command;
- // S_BT_HCI_PARAMETER parameter;
- if( rbHCICategory->Checked )
- {
- for( iter_category = m_pvHCICategory->begin(); iter_category != m_pvHCICategory->end(); iter_category++ )
- {
- AnsiString as_category_name = iter_category->as_category_name.Trim();
- AnsiString as_text = cbHCICategory->Text.Trim();
- if( as_category_name.AnsiCompareIC(as_text) == 0 )
- break;
- }
- for( iter_cmd = iter_category->v_cmd.begin(); iter_cmd != iter_category->v_cmd.end(); iter_cmd++ )
- {
- AnsiString as_cmd_name = iter_cmd->as_cmd_name.Trim();
- AnsiString as_text = cbHCICommand->Text.Trim();
- if( as_cmd_name.AnsiCompareIC(as_text) == 0 )
- break;
- }
- for (unsigned int i=0; i<iter_cmd->ui_receive_num; i++ )
- {
- iter_par = iter_cmd->v_receive_par.begin() + i;
- sParameter = *iter_par;
- for( int i=0; i<BT_HCI_VALUE_SIZE; i++ )
- { sParameter.s_value.uc_value[i] = 0;
- }
- sParameter.s_value.uc_nz_byte = 0;
- for (unsigned int i=0; i<sParameter.ui_bytes; i++)
- {
- sParameter.s_value.uc_value[i] = (char) event.m_parms[idx];
- idx++;
- if( sParameter.s_value.uc_value[i] != 0 )
- sParameter.s_value.uc_nz_byte++;
- }
- m_pvReceiveHCIPar->push_back( sParameter );
- }
- }
- else
- {
- for( iter_group = m_pvHCIGroup->begin(); iter_group != m_pvHCIGroup->end(); iter_group++ )
- {
- AnsiString as_group_name = iter_group->as_group_name.Trim();
- AnsiString as_text = cbHCIGroup->Text.Trim();
- if( as_group_name.AnsiCompareIC(as_text) == 0 )
- break;
- }
- for( iter_cmd = iter_group->v_cmd.begin(); iter_cmd != iter_group->v_cmd.end(); iter_cmd++ )
- {
- AnsiString as_cmd_name = iter_cmd->as_cmd_name.Trim();
- AnsiString as_text = cbHCICommand->Text.Trim();
- if( as_cmd_name.AnsiCompareIC(as_text) == 0 )
- break;
- }
- for (unsigned int i=0; i<iter_cmd->ui_receive_num; i++ )
- {
- iter_par = iter_cmd->v_receive_par.begin() + i;
- sParameter = *iter_par;
- for( int i=0; i<BT_HCI_VALUE_SIZE; i++ )
- { sParameter.s_value.uc_value[i] = 0;
- }
- sParameter.s_value.uc_nz_byte = 0;
- for (unsigned int i=0; i<sParameter.ui_bytes; i++ )
- {
- sParameter.s_value.uc_value[i] = (char) event.m_parms[idx];
- idx++;
- if( sParameter.s_value.uc_value[i] != 0 )
- sParameter.s_value.uc_nz_byte++;
- }
- m_pvReceiveHCIPar->push_back( sParameter );
- }
- }
- #if 0
- for( row=1; row<sgReceiveHCI->RowCount; row++ )
- {
- sParameter.as_name = sgReceiveHCI->Cells[HCI_NAME_COL_IDX][row];
- sParameter.ui_bytes = sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt();
- for( int i=0; i<BT_HCI_VALUE_SIZE; i++ )
- { sParameter.s_value.uc_value[i] = 0;
- }
- sParameter.s_value.uc_nz_byte = 0;
- for( int i=0; i<sParameter.ui_bytes; i++ )
- {
- sParameter.s_value.uc_value[i] = (char) event.m_parms[HCI_EVENT_PARAMETER_START_IDX+idx];
- idx++;
- if( sParameter.s_value.uc_value[i] != 0 )
- sParameter.s_value.uc_nz_byte++;
- }
- m_pvReceiveHCIPar->push_back( sParameter );
- }
- #endif
- return true;
- }
- //--------------------------------------------------------------------------
- void TfrmBT::ReDrawHCIFields( E_DRAM_MASK_HCI draw_mask )
- {
- vector<S_BT_HCI_PARAMETER>:: iterator iter_par;
- if( draw_mask & DRAM_MASK_HCI_SEND )
- {
- for( int row=1; row<sgSendHCI->RowCount; row++ )
- {
- for( iter_par = m_pvSendHCIPar->begin(); iter_par != m_pvSendHCIPar->end(); iter_par++ )
- {
- AnsiString as_name = sgSendHCI->Cells[HCI_NAME_COL_IDX][row];
- if( iter_par->as_name.AnsiCompareIC( as_name ) == 0 )
- {
- AnsiString as_hci_value;
- if( rbHCIDec->Checked )
- {
- BTHCIValue_To_AnsiString( iter_par->s_value, as_hci_value );
- }
- else
- { BTHCIValue_To_Hex_AnsiString( iter_par->s_value, as_hci_value );
- }
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][row] = as_hci_value;
- break;
- }
- }
- }
- }
- if( draw_mask & DRAM_MASK_HCI_RECEIVE )
- {
- AnsiString ansi_str;
- // iter_par = m_sRxEvent.v_par.begin();
- for(int row=1; row<sgReceiveHCI->RowCount; row++ )
- {
- for( iter_par = m_pvReceiveHCIPar->begin(); iter_par != m_pvReceiveHCIPar->end(); iter_par++ )
- {
- AnsiString as_name = sgReceiveHCI->Cells[HCI_NAME_COL_IDX][row];
- if( iter_par->as_name.AnsiCompareIC( as_name ) == 0 )
- {
- AnsiString as_hci_value;
- if( rbHCIDec->Checked )
- {
- BTHCIValue_To_AnsiString( iter_par->s_value, as_hci_value );
- }
- else
- { BTHCIValue_To_Hex_AnsiString( iter_par->s_value, as_hci_value );
- }
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][row] = as_hci_value;
- break;
- }
- }
- // BTHCIValue_To_AnsiString( iter_par->s_value, ansi_str );
- // sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][row] = ansi_str;
- // iter_par++;
- }
- }
- }
- //--------------------------------------------------------------------------
- void TfrmBT::FillHCIResult( void )
- {
- for(int i=0; i<m_pHCILog->Count; i++ )
- {
- AnsiString as = m_pHCILog->Strings[i];
- memHCIResult->Lines->Add( as );
- }
- m_pHCILog->Clear();
- }
- //--------------------------------------------------------------------------
- void TfrmBT::FillRFResult( void )
- {
- for(int i=0; i<m_pRFLog->Count; i++ )
- {
- AnsiString as = m_pRFLog->Strings[i];
- memRFResult->Lines->Add( as );
- }
- m_pRFLog->Clear();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmBT::DisplayPKTBDAddress( E_BT_PACKET_DEVICE_T obj )
- {
- AnsiString as_bd_addr;
- if( BT_PACKET_TESTER == obj )
- {
- BDAddress_To_Hex_AnsiString( m_BT_PKT_Obj.Get_TesterBDAddress(), as_bd_addr );
- stPKTTesterBDAddr->Caption = as_bd_addr;
- }
- else
- {
- BDAddress_To_Hex_AnsiString( m_BT_PKT_Obj.Get_DUTBDAddress(), as_bd_addr );
- stPKTDUTBDAddr->Caption = as_bd_addr;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmBT::FillPKTResult( void )
- {
- for(int i=0; i<m_pPKTLog->Count; i++ )
- {
- AnsiString as = m_pPKTLog->Strings[i];
- memPKTResult->Lines->Add( as );
- }
- m_pPKTLog->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbHCIGroupChange(TObject *Sender)
- {
- DisplayHCIUI( DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, cbHCIGroup->ItemIndex, 0 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbHCICommandChange(TObject *Sender)
- {
- DisplayHCIUI( DRAW_MASK_HCI_PARAMETER, cbHCIGroup->ItemIndex, cbHCICommand->ItemIndex );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnHCISendClick(TObject *Sender)
- {
- if( ! CheckSendHCIValue() )
- {
- return;
- }
- m_sBTHCI.hPostMsgDestHandle = this->Handle;
- m_sBTHCI.filename = stHCIFile->Caption;
- m_sBTHCI.log = m_pHCILog;
- m_sBTHCI.ui_ms_timeout = edtHCITimeout->Text.ToInt();
- ComposeHCICommand( m_sBTHCI );
- CurrentPageLock();
- sbHCI->Panels->Items[0]->Text = (AnsiString) " Send HCI command progressing";
- m_BT_HCI_Obj.ConfirmCallback = ::ConfirmCallback_HCI;
- m_BT_HCI_Obj.REQ_Start( m_sBTHCI );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_HCI(void)
- {
- E_METAAPP_RESULT_T state = m_BT_HCI_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- m_sHCIEventFmt = m_BT_HCI_Obj.Get_HCIEvent();
- DeComposeHCIEvent(m_sHCIEventFmt);
- ReDrawHCIFields(DRAM_MASK_HCI_RECEIVE);
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Send HCI command successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Send HCI command fail";
- Application->MessageBox( "Execution Fail : Send HCI command", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop(false);
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Send HCI command timeout";
- Application->MessageBox( "Execution Timeout : Send HCI command", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Send HCI command stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //===========================================================================
- ///////////////////////////////// RF test /////////////////////////////////
- //===========================================================================
- void TfrmBT::ReDrawRFFields( E_DRAM_MASK_RF draw_mask )
- {
- if( draw_mask & DRAM_MASK_RF_BD_ADDRESS )
- {
- AnsiString as_bd_addr;
- BDAddress_To_Hex_Colon_AnsiString( m_sRFBdAddr, as_bd_addr );
- edtRFBDAddress->Text = as_bd_addr;
- }
- if( draw_mask & DRAM_MASK_RF_ACCESS_CODE )
- {
- char str[20];
- // access code
- for( int i=0; i<(sizeof(m_sBtRf.s_access_code.uc_access_code)/sizeof(m_sBtRf.s_access_code.uc_access_code[0])); i++ )
- {
- sprintf( str, "%X", m_sBtRf.s_access_code.uc_access_code[i] );
- m_edtRFTxAccessCode[i]->Text = str;
- }
- }
- if( draw_mask & DRAM_MASK_RF_TX_OTHERS )
- {
- edtRFTxSignleFreq->Text = IntToStr( m_sBtRf.uc_freq );
- edtRFTxDataLen->Text = IntToStr( m_sBtRf.us_data_len );
- edtRFTxPollPeriod->Text = IntToStr( m_sBtRf.uc_poll_period );
- edtRFTxLevel->Text = IntToStr( m_sBtRf.uc_pcl );
- }
- // if( draw_mask & DRAM_MASK_RF_RX )
- // {
- // edtRFRxSignleFreq->Text = IntToStr( m_sBtRf.uc_freq );
- // }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFTxSignleFreqCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~255 "
- };
- text = edit->Text;
- if( !IsValidBTFreq( text, uc_data ) )
- {
- edit->Text = 78;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBtRf.uc_freq = uc_data;
- }
- //-------------------------------------------------------------------------
- unsigned short TfrmBT::Get_RFTxDataDefaultLen(int index)
- {
- unsigned short us_default_len[] =
- {
- 0,// NULL
- 0,// POLL
- 0,// FHS
- 17,// DM1
- 27,// DH1
- 10,// HV1
- 20,// HV2
- 30,// HV3
- 19,// DV
- 10,// AUX
- 121,// DM3
- 183,// DH3
- 224,// DM5
- 339,// DH5
- 30,// EV3
- 120,// EV4
- 180,//EV5
- 54,// 2-DH1
- 60,// 2-EV3
- 367,// 2-DH3
- 360,// 2-EV5
- 679,// 2-DH5
- 90,// 3-EV3
- 83,// 3-DH1
- 552,// 3-DH3
- 540,// 3-EV5
- 1021 // 3-DH5
- };
- return us_default_len[index];
- }
- //--------------------------------------------------------------------------
- unsigned short TfrmBT::Get_RFTxDataMinLen( int index )
- {
- unsigned short us_min_len[] =
- {
- 0,// NULL
- 0,// POLL
- 0,// FHS
- 0,// DM1
- 0,// DH1
- 10,// HV1
- 20,// HV2
- 30,// HV3
- 10,// DV
- 0,// AUX
- 0,// DM3
- 0,// DH3
- 0,// DM5
- 0,// DH5
- 1,// EV3
- 1,// EV4
- 1,//EV5
- 0,// 2-DH1
- 1,// 2-EV3
- 0,// 2-DH3
- 1,// 2-EV5
- 0,// 2-DH5
- 1,// 3-EV3
- 0,// 3-DH1
- 0,// 3-DH3
- 1,// 3-EV5
- 0// 3-DH5
- };
- return us_min_len[index];
- }
- //--------------------------------------------------------------------------
- unsigned short TfrmBT::Get_RFTxDataMaxLen( int index )
- {
- unsigned short us_max_len[] =
- {
- 0,// NULL
- 0,// POLL
- 0,// FHS
- 17,// DM1
- 27,// DH1
- 10,// HV1
- 20,// HV2
- 30,// HV3
- 19,// DV
- 255,// AUX
- 121,// DM3
- 183,// DH3
- 224,// DM5
- 339,// DH5
- 30,// EV3
- 120,// EV4
- 180,//EV5
- 54,// 2-DH1
- 60,// 2-EV3
- 367,// 2-DH3
- 360,// 2-EV5
- 679,// 2-DH5
- 90,// 3-EV3
- 83,// 3-DH1
- 552,// 3-DH3
- 540,// 3-EV5
- 1021 // 3-DH5
- };
- return us_max_len[index];
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayRFDefaultDataLen( void )
- {
- unsigned short len = Get_RFTxDataDefaultLen(cbRFTxType->ItemIndex);
- edtRFTxDataLen->Text = IntToStr( len );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFTxDataLenCheck(TObject *Sender)
- {
- unsigned short us_min_len = Get_RFTxDataMinLen(cbRFTxType->ItemIndex);
- unsigned short us_max_len = Get_RFTxDataMaxLen(cbRFTxType->ItemIndex);
- unsigned short us_data;
- AnsiString text;
- AnsiString as_hint;
- TEdit *edit = (TEdit*)Sender;
- if( us_min_len != us_max_len )
- {
- as_hint = " value should be " + IntToStr( us_min_len ) +"~" + IntToStr( us_max_len );
- }
- else
- { as_hint = " value should be " + IntToStr( us_min_len );
- }
- text = edit->Text;
- if( !IsValidBTTxDataLength( text, us_data, Get_RFTxDataMinLen(cbRFTxType->ItemIndex), Get_RFTxDataMaxLen(cbRFTxType->ItemIndex) ) )
- {
- edit->Text = Get_RFTxDataDefaultLen(cbRFTxType->ItemIndex);
- ShowHintLabel( edit, as_hint.c_str() );
- edit->SetFocus();
- return;
- }
- m_sBtRf.us_data_len = us_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFTxPollPeriodCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~255 "
- };
- text = edit->Text;
- if( !IsValidBTTxPollPeriod( text, uc_data ) )
- {
- edit->Text = 0;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBtRf.uc_poll_period = uc_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFTxLevelCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 1~7 "
- };
- text = edit->Text;
- if( !IsValidBTTxPcl( text, uc_data ) )
- {
- edit->Text = 7;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBtRf.uc_pcl = uc_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFTxAccessCodeCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~255 "
- };
- text = edit->Text;
- if( !IsValidHexBTTxAccessCode( text, uc_data ) )
- {
- edit->Text = 0;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBtRf.s_access_code.uc_access_code[edit->Tag] = uc_data;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFTxStartClick(TObject *Sender)
- {
- if( rbRFTx->Checked )
- {
- if( ! CheckRFFields( CHECK_MASK_RF_TX ) )
- {
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF TX fail";
- Application->MessageBox( "Execution Failure : BT RF TX", "FAILURE", MB_OK );
- return;
- }
- }
- else
- {
- if( ! CheckRFFields( CHECK_MASK_RF_RX ) )
- {
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF RX fail";
- Application->MessageBox( "Execution Failure : BT RF RX", "FAILURE", MB_OK );
- return;
- }
- }
- m_sBtRf.hPostMsgDestHandle = this->Handle;
- m_sBtRf.log = m_pRFLog;
- m_sBtRf.e_test_type = BT_TX;
- CurrentPageLock();
- if( rbRFTx->Checked )
- {
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF TX progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_RFTX;
- }
- else
- {
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF RX progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_RFRX;
- }
- m_BT_RF_Obj.REQ_Start( m_sBtRf );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_RFTX(void)
- {
- E_METAAPP_RESULT_T state = m_BT_RF_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX fail";
- Application->MessageBox( "Execution Failure : BT RF TX", "FAILURE", MB_OK );
- Application->BringToFront();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( true );
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX timeout";
- Application->MessageBox( "Execution Timeout : BT RF TX", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmBT::SyncLAPAndAccessCode( void )
- {
- unsigned int syncHi;
- unsigned int syncLo;
- unsigned int a_lap = 0;
- char lap_string[9];
- unsigned char hex_string[3];
- char sync_string[16];
- // transform LAP string to 32bit value
- //GetDlgItemText(IDC_LAP, lap_string, 9);
- AnsiString as_lap;
- for( int i=BD_ADDRESS_LAP_LEN-1; i>=0; i-- )
- { as_lap += m_edtRFLAP[i]->Text;
- }
- AnsiString_Hex_To_UnsignedInt( as_lap, a_lap );
- // for(int i = 0; i < 6; i++)
- // lap_string[i] = lap_string[i+2];
- // ascii_hex_string_2_hex_string((unsigned char *)lap_string, hex_string, 6);
- // a_lap = hex_string[0] << 16;
- /// a_lap |= hex_string[1] << 8;
- //a_lap |= hex_string[2];
- // 32 bit LAP --> 64 bit Access Word
- Build_Sync_Word(a_lap, &syncHi, &syncLo);
- // print 64 bit Access Word
- sprintf(sync_string, "%08X%08X", syncHi, syncLo);
- // SetDlgItemText(IDC_SYNC, sync_string);
- m_sBtRf.s_access_code.uc_access_code[7] = (syncHi>>24) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[6] = (syncHi>>16) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[5] = (syncHi>>8 ) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[4] = (syncHi ) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[3] = (syncLo>>24) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[2] = (syncLo>>16) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[1] = (syncLo>>8 ) & 0x000000FF;
- m_sBtRf.s_access_code.uc_access_code[0] = (syncLo ) & 0x000000FF;
- }
- //--------------------------------------------------------------------------
- // 32 bit LAP --> 64 bit Access Word
- void TfrmBT::Build_Sync_Word(const unsigned int a_lap, unsigned int* pSyncHi, unsigned int* pSyncLo)
- {
- unsigned int BCHgeneratorHi = 026053423665L;
- unsigned int BCHgeneratorLo = (1L << 29);
- const unsigned int p_PNsequenceHi = 0x83848D96L;
- const unsigned int p_PNsequenceLo = 0xBBCC54FCL;
- const unsigned int B_BitsA23_0 = 0x2C000000U;
- const unsigned int B_BitsA23_1 = 0x13000000U;
- unsigned int x_infoBits;
- unsigned int x_encodeBits;
- unsigned int regHi, regLo;
- unsigned int count;
- #define BIT23 0x00800000L
- #define BIT31 0x80000000UL
- /* V0.8 p126 */
- /* Step 1 Format the 30 information bits to encode LAP + Barker Sequence */
- /* x(D) = a(D) +D^24 B_A23(D) */
- if (a_lap&BIT23) /* Toggle bits 5:0 */
- x_infoBits = a_lap | B_BitsA23_1;
- else
- x_infoBits = a_lap | B_BitsA23_0;
- /* Step 2 Add (Exor) the information covering part of the PN sequence */
- /* x~(D) = x(D) + p34 + p35D + ... + p63D^29 */
- x_encodeBits = (x_infoBits ^ (p_PNsequenceHi>>2)) << 2;
- /* Step 3 Generate parity bits of BCH(64,30) */
- /* c~(D) = D^34 x~(D) mod g(D) */
- /* Initialise */
- regHi = x_encodeBits;
- regLo = 0;
- /* Generate remainder 64 bit dividend, 35 bit divisor */
- count = 0;
- while (++count <= 64 - 35 + 1) /* Reduce/Shift the remaining 30 bits*/
- {
- if (regHi&BIT31) /* Reduce */
- {
- regHi ^= BCHgeneratorHi;
- regLo ^= BCHgeneratorLo;
- }
- regHi = (regHi<<1) + (regLo>>31);/*Shift full register */
- regLo <<= 1;
- }
- /* Step 4 Create the BCH codeword */
- /* s~(D) = D^34 x~(D) + c~(D) Note: Exor Addition */
- /* Step 5 Add the PN Sequence */
- /* s(D) = s(D) + p(D) Note: Exor Addition */
- *pSyncLo = ((regHi<<2) ^ (regLo>>30)) ^ p_PNsequenceLo;
- *pSyncHi = ((regHi>>30) ^ (x_encodeBits)) ^ p_PNsequenceHi;
- /* Hardware ? */
- /* Step 6 Prepend and append the (DC-free preamble and trailer */
- /* y(D = F_c0(D) + D^4 s(D) + D^68 F_a23(D) */
- }
- //---------------------------------------------------------------------------
- //void __fastcall TfrmBT::edtRFTxLapCheck(TObject *Sender)
- //{
- // unsigned int ui_data;
- // AnsiString text;
- // TEdit *edit = (TEdit*)Sender;
- // char hint[] =
- // { " value should be 0~4294967296 "
- // };
- //
- // text = edit->Text;
- // if( !IsValidHexBTLAP( text, ui_data ) )
- // {
- // edit->Text = 0;
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- //
- // m_sBtRf.ui_lap = ui_data;
- // SyncLAPAndAccessCode();
- // ReDrawRFFields( DRAM_MASK_RF_ACCESS_CODE );
- //}
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFRxStartClick(TObject *Sender)
- {
- if( ! CheckRFFields( CHECK_MASK_RF_RX ) )
- {
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF RX fail";
- Application->MessageBox( "Execution Failure : BT RF RX", "FAILURE", MB_OK );
- return;
- }
- m_sBtRf.hPostMsgDestHandle = this->Handle;
- m_sBtRf.log = m_pRFLog;
- m_sBtRf.e_test_type = BT_RX;
- CurrentPageLock();
- sbRF->Panels->Items[0]->Text = (AnsiString) " BT RF RX progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_RFRX;
- m_BT_RF_Obj.REQ_Start( m_sBtRf );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_RFRX(void)
- {
- E_METAAPP_RESULT_T state = m_BT_RF_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX fail";
- Application->MessageBox( "Execution Failure : BT RF TX", "FAILURE", MB_OK );
- Application->BringToFront();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( true );
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX timeout";
- Application->MessageBox( "Execution Timeout : BT RF TX", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" BT RF TX stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmBT::rbHCICategoryClick(TObject *Sender)
- {
- cbHCICategory->Enabled = true;
- cbHCIGroup->Enabled = false;
- m_pvHCICategory = m_BT_HCI_Obj.Get_HciCategoryVector();
- DisplayHCIUI( DRAW_MASK_HCI_CATEGORY | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::rbHCIGroupClick(TObject *Sender)
- {
- cbHCICategory->Enabled = false;
- cbHCIGroup->Enabled = true;
- m_pvHCIGroup = m_BT_HCI_Obj.Get_HciGroupVector();
- DisplayHCIUI( DRAW_MASK_HCI_GROUP | DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, 0, 0 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::FormShow(TObject *Sender)
- {
- if (m_bFirstFormShow)
- {
- m_bFirstFormShow = false;
- m_META_HANDLE_Obj.REQ_AllocateSecondHandle_Start();
- unsigned short ComPortCount = MAX_SUPPORT_COM_NUM;
- int result = ComPortEnumerate( m_usComPortArray, &ComPortCount );
- if (result)
- {
- Application->MessageBox("Enumerate COM port fail", "FAIL", MB_OK);
- return;
- }
- for (int i=0; i<ComPortCount; i++)
- {
- cbPKTCOM->Items->Add((AnsiString) "COM" + IntToStr( m_usComPortArray[i]));
- m_cbMTBT2COM->Items->Add((AnsiString) "COM" + IntToStr( m_usComPortArray[i]));
- }
- cbPKTCOM->ItemIndex = 0;
- m_cbMTBT2COM->ItemIndex = 0;
- // string grid
- sgSendHCI->Cells[HCI_NAME_COL_IDX][0] = "Send Parameter";
- sgSendHCI->Cells[HCI_BYTE_COL_IDX][0] = "Bytes";
- if( rbHCIDec->Checked )
- {
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value";
- }
- else
- {
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value (Hex)";
- }
- sgReceiveHCI->Cells[HCI_NAME_COL_IDX][0] = "Receive Parameter";
- sgReceiveHCI->Cells[HCI_BYTE_COL_IDX][0] = "Bytes";
- if( rbHCIDec->Checked )
- {
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value";
- }
- else
- {
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value (Hex)";
- }
- // HCI file
- DisplayHCIFile();
- // RF
- DisplayRFDefaultDataLen();
- // module test
- ReloadScriptFiles();
- UpdateProcessGroup();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::glbTimerTimer(TObject *Sender)
- {
- glbTimer->Enabled = false;
- glbTimer->Interval = 1000;
- glbTimer->Enabled = true;
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnPKTConnectDUTClick(TObject *Sender)
- {
- shpPKTConnect->Brush->Color = clRed;
- m_sCWT.i_meta_handle = m_META_HANDLE_Obj.Get_SecondHandle();
- SetMetaConnectReq(m_sCWT.META_connect_req);
- m_sCWT.neSuccess = on_PKTConnectWithTarget_Success;
- m_sCWT.neByUser = on_PKTConnectWithTarget_ByUser;
- AbortConnectWithTarget();
- m_pT_CWT = new T_META_ConnectWithTarget(true, &m_sCWT);
- if (NULL != m_pT_CWT)
- {
- m_pT_CWT->FreeOnTerminate = true;
- m_pT_CWT->OnTerminate = on_PKTConnectWithTarget_Fail;
- m_pT_CWT->Priority = tpHighest;
- }
- else
- {
- m_pPKTLog->Add( DateToStr(Date()) + " " + TimeToStr(Time()) +
- " FAIL: connect with target"
- );
- PostMessage(
- this->Handle,
- WM_ML_BT_PRINT_MSG,
- 0,
- 0
- );
- return;
- }
- if( NULL != m_pT_CWT )
- {
- m_pT_CWT->Resume();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_PKTConnectWithTarget_Success(TObject *Sender)
- {
- if (PAGEIDX_BT_PKT == m_pctlToolSel->ActivePageIndex)
- {
- shpPKTConnect->Brush->Color = clYellow;
- }
- else
- {
- m_shpMTConnect->Brush->Color = clYellow;
- }
- m_bConnectTargetok = true;
- CBTPOWER BT_POWER_Obj;
- BT_POWER_Obj.REQ_Power_On_Second_BT_Start();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_PKTConnectWithTarget_Fail(TObject *Sender)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_PKTConnectWithTarget_ByUser(TObject *Sender)
- {
- }
- //---------------------------------------------------------------------------
- void TfrmBT::SetMetaConnectReq(META_Connect_Req &META_connect_req)
- {
- AnsiString as_BootTimeout, as_METAConnectTimeout;
- int com_index;
- int baudrate_index;
- if (PAGEIDX_BT_PKT == m_pctlToolSel->ActivePageIndex)
- {
- com_index = cbPKTCOM->ItemIndex;
- baudrate_index = cbPKTBaudRate->ItemIndex;
- }
- else
- {
- com_index = m_cbMTBT2COM->ItemIndex;
- baudrate_index = m_cbMTBT2Baud->ItemIndex;
- }
- as_BootTimeout = read_Boot_timeout("MF_setup.txt", Application->ExeName);
- if (as_BootTimeout.AnsiCompareIC("infinite") == 0)
- {
- META_connect_req.boot_meta_arg.m_ms_boot_timeout = BOOT_INFINITE;
- }
- else
- {
- META_connect_req.boot_meta_arg.m_ms_boot_timeout = as_BootTimeout.ToInt();
- }
- META_connect_req.com_port = m_usComPortArray[com_index];
- META_connect_req.boot_meta_arg.m_bbchip_type = frmMainSel->Get_CurBBChipType();
- META_connect_req.boot_meta_arg.m_ext_clock = frmMainSel->Get_CurExternalClockType();
- switch ((E_BAUD_RATE_INDEX) baudrate_index)
- {
- case BAUD_RATE_AUTO_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD57600;
- META_connect_req.baudrate[1] = META_BAUD115200;
- META_connect_req.baudrate[2] = META_BAUD230400;
- META_connect_req.baudrate[3] = META_BAUD460800;
- META_connect_req.baudrate[4] = META_BAUD921600;
- META_connect_req.baudrate[5] = META_BAUD_END;
- }
- break;
- case BAUD_RATE_57600_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD57600;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- case BAUD_RATE_115200_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD115200;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- case BAUD_RATE_230400_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD230400;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- case BAUD_RATE_460800_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD460800;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- case BAUD_RATE_921600_INDEX:
- {
- META_connect_req.baudrate[0] = META_BAUD921600;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- default: // set baud rate = AUTO
- {
- META_connect_req.baudrate[0] = META_BAUD115200;
- META_connect_req.baudrate[1] = META_BAUD_END;
- }
- break;
- }
- META_connect_req.flowctrl = META_SW_FLOWCTRL;
- as_METAConnectTimeout = read_META_Connect_timeout("MF_setup.txt", Application->ExeName);
- META_connect_req.ms_connect_timeout = as_METAConnectTimeout.ToInt();
- META_connect_req.boot_meta_arg.m_cb_in_brom_stage = NULL;
- META_connect_req.boot_meta_arg.m_cb_in_brom_stage_arg = NULL;
- // security
- META_connect_req.boot_meta_arg.m_speedup_brom_baudrate = _TRUE; //115200
- META_connect_req.boot_meta_arg.m_ready_power_on_wnd_handle = NULL;
- META_connect_req.boot_meta_arg.m_ready_power_on_wparam = NULL;
- META_connect_req.boot_meta_arg.m_ready_power_on_lparam = NULL;
- META_connect_req.boot_meta_arg.m_auth_handle = frmMainSel->Get_SLA_Object()->Get_AuthHandle();
- META_connect_req.boot_meta_arg.m_cb_sla_challenge = SLA_Challenge;
- META_connect_req.boot_meta_arg.m_cb_sla_challenge_arg = NULL;
- META_connect_req.boot_meta_arg.m_cb_sla_challenge_end = SLA_Challenge_END;
- META_connect_req.boot_meta_arg.m_cb_sla_challenge_end_arg = NULL;
- // EDGE PC card
- // META_connect_req.boot_meta_arg.m_cb_com_init_stage = ::cb_PowerOnOxford;
- // META_connect_req.boot_meta_arg.m_cb_com_init_stage_arg = NULL;
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ReDrawPKTFields(E_DRAM_MASK_PKT draw_mask)
- {
- if (draw_mask & DRAM_MASK_PKT_MONITOR)
- {
- int count;
- if (BTMODULE_MT6611 != m_cBtId)
- {
- count = BT_PACKET_IDX_NONEDR_COUNT;
- }
- else
- {
- count = BT_PACKET_IDX_COUNT;
- }
- for (int i=0; i<count; i++)
- {
- if (m_cbPKTType[i]->Checked)
- {
- m_edtPKTTesterTXCount[i]->Text = IntToStr( m_sBTMonCnf.s_tester_monitor.ui_tx_pkt_count[i] );
- m_edtPKTTesterRXCount[i]->Text = IntToStr( m_sBTMonCnf.s_tester_monitor.ui_rx_pkt_count[i] );
- m_edtPKTDUTTXCount[i]->Text = IntToStr( m_sBTMonCnf.s_dut_monitor.ui_tx_pkt_count[i] );
- m_edtPKTDUTRXCount[i]->Text = IntToStr( m_sBTMonCnf.s_dut_monitor.ui_rx_pkt_count[i] );
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::IsPKTTestFinish( E_BT_PACKET_IDX idx )
- { return m_sPKTStatus.b_finish[idx];
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::IsAllPKTTestFinish( void )
- {
- for( int i=0; i<BT_PACKET_IDX_COUNT; i++ )
- {
- if( m_cbPKTType[i]->Checked )
- {
- if( ! m_sPKTStatus.b_finish[i] )
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool TfrmBT::SetPKTFinish(E_BT_PACKET_IDX idx)
- {
- if (idx >= BT_PACKET_IDX_COUNT)
- {
- return false;
- }
- unsigned int ui_tester_tx = m_edtPKTTesterTXCount[idx]->Text.ToInt();
- unsigned int ui_tester_rx = m_edtPKTTesterRXCount[idx]->Text.ToInt();
- unsigned int ui_dut_tx = m_edtPKTDUTTXCount[idx]->Text.ToInt();
- unsigned int ui_dut_rx = m_edtPKTDUTRXCount[idx]->Text.ToInt();
- unsigned int ui_pkt_count = m_edtPKTPktCount[idx]->Text.ToInt();
- if( (ui_tester_tx == m_uiPKTLastTesterTx) ||
- (ui_tester_rx == m_uiPKTLastTesterRx) ||
- (ui_dut_tx == m_uiPKTLastDutTx) ||
- (ui_dut_rx == m_uiPKTLastDutRx)
- )
- {
- m_uiPKTCount++;
- }
- else
- { m_uiPKTCount = 0;
- }
- if( (ui_tester_tx >= ui_pkt_count ) &&
- ( ui_tester_rx >= ui_pkt_count ) &&
- ( ui_dut_tx >= ui_pkt_count ) &&
- ( ui_dut_rx >= ui_pkt_count ) ||
- ( m_uiPKTCount > 3 )
- )
- { m_sPKTStatus.b_finish[idx] = true;
- m_uiPKTLastTesterTx = 0;
- m_uiPKTLastTesterRx = 0;
- m_uiPKTLastDutTx = 0;
- m_uiPKTLastDutRx = 0;
- m_uiPKTCount = 0;
- }
- else
- {
- m_sPKTStatus.b_finish[idx] = false;
- m_uiPKTLastTesterTx = ui_tester_tx;
- m_uiPKTLastTesterRx = ui_tester_rx;
- m_uiPKTLastDutTx = ui_dut_tx;
- m_uiPKTLastDutRx = ui_dut_rx;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::IsPKTTestRunning( E_BT_PACKET_IDX idx )
- {
- if( PKT_STATE_IDLE == m_sPKTStatus.e_state[idx] )
- return false;
- else
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::CheckPKTFields( E_CHECK_MASK_PKT mark )
- {
- #if 0
- AnsiString_To_Hex_BDAddress( stTesterBDAddr->Caption, m_sBTPKT.s_tester_bd_addr );
- AnsiString_To_Hex_BDAddress( stDUTBDAddr->Caption, m_sBTPKT.s_dut_bd_addr );
- if( cbPKTDM1->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DM1) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DM1;
- //m_sBTPKT.e_p2 = BT_ACL_P2_DM1;
- //m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- //m_sBTPKT.e_idx = BT_PACKET_IDX_DM1;
- }
- else if( cbPKTDH1->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DH1) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DH1;
- // m_sBTPKT.e_p2 = BT_ACL_P2_DH1;
- // m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- m_sBTPKT.e_idx = BT_PACKET_IDX_DH1;
- }
- else if( cbPKTDM3->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DM3) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DM3;
- //m_sBTPKT.e_p2 = BT_ACL_P2_DM3;
- //m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- m_sBTPKT.e_idx = BT_PACKET_IDX_DM3;
- }
- else if( cbPKTDH3->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DH3) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DH3;
- //m_sBTPKT.e_p2 = BT_ACL_P2_DH3;
- //m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- m_sBTPKT.e_idx = BT_PACKET_IDX_DH3;
- }
- else if( cbPKTDM5->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DM5) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DM5;
- // m_sBTPKT.e_p2 = BT_ACL_P2_DM5;
- // m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- m_sBTPKT.e_idx = BT_PACKET_IDX_DM5;
- }
- else if( cbPKTDH5->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_DH5) ) )
- {
- //m_sBTPKT.e_p1 = BT_ACL_P1_DH5;
- //m_sBTPKT.e_p2 = BT_ACL_P2_DH5;
- //m_sBTPKT.e_sco = BT_SCO_UNKNOWN;
- m_sBTPKT.e_idx = BT_PACKET_IDX_DH5;
- }
- else if( cbPKTHV1->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_HV1) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_HV1;
- m_sBTPKT.e_p2 = BT_ACL_P2_HV1;
- m_sBTPKT.e_sco = BT_SCO_HV1;
- m_sBTPKT.e_idx = BT_PACKET_IDX_HV1;
- }
- else if( cbPKTHV2->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_HV2) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_HV2;
- m_sBTPKT.e_p2 = BT_ACL_P2_HV2;
- m_sBTPKT.e_sco = BT_SCO_HV2;
- m_sBTPKT.e_idx = BT_PACKET_IDX_HV2;
- }
- else if( cbPKTHV3->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_HV3) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_HV3;
- m_sBTPKT.e_p2 = BT_ACL_P2_HV3;
- m_sBTPKT.e_sco = BT_SCO_HV3;
- m_sBTPKT.e_idx = BT_PACKET_IDX_HV3;
- }
- else if( cbPKTEV3->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_EV3) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_EV3;
- m_sBTPKT.e_p2 = BT_ACL_P2_EV3;
- m_sBTPKT.e_sco = BT_SCO_EV3;
- m_sBTPKT.e_idx = BT_PACKET_IDX_EV3;
- }
- else if( cbPKTEV4->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_EV4) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_EV4;
- m_sBTPKT.e_p2 = BT_ACL_P2_EV4;
- m_sBTPKT.e_sco = BT_SCO_EV4;
- m_sBTPKT.e_idx = BT_PACKET_IDX_EV4;
- }
- else if( cbPKTEV5->Checked && (! IsPKTTestFinish(BT_PACKET_IDX_EV5) ) )
- {
- m_sBTPKT.e_p1 = BT_ACL_P1_EV5;
- m_sBTPKT.e_p2 = BT_ACL_P2_EV5;
- m_sBTPKT.e_sco = BT_SCO_EV5;
- m_sBTPKT.e_idx = BT_PACKET_IDX_EV5;
- }
- AnsiString text;
- if( BT_PACKET_IDX_DH5 >= m_sBTPKT.e_idx )
- {
- text = m_edtPKTDataLen[m_sBTPKT.e_idx]->Text; if( !IsValidBTTxDataLength( text, m_sBTPKT.us_packet_length, 0, 65535 ) ) { edtPKTDataLenCheck(m_edtPKTDataLen[m_sBTPKT.e_idx]); return false; }
- }
- text = m_edtPKTPollPeriod[m_sBTPKT.e_idx]->Text; if( !IsValidBTTxPollPeriod( text, m_sBTPKT.uc_poll_period ) ) { edtPKTDataLenCheck(m_edtPKTPollPeriod[m_sBTPKT.e_idx]); return false; }
- text = m_edtPKTPktCount[m_sBTPKT.e_idx]->Text; if( !IsValidBTTxPacketCount( text, m_sBTPKT.ui_packet_count ) ) { edtPKTCountCheck(m_edtPKTPktCount[m_sBTPKT.e_idx]); return false; }
- #endif
- if( CHECK_MASK_PKT_TCI == mark )
- {
- AnsiString text;
- text = m_edtPKTPollPeriod[m_sBTTCI.e_idx]->Text; if( !IsValidBTTxPollPeriod( text, m_sBTTCI.uc_poll_period ) ) { edtPKTDataLenCheck(m_edtPKTPollPeriod[m_sBTTCI.e_idx]); return false; }
- text = m_edtPKTPktCount[m_sBTTCI.e_idx]->Text; if( !IsValidBTTxPacketCount( text, m_sBTTCI.ui_packet_count ) ) { edtPKTCountCheck(m_edtPKTPktCount[m_sBTTCI.e_idx]); return false; }
- if( BT_PACKET_IDX_DH5 >= m_sBTTCI.e_idx )
- {
- text = m_edtPKTDataLen[m_sBTTCI.e_idx]->Text; if( !IsValidBTTxDataLength( text, m_sBTTCI.us_packet_length, 0, 65535 ) ) { edtPKTDataLenCheck(m_edtPKTDataLen[m_sBTTCI.e_idx]); return false; }
- }
- else
- {
- switch( m_sBTTCI.e_idx )
- {
- case BT_PACKET_IDX_HV1:
- m_sBTTCI.us_packet_length = 10;
- break;
- case BT_PACKET_IDX_HV2:
- m_sBTTCI.us_packet_length = 20;
- break;
- case BT_PACKET_IDX_HV3:
- m_sBTTCI.us_packet_length = 30;
- break;
- case BT_PACKET_IDX_EV3:
- m_sBTTCI.us_packet_length = 30;
- break;
- case BT_PACKET_IDX_EV4:
- m_sBTTCI.us_packet_length = 120;
- break;
- case BT_PACKET_IDX_EV5:
- m_sBTTCI.us_packet_length = 180;
- break;
- }
- }
- }
- return true;
- }
- //-------------------------------------------------------------------------
- unsigned short TfrmBT::Get_PKTTxDataDefaultLen( E_BT_PACKET_IDX index )
- {
- unsigned short us_default_len[] =
- {
- 17, // DM1
- 27, // DH1,
- 10, // HV1,
- 20, // HV2,
- 30, // HV3,
- 121, // DM3,
- 183, // DH3,
- 224, // DM5,
- 339, // DH5,
- 30, // EV3,
- 120, // EV4,
- 180, //EV5,
- // BT 2.0
- 54, // 2-DH1,
- 60, // 2-EV3,
- 367, // 2-DH3,
- 360, // 2-EV5,
- 679, // 2-DH5,
- 90, // 3-EV3,
- 83, // 3-DH1,
- 552, // 3-DH3,
- 540, // 3-EV5,
- 1021, // 3-DH5,
- };
- return us_default_len[index];
- }
- //--------------------------------------------------------------------------
- unsigned short TfrmBT::Get_PKTTxDataMinLen( E_BT_PACKET_IDX index )
- {
- unsigned short us_min_len[] =
- {
- 0, // DM1
- 0, // DH1,
- 10, // HV1,
- 20, // HV2,
- 30, // HV3,
- 0, // DM3,
- 0, // DH3,
- 0, // DM5,
- 0, // DH5,
- 1, // EV3,
- 1, // EV4,
- 1, //EV5,
- // BT 2.0
- 0, // 2-DH1,
- 1, // 2-EV3,
- 0, // 2-DH3,
- 1, // 2-EV5,
- 0, // 2-DH5,
- 1, // 3-EV3,
- 0, // 3-DH1,
- 0, // 3-DH3,
- 1, // 3-EV5,
- 0, // 3-DH5,
- };
- return us_min_len[index];
- }
- //--------------------------------------------------------------------------
- unsigned short TfrmBT::Get_PKTTxDataMaxLen( E_BT_PACKET_IDX index )
- {
- unsigned char us_max_len[] =
- {
- 17, // DM1
- 27, // DH1,
- 10, // HV1,
- 20, // HV2,
- 30, // HV3,
- 121, // DM3,
- 183, // DH3,
- 224, // DM5,
- 339, // DH5,
- 30, // EV3,
- 120, // EV4,
- 180, //EV5,
- // BT 2.0
- 54, // 2-DH1,
- 60, // 2-EV3,
- 367, // 2-DH3,
- 360, // 2-EV5,
- 679, // 2-DH5,
- 90, // 3-EV3,
- 83, // 3-DH1,
- 552, // 3-DH3,
- 540, // 3-EV5,
- 1021, // 3-DH5,
- };
- return us_max_len[index];
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnPKTStartClick(TObject *Sender)
- {
- if( ! CheckPKTFields( CHECK_MASK_PKT ) )
- {
- sbPKT->Panels->Items[0]->Text = (AnsiString) " BT packet test fail";
- Application->MessageBox( "Execution Failure : BT packet test", "FAILURE", MB_OK );
- return;
- }
- for( int i=0; i<BT_PACKET_IDX_COUNT; i++ )
- {
- m_sPKTStatus.b_finish[i] = false;
- m_sPKTStatus.e_state[i] = PKT_STATE_IDLE;
- }
- m_sBTPKT.hPostMsgDestHandle = this->Handle;
- m_sBTPKT.log = m_pPKTLog;
- CurrentPageLock();
- sbPKT->Panels->Items[0]->Text = (AnsiString) " BT packet test progressing";
- MonitorTimer->Enabled = false;
- m_uiPKTLastTesterTx = 0;
- m_uiPKTLastTesterRx = 0;
- m_uiPKTLastDutTx = 0;
- m_uiPKTLastDutRx = 0;
- m_uiPKTCount = 0;
- m_BT_PKT_Obj.ConfirmCallback = ::CNF_PKT;
- m_BT_PKT_Obj.REQ_Start( m_sBTPKT );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CNF_PKT(void)
- {
- E_METAAPP_RESULT_T state = m_BT_PKT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- MonitorTimer->Enabled = true;
- // m_sHCIEventFmt = m_BT_HCI_Obj.Get_HCIEvent();
- // DeComposeHCIEvent( m_sHCIEventFmt );
- // ReDrawHCIFields( DRAM_MASK_HCI_RECEIVE );
- // sbPKT->Panels->Items[0]->Text = (AnsiString)" BT packet test successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- CurrentPageReset();
- sbPKT->Panels->Items[0]->Text = (AnsiString)" BT packet test fail";
- Application->MessageBox( "Execution Fail : BT packet test", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- CurrentPageReset();
- sbPKT->Panels->Items[0]->Text = (AnsiString)" BT packet test timeout";
- Application->MessageBox( "Execution Timeout : BT packet test", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- CurrentPageReset();
- sbPKT->Panels->Items[0]->Text = (AnsiString)" BT packet test stop";
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::rbHCIDecClick(TObject *Sender)
- {
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value";
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value";
- ReDrawHCIFields( DRAM_MASK_HCI_SEND | DRAM_MASK_HCI_RECEIVE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::rbHCIHexClick(TObject *Sender)
- {
- sgSendHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value (Hex)";
- sgReceiveHCI->Cells[HCI_VALUE_COL_IDX][0] = "Value (Hex)";
- ReDrawHCIFields( DRAM_MASK_HCI_SEND | DRAM_MASK_HCI_RECEIVE );
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::CheckSendHCIValue( void )
- {
- S_BT_HCI_VALUE hci_value;
- vector<S_BT_HCI_PARAMETER>:: iterator iter;
- bool ok;
- for( int row=1; row<sgSendHCI->RowCount; row++ )
- {
- AnsiString as_name = sgSendHCI->Cells[HCI_NAME_COL_IDX][row];
- if( rbHCIDec->Checked )
- {
- if( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row].AnsiCompareIC("") == 0 )
- {
- return true;
- }
- for( iter = m_pvSendHCIPar->begin(); iter != m_pvSendHCIPar->end(); iter++ )
- {
- if( iter->as_name.AnsiCompareIC( as_name ) == 0 )
- {
- // iter->ui_bytes = sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt();
- // iter->s_value = hci_value;
- break;
- }
- }
- if( iter->b_rangecheck )
- { ok = IsValidDecBTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], (unsigned char)sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt(), hci_value, iter->s_min_value, iter->s_max_value ) ;
- if( ! ok )
- {
- AnsiString as_min_range, as_max_range;
- BTHCIValue_To_AnsiString( iter->s_min_value, as_min_range );
- BTHCIValue_To_AnsiString( iter->s_max_value, as_max_range );
- AnsiString as_msg = "Execution Fail : value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect, range : " + as_min_range + "~" + as_max_range;
- sbHCI->Panels->Items[0]->Text = (AnsiString)" value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- Application->MessageBox( as_msg.c_str(), "FAIL", MB_OK );
- return false;
- }
- }
- else
- { ok = IsValidDecBTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], (unsigned char)sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt(), hci_value ) ;
- if( ! ok )
- {
- AnsiString as_msg = "Execution Fail : value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- sbHCI->Panels->Items[0]->Text = (AnsiString)" value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- Application->MessageBox( as_msg.c_str(), "FAIL", MB_OK );
- return false;
- }
- }
- }
- else
- {
- if( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row].AnsiCompareIC("") == 0 )
- {
- return true;
- }
- for( iter = m_pvSendHCIPar->begin(); iter != m_pvSendHCIPar->end(); iter++ )
- {
- if( iter->as_name.AnsiCompareIC( as_name ) == 0 )
- {
- // iter->ui_bytes = sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt();
- // iter->s_value = hci_value;
- break;
- }
- }
- if( iter->b_rangecheck )
- { ok = IsValidHexBTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], (unsigned char)sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt(), hci_value, iter->s_min_value, iter->s_max_value ) ;
- if( ! ok )
- {
- AnsiString as_min_range, as_max_range;
- BTHCIValue_To_Hex_AnsiString( iter->s_min_value, as_min_range );
- BTHCIValue_To_Hex_AnsiString( iter->s_max_value, as_max_range );
- AnsiString as_msg = "Execution Fail : value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect, range : 0x" + as_min_range + "~0x" + as_max_range;
- sbHCI->Panels->Items[0]->Text = (AnsiString)" value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- Application->MessageBox( as_msg.c_str(), "FAIL", MB_OK );
- return false;
- }
- }
- else
- {
- ok = IsValidHexBTHCIValue( sgSendHCI->Cells[HCI_VALUE_COL_IDX][row], (unsigned char)sgSendHCI->Cells[HCI_BYTE_COL_IDX][row].ToInt(), hci_value ) ;
- if( ! ok )
- {
- AnsiString as_msg = "Execution Fail : value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- sbHCI->Panels->Items[0]->Text = (AnsiString)" value of parameter " + sgSendHCI->Cells[HCI_NAME_COL_IDX][row] + " incorrect";
- Application->MessageBox( as_msg.c_str(), "FAIL", MB_OK );
- return false;
- }
- }
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::sgSendHCICheck(TObject *Sender)
- {
- CheckSendHCIValue();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtHCITimeoutCheck(TObject *Sender)
- {
- int data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " Timeout is not valid ";
- text = edit->Text;
- if (!IsValidTimeout(text, data))
- {
- ShowHintLabel(edit, hint);
- edit->Text = IntToStr( HCI_DEFAULT_TIMEOUT_MS );
- edit->SetFocus();
- return;
- }
- m_sBTHCI.ui_ms_timeout = (unsigned int) data;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbRFTxTypeChange(TObject *Sender)
- {
- DisplayRFDefaultDataLen();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFRxSignleFreqCheck(TObject *Sender)
- {
- unsigned char uc_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~255 "
- };
- text = edit->Text;
- if( !IsValidBTFreq( text, uc_data ) )
- {
- edit->Text = 78;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBtRf.uc_freq = uc_data;
- }
- //===========================================================================
- ///////////////////////////// Packet test ////////////////////////////////
- //===========================================================================
- void TfrmBT::AbortConnectWithTarget(void)
- {
- m_sCWT.iBootStop = BOOT_STOP;
- if (m_bConnectTargetok)
- {
- META_ShutDownTarget_r(m_META_HANDLE_Obj.Get_SecondHandle());
- META_DisconnectWithTarget_r(m_META_HANDLE_Obj.Get_SecondHandle());
- m_bConnectTargetok = false;
- }
- if (NULL != m_pT_CWT)
- {
- WaitForSingleObject(m_sCWT.METADLL_Connect_Event, 5000);
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmBT::IsNewTciRequired(void)
- {
- TCheckBox *cbPkt20[] =
- {
- cbPKTDM1,
- cbPKTDH1,
- cbPKTDM3,
- cbPKTDH3,
- cbPKTDM5,
- cbPKTDH5,
- cbPKTHV1,
- cbPKTHV2,
- cbPKTHV3,
- cbPKTEV3,
- cbPKTEV4,
- cbPKTEV5,
- cbPK2DH1,
- cbPK2EV3,
- cbPK2DH3,
- cbPK2EV5,
- cbPK2DH5,
- cbPK3EV3,
- cbPK3DH1,
- cbPK3DH3,
- cbPK3EV5,
- cbPK3DH5
- };
- int total_num;
- if (BTMODULE_MT6611 != m_cBtId)
- {
- total_num = BT_PACKET_IDX_NONEDR_COUNT;
- }
- else
- {
- total_num = BT_PACKET_IDX_COUNT;
- }
- for (int i=0; i<total_num; i++)
- {
- if (cbPkt20[i]->Checked &&
- (!IsPKTTestFinish((E_BT_PACKET_IDX) i))
- )
- {
- if (IsPKTTestRunning((E_BT_PACKET_IDX) i))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = (E_BT_PACKET_IDX) i;
- return true;
- }
- }
- }
- return false;
- #if 0
- if (cbPKTDM1->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DM1))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DM1))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DM1;