다음을 통해 공유


Bluetooth 요청 블록 빌드 및 보내기(BRB)

다음 절차에서는 프로필 드라이버가 BRB(Bluetooth 요청 블록)를 빌드하고 보내기 위해 따르는 일반적인 프로세스를 간략하게 설명합니다. BRB는 수행할 Bluetooth 작업을 설명하는 데이터 블록입니다.

BRB를 빌드하고 보내려면

  1. IRP를 할당합니다. IRP를 사용하는 방법에 대한 자세한 내용은 IRP 처리를 참조하세요.
  2. BRB를 할당합니다. BRB를 할당하려면 Bluetooth 드라이버 스택이 프로필 드라이버에서 사용하기 위해 내보내는 BthAllocateBrb 함수를 호출합니다. BthAllocateBrb 함수에 대한 포인터를 가져오려면 Bluetooth 인터페이스 쿼리를 참조하세요.
  3. BRB의 매개 변수를 초기화합니다. 각 BRB는 해당 구조를 사용합니다. 의도한 용도에 따라 구조체의 멤버를 설정합니다. BRB 및 해당 구조의 목록은 Bluetooth 드라이버 스택 사용을 참조하세요.
  4. IRP의 매개 변수를 초기화합니다. IRP의 MajorFunction 멤버를 IRP_MJ_INTERNAL_DEVICE_CONTROL 설정합니다. Parameters.DeviceIoControl.IoControlCode 멤버를 IOCTL_INTERNAL_BTH_SUBMIT_BRB 설정합니다. BRB를 가리키도록 Parameters.Others.Argument1 멤버를 설정합니다.
  5. 드라이버 스택 아래로 IRP를 전달합니다. IoCallDriver를 호출하여 IRP를 다음 하위 드라이버로 보냅니다.

다음 의사 코드 예제에서는 처리할 Bluetooth 드라이버 스택에 대해 L2CAP Ping BRB를 설정하는 방법을 보여 줍니다. 가독성을 위해 예제에서는 오류 처리를 보여 주지 않습니다.

#include <bthddi.h>

// Code for obtaining the BthInterface pointer

// Define a custom pool tag to identify your profile driver's dynamic memory allocations.
// You should change this tag to easily identify your driver's allocations from other drivers.
#define PROFILE_DRIVER_POOL_TAG '_htB'

PIRP Irp;
Irp = IoAllocateIrp( DeviceExtension->ParentDeviceObject->StackSize, FALSE );

PBRB_L2CA_PING BrbPing; // Define storage for a L2CAP Ping BRB

// Allocate the Ping BRB
BrbPing = BthInterface->BthAllocateBrb( BRB_L2CA_PING, PROFILE_DRIVER_POOL_TAG );

// Set up the next IRP stack location
PIO_STACK_LOCATION NextIrpStack;
NextIrpStack = IoGetNextIrpStackLocation( Irp );
NextIrpStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextIrpStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_BTH_SUBMIT_BRB;
NextIrpStack->Parameters.Others.Argument1 = BrbPing;

// Pass the IRP down the driver stack
NTSTATUS Status;
Status = IoCallDriver( DeviceExtension->NextLowerDriver, Irp );