form_BT.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:232k
- return true;
- }
- }
- else if (cbPKTDH1->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DH1))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DH1))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DH1;
- return true;
- }
- }
- else if (cbPKTDM3->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DM3))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DM3))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DM3;
- return true;
- }
- }
- else if (cbPKTDH3->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DH3))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DH3))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DH3;
- return true;
- }
- }
- else if (cbPKTDM5->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DM5))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DM5))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DM5;
- return true;
- }
- }
- else if (cbPKTDH5->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_DH5))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_DH5))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_DH5;
- return true;
- }
- }
- else if (cbPKTHV1->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_HV1))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_HV1))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_HV1;
- return true;
- }
- }
- else if (cbPKTHV2->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_HV2))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_HV2))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_HV2;
- return true;
- }
- }
- else if (cbPKTHV3->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_HV3))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_HV3))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_HV3;
- return true;
- }
- }
- else if (cbPKTEV3->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_EV3))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_EV3))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_EV3;
- return true;
- }
- }
- else if (cbPKTEV4->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_EV4))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_EV4))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_EV4;
- return true;
- }
- }
- else if (cbPKTEV5->Checked &&
- (!IsPKTTestFinish(BT_PACKET_IDX_EV5))
- )
- {
- if (IsPKTTestRunning(BT_PACKET_IDX_EV5))
- {
- return false;
- }
- else
- {
- m_sBTTCI.e_idx = BT_PACKET_IDX_EV5;
- return true;
- }
- }
- if (BTMODULE_MT6611 == m_cBtId)
- {
- E_BT_PACKET_IDX ePkt20[] =
- {
- BT_PACKET_IDX_2DH1,
- BT_PACKET_IDX_2EV3,
- BT_PACKET_IDX_2DH3,
- BT_PACKET_IDX_2EV5,
- BT_PACKET_IDX_2DH5,
- BT_PACKET_IDX_3EV3,
- BT_PACKET_IDX_3DH1,
- BT_PACKET_IDX_3DH3,
- BT_PACKET_IDX_3EV5,
- BT_PACKET_IDX_3DH5,
- };
- }
- return false;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::MonitorTimerTimer(TObject *Sender)
- {
- if (IsAllPKTTestFinish())
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" BT packet test finish";
- CurrentPageReset();
- }
- if (IsNewTciRequired())
- {
- if( ! CheckPKTFields( CHECK_MASK_PKT_TCI ) )
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString) " BT packet test fail";
- Application->MessageBox( "Execution Failure : BT packet test", "FAILURE", MB_OK );
- return;
- }
- m_sPKTStatus.e_state[m_sBTTCI.e_idx] = PKT_STATE_RUNNING;
- m_BT_PKT_Obj.ConfirmCallback = ::CNF_PKT_TCI;
- m_BT_PKT_Obj.REQ_TCI_Control_Remote_DUT_Start(m_sBTTCI);
- }
- else
- {
- m_BT_PKT_Obj.ConfirmCallback = ::CNF_PKT_Read_TxRxCount;
- m_BT_PKT_Obj.REQ_Read_TX_RX_Count_Start();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CNF_PKT_TCI( void )
- {
- E_METAAPP_RESULT_T state = m_BT_PKT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- // sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count fail";
- Application->MessageBox("Execution Fail : Read packet TX/RX count", "FAIL", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count timeout";
- Application->MessageBox("Execution Timeout : Read packet TX/RX count", "TIMEOUT", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CNF_PKT_Read_TxRxCount(void)
- {
- E_METAAPP_RESULT_T state = m_BT_PKT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (BTMODULE_MT6611 != m_cBtId)
- {
- SetPKTFinish(m_sBTTCI.e_idx);
- m_sBTMonCnf = m_BT_PKT_Obj.Get_MonitorResult();
- ReDrawPKTFields(DRAM_MASK_PKT_MONITOR);
- }
- else
- {
- m_BT_PKT_Obj.ConfirmCallback = ::CNF_PKT_Read_EDRTxRxCount;
- m_BT_PKT_Obj.REQ_Read_EDR_TX_RX_Count_Start();
- }
- // sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count fail";
- Application->MessageBox("Execution Fail : Read packet TX/RX count", "FAIL", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count timeout";
- Application->MessageBox("Execution Timeout : Read packet TX/RX count", "TIMEOUT", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::CNF_PKT_Read_EDRTxRxCount(void)
- {
- E_METAAPP_RESULT_T state = m_BT_PKT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- SetPKTFinish(m_sBTTCI.e_idx);
- m_sBTMonCnf = m_BT_PKT_Obj.Get_MonitorResult();
- ReDrawPKTFields(DRAM_MASK_PKT_MONITOR);
- // sbPKT->Panels->Items[0]->Text = (AnsiString)" Read packet TX/RX count successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read EDR packet TX/RX count fail";
- Application->MessageBox("Execution Fail : Read EDR packet TX/RX count", "FAIL", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read EDR packet TX/RX count timeout";
- Application->MessageBox("Execution Timeout : Read EDR packet TX/RX count", "TIMEOUT", MB_OK);
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- MonitorTimer->Enabled = false;
- sbPKT->Panels->Items[0]->Text = (AnsiString)" Read EDR packet TX/RX count stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmBT::edtPKTDataLenCheck(TObject *Sender)
- {
- AnsiString text;
- AnsiString as_hint;
- TEdit *edit = (TEdit*)Sender;
- unsigned short us_min_len = Get_PKTTxDataMinLen((E_BT_PACKET_IDX) edit->Tag);
- unsigned short us_max_len = Get_PKTTxDataMaxLen((E_BT_PACKET_IDX) edit->Tag);
- unsigned short us_data;
- 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, us_min_len, us_max_len ) )
- {
- edit->Text = Get_PKTTxDataDefaultLen((E_BT_PACKET_IDX) edit->Tag);
- ShowHintLabel( edit, as_hint.c_str() );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtPKTPollPeriodCheck(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;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtPKTCountCheck(TObject *Sender)
- {
- unsigned int ui_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~4294967295 "
- };
- text = edit->Text;
- if( !IsValidBTTxPacketCount( text, ui_data ) )
- {
- edit->Text = 1000;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnSCTFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- ok = dlgOpenSCTFile->Execute();
- if( ! ::CheckFileExist(dlgOpenSCTFile->FileName))
- ok = false;
- if( !ok )
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString) " Load script file fail";
- return;
- }
- m_sBTSCT.hPostMsgDestHandle = this->Handle;
- m_sBTSCT.filename = dlgOpenSCTFile->FileName;
- m_sBTSCT.log = m_pSCTLog;
- m_BT_SCT_Obj.ConfirmCallback = ::ConfirmCallback_SetupSCTFile;
- m_BT_SCT_Obj.REQ_Read_From_File_Start( m_sBTSCT );
- sbSCT->Panels->Items[0]->Text = (AnsiString) " Setup script file progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_SetupSCTFile(void)
- {
- E_METAAPP_RESULT_T state = m_BT_SCT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- stSCTFile->Caption = m_sBTSCT.filename;
- m_pvScript = m_BT_SCT_Obj.Get_ScriptVector();
- DisplaySCTUI();
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Setup script file successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Setup script file fail";
- Application->MessageBox( "Execution Fail : Setup script file", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Setup script file timeout";
- Application->MessageBox( "Execution Timeout : Setup script file", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Setup script file stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplaySCTUI( void )
- {
- vector<S_BT_SCT_SCRIPT>:: iterator iter_script;
- // S_BT_SCT_SCRIPT script;
- // int i;
- // for( i=0; i<MAX_SCRIPT_NUM; i++ )
- // { // m_btnSCTTest[i]->Visible = false;
- // m_btnSCTTest[i]->Enabled = false;
- // }
- lbSCT->Clear();
- for( iter_script = m_pvScript->begin(); iter_script != m_pvScript->end(); iter_script++ )
- {
- lbSCT->Items->Add( iter_script->as_script_name );
- // script = *iter_script;
- // for( int i=1; i<=MAX_SCRIPT_NUM; i++ )
- // {
- // if( script.as_script_tag.AnsiPos(IntToStr(i)) != 0 )
- // {
- // m_btnSCTTest[i-1]->Enabled = true;
- // // m_btnSCTTest[i-1]->Visible = true;
- // m_btnSCTTest[i-1]->Caption = script.as_script_name;
- // break;
- // }
- // }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnSCTTestClick(TObject *Sender)
- {
- TButton *btn = (TButton *)Sender;
- m_sBTSCT.hPostMsgDestHandle = this->Handle;
- m_sBTSCT.filename = stSCTFile->Caption;
- m_sBTSCT.log = m_pSCTLog;
- m_sBTSCT.as_script_name = btn->Caption;
- CurrentPageLock();
- sbSCT->Panels->Items[0]->Text = (AnsiString) " Script test progressing";
- m_BT_SCT_Obj.ConfirmCallback = ::ConfirmCallback_SCT;
- m_BT_SCT_Obj.REQ_Start( m_sBTSCT );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_SCT(void)
- {
- E_METAAPP_RESULT_T state = m_BT_SCT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Script test successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Script test fail";
- Application->MessageBox( "Execution Fail : Script test", "FAIL", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop(true);
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Script test timeout";
- Application->MessageBox( "Execution Timeout : Script test", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Send HCI command stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnPKTStopClick(TObject *Sender)
- {
- if( btnPKTStart->Tag==1 )
- {
- MonitorTimer->Enabled = false;
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Stop packet test successfully";
- m_BT_PKT_Obj.ConfirmCallback = ::CNF_PKT_Stop;
- m_BT_PKT_Obj.REQ_Stop_Start();
- }
- }
- //--------------------------------------------------------------------------
- void TfrmBT::CNF_PKT_Stop(void)
- {
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void TfrmBT::FillSCTResult( void )
- {
- for(int i=0; i<m_pSCTLog->Count; i++ )
- {
- AnsiString as = m_pSCTLog->Strings[i];
- memSCTResult->Lines->Add( as );
- }
- m_pSCTLog->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFTxStopClick(TObject *Sender)
- {
- if( btnRFTxStart->Tag==1 )
- {
- Force_BT_Stop( true );
- m_BT_RF_Obj.REQ_Stop_Start();
- CurrentPageReset();
- sbRF->Panels->Items[0]->Text = (AnsiString)" Stop RF TX test successfully";
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbHCICategoryChange(TObject *Sender)
- {
- DisplayHCIUI( DRAW_MASK_HCI_COMMAND | DRAW_MASK_HCI_PARAMETER, cbHCICategory->ItemIndex, 0 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnHCIStartClick(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) " Start HCI commander test progressing";
- m_BT_HCI_Obj.ConfirmCallback = ::ConfirmCallback_HCI;
- m_BT_HCI_Obj.REQ_Start( m_sBTHCI );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnHCIStopClick(TObject *Sender)
- {
- if( btnHCIStart->Tag==1 )
- {
- Force_BT_Stop( false );
- m_BT_HCI_Obj.REQ_Stop();
- CurrentPageReset();
- sbHCI->Panels->Items[0]->Text = (AnsiString)" Stop HCI commander test successfully";
- return;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::Force_BT_Stop(bool reset)
- {
- m_cBT_STOP_Obj.REQ_Start( reset );
- }
- //--------------------------------------------------------------------------
- //void __fastcall TfrmBT::btnRFRxStopClick(TObject *Sender)
- //{
- // if( btnRFRxStart->Tag==1 )
- // {
- // Force_BT_Stop();
- // m_BT_RF_Obj.REQ_Stop_Start();
- // CurrentPageReset();
- // sbRF->Panels->Items[0]->Text = (AnsiString)" Stop RF RX test successfully";
- // return;
- // }
- //}
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnSCTStopClick(TObject *Sender)
- {
- Force_BT_Stop( true );
- CurrentPageReset();
- sbSCT->Panels->Items[0]->Text = (AnsiString)" Stop script test successfully";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnSCTStartClick(TObject *Sender)
- {
- //TButton *btn = (TButton *)Sender;
- m_sBTSCT.hPostMsgDestHandle = this->Handle;
- m_sBTSCT.filename = stSCTFile->Caption;
- m_sBTSCT.log = m_pSCTLog;
- m_sBTSCT.as_script_name = lbSCT->Items->Strings[lbSCT->ItemIndex];
- CurrentPageLock();
- sbSCT->Panels->Items[0]->Text = (AnsiString) " Script test progressing";
- m_BT_SCT_Obj.ConfirmCallback = ::ConfirmCallback_SCT;
- m_BT_SCT_Obj.REQ_Start( m_sBTSCT );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnSCTClearLogClick(TObject *Sender)
- {
- memSCTResult->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnHCIClearLogClick(TObject *Sender)
- {
- memHCIResult->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFClearLogClick(TObject *Sender)
- {
- memRFResult->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnPKTClearLogClick(TObject *Sender)
- {
- memPKTResult->Clear();
- }
- //===========================================================================
- ////////////////////////////// Throughput test ///////////////////////////
- //===========================================================================
- void __fastcall TfrmBT::btnTHClearLogClick(TObject *Sender)
- {
- memTTResult->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTHConnectDUTClick(TObject *Sender)
- {
- #if 0
- shpTHConnect->Brush->Color = clRed;
- if( m_bConnectingTarget )
- {
- m_sCWT.iBootStop = BOOT_STOP;
- if( NULL != m_pT_CWT )
- {
- WaitForSingleObject( m_sCWT.METADLL_Connect_Event, 5000 );
- }
- m_sCWT.iBootStop = 0;
- }
- else
- {
- m_sCWT.iBootStop = 0;
- }
- m_sCWT.i_meta_handle = m_META_HANDLE_Obj.Get_SecondHandle();
- SetTHMetaConnectReq( m_sCWT.META_connect_req );
- m_sCWT.neSuccess = on_THConnectWithTarget_Success;
- m_sCWT.neByUser = on_THConnectWithTarget_ByUser;
- 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 );
- }
- 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_THConnectWithTarget_Fail;
- m_pT_CWT->Priority = tpHighest;
- }
- else
- {
- m_pTHLog->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_bConnectingTarget = true;
- m_pT_CWT->Resume();
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void TfrmBT::SetTHMetaConnectReq( META_Connect_Req &META_connect_req )
- {
- #if 0
- AnsiString as_BootTimeout, as_METAConnectTimeout;
- 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[cbTHCOM->ItemIndex];
- 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) cbPKTBaudRate->ItemIndex )
- {
- 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;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_THConnectWithTarget_Success(TObject *Sender)
- {
- #if 0
- shpTHConnect->Brush->Color = clYellow;
- m_bConnectTargetok = true;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_THConnectWithTarget_Fail(TObject *Sender)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::on_THConnectWithTarget_ByUser(TObject *Sender)
- {
- }
- void __fastcall TfrmBT::cbTHCOMChange(TObject *Sender)
- {
- //m_sCWT.iBootStop = BOOT_STOP;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::ComboBox1Change(TObject *Sender)
- {
- //m_sCWT.iBootStop = BOOT_STOP;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFEnterTestModeClick(TObject *Sender)
- {
- m_sBtRf.hPostMsgDestHandle = this->Handle;
- m_sBtRf.log = m_pRFLog;
- CurrentPageLock();
- sbRF->Panels->Items[0]->Text = (AnsiString) " Enter BT test mode progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_RFEnterTestMode;
- m_BT_RF_Obj.REQ_Enter_Test_Mode_Start( m_sBtRf );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_RFEnterTestMode(void)
- {
- E_METAAPP_RESULT_T state = m_BT_RF_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Enter BT test mode finish";
- }
- break;
- case METAAPP_FAIL:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Enter BT test mode fail";
- Application->MessageBox( "Execution Failure : Enter BT test mode", "FAILURE", MB_OK );
- Application->BringToFront();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( true );
- sbRF->Panels->Items[0]->Text = (AnsiString)" Enter BT test mode timeout";
- Application->MessageBox( "Execution Timeout : Enter BT test mode", "TIMEOUT", MB_OK );
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Enter BT test mode stop";
- CurrentPageReset();
- }
- break;
- }
- CurrentPageReset();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFBDAddressCheck(TObject *Sender)
- {
- S_BD_ADDR bd_addr;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " BD address is not valid "
- };
- text = edit->Text;
- if( !IsValidHexBDAddress( text, bd_addr ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sRFBdAddr = bd_addr;
- SyncLAPAndAccessCode();
- ReDrawRFFields( DRAM_MASK_RF_ACCESS_CODE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFQueryBdAddrClick(TObject *Sender)
- {
- m_sBtRf.hPostMsgDestHandle = this->Handle;
- m_sBtRf.log = m_pRFLog;
- CurrentPageLock();
- sbRF->Panels->Items[0]->Text = (AnsiString) " Query BD address progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_QueryBDAddress;
- m_BT_RF_Obj.REQ_QueryBDAddress_Start( m_sBtRf );
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ConfirmCallback_QueryBDAddress(void)
- {
- E_METAAPP_RESULT_T state = m_BT_RF_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- m_sRFBdAddr = m_BT_RF_Obj.Get_BdAddress();
- ReDrawRFFields( DRAM_MASK_RF_BD_ADDRESS );
- SyncLAPAndAccessCode();
- ReDrawRFFields( DRAM_MASK_RF_ACCESS_CODE );
- sbRF->Panels->Items[0]->Text = (AnsiString)" Query BD address finish";
- }
- break;
- case METAAPP_FAIL:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Query BD address fail";
- Application->MessageBox( "Execution Failure : Query BD address ", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( true );
- sbRF->Panels->Items[0]->Text = (AnsiString)" Query BD address timeout";
- Application->MessageBox( "Execution Timeout : Query BD address ", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Query BD address stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::cbRFTxPowerCtrlClick(TObject *Sender)
- {
- if( (cbRFTxPowerCtrl->Checked) && (! btnRFTxStart->Enabled) )
- btnRFChangeLevel->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnRFChangeLevelClick(TObject *Sender)
- {
- m_sBtRf.hPostMsgDestHandle = this->Handle;
- m_sBtRf.log = m_pRFLog;
- CurrentPageLock();
- sbRF->Panels->Items[0]->Text = (AnsiString) " Change power control level progressing";
- m_BT_RF_Obj.ConfirmCallback = ::ConfirmCallback_ChangePCL;
- m_BT_RF_Obj.REQ_ChangePCL_Start( m_sBtRf );
- }
- //--------------------------------------------------
- void TfrmBT::ConfirmCallback_ChangePCL(void)
- {
- E_METAAPP_RESULT_T state = m_BT_RF_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Change power control level finish";
- }
- break;
- case METAAPP_FAIL:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Change power control level fail";
- Application->MessageBox( "Execution Failure : Change power control level", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( true );
- sbRF->Panels->Items[0]->Text = (AnsiString)" Change power control level timeout";
- Application->MessageBox( "Execution Timeout : Change power control level", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbRF->Panels->Items[0]->Text = (AnsiString)" Change power control level stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::ToggleHideExecute(TObject *Sender)
- {
- g_bHideEnable = g_bHideEnable ? false : true;
- ApplyHideProperty();
- }
- //---------------------------------------------------------------------------
- void TfrmBT::ApplyHideProperty(void)
- {
- bool visible = g_bHideEnable ? false : true;
- tsHCI->Visible = visible;
- tsHCI->TabVisible = visible;
- tsSCT->Visible = visible;
- tsSCT->TabVisible = visible;
- m_tsMT->Visible = visible;
- m_tsMT->TabVisible = visible;
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFNAPCheck(TObject *Sender)
- {
- #if 0
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 3 == edit->Tag % 4 )
- {
- m_sBtRf.s_BDAddr.us_NAP = (m_sBtRf.s_BDAddr.us_NAP & 0x0FFF) | ((ucdata &0xF)<<12);
- }
- else if( 2 == edit->Tag % 4 )
- {
- m_sBtRf.s_BDAddr.us_NAP = (m_sBtRf.s_BDAddr.us_NAP & 0xF0FF) | ((ucdata &0xF)<<8);
- }
- else if( 1 == edit->Tag % 4 )
- {
- m_sBtRf.s_BDAddr.us_NAP = (m_sBtRf.s_BDAddr.us_NAP & 0xFF0F) | ((ucdata &0xF)<<4);
- }
- else
- {
- m_sBtRf.s_BDAddr.us_NAP = (m_sBtRf.s_BDAddr.us_NAP & 0xFFF0) | (ucdata &0xF);
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFUAPCheck(TObject *Sender)
- {
- #if 0
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 1 == edit->Tag % 2 )
- {
- m_sBtRf.s_BDAddr.uc_UAP = (m_sBtRf.s_BDAddr.uc_UAP & 0x0F) | ((ucdata & 0xF)<<4);
- }
- else
- {
- m_sBtRf.s_BDAddr.uc_UAP = (m_sBtRf.s_BDAddr.uc_UAP & 0xF0) | (ucdata & 0xF);
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtRFLAPCheck(TObject *Sender)
- {
- #if 0
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 5 == edit->Tag % 6 )
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0x0FFFFF) | ((ucdata & 0xF)<<20);
- }
- else if( 4 == edit->Tag % 6 )
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0xF0FFFF) | ((ucdata & 0xF)<<16);
- }
- else if( 3 == edit->Tag % 6 )
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0xFF0FFF) | ((ucdata & 0xF)<<12);
- }
- else if( 2 == edit->Tag % 6 )
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0xFFF0FF) | ((ucdata & 0xF)<<8);
- }
- else if( 1 == edit->Tag % 6 )
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0xFFFF0F) | ((ucdata & 0xF)<<4);
- }
- else
- {
- m_sBtRf.s_BDAddr.ui_LAP = (m_sBtRf.s_BDAddr.ui_LAP & 0xFFFFF0) | (ucdata & 0xF);
- }
- #endif
- }
- //============================================================================
- ////////////////////////// Connection test /////////////////////////////////
- //============================================================================
- void TfrmBT::ReDrawCTFields( E_DRAM_MASK_CT draw_mask )
- {
- if( draw_mask & DRAM_MASK_CT_LOCAL_BDADDR )
- {
- char str[20];
- // NAP
- sprintf( str, "%X", (m_sLocalBdAddr.us_NAP & 0xF000) >> 12 );
- edtCTLDINAP3->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.us_NAP & 0x0F00) >> 8 );
- edtCTLDINAP2->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.us_NAP & 0x00F0) >> 4 );
- edtCTLDINAP1->Text = (AnsiString) str;
- sprintf( str, "%X", m_sLocalBdAddr.us_NAP & 0x000F );
- edtCTLDINAP0->Text = (AnsiString) str;
- // UAP
- sprintf( str, "%X", (m_sLocalBdAddr.uc_UAP & 0xF0) >> 4 );
- edtCTLDIUAP1->Text = (AnsiString) str;
- sprintf( str, "%X", m_sLocalBdAddr.uc_UAP & 0x0F );
- edtCTLDIUAP0->Text = (AnsiString) str;
- // LAP
- sprintf( str, "%X", (m_sLocalBdAddr.ui_LAP & 0x00F00000) >> 20 );
- edtCTLDILAP5->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.ui_LAP & 0x000F0000) >> 16 );
- edtCTLDILAP4->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.ui_LAP & 0x0000F000) >> 12 );
- edtCTLDILAP3->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.ui_LAP & 0x00000F00) >> 8 );
- edtCTLDILAP2->Text = (AnsiString) str;
- sprintf( str, "%X", (m_sLocalBdAddr.ui_LAP & 0x000000F0) >> 4 );
- edtCTLDILAP1->Text = (AnsiString) str;
- sprintf( str, "%X", m_sLocalBdAddr.ui_LAP & 0x0000000F );
- edtCTLDILAP0->Text = (AnsiString) str;
- }
- // ACL BD address
- if( draw_mask & DRAM_MASK_CT_ACL_BDADDR )
- {
- AnsiString as_bd_addr;
- char str[3];
- for( int i=BD_ADDRESS_LEN-1; i>=0; i-- )
- {
- if( m_sCTACLBdAddr.uc_BD_Addr[i] <= 0x0F )
- sprintf( str, "0%X", m_sCTACLBdAddr.uc_BD_Addr[i] );
- else
- sprintf( str, "%X", m_sCTACLBdAddr.uc_BD_Addr[i] );
- AnsiString as_str(str);
- if( i != 0 ) as_str += ":";
- as_bd_addr+= as_str;
- }
- m_stCTACLBDAddr->Caption = as_bd_addr;
- }
- // SCO BD address
- if( draw_mask & DRAM_MASK_CT_SCO_BDADDR )
- {
- AnsiString as_bd_addr;
- char str[3];
- for( int i=BD_ADDRESS_LEN-1; i>=0; i-- )
- {
- if( m_sSCOBdAddr.uc_BD_Addr[i] <= 0x0F )
- sprintf( str, "0%X", m_sSCOBdAddr.uc_BD_Addr[i] );
- else
- sprintf( str, "%X", m_sSCOBdAddr.uc_BD_Addr[i] );
- AnsiString as_str(str);
- if( i != 0 ) as_str += ":";
- as_bd_addr+= as_str;
- }
- m_stCTSCOBDAddr->Caption = as_bd_addr;
- }
- // discovered list
- if( draw_mask & DRAM_MASK_CT_DISCOVERED_LIST )
- {
- DisplayInquiryBDList();
- }
- // connect list
- if( draw_mask & DRAM_MASK_CT_CONNECT_LIST )
- {
- DisplayConnectBDList();
- }
- // ACL connect status
- if( draw_mask & DRAM_MASK_CT_ACL_STATUS )
- {
- vector<S_BT_CT_RES>:: iterator iter;
- vector<S_BT_CT_RES> *pvCTRes = m_cBT_CT_Obj.Get_CtResVector();
- bool match = false;
- for( iter = pvCTRes->begin(); iter != pvCTRes->end(); iter++ )
- {
- match = true;
- for(int i=0; i<BD_ADDRESS_LEN; i++ )
- {
- if( iter->s_bd_addr.uc_BD_Addr[i] != m_sCTACLBdAddr.uc_BD_Addr[i] )
- {
- match = false;
- break;
- }
- }
- if( match )
- break;
- }
- if (match)
- {
- switch (iter->e_acl_status)
- {
- case BT_ACL_STATUS_SUCCESS:
- {
- stCTACLStatus->Caption = (AnsiString) STR_BT_ACL_SUCCESS;
- }
- break;
- case BT_ACL_STATUS_PAGE_TIMEOUT:
- {
- stCTACLStatus->Caption = (AnsiString) STR_BT_ACL_PAGE_TIMEOUT;
- }
- break;
- case BT_ACL_STATUS_FAIL:
- {
- stCTACLStatus->Caption = (AnsiString) STR_BT_ACL_FAIL;
- }
- break;
- case BT_ACL_STATUS_NONE:
- default:
- {
- stCTACLStatus->Caption = (AnsiString) "";
- }
- break;
- }
- }
- }
- // SCO connect status
- if (draw_mask & DRAM_MASK_CT_SCO_STATUS)
- {
- vector<S_BT_CT_RES>:: iterator iter;
- vector<S_BT_CT_RES> *pvCTRes = m_cBT_CT_Obj.Get_CtResVector();
- bool match;
- for (iter = pvCTRes->begin(); iter != pvCTRes->end(); iter++)
- {
- match = true;
- for(int i=0; i<BD_ADDRESS_LEN; i++ )
- {
- if (iter->s_bd_addr.uc_BD_Addr[i] != m_sSCOBdAddr.uc_BD_Addr[i])
- {
- match = false;
- break;
- }
- }
- if (match)
- {
- break;
- }
- }
- if (match)
- {
- switch (iter->e_sco_status)
- {
- case BT_CT_SCO_STATUS_SUCCESS:
- {
- stCTSCOStatus->Caption = (AnsiString) STR_BT_CT_SCO_SUCCESS;
- }
- break;
- case BT_CT_SCO_STATUS_FAIL:
- {
- stCTSCOStatus->Caption = (AnsiString) STR_BT_CT_SCO_FAIL;
- }
- break;
- default:
- case BT_CT_SCO_STATUS_NONE:
- {
- stCTSCOStatus->Caption = (AnsiString) "";
- }
- break;
- }
- }
- }
- // button
- if (draw_mask & DRAM_MASK_CT_BUTTON)
- {
- if (1 == btnCTInquiryStart->Tag)
- {
- btnCTScan->Enabled = false;
- btnCTAutoAccept->Enabled = false;
- btnCTEnterPIN->Enabled = false;
- btnCTConnectSCO->Enabled = false;
- btnCTDisconnectSCO->Enabled = false;
- btnCTConnectACL->Enabled = false;
- btnCTDisconnectACL->Enabled = false;
- btnCTChangeAclPktType->Enabled = false;
- }
- else
- {
- int acl_result = stCTACLStatus->Caption.AnsiCompareIC(STR_BT_ACL_SUCCESS);
- int sco_result = stCTSCOStatus->Caption.AnsiCompareIC(STR_BT_CT_SCO_SUCCESS);
- btnCTScan->Enabled = true;
- btnCTAutoAccept->Enabled = true;
- btnCTEnterPIN->Enabled = false;
- if (1 == acl_result)
- {
- btnCTConnectSCO->Enabled = false;
- btnCTDisconnectSCO->Enabled = false;
- }
- else
- {
- btnCTConnectSCO->Enabled = sco_result;
- btnCTDisconnectSCO->Enabled = !sco_result;
- }
- btnCTConnectACL->Enabled = acl_result;
- btnCTDisconnectACL->Enabled = !acl_result;
- if ((0 == acl_result) && (0 != sco_result))
- {
- btnCTChangeAclPktType->Enabled = true;
- }
- else
- {
- btnCTChangeAclPktType->Enabled = false;
- }
- }
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTLDIReadClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Read local BD address progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_ReadLocalBDAddr;
- m_cBT_CT_Obj.REQ_ReadLocalBDAddress_Start( m_sBTCT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_CT_ReadLocalBDAddr( void )
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- m_sLocalBdAddr = m_cBT_CT_Obj.Get_LocalBdAddr();
- ReDrawCTFields(DRAM_MASK_CT_LOCAL_BDADDR);
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address fail";
- Application->MessageBox( "Execution Failure : Read local BD address", "FAILURE", MB_OK );
- Application->BringToFront();
-
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address timeout";
- Application->MessageBox( "Execution Timeout : Read local BD address", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTResetLDClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Reset local device progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_Reset;
- m_cBT_CT_Obj.REQ_Reset_Start( m_sBTCT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_CT_Reset( void )
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- CurrentPageReset();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- ReDrawCTFields( DRAM_MASK_CT_DISCOVERED_LIST |
- DRAM_MASK_CT_CONNECT_LIST |
- DRAM_MASK_CT_BUTTON |
- DRAM_MASK_CT_ACL_STATUS |
- DRAM_MASK_CT_SCO_STATUS
- );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Reset local device successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Reset local device fail";
- Application->MessageBox( "Execution Failure : Reset local device", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Reset local device timeout";
- Application->MessageBox( "Execution Timeout : Reset local device", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Reset local device stop";
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- void TfrmBT::FillCTResult( void )
- {
- for(int i=0; i<m_pCTLog->Count; i++ )
- {
- AnsiString as = m_pCTLog->Strings[i];
- memCTResult->Lines->Add( as );
- }
- m_pCTLog->Clear();
- }
- void __fastcall TfrmBT::btnCTLDIWriteClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- m_cBT_CT_Obj.Set_LocalBdAddr( m_sLocalBdAddr );
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Write local BD address progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_WriteLocalBDAddr;
- m_cBT_CT_Obj.REQ_WriteLocalBDAddress_Start( m_sBTCT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_CT_WriteLocalBDAddr(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Write local BD address successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address fail";
- Application->MessageBox( "Execution Failure : Read local BD address", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address timeout";
- Application->MessageBox( "Execution Timeout : Read local BD address", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Read local BD address stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTLDINAPCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 3 == edit->Tag )
- {
- m_sLocalBdAddr.us_NAP = (m_sLocalBdAddr.us_NAP & 0x0FFF) | ((ucdata &0xF)<<12);
- }
- else if( 2 == edit->Tag )
- {
- m_sLocalBdAddr.us_NAP = (m_sLocalBdAddr.us_NAP & 0xF0FF) | ((ucdata &0xF)<<8);
- }
- else if( 1 == edit->Tag )
- {
- m_sLocalBdAddr.us_NAP = (m_sLocalBdAddr.us_NAP & 0xFF0F) | ((ucdata &0xF)<<4);
- }
- else
- {
- m_sLocalBdAddr.us_NAP = (m_sLocalBdAddr.us_NAP & 0xFFF0) | (ucdata &0xF);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTLDIUAPCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 1 == edit->Tag )
- {
- m_sLocalBdAddr.uc_UAP = (m_sLocalBdAddr.uc_UAP & 0x0F) | ((ucdata & 0xF)<<4);
- }
- else
- {
- m_sLocalBdAddr.uc_UAP = (m_sLocalBdAddr.uc_UAP & 0xF0) | (ucdata & 0xF);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTLDILAPCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char ucdata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~F ";
- text = edit->Text;
- if( !IsValidHexBDAddress( text, ucdata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( 5 == edit->Tag )
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0x0FFFFF) | ((ucdata & 0xF)<<20);
- }
- else if( 4 == edit->Tag )
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0xF0FFFF) | ((ucdata & 0xF)<<16);
- }
- else if( 3 == edit->Tag )
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0xFF0FFF) | ((ucdata & 0xF)<<12);
- }
- else if( 2 == edit->Tag )
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0xFFF0FF) | ((ucdata & 0xF)<<8);
- }
- else if( 1 == edit->Tag )
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0xFFFF0F) | ((ucdata & 0xF)<<4);
- }
- else
- {
- m_sLocalBdAddr.ui_LAP = (m_sLocalBdAddr.ui_LAP & 0xFFFFF0) | (ucdata & 0xF);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnCTInquiryStartClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- m_sBTCT.list = lbCTDisDevices->Items;
- m_cBT_CT_Obj.Set_InquiryTimeout( m_uiInquiryTimeout );
- // lbCTDisDevices->Clear();
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Inquiry progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_Inquiry;
- m_cBT_CT_Obj.REQ_Inquiry_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_Inquiry(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Inquiry successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Inquiry fail";
- Application->MessageBox( "Execution Failure : Inquiry", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop(false);
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_InquiryCancel;
- m_cBT_CT_Obj.REQ_Inquiry_Cancel_Start(m_sBTCT);
- sbCT->Panels->Items[0]->Text = (AnsiString)" Inquiry timeout";
- Application->MessageBox( "Execution Timeout : Inquiry", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Inquiry stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayInquiryBDList( void )
- {
- vector<S_BT_CT_RES> *pvCTRes = m_cBT_CT_Obj.Get_CtResVector();
- vector<S_BT_CT_RES>:: iterator iter;
- lbCTDisDevices->Clear();
- for( iter = pvCTRes->begin(); iter != pvCTRes->end(); iter++ )
- {
- if( iter->e_acl_status != BT_ACL_STATUS_SUCCESS )
- {
- AnsiString as_bd_addr;
- char str[3];
- for( int i=BD_ADDRESS_LEN-1; i>=0; i-- )
- {
- if( iter->s_bd_addr.uc_BD_Addr[i] <= 0x0F )
- sprintf( str, "0%X", iter->s_bd_addr.uc_BD_Addr[i] );
- else
- sprintf( str, "%X", iter->s_bd_addr.uc_BD_Addr[i] );
- AnsiString as_str(str);
- if( i != 0 )
- as_bd_addr+= as_str + ":";
- else
- as_bd_addr+= as_str;
- }
- lbCTDisDevices->Items->Add( as_bd_addr );
- }
- }
- }
- //---------------------------------------------------------------------------
- void TfrmBT::DisplayConnectBDList( void )
- {
- vector<S_BT_CT_RES> *pvCTRes = m_cBT_CT_Obj.Get_CtResVector();
- vector<S_BT_CT_RES>:: iterator iter;
- lbCTConDevices->Clear();
- for( iter = pvCTRes->begin(); iter != pvCTRes->end(); iter++ )
- {
- if( BT_ACL_STATUS_SUCCESS == iter->e_acl_status )
- {
- AnsiString as_bd_addr;
- char str[3];
- for( int i=BD_ADDRESS_LEN-1; i>=0; i-- )
- {
- if( iter->s_bd_addr.uc_BD_Addr[i] <= 0x0F )
- sprintf( str, "0%X", iter->s_bd_addr.uc_BD_Addr[i] );
- else
- sprintf( str, "%X", iter->s_bd_addr.uc_BD_Addr[i] );
- AnsiString as_str(str);
- if( i != 0 )
- as_bd_addr+= as_str + ":";
- else
- as_bd_addr+= as_str;
- }
- lbCTConDevices->Items->Add( as_bd_addr );
- }
- }
- }
- //--------------------------------------------------------------------------
- S_BD_ADDR TfrmBT::Get_BDAddrFromString( AnsiString as_str )
- {
- int iLD;
- // AnsiString as_bd_addr;
- S_BD_ADDR bd_addr;
- unsigned char str[BD_ADDRESS_LEN];
- AnsiString_Hex_To_Array_UnsignedChar( as_str, str, BD_ADDRESS_LEN, ':' );
- for( int i=0; i<BD_ADDRESS_LEN; i++ )
- { bd_addr.uc_BD_Addr[i] = str[BD_ADDRESS_LEN-i-1];
- }
- return bd_addr;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::edtCTInquiryTimeoutCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int uidata;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~10000000 ";
- text = edit->Text;
- if( !IsValidBTTimeout( text, uidata ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_uiInquiryTimeout = uidata * 1.28 * 1000;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btCTClearLogClick(TObject *Sender)
- {
- memCTResult->Clear();
- }
- //-------------------------------------------------------------------------
- void __fastcall TfrmBT::btnCTScanClick(TObject *Sender)
- {
- S_BT_SCAN scan;
- scan.e_scan_type = (E_BT_SCAN_TYPE) cbCTScanType->ItemIndex;
- scan.b_interlaced_inquiry_scan = cbCTInterlacedInquiryScan->Checked;
- scan.b_interlaced_page_scan = cbInterlacedPageScan->Checked;
- m_cBT_CT_Obj.Set_ScanParameter( scan );
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Set scan parameter progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_Scan;
- m_cBT_CT_Obj.REQ_Scan_Start( m_sBTCT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_CT_Scan(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter fail";
- Application->MessageBox( "Execution Failure : Set scan parameter", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter timeout";
- Application->MessageBox( "Execution Timeout : Set scan parameter", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::lbCTDisDevicesClick(TObject *Sender)
- {
- m_sCTACLBdAddr = Get_BDAddrFromString( lbCTDisDevices->Items->Strings[lbCTDisDevices->ItemIndex] );
- m_sSCOBdAddr = m_sCTACLBdAddr;
- ReDrawCTFields( DRAM_MASK_CT_ACL_BDADDR |
- DRAM_MASK_CT_SCO_BDADDR |
- DRAM_MASK_CT_ACL_STATUS |
- DRAM_MASK_CT_SCO_STATUS |
- DRAM_MASK_CT_BUTTON);
- }
- //---------------------------------------------------------------------------
- unsigned short TfrmBT::Get_CTAclPacketType( void )
- {
- unsigned short pkt_type=0;
- if( cbCTDM1->Checked )
- { pkt_type |= ACL_PKT_MASK_DM1;
- }
- if( cbCTDH1->Checked )
- { pkt_type |= ACL_PKT_MASK_DH1;
- }
- if( cbCTDM3->Checked )
- { pkt_type |= ACL_PKT_MASK_DM3;
- }
- if( cbCTDH3->Checked )
- { pkt_type |= ACL_PKT_MASK_DH3;
- }
- if( cbCTDM5->Checked )
- { pkt_type |= ACL_PKT_MASK_DM5;
- }
- if( cbCTDH5->Checked )
- { pkt_type |= ACL_PKT_MASK_DH5;
- }
- // BT 2.0
- if( ! cbCT2DH1->Checked )
- { pkt_type |= ACL_PKT_MASK_2DH1;
- }
- if( ! cbCT3DH1->Checked )
- { pkt_type |= ACL_PKT_MASK_3DH1;
- }
- if( ! cbCT2DH3->Checked )
- { pkt_type |= ACL_PKT_MASK_2DH3;
- }
- if( ! cbCT3DH3->Checked )
- { pkt_type |= ACL_PKT_MASK_3DH3;
- }
- if( ! cbCT2DH5->Checked )
- { pkt_type |= ACL_PKT_MASK_2DH5;
- }
- if( ! cbCT3DH5->Checked )
- { pkt_type |= ACL_PKT_MASK_3DH5;
- }
- return pkt_type;
- }
- //---------------------------------------------------------------------------
- E_SCO_PKT_MASK TfrmBT::Get_ScoPacketType( void )
- {
- return (E_SCO_PKT_MASK) cbCTSCOPktType->ItemIndex;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTConnectACLClick(TObject *Sender)
- {
- if ((!cbCTDM1->Checked) &&
- (!cbCTDH1->Checked) &&
- (!cbCTDM3->Checked) &&
- (!cbCTDH3->Checked) &&
- (!cbCTDM5->Checked) &&
- (!cbCTDH5->Checked) &&
- (!cbCT2DH1->Checked) &&
- (!cbCT2DH3->Checked) &&
- (!cbCT2DH5->Checked) &&
- (!cbCT3DH1->Checked) &&
- (!cbCT3DH3->Checked) &&
- (!cbCT3DH5->Checked)
- )
- {
- Application->MessageBox("Please select at least one ACL packet type", "WARRNING", MB_OK);
- Application->BringToFront();
- return;
- }
- if (m_stCTACLBDAddr->Caption.AnsiCompareIC("") == 0)
- {
- Application->MessageBox("BD address is incorrect", "WARRNING", MB_OK);
- Application->BringToFront();
- return;
- }
- S_BT_CONNECT_ACL connect;
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- connect.us_acl_pkt_type = Get_CTAclPacketType();
- connect.s_bd_addr = m_sCTACLBdAddr;
- m_cBT_CT_Obj.Set_ConnectACLParameter(connect);
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Connect ACL link progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_ConnectACL;
- m_cBT_CT_Obj.REQ_ConnectACL_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_ConnectACL(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- CurrentPageReset();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- 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 ACL link successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link fail";
- Application->MessageBox( "Execution Failure : Connect ACL link", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link timeout";
- Application->MessageBox( "Execution Timeout : Connect ACL link", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link stop";
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnCTInquiryStopClick(TObject *Sender)
- {
- Force_BT_Stop( false );
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Cancel inquiry progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_InquiryCancel;
- m_cBT_CT_Obj.REQ_Inquiry_Cancel_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_InquiryCancel(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Cancel inquiry successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Cancel inquiry fail";
- Application->MessageBox( "Execution Failure : Cancel inquiry", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayInquiryBDList();
- sbCT->Panels->Items[0]->Text = (AnsiString)" Cancel inquiry timeout";
- Application->MessageBox( "Execution Timeout : Cancel inquiry", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- DisplayInquiryBDList();
- sbCT->Panels->Items[0]->Text = (AnsiString)" Cancel inquiry stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::btnCTAutoAcceptClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Auto accept progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_AutoAccept;
- m_cBT_CT_Obj.REQ_Auto_Accept_Start( m_sBTCT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_CT_AutoAccept(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Auto accept successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Auto accept fail";
- Application->MessageBox( "Execution Failure : Auto accept", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Auto accept timeout";
- Application->MessageBox( "Execution Timeout : Auto accept", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Auto accept stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTDisconnectACLClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- S_BT_DISCONNECT_ACL disconnect;
- disconnect.s_bd_addr = m_sCTACLBdAddr;
- m_cBT_CT_Obj.Set_DisconnectACLParameter( disconnect );
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Disconnect progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_DisconnectACL;
- m_cBT_CT_Obj.REQ_DisconnectACL_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_DisconnectACL(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- 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 successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect fail";
- Application->MessageBox( "Execution Failure : Disconnect", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect timeout";
- Application->MessageBox( "Execution Timeout : Disconnect", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::lbCTConDevicesClick(TObject *Sender)
- {
- m_sCTACLBdAddr = Get_BDAddrFromString( lbCTConDevices->Items->Strings[lbCTConDevices->ItemIndex] );
- m_sSCOBdAddr = m_sCTACLBdAddr;
- ReDrawCTFields( DRAM_MASK_CT_ACL_BDADDR |
- DRAM_MASK_CT_SCO_BDADDR |
- DRAM_MASK_CT_ACL_STATUS |
- DRAM_MASK_CT_SCO_STATUS |
- DRAM_MASK_CT_BUTTON);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnCTChangeAclPktTypeClick(TObject *Sender)
- {
- if( (! cbCTDM1->Checked) &&
- (! cbCTDH1->Checked) &&
- (! cbCTDM3->Checked) &&
- (! cbCTDH3->Checked) &&
- (! cbCTDM5->Checked) &&
- (! cbCTDH5->Checked)
- )
- {
- Application->MessageBox( "Please select at least one ACL packet type", "WARRNING", MB_OK );
- Application->BringToFront();
- return;
- }
- S_BT_CONNECT_ACL connect;
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- connect.us_acl_pkt_type = Get_CTAclPacketType();
- connect.s_bd_addr = m_sCTACLBdAddr;
- m_cBT_CT_Obj.Set_ConnectACLParameter( connect );
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Change ACL packet type progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_ChangeACLPacketType;
- m_cBT_CT_Obj.REQ_Change_ACL_Packet_Type_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_ChangeACLPacketType(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type fail";
- Application->MessageBox( "Execution Failure : Change ACL packet type", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type timeout";
- Application->MessageBox( "Execution Timeout : Change ACL packet type", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTConnectSCOClick(TObject *Sender)
- {
- if (m_stCTSCOBDAddr->Caption.AnsiCompareIC("") == 0)
- {
- Application->MessageBox("BD address is incorrect", "WARRNING", MB_OK);
- Application->BringToFront();
- return;
- }
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Connect SCO link progressing";
- S_BT_CT_CONNECT_SCO connect;
- connect.s_bd_addr = m_sSCOBdAddr;
- connect.e_pkt_type = Get_ScoPacketType();
- m_cBT_CT_Obj.Set_ConnectSCOParameter(connect);
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_ConnectSCO;
- m_cBT_CT_Obj.REQ_ConnectSCO_Start( m_sBTCT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_ConnectSCO(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- ReDrawCTFields( DRAM_MASK_CT_SCO_STATUS | DRAM_MASK_CT_BUTTON );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect SCO link successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect SCO link fail";
- Application->MessageBox( "Execution Failure : Connect SCO link ", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect SCO link timeout";
- Application->MessageBox( "Execution Timeout : Connect SCO link ", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Connect SCO link stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnCTDisconnectSCOClick(TObject *Sender)
- {
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- S_BT_CT_DISCONNECT_SCO disconnect;
- disconnect.s_bd_addr = m_sSCOBdAddr;
- m_cBT_CT_Obj.Set_DisconnectSCOParameter(disconnect);
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Disconnect SCO link progressing";
- m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_DisconnectSCO;
- m_cBT_CT_Obj.REQ_DisconnectSCO_Start(m_sBTCT);
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_DisconnectSCO(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- ReDrawCTFields(DRAM_MASK_CT_SCO_STATUS | DRAM_MASK_CT_BUTTON);
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect SCO link successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect SCO link fail";
- Application->MessageBox("Execution Failure : Disconnect SCO link ", "FAILURE", MB_OK);
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop(false);
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect SCO link timeout";
- Application->MessageBox("Execution Timeout : Disconnect SCO link ", "TIMEOUT", MB_OK);
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Disconnect SCO link stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //-------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTPINCheck(TObject *Sender)
- {
- AnsiString text;
- S_BT_PIN pin;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0x0~0xFFFFFFFFFFFFFFFF ";
- text = edit->Text;
- if( !IsValidHexBTPIN( text, pin ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sBTPIN = pin;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnCTEnterPINClick(TObject *Sender)
- {
- S_BT_ENTER_PIN enter_pin;
- m_sBTCT.hPostMsgDestHandle = this->Handle;
- m_sBTCT.log = m_pCTLog;
- enter_pin.s_bd_addr = m_sSCOBdAddr;
- enter_pin.s_bt_pin = m_sBTPIN;
- m_cBT_CT_Obj.Set_EnterPINParameter( enter_pin );
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Enter PIN progressing";
- // m_cBT_CT_Obj.ConfirmCallback = ::CNF_CT_EnterPIN;
- if( ! m_cBT_CT_Obj.REQ_EnterPIN_Start( m_sBTCT ) )
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN successfully";
- return;
- }
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN fail";
- }
- //-----------------------------------------
- void TfrmBT::CNF_CT_EnterPIN(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_CT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN fail";
- Application->MessageBox( "Execution Failure : Enter PIN ", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN timeout";
- Application->MessageBox( "Execution Timeout : Enter PIN ", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Enter PIN stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //============================================================================
- /////////////////////////// Throughput test ////////////////////////////////
- //============================================================================
- void TfrmBT::ReDrawTTFields( E_DRAM_MASK_TT draw_mask )
- {
- if( draw_mask & DRAM_MASK_TT_ACL_STATUS )
- {
- switch( m_sBTTTRes.e_acl_status )
- {
- case BT_ACL_STATUS_SUCCESS:
- stTTACLStatus->Caption = (AnsiString ) STR_BT_ACL_SUCCESS;
- break;
- case BT_ACL_STATUS_PAGE_TIMEOUT:
- stTTACLStatus->Caption = (AnsiString ) STR_BT_ACL_PAGE_TIMEOUT;
- break;
- case BT_ACL_STATUS_FAIL:
- stTTACLStatus->Caption = (AnsiString ) STR_BT_ACL_FAIL;
- break;
- default:
- case BT_ACL_STATUS_NONE:
- stTTACLStatus->Caption = (AnsiString ) "";
- break;
- }
- }
- if( draw_mask & DRAM_MASK_TT_BUTTON )
- {
- int acl_result = stTTACLStatus->Caption.AnsiCompareIC(STR_BT_ACL_SUCCESS);
- btnTTScan->Enabled = true;
- btnTTAutoAccept->Enabled = true;
- btnTTConnect->Enabled = (bool) acl_result;
- btnTTDisconnect->Enabled = ! (bool) acl_result;
- btnTTChangeACLPacketType->Enabled = ! (bool) acl_result;
- btnTTTxStart->Enabled = ! (bool) acl_result;
- btnTTTxStart->Tag = 0;
- btnTTRxStart->Enabled = ! (bool) acl_result;
- btnTTRxStart->Tag = 0;
- }
- }
- //----------------------------------------------------------------------------
- bool TfrmBT::CheckTTFields( E_CHECK_MASK_TT mask )
- {
- if( CHECK_MASK_TT_BD_ADDR == mask )
- {
- AnsiString text;
- text = edtTTBDAddr->Text; if( !IsValidHexBDAddress( text, m_sTTACLBdAddr ) ) { edtTTBdAddrCheck(edtTTBDAddr); return false; }
- }
- else if( CHECK_MASK_TT_TX == mask )
- {
- }
- return true;
- }
- //----------------------------------------------------------------------------
- void TfrmBT::FillTTResult( void )
- {
- for(int i=0; i<m_pTTLog->Count; i++ )
- {
- AnsiString as = m_pTTLog->Strings[i];
- memTTResult->Lines->Add( as );
- }
- m_pTTLog->Clear();
- }
- //----------------------------------------------------------------------------
- unsigned short TfrmBT::Get_TTAclPacketType( void )
- {
- unsigned short pkt_type=0;
- if( cbTTDM1->Checked )
- { pkt_type |= ACL_PKT_MASK_DM1;
- }
- if( cbTTDH1->Checked )
- { pkt_type |= ACL_PKT_MASK_DH1;
- }
- if( cbTTDM3->Checked )
- { pkt_type |= ACL_PKT_MASK_DM3;
- }
- if( cbTTDH3->Checked )
- { pkt_type |= ACL_PKT_MASK_DH3;
- }
- if( cbTTDM5->Checked )
- { pkt_type |= ACL_PKT_MASK_DM5;
- }
- if( cbTTDH5->Checked )
- { pkt_type |= ACL_PKT_MASK_DH5;
- }
- return pkt_type;
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTTConnectClick(TObject *Sender)
- {
- if ((!cbTTDM1->Checked) &&
- (!cbTTDH1->Checked) &&
- (!cbTTDM3->Checked) &&
- (!cbTTDH3->Checked) &&
- (!cbTTDM5->Checked) &&
- (!cbTTDH5->Checked) &&
- (!m_cbTT2DH1->Checked) &&
- (!m_cbTT2DH3->Checked) &&
- (!m_cbTT2DH5->Checked) &&
- (!m_cbTT3DH1->Checked) &&
- (!m_cbTT3DH3->Checked) &&
- (!m_cbTT3DH5->Checked)
- )
- {
- Application->MessageBox( "Please select at least one ACL packet type", "WARRNING", MB_OK );
- Application->BringToFront();
- return;
- }
- if( ! CheckTTFields( CHECK_MASK_TT_BD_ADDR ) )
- {
- return;
- }
- S_BT_CONNECT_ACL connect;
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- connect.us_acl_pkt_type = Get_TTAclPacketType();
- connect.s_bd_addr = m_sTTACLBdAddr;
- m_cBT_TT_Obj.Set_ConnectACLParameter( connect );
- CurrentPageLock();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Connect ACL link progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_ConnectACL;
- m_cBT_TT_Obj.REQ_ConnectACL_Start( m_sBTTT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_TT_ConnectACL(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- CurrentPageReset();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- 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 ACL link successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link fail";
- Application->MessageBox( "Execution Failure : Connect ACL link", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link timeout";
- Application->MessageBox( "Execution Timeout : Connect ACL link", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Connect ACL link stop";
- }
- break;
- }
- }
- //----------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTTDisconnectClick(TObject *Sender)
- {
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- S_BT_DISCONNECT_ACL disconnect;
- disconnect.s_bd_addr = m_sTTACLBdAddr;
- m_cBT_TT_Obj.Set_DisconnectACLParameter( disconnect );
- CurrentPageLock();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Disconnect progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_DisconnectACL;
- m_cBT_TT_Obj.REQ_DisconnectACL_Start( m_sBTTT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_TT_DisconnectACL(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- 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 successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Disconnect fail";
- Application->MessageBox( "Execution Failure : Disconnect", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Disconnect timeout";
- Application->MessageBox( "Execution Timeout : Disconnect", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Disconnect stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtTTDataLenCheck(TObject *Sender)
- {
- bool ok;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- unsigned short us_data;
- AnsiString as_hint[] = {" value should be 1~339 ", " value should be 1~1021 "};
- text = edit->Text;
- if (BTMODULE_MT6611 != m_cBtId)
- {
- ok = IsValidBTTxDataLength(text, us_data, 1, 339);
- }
- else
- {
- ok = IsValidBTTxDataLength(text, us_data, 1, 1021);
- }
- if (!ok)
- {
- if (BTMODULE_MT6611 != m_cBtId)
- {
- edit->Text = IntToStr(339);
- ShowHintLabel( edit, as_hint[0].c_str());
- }
- else
- {
- edit->Text = IntToStr(1021);
- ShowHintLabel( edit, as_hint[1].c_str());
- }
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtTTPacketCountCheck(TObject *Sender)
- {
- unsigned int ui_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " value should be 0~4294967295 "
- };
- text = edit->Text;
- if( !IsValidBTTxPacketCount( text, ui_data ) )
- {
- edit->Text = 1000;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTTChangeACLPacketTypeClick(TObject *Sender)
- {
- if( (! cbTTDM1->Checked) &&
- (! cbTTDH1->Checked) &&
- (! cbTTDM3->Checked) &&
- (! cbTTDH3->Checked) &&
- (! cbTTDM5->Checked) &&
- (! cbTTDH5->Checked)
- )
- {
- Application->MessageBox( "Please select at least one ACL packet type", "WARRNING", MB_OK );
- Application->BringToFront();
- return;
- }
- S_BT_CONNECT_ACL connect;
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- connect.us_acl_pkt_type = Get_TTAclPacketType();
- connect.s_bd_addr = m_sTTACLBdAddr;
- m_cBT_TT_Obj.Set_ConnectACLParameter( connect );
- CurrentPageLock();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Change ACL packet type progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_ChangeACLPacketType;
- m_cBT_TT_Obj.REQ_Change_ACL_Packet_Type_Start( m_sBTTT );
- }
- //-----------------------------------------
- void TfrmBT::CNF_TT_ChangeACLPacketType(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type fail";
- Application->MessageBox( "Execution Failure : Change ACL packet type", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type timeout";
- Application->MessageBox( "Execution Timeout : Change ACL packet type", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Change ACL packet type stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmBT::btnTTTxStartClick(TObject *Sender)
- {
- CurrentPageLock();
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- stTTTxCount->Caption = "0";
- stTTTxThroughput->Caption = "0";
- S_BT_TT_TX_PARAMETER tx_par;
- tx_par.us_data_len = edtTTDataLen->Text.ToInt();
- tx_par.us_packet_count = edtTTPacketCount->Text.ToInt();
- m_cBT_TT_Obj.Set_TxParameter( tx_par );
- m_sTTTxStartTime = ::Get_CurrentTime();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Transmit BT data progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_TxData;
- m_cBT_TT_Obj.REQ_TX_Data_Start(m_eTtVer, m_sBTTT);
- }
- //----------------------------------
- void TfrmBT::CNF_TT_TxData(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Transmit BT data successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Transmit BT data fail";
- Application->MessageBox( "Execution Failure : Transmit BT data", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Transmit BT data timeout";
- Application->MessageBox( "Execution Timeout : Transmit BT data", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Transmit BT data stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::edtTTBdAddrCheck(TObject *Sender)
- {
- S_BD_ADDR bd_addr;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] =
- { " BD address is not valid "
- };
- text = edit->Text;
- if( !IsValidHexBDAddress( text, bd_addr ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sTTACLBdAddr = bd_addr;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTTRxStartClick(TObject *Sender)
- {
- CurrentPageLock();
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- stTTRxBytes->Caption = "0";
- stTTRxThroughput->Caption = "0";
- m_sTTRxStartTime = ::Get_CurrentTime();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Receive BT data progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_RxData;
- m_cBT_TT_Obj.REQ_RX_Data_Start(m_eTtVer, m_sBTTT);
- }
- //----------------------------------
- void TfrmBT::CNF_TT_RxData(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch( state )
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Receive BT data successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Receive BT data fail";
- Application->MessageBox( "Execution Failure : Receive BT data", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Receive BT data timeout";
- Application->MessageBox( "Execution Timeout : Receive BT data", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Receive BT data stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::btnTTScanClick(TObject *Sender)
- {
- S_BT_SCAN scan;
- scan.e_scan_type = (E_BT_SCAN_TYPE) cbCTScanType->ItemIndex;
- scan.b_interlaced_inquiry_scan = cbCTInterlacedInquiryScan->Checked;
- scan.b_interlaced_page_scan = cbInterlacedPageScan->Checked;
- m_cBT_TT_Obj.Set_ScanParameter( scan );
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- CurrentPageLock();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Set scan parameter progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_CT_Scan;
- m_cBT_TT_Obj.REQ_Scan_Start( m_sBTTT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_TT_Scan(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter fail";
- Application->MessageBox( "Execution Failure : Set scan parameter", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter timeout";
- Application->MessageBox( "Execution Timeout : Set scan parameter", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Set scan parameter stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::btnTTAutoAcceptClick(TObject *Sender)
- {
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- CurrentPageLock();
- sbTT->Panels->Items[0]->Text = (AnsiString) " Auto accept progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_AutoAccept;
- m_cBT_TT_Obj.REQ_Auto_Accept_Start( m_sBTTT );
- }
- //---------------------------------------------
- void TfrmBT::CNF_TT_AutoAccept(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Auto accept successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Auto accept fail";
- Application->MessageBox( "Execution Failure : Auto accept", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbCT->Panels->Items[0]->Text = (AnsiString)" Auto accept timeout";
- Application->MessageBox( "Execution Timeout : Auto accept", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Auto accept stop";
- }
- break;
- }
- CurrentPageReset();
- }
- void __fastcall TfrmBT::btnTTTxStopClick(TObject *Sender)
- {
- m_cBT_TT_Obj.REQ_Stop_Start();
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTTxBandwidthCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int ui_data;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0x0~0xFFFFFFFF ";
- text = edit->Text;
- if( !IsValidTxBandwidth( text, ui_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_uiTxBandwidth = ui_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTRxBandwidthCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned int ui_data;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0x0~0xFFFFFFFF ";
- text = edit->Text;
- if( !IsValidRxBandwidth( text, ui_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_uiRxBandwidth = ui_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTMaxLatencyCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned short us_data;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0x0~0xFFFF ";
- text = edit->Text;
- if( !IsValidMaxLatency( text, us_data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_usMaxLatency = us_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::edtCTRetransmitEffortCheck(TObject *Sender)
- {
- AnsiString text;
- unsigned char uc_data;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0x0~0xFF ";
- text = edit->Text;
- if (!IsValidRetransmissionEffort(text, uc_data))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_ucRetransmissionEffort = uc_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::btnTTRxStopClick(TObject *Sender)
- {
- CurrentPageLock();
- m_sBTTT.hPostMsgDestHandle = this->Handle;
- m_sBTTT.log = m_pTTLog;
- sbTT->Panels->Items[0]->Text = (AnsiString) " Stop Receiving BT data progressing";
- m_cBT_TT_Obj.ConfirmCallback = ::CNF_TT_Stop_RxData;
- m_cBT_TT_Obj.REQ_Stop_RX_Data_Start(m_sBTTT);
- }
- //----------------------------------
- void TfrmBT::CNF_TT_Stop_RxData(void)
- {
- E_METAAPP_RESULT_T state = m_cBT_TT_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Stop Receiving BT data successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Stop Receiving BT data fail";
- Application->MessageBox( "Execution Failure : Stop Receiving BT data", "FAILURE", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- Force_BT_Stop( false );
- sbTT->Panels->Items[0]->Text = (AnsiString)" Stop Receiving BT data timeout";
- Application->MessageBox( "Execution Timeout : Stop Receiving BT data", "TIMEOUT", MB_OK );
- Application->BringToFront();
- }
- break;
- case METAAPP_CANCEL:
- case METAAPP_STOP:
- {
- sbTT->Panels->Items[0]->Text = (AnsiString)" Stop Receiving BT data stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbPKTCOMChange(TObject *Sender)
- {
- AbortConnectWithTarget();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::cbPKTBaudRateChange(TObject *Sender)
- {
- AbortConnectWithTarget();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::m_tmMTTimer(TObject *Sender)
- {
- m_tmMT->Enabled = false;
- // Add Logging String
- Script[ActIdx]->TimerTick();
- //int len = strlen(Script[ActIdx]->LogString);
- int len = Script[ActIdx]->Get_LogStringLen();
- if (len >= 2)
- {
- // if (Script[ActIdx]->LogString[len-2] == 'n')
- if (Script[ActIdx]->Get_LogString(len-2) == 'n')
- {
- //Script[ActIdx]->LogString[len-2] = 0;
- Script[ActIdx]->Set_LogString(len-2, 0);
- }
- //m_edtMTLog->Lines->Add(Script[ActIdx]->LogString);
- m_edtMTLog->Lines->Add(Script[ActIdx]->Get_LogString());
- }
- // Update progress group
- //if (Script[ActIdx]->LastProc!=Script[ActIdx]->CurProc)
- if (Script[ActIdx]->Get_LastProc() != Script[ActIdx]->Get_CurProc())
- {
- UpdateProcessGroup();
- //Script[ActIdx]->LastProc = Script[ActIdx]->CurProc;
- Script[ActIdx]->Set_LastProc(Script[ActIdx]->Get_CurProc());
- m_edtMTLog->Lines->Clear();
- }
- // Exit Timer
- //if (Script[ActIdx]->ErrorCode != ERR_FILEEND)
- if (Script[ActIdx]->Get_ErrorCode() != ERR_FILEEND)
- {
- m_tmMT->Enabled = true;
- }
- else // End of this testing
- {
- m_tmMT->Enabled = false;
- m_btnMTRunClick(0);
- // if (Script[ActIdx]->FailCount != 0)
- if (Script[ActIdx]->Get_FailCount() != 0)
- {
- m_lblMTStatus->Font->Color = clRed;
- m_lblMTStatus->Caption = "FAIL";
- //m_edtMTLog->Lines->Add(Script[ActIdx]->LogString);
- m_edtMTLog->Lines->Add(Script[ActIdx]->Get_LogString());
- }
- else
- {
- m_lblMTStatus->Font->Color = clBlue;
- m_lblMTStatus->Caption = "PASS";
- }
- if ((LoopCount > 0) && (LoopCount != 99999))
- {
- LoopCount--;
- }
- if (LoopCount != 0)
- {
- m_edtMTRepeat->Text = LoopCount;
- scrTestItemList->Position = scrTestItemList->Min;
- m_btnMTRunClick(0);
- }
- }
- }
- //---------------------------------------------------------------------------
- int TfrmBT::UpdateProcessGroup(void)
- {
- int n, base;
- char str[256];
- int cidx = ActIdx;
- CBTMT *scr = Script[cidx];
- //grpTestItemList->Caption = scr->Title;
- grpTestItemList->Caption = scr->Get_Title();
- scrTestItemList->Min = 0;
- //n = scr->ProcCount - BT_MT_MAX_PROC_NUM;
- n = scr->Get_ProcCount() - BT_MT_MAX_PROC_NUM;
- scrTestItemList->Max = (n>0) ? n : 0;
- if (m_btnMTRun->Tag) //Running
- {
- //base = (scr->CurProc < BT_MT_MAX_PROC_NUM) ? 0 : (scr->CurProc-BT_MT_MAX_PROC_NUM+1);
- base = (scr->Get_CurProc() < BT_MT_MAX_PROC_NUM) ? 0 : (scr->Get_CurProc() - BT_MT_MAX_PROC_NUM + 1);
- }
- else
- {
- base = scrTestItemList->Position;
- }
- for (n=0; n<BT_MT_MAX_PROC_NUM; n++)
- {
- //if (base + n >= scr->CurProc)
- if (base + n >= scr->Get_CurProc())
- {
- break;
- }
- //if (scr->ProcFail[base+n] != 0)
- if (scr->Get_ProcFail(base+n) != 0)
- {
- lblItem[n]->Font->Color = clRed;
- lblItem[n]->Font->Style = TFontStyles()<< fsBold ;
- //sprintf(str, "%s (Fail)", scr->ProcName[base+n]);
- sprintf(str, "%s (Fail)", scr->Get_ProcName(base+n));
- lblItem[n]->Caption = str;
- lblItem[n]->Visible = true;
- }
- else
- {
- lblItem[n]->Font->Color = clBlue;
- lblItem[n]->Font->Style = TFontStyles()<< fsBold ;
- //sprintf(str, "%s (Pass)", scr->ProcName[base+n]);
- sprintf(str, "%s (Pass)", scr->Get_ProcName(base+n));
- lblItem[n]->Caption = str;
- lblItem[n]->Visible = true;
- }
- }
- if (n < BT_MT_MAX_PROC_NUM)
- {
- //if (base+n == scr->CurProc)
- if (base+n == scr->Get_CurProc())
- {
- lblItem[n]->Font->Color = clBlack;
- lblItem[n]->Font->Style = TFontStyles()<< fsBold ;
- //sprintf(str, "%s", scr->ProcName[base+n]);
- sprintf(str, "%s", scr->Get_ProcName(base+n));
- lblItem[n]->Caption = str;
- lblItem[n]->Visible = true;
- n++;
- }
- }
- for (; n<BT_MT_MAX_PROC_NUM; n++)
- {
- //if (base+n < scr->ProcCount)
- if (base+n < scr->Get_ProcCount())
- {
- lblItem[n]->Font->Color = clBlack;
- lblItem[n]->Font->Style = TFontStyles();
- //sprintf(str, "%s", scr->ProcName[base+n]);
- sprintf(str, "%s", scr->Get_ProcName(base+n));
- lblItem[n]->Caption = str;
- lblItem[n]->Visible = true;
- }
- else
- {
- lblItem[n]->Visible = false;
- }
- }
- return(1);
- }
- //---------------------------------------------------------------------------
- int TfrmBT::ReloadScriptFiles(void)
- {
- int ok;
- char str[256];
- FILE *fs ;
- scrTestItemList->LargeChange = BT_MT_MAX_PROC_NUM;
- for (int n=0; n < BT_MT_TESTCASE_NUM; n++)
- {
- sprintf(str, "Item%d.txt", n+1);
- fs = fopen(str, "r");
- if (NULL == fs)
- {
- if (Script[n] != NULL)
- {
- delete Script[n];
- }
- Script[n] = 0;
- m_rbTestItem[n]->Caption = "TBD";
- m_rbTestItem[n]->Enabled = false;
- continue;
- }
- fclose(fs);
- if (Script[n] != NULL)
- {
- delete Script[n];
- }
- Script[n] = new CBTMT;
- ok = Script[n]->OpenScript(str);
- if (!ok)
- {
- if(Script[n]!=NULL) delete Script[n];
- Script[n] = 0;
- m_rbTestItem[n]->Caption = "TBD";
- m_rbTestItem[n]->Enabled = false;
- continue;
- }
- //m_rbTestItem[n]->Caption = Script[n]->Title;
- m_rbTestItem[n]->Caption = Script[n]->Get_Title();
- m_rbTestItem[n]->Enabled = true;
- if(ActIdx<0) ActIdx = n;
- }
- m_rbTestItem[ActIdx]->Checked = true;
- // btnCheckCOMClick(this);
- return(1);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::m_btnMTReloadClick(TObject *Sender)
- {
- ReloadScriptFiles();
- UpdateProcessGroup();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::m_btnMTRunClick(TObject *Sender)
- {
- TSpeedButton* btn;
- btn = (Sender!=0) ? (TSpeedButton*)Sender : m_btnMTRun;
- if (0 == btn->Tag)
- {
- btn->Tag = 1;
- btn->Caption = "Stop";
- for (int n = 0; n < BT_MT_TESTCASE_NUM; n++)
- {
- m_rbTestItem[n]->Enabled = false;
- }
- Script[ActIdx]->Set_BTTrans(0, BT_META);
- if (m_cbMETAMode->Checked)
- {
- Script[ActIdx]->Set_BTTrans(1, BT_META);
- }
- else
- {
- Script[ActIdx]->Set_ComPort(m_usComPortArray[m_cbMTBT2COM->ItemIndex]);
- Script[ActIdx]->Set_BTTrans(1, BT_RS232);
- }
- m_lblMTStatus->Font->Color = clBlue;
- m_lblMTStatus->Caption = "RUNNING";
- Script[ActIdx]->Reset();
- m_edtMTLog->Lines->Clear();
- m_tmMT->Enabled =true;
- }
- else
- {
- btn->Tag = 0;
- m_tmMT->Enabled =false;
- btn->Caption = "Run";
- for (int n=0; n<BT_MT_TESTCASE_NUM; n++)
- {
- m_rbTestItem[n]->Enabled = (Script[n]!=0);
- }
- m_lblMTStatus->Font->Color = clBlack;
- m_lblMTStatus->Caption = "STOP";
- Script[ActIdx]->CloseScript();
- UpdateProcessGroup();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::m_btnMTConnectClick(TObject *Sender)
- {
- m_shpMTConnect->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::m_cbMETAModeClick(TObject *Sender)
- {
- m_btnMTConnect->Enabled = m_cbMETAMode->Checked;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmBT::scrTestItemListChange(TObject *Sender)
- {
- UpdateProcessGroup();
- }
- //---------------------------------------------------------------------------