From a4a62493e2903893d91ad33a6b9d44d116b60c1e Mon Sep 17 00:00:00 2001 From: Cody Date: Thu, 21 Jul 2022 16:33:21 -0700 Subject: [PATCH] Added the setDeviceName functionality while BLE is running (#421) --- src/NimBLEDevice.cpp | 9 +++++++++ src/NimBLEDevice.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 6ae9a77..43ba219 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -971,6 +971,15 @@ void NimBLEDevice::deinit(bool clearAll) { } } // deinit +/** + * @brief Set the BLEDevice's name + * @param [in] deviceName The device name of the device. + */ +/* STATIC */ +void NimBLEDevice::setDeviceName(const std::string &deviceName) { + ble_svc_gap_device_name_set(deviceName.c_str()); +} // setDeviceName + /** * @brief Check if the initialization is complete. diff --git a/src/NimBLEDevice.h b/src/NimBLEDevice.h index b7e804b..92c2187 100644 --- a/src/NimBLEDevice.h +++ b/src/NimBLEDevice.h @@ -97,6 +97,7 @@ class NimBLEDevice { public: static void init(const std::string &deviceName); static void deinit(bool clearAll = false); + static void setDeviceName(const std::string &deviceName); static bool getInitialized(); static NimBLEAddress getAddress(); static std::string toString();