Skip to content

Commit

Permalink
nimble/host: Avoid slave instance reset inside extract_cb
Browse files Browse the repository at this point in the history
  • Loading branch information
rahult-github authored and sjanc committed May 9, 2024
1 parent 175029c commit f3afc17
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,14 +1617,26 @@ ble_gap_rx_adv_set_terminated(const struct ble_hci_ev_le_subev_adv_set_terminate
ble_gap_adv_finished(ev->adv_handle, reason, conn_handle, ev->num_events);
}

static void
ble_gap_slave_get_cb(uint8_t instance,
ble_gap_event_fn **out_cb, void **out_cb_arg)
{
ble_hs_lock();

*out_cb = ble_gap_slave[instance].cb;
*out_cb_arg = ble_gap_slave[instance].cb_arg;

ble_hs_unlock();
}

void
ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev)
{
struct ble_gap_event event;
ble_gap_event_fn *cb;
void *cb_arg;

ble_gap_slave_extract_cb(ev->adv_handle, &cb, &cb_arg);
ble_gap_slave_get_cb(ev->adv_handle, &cb, &cb_arg);
if (cb != NULL) {
memset(&event, 0, sizeof event);
event.type = BLE_GAP_EVENT_SCAN_REQ_RCVD;
Expand Down

0 comments on commit f3afc17

Please sign in to comment.