Lines Matching refs:cli

38 	struct bt_mesh_rpr_cli *cli;  member
46 static void link_reset(struct bt_mesh_rpr_cli *cli);
47 static void link_closed(struct bt_mesh_rpr_cli *cli,
50 static void link_report(struct bt_mesh_rpr_cli *cli, in link_report() argument
54 struct pb_remote_ctx ctx = { cli, srv }; in link_report()
65 cli->link.time = PROTOCOL_TIMEOUT_SEC; in link_report()
81 static void tx_complete(struct bt_mesh_rpr_cli *cli, int err, void *cb_data) in tx_complete() argument
85 cli->link.tx_pdu++; in tx_complete()
86 bt_mesh_msg_ack_ctx_clear(&cli->prov_ack_ctx); in tx_complete()
97 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_extended_scan_report() local
119 if (cli->scan_report && found_dev) { in handle_extended_scan_report()
120 cli->scan_report(cli, &srv, &dev, buf); in handle_extended_scan_report()
130 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_link_report() local
143 if (cli->link.srv.addr != srv.addr) { in handle_link_report()
148 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in handle_link_report()
150 cli->link.state = link.state; in handle_link_report()
156 link_reset(cli); in handle_link_report()
159 link_report(cli, &cli->link.srv, &link); in handle_link_report()
167 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_link_status() local
178 if (bt_mesh_msg_ack_ctx_match(&cli->prov_ack_ctx, RPR_OP_LINK_STATUS, in handle_link_status()
181 bt_mesh_msg_ack_ctx_rx(&cli->prov_ack_ctx); in handle_link_status()
184 if (cli->link.srv.addr == srv.addr) { in handle_link_status()
185 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in handle_link_status()
187 cli->link.state = link.state; in handle_link_status()
189 cli->link.srv.addr = BT_MESH_ADDR_UNASSIGNED; in handle_link_status()
192 link_report(cli, &cli->link.srv, &link); in handle_link_status()
201 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_pdu_outbound_report() local
206 if (srv.addr != cli->link.srv.addr) { in handle_pdu_outbound_report()
215 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in handle_pdu_outbound_report()
217 if (!bt_mesh_msg_ack_ctx_match(&cli->prov_ack_ctx, RPR_OP_PDU_OUTBOUND_REPORT, in handle_pdu_outbound_report()
219 num != cli->link.tx_pdu) { in handle_pdu_outbound_report()
224 tx_complete(cli, 0, cb_data); in handle_pdu_outbound_report()
232 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_pdu_report() local
235 cli, in handle_pdu_report()
236 &cli->link.srv, in handle_pdu_report()
240 if (cli->link.srv.addr != srv.addr) { in handle_pdu_report()
245 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in handle_pdu_report()
248 if (pdu <= cli->link.rx_pdu) { in handle_pdu_report()
263 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_scan_caps_status() local
267 if (!bt_mesh_msg_ack_ctx_match(&cli->scan_ack_ctx, RPR_OP_SCAN_CAPS_STATUS, in handle_scan_caps_status()
279 bt_mesh_msg_ack_ctx_rx(&cli->scan_ack_ctx); in handle_scan_caps_status()
287 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_scan_report() local
309 if (cli->scan_report) { in handle_scan_report()
310 cli->scan_report(cli, &srv, &dev, NULL); in handle_scan_report()
319 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in handle_scan_status() local
323 if (!bt_mesh_msg_ack_ctx_match(&cli->scan_ack_ctx, RPR_OP_SCAN_STATUS, in handle_scan_status()
336 bt_mesh_msg_ack_ctx_rx(&cli->scan_ack_ctx); in handle_scan_status()
355 struct bt_mesh_rpr_cli *cli = CONTAINER_OF(k_work_delayable_from_work(work), in link_timeout() local
360 link_closed(cli, BT_MESH_RPR_ERR_LINK_CLOSED_BY_CLIENT); in link_timeout()
372 struct bt_mesh_rpr_cli *cli = mod->rt->user_data; in rpr_cli_init() local
374 cli->mod = mod; in rpr_cli_init()
375 cli->link.time = LINK_TIMEOUT_SECONDS_DEFAULT; in rpr_cli_init()
377 bt_mesh_msg_ack_ctx_init(&cli->scan_ack_ctx); in rpr_cli_init()
378 bt_mesh_msg_ack_ctx_init(&cli->prov_ack_ctx); in rpr_cli_init()
379 k_work_init_delayable(&cli->link.timeout, link_timeout); in rpr_cli_init()
392 struct bt_mesh_rpr_cli *cli = cb_data; in pdu_send_start() local
397 link_closed(cli, in pdu_send_start()
404 struct bt_mesh_rpr_cli *cli = cb_data; in pdu_send_end() local
409 link_closed(cli, in pdu_send_end()
414 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in pdu_send_end()
422 static int tx_wait(struct bt_mesh_rpr_cli *cli, in tx_wait() argument
434 err = bt_mesh_model_send(cli->mod, &ctx, buf, NULL, NULL); in tx_wait()
447 static void link_init(struct bt_mesh_rpr_cli *cli, in link_init() argument
450 cli->link.srv = *srv; in link_init()
451 cli->link.state = BT_MESH_RPR_LINK_IDLE; in link_init()
452 cli->link.rx_pdu = 0; in link_init()
453 cli->link.tx_pdu = 1; in link_init()
454 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in link_init()
457 static void link_reset(struct bt_mesh_rpr_cli *cli) in link_reset() argument
459 k_work_cancel_delayable(&cli->link.timeout); in link_reset()
460 cli->link.srv.addr = BT_MESH_ADDR_UNASSIGNED; in link_reset()
461 cli->link.state = BT_MESH_RPR_LINK_IDLE; in link_reset()
462 bt_mesh_msg_ack_ctx_clear(&cli->prov_ack_ctx); in link_reset()
465 static void link_closed(struct bt_mesh_rpr_cli *cli, in link_closed() argument
468 struct bt_mesh_rpr_node srv = cli->link.srv; in link_closed()
475 cli->link.state, cli->link.rx_pdu, cli->link.tx_pdu); in link_closed()
477 link_reset(cli); in link_closed()
479 link_report(cli, &srv, &link); in link_closed()
482 int bt_mesh_rpr_scan_caps_get(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_scan_caps_get() argument
489 return tx_wait(cli, &cli->scan_ack_ctx, srv, &buf, RPR_OP_SCAN_CAPS_STATUS, caps); in bt_mesh_rpr_scan_caps_get()
492 int bt_mesh_rpr_scan_get(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_scan_get() argument
499 return tx_wait(cli, &cli->scan_ack_ctx, srv, &buf, RPR_OP_SCAN_STATUS, status); in bt_mesh_rpr_scan_get()
502 int bt_mesh_rpr_scan_start(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_scan_start() argument
522 return tx_wait(cli, &cli->scan_ack_ctx, srv, &buf, RPR_OP_SCAN_STATUS, status); in bt_mesh_rpr_scan_start()
525 int bt_mesh_rpr_scan_start_ext(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_scan_start_ext() argument
549 return bt_mesh_model_send(cli->mod, &ctx, &buf, NULL, NULL); in bt_mesh_rpr_scan_start_ext()
552 int bt_mesh_rpr_scan_stop(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_scan_stop() argument
559 return tx_wait(cli, &cli->scan_ack_ctx, srv, &buf, RPR_OP_SCAN_STATUS, status); in bt_mesh_rpr_scan_stop()
562 int bt_mesh_rpr_link_get(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_link_get() argument
569 return tx_wait(cli, &cli->prov_ack_ctx, srv, &buf, RPR_OP_LINK_STATUS, rsp); in bt_mesh_rpr_link_get()
572 int bt_mesh_rpr_link_close(struct bt_mesh_rpr_cli *cli, in bt_mesh_rpr_link_close() argument
580 return tx_wait(cli, &cli->prov_ack_ctx, srv, &buf, RPR_OP_LINK_STATUS, rsp); in bt_mesh_rpr_link_close()
583 static int link_open_prov(struct bt_mesh_rpr_cli *cli, in link_open_prov() argument
594 if (cli->link.time != LINK_TIMEOUT_SECONDS_DEFAULT) { in link_open_prov()
595 net_buf_simple_add_u8(&buf, cli->link.time); in link_open_prov()
598 return bt_mesh_model_send(cli->mod, &ctx, &buf, NULL, NULL); in link_open_prov()
601 static int link_open_node(struct bt_mesh_rpr_cli *cli, in link_open_node() argument
612 return bt_mesh_model_send(cli->mod, &ctx, &buf, NULL, NULL); in link_open_node()
615 static int link_close(struct bt_mesh_rpr_cli *cli, in link_close() argument
618 struct bt_mesh_msg_ctx ctx = LINK_CTX(&cli->link.srv, false); in link_close()
621 if (cli->link.srv.addr == BT_MESH_ADDR_UNASSIGNED) { in link_close()
630 err = bt_mesh_model_send(cli->mod, &ctx, &buf, NULL, NULL); in link_close()
632 link_reset(cli); in link_close()
635 k_work_reschedule(&cli->link.timeout, K_SECONDS(cli->link.time)); in link_close()
639 static int send(struct bt_mesh_rpr_cli *cli, struct net_buf_simple *buf, in send() argument
642 struct bt_mesh_msg_ctx ctx = LINK_CTX(&cli->link.srv, true); in send()
645 if (cli->link.srv.addr == BT_MESH_ADDR_UNASSIGNED) { in send()
655 err = bt_mesh_msg_ack_ctx_prepare(&cli->prov_ack_ctx, in send()
657 cli->link.srv.addr, cb_data); in send()
665 net_buf_simple_push_u8(buf, cli->link.tx_pdu); in send()
670 err = bt_mesh_model_send(cli->mod, &ctx, buf, &pdu_send_cb, cli); in send()
672 link_closed(cli, in send()
697 return send(bearer.cli, buf, cb_data); in pb_send()
709 struct bt_mesh_rpr_cli *cli = ctx->cli; in pb_link_open() local
713 if (cli->link.srv.addr != BT_MESH_ADDR_UNASSIGNED) { in pb_link_open()
717 bearer.cli = ctx->cli; in pb_link_open()
720 cli->link.time = timeout ? timeout : LINK_TIMEOUT_SECONDS_DEFAULT; in pb_link_open()
722 LOG_DBG("timeout: %d", cli->link.time); in pb_link_open()
724 link_init(cli, srv); in pb_link_open()
727 err = link_open_prov(cli, srv, uuid, timeout); in pb_link_open()
729 err = link_open_node(cli, srv, ctx->refresh); in pb_link_open()
733 link_reset(cli); in pb_link_open()
746 err = link_close(bearer.cli, status); in pb_link_close()