l2cap: support de-init

This commit is contained in:
Matthias Ringwald 2021-01-08 17:41:31 +01:00
parent 4688f21608
commit a0549bf12c
2 changed files with 19 additions and 5 deletions

View File

@ -200,10 +200,10 @@ static btstack_linked_list_t l2cap_le_services;
static btstack_linked_list_t l2cap_channels; static btstack_linked_list_t l2cap_channels;
#ifdef L2CAP_USES_CHANNELS #ifdef L2CAP_USES_CHANNELS
// next channel id for new connections // next channel id for new connections
static uint16_t local_source_cid = 0x40; static uint16_t local_source_cid;
#endif #endif
// next signaling sequence number // next signaling sequence number
static uint8_t sig_seq_nr = 0xff; static uint8_t sig_seq_nr;
// used to cache l2cap rejects, echo, and informational requests // used to cache l2cap rejects, echo, and informational requests
static l2cap_signaling_response_t signaling_responses[NR_PENDING_SIGNALING_RESPONSES]; static l2cap_signaling_response_t signaling_responses[NR_PENDING_SIGNALING_RESPONSES];
@ -873,7 +873,8 @@ static uint8_t l2cap_next_sig_id(void){
void l2cap_init(void){ void l2cap_init(void){
signaling_responses_pending = 0; signaling_responses_pending = 0;
local_source_cid = 0x40;
sig_seq_nr = 0xff;
l2cap_channels = NULL; l2cap_channels = NULL;
#ifdef ENABLE_CLASSIC #ifdef ENABLE_CLASSIC
@ -920,6 +921,14 @@ void l2cap_init(void){
#endif #endif
} }
/**
* @brief De-Init L2CAP
*/
void l2cap_deinit(void){
memset(l2cap_outgoing_classic_addr, 0, 6);
signaling_responses_pending = 0;
}
void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){ void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
#ifdef ENABLE_BLE #ifdef ENABLE_BLE
l2cap_event_packet_handler = handler; l2cap_event_packet_handler = handler;

View File

@ -665,8 +665,6 @@ uint8_t l2cap_le_send_data(uint16_t cid, uint8_t * data, uint16_t size);
*/ */
uint8_t l2cap_le_disconnect(uint16_t cid); uint8_t l2cap_le_disconnect(uint16_t cid);
/* API_END */
/** /**
* @brief ERTM Set channel as busy. * @brief ERTM Set channel as busy.
* @note Can be cleared by l2cap_ertm_set_ready * @note Can be cleared by l2cap_ertm_set_ready
@ -681,6 +679,13 @@ uint8_t l2cap_ertm_set_busy(uint16_t local_cid);
*/ */
uint8_t l2cap_ertm_set_ready(uint16_t local_cid); uint8_t l2cap_ertm_set_ready(uint16_t local_cid);
/**
* @brief De-Init L2CAP
*/
void l2cap_deinit(void);
/* API_END */
#if defined __cplusplus #if defined __cplusplus
} }
#endif #endif