From a03aaa23421c1d1328dddf372ddf7e5b1252c689 Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Mon, 26 Nov 2018 11:26:13 +0000 Subject: [PATCH] simplify and explain swapping --- .../FEATURE_BLE/ble/gap/ConnectionParameters.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/features/FEATURE_BLE/ble/gap/ConnectionParameters.h b/features/FEATURE_BLE/ble/gap/ConnectionParameters.h index 018fb52723..b023a2e5d3 100644 --- a/features/FEATURE_BLE/ble/gap/ConnectionParameters.h +++ b/features/FEATURE_BLE/ble/gap/ConnectionParameters.h @@ -382,25 +382,19 @@ private: { uint8_t index = phyToIndex(phy); - bool was_swapped = false; - bool is_swapped = false; - - if (isSwapped()) { - was_swapped = true; - } + bool was_swapped = isSwapped(); _enabledPhy[index] = enable; - if (isSwapped()) { - is_swapped = true; - } + bool is_swapped = isSwapped(); if (was_swapped != is_swapped) { swapCodedAnd2M(); } - if (is_swapped && phy == phy_t::LE_CODED) { - index -= 1; + if (is_swapped && index == LE_CODED_INDEX) { + /* to keep the data contiguous coded params are in place of the missing 2M params */ + index = LE_2M_INDEX; } return index;