Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/NimBLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ void NimBLEClient::setConfig(NimBLEClient::Config config) {
void NimBLEClient::setConnectPhy(uint8_t mask) {
m_phyMask = mask;
} // setConnectPhy
# endif

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

return rc == 0;
} // getPhy
# endif

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

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

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

# if CONFIG_BT_NIMBLE_EXT_ADV
void NimBLEClientCallbacks::onPhyUpdate(NimBLEClient* pClient, uint8_t txPhy, uint8_t rxPhy) {
NIMBLE_LOGD(CB_TAG, "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
} // onPhyUpdate
# endif
#

#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
4 changes: 1 addition & 3 deletions src/NimBLEClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class NimBLEClient {

# if CONFIG_BT_NIMBLE_EXT_ADV
void setConnectPhy(uint8_t phyMask);
# endif
bool updatePhy(uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions = 0);
bool getPhy(uint8_t* txPhy, uint8_t* rxPhy);
# endif

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

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

#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
Expand Down
2 changes: 0 additions & 2 deletions src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ NimBLEAddress NimBLEDevice::getWhiteListAddress(size_t index) {
/* STACK FUNCTIONS */
/* -------------------------------------------------------------------------- */

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

return rc == 0;
}
# endif

/**
* @brief Host reset, we pass the message so we don't make calls until re-synced.
Expand Down
12 changes: 2 additions & 10 deletions src/NimBLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ class NimBLEDeviceCallbacks;
# define NIMBLE_MAX_CONNECTIONS CONFIG_NIMBLE_MAX_CONNECTIONS
# endif

enum class NimBLETxPowerType {
All = 0,
Advertise = 1,
Scan = 2,
Connection = 3
};
enum class NimBLETxPowerType { All = 0, Advertise = 1, Scan = 2, Connection = 3 };

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

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

# ifdef ESP_PLATFORM
# ifndef CONFIG_IDF_TARGET_ESP32P4
Expand All @@ -157,10 +153,6 @@ class NimBLEDevice {
# endif
# endif

# if CONFIG_BT_NIMBLE_EXT_ADV
static bool setDefaultPhy(uint8_t txPhyMask, uint8_t rxPhyMask);
# endif

# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
static NimBLEScan* getScan();
# endif
Expand Down
51 changes: 24 additions & 27 deletions src/NimBLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
break;
} // BLE_GAP_EVENT_IDENTITY_RESOLVED

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

case BLE_GAP_EVENT_PASSKEY_ACTION: {
struct ble_sm_io pkey = {0, 0};
Expand Down Expand Up @@ -788,29 +786,6 @@ void NimBLEServer::resetGATT() {
m_gattsStarted = false;
} // resetGATT

# if CONFIG_BT_NIMBLE_EXT_ADV
/**
* @brief Start advertising.
* @param [in] instId The extended advertisement instance ID to start.
* @param [in] duration How long to advertise for in milliseconds, 0 = forever (default).
* @param [in] maxEvents Maximum number of advertisement events to send, 0 = no limit (default).
* @return True if advertising started successfully.
* @details Start the server advertising its existence. This is a convenience function and is equivalent to
* retrieving the advertising object and invoking start upon it.
*/
bool NimBLEServer::startAdvertising(uint8_t instId, int duration, int maxEvents) const {
return getAdvertising()->start(instId, duration, maxEvents);
} // startAdvertising

/**
* @brief Convenience function to stop advertising a data set.
* @param [in] instId The extended advertisement instance ID to stop advertising.
* @return True if advertising stopped successfully.
*/
bool NimBLEServer::stopAdvertising(uint8_t instId) const {
return getAdvertising()->stop(instId);
} // stopAdvertising

/**
* @brief Request an update to the PHY used for a peer connection.
* @param [in] connHandle the connection handle to the update the PHY for.
Expand Down Expand Up @@ -854,6 +829,30 @@ bool NimBLEServer::getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy) {

return rc == 0;
} // getPhy

# if CONFIG_BT_NIMBLE_EXT_ADV
/**
* @brief Start advertising.
* @param [in] instId The extended advertisement instance ID to start.
* @param [in] duration How long to advertise for in milliseconds, 0 = forever (default).
* @param [in] maxEvents Maximum number of advertisement events to send, 0 = no limit (default).
* @return True if advertising started successfully.
* @details Start the server advertising its existence. This is a convenience function and is equivalent to
* retrieving the advertising object and invoking start upon it.
*/
bool NimBLEServer::startAdvertising(uint8_t instId, int duration, int maxEvents) const {
return getAdvertising()->start(instId, duration, maxEvents);
} // startAdvertising

/**
* @brief Convenience function to stop advertising a data set.
* @param [in] instId The extended advertisement instance ID to stop advertising.
* @return True if advertising stopped successfully.
*/
bool NimBLEServer::stopAdvertising(uint8_t instId) const {
return getAdvertising()->stop(instId);
} // stopAdvertising

# endif

# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
Expand Down Expand Up @@ -1016,10 +1015,8 @@ void NimBLEServerCallbacks::onConnParamsUpdate(NimBLEConnInfo& connInfo) {
NIMBLE_LOGD("NimBLEServerCallbacks", "onConnParamsUpdate: default");
} // onConnParamsUpdate

# if CONFIG_BT_NIMBLE_EXT_ADV
void NimBLEServerCallbacks::onPhyUpdate(NimBLEConnInfo& connInfo, uint8_t txPhy, uint8_t rxPhy) {
NIMBLE_LOGD("NimBLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
} // onPhyUpdate
# endif

#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
6 changes: 2 additions & 4 deletions src/NimBLEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class NimBLEServer {
NimBLEConnInfo getPeerInfoByHandle(uint16_t connHandle) const;
void advertiseOnDisconnect(bool enable);
void setDataLen(uint16_t connHandle, uint16_t tx_octets) const;
bool updatePhy(uint16_t connHandle, uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions);
bool getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy);

# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
NimBLEClient* getClient(uint16_t connHandle);
Expand All @@ -90,8 +92,6 @@ class NimBLEServer {
NimBLEExtAdvertising* getAdvertising() const;
bool startAdvertising(uint8_t instanceId, int duration = 0, int maxEvents = 0) const;
bool stopAdvertising(uint8_t instanceId) const;
bool updatePhy(uint16_t connHandle, uint8_t txPhysMask, uint8_t rxPhysMask, uint16_t phyOptions);
bool getPhy(uint16_t connHandle, uint8_t* txPhy, uint8_t* rxPhy);
# endif

# if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
Expand Down Expand Up @@ -203,7 +203,6 @@ class NimBLEServerCallbacks {
*/
virtual void onConnParamsUpdate(NimBLEConnInfo& connInfo);

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

#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
Expand Down