1. STM32WB-WBA - Connection Oriented Channel
A COC allows the exchange of Bluetooth® Low Energy data at L2CAP layer without GATT layer. There is no notion of client/server, only central and peripheral.
To set a COC logical link, it is necessary to establish first a Bluetooth® Low Energy link.
Over this Bluetooth® Low Energy link, one or several COC can be established.
The central or the peripheral may be COC initiator.
Bluetooth® LE architecture |
---|
1.1. General L2CAP Terminology
Bluetooth® Low Energy General L2CAP Terminology |
---|
1.2. L2CAP Connection Oriented Channel Example
L2CAP COC example |
---|
1.3. L2CAP COC establishment
ACI_L2CAP_COC_CONNECT
L2CAP COC connect command |
---|
ACI_L2CAP_COC_CONNECT_CONFIRM
L2CAP COC connect confirm command |
---|
- MTU frames are fragmented into K-frames of MPS size at application level on transmitter side.
- MTU frames are reassembled at application level on receiver side.
- Initial Credits are handled at application level once they have been exchanged through both previous commands.
1.4. L2CAP COC data exchange
ACI_L2CAP_COC_TX_DATA
L2CAP COC Tx Data command |
---|
- This command sends a K-frame packet on the specified connection-oriented channel.
- Note: for the first K-frame of the SDU, the Information data shall contain the MTU Length coded on two octets followed by the K-frame information payload. For the next K-frames of the SDU, the Information data shall only contain the K-frame information payload.
- Application must handle MTU length, fragmentation in K-frame, length of current transmitted frame and credits number.
Reception of ACI_L2CAP_COC_RX_DATA_EVENT
L2CAP COC Rx Data event |
---|
- Application must handle MTU length received in first K-frame, K-frame number, length of current received frame and credits number.
1.5. L2CAP COC flow control
ACI_L2CAP_COC_FLOW_CONTROL
L2CAP COC Flow Control command |
---|
ACI_L2CAP_COC_FLOW_CONTROL_EVENT
L2CAP COC Flow Control Event |
---|
- Application must handle credits number on transmitter and receiver side.
1.6. Bluetooth® Low Energy connection and COC establishment initiated by the central
1.6.1. On central side
- Initiate a Bluetooth® Low Energy link: send aci_gap_create_connection
- Wait for HCI_LE_CONNECTION_COMPLETE_EVENT
- Initiate a CoC connection: ACI_L2CAP_COC_CONNECT
- Wait for ACI_L2CAP_COC_CONNECT_CONFIRM_EVENT (get channel_index_list)
Range of channel_index_list for the COC initiator: from 0 to 0x1F
1.6.2. On peripheral side
- Start advertising: send aci_gap_set_discoverable
- Wait for HCI_LE_CONNECTION_COMPLETE_EVENT
- Wait for ACI_L2CAP_COC_CONNECT_EVENT
- Send ACI_L2CAP_COC_CONNECT_CONFIRM
- In hci_command_complete_event, get Channel_number and Channel_Index_List values
Range of channel_index_list for the COC peripheral: from 0x20 to 0x3F
1.7. COC data exchange
1.7.1. On sender side
Send ACI_L2CAP_COC_TX_DATA (Channel_Index, length, data)
1.7.2. On receiver side
Reception of ACI_L2CAP_COC_RX_DATA_EVENT
1.8. Example of Bluetooth® Low Energy connection, COC establishment and data exchange
Bluetooth® Low Energy and COC link establishment |
---|
L2CAP COC data exchange |
---|
1.9. Code Example
A STM32WB COC code example has been shared on STM32-Hotspot [1]
A STM32WBA COC code example is available with BLE_SerialCom application