diff options
Diffstat (limited to 'include/ble')
-rw-r--r-- | include/ble/Bluetooth.h | 27 | ||||
-rw-r--r-- | include/ble/ByteBuffer.h | 8 |
2 files changed, 22 insertions, 13 deletions
diff --git a/include/ble/Bluetooth.h b/include/ble/Bluetooth.h index 28e2794..80becec 100644 --- a/include/ble/Bluetooth.h +++ b/include/ble/Bluetooth.h @@ -38,31 +38,38 @@ typedef std::shared_ptr<BluetoothAdapter> BluetoothAdapterPtr; class Mac { public: - explicit Mac(uint8_t _5, uint8_t _4, uint8_t _3, uint8_t _2, uint8_t _1, uint8_t _0) : bytes() { - bytes[5] = _5; - bytes[4] = _4; - bytes[3] = _3; - bytes[2] = _2; - bytes[1] = _1; + explicit Mac(uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5) : bytes() { bytes[0] = _0; + bytes[1] = _1; + bytes[2] = _2; + bytes[3] = _3; + bytes[4] = _4; + bytes[5] = _5; }; string str() const; - bool operator==(Mac &other) const; +// bool operator==(const Mac &other) const; +// bool operator!=(const Mac &other) const; +// bool operator<(const Mac &other) const; - bool operator!=(Mac &other) const; - - void copy(uint8_t &_5, uint8_t &_4, uint8_t &_3, uint8_t &_2, uint8_t &_1, uint8_t &_0) const; + void copy(uint8_t &_0, uint8_t &_1, uint8_t &_2, uint8_t &_3, uint8_t &_4, uint8_t &_5) const; static Mac parseMac(string s); friend bool operator<(const Mac &a, const Mac &b); + friend bool operator==(const Mac &a, const Mac &b); private: uint8_t bytes[6]; }; +std::ostream& operator<<(std::ostream& os, const Mac& mac); + +bool operator==(const Mac &a, const Mac &b); +bool operator!=(const Mac &a, const Mac &b); +bool operator<(const Mac &a, const Mac &b); + class BluetoothCallback { virtual ~BluetoothCallback() = default; diff --git a/include/ble/ByteBuffer.h b/include/ble/ByteBuffer.h index 6b09049..1ba088f 100644 --- a/include/ble/ByteBuffer.h +++ b/include/ble/ByteBuffer.h @@ -42,7 +42,7 @@ public: ByteBuffer(uint8_t *bytes, size_t size) noexcept : zero(bytes), end_(&bytes[size]), cursor(zero) {}; ByteBuffer(uint8_t *bytes, size_t size, size_t position) : zero(bytes), end_(&bytes[size]), cursor(zero) { - setPosition(position); + setCursor(position); }; template<size_t N> @@ -64,8 +64,10 @@ public: return end_ - cursor; } - inline ByteBuffer &setPosition(size_t newCursor) { - cursor = &zero[newCursor]; + inline ByteBuffer &setCursor(size_t newCursor) { + auto tmp = &zero[newCursor]; + assertCanAccessPtr(tmp); + cursor = tmp; return *this; } |