mesh: add bt_mesh_friend_terminate() function

This function allows to terminate friendship manually.
This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent 9897e56cfb
commit 0b3db9a0df
2 changed files with 24 additions and 0 deletions
+10
View File
@@ -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
+14
View File
@@ -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)
{