Stack Extension Layer Design Considerations
This topic discusses some stack extension layer design considerations you should keep in mind.
- Always process errors because every operation can fail.
- Never call upper or lower layers of the stack under a critical section - the command will always complete on a different thread.
- Implement what you need but always process Aborts and Stack events.
Packet buffering and fragmentation
Data packets are sent to the HCI layer using the following interface functions.
typedef int (*HCI_DataPacketDown_In)
(
HANDLE hDeviceContext,
void* pCallContext,
unsigned short connection_handle,
BD_BUFFER* pBuffer
);
typedef int (*HCI_DataPacketDown_Out)
(
void* pCallContext,
int iError
);
Both data and command packets are placed in an HCI queue. Data packet fragmentation happens automatically. The upper layers have no control over this.
It is impossible to properly defragment data on the way up without knowing the size of the total packet. If the protocol is following the L2CAP packet format, that is, the data is length-prefixed, defragmentation is handled by the HCI and the packet is delivered through the following indication.
typedef int (*HCI_DataPacketUp)
(
void* pUserContext,
unsigned short connection_handle,
BD_BUFFER* pBuffer
);
However, if the upper interface exposes the following function, it will be expected to handle the buffering of incoming ACL (asynchronous connection-less) packets, which will be reported to it immediately. In this case, there are no restrictions on the packet format.
typedef int (*HCI_DataPacketUpAclUnbuffered)
(
void* pUserContext,
unsigned short connection_handle,
unsigned char boundary,
unsigned char broadcast,
BD_BUFFER* pBuffer
);
See Also
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.