Opening Connections
9/8/2008
Quando a pilha Bluetooth é inicializado, ele chama o HCI_SetCallback função de interface de HCI Transport. Ele passa uma callback que é usada pelo camada de transporte HCI para indicar inserção ou remoção de hardware.
A pilha também pode chamar o HCI_StartHardware e HCI_StopHardware funções para tornar o físico camada simular um ejeção ou inserção de um controlador, quer seja removível ou não.
O seguinte codificar mostra definições de função de Bt_hcip.h.
enum HCI_EVENT {
DEVICE_UP,
DEVICE_DOWN,
DEVICE_ERROR
};
typedef int (*HCI_TransportCallback) (HCI_EVENT eEvent, void *pEvent);
int HCI_SetCallback (HCI_TransportCallback pfCallback);
int HCI_StartHardware (void);
int HCI_StopHardware (void);
Quando uma inserção está sinalizado, as chamadas pilha a HCI_OpenConnection função. Se ele retorna TRUE, o transporte é considerado ativo.
Quando HCI_OpenConnection Retorna TRUE, as chamadas pilha Bluetooth de HCI_ReadHciParameters função.
In a HCI_PARAMETERS estrutura passada como um argumento, ele preenche apenas o campo tamanho e versão. O driver transporte deve garantir que a versão da pilha corresponde a versão do driver de transporte exatamente.
O transporte HCI é responsável por preenchimento a HCI_PARAMETERS estrutura completamente. Importantes membros dessa estrutura indicam buffers mínimos exigido para de entrada pacotes e buffers máximo permitidos para de saída pacotes, bem como a versão do hardware Bluetooth.
#define HCI_INTERFACE_VERSION_1_0 0x00010000
#define HCI_HARDWARE_VERSION_V_1_0_A 0
#define HCI_HARDWARE_VERSION_V_1_0_B 1
#define HCI_HARDWARE_VERSION_V_1_1 2
#define HCI_DEFAULT_WRITE_TIMEOUT 15000
#define HCI_FLAGS_NORESET 0x00000001
#define HCI_FLAGS_NOLOCALNAME 0x00000002
#define HCI_FLAGS_NOROLESWITCH 0x00000004
//
// Note:
// iMaxSize parameters MUST fit the biggest HCI command
// (HCI_RemoteNameRequest as of this writing is 257 bytes,
// see also bt_ddi.h::HCI_MAX_COMMAND_LENGTH)
// iReadBufferHeader and iWriteBufferHeader MUST be 4-bytes aligned
//
typedef struct __hci_parameters
{
unsigned int uiSize; // structure size
unsigned int fInterfaceVersion; // interface version
int iMaxSizeRead; // Max size of read packet (not including headers and
//trailers)
int iMaxSizeWrite; // Max size of write packet (not including headers
//and trailers)
int iReadBufferHeader; // Hint : read may contain up to as much
//transport header bytes
int iReadBufferTrailer; // Hint : read may contain up to as much
//transport trailer bytes
int iWriteBufferHeader; // Number of bytes to preallocate for transport
//header
int iWriteBufferTrailer; // Number of bytes to preallocate for transport
//trailer
int uiFlags; // Flags
int fHardwareVersion; // Bluetooth spec version of hardware
unsigned int uiResetDelay; // milliseconds : delay next command after
//reset by this much
unsigned int uiWriteTimeout; // milliseconds : abort if card does not
//respond in this time (use the default above)
unsigned int uiDriftFactor; // milliseconds : inquiry data is good for
//this long
int iScoWriteLowNumPackets; // Minimum number of outstanding SCO write
//packets in backlog (0 - use default)
int iScoWriteNumPackets; // Maximum number of outstanding SCO write
//packets in backlog (0 - use default)
int iScoWritePacketSize; // Size of each SCO packet (0 - use default, -1
//- SCO not supported)
int iScoSampleSize; // Sample size of SCO packet (8 or 16 bits)
} HCI_PARAMETERS;
int HCI_ReadHciParameters (HCI_PARAMETERS *pParms);