bt_mesh_proxy_role_setup() is called conditionally when peer is connected and gatt_disconnected() is always called. This leads to unbalance in role->conn reference count and crash. Instead of hot-fixing this in gatt_disconnected(), this commit adds proper bt_mesh_proxy_role_cleanup() API that is called by roles implementations if cleanup is needed. Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
60 lines
1.6 KiB
C
60 lines
1.6 KiB
C
/* Bluetooth Mesh */
|
|
|
|
/*
|
|
* Copyright (c) 2017 Intel Corporation
|
|
* Copyright (c) 2021 Lingao Meng
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_MSG_H_
|
|
#define ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_MSG_H_
|
|
|
|
#include <bluetooth/gatt.h>
|
|
|
|
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
|
|
#define CFG_FILTER_SET 0x00
|
|
#define CFG_FILTER_ADD 0x01
|
|
#define CFG_FILTER_REMOVE 0x02
|
|
#define CFG_FILTER_STATUS 0x03
|
|
|
|
#define BT_MESH_PROXY_NET_PDU 0x00
|
|
#define BT_MESH_PROXY_BEACON 0x01
|
|
#define BT_MESH_PROXY_CONFIG 0x02
|
|
#define BT_MESH_PROXY_PROV 0x03
|
|
|
|
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
|
|
|
|
struct bt_mesh_proxy_role;
|
|
|
|
typedef int (*proxy_send_cb_t)(struct bt_conn *conn,
|
|
const void *data, uint16_t len,
|
|
bt_gatt_complete_func_t end, void *user_data);
|
|
|
|
typedef void (*proxy_recv_cb_t)(struct bt_mesh_proxy_role *role);
|
|
|
|
struct bt_mesh_proxy_role {
|
|
struct bt_conn *conn;
|
|
uint8_t msg_type;
|
|
|
|
struct {
|
|
proxy_send_cb_t send;
|
|
proxy_recv_cb_t recv;
|
|
} cb;
|
|
|
|
struct k_work_delayable sar_timer;
|
|
struct net_buf_simple buf;
|
|
};
|
|
|
|
ssize_t bt_mesh_proxy_msg_recv(struct bt_mesh_proxy_role *role,
|
|
const void *buf, uint16_t len);
|
|
int bt_mesh_proxy_msg_send(struct bt_mesh_proxy_role *role, uint8_t type,
|
|
struct net_buf_simple *msg,
|
|
bt_gatt_complete_func_t end, void *user_data);
|
|
struct bt_mesh_proxy_role *bt_mesh_proxy_role_setup(struct bt_conn *conn,
|
|
proxy_send_cb_t send,
|
|
proxy_recv_cb_t recv);
|
|
void bt_mesh_proxy_role_cleanup(struct bt_mesh_proxy_role *role);
|
|
|
|
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_PROXY_MSG_H_ */
|