aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/ATTPDUTypes.hpp8
-rw-r--r--api/direct_bt/GATTCharacteristic.hpp6
-rw-r--r--api/direct_bt/GATTDescriptor.hpp9
-rw-r--r--api/direct_bt/GATTHandler.hpp4
-rw-r--r--api/direct_bt/GATTService.hpp6
-rw-r--r--api/direct_bt/OctetTypes.hpp2
-rw-r--r--api/direct_bt/UUID.hpp2
-rw-r--r--src/direct_bt/ATTPDUTypes.cpp70
-rw-r--r--src/direct_bt/GATTCharacteristic.cpp3
-rw-r--r--src/direct_bt/GATTHandler.cpp24
-rw-r--r--src/direct_bt/UUID.cpp8
11 files changed, 68 insertions, 74 deletions
diff --git a/api/direct_bt/ATTPDUTypes.hpp b/api/direct_bt/ATTPDUTypes.hpp
index 66e3c32a..990d5362 100644
--- a/api/direct_bt/ATTPDUTypes.hpp
+++ b/api/direct_bt/ATTPDUTypes.hpp
@@ -369,7 +369,7 @@ namespace direct_bt {
* Returned memory reference is managed by caller (delete etc)
* </p>
*/
- static std::shared_ptr<const AttPDUMsg> getSpecialized(const uint8_t * buffer, jau::nsize_t const buffer_size) noexcept;
+ static std::unique_ptr<const AttPDUMsg> getSpecialized(const uint8_t * buffer, jau::nsize_t const buffer_size) noexcept;
/** Persistent memory, w/ ownership ..*/
AttPDUMsg(const uint8_t* source, const jau::nsize_t size)
@@ -1111,7 +1111,7 @@ namespace direct_bt {
return "AttReadByNTypeReq";
}
- std::shared_ptr<const uuid_t> getNType() const {
+ std::unique_ptr<const uuid_t> getNType() const {
return pdu.get_uuid( getPDUValueOffset(), getUUIFormat() );
}
@@ -1415,7 +1415,7 @@ namespace direct_bt {
class Element {
public:
const uint16_t handle;
- const std::shared_ptr<const uuid_t> uuid;
+ const std::unique_ptr<const uuid_t> uuid;
Element(const AttFindInfoRsp & p, const jau::nsize_t idx)
: handle( p.getElementHandle(idx) ), uuid( p.getElementValue(idx) )
@@ -1460,7 +1460,7 @@ namespace direct_bt {
return pdu.get_uint16( getElementPDUOffset(elementIdx) );
}
- std::shared_ptr<const uuid_t> getElementValue(const jau::nsize_t elementIdx) const {
+ std::unique_ptr<const uuid_t> getElementValue(const jau::nsize_t elementIdx) const {
return pdu.get_uuid( getElementPDUOffset(elementIdx) + 2, getUUIFormat() );
}
diff --git a/api/direct_bt/GATTCharacteristic.hpp b/api/direct_bt/GATTCharacteristic.hpp
index b1802dcc..acfda6d0 100644
--- a/api/direct_bt/GATTCharacteristic.hpp
+++ b/api/direct_bt/GATTCharacteristic.hpp
@@ -135,7 +135,7 @@ namespace direct_bt {
const uint16_t value_handle;
/* Characteristics Value Type UUID */
- std::shared_ptr<const uuid_t> value_type;
+ std::unique_ptr<const uuid_t> value_type;
/** List of Characteristic Descriptions as shared reference */
std::vector<GATTDescriptorRef> descriptorList;
@@ -144,9 +144,9 @@ namespace direct_bt {
int clientCharacteristicsConfigIndex = -1;
GATTCharacteristic(const GATTServiceRef & service_, const uint16_t service_handle_, const uint16_t handle_,
- const PropertyBitVal properties_, const uint16_t value_handle_, std::shared_ptr<const uuid_t> value_type_) noexcept
+ const PropertyBitVal properties_, const uint16_t value_handle_, std::unique_ptr<const uuid_t> && value_type_) noexcept
: wbr_service(service_), service_handle(service_handle_), handle(handle_),
- properties(properties_), value_handle(value_handle_), value_type(value_type_) {}
+ properties(properties_), value_handle(value_handle_), value_type(std::move(value_type_)) {}
std::string get_java_class() const noexcept override {
return java_class();
diff --git a/api/direct_bt/GATTDescriptor.hpp b/api/direct_bt/GATTDescriptor.hpp
index af3e0f20..fb852113 100644
--- a/api/direct_bt/GATTDescriptor.hpp
+++ b/api/direct_bt/GATTDescriptor.hpp
@@ -71,9 +71,6 @@ namespace direct_bt {
static const uuid16_t TYPE_EXT_PROP;
static const uuid16_t TYPE_USER_DESC;
static const uuid16_t TYPE_CCC_DESC;
- static std::shared_ptr<const uuid_t> getStaticType(const uuid16_t & type) noexcept {
- return std::shared_ptr<const uuid_t>(&type, [](const uuid_t *){});
- }
/**
* Following UUID16 GATT profile attribute types are listed under:
@@ -103,7 +100,7 @@ namespace direct_bt {
};
/** Type of descriptor */
- std::shared_ptr<const uuid_t> type;
+ std::unique_ptr<const uuid_t> type;
/**
* Characteristic Descriptor Handle
@@ -116,9 +113,9 @@ namespace direct_bt {
/* Characteristics Descriptor's Value */
POctets value;
- GATTDescriptor(const GATTCharacteristicRef & characteristic, const std::shared_ptr<const uuid_t> & type_,
+ GATTDescriptor(const GATTCharacteristicRef & characteristic, std::unique_ptr<const uuid_t> && type_,
const uint16_t handle_) noexcept
- : wbr_characteristic(characteristic), type(type_), handle(handle_), value(/* intentional zero sized */) {}
+ : wbr_characteristic(characteristic), type(std::move(type_)), handle(handle_), value(/* intentional zero sized */) {}
std::string get_java_class() const noexcept override {
return java_class();
diff --git a/api/direct_bt/GATTHandler.hpp b/api/direct_bt/GATTHandler.hpp
index 447143e0..d477b649 100644
--- a/api/direct_bt/GATTHandler.hpp
+++ b/api/direct_bt/GATTHandler.hpp
@@ -163,7 +163,7 @@ namespace direct_bt {
jau::sc_atomic_bool is_connected; // reflects state
jau::relaxed_atomic_bool has_ioerror; // reflects state
- jau::ringbuffer<std::shared_ptr<const AttPDUMsg>, nullptr, jau::nsize_t> attPDURing;
+ jau::ringbuffer<std::unique_ptr<const AttPDUMsg>, nullptr, jau::nsize_t> attPDURing;
jau::sc_atomic_bool l2capReaderShallStop;
std::mutex mtx_l2capReaderLifecycle;
@@ -221,7 +221,7 @@ namespace direct_bt {
* @param timeout milliseconds to wait for a reply
* @return a valid reply, never nullptrs
*/
- std::shared_ptr<const AttPDUMsg> sendWithReply(const AttPDUMsg & msg, const int timeout);
+ std::unique_ptr<const AttPDUMsg> sendWithReply(const AttPDUMsg & msg, const int timeout);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.4.2 MTU Exchange
diff --git a/api/direct_bt/GATTService.hpp b/api/direct_bt/GATTService.hpp
index f8ebe465..8506465e 100644
--- a/api/direct_bt/GATTService.hpp
+++ b/api/direct_bt/GATTService.hpp
@@ -91,14 +91,14 @@ namespace direct_bt {
const uint16_t endHandle;
/** Service type UUID */
- std::shared_ptr<const uuid_t> type;
+ std::unique_ptr<const uuid_t> type;
/** List of Characteristic Declarations as shared reference */
std::vector<GATTCharacteristicRef> characteristicList;
GATTService(const std::shared_ptr<GATTHandler> &handler_, const bool isPrimary_,
- const uint16_t startHandle_, const uint16_t endHandle_, std::shared_ptr<const uuid_t> type_) noexcept
- : wbr_handler(handler_), isPrimary(isPrimary_), startHandle(startHandle_), endHandle(endHandle_), type(type_), characteristicList() {
+ const uint16_t startHandle_, const uint16_t endHandle_, std::unique_ptr<const uuid_t> && type_) noexcept
+ : wbr_handler(handler_), isPrimary(isPrimary_), startHandle(startHandle_), endHandle(endHandle_), type(std::move(type_)), characteristicList() {
characteristicList.reserve(10);
}
diff --git a/api/direct_bt/OctetTypes.hpp b/api/direct_bt/OctetTypes.hpp
index 7de03b87..c9ac6ca1 100644
--- a/api/direct_bt/OctetTypes.hpp
+++ b/api/direct_bt/OctetTypes.hpp
@@ -221,7 +221,7 @@ namespace direct_bt {
return uuid128_t(jau::get_uint128(_data, i, true /* littleEndian */));
}
- std::shared_ptr<const uuid_t> get_uuid(const jau::nsize_t i, const uuid_t::TypeSize tsize) const {
+ std::unique_ptr<const uuid_t> get_uuid(const jau::nsize_t i, const uuid_t::TypeSize tsize) const {
check_range(i, uuid_t::number(tsize));
return uuid_t::create(tsize, _data, i, true /* littleEndian */);
}
diff --git a/api/direct_bt/UUID.hpp b/api/direct_bt/UUID.hpp
index 407a601f..81b55e5e 100644
--- a/api/direct_bt/UUID.hpp
+++ b/api/direct_bt/UUID.hpp
@@ -67,7 +67,7 @@ protected:
public:
static TypeSize toTypeSize(const jau::nsize_t size);
- static std::shared_ptr<const uuid_t> create(TypeSize const t, uint8_t const * const buffer, jau::nsize_t const byte_offset, bool const littleEndian);
+ static std::unique_ptr<const uuid_t> create(TypeSize const t, uint8_t const * const buffer, jau::nsize_t const byte_offset, bool const littleEndian);
virtual ~uuid_t() noexcept {}
diff --git a/src/direct_bt/ATTPDUTypes.cpp b/src/direct_bt/ATTPDUTypes.cpp
index d8e4b2bf..c26eff12 100644
--- a/src/direct_bt/ATTPDUTypes.cpp
+++ b/src/direct_bt/ATTPDUTypes.cpp
@@ -115,43 +115,41 @@ std::string AttErrorRsp::getPlainErrorString(const ErrorCode errorCode) noexcept
return "Error Reserved for future use";
}
-std::shared_ptr<const AttPDUMsg> AttPDUMsg::getSpecialized(const uint8_t * buffer, jau::nsize_t const buffer_size) noexcept {
+std::unique_ptr<const AttPDUMsg> AttPDUMsg::getSpecialized(const uint8_t * buffer, jau::nsize_t const buffer_size) noexcept {
const AttPDUMsg::Opcode opc = static_cast<AttPDUMsg::Opcode>(*buffer);
- const AttPDUMsg * res;
switch( opc ) {
- case Opcode::PDU_UNDEFINED: res = new AttPDUUndefined(buffer, buffer_size); break;
- case Opcode::ERROR_RSP: res = new AttErrorRsp(buffer, buffer_size); break;
- case Opcode::EXCHANGE_MTU_REQ: res = new AttExchangeMTU(buffer, buffer_size); break;
- case Opcode::EXCHANGE_MTU_RSP: res = new AttExchangeMTU(buffer, buffer_size); break;
- case Opcode::FIND_INFORMATION_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::FIND_INFORMATION_RSP: res = new AttFindInfoRsp(buffer, buffer_size); break;
- case Opcode::FIND_BY_TYPE_VALUE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::FIND_BY_TYPE_VALUE_RSP: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_BY_TYPE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_BY_TYPE_RSP: res = new AttReadByTypeRsp(buffer, buffer_size); break;
- case Opcode::READ_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_RSP: res = new AttReadRsp(buffer, buffer_size); break;
- case Opcode::READ_BLOB_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_BLOB_RSP: res = new AttReadBlobRsp(buffer, buffer_size); break;
- case Opcode::READ_MULTIPLE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_MULTIPLE_RSP: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_BY_GROUP_TYPE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_BY_GROUP_TYPE_RSP: res = new AttReadByGroupTypeRsp(buffer, buffer_size); break;
- case Opcode::WRITE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::WRITE_RSP: res = new AttWriteRsp(buffer, buffer_size); break;
- case Opcode::WRITE_CMD: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::PREPARE_WRITE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::PREPARE_WRITE_RSP: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::EXECUTE_WRITE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::EXECUTE_WRITE_RSP: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_MULTIPLE_VARIABLE_REQ: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::READ_MULTIPLE_VARIABLE_RSP: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::MULTIPLE_HANDLE_VALUE_NTF: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::HANDLE_VALUE_NTF: res = new AttHandleValueRcv(buffer, buffer_size); break;
- case Opcode::HANDLE_VALUE_IND: res = new AttHandleValueRcv(buffer, buffer_size); break;
- case Opcode::HANDLE_VALUE_CFM: res = new AttPDUMsg(buffer, buffer_size); break;
- case Opcode::SIGNED_WRITE_CMD: res = new AttPDUMsg(buffer, buffer_size); break;
- default: res = new AttPDUMsg(buffer, buffer_size); break;
+ case Opcode::PDU_UNDEFINED: return std::make_unique<AttPDUUndefined>(buffer, buffer_size);
+ case Opcode::ERROR_RSP: return std::make_unique<AttErrorRsp>(buffer, buffer_size);
+ case Opcode::EXCHANGE_MTU_REQ: return std::make_unique<AttExchangeMTU>(buffer, buffer_size);
+ case Opcode::EXCHANGE_MTU_RSP: return std::make_unique<AttExchangeMTU>(buffer, buffer_size);
+ case Opcode::FIND_INFORMATION_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::FIND_INFORMATION_RSP: return std::make_unique<AttFindInfoRsp>(buffer, buffer_size);
+ case Opcode::FIND_BY_TYPE_VALUE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::FIND_BY_TYPE_VALUE_RSP: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_BY_TYPE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_BY_TYPE_RSP: return std::make_unique<AttReadByTypeRsp>(buffer, buffer_size);
+ case Opcode::READ_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_RSP: return std::make_unique<AttReadRsp>(buffer, buffer_size);
+ case Opcode::READ_BLOB_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_BLOB_RSP: return std::make_unique<AttReadBlobRsp>(buffer, buffer_size);
+ case Opcode::READ_MULTIPLE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_MULTIPLE_RSP: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_BY_GROUP_TYPE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_BY_GROUP_TYPE_RSP: return std::make_unique<AttReadByGroupTypeRsp>(buffer, buffer_size);
+ case Opcode::WRITE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::WRITE_RSP: return std::make_unique<AttWriteRsp>(buffer, buffer_size);
+ case Opcode::WRITE_CMD: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::PREPARE_WRITE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::PREPARE_WRITE_RSP: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::EXECUTE_WRITE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::EXECUTE_WRITE_RSP: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_MULTIPLE_VARIABLE_REQ: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::READ_MULTIPLE_VARIABLE_RSP: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::MULTIPLE_HANDLE_VALUE_NTF: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::HANDLE_VALUE_NTF: return std::make_unique<AttHandleValueRcv>(buffer, buffer_size);
+ case Opcode::HANDLE_VALUE_IND: return std::make_unique<AttHandleValueRcv>(buffer, buffer_size);
+ case Opcode::HANDLE_VALUE_CFM: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ case Opcode::SIGNED_WRITE_CMD: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
+ default: return std::make_unique<AttPDUMsg>(buffer, buffer_size);
}
- return std::shared_ptr<const AttPDUMsg>(res);
}
diff --git a/src/direct_bt/GATTCharacteristic.cpp b/src/direct_bt/GATTCharacteristic.cpp
index fc55be5b..f67a1f1c 100644
--- a/src/direct_bt/GATTCharacteristic.cpp
+++ b/src/direct_bt/GATTCharacteristic.cpp
@@ -104,7 +104,6 @@ std::vector<std::unique_ptr<std::string>> GATTCharacteristic::getPropertiesStrin
}
std::string GATTCharacteristic::toString() const noexcept {
- std::shared_ptr<const uuid_t> service_uuid;
uint16_t service_handle_end = 0xffff;
GATTServiceRef serviceRef = getServiceUnchecked();
std::string service_uuid_str = "";
@@ -113,7 +112,7 @@ std::string GATTCharacteristic::toString() const noexcept {
std::string desc_str = ", descr[ ";
if( nullptr != serviceRef ) {
- service_uuid = serviceRef->type;
+ std::unique_ptr<const uuid_t> & service_uuid = serviceRef->type;
service_uuid_str = service_uuid->toString();
service_handle_end = serviceRef->endHandle;
diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp
index 9b7ba3b8..6ed0f8b3 100644
--- a/src/direct_bt/GATTHandler.cpp
+++ b/src/direct_bt/GATTHandler.cpp
@@ -211,7 +211,7 @@ void GATTHandler::l2capReaderThreadImpl() {
len = l2cap.read(rbuffer.get_wptr(), rbuffer.getSize());
if( 0 < len ) {
- std::shared_ptr<const AttPDUMsg> attPDU = AttPDUMsg::getSpecialized(rbuffer.get_ptr(), static_cast<jau::nsize_t>(len));
+ std::unique_ptr<const AttPDUMsg> attPDU = AttPDUMsg::getSpecialized(rbuffer.get_ptr(), static_cast<jau::nsize_t>(len));
const AttPDUMsg::Opcode opc = attPDU->getOpcode();
if( AttPDUMsg::Opcode::HANDLE_VALUE_NTF == opc ) {
@@ -263,7 +263,7 @@ void GATTHandler::l2capReaderThreadImpl() {
// FIXME TODO ..
ERR_PRINT("GATTHandler::reader: MULTI-NTF not implemented: %s", attPDU->toString().c_str());
} else {
- attPDURing.putBlocking( attPDU );
+ attPDURing.putBlocking( std::move(attPDU) );
}
} else if( ETIMEDOUT != errno && !l2capReaderShallStop ) { // expected exits
IRQ_PRINT("GATTHandler::reader: l2cap read error -> Stop; l2cap.read %d", len);
@@ -437,11 +437,11 @@ void GATTHandler::send(const AttPDUMsg & msg) {
}
}
-std::shared_ptr<const AttPDUMsg> GATTHandler::sendWithReply(const AttPDUMsg & msg, const int timeout) {
+std::unique_ptr<const AttPDUMsg> GATTHandler::sendWithReply(const AttPDUMsg & msg, const int timeout) {
send( msg );
// Ringbuffer read is thread safe
- std::shared_ptr<const AttPDUMsg> res = attPDURing.getBlocking(timeout);
+ std::unique_ptr<const AttPDUMsg> res = attPDURing.getBlocking(timeout);
if( nullptr == res ) {
errno = ETIMEDOUT;
IRQ_PRINT("GATTHandler::sendWithReply: nullptr result (timeout %d): req %s to %s", timeout, msg.toString().c_str(), deviceString.c_str());
@@ -466,7 +466,7 @@ uint16_t GATTHandler::exchangeMTUImpl(const uint16_t clientMaxMTU, const int32_t
uint16_t mtu = 0;
DBG_PRINT("GATT MTU send: %s to %s", req.toString().c_str(), deviceString.c_str());
- std::shared_ptr<const AttPDUMsg> pdu = sendWithReply(req, timeout); // valid reply or exception
+ std::unique_ptr<const AttPDUMsg> pdu = sendWithReply(req, timeout); // valid reply or exception
if( pdu->getOpcode() == AttPDUMsg::Opcode::EXCHANGE_MTU_RSP ) {
const AttExchangeMTU * p = static_cast<const AttExchangeMTU*>(pdu.get());
@@ -559,7 +559,7 @@ bool GATTHandler::discoverPrimaryServices(std::shared_ptr<GATTHandler> shared_th
const AttReadByNTypeReq req(true /* group */, startHandle, 0xffff, groupType);
COND_PRINT(env.DEBUG_DATA, "GATT PRIM SRV discover send: %s to %s", req.toString().c_str(), deviceString.c_str());
- std::shared_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
+ std::unique_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
COND_PRINT(env.DEBUG_DATA, "GATT PRIM SRV discover recv: %s on %s", pdu->toString().c_str(), deviceString.c_str());
if( pdu->getOpcode() == AttPDUMsg::Opcode::READ_BY_GROUP_TYPE_RSP ) {
@@ -619,7 +619,7 @@ bool GATTHandler::discoverCharacteristics(GATTServiceRef & service) {
const AttReadByNTypeReq req(false /* group */, handle, service->endHandle, characteristicTypeReq);
COND_PRINT(env.DEBUG_DATA, "GATT C discover send: %s to %s", req.toString().c_str(), deviceString.c_str());
- std::shared_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
+ std::unique_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
COND_PRINT(env.DEBUG_DATA, "GATT C discover recv: %s from %s", pdu->toString().c_str(), deviceString.c_str());
if( pdu->getOpcode() == AttPDUMsg::Opcode::READ_BY_TYPE_RSP ) {
@@ -691,7 +691,7 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
const AttFindInfoReq req(cd_handle_iter, cd_handle_end);
COND_PRINT(env.DEBUG_DATA, "GATT CD discover send: %s", req.toString().c_str());
- std::shared_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
+ std::unique_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_READ_COMMAND_REPLY_TIMEOUT); // valid reply or exception
COND_PRINT(env.DEBUG_DATA, "GATT CD discover recv: %s from ", pdu->toString().c_str(), deviceString.c_str());
if( pdu->getOpcode() == AttPDUMsg::Opcode::FIND_INFORMATION_RSP ) {
@@ -702,9 +702,9 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
// handle: handle of Characteristic Descriptor.
// value: Characteristic Descriptor UUID.
const uint16_t cd_handle = p->getElementHandle(e_iter);
- const std::shared_ptr<const uuid_t> cd_uuid = p->getElementValue(e_iter);
+ std::unique_ptr<const uuid_t> cd_uuid = p->getElementValue(e_iter);
- std::shared_ptr<GATTDescriptor> cd( new GATTDescriptor(charDecl, cd_uuid, cd_handle) );
+ std::shared_ptr<GATTDescriptor> cd( new GATTDescriptor(charDecl, std::move(cd_uuid), cd_handle) );
if( cd_handle <= charDecl->value_handle || cd_handle > cd_handle_end ) { // should never happen!
ERR_PRINT("GATT discoverDescriptors CD handle %s not in range ]%s..%s]: descr%s within char%s on %s",
jau::uint16HexString(cd_handle).c_str(),
@@ -783,7 +783,7 @@ bool GATTHandler::readValue(const uint16_t handle, POctets & res, int expectedLe
break; // done w/ only one request
} // else 0 > expectedLength: implicit
- std::shared_ptr<const AttPDUMsg> pdu = nullptr;
+ std::unique_ptr<const AttPDUMsg> pdu = nullptr;
const AttReadReq req0(handle);
const AttReadBlobReq req1(handle, offset);
@@ -896,7 +896,7 @@ bool GATTHandler::writeValue(const uint16_t handle, const TROOctets & value, con
COND_PRINT(env.DEBUG_DATA, "GATT WV send(resp %d): %s to %s", withResponse, req.toString().c_str(), deviceString.c_str());
bool res = false;
- std::shared_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_WRITE_COMMAND_REPLY_TIMEOUT); // valid reply or exception
+ std::unique_ptr<const AttPDUMsg> pdu = sendWithReply(req, env.GATT_WRITE_COMMAND_REPLY_TIMEOUT); // valid reply or exception
COND_PRINT(env.DEBUG_DATA, "GATT WV recv: %s from %s", pdu->toString().c_str(), deviceString.c_str());
if( pdu->getOpcode() == AttPDUMsg::Opcode::WRITE_RSP ) {
diff --git a/src/direct_bt/UUID.cpp b/src/direct_bt/UUID.cpp
index 97b2fe81..55e27397 100644
--- a/src/direct_bt/UUID.cpp
+++ b/src/direct_bt/UUID.cpp
@@ -44,13 +44,13 @@ uuid_t::TypeSize uuid_t::toTypeSize(const jau::nsize_t size) {
throw jau::IllegalArgumentException("Given size "+std::to_string(size)+", not matching uuid16_t, uuid32_t or uuid128_t", E_FILE_LINE);
}
-std::shared_ptr<const uuid_t> uuid_t::create(TypeSize t, uint8_t const * const buffer, jau::nsize_t const byte_offset, bool littleEndian) {
+std::unique_ptr<const uuid_t> uuid_t::create(TypeSize t, uint8_t const * const buffer, jau::nsize_t const byte_offset, bool littleEndian) {
if( TypeSize::UUID16_SZ == t ) {
- return std::shared_ptr<const uuid_t>(new uuid16_t(buffer, byte_offset, littleEndian));
+ return std::unique_ptr<const uuid_t>(new uuid16_t(buffer, byte_offset, littleEndian));
} else if( TypeSize::UUID32_SZ == t ) {
- return std::shared_ptr<const uuid_t>(new uuid32_t(buffer, byte_offset, littleEndian));
+ return std::unique_ptr<const uuid_t>(new uuid32_t(buffer, byte_offset, littleEndian));
} else if( TypeSize::UUID128_SZ == t ) {
- return std::shared_ptr<const uuid_t>(new uuid128_t(buffer, byte_offset, littleEndian));
+ return std::unique_ptr<const uuid_t>(new uuid128_t(buffer, byte_offset, littleEndian));
}
throw jau::IllegalArgumentException("Unknown Type "+std::to_string(static_cast<jau::nsize_t>(t)), E_FILE_LINE);
}