From afb2f8d4c7b02ddb23c5397526dd73865caa191e Mon Sep 17 00:00:00 2001 From: h2zero Date: Fri, 19 Jun 2020 12:32:57 -0600 Subject: [PATCH] Add uint64_t cast of an address --- src/NimBLEAddress.cpp | 6 ++++++ src/NimBLEAddress.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/NimBLEAddress.cpp b/src/NimBLEAddress.cpp index b6bc952..8c2c68f 100644 --- a/src/NimBLEAddress.cpp +++ b/src/NimBLEAddress.cpp @@ -142,4 +142,10 @@ NimBLEAddress::operator std::string() const { return std::string(buffer); } +NimBLEAddress::operator uint64_t() const { + uint64_t address = 0; + memcpy(&address, m_address, sizeof m_address); + return address; +} + #endif diff --git a/src/NimBLEAddress.h b/src/NimBLEAddress.h index e81a2bd..778ff86 100644 --- a/src/NimBLEAddress.h +++ b/src/NimBLEAddress.h @@ -44,6 +44,7 @@ public: bool operator ==(const NimBLEAddress & rhs) const; bool operator !=(const NimBLEAddress & rhs) const; operator std::string() const; + operator uint64_t() const; private: uint8_t m_address[6];