From 67a3a5b71dd9d2109e817b070ee049705e1d12de Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 17 Jul 2017 16:17:25 +0200 Subject: [PATCH] l2cap-ertm: add (empty) l2cap_ertm_set_busy and set_ready to signal local busy condition --- src/l2cap.c | 13 ++++++++++++- src/l2cap.h | 14 ++++++++++++++ test/pts/l2cap_test.c | 10 ++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/l2cap.c b/src/l2cap.c index 8b9bc7ebd..f4b53a354 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -1707,6 +1707,16 @@ uint8_t l2cap_accept_ertm_connection(uint16_t local_cid, int ertm_mandatory, uin return ERROR_CODE_SUCCESS; } +uint8_t l2cap_ertm_set_busy(uint16_t local_cid){ + UNUSED(local_cid); + return ERROR_CODE_SUCCESS; +} + +uint8_t l2cap_ertm_set_ready(uint16_t local_cid){ + return ERROR_CODE_SUCCESS; + UNUSED(local_cid); +} + static void l2cap_ertm_handle_req_seq(l2cap_channel_t * l2cap_channel, uint8_t req_seq){ l2cap_ertm_tx_packet_state_t * tx_state; tx_state = &l2cap_channel->tx_packets_state[l2cap_channel->tx_read_index]; @@ -1719,7 +1729,8 @@ static void l2cap_ertm_handle_req_seq(l2cap_channel_t * l2cap_channel, uint8_t r } else { log_info("RR seq %u != seq of oldest tx packet %u ???", req_seq, tx_state->tx_seq); } -} +} + #endif diff --git a/src/l2cap.h b/src/l2cap.h index e44543d7c..edcb5d91c 100644 --- a/src/l2cap.h +++ b/src/l2cap.h @@ -523,6 +523,20 @@ uint8_t l2cap_le_disconnect(uint16_t cid); /* API_END */ +/** + * @brief ERTM Set channel as busy. + * @note Can be cleared by l2cap_ertm_set_ready + * @param local_cid + */ +uint8_t l2cap_ertm_set_busy(uint16_t local_cid); + +/** + * @brief ERTM Set channel as ready + * @note Used after l2cap_ertm_set_busy + * @param local_cid + */ +uint8_t l2cap_ertm_set_ready(uint16_t local_cid); + #if defined __cplusplus } #endif diff --git a/test/pts/l2cap_test.c b/test/pts/l2cap_test.c index 484ce5c54..7b061878c 100644 --- a/test/pts/l2cap_test.c +++ b/test/pts/l2cap_test.c @@ -143,6 +143,8 @@ static void show_usage(void){ printf("p - send echo request\n"); printf("e - optional ERTM mode\n"); printf("E - mandatory ERTM mode\n"); + printf("b - set channel as busy (ERTM)\n"); + printf("B - set channel as ready (ERTM)\n"); printf("d - disconnect\n"); printf("t - terminate ACL connection\n"); printf("Ctrl-c - exit\n"); @@ -159,6 +161,14 @@ static void stdin_process(char buffer){ l2cap_create_channel(packet_handler, remote, BLUETOOTH_PROTOCOL_SDP, 100, &local_cid); } break; + case 'b': + printf("Set channel busy\n"); + l2cap_ertm_set_busy(local_cid); + break; + case 'B': + printf("Set channel ready\n"); + l2cap_ertm_set_ready(local_cid); + break; case 's': printf("Send L2CAP Data\n"); l2cap_send(local_cid, (uint8_t *) "0123456789", 10);