Make setImplicitCCCD private and add impl::GattServer as a friend class

pull/13729/head
George Beckstein 2020-10-07 13:31:09 -04:00
parent ca9b70582c
commit eccb3e9bda
2 changed files with 16 additions and 5 deletions

View File

@ -24,6 +24,16 @@
#include "ble/gatt/GattAttribute.h"
#include "ble/gatt/GattCallbackParamTypes.h"
// Forward declare ble::impl::GattServer
namespace ble {
#if !defined(DOXYGEN_ONLY)
namespace impl {
class GattServer;
}
#endif // !defined(DOXYGEN_ONLY)
}
/**
* @addtogroup ble
* @{
@ -1774,6 +1784,10 @@ public:
return _descriptors[index];
}
private:
friend ble::impl::GattServer;
/**
* Sets this GattCharacteristic's implicitly-created CCCD, if
* applicable.
@ -1781,11 +1795,8 @@ public:
* @note once this is called, the pointed-to GattAttribute
* is owned by this GattCharacteristic and will be deleted
* during this object's destructor
*
* @note this is an internal function and should not be called
* by the application
*/
void _setImplicitCCCD(GattAttribute *implicit_cccd) {
void setImplicitCCCD(GattAttribute *implicit_cccd) {
_implicit_cccd = implicit_cccd;
}

View File

@ -603,7 +603,7 @@ ble_error_t GattServer::insert_cccd(
implicit_cccd->setHandle(cccds[cccd_cnt].handle);
implicit_cccd->allowRead(true);
implicit_cccd->allowWrite(true);
characteristic->_setImplicitCCCD(implicit_cccd);
characteristic->setImplicitCCCD(implicit_cccd);
cccd_cnt++;
attribute_it++;