?? hcieventpacketproc.cpp
字號(hào):
//--------------------------------------------------------------- %FILH_BEG% --
//
// Project: $$ProjectName
//
// File name: HCIEventPacketProc.cpp
//
// Author:
// Description:
//
// Revision History:
// $Log: $
//
// rev 1.13 06/14/01 EK .Modified InquiryCompleteEvent() to comply with BlueTooth Spec 1.1
// .Display Line numbers for USB Console.
// rev 1.12 05/08/01 EK .Added timestamp routine to DebugInformationEvent() function to report
// it in the following format : hhh:mm:ss_mmm:uuu
// .Added ConLineCounter as Line counter to the console output
// rev 1.11 04/23/01 Ek .Changed ReturnLinkKeysEvent() to report all stored link keys in the target
// rev 1.10 03/22/01 Ek .Modified LinkKeyRequestevent() and PInCodeRequestEvent()
// Use CallTransmit() to send the command because of problem sending
// the same command (same BD_Addr)to different Units.Since we don't
// use dialog box for entries there is No need to use DoModal().
// rev 1.09 01/24/01 Ek .Added following parameters to CommandCompleteEvent :
// UartTl Header, ParamLength, Command OpCode
// rev 1.08 12/13/00 Ek .Remove \r from debug information for event type 00 in DebugInformationEvent()
// rev 1.07 11/10/00 Ek .Commented out pHCICommandTable[Index].CmdRetParamFunction for Status Display
// rev 1.06 10/16/00 Ek .Parsing Following Events
// PinCodeRequestEvent ,LinkKeyRequestEvent
// LinkKeyNotificationEvent,LoopbackCommandEvent
// DataBufferOverflowEvent
// MaxSlotsChangeEvent
// ChangeConnectionPacketTypeEvent
// QosViolationEvent
// PageScanRepeatationModeChangeEvent
//
// rev 1.05 10/13/00 Ek .Parsing Inquiry Complete Event , Inquiry Result Event and
// Connection complete Event, Connection request Event
// AuthenticationCompleteEvent,EncryptionChangeEvent
// ChangeConnectionLinkKeyCompleteEvent
// MasterLinkKeyCompleteEvent
// ReadRemoteSupportedFeaturesCompleteEvent
// ReadRemoteVersionInformationCompleteEvent
// QosSetupCompleteEvent,FlushOccuredEvent ,HardwareErrorEvent,
// NumberOfCompletedPacketsEvent
// ReturnLinkKeysEvent
// 10/06/00 Ek .Added DebugInformationEvent function to the list.
// Need to ask Charles to Add \r\n [0x0D,0x0A]
// (Carriage return First) in Firmware.
// rev 1.04 09/14/00 Ek Added Switch_Role to the list of Link policy Commands
// along with the Role change Event parsing.
// rev 1.03 09/13/00 Ek Added Hold Mode to the list of Link policy Commands
// along with the Mode change Event parsing.
// rev 1.02 09/12/00 EK Implemneted RemoteNameRequestCompleteEvent() function
// Rev 1.01 07/21/00 EK CmdType range is from (1 to 6) to fix "Vendor specific Commands"
// Rev 1.00 15 July 2000 Initial release
//
//
// Copyright (c) TelenComm Corporation 2000 - All rights reserved
//--------------------------------------------------------------- %FILH_END%
#include <string.h>
#include <stdio.h>
#include "..\..\..\stdafx.h"
#include "..\..\..\BTHost.h"
#include "..\..\Common\common.h"
#include "..\..\Inc\HCIError.h"
#include "..\..\Inc\HCIProc.h"
//#include "HCIErrorStrTable.h"
#include "..\..\Commands\Inc\HCIBaseCmdProc.h"
#include "..\Inc\HCIEventPacket.h"
#include "..\Inc\HCIEventFormFunctions.h"
#include "..\Inc\HCIEventProcFunctions.h"
#include "..\..\..\Comm\SerialCommunication.h"
#include "..\..\..\ConectionReqDlg.h"
#include "..\..\..\TextConsoleDlg1.h"
#include "..\..\..\LinkKeyPinCodeReq.h"
#include "..\..\..\PinCodeRequest.h"
#define REMOTE_NAME_SIZE 248
#define TS_LOGM_TEXT_MAX_SIZE 16
#define TS_LOGM_MAX_DATA_SIZE 24
extern UINT g_ComPortFlag; // Used for Serial or USB device Selection
extern bool g_TargetAssert;
extern int iCurPort1;
extern int iCurPort2;
int ConLineCounter[2];
//------------------------------------------------------------------------------
//
// 5.2.1 Inquiry Complete Event
//
//------------------------------------------------------------------------------
//BTLogicalIODevice* g_pBTLogicalIODevice;
struct sConnectedDeviceList
{
tConnectionHandle ConnectionHandle;
sBD_ADDR sDevAddr;
tLINK_TYPE tLinkType;
tENCRYPTION_MODE tEncryptionMode;
};
sConnectedDeviceList g_sConnectedDeviceList[10];
int g_ConnectedDeviceListNo=0;
uint8 HCI_EventsInterfaceProcFunctions::InquiryCompleteEvent(CHCI_EventPacket& rHCI_EventPacket)/*teHCI_EVENT_ERROR_CODE teStatus,uint8 u8NumResponses )*/
{
CString Temp;
CString EventCode;
CString StatusStr;
CString NumRes;
CString ParamStr;
char ErrorDef[40];
sInquiryCompleteEvent* psInqComEvent;
psInqComEvent = (sInquiryCompleteEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
if(psInqComEvent->Status ){
g_pChildFrame->ErrorDef((char *)(&psInqComEvent->Status), ErrorDef);
Temp.Format ("%.2X - %s", psInqComEvent->Status, ErrorDef);
}else
Temp.Format ("%.2X",psInqComEvent->Status );
StatusStr.Format ("\tStatus: [1] %s\n", Temp );
Temp.Empty();
ParamStr = StatusStr ;
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
//struct sInquiryResultEvent
//{
// uint8 NumResponses; // 1 Byte
// sBD_ADDR asDevAddr; // 6 Bytes [i]
// uint8 atPageScanRepetitionMode; // 1 Byte [i] ePageScanRepMode{}
// tPAGE_SCAN_PERIOD_MODE atPageScanPeriodMode; // 1 Byte [i]
// uint8 atPageScanMode; // 1 Byte [i] ePageScanMode{}
// sCLASS_OF_DEVICE asClassOfDevice; // 3 Bytes [i]
// tCLOCK_OFFSET atClockOffset; // 2 Bytes [i]
//}
uint8 HCI_EventsInterfaceProcFunctions::InquiryResultEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp; int n;
CString EventCode;
CString NumRes;
CString BD_ADDR;
CString PageScanRepMode;
CString PageScanPeriodMode;
CString PageScanMode;
CString ClassOfDevice;
CString ClockOffset;
CString ParamStr;
char buf1[20] = {'\0'};
char buf2[20] = {'\0'};
sInquiryResultEvent* psInquiryRes;
psInquiryRes = (sInquiryResultEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
Temp.Format ("%.2X", psInquiryRes->NUM_RESPONSES);
NumRes.Format ("\tNum_Responses: [%d] %s\n",sizeof(psInquiryRes->NUM_RESPONSES), Temp );
Temp.Empty();
BT_itoa(&psInquiryRes->asDevAddr ,6, buf1);
BT_ReverseStr(buf1, buf2);
Temp.Format ("%s", buf2); n = Temp.GetLength();
BD_ADDR.Format ("\tBD_ADDR: [%d] %s\n",sizeof(psInquiryRes->asDevAddr), Temp );
Temp.Empty();
Temp.Format ("%.2X", psInquiryRes->atPageScanRepetitionMode);
PageScanRepMode.Format("\tPageScanRepetitionMode: [%d] %s\n",sizeof(psInquiryRes->atPageScanRepetitionMode), Temp );
Temp.Empty();
Temp.Format ("%.2X", psInquiryRes->atPageScanPeriodMode);
PageScanPeriodMode.Format("\tPageScanPeriodMode: [%d] %s\n",sizeof(psInquiryRes->atPageScanPeriodMode), Temp );
Temp.Empty();
Temp.Format ("%.2X", psInquiryRes->atPageScanMode);
PageScanMode.Format ("\tPageScanMode: [%d] %s\n",sizeof(psInquiryRes->atPageScanMode), Temp );
Temp.Empty();
for(int i = 0; i < 20; i++) buf1[i] = buf2[i] = '\0';
BT_itoa(&psInquiryRes->asClassOfDevice ,3, buf1);
BT_ReverseStr(buf1, buf2);
Temp.Format ("%s", buf2);
ClassOfDevice.Format ("\tClassOfDevice: [%d] %s\n",sizeof(psInquiryRes->asClassOfDevice), Temp );
Temp.Empty();
Temp.Format ("%.4X", psInquiryRes->atClockOffset);
ClockOffset.Format ("\tClockOffset: [%d] %s\n",sizeof(psInquiryRes->atClockOffset), Temp );
ParamStr = EventCode + NumRes+ BD_ADDR+ PageScanRepMode + PageScanPeriodMode + PageScanMode + ClassOfDevice + ClockOffset;
Temp.Format("InquiryResult completion status: Completed\n");
g_pChildFrame->ParamListForOutput(Temp);
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
// struct sConnectionCompleteEvent
// {
// uint8 Status;
// tConnectionHandle ConnectionHandle;
// sBD_ADDR sDevAddr;
// tLINK_TYPE tLinkType;
// tENCRYPTION_MODE tEncryptionMode;
// };
uint8 HCI_EventsInterfaceProcFunctions::ConnectionCompleteEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp; int n;
CString EventCode;
CString Status;
CString ConHandle;
CString LinkType;
CString EncMode;
CString BD_ADDR;
CString ParamStr;
char buf1[20] = {'\0'}, buf2[20] = {'\0'};
char ErrorDef[40] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
sConnectionCompleteEvent* psConnection = (sConnectionCompleteEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
if(psConnection->Status) {
g_pChildFrame->ErrorDef((char *)(&psConnection->Status), ErrorDef);
Temp.Format ("%.2X - %s",psConnection->Status , ErrorDef);
}else
Temp.Format ("%.2X",psConnection->Status);
Status.Format ("\tStatus: [1] %s\n", Temp );
Temp.Empty();
Temp.Empty();
Temp.Format ("%.4X", psConnection->ConnectionHandle);
ConHandle.Format ("\tConnection Handle: [%d] %s\n",sizeof(psConnection->ConnectionHandle), Temp );
BT_itoa(&psConnection->sDevAddr ,6, buf1);
BT_ReverseStr(buf1, buf2);
Temp.Format ("%s", buf2); n = Temp.GetLength();
BD_ADDR.Format ("\tBD_ADDR: [%d] %s\n",sizeof(psConnection->sDevAddr), Temp );
Temp.Empty();
Temp.Format ("%.2X", psConnection->tLinkType);
LinkType.Format ("\tLink_Type: [%d] %s\n",sizeof(psConnection->tLinkType), Temp );
Temp.Empty();
Temp.Format ("%.2X", psConnection->tEncryptionMode);
EncMode.Format ("\tEncryption Mode: [%d] %s\n",sizeof(psConnection->tEncryptionMode), Temp );
ParamStr = Status + ConHandle + BD_ADDR + LinkType + EncMode;
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
uint8 HCI_EventsInterfaceProcFunctions::ConnectionRequestEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp; int n;
CString EventCode;
CString LinkType;
CString ClassOfDevice;
CString BD_ADDR;
CString ParamStr, str;
char buf1[15] = {'\0'},buf2[20] = {'\0'},buf3[10] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
sConnectionRequestEventParams* psConnectionRequestEventParams = (sConnectionRequestEventParams*)rHCI_EventPacket.GetHCI_EventPacketParam();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
BT_itoa(&psConnectionRequestEventParams->sDevAddr ,6, buf1);
BT_ReverseStr(buf1, buf2);
Temp.Format ("%s", buf2);
BD_ADDR.Format ("\tBD_ADDR: [%d] %s\n",sizeof(psConnectionRequestEventParams->sDevAddr), Temp );
for(int i = 0; i < 15; i++) buf1[i] = '\0';
for( i = 0; i < 20; i++) buf2[i] = '\0';
BT_itoa(&psConnectionRequestEventParams->sClassOfDevice ,3, buf1);
BT_ReverseStr(buf1, buf2);
Temp.Format ("%s", buf2); n = Temp.GetLength();
ClassOfDevice.Format ("\tClassOfDevice: [%d] %s\n",sizeof(psConnectionRequestEventParams->sClassOfDevice), Temp );
BT_itoa(&psConnectionRequestEventParams->tLinkType ,1, buf3);
Temp.Format ("%s", buf3); n = Temp.GetLength();
LinkType.Format ("\tLinkType: [%d] %s\n",sizeof(psConnectionRequestEventParams->tLinkType), Temp );
str.Format("\t%s\n","Received connection request from the following device:");
ParamStr = str + BD_ADDR + ClassOfDevice + LinkType;
g_pChildFrame->ParamListForOutput(ParamStr);
CConectionReqDlg ReqDlg(psConnectionRequestEventParams);
ReqDlg.DoModal();
// if( ComPortNo== COMPORT1 || ComPortNo== USBDEV1)
if( ComPortNo == iCurPort1)
{
g_pBTHostView1->BTHostView1_CommandToMaster = false; // Set To Unit 1
g_pBTHostView1->DisplayAndTransmitCmd(ReqDlg.m_strCmdName);
}
// else if( ComPortNo== COMPORT2 || ComPortNo== USBDEV2)
else if( ComPortNo == iCurPort2)
{
g_pBTHostView1->BTHostView1_CommandToMaster = true; // Set To Unit 2
//Ek g_pBTHostView2->DisplayAndTransmitCmd(ReqDlg.m_strCmdName);
g_pBTHostView1->DisplayAndTransmitCmd(ReqDlg.m_strCmdName);
}
//g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
//struct sDisconnectionCompleteEvent
// {
// uint8 Status;
// tConnectionHandle ConnectionHandle;
// tREASON tReason;
// };
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -