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 committed May 9, 2024
1 parent 8621593 commit 8cfb75a
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 @@ -891,6 +891,18 @@ ble_gap_master_extract_state(struct ble_gap_master_state *out_state,
#endif

#if NIMBLE_BLE_ADVERTISE || NIMBLE_BLE_CONNECT
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();
}

static void
ble_gap_slave_extract_cb(uint8_t instance,
ble_gap_event_fn **out_cb, void **out_cb_arg)
Expand Down Expand Up @@ -1624,7 +1636,7 @@ ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev)
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 8cfb75a

Please sign in to comment.