Compare commits

...

4 Commits

Author SHA1 Message Date
David Lehrian 26da716ebe
Merge e94c081378 into 22fb1ab801 2024-02-04 18:14:42 +00:00
David Lehrian e94c081378
Merge branch 'h2zero:master' into master 2024-02-04 10:14:40 -08:00
David Lehrian 217d06ca3a 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.
2023-10-22 15:05:29 -07:00
David Lehrian 6b555d763b 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".
2023-10-06 13:12:15 -07:00
1 changed files with 1 additions and 0 deletions

View File

@ -138,6 +138,7 @@ void NimBLEAdvertising::addTxPower() {
*/
void NimBLEAdvertising::setName(const std::string &name) {
m_name.assign(name.begin(), name.end());
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;