Skip to content

Commit 41e71ef

Browse files
mkapala-nordickapi-no
authored andcommitted
dult: Move assert after ready check in ANOS characteristic handler
Moved assert after the subsys ready check in the ANOS GATT characteristic write handler as the pointer checked in the assert is initialized on the dult_enable call. It could result in assertion when the DULT was not yet initialized but characteristic was accessed as it is statically defined. Now instead of assertion it just gracefully returns from the function. Jira: NCSDK-33739 Signed-off-by: Mateusz Kapala <[email protected]>
1 parent 5604b9b commit 41e71ef

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ nRF RPC libraries
554554
Other libraries
555555
---------------
556556

557-
|no_changes_yet_note|
557+
* :ref:`dult_readme` library:
558+
559+
* Updated the write handler of the accessory non-owner service (ANOS) GATT characteristic to no longer assert on write operations if the DULT was not enabled at least once.
558560

559561
Shell libraries
560562
---------------

subsys/dult/bt/anos.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,18 +519,18 @@ static ssize_t write_accessory_non_owner(struct bt_conn *conn,
519519
const struct dult_user *dult_user;
520520
enum dult_near_owner_state_mode mode;
521521

522-
/* The Accessory Non-owner characteristic should be used to handle the GATT Write
523-
* operations and to send GATT indications.
524-
*/
525-
__ASSERT_NO_MSG(attr == anos_chrc_indicate_attr);
526-
527522
if (!dult_user_is_ready()) {
528523
res = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
529524
LOG_INF("Accessory non-owner write: res=%d conn=%p, "
530525
"Return error because DULT is not enabled", res, (void *)conn);
531526
return res;
532527
}
533528

529+
/* The Accessory Non-owner characteristic should be used to handle the GATT Write
530+
* operations and to send GATT indications.
531+
*/
532+
__ASSERT_NO_MSG(attr == anos_chrc_indicate_attr);
533+
534534
if (offset != 0) {
535535
LOG_WRN("Invalid offset: off=%" PRIu16 " (Accessory non-owner write)", offset);
536536
res = BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);

0 commit comments

Comments
 (0)