mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Add initiating flag into gap to track if the local device tries to connect to a peer.
parent
13771b8172
commit
f810ec4c2a
|
@ -646,7 +646,15 @@ ble_error_t Gap::rejectConnectionParametersUpdate(
|
|||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t Gap::cancelConnect()
|
||||
{
|
||||
return _pal_gap.cancel_connection_creation();
|
||||
if (!_initiating) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
auto ret = _pal_gap.cancel_connection_creation();
|
||||
if (ret) {
|
||||
_initiating = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1192,6 +1200,10 @@ void Gap::on_advertising_report(const GapAdvertisingReportEvent &e)
|
|||
|
||||
void Gap::on_connection_complete(const GapConnectionCompleteEvent &e)
|
||||
{
|
||||
if (e.role == connection_role_t::CENTRAL) {
|
||||
_initiating = false;
|
||||
}
|
||||
|
||||
if (e.status != hci_error_code_t::SUCCESS) {
|
||||
if (_event_handler) {
|
||||
_event_handler->onConnectionComplete(
|
||||
|
@ -2332,6 +2344,10 @@ void Gap::on_enhanced_connection_complete(
|
|||
return;
|
||||
}
|
||||
|
||||
if (own_role == connection_role_t::CENTRAL) {
|
||||
_initiating = false;
|
||||
}
|
||||
|
||||
_event_handler->onConnectionComplete(
|
||||
ConnectionCompleteEvent(
|
||||
(status == hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
||||
|
|
|
@ -586,6 +586,7 @@ private:
|
|||
mbed::LowPowerTimeout _scan_timeout;
|
||||
mbed::LowPowerTicker _address_rotation_ticker;
|
||||
|
||||
bool _initiating = false;
|
||||
template<size_t bit_size>
|
||||
struct BitArray {
|
||||
BitArray() : data()
|
||||
|
|
Loading…
Reference in New Issue