diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index 111c20742..8896f2d17 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -346,6 +346,39 @@ struct ble_gap_event { */ struct ble_gap_ext_disc_desc ext_disc; #endif + + /** + * Represents a completed discovery procedure. Valid for the following + * event types: + * o BLE_GAP_EVENT_DISC_COMPLETE + */ + struct { + /** + * The reason the discovery procedure stopped. Typical reason + * codes are: + * o 0: Duration expired. + * o BLE_HS_EPREEMPTED: Host aborted procedure to configure a + * peer's identity. + */ + int reason; + } disc_complete; + + /** + * Represents a completed advertise procedure. Valid for the following + * event types: + * o BLE_GAP_EVENT_ADV_COMPLETE + */ + struct { + /** + * The reason the advertise procedure stopped. Typical reason + * codes are: + * o 0: Duration expired. + * o BLE_HS_EPREEMPTED: Host aborted procedure to configure a + * peer's identity. + */ + int reason; + } adv_complete; + /** * Represents an attempt to update a connection's parameters. If the * attempt was successful, the connection's descriptor reflects the diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index dad40dd9c..7f2b39e3c 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -666,7 +666,7 @@ ble_gap_adv_finished(void) if (cb != NULL) { memset(&event, 0, sizeof event); event.type = BLE_GAP_EVENT_ADV_COMPLETE; - + event.adv_complete.reason = 0; cb(&event, cb_arg); } } @@ -764,6 +764,7 @@ ble_gap_disc_complete(void) memset(&event, 0, sizeof event); event.type = BLE_GAP_EVENT_DISC_COMPLETE; + event.disc_complete.reason = 0; ble_gap_master_extract_state(&state, 1); if (ble_gap_has_client(&state)) {