2020-03-30 01:44:20 +02:00
|
|
|
/*
|
|
|
|
* NimBLERemoteDescriptor.cpp
|
|
|
|
*
|
|
|
|
* Created: on Jan 27 2020
|
|
|
|
* Author H2zero
|
2020-05-14 06:03:56 +02:00
|
|
|
*
|
2020-03-30 01:44:20 +02:00
|
|
|
* Originally:
|
|
|
|
*
|
|
|
|
* BLERemoteDescriptor.cpp
|
|
|
|
*
|
|
|
|
* Created on: Jul 8, 2017
|
|
|
|
* Author: kolban
|
|
|
|
*/
|
|
|
|
|
2020-05-14 06:03:56 +02:00
|
|
|
#include "nimconfig.h"
|
2021-09-07 05:14:43 +02:00
|
|
|
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
2020-05-14 06:03:56 +02:00
|
|
|
|
2024-07-26 22:47:36 +02:00
|
|
|
# include "NimBLERemoteDescriptor.h"
|
|
|
|
# include "NimBLERemoteCharacteristic.h"
|
2020-03-30 01:44:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remote descriptor constructor.
|
2020-07-09 03:27:26 +02: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-30 01:44:20 +02:00
|
|
|
*/
|
2024-07-26 22:47:36 +02:00
|
|
|
NimBLERemoteDescriptor::NimBLERemoteDescriptor(const NimBLERemoteCharacteristic* pRemoteCharacteristic,
|
|
|
|
const ble_gatt_dsc* dsc)
|
|
|
|
: NimBLERemoteValueAttribute{dsc->uuid, dsc->handle}, m_pRemoteCharacteristic{pRemoteCharacteristic} {} // NimBLERemoteDescriptor
|
2020-03-30 01:44:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the characteristic that owns this descriptor.
|
|
|
|
* @return The characteristic that owns this descriptor.
|
|
|
|
*/
|
2024-07-26 22:47:36 +02:00
|
|
|
NimBLERemoteCharacteristic* NimBLERemoteDescriptor::getRemoteCharacteristic() const {
|
|
|
|
return const_cast<NimBLERemoteCharacteristic*>(m_pRemoteCharacteristic);
|
2020-03-30 01:44:20 +02:00
|
|
|
} // getRemoteCharacteristic
|
|
|
|
|
|
|
|
/**
|
2020-07-09 03:27:26 +02:00
|
|
|
* @brief Return a string representation of this Remote Descriptor.
|
|
|
|
* @return A string representation of this Remote Descriptor.
|
2020-03-30 01:44:20 +02:00
|
|
|
*/
|
2024-07-26 22:47:36 +02:00
|
|
|
std::string NimBLERemoteDescriptor::toString() const {
|
2020-03-30 01:44:20 +02:00
|
|
|
std::string res = "Descriptor: uuid: " + getUUID().toString();
|
2024-07-26 22:47:36 +02:00
|
|
|
char val[6];
|
2020-03-30 01:44:20 +02:00
|
|
|
res += ", handle: ";
|
|
|
|
snprintf(val, sizeof(val), "%d", getHandle());
|
|
|
|
res += val;
|
2020-05-14 06:03:56 +02:00
|
|
|
|
2020-03-30 01:44:20 +02:00
|
|
|
return res;
|
|
|
|
} // toString
|
|
|
|
|
2024-07-26 22:47:36 +02:00
|
|
|
NimBLEClient* NimBLERemoteDescriptor::getClient() const {
|
|
|
|
return m_pRemoteCharacteristic->getClient();
|
2020-03-30 01:44:20 +02:00
|
|
|
}
|
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
|