Lines Matching refs:role
59 static void proxy_queue_put(struct bt_mesh_proxy_role *role, struct bt_mesh_adv *adv) in proxy_queue_put() argument
61 k_fifo_put(&role->pending, &(adv->gatt_bearer[bt_conn_index(role->conn)])); in proxy_queue_put()
64 static struct bt_mesh_adv *proxy_queue_get(struct bt_mesh_proxy_role *role) in proxy_queue_get() argument
68 gatt_bearer = k_fifo_get(&role->pending, K_NO_WAIT); in proxy_queue_get()
74 gatt_bearer[bt_conn_index(role->conn)]); in proxy_queue_get()
79 struct bt_mesh_proxy_role *role; in proxy_sar_timeout() local
84 role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer); in proxy_sar_timeout()
86 while (!k_fifo_is_empty(&role->pending)) { in proxy_sar_timeout()
87 struct bt_mesh_adv *adv = proxy_queue_get(role); in proxy_sar_timeout()
94 if (role->conn) { in proxy_sar_timeout()
95 bt_conn_disconnect(role->conn, in proxy_sar_timeout()
104 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_msg_recv() local
106 if (net_buf_simple_tailroom(&role->buf) < len - 1) { in bt_mesh_proxy_msg_recv()
113 if (role->buf.len) { in bt_mesh_proxy_msg_recv()
118 role->msg_type = PDU_TYPE(data); in bt_mesh_proxy_msg_recv()
119 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
120 role->cb.recv(role); in bt_mesh_proxy_msg_recv()
121 net_buf_simple_reset(&role->buf); in bt_mesh_proxy_msg_recv()
125 if (role->buf.len) { in bt_mesh_proxy_msg_recv()
130 k_work_reschedule(&role->sar_timer, PROXY_SAR_TIMEOUT); in bt_mesh_proxy_msg_recv()
131 role->msg_type = PDU_TYPE(data); in bt_mesh_proxy_msg_recv()
132 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
136 if (!role->buf.len) { in bt_mesh_proxy_msg_recv()
141 if (role->msg_type != PDU_TYPE(data)) { in bt_mesh_proxy_msg_recv()
146 k_work_reschedule(&role->sar_timer, PROXY_SAR_TIMEOUT); in bt_mesh_proxy_msg_recv()
147 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
151 if (!role->buf.len) { in bt_mesh_proxy_msg_recv()
156 if (role->msg_type != PDU_TYPE(data)) { in bt_mesh_proxy_msg_recv()
164 (void)k_work_cancel_delayable(&role->sar_timer); in bt_mesh_proxy_msg_recv()
165 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
166 role->cb.recv(role); in bt_mesh_proxy_msg_recv()
167 net_buf_simple_reset(&role->buf); in bt_mesh_proxy_msg_recv()
181 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_msg_send() local
195 return role->cb.send(conn, msg->data, msg->len, end, user_data); in bt_mesh_proxy_msg_send()
199 err = role->cb.send(conn, msg->data, mtu, NULL, NULL); in bt_mesh_proxy_msg_send()
209 err = role->cb.send(conn, msg->data, msg->len, end, user_data); in bt_mesh_proxy_msg_send()
218 err = role->cb.send(conn, msg->data, mtu, NULL, NULL); in bt_mesh_proxy_msg_send()
268 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_relay_send() local
270 proxy_queue_put(role, bt_mesh_adv_ref(adv)); in bt_mesh_proxy_relay_send()
272 bt_mesh_wq_submit(&role->work); in bt_mesh_proxy_relay_send()
279 struct bt_mesh_proxy_role *role = CONTAINER_OF(work, struct bt_mesh_proxy_role, work); in proxy_msg_send_pending() local
282 if (!role->conn) { in proxy_msg_send_pending()
286 adv = proxy_queue_get(role); in proxy_msg_send_pending()
291 (void)proxy_relay_send(role->conn, adv); in proxy_msg_send_pending()
294 if (!k_fifo_is_empty(&role->pending)) { in proxy_msg_send_pending()
295 bt_mesh_wq_submit(&role->work); in proxy_msg_send_pending()
299 static void proxy_msg_init(struct bt_mesh_proxy_role *role) in proxy_msg_init() argument
304 if (role->buf.__buf) { in proxy_msg_init()
305 net_buf_simple_reset(&role->buf); in proxy_msg_init()
309 net_buf_simple_init_with_data(&role->buf, in proxy_msg_init()
310 &bufs[bt_conn_index(role->conn) * in proxy_msg_init()
314 net_buf_simple_reset(&role->buf); in proxy_msg_init()
316 k_fifo_init(&role->pending); in proxy_msg_init()
317 k_work_init(&role->work, proxy_msg_send_pending); in proxy_msg_init()
319 k_work_init_delayable(&role->sar_timer, proxy_sar_timeout); in proxy_msg_init()
326 struct bt_mesh_proxy_role *role; in bt_mesh_proxy_role_setup() local
330 role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_role_setup()
332 role->conn = bt_conn_ref(conn); in bt_mesh_proxy_role_setup()
333 proxy_msg_init(role); in bt_mesh_proxy_role_setup()
335 role->cb.recv = recv; in bt_mesh_proxy_role_setup()
336 role->cb.send = send; in bt_mesh_proxy_role_setup()
338 return role; in bt_mesh_proxy_role_setup()
341 void bt_mesh_proxy_role_cleanup(struct bt_mesh_proxy_role *role) in bt_mesh_proxy_role_cleanup() argument
346 (void)k_work_cancel_delayable(&role->sar_timer); in bt_mesh_proxy_role_cleanup()
347 bt_conn_unref(role->conn); in bt_mesh_proxy_role_cleanup()
348 role->conn = NULL; in bt_mesh_proxy_role_cleanup()