Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
La procedura seguente descrive il processo generale seguito da un driver di profilo per compilare e inviare un blocco di richieste Bluetooth (BRB). BRB è un blocco di dati che descrive l'operazione Bluetooth da eseguire.
Per compilare e inviare un BRB
- Allocare un IRP. Per altre informazioni su come usare i runtime di integrazione, vedere Gestione dei runtime di integrazione.
- Allocare un BRB. Per allocare i BRB, chiamare la funzione BthAllocateBrb esportata dallo stack di driver Bluetooth per essere utilizzata dai driver di profilo. Per ottenere un puntatore alla funzione BthAllocateBrb, consultare Esecuzione di query per interfacce Bluetooth.
- Inizializzare i parametri di BRB. Ogni BRB usa una struttura corrispondente. Impostare i membri della struttura in base all'uso previsto. Per un elenco di BRB e le relative strutture corrispondenti, vedere Uso dello stack di driver Bluetooth.
- Inizializzare i parametri dell'IRP. Impostare il membro MajorFunction dell'IRP su IRP_MJ_INTERNAL_DEVICE_CONTROL. Impostare il membro Parameters.DeviceIoControl.IoControlCode su IOCTL_INTERNAL_BTH_SUBMIT_BRB. Impostare il membro Parameters.Others.Argument1 in modo che punti a BRB.
- Trasmettere l'IRP nello stack dei driver. Chiamare IoCallDriver per inviare l'IRP al prossimo driver inferiore.
L'esempio di pseudocodice seguente dimostra come impostare un BRB L2CAP Ping affinché lo stack di driver Bluetooth lo elabori. Per la leggibilità, l'esempio non illustra la gestione degli errori.
#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 );