fix swapping

pull/8738/head
paul-szczepanek-arm 2018-11-12 08:15:02 +00:00 committed by Vincent Coubard
parent 62b38cfbc8
commit fd880d1e6b
1 changed files with 21 additions and 11 deletions

View File

@ -203,21 +203,31 @@ private:
uint8_t handlePhyToggle(ble::phy_t phy, bool enable) {
uint8_t index = phy.value();
if (_enabledPhy[phy.value()] != enable) {
if (phy == ble::phy_t::LE_2M) {
if (_enabledPhy[ble::phy_t::LE_CODED]) {
swapCodedAnd2M();
}
} else if (phy == ble::phy_t::LE_CODED) {
if (!_enabledPhy[ble::phy_t::LE_2M]) {
swapCodedAnd2M();
index = ble::phy_t::LE_2M;
}
}
bool was_swapped = false;
bool is_swapped = false;
if (_enabledPhy[ble::phy_t::LE_1M] &&
!_enabledPhy[ble::phy_t::LE_2M] &&
_enabledPhy[ble::phy_t::LE_CODED]) {
was_swapped = true;
}
_enabledPhy[phy.value()] = enable;
if (_enabledPhy[ble::phy_t::LE_1M] &&
!_enabledPhy[ble::phy_t::LE_2M] &&
_enabledPhy[ble::phy_t::LE_CODED]) {
is_swapped = true;
}
if (was_swapped != is_swapped) {
swapCodedAnd2M();
}
if (is_swapped && phy == ble::phy_t::LE_CODED) {
index -= 1;
}
return index;
}