?? hci_acldataproc.cpp
字號(hào):
?
+
//--------------------------------------------------------------- %FILH_BEG% --
//
// Project: $$ProjectName
//
// File name: HCIDataPacket.cpp
// Author:
// Description:
//
// Revision History:
// $Log: $
//
// Rev 1.02 02/22/01 Ek .Modified UnpaqAclEvent() function to handle Acl Packet Format for USB
// properly by decrementing the buffer pointer by 1 Byte to make up for
// Uart's TPL byte.
// Rev 1.01 12/22/00 Ek .Added UnpaqAclEvent(char* AclHeaderBuf, CString& ParamStr) function
// to decipher Acl Event.
// 12/18/00 .Changed CHCI_ACLDataProcessor::ParseHCI_ACLData return value from uint8
// to tDataParseStatus type to match with other function call
// Rev 1.00 15 July 2000 Initial release
//
//
// Copyright (c) TelenComm Corporation 2000 - All rights reserved
//--------------------------------------------------------------- %FILH_END%
//------------------------------------------------------------------------------
//
// Includes
//
//------------------------------------------------------------------------------
#include "..\..\..\stdafx.h"
#include "..\..\..\BTHost.h"
#include "..\..\Common\Common.h"
#include "..\..\Data\Inc\HCI_ACLDataProc.h"
#include "..\..\..\comm\SerialCommunication.h"
extern UINT g_ComPortFlag; // Used for Serial or USB device Selection
//------------------------------------------------------------------------------
//
// Declarations
//
//------------------------------------------------------------------------------
//uint8 CHCI_ACLDataProcessor::ParseHCI_ACLData(CHCI_ACLDataPacket& HCI_DataPacket)
CHCI_ACLDataProcessor::tDataParseStatus CHCI_ACLDataProcessor::ParseHCI_ACLData(CHCI_ACLDataPacket& HCI_DataPacket)
{
if (HCI_DataPacket.GetParmLen() != (HCI_DataPacket.GetPacketLen() -4))
{
// Wrong parameter total length, send error meesage
TRACE("E001/ParseHCI_ACLData(): Wrong parameter size");
return ePARAMETER_SIZE_MISMATCH;
}
else
{
ProcessHCI_ACLData(HCI_DataPacket);
}
return ePARSING_OK;
}
uint8 CHCI_ACLDataProcessor::ProcessHCI_ACLData(CHCI_ACLDataPacket& HCI_DataPacket)
{
FILE *fp;
CString Msg;
tConnectionHandle ConnectionHandle = HCI_DataPacket.GetConnectionHandle();
int ComPortNo = g_odTheBTHostApp.GetCurComPortNo();
char buf[10] ={'\0'};
itoa(ConnectionHandle, buf, 10);
CString str;
str.Format("%s%s\n"," Connection Handle: ",buf);
if((fp = fopen(g_pBTHostView1->BTHostLogFile,"a")) == NULL)
{
Msg.Format(Msg ," Can't Open %s", g_pBTHostView1->BTHostLogFile);
AfxMessageBox(Msg);
}
fprintf(fp, str);
(*g_odTheBTHostApp.m_DisplayTextFuncPtrArr[ComPortNo])(str,RESPONSEVIEW);
char* pRdBufDataSeek = HCI_DataPacket.pGetData();
int RxPktLen= HCI_DataPacket.GetParmLen();
FOR_LOOP(i,0,RxPktLen)
{
char *p = (pRdBufDataSeek+i);
char c = *p;
if( c >=0 && c<=9)
c += '0';
else if( c >=0xa && c<=0xf)
c += 'a' - 0xa;
else
c = 'X';
*p = c;
}
CString strReadString(pRdBufDataSeek,RxPktLen );
strReadString.Format("%s%s%s\n","Data Received: ",strReadString);
(*g_odTheBTHostApp.m_DisplayTextFuncPtrArr[ComPortNo])(strReadString,RESPONSEVIEW);
return true;
}
//------------------------------------------------------------------------------
// End of HCI_ACLDataProc.cpp
void CHCI_ACLDataProcessor::UnpaqAclEvent(char* AclHeaderBuf, CString& ParamStr)
{
CString AclStr,str,Temp;
char* cp ;
uint16 tval16 = 0;
uint8 tval8 = 0;
uint8 UartHeader;
uint16 ConHandle;
uint8 PacketBoundary;
uint8 BroadCast;
uint16 AclDataLen;
uint16 L2CapLen;
uint16 L2CapChanID;
//strcpy(str, g_aPktBuf+(L2CapHeader*2));
// ACL Packet Format
// 02 00 20 09 00 05 00 0000
// -- ----- ----- ----- ----
//
// For USB there is no first byte for UartHeader, to make an adjusment we decremnet cp by 2
if(g_ComPortFlag == USB_PORT)
cp = AclHeaderBuf -2;
else
cp = AclHeaderBuf;
UartHeader = 0x02;
sscanf(cp + 2, "%4X",&tval16); tval8 = (tval16 & 0x000F );
uint16 val = tval16 >> 8;
ConHandle = (val << 4) + tval8; // Connection handle is 12 Bits
tval16 = tval8 = 0;
sscanf(cp + 4, "%2X",&tval8); PacketBoundary = (tval8 >> 4) & 0x3 ; // Packet Boundry is 2 Bits
sscanf(cp + 4,"%2X",&tval8); BroadCast = (tval8 >> 6) & 0x3; // Broadcast Flag is 2 Bits
sscanf(cp + 6, "%4X",&tval16);
AclDataLen = ((tval16 & 0xFF) << 8) + ((tval16 & 0xFF00) >> 8) & 0xFFFF;// Data Length is 2Bytes
sscanf(cp +10, "%4X",&tval16);
L2CapLen = ((tval16 & 0xFF) << 8) + ((tval16 & 0xFF00) >> 8) & 0xFFFF;// Data Length is 2Bytes
sscanf(cp +14, "%4X",&tval16);
L2CapChanID= ((tval16 & 0xFF) << 8) + ((tval16 & 0xFF00) >> 8) & 0xFFFF;// Data Length is 2Bytes
// For USB ther is no first byte for UartHeader
if(g_ComPortFlag != USB_PORT)
{
Temp.Empty();
Temp.Format ("\tUART Tl Header: [1] %-.2X\n",UartHeader);
}
ParamStr += Temp; Temp.Empty();
Temp.Format ("\tConnection Handle: [2] %-.4X\n",ConHandle);
ParamStr += Temp; Temp.Empty();
CString pBound,bCast;
if(PacketBoundary == 0)
pBound.Format("%-.2X Reserved For Future",PacketBoundary);
else if(PacketBoundary == 1)
pBound.Format("%-.2X Continuing Packet",PacketBoundary);
else if(PacketBoundary == 2)
pBound.Format("%-.2X First Packet",PacketBoundary);
else if(PacketBoundary == 3)
pBound.Format("%-.2X Reserved For Future",PacketBoundary);
else
pBound = " ";
if(BroadCast == 0)
bCast.Format ("%-.2X Point To Point", BroadCast);
else if(BroadCast == 1)
bCast.Format ("%-.2X Active Broadcast", BroadCast);
else if(BroadCast == 2)
bCast.Format ("%-.2X Piconet Broadcast", BroadCast);
else if(BroadCast == 3)
bCast.Format ("%-.2X Reserved For Future", BroadCast);
else
bCast = " ";
Temp.Format ("\tPacket Boundry Flag: [<1] %s\n",pBound);
ParamStr += Temp; Temp.Empty();
Temp.Format ("\tBroadcast Flag: [<1] %s\n",bCast);
ParamStr += Temp; Temp.Empty();
Temp.Format ("\tDataLen: [2] %-.4X\n",AclDataLen);
ParamStr += Temp; Temp.Empty();
Temp.Format ("\tL2Cap Length: [2] %-.4X\n",L2CapLen);
ParamStr += Temp; Temp.Empty();
Temp.Format ("\tL2Cap Channel ID: [2] %-.4X\n",L2CapChanID);
ParamStr += Temp; Temp.Empty();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -