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
|
#if BLE_ROLE_CENTRAL
|
||||||
ble_error_t Gap::cancelConnect()
|
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
|
#endif
|
||||||
|
|
||||||
|
@ -1192,6 +1200,10 @@ void Gap::on_advertising_report(const GapAdvertisingReportEvent &e)
|
||||||
|
|
||||||
void Gap::on_connection_complete(const GapConnectionCompleteEvent &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 (e.status != hci_error_code_t::SUCCESS) {
|
||||||
if (_event_handler) {
|
if (_event_handler) {
|
||||||
_event_handler->onConnectionComplete(
|
_event_handler->onConnectionComplete(
|
||||||
|
@ -2332,6 +2344,10 @@ void Gap::on_enhanced_connection_complete(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (own_role == connection_role_t::CENTRAL) {
|
||||||
|
_initiating = false;
|
||||||
|
}
|
||||||
|
|
||||||
_event_handler->onConnectionComplete(
|
_event_handler->onConnectionComplete(
|
||||||
ConnectionCompleteEvent(
|
ConnectionCompleteEvent(
|
||||||
(status == hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
(status == hci_error_code_t::SUCCESS) ? BLE_ERROR_NONE : BLE_ERROR_INTERNAL_STACK_FAILURE,
|
||||||
|
|
|
@ -586,6 +586,7 @@ private:
|
||||||
mbed::LowPowerTimeout _scan_timeout;
|
mbed::LowPowerTimeout _scan_timeout;
|
||||||
mbed::LowPowerTicker _address_rotation_ticker;
|
mbed::LowPowerTicker _address_rotation_ticker;
|
||||||
|
|
||||||
|
bool _initiating = false;
|
||||||
template<size_t bit_size>
|
template<size_t bit_size>
|
||||||
struct BitArray {
|
struct BitArray {
|
||||||
BitArray() : data()
|
BitArray() : data()
|
||||||
|
|
Loading…
Reference in New Issue