Lines Matching refs:scan

69 	} scan;  member
90 .scan = {
104 for (i = 0; i < srv.scan.max_devs; ++i) { in unprov_get()
106 if ((srv.scan.devs[i].flags & BT_MESH_RPR_UNPROV_ACTIVE) && in unprov_get()
107 !memcmp(srv.scan.devs[i].uuid, uuid, 16)) { in unprov_get()
108 return &srv.scan.devs[i]; in unprov_get()
110 } else if (!(srv.scan.devs[i].flags & BT_MESH_RPR_UNPROV_ACTIVE)) { in unprov_get()
111 return &srv.scan.devs[i]; in unprov_get()
134 srv.scan.cli.addr = BT_MESH_ADDR_UNASSIGNED; in cli_scan_clear()
135 srv.scan.cli.net_idx = BT_MESH_KEY_UNUSED; in cli_scan_clear()
151 k_work_delayable_remaining_get(&srv.scan.timeout)) / in scan_status_send()
158 net_buf_simple_add_u8(&rsp, srv.scan.state); in scan_status_send()
159 net_buf_simple_add_u8(&rsp, srv.scan.max_devs); in scan_status_send()
198 if (k_work_delayable_remaining_get(&srv.scan.report) || in scan_report_schedule()
206 k_work_reschedule(&srv.scan.report, K_MSEC(delay)); in scan_report_schedule()
212 k_work_reschedule(&srv.scan.report, K_NO_WAIT); in scan_report_sent()
221 struct bt_mesh_msg_ctx ctx = LINK_CTX(&srv.scan.cli, true); in scan_report_send()
228 for (i = 0; i < srv.scan.max_devs; ++i) { in scan_report_send()
229 struct bt_mesh_rpr_unprov *dev = &srv.scan.devs[i]; in scan_report_send()
262 struct bt_mesh_msg_ctx ctx = LINK_CTX(&srv.scan.cli, true); in scan_ext_report_send()
269 net_buf_simple_add_mem(&buf, srv.scan.dev->uuid, 16); in scan_ext_report_send()
271 if (srv.scan.dev->flags & BT_MESH_RPR_UNPROV_FOUND) { in scan_ext_report_send()
272 net_buf_simple_add_le16(&buf, srv.scan.dev->oob); in scan_ext_report_send()
278 if (srv.scan.dev->flags & BT_MESH_RPR_UNPROV_EXT_ADV_RXD) { in scan_ext_report_send()
279 net_buf_simple_add_mem(&buf, srv.scan.adv_data->data, in scan_ext_report_send()
280 srv.scan.adv_data->len); in scan_ext_report_send()
282 bt_hex(srv.scan.adv_data->data, srv.scan.adv_data->len)); in scan_ext_report_send()
285 srv.scan.dev->flags &= ~BT_MESH_RPR_UNPROV_EXT_ADV_RXD; in scan_ext_report_send()
289 srv.scan.dev->flags |= BT_MESH_RPR_UNPROV_REPORTED; in scan_ext_report_send()
297 k_work_cancel_delayable(&srv.scan.report); in scan_stop()
298 k_work_cancel_delayable(&srv.scan.timeout); in scan_stop()
299 srv.scan.state = BT_MESH_RPR_SCAN_IDLE; in scan_stop()
314 if ((remaining_time + srv.scan.additional_time) && in scan_ext_stop()
315 srv.scan.state != BT_MESH_RPR_SCAN_IDLE) { in scan_ext_stop()
317 &srv.scan.timeout, in scan_ext_stop()
318 K_MSEC(remaining_time + srv.scan.additional_time)); in scan_ext_stop()
319 } else if (srv.scan.state == BT_MESH_RPR_SCAN_MULTI) { in scan_ext_stop()
322 } else if (srv.scan.state != BT_MESH_RPR_SCAN_IDLE) { in scan_ext_stop()
329 if (!(srv.scan.dev->flags & BT_MESH_RPR_UNPROV_REPORTED)) { in scan_ext_stop()
334 srv.scan.dev = NULL; in scan_ext_stop()
342 LOG_DBG("%s", (srv.scan.dev ? "Extended scanning" : "Normal scanning")); in scan_timeout()
344 if (srv.scan.dev) { in scan_timeout()
430 subnet->net_idx == srv.scan.cli.net_idx) { in subnet_evt_handler()
590 if (srv.scan.state != BT_MESH_RPR_SCAN_IDLE && in handle_scan_start()
591 !rpr_node_equal(&cli, &srv.scan.cli)) { in handle_scan_start()
596 for (i = 0; i < ARRAY_SIZE(srv.scan.devs); ++i) { in handle_scan_start()
597 srv.scan.devs[i].flags = 0; in handle_scan_start()
601 srv.scan.state = BT_MESH_RPR_SCAN_SINGLE; in handle_scan_start()
603 srv.scan.devs[0].flags = BT_MESH_RPR_UNPROV_ACTIVE; in handle_scan_start()
604 memcpy(srv.scan.devs[0].uuid, uuid, 16); in handle_scan_start()
606 srv.scan.state = BT_MESH_RPR_SCAN_MULTI; in handle_scan_start()
609 srv.scan.max_devs = in handle_scan_start()
612 srv.scan.cli = cli; in handle_scan_start()
616 k_work_reschedule(&srv.scan.timeout, K_SECONDS(timeout)); in handle_scan_start()
726 if (srv.scan.dev && (memcmp(srv.scan.dev->uuid, uuid, 16) || in handle_extended_scan_start()
727 !rpr_node_equal(&srv.scan.cli, &cli))) { in handle_extended_scan_start()
733 if (srv.scan.state == BT_MESH_RPR_SCAN_IDLE) { in handle_extended_scan_start()
734 srv.scan.max_devs = 1; in handle_extended_scan_start()
735 srv.scan.devs[0].flags = 0; in handle_extended_scan_start()
738 srv.scan.dev = unprov_get(uuid); in handle_extended_scan_start()
739 if (!srv.scan.dev) { in handle_extended_scan_start()
740 srv.scan.dev = unprov_get(NULL); in handle_extended_scan_start()
741 if (!srv.scan.dev) { in handle_extended_scan_start()
747 memcpy(srv.scan.dev->uuid, uuid, 16); in handle_extended_scan_start()
748 srv.scan.dev->oob = 0; in handle_extended_scan_start()
749 srv.scan.dev->flags = 0; in handle_extended_scan_start()
752 memcpy(srv.scan.ad, ad, ad_count); in handle_extended_scan_start()
753 srv.scan.ad_count = ad_count; in handle_extended_scan_start()
754 net_buf_simple_reset(srv.scan.adv_data); in handle_extended_scan_start()
758 srv.scan.dev->flags &= ~BT_MESH_RPR_UNPROV_REPORTED; in handle_extended_scan_start()
759 srv.scan.dev->flags |= BT_MESH_RPR_UNPROV_ACTIVE | BT_MESH_RPR_UNPROV_EXT; in handle_extended_scan_start()
761 if (srv.scan.state == BT_MESH_RPR_SCAN_IDLE) { in handle_extended_scan_start()
762 srv.scan.additional_time = 0; in handle_extended_scan_start()
763 srv.scan.cli = cli; in handle_extended_scan_start()
765 k_work_delayable_remaining_get(&srv.scan.timeout)) < in handle_extended_scan_start()
767 srv.scan.additional_time = 0; in handle_extended_scan_start()
769 srv.scan.additional_time = in handle_extended_scan_start()
770 k_ticks_to_ms_floor32(k_work_delayable_remaining_get(&srv.scan.timeout)) - in handle_extended_scan_start()
775 k_work_reschedule(&srv.scan.timeout, K_SECONDS(timeout)); in handle_extended_scan_start()
916 srv.link.dev = &srv.scan.devs[0]; in handle_link_open()
1058 if (srv.scan.state != BT_MESH_RPR_SCAN_MULTI) { in adv_handle_beacon()
1084 LOG_DBG("Unprov #%u: %s OOB: 0x%04x %s", dev - &srv.scan.devs[0], in adv_handle_beacon()
1089 if (dev != srv.scan.dev && !(dev->flags & BT_MESH_RPR_UNPROV_REPORTED)) { in adv_handle_beacon()
1126 !bt_addr_le_cmp(&srv.scan.addr, info->addr)) { in adv_handle_ext_scan()
1127 dev = srv.scan.dev; in adv_handle_ext_scan()
1145 (srv.scan.dev->flags & BT_MESH_RPR_UNPROV_HASH)) { in adv_handle_ext_scan()
1149 memcmp(hash, &srv.scan.dev->hash, 4)) { in adv_handle_ext_scan()
1155 dev = srv.scan.dev; in adv_handle_ext_scan()
1156 srv.scan.dev->flags |= BT_MESH_RPR_UNPROV_EXT_ADV_RXD; in adv_handle_ext_scan()
1173 srv.scan.addr = *info->addr; in adv_handle_ext_scan()
1190 if (srv.scan.ad_count == 1 && in adv_handle_ext_scan()
1191 get_ad_type(srv.scan.ad, 1, BT_DATA_URI) && in adv_handle_ext_scan()
1196 while (srv.scan.ad_count && pull_ad_data(buf, &ad)) { in adv_handle_ext_scan()
1199 ad_entry = get_ad_type(srv.scan.ad, srv.scan.ad_count, ad.type); in adv_handle_ext_scan()
1211 net_buf_simple_tailroom(srv.scan.adv_data)) { in adv_handle_ext_scan()
1216 net_buf_simple_add_u8(srv.scan.adv_data, ad.data_len + 1); in adv_handle_ext_scan()
1217 net_buf_simple_add_u8(srv.scan.adv_data, ad.type); in adv_handle_ext_scan()
1218 net_buf_simple_add_mem(srv.scan.adv_data, ad.data, ad.data_len); in adv_handle_ext_scan()
1220 *ad_entry = srv.scan.ad[--srv.scan.ad_count]; in adv_handle_ext_scan()
1234 if (!srv.scan.ad_count) { in adv_handle_ext_scan()
1270 srv.scan.additional_time = 0; in adv_handle_ext_scan()
1271 if (srv.scan.state != BT_MESH_RPR_SCAN_MULTI) { in adv_handle_ext_scan()
1272 k_work_cancel_delayable(&srv.scan.timeout); in adv_handle_ext_scan()
1301 if (srv.scan.dev) { in scan_packet_recv()
1322 net_buf_simple_init(srv.scan.adv_data, 0); in rpr_srv_init()
1324 k_work_init_delayable(&srv.scan.timeout, scan_timeout); in rpr_srv_init()
1325 k_work_init_delayable(&srv.scan.report, scan_report_timeout); in rpr_srv_init()
1338 srv.scan.state = BT_MESH_RPR_SCAN_IDLE; in rpr_srv_reset()
1340 k_work_cancel_delayable(&srv.scan.timeout); in rpr_srv_reset()
1341 k_work_cancel_delayable(&srv.scan.report); in rpr_srv_reset()
1342 net_buf_simple_init(srv.scan.adv_data, 0); in rpr_srv_reset()
1345 srv.scan.dev = NULL; in rpr_srv_reset()