From 10acb004dc692a865d1cbda54c9031a20509cffa Mon Sep 17 00:00:00 2001 From: h2zero Date: Wed, 2 Sep 2020 14:52:34 -0600 Subject: [PATCH] NimBLEAddress: New constructor added to create blank addresses * Docuement NimBLEAddress::getNative in migration docs. --- docs/Migration_guide.md | 6 ++++++ src/NimBLEAddress.cpp | 8 ++++++++ src/NimBLEAddress.h | 1 + 3 files changed, 15 insertions(+) diff --git a/docs/Migration_guide.md b/docs/Migration_guide.md index 954a84b..9ed81ce 100644 --- a/docs/Migration_guide.md +++ b/docs/Migration_guide.md @@ -47,6 +47,12 @@ For example `BLEAddress addr(11:22:33:44:55:66, 1)` will create the address obje As this paramameter is optional no changes to existing code are needed, it is mentioned here for information.
+`BLEAddress::getNative` (`NimBLEAddress::getNative`) returns a uint8_t pointer to the native address byte array. +In this library the address bytes are stored in reverse order from the original library. This is due to the way +the NimBLE stack expects addresses to be presented to it. All other functions such as `toString` are +not affected as the endian change is made within them. +
+ ## Server API Creating a `BLEServer` instance is the same as original, no changes required. diff --git a/src/NimBLEAddress.cpp b/src/NimBLEAddress.cpp index 752e783..e1d3e54 100644 --- a/src/NimBLEAddress.cpp +++ b/src/NimBLEAddress.cpp @@ -37,6 +37,14 @@ NimBLEAddress::NimBLEAddress(ble_addr_t address) { } // NimBLEAddress +/** + * @brief Create a blank address, i.e. 00:00:00:00:00:00, type 0. + */ +NimBLEAddress::NimBLEAddress() { + NimBLEAddress(""); +} // NimBLEAddress + + /** * @brief Create an address from a hex string * diff --git a/src/NimBLEAddress.h b/src/NimBLEAddress.h index 52ef9b4..50f9231 100644 --- a/src/NimBLEAddress.h +++ b/src/NimBLEAddress.h @@ -33,6 +33,7 @@ */ class NimBLEAddress { public: + NimBLEAddress(); NimBLEAddress(ble_addr_t address); NimBLEAddress(uint8_t address[6], uint8_t type = BLE_ADDR_PUBLIC); NimBLEAddress(const std::string &stringAddress, uint8_t type = BLE_ADDR_PUBLIC);