From 217d06ca3a84268b5edc0ff0e64b4a1e3398de2c Mon Sep 17 00:00:00 2001 From: David Lehrian Date: Sun, 22 Oct 2023 15:05:29 -0700 Subject: [PATCH] Update NimBLEAdvertising.cpp Apparently a name length of 19 is a magic number because if it is longer than this then adding the null at the end isn't necessary, shortening the name works. Furthermore, adding the null appears to step on something and cause the uP to reboot. However if the name is shorter than 19 then adding a null at the end allows the name to be shortened without having the end of the previous longer name tacked onto the end of the shorter name AND it doesn't seem to step on anything as the uP appears to continue to operate fine. --- src/NimBLEAdvertising.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index af98b34..4dd5a39 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -138,7 +138,7 @@ void NimBLEAdvertising::addTxPower() { */ void NimBLEAdvertising::setName(const std::string &name) { m_name.assign(name.begin(), name.end()); - m_name[name.length()] = 0; + if (name.length() <= 19) m_name[name.length()] = 0; m_advData.name = &m_name[0]; m_advData.name_len = m_name.size(); m_advDataSet = false;