Skip to content

Commit dfa526b

Browse files
committed
Allow PHY updates without enabling extended advertising.
1 parent bdeb084 commit dfa526b

6 files changed

+5
-26
lines changed

src/NimBLEClient.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ void NimBLEClient::setConfig(NimBLEClient::Config config) {
408408
void NimBLEClient::setConnectPhy(uint8_t mask) {
409409
m_phyMask = mask;
410410
} // setConnectPhy
411+
# endif
411412

412413
/**
413414
* @brief Request a change to the PHY used for this peer connection.
@@ -450,7 +451,6 @@ bool NimBLEClient::getPhy(uint8_t* txPhy, uint8_t* rxPhy) {
450451

451452
return rc == 0;
452453
} // getPhy
453-
# endif
454454

455455
/**
456456
* @brief Set the connection parameters to use when connecting to a server.
@@ -1141,7 +1141,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
11411141
break;
11421142
} // BLE_GAP_EVENT_IDENTITY_RESOLVED
11431143

1144-
# if CONFIG_BT_NIMBLE_EXT_ADV
11451144
case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: {
11461145
NimBLEConnInfo peerInfo;
11471146
rc = ble_gap_conn_find(event->phy_updated.conn_handle, &peerInfo.m_desc);
@@ -1152,7 +1151,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
11521151
pClient->m_pClientCallbacks->onPhyUpdate(pClient, event->phy_updated.tx_phy, event->phy_updated.rx_phy);
11531152
return 0;
11541153
} // BLE_GAP_EVENT_PHY_UPDATE_COMPLETE
1155-
# endif
11561154

11571155
case BLE_GAP_EVENT_MTU: {
11581156
if (pClient->m_connHandle != event->mtu.conn_handle) {
@@ -1298,10 +1296,9 @@ void NimBLEClientCallbacks::onMTUChange(NimBLEClient* pClient, uint16_t mtu) {
12981296
NIMBLE_LOGD(CB_TAG, "onMTUChange: default");
12991297
} // onMTUChange
13001298

1301-
# if CONFIG_BT_NIMBLE_EXT_ADV
13021299
void NimBLEClientCallbacks::onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, uint8_t rxPhy) {
13031300
NIMBLE_LOGD(CB_TAG, "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
13041301
} // onPhyUpdate
1305-
# endif
1302+
#
13061303

13071304
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */

src/NimBLEClient.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ class NimBLEClient {
9595

9696
# if CONFIG_BT_NIMBLE_EXT_ADV
9797
void setConnectPhy(uint8_t phyMask);
98+
# endif
9899
bool updatePhy(uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions = 0);
99100
bool getPhy(uint8_t* txPhy, uint8_t* rxPhy);
100-
# endif
101101

102102
struct Config {
103103
uint8_t deleteCallbacks : 1; // Delete the callback object when the client is deleted.
@@ -213,7 +213,6 @@ class NimBLEClientCallbacks {
213213
*/
214214
virtual void onMTUChange(NimBLEClient* pClient, uint16_t MTU);
215215

216-
# if CONFIG_BT_NIMBLE_EXT_ADV
217216
/**
218217
* @brief Called when the PHY update procedure is complete.
219218
* @param [in] pClient A pointer to the client whose PHY was updated.
@@ -226,7 +225,6 @@ class NimBLEClientCallbacks {
226225
* * BLE_GAP_LE_PHY_CODED
227226
*/
228227
virtual void onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, uint8_t rxPhy);
229-
# endif
230228
};
231229

232230
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */

src/NimBLEDevice.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@ NimBLEAddress NimBLEDevice::getWhiteListAddress(size_t index) {
737737
/* STACK FUNCTIONS */
738738
/* -------------------------------------------------------------------------- */
739739

740-
# if CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
741740
/**
742741
* @brief Set the preferred default phy to use for connections.
743742
* @param [in] txPhyMask TX PHY. Can be mask of following:
@@ -760,7 +759,6 @@ bool NimBLEDevice::setDefaultPhy(uint8_t txPhyMask, uint8_t rxPhyMask) {
760759

761760
return rc == 0;
762761
}
763-
# endif
764762

765763
/**
766764
* @brief Host reset, we pass the message so we don't make calls until re-synced.

src/NimBLEDevice.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,7 @@ class NimBLEDeviceCallbacks;
102102
# define NIMBLE_MAX_CONNECTIONS CONFIG_NIMBLE_MAX_CONNECTIONS
103103
# endif
104104

105-
enum class NimBLETxPowerType {
106-
All = 0,
107-
Advertise = 1,
108-
Scan = 2,
109-
Connection = 3
110-
};
105+
enum class NimBLETxPowerType { All = 0, Advertise = 1, Scan = 2, Connection = 3 };
111106

112107
typedef int (*gap_event_handler)(ble_gap_event* event, void* arg);
113108

@@ -149,6 +144,7 @@ class NimBLEDevice {
149144
static void host_task(void* param);
150145
static int getPower(NimBLETxPowerType type = NimBLETxPowerType::All);
151146
static bool setPower(int8_t dbm, NimBLETxPowerType type = NimBLETxPowerType::All);
147+
static bool setDefaultPhy(uint8_t txPhyMask, uint8_t rxPhyMask);
152148

153149
# ifdef ESP_PLATFORM
154150
# ifndef CONFIG_IDF_TARGET_ESP32P4
@@ -157,10 +153,6 @@ class NimBLEDevice {
157153
# endif
158154
# endif
159155

160-
# if CONFIG_BT_NIMBLE_EXT_ADV
161-
static bool setDefaultPhy(uint8_t txPhyMask, uint8_t rxPhyMask);
162-
# endif
163-
164156
# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
165157
static NimBLEScan* getScan();
166158
# endif

src/NimBLEServer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
544544
break;
545545
} // BLE_GAP_EVENT_IDENTITY_RESOLVED
546546

547-
# if CONFIG_BT_NIMBLE_EXT_ADV
548547
case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: {
549548
rc = ble_gap_conn_find(event->phy_updated.conn_handle, &peerInfo.m_desc);
550549
if (rc != 0) {
@@ -554,7 +553,6 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
554553
pServer->m_pServerCallbacks->onPhyUpdate(peerInfo, event->phy_updated.tx_phy, event->phy_updated.rx_phy);
555554
return 0;
556555
} // BLE_GAP_EVENT_PHY_UPDATE_COMPLETE
557-
# endif
558556

559557
case BLE_GAP_EVENT_PASSKEY_ACTION: {
560558
struct ble_sm_io pkey = {0, 0};
@@ -1016,10 +1014,8 @@ void NimBLEServerCallbacks::onConnParamsUpdate(NimBLEConnInfo& connInfo) {
10161014
NIMBLE_LOGD("NimBLEServerCallbacks", "onConnParamsUpdate: default");
10171015
} // onConnParamsUpdate
10181016

1019-
# if CONFIG_BT_NIMBLE_EXT_ADV
10201017
void NimBLEServerCallbacks::onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy) {
10211018
NIMBLE_LOGD("NimBLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
10221019
} // onPhyUpdate
1023-
# endif
10241020

10251021
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

src/NimBLEServer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ class NimBLEServerCallbacks {
203203
*/
204204
virtual void onConnParamsUpdate(NimBLEConnInfo& connInfo);
205205

206-
# if CONFIG_BT_NIMBLE_EXT_ADV
207206
/**
208207
* @brief Called when the PHY update procedure is complete.
209208
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
@@ -216,7 +215,6 @@ class NimBLEServerCallbacks {
216215
* * BLE_GAP_LE_PHY_CODED
217216
*/
218217
virtual void onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy);
219-
# endif
220218
}; // NimBLEServerCallbacks
221219

222220
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL

0 commit comments

Comments
 (0)