?? hcieventpacketproc.cpp
字號:
uint8 u8LMP_Version,
uint32 u16ManufacturerName,
uint8 u16LMP_Subversion
)*/
uint8 HCI_EventsInterfaceProcFunctions::ReadRemoteVersionInformationCompleteEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp; int n;
CString EventCode;
CString Status;
CString ConHandle;
CString LMP_Version;
CString ManName ;
CString LMP_SubVersion;
CString ParamStr;
char buf1[10] = {'\0'},buf2[10] = {'\0'},buf3[10] = {'\0'},buf4[10] = {'\0'},buf5[10] = {'\0'};
char ErrorDef[40] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
sReadRemoteVersionInformationCompleteEvent* psReadRemoteVersion = (sReadRemoteVersionInformationCompleteEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
if(psReadRemoteVersion->Status) {
g_pChildFrame->ErrorDef((char *)(&psReadRemoteVersion->Status), ErrorDef);
Temp.Format ("%.2X - %s", psReadRemoteVersion->Status, ErrorDef);
}else
Temp.Format ("%.2X",psReadRemoteVersion->Status);
Status.Format ("\tStatus: [%d] %s\n",sizeof(psReadRemoteVersion->Status), Temp );
Temp.Format ("%-.4X", psReadRemoteVersion->ConnectionHandle); n = Temp.GetLength();
ConHandle.Format ("\tConnectionHandle: [%d] %s\n",sizeof(psReadRemoteVersion->ConnectionHandle), Temp );
BT_itoa(&psReadRemoteVersion->u8LMP_Version ,1, buf3);
Temp.Format ("%s", buf3); n = Temp.GetLength();
LMP_Version.Format ("\tLMP_Version: [%d] %s\n",sizeof(psReadRemoteVersion->u8LMP_Version), Temp );
//BT_itoa(&psReadRemoteVersion->u16ManufacturerName ,2, buf4);
Temp.Format ("%-.4X", psReadRemoteVersion->u16ManufacturerName); n = Temp.GetLength();
ManName.Format ("\tManufacturer_Name: [%d] %s\n",sizeof(psReadRemoteVersion->u16ManufacturerName), Temp );
//BT_itoa(&psReadRemoteVersion->u16LMP_Subversion ,2, buf5);
Temp.Format ("%-.4X", psReadRemoteVersion->u16LMP_Subversion); n = Temp.GetLength();
LMP_SubVersion.Format("\tLMP_SubVersion: [%d] %s\n",sizeof(psReadRemoteVersion->u16LMP_Subversion), Temp );
ParamStr = EventCode + Status + ConHandle + LMP_Version + ManName + LMP_SubVersion ;
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
// /*teHCI_EVENT_ERROR_CODE teStatus,
// tConnectionHandle ConnectionHandle,
// uint8 u8Flags,
// uint8 u8ServiceType,
// uint32 u32TokenRate,
// uint32 u32PeakBW,
// uint32 u32Latency,
// uint32 u32DelayVariation
// )*/
uint8 HCI_EventsInterfaceProcFunctions::QosSetupCompleteEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp; int n;
CString EventCode;
CString Status;
CString ConHandle;
CString Flags;
CString ServiceType ;
CString TokenRate;
CString PeakBW;
CString Latency;
CString DelayVariation;
CString ParamStr;
char buf1[15] = {'\0'},buf2[10] = {'\0'},buf3[10] = {'\0'},buf4[10] = {'\0'};
char buf5[15] = {'\0'},buf6[15] = {'\0'},buf7[15] = {'\0'},buf8[15] = {'\0'};
char ErrorDef[40] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
sQosSetupCompleteEvent* psQosSetup = (sQosSetupCompleteEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
if(psQosSetup->Status) {
g_pChildFrame->ErrorDef((char *)(&psQosSetup->Status), ErrorDef);
Temp.Format ("%.2X - %s", psQosSetup->Status, ErrorDef);
}else
Temp.Format ("%.2X",psQosSetup->Status);
Status.Format ("\tStatus: [%d] %s\n",sizeof(psQosSetup->Status), Temp );
Temp.Format ("%-.4X", psQosSetup->ConnectionHandle); n = Temp.GetLength();
ConHandle.Format ("\tConnectionHandle: [%d] %s\n",sizeof(psQosSetup->ConnectionHandle), Temp );
BT_itoa(&psQosSetup->u8Flags ,1, buf3);
Temp.Format ("%s", buf3); n = Temp.GetLength();
Flags.Format ("\tFlags: [%d] %s\n",sizeof(psQosSetup->u8Flags), Temp );
BT_itoa(&psQosSetup->u8ServiceType ,1, buf4);
Temp.Format ("%s", buf4); n = Temp.GetLength();
ServiceType.Format ("\tSeviceType: [%d] %s\n",sizeof(psQosSetup->u8ServiceType), Temp );
for(int i =0; i < 15; i++) buf1[i] = '\0';
BT_itoa(&psQosSetup->u32TokenRate ,4, buf1);
BT_ReverseStr(buf1, buf5);
Temp.Format ("%s", buf5); n = Temp.GetLength();
TokenRate.Format ("\tTokenRate: [%d] %s\n",sizeof(psQosSetup->u32TokenRate), Temp );
for(i =0; i < 15; i++) buf1[i] = '\0';
BT_itoa(&psQosSetup->u32PeakBW ,4, buf1);
BT_ReverseStr(buf1, buf6);
Temp.Format ("%s", buf6); n = Temp.GetLength();
PeakBW.Format ("\tPeakBW: [%d] %s\n",sizeof(psQosSetup->u32PeakBW), Temp );
for(i =0; i < 15; i++) buf1[i] = '\0';
BT_itoa(&psQosSetup->u32Latency ,4, buf1);
BT_ReverseStr(buf1, buf7);
Temp.Format ("%s", buf7); n = Temp.GetLength();
Latency.Format ("\tLatency: [%d] %s\n",sizeof(psQosSetup->u32Latency), Temp );
for(i =0; i < 15; i++) buf1[i] = '\0';
BT_itoa(&psQosSetup->u32DelayVariation ,4, buf1);
BT_ReverseStr(buf1, buf8);
Temp.Format ("%s", buf8); n = Temp.GetLength();
DelayVariation.Format("\tDelay Variation: [%d] %s\n",sizeof(psQosSetup->u32DelayVariation), Temp );
ParamStr = EventCode + Status + ConHandle + Flags + ServiceType + TokenRate + PeakBW + Latency + DelayVariation ;
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
//------------------------------------------------------------------------------
//
// 5.2.14 Command Complete Event
//
//------------------------------------------------------------------------------
uint8 HCI_EventsInterfaceProcFunctions::CommandCompleteEvent(CHCI_EventPacket& rHCI_EventPacket)
{
int n;
int Index;
CString Temp;
CString Status;
CString CPacketAll;
CString EventCode;
CString OpCodeStr;
CString ParamStr;
CString UartTlStr;
sCommandCompleteEvent *psCmdCompEv;
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
psCmdCompEv = (sCommandCompleteEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 UartTl = rHCI_EventPacket.GetUartTl();
uint8 ParamLen = rHCI_EventPacket.GetParmLen();
g_NumHciCommandPackets = psCmdCompEv->NumHCI_CmdPkts;
int MaxNoOfCmds =0;
uint16 OpCode = (psCmdCompEv->u8CommandOpcode[1] << 8 )+(psCmdCompEv->u8CommandOpcode[0]);
//uint16 OpCode = (uint16)psCmdCompEv->u16CommandOpcode;
//msg.Format("Testing:[%X][%X]\n", (*psCmdCompEv),g_NumHciCommandPackets);//OpCode );
//g_pChildFrame->ParamListForOutput(msg);
int CmdType = GET_OGF(OpCode);
if (CmdType == 0x3F)
CmdType = 0x7 ; //;eVEND_SPEC_CMD // EK Vendor Specific Command
if(CmdType >=1 && CmdType <= 7) //Change the limit from 6 to 3F
{
Index = g_pHCIProcessor->FindHCICommandType(OpCode);
if(Index != -1)
{
CHCIBaseCmdProcessor::tHCICommandTableItem* pHCICommandTable = (g_pHCIProcessor->CmdTypeTable[CmdType]).CmdTable;
pHCICommandTable[Index].CmdRetParamFunction((char *)(++psCmdCompEv));
if (g_ComPortFlag != USB_PORT)
{
Temp.Format ("%.2X", UartTl ); n = Temp.GetLength(); // Return Number of Characters
UartTlStr.Format ("\tUART Tl Header: [1] %s\n", Temp );
}
Temp.Format ("%.2X", EventIndex ); n = Temp.GetLength(); // Return Number of Characters
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
Temp.Format ("%.2X", ParamLen ); n = Temp.GetLength(); // Return Number of Characters
ParamStr.Format ("\tParamLen: [1] %s\n", Temp );
Temp.Format ("%.2X",g_NumHciCommandPackets); n = Temp.GetLength(); // Return Number of Characters
CPacketAll.Format ("\tNum HCI Command Packets: [1] %s\n", Temp );
Temp.Format ("%-.4X", OpCode ); n = Temp.GetLength(); // Return Number of Characters
OpCodeStr.Format ("\tOpCode: [2] %s\n", Temp );
ParamStr = UartTlStr + EventCode + ParamStr + CPacketAll + OpCodeStr + Status;
//g_ComReadListCritSec[ComPortNo].Lock();
//g_omSerialResponseStringList[ComPortNo].AddTail(ParamStr);
//g_ComReadListCritSec[ComPortNo].Unlock();
//PostMessage(g_pChildFrame->GetSafeHwnd(),WM_SERIAL_READ_OPN_OVER,ComPortNo ,0);
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
}
//MessageBox(NULL,"Wrong command code in Command Complete Event packet","Error",MB_OK|MB_ICONWARNING);
return false;
}
//------------------------------------------------------------------------------
//
// 5.2.15 Command Status Event
//
//------------------------------------------------------------------------------
uint8 HCI_EventsInterfaceProcFunctions::CommandStatusEvent(CHCI_EventPacket& rHCI_EventPacket)
{
CString Temp;
CString StatusStr;
CString CPacketAll;
CString EventCode;
CString ParamStr;
char ErrorDef[60]= {'\0'};
struct sCommandStatusEventParams
{
uint8 teStatus;
uint8 u8NumHCICommandPackets;
uint16 u16CommandOpcode;
}*psCommandStatusEventParams;
// int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
psCommandStatusEventParams = (sCommandStatusEventParams*)rHCI_EventPacket.GetHCI_EventPacketParam();
UCHAR Status = psCommandStatusEventParams->teStatus;
g_NumHciCommandPackets = psCommandStatusEventParams->u8NumHCICommandPackets;
uint16 OpCode = psCommandStatusEventParams->u16CommandOpcode;
int Index; //= GET_OCF(opcode);
int CmdType = GET_OGF(OpCode);
if (CmdType == 0x3F)
CmdType = 0x07; //eVEND_SPEC_CMD; // EK Vendor Specific Command
if(CmdType >=1 && CmdType <= 7)
{
Index = g_pHCIProcessor->FindHCICommandType(OpCode);
if(Index != -1)
{
CHCIBaseCmdProcessor::tHCICommandTableItem* pHCICommandTable = (g_pHCIProcessor->CmdTypeTable[CmdType]).CmdTable;
pHCICommandTable[Index].CmdRetParamFunction((char *)(psCommandStatusEventParams));
//pHCICommandTable[Index].CmdRetParamFunction((char *)(++psCommandStatusEventParams));
if(Status) {
g_pChildFrame->ErrorDef((char *)(psCommandStatusEventParams), ErrorDef);
Temp.Format ("%.2X - %s", Status, ErrorDef);
}else
Temp.Format ("%.2X", Status);
StatusStr.Format ("\tStatus: [1] %s\n", Temp );
Temp.Format ("%.2X", EventIndex ); //n = Temp.GetLength(); // Return Number of Characters
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
Temp.Format ("%.2X", g_NumHciCommandPackets ); //n = Temp.GetLength();
CPacketAll.Format("\tCommand Packets Allowed: [1] %s\n",Temp);
ParamStr = StatusStr + EventCode + CPacketAll;
//g_ComReadListCritSec[ComPortNo].Lock();
//g_omSerialResponseStringList[ComPortNo].AddTail(ParamStr);
//g_ComReadListCritSec[ComPortNo].Unlock();
//PostMessage(g_pChildFrame->GetSafeHwnd(),WM_SERIAL_READ_OPN_OVER,ComPortNo ,0);
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
}
MessageBox(NULL,"Wrong command code in Command status Event packet","Error",MB_OK|MB_ICONWARNING);
return false;
}
//------------------------------------------------------------------------------
//
// 5.2.16 Hardware Error Event
//
//------------------------------------------------------------------------------
uint8 HCI_EventsInterfaceProcFunctions::HardwareErrorEvent(CHCI_EventPacket& rHCI_EventPacket)/*uint8 HardwareCode )*/
{
CString Temp;
CString EventCode;
CString HardwareCode;
CString ParamStr;
char buf1[10] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
uint8 ParamLength= rHCI_EventPacket.GetParmLen();
sHardwareErrorEvent* psHardwareError = (sHardwareErrorEvent*)rHCI_EventPacket.GetHCI_EventPacketParam();
Temp.Format ("%.2X", EventIndex );
EventCode.Format ("\tEvent Code: [1] %s\n", Temp );
BT_itoa(&psHardwareError->HardwareCode ,1, buf1);
Temp.Format ("%s", buf1);
HardwareCode.Format ("\tHardware Code: [%d] %s\n",sizeof(psHardwareError->HardwareCode), Temp );
ParamStr = EventCode + HardwareCode ;
g_pChildFrame->ParamListForOutput(ParamStr);
return true;
}
uint8 HCI_EventsInterfaceProcFunctions::FlushOccuredEvent(CHCI_EventPacket& rHCI_EventPacket)/*tConnectionHandle ConnectionHandle)*/
{
CString Temp;
CString EventCode;
CString ConHandle;
CString ParamStr;
char buf1[10] = {'\0'};
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
uint8 EventIndex = rHCI_EventPacket.GetOpCode();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -