diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/BTTypes.hpp | 17 | ||||
-rw-r--r-- | api/direct_bt/GATTDescriptor.hpp | 3 | ||||
-rw-r--r-- | api/direct_bt/OctetTypes.hpp | 14 |
3 files changed, 16 insertions, 18 deletions
diff --git a/api/direct_bt/BTTypes.hpp b/api/direct_bt/BTTypes.hpp index e0505095..d6d09f5a 100644 --- a/api/direct_bt/BTTypes.hpp +++ b/api/direct_bt/BTTypes.hpp @@ -400,9 +400,7 @@ namespace direct_bt { std::string const companyName; POctets data; - ManufactureSpecificData() noexcept - : company(0), companyName(), data(0) {} - + ManufactureSpecificData(uint16_t const company) noexcept; ManufactureSpecificData(uint16_t const company, uint8_t const * const data, int const data_len) noexcept; std::string toString() const noexcept; @@ -506,22 +504,13 @@ namespace direct_bt { void setName(const uint8_t *buffer, int buffer_len) noexcept; void setShortName(const uint8_t *buffer, int buffer_len) noexcept; void setTxPower(int8_t v) noexcept { tx_power = v; set(EIRDataType::TX_POWER); } - void setManufactureSpecificData(uint16_t const company, uint8_t const * const data, int const data_len) noexcept { - msd = std::shared_ptr<ManufactureSpecificData>(new ManufactureSpecificData(company, data, data_len)); - set(EIRDataType::MANUF_DATA); - } + void setManufactureSpecificData(uint16_t const company, uint8_t const * const data, int const data_len) noexcept; void addService(std::shared_ptr<uuid_t> const &uuid) noexcept; void setDeviceClass(uint32_t c) noexcept { device_class= c; set(EIRDataType::DEVICE_CLASS); } void setAppearance(AppearanceCat a) noexcept { appearance= a; set(EIRDataType::APPEARANCE); } void setHash(const uint8_t * h) noexcept { hash.resize(16); memcpy(hash.get_wptr(), h, 16); set(EIRDataType::HASH); } void setRandomizer(const uint8_t * r) noexcept { randomizer.resize(16); memcpy(randomizer.get_wptr(), r, 16); set(EIRDataType::RANDOMIZER); } - void setDeviceID(const uint16_t source, const uint16_t vendor, const uint16_t product, const uint16_t version) noexcept { - did_source = source; - did_vendor = vendor; - did_product = product; - did_version = version; - set(EIRDataType::DEVICE_ID); - } + void setDeviceID(const uint16_t source, const uint16_t vendor, const uint16_t product, const uint16_t version) noexcept; int next_data_elem(uint8_t *eir_elem_len, uint8_t *eir_elem_type, uint8_t const **eir_elem_data, uint8_t const * data, int offset, int const size) noexcept; diff --git a/api/direct_bt/GATTDescriptor.hpp b/api/direct_bt/GATTDescriptor.hpp index 614b61e4..a9a6407b 100644 --- a/api/direct_bt/GATTDescriptor.hpp +++ b/api/direct_bt/GATTDescriptor.hpp @@ -53,6 +53,7 @@ namespace direct_bt { class DBTDevice; // forward + class GATTHandler; // forward class GATTCharacteristic; // forward typedef std::shared_ptr<GATTCharacteristic> GATTCharacteristicRef; @@ -125,7 +126,7 @@ namespace direct_bt { GATTDescriptor(const GATTCharacteristicRef & characteristic, const std::shared_ptr<const uuid_t> & type, const uint16_t handle) noexcept - : wbr_characteristic(characteristic), type(type), handle(handle), value(0) {} + : wbr_characteristic(characteristic), type(type), handle(handle), value(/* intentional zero sized */) {} std::string get_java_class() const noexcept override { return java_class(); diff --git a/api/direct_bt/OctetTypes.hpp b/api/direct_bt/OctetTypes.hpp index 0e94f557..9b9c6eac 100644 --- a/api/direct_bt/OctetTypes.hpp +++ b/api/direct_bt/OctetTypes.hpp @@ -408,13 +408,21 @@ namespace direct_bt { /** Returns the memory capacity, never zero, greater or equal {@link #getSize()}. */ inline int getCapacity() const noexcept { return capacity; } + /** Intentional zero sized POctets instance. */ + POctets() + : TOctets( nullptr, 0, true /* nocheck */), + capacity(0) + { + TRACE_PRINT("POctets ctor0: zero-sized"); + } + /** Takes ownership (malloc and copy, free) ..*/ POctets(const uint8_t *_source, const int _size) : TOctets( malloc(_size), _size), capacity( _size ) { std::memcpy(data(), _source, _size); - TRACE_PRINT("POctets ctor0: %p", data()); + TRACE_PRINT("POctets ctor1: %p", data()); } /** New buffer (malloc, free) */ @@ -425,14 +433,14 @@ namespace direct_bt { if( capacity < getSize() ) { throw IllegalArgumentException("capacity "+std::to_string(capacity)+" < size "+std::to_string(getSize()), E_FILE_LINE); } - TRACE_PRINT("POctets ctor1: %p", data()); + TRACE_PRINT("POctets ctor2: %p", data()); } /** New buffer (malloc, free) */ POctets(const int size) : POctets(size, size) { - TRACE_PRINT("POctets ctor2: %p", data()); + TRACE_PRINT("POctets ctor3: %p", data()); } POctets(const POctets &_source) |