2020-03-30 01:44:20 +02:00
|
|
|
/*
|
2024-12-13 03:21:03 +01:00
|
|
|
* Copyright 2020-2024 Ryan Powell <ryan@nable-embedded.io> and
|
|
|
|
* esp-nimble-cpp, NimBLE-Arduino contributors.
|
2020-03-30 01:44:20 +02:00
|
|
|
*
|
2024-12-13 03:21:03 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2020-05-14 06:03:56 +02:00
|
|
|
*
|
2024-12-13 03:21:03 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2020-03-30 01:44:20 +02:00
|
|
|
*
|
2024-12-13 03:21:03 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2020-03-30 01:44:20 +02:00
|
|
|
*/
|
|
|
|
|
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)
|
2024-12-13 03:21:03 +01:00
|
|
|
: 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 */
|