From e1f28982cfe90791f7c4487e9a69a46b4b719c29 Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Sat, 30 Apr 2022 14:48:31 -0700 Subject: [PATCH] When configured set meshtastic bluetooth name based on owner shortname. --- src/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 666a59831..9eb1f314d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -97,8 +97,15 @@ const char *getDeviceName() getMacAddr(dmac); // Meshtastic_ab3c - static char name[20]; - sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]); + 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); + } else { + sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]); + } return name; }