Skip to content

Commit 96d01c0

Browse files
Scoutzknifezh2zero
authored andcommitted
Added the setDeviceName functionality while BLE is running (#421)
1 parent 1cddddb commit 96d01c0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/NimBLEDevice.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,15 @@ void NimBLEDevice::deinit(bool clearAll) {
971971
}
972972
} // deinit
973973

974+
/**
975+
* @brief Set the BLEDevice's name
976+
* @param [in] deviceName The device name of the device.
977+
*/
978+
/* STATIC */
979+
void NimBLEDevice::setDeviceName(const std::string &deviceName) {
980+
ble_svc_gap_device_name_set(deviceName.c_str());
981+
} // setDeviceName
982+
974983

975984
/**
976985
* @brief Check if the initialization is complete.

src/NimBLEDevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class NimBLEDevice {
9797
public:
9898
static void init(const std::string &deviceName);
9999
static void deinit(bool clearAll = false);
100+
static void setDeviceName(const std::string &deviceName);
100101
static bool getInitialized();
101102
static NimBLEAddress getAddress();
102103
static std::string toString();

0 commit comments

Comments
 (0)