mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-07-30 10:27:14 +02:00
[Bugfix] Explicit getValue template returning nil value with convertable types.
This commit is contained in:
@ -305,9 +305,6 @@ class NimBLEAttValue {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T getValue(time_t* timestamp = nullptr, bool skipSizeCheck = false) const {
|
T getValue(time_t* timestamp = nullptr, bool skipSizeCheck = false) const {
|
||||||
if (!skipSizeCheck && size() < sizeof(T)) {
|
|
||||||
return T();
|
|
||||||
}
|
|
||||||
if (timestamp != nullptr) {
|
if (timestamp != nullptr) {
|
||||||
# if CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED
|
# if CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED
|
||||||
*timestamp = m_timestamp;
|
*timestamp = m_timestamp;
|
||||||
@ -316,7 +313,14 @@ class NimBLEAttValue {
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return *(reinterpret_cast<const T*>(m_attr_value));
|
if (std::is_convertible<NimBLEAttValue, T>::value) {
|
||||||
|
return *this;
|
||||||
|
} else {
|
||||||
|
if (!skipSizeCheck && size() < sizeof(T)) {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
return *(reinterpret_cast<const T*>(m_attr_value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** Operators ************************/
|
/*********************** Operators ************************/
|
||||||
|
Reference in New Issue
Block a user