Lines Matching full:role
61 struct bt_mesh_proxy_role *role; in proxy_sar_timeout() local
66 role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer); in proxy_sar_timeout()
68 while (!k_fifo_is_empty(&role->pending)) { in proxy_sar_timeout()
69 struct bt_mesh_adv *adv = k_fifo_get(&role->pending, K_NO_WAIT); in proxy_sar_timeout()
76 if (role->conn) { in proxy_sar_timeout()
77 bt_conn_disconnect(role->conn, in proxy_sar_timeout()
86 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_msg_recv() local
88 if (net_buf_simple_tailroom(&role->buf) < len - 1) { in bt_mesh_proxy_msg_recv()
89 LOG_WRN("Proxy role buffer overflow"); in bt_mesh_proxy_msg_recv()
95 if (role->buf.len) { in bt_mesh_proxy_msg_recv()
100 role->msg_type = PDU_TYPE(data); in bt_mesh_proxy_msg_recv()
101 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
102 role->cb.recv(role); in bt_mesh_proxy_msg_recv()
103 net_buf_simple_reset(&role->buf); in bt_mesh_proxy_msg_recv()
107 if (role->buf.len) { in bt_mesh_proxy_msg_recv()
112 k_work_reschedule(&role->sar_timer, PROXY_SAR_TIMEOUT); in bt_mesh_proxy_msg_recv()
113 role->msg_type = PDU_TYPE(data); in bt_mesh_proxy_msg_recv()
114 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
118 if (!role->buf.len) { in bt_mesh_proxy_msg_recv()
123 if (role->msg_type != PDU_TYPE(data)) { in bt_mesh_proxy_msg_recv()
128 k_work_reschedule(&role->sar_timer, PROXY_SAR_TIMEOUT); in bt_mesh_proxy_msg_recv()
129 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
133 if (!role->buf.len) { in bt_mesh_proxy_msg_recv()
138 if (role->msg_type != PDU_TYPE(data)) { in bt_mesh_proxy_msg_recv()
146 (void)k_work_cancel_delayable(&role->sar_timer); in bt_mesh_proxy_msg_recv()
147 net_buf_simple_add_mem(&role->buf, data + 1, len - 1); in bt_mesh_proxy_msg_recv()
148 role->cb.recv(role); in bt_mesh_proxy_msg_recv()
149 net_buf_simple_reset(&role->buf); in bt_mesh_proxy_msg_recv()
162 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_msg_send() local
171 return role->cb.send(conn, msg->data, msg->len, end, user_data); in bt_mesh_proxy_msg_send()
175 err = role->cb.send(conn, msg->data, mtu, NULL, NULL); in bt_mesh_proxy_msg_send()
185 err = role->cb.send(conn, msg->data, msg->len, end, user_data); in bt_mesh_proxy_msg_send()
194 err = role->cb.send(conn, msg->data, mtu, NULL, NULL); in bt_mesh_proxy_msg_send()
244 struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_relay_send() local
246 k_fifo_put(&role->pending, bt_mesh_adv_ref(adv)); in bt_mesh_proxy_relay_send()
248 bt_mesh_wq_submit(&role->work); in bt_mesh_proxy_relay_send()
255 struct bt_mesh_proxy_role *role = CONTAINER_OF(work, struct bt_mesh_proxy_role, work); in proxy_msg_send_pending() local
258 if (!role->conn) { in proxy_msg_send_pending()
262 adv = k_fifo_get(&role->pending, K_NO_WAIT); in proxy_msg_send_pending()
267 (void)proxy_relay_send(role->conn, adv); in proxy_msg_send_pending()
270 if (!k_fifo_is_empty(&role->pending)) { in proxy_msg_send_pending()
271 bt_mesh_wq_submit(&role->work); in proxy_msg_send_pending()
275 static void proxy_msg_init(struct bt_mesh_proxy_role *role) in proxy_msg_init() argument
280 if (role->buf.__buf) { in proxy_msg_init()
281 net_buf_simple_reset(&role->buf); in proxy_msg_init()
285 net_buf_simple_init_with_data(&role->buf, in proxy_msg_init()
286 &bufs[bt_conn_index(role->conn) * in proxy_msg_init()
290 net_buf_simple_reset(&role->buf); in proxy_msg_init()
292 k_fifo_init(&role->pending); in proxy_msg_init()
293 k_work_init(&role->work, proxy_msg_send_pending); in proxy_msg_init()
295 k_work_init_delayable(&role->sar_timer, proxy_sar_timeout); in proxy_msg_init()
302 struct bt_mesh_proxy_role *role; in bt_mesh_proxy_role_setup() local
306 role = &roles[bt_conn_index(conn)]; in bt_mesh_proxy_role_setup()
308 role->conn = bt_conn_ref(conn); in bt_mesh_proxy_role_setup()
309 proxy_msg_init(role); in bt_mesh_proxy_role_setup()
311 role->cb.recv = recv; in bt_mesh_proxy_role_setup()
312 role->cb.send = send; in bt_mesh_proxy_role_setup()
314 return role; in bt_mesh_proxy_role_setup()
317 void bt_mesh_proxy_role_cleanup(struct bt_mesh_proxy_role *role) in bt_mesh_proxy_role_cleanup() argument
322 (void)k_work_cancel_delayable(&role->sar_timer); in bt_mesh_proxy_role_cleanup()
323 bt_conn_unref(role->conn); in bt_mesh_proxy_role_cleanup()
324 role->conn = NULL; in bt_mesh_proxy_role_cleanup()