mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-24 15:02:43 +00:00
l2cap: provide channel mode (basic/ertm) and fcs option in L2CAP_EVENT_CHANNEL_OPENED
This commit is contained in:
parent
729710c069
commit
7f1690cf27
@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- L2CAP: provide channel mode (basic/ertm) and fcs option in L2CAP_EVENT_CHANNEL_OPENED
|
||||||
|
|
||||||
|
## Changes December 2018
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- SM: generate and store ER / IR keys in TLV, unless manually set by application
|
- SM: generate and store ER / IR keys in TLV, unless manually set by application
|
||||||
- hci_dump: support PacketLogger or BlueZ format output via SEGGER RTT Channel 1 Up
|
- hci_dump: support PacketLogger or BlueZ format output via SEGGER RTT Channel 1 Up
|
||||||
|
@ -435,7 +435,7 @@ typedef uint8_t sm_key_t[16];
|
|||||||
// L2CAP EVENTS
|
// L2CAP EVENTS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @format 1BH2222221
|
* @format 1BH222222111
|
||||||
* @param status
|
* @param status
|
||||||
* @param address
|
* @param address
|
||||||
* @param handle
|
* @param handle
|
||||||
@ -446,6 +446,8 @@ typedef uint8_t sm_key_t[16];
|
|||||||
* @param remote_mtu
|
* @param remote_mtu
|
||||||
* @param flush_timeout
|
* @param flush_timeout
|
||||||
* @param incoming
|
* @param incoming
|
||||||
|
* @param mode
|
||||||
|
* @param fcs
|
||||||
*/
|
*/
|
||||||
#define L2CAP_EVENT_CHANNEL_OPENED 0x70
|
#define L2CAP_EVENT_CHANNEL_OPENED 0x70
|
||||||
|
|
||||||
|
@ -1127,6 +1127,24 @@ static inline uint16_t l2cap_event_channel_opened_get_flush_timeout(const uint8_
|
|||||||
static inline uint8_t l2cap_event_channel_opened_get_incoming(const uint8_t * event){
|
static inline uint8_t l2cap_event_channel_opened_get_incoming(const uint8_t * event){
|
||||||
return event[23];
|
return event[23];
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get field mode from event L2CAP_EVENT_CHANNEL_OPENED
|
||||||
|
* @param event packet
|
||||||
|
* @return mode
|
||||||
|
* @note: btstack_type 1
|
||||||
|
*/
|
||||||
|
static inline uint8_t l2cap_event_channel_opened_get_mode(const uint8_t * event){
|
||||||
|
return event[24];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get field fcs from event L2CAP_EVENT_CHANNEL_OPENED
|
||||||
|
* @param event packet
|
||||||
|
* @return fcs
|
||||||
|
* @note: btstack_type 1
|
||||||
|
*/
|
||||||
|
static inline uint8_t l2cap_event_channel_opened_get_fcs(const uint8_t * event){
|
||||||
|
return event[25];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get field local_cid from event L2CAP_EVENT_CHANNEL_CLOSED
|
* @brief Get field local_cid from event L2CAP_EVENT_CHANNEL_CLOSED
|
||||||
|
14
src/l2cap.c
14
src/l2cap.c
@ -904,10 +904,7 @@ void l2cap_emit_channel_opened(l2cap_channel_t *channel, uint8_t status) {
|
|||||||
log_info("L2CAP_EVENT_CHANNEL_OPENED status 0x%x addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x local_mtu %u, remote_mtu %u, flush_timeout %u",
|
log_info("L2CAP_EVENT_CHANNEL_OPENED status 0x%x addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x local_mtu %u, remote_mtu %u, flush_timeout %u",
|
||||||
status, bd_addr_to_str(channel->address), channel->con_handle, channel->psm,
|
status, bd_addr_to_str(channel->address), channel->con_handle, channel->psm,
|
||||||
channel->local_cid, channel->remote_cid, channel->local_mtu, channel->remote_mtu, channel->flush_timeout);
|
channel->local_cid, channel->remote_cid, channel->local_mtu, channel->remote_mtu, channel->flush_timeout);
|
||||||
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
uint8_t event[26];
|
||||||
log_info("ERTM mode %u, fcs enabled %u", channel->mode, channel->fcs_option);
|
|
||||||
#endif
|
|
||||||
uint8_t event[24];
|
|
||||||
event[0] = L2CAP_EVENT_CHANNEL_OPENED;
|
event[0] = L2CAP_EVENT_CHANNEL_OPENED;
|
||||||
event[1] = sizeof(event) - 2;
|
event[1] = sizeof(event) - 2;
|
||||||
event[2] = status;
|
event[2] = status;
|
||||||
@ -920,6 +917,15 @@ void l2cap_emit_channel_opened(l2cap_channel_t *channel, uint8_t status) {
|
|||||||
little_endian_store_16(event, 19, channel->remote_mtu);
|
little_endian_store_16(event, 19, channel->remote_mtu);
|
||||||
little_endian_store_16(event, 21, channel->flush_timeout);
|
little_endian_store_16(event, 21, channel->flush_timeout);
|
||||||
event[23] = channel->state_var & L2CAP_CHANNEL_STATE_VAR_INCOMING ? 1 : 0;
|
event[23] = channel->state_var & L2CAP_CHANNEL_STATE_VAR_INCOMING ? 1 : 0;
|
||||||
|
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
||||||
|
log_info("ERTM mode %u, fcs enabled %u", channel->mode, channel->fcs_option);
|
||||||
|
event[24] = channel->mode;
|
||||||
|
event[25] = channel->fcs_option;
|
||||||
|
|
||||||
|
#else
|
||||||
|
event[24] = L2CAP_CHANNEL_MODE_BASIC;
|
||||||
|
event[25] = 0;
|
||||||
|
#endif
|
||||||
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||||
l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
|
l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user