From 6b555d763b9c715856d3e2dd513b3c48dc0270a8 Mon Sep 17 00:00:00 2001 From: David Lehrian Date: Fri, 6 Oct 2023 13:12:15 -0700 Subject: [PATCH] Update NimBLEAdvertising.cpp Null terminate the m_name vector because for some reason if you shorten the advertising name it will keep the length the same as the longest name that has been set until the uP is restarted. This means that if you set the name to "longest" and then set it to "short" it will advertise as "shortst" (note two letters from the end of "longest". --- src/NimBLEAdvertising.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index 50a9e89..af98b34 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -138,6 +138,7 @@ void NimBLEAdvertising::addTxPower() { */ void NimBLEAdvertising::setName(const std::string &name) { m_name.assign(name.begin(), name.end()); + m_name[name.length()] = 0; m_advData.name = &m_name[0]; m_advData.name_len = m_name.size(); m_advDataSet = false;