From 3d3511ceeb8e8646c9bcf3dec46e1fd5f8ff5ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 Jun 2022 20:54:50 +0200 Subject: [PATCH] Change to a different logic --- src/main.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c709f90e..5efbb841 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,15 +101,14 @@ const char *getDeviceName() getMacAddr(dmac); - // Meshtastic_ab3c - static char name[30]; - // If we have an owner shortname and it is short. - if (owner.short_name != NULL - && strlen(owner.short_name) >= 2 - && strlen(owner.short_name) < 10) { - sprintf(name, "Meshtastic_%s", owner.short_name); + // Meshtastic_ab3c or Shortname_abcd + static char name[20]; + sprintf(name, "%02x%02x", dmac[4], dmac[5]); + // if the shortname exists and is NOT the new default of ab3c, use it for BLE name. + if ((owner.short_name != NULL) && (owner.short_name != name)) { + sprintf(name, "%s_%02x%02x", owner.short_name, dmac[4], dmac[5]); } else { - sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]); + sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]); } return name; }