Skip to content

Commit c2e07a3

Browse files
Andries Kruithofcarlescufi
authored andcommitted
Bluetooth: controller: llcp: send correct collision code
Upon collision either the error code for different procedure collision or same procedure collision must be transmitted, which is fixed in this PR. Previously always the error code for same procedure collision was sent Signed-off-by: Andries Kruithof <[email protected]>
1 parent ce84c78 commit c2e07a3

File tree

5 files changed

+816
-3
lines changed

5 files changed

+816
-3
lines changed

subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ static void lp_pu_st_wait_rx_phy_update_ind(struct ll_conn *conn, struct proc_ct
653653
break;
654654
case LP_PU_EVT_REJECT:
655655
llcp_rr_set_incompat(conn, INCOMPAT_NO_COLLISION);
656-
ctx->data.pu.error = BT_HCI_ERR_LL_PROC_COLLISION;
656+
llcp_pdu_decode_reject_ext_ind(ctx, (struct pdu_data *) param);
657+
ctx->data.pu.error = ctx->reject_ext_ind.error_code;
657658
ctx->data.pu.ntf_pu = 1;
658659
lp_pu_complete(conn, ctx, evt, param);
659660
default:

subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ static void rr_tx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t opcode)
363363
{
364364
struct node_tx *tx;
365365
struct pdu_data *pdu;
366+
struct proc_ctx *ctx_local;
367+
uint8_t reject_code;
366368

367369
/* Allocate tx node */
368370
tx = llcp_tx_alloc(conn, ctx);
@@ -373,11 +375,20 @@ static void rr_tx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t opcode)
373375
/* Encode LL Control PDU */
374376
switch (opcode) {
375377
case PDU_DATA_LLCTRL_TYPE_REJECT_IND:
378+
ctx_local = llcp_lr_peek(conn);
379+
if (ctx_local->proc == ctx->proc ||
380+
(ctx_local->proc == PROC_CONN_UPDATE &&
381+
ctx->proc == PROC_CONN_PARAM_REQ)) {
382+
reject_code = BT_HCI_ERR_LL_PROC_COLLISION;
383+
} else {
384+
reject_code = BT_HCI_ERR_DIFF_TRANS_COLLISION;
385+
}
386+
376387
if (conn->llcp.fex.valid && feature_ext_rej_ind(conn)) {
377388
llcp_pdu_encode_reject_ext_ind(pdu, conn->llcp.remote.reject_opcode,
378-
BT_HCI_ERR_LL_PROC_COLLISION);
389+
reject_code);
379390
} else {
380-
llcp_pdu_encode_reject_ind(pdu, BT_HCI_ERR_LL_PROC_COLLISION);
391+
llcp_pdu_encode_reject_ind(pdu, reject_code);
381392
}
382393
break;
383394
case PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
if (NOT BOARD STREQUAL unit_testing)
6+
message(FATAL_ERROR "This project can only be used with '-DBOARD=unit_testing'.")
7+
endif()
8+
9+
FILE(GLOB SOURCES
10+
src/*.c
11+
)
12+
13+
project(bluetooth_ull_llcp_collision)
14+
find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE})
15+
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
16+
17+
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})

0 commit comments

Comments
 (0)