host/mesh: Use common buf size for all conn
Use common buffer size for all bluetooth mesh connection.
This is port of
#define PROXY_BUF_LEN_MAX 30
#if defined(CONFIG_BT_MESH_PB_GATT)
-#define PROXY_MSG_FIRST_BUF_LEN PB_GATT_BUF_LEN_MAX
+#define PROXY_MSG_BUF_LEN PB_GATT_BUF_LEN_MAX
#else
-#define PROXY_MSG_FIRST_BUF_LEN PROXY_BUF_LEN_MAX
+#define PROXY_MSG_BUF_LEN PROXY_BUF_LEN_MAX
#endif
-static uint8_t bufs[PROXY_MSG_FIRST_BUF_LEN +
+static uint8_t bufs[CONFIG_BT_MAX_CONN +
((CONFIG_BT_MAX_CONN - 1) * PROXY_BUF_LEN_MAX)];
static struct bt_mesh_proxy_role roles[CONFIG_BT_MAX_CONN];
@@ -176,8 +176,6 @@ int bt_mesh_proxy_msg_send(struct bt_mesh_proxy_role *role, uint8_t type,
static void proxy_msg_init(struct bt_mesh_proxy_role *role)
{
- uint8_t i, len;
- uint8_t *buf;
/* Check if buf has been allocated, in this way, we no longer need
* to repeat the operation.
@@ -187,16 +185,9 @@ static void proxy_msg_init(struct bt_mesh_proxy_role *role)
return;
}
- i = role->conn_handle;
- if (!i) {
- len = PROXY_MSG_FIRST_BUF_LEN;
- buf = bufs;
- } else {
- len = PROXY_BUF_LEN_MAX;
- buf = &bufs[PROXY_MSG_FIRST_BUF_LEN + (PROXY_BUF_LEN_MAX * (i - 1))];
- }
-
- net_buf_simple_init_with_data(role->buf, buf, len);
+ net_buf_simple_init_with_data(role->buf,
+ &bufs[role->conn_handle * PROXY_MSG_BUF_LEN],
+ PROXY_MSG_BUF_LEN);
net_buf_simple_reset(role->buf);
}
