Files
esp-nimble-cpp/src/NimBLERemoteDescriptor.cpp
T

57 lines
1.8 KiB
C++
Raw Normal View History

2020-03-29 17:44:20 -06:00
/*
* NimBLERemoteDescriptor.cpp
*
* Created: on Jan 27 2020
* Author H2zero
*
2020-03-29 17:44:20 -06:00
* Originally:
*
* BLERemoteDescriptor.cpp
*
* Created on: Jul 8, 2017
* Author: kolban
*/
#include "nimconfig.h"
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
2024-07-26 14:47:36 -06:00
# include "NimBLERemoteDescriptor.h"
# include "NimBLERemoteCharacteristic.h"
2020-03-29 17:44:20 -06:00
/**
* @brief Remote descriptor constructor.
2020-07-08 19:27:26 -06:00
* @param [in] pRemoteCharacteristic A pointer to the Characteristic that this belongs to.
* @param [in] dsc A pointer to the struct that contains the descriptor information.
2020-03-29 17:44:20 -06:00
*/
2024-07-26 14:47:36 -06:00
NimBLERemoteDescriptor::NimBLERemoteDescriptor(const NimBLERemoteCharacteristic* pRemoteCharacteristic,
const ble_gatt_dsc* dsc)
: NimBLERemoteValueAttribute{dsc->uuid, dsc->handle}, m_pRemoteCharacteristic{pRemoteCharacteristic} {} // NimBLERemoteDescriptor
2020-03-29 17:44:20 -06:00
/**
* @brief Get the characteristic that owns this descriptor.
* @return The characteristic that owns this descriptor.
*/
2024-07-26 14:47:36 -06:00
NimBLERemoteCharacteristic* NimBLERemoteDescriptor::getRemoteCharacteristic() const {
return const_cast<NimBLERemoteCharacteristic*>(m_pRemoteCharacteristic);
2020-03-29 17:44:20 -06:00
} // getRemoteCharacteristic
/**
2020-07-08 19:27:26 -06:00
* @brief Return a string representation of this Remote Descriptor.
* @return A string representation of this Remote Descriptor.
2020-03-29 17:44:20 -06:00
*/
2024-07-26 14:47:36 -06:00
std::string NimBLERemoteDescriptor::toString() const {
2020-03-29 17:44:20 -06:00
std::string res = "Descriptor: uuid: " + getUUID().toString();
2024-07-26 14:47:36 -06:00
char val[6];
2020-03-29 17:44:20 -06:00
res += ", handle: ";
snprintf(val, sizeof(val), "%d", getHandle());
res += val;
2020-03-29 17:44:20 -06:00
return res;
} // toString
2024-07-26 14:47:36 -06:00
NimBLEClient* NimBLERemoteDescriptor::getClient() const {
return m_pRemoteCharacteristic->getClient();
2020-03-29 17:44:20 -06:00
}
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */