diff --git a/nimble/host/mesh/include/mesh/main.h b/nimble/host/mesh/include/mesh/main.h index 042b59a5a..c0ef04da7 100644 --- a/nimble/host/mesh/include/mesh/main.h +++ b/nimble/host/mesh/include/mesh/main.h @@ -432,6 +432,16 @@ int bt_mesh_lpn_poll(void); */ void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established)); +/** @brief Terminate Friendship. + * + * Terminated Friendship for given LPN. + * + * @param lpn_addr Low Power Node address. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_friend_terminate(uint16_t lpn_addr); + #ifdef __cplusplus } #endif diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c index ed6e69dd9..58dd6d358 100644 --- a/nimble/host/mesh/src/friend.c +++ b/nimble/host/mesh/src/friend.c @@ -1693,6 +1693,20 @@ bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, return matched; } +int bt_mesh_friend_terminate(uint16_t lpn_addr) +{ + struct bt_mesh_friend *frnd; + + frnd = bt_mesh_friend_find(BT_MESH_KEY_ANY, lpn_addr, false, false); + if (!frnd) { + return -ENOENT; + } + + friend_clear(frnd); + + return 0; +} + void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, uint16_t dst, uint64_t *seq_auth) {