Lines Matching refs:ext_adv
78 static bool schedule_send(struct bt_mesh_ext_adv *ext_adv);
156 static int adv_start(struct bt_mesh_ext_adv *ext_adv, in adv_start() argument
164 if (!ext_adv->instance) { in adv_start()
169 if (atomic_test_and_set_bit(ext_adv->flags, ADV_FLAG_ACTIVE)) { in adv_start()
174 if (atomic_test_bit(ext_adv->flags, ADV_FLAG_UPDATE_PARAMS)) { in adv_start()
175 err = bt_le_ext_adv_update_param(ext_adv->instance, param); in adv_start()
178 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in adv_start()
182 atomic_set_bit_to(ext_adv->flags, ADV_FLAG_UPDATE_PARAMS, in adv_start()
183 param != &ext_adv->adv_param); in adv_start()
186 err = bt_le_ext_adv_set_data(ext_adv->instance, ad, ad_len, sd, sd_len); in adv_start()
189 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in adv_start()
193 ext_adv->timestamp = k_uptime_get_32(); in adv_start()
195 err = bt_le_ext_adv_start(ext_adv->instance, start); in adv_start()
198 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in adv_start()
204 static int bt_data_send(struct bt_mesh_ext_adv *ext_adv, uint8_t num_events, uint16_t adv_interval, in bt_data_send() argument
214 if (ext_adv->adv_param.interval_min != BT_MESH_ADV_SCAN_UNIT(adv_interval)) { in bt_data_send()
215 ext_adv->adv_param.interval_min = BT_MESH_ADV_SCAN_UNIT(adv_interval); in bt_data_send()
216 ext_adv->adv_param.interval_max = ext_adv->adv_param.interval_min; in bt_data_send()
217 atomic_set_bit(ext_adv->flags, ADV_FLAG_UPDATE_PARAMS); in bt_data_send()
220 return adv_start(ext_adv, &ext_adv->adv_param, &start, ad, ad_len, NULL, 0); in bt_data_send()
223 static int adv_send(struct bt_mesh_ext_adv *ext_adv, struct bt_mesh_adv *adv) in adv_send() argument
243 err = bt_data_send(ext_adv, num_events, adv_int, &ad, 1); in adv_send()
245 ext_adv->adv = bt_mesh_adv_ref(adv); in adv_send()
261 static bool schedule_send_with_mask(struct bt_mesh_ext_adv *ext_adv, int ignore_mask) in schedule_send_with_mask() argument
263 if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_PROXY)) { in schedule_send_with_mask()
264 atomic_clear_bit(ext_adv->flags, ADV_FLAG_PROXY_START); in schedule_send_with_mask()
265 (void)bt_le_ext_adv_stop(ext_adv->instance); in schedule_send_with_mask()
267 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in schedule_send_with_mask()
270 if (atomic_test_bit(ext_adv->flags, ADV_FLAG_ACTIVE)) { in schedule_send_with_mask()
271 atomic_set_bit(ext_adv->flags, ADV_FLAG_SCHEDULE_PENDING); in schedule_send_with_mask()
273 } else if ((~ignore_mask) & k_work_busy_get(&ext_adv->work)) { in schedule_send_with_mask()
277 atomic_clear_bit(ext_adv->flags, ADV_FLAG_SCHEDULE_PENDING); in schedule_send_with_mask()
278 bt_mesh_wq_submit(&ext_adv->work); in schedule_send_with_mask()
285 struct bt_mesh_ext_adv *ext_adv; in send_pending_adv() local
289 ext_adv = CONTAINER_OF(work, struct bt_mesh_ext_adv, work); in send_pending_adv()
291 if (atomic_test_bit(ext_adv->flags, ADV_FLAG_SUSPENDING)) { in send_pending_adv()
296 if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_SENT)) { in send_pending_adv()
298 k_uptime_get_32() - ext_adv->timestamp, in send_pending_adv()
299 ext_adv->adv ? adv_tag_to_str[ext_adv->adv->ctx.tag] in send_pending_adv()
302 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in send_pending_adv()
303 atomic_clear_bit(ext_adv->flags, ADV_FLAG_PROXY); in send_pending_adv()
304 atomic_clear_bit(ext_adv->flags, ADV_FLAG_PROXY_START); in send_pending_adv()
306 if (ext_adv->adv) { in send_pending_adv()
307 struct bt_mesh_adv_ctx ctx = ext_adv->adv->ctx; in send_pending_adv()
309 ext_adv->adv->ctx.started = 0; in send_pending_adv()
310 bt_mesh_adv_unref(ext_adv->adv); in send_pending_adv()
313 ext_adv->adv = NULL; in send_pending_adv()
317 while ((adv = bt_mesh_adv_get_by_tag(ext_adv->tags, K_NO_WAIT))) { in send_pending_adv()
325 err = adv_send(ext_adv, adv); in send_pending_adv()
334 if (ext_adv->instance == NULL) { in send_pending_adv()
345 !(ext_adv->tags & BT_MESH_ADV_TAG_BIT_PROXY)) { in send_pending_adv()
349 atomic_set_bit(ext_adv->flags, ADV_FLAG_PROXY_START); in send_pending_adv()
352 atomic_set_bit(ext_adv->flags, ADV_FLAG_PROXY); in send_pending_adv()
355 if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_SCHEDULE_PENDING)) { in send_pending_adv()
356 schedule_send_with_mask(ext_adv, K_WORK_RUNNING); in send_pending_adv()
360 static bool schedule_send(struct bt_mesh_ext_adv *ext_adv) in schedule_send() argument
362 return schedule_send_with_mask(ext_adv, 0); in schedule_send()
377 struct bt_mesh_ext_adv *ext_adv = relay_adv_get(); in bt_mesh_adv_relay_ready() local
380 if (schedule_send(&ext_adv[i])) { in bt_mesh_adv_relay_ready()
406 struct bt_mesh_ext_adv *ext_adv = &advs[i]; in bt_mesh_adv_terminate() local
408 if (ext_adv->adv != adv) { in bt_mesh_adv_terminate()
412 if (!atomic_test_bit(ext_adv->flags, ADV_FLAG_ACTIVE)) { in bt_mesh_adv_terminate()
416 err = bt_le_ext_adv_stop(ext_adv->instance); in bt_mesh_adv_terminate()
425 atomic_set_bit(ext_adv->flags, ADV_FLAG_SENT); in bt_mesh_adv_terminate()
427 bt_mesh_wq_submit(&ext_adv->work); in bt_mesh_adv_terminate()
472 struct bt_mesh_ext_adv *ext_adv = adv_instance_find(instance); in adv_sent() local
474 if (!ext_adv) { in adv_sent()
479 if (!atomic_test_bit(ext_adv->flags, ADV_FLAG_ACTIVE)) { in adv_sent()
483 atomic_set_bit(ext_adv->flags, ADV_FLAG_SENT); in adv_sent()
485 bt_mesh_wq_submit(&ext_adv->work); in adv_sent()
492 struct bt_mesh_ext_adv *ext_adv = gatt_adv_get(); in connected() local
494 if (atomic_test_and_clear_bit(ext_adv->flags, ADV_FLAG_PROXY_START)) { in connected()
495 atomic_clear_bit(ext_adv->flags, ADV_FLAG_ACTIVE); in connected()
496 (void)schedule_send(ext_adv); in connected()
571 struct bt_mesh_ext_adv *ext_adv = gatt_adv_get(); in bt_mesh_adv_gatt_start() local
579 atomic_set_bit(ext_adv->flags, ADV_FLAG_UPDATE_PARAMS); in bt_mesh_adv_gatt_start()
581 return adv_start(ext_adv, param, &start, ad, ad_len, sd, sd_len); in bt_mesh_adv_gatt_start()