mesh: add bt_mesh_friend_terminate() function
This function allows to terminate friendship manually.
diff --git a/nimble/host/mesh/include/mesh/main.h b/nimble/host/mesh/include/mesh/main.h
index 042b59a..c0ef04d 100644
--- a/nimble/host/mesh/include/mesh/main.h
+++ b/nimble/host/mesh/include/mesh/main.h
@@ -432,6 +432,16 @@
*/
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 ed6e69d..58dd6d3 100644
--- a/nimble/host/mesh/src/friend.c
+++ b/nimble/host/mesh/src/friend.c
@@ -1693,6 +1693,20 @@
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)
{