From e1f28982cfe90791f7c4487e9a69a46b4b719c29 Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Sat, 30 Apr 2022 14:48:31 -0700 Subject: [PATCH 1/7] 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; } From ca3192b3dc95f89a17712644ad85c30339f41fca Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Sat, 30 Apr 2022 18:20:41 -0700 Subject: [PATCH 2/7] Clear the existing data before we start advertising --- src/nrf52/NRF52Bluetooth.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nrf52/NRF52Bluetooth.cpp b/src/nrf52/NRF52Bluetooth.cpp index e505e2104..28aa4fea2 100644 --- a/src/nrf52/NRF52Bluetooth.cpp +++ b/src/nrf52/NRF52Bluetooth.cpp @@ -225,6 +225,11 @@ void NRF52Bluetooth::setup() Bluefruit.autoConnLed(false); Bluefruit.begin(); + // Clear existing data. + Bluefruit.Advertising.stop(); + Bluefruit.Advertising.clearData(); + Bluefruit.ScanResponse.clearData(); + // Set the advertised device name (keep it short!) Bluefruit.setName(getDeviceName()); @@ -276,4 +281,4 @@ void NRF52Bluetooth::clearBonds() Bluefruit.Periph.clearBonds(); Bluefruit.Central.clearBonds(); -} \ No newline at end of file +} From 49e47f3e6d02a65c23eee66eefd279d782ad15a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 15 Jun 2022 21:50:33 +0200 Subject: [PATCH 3/7] Let's try this --- src/mesh/PhoneAPI.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 84ff17d93..406963951 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -232,6 +232,9 @@ bool PhoneAPI::available() case STATE_SEND_MY_INFO: return true; + + case STATE_SEND_CONFIG: + return true; case STATE_SEND_NODEINFO: if (!nodeInfoForPhone) @@ -281,4 +284,4 @@ int PhoneAPI::onNotify(uint32_t newValue) DEBUG_MSG("(Client not yet interested in packets)\n"); return 0; -} \ No newline at end of file +} 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 4/7] 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 c709f90e2..5efbb841c 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; } From bc9a4367d1472e416a1674f1f6b539db2871d435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 Jun 2022 20:58:15 +0200 Subject: [PATCH 5/7] Fix #1510 --- src/mesh/NodeDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index f70ffa1dd..4d9e27cf4 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -204,7 +204,7 @@ void NodeDB::installDefaultDeviceState() // Set default owner name pickNewNodeNum(); // based on macaddr now - sprintf(owner.long_name, "Unknown %02x%02x", ourMacAddr[4], ourMacAddr[5]); + sprintf(owner.long_name, "Meshtastic %02x%02x", ourMacAddr[4], ourMacAddr[5]); sprintf(owner.short_name, "%02x%02x", ourMacAddr[4], ourMacAddr[5]); sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum From d4a4bcf91a4ca255167230de0465eac948c85f71 Mon Sep 17 00:00:00 2001 From: caveman99 Date: Thu, 16 Jun 2022 19:31:21 +0000 Subject: [PATCH 6/7] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/mesh.pb.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/protobufs b/protobufs index a7bbc3586..94a4dbb84 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit a7bbc358664c83f5148bae2a502cb294e7cafee5 +Subproject commit 94a4dbb842961e75f89de13dc6d0437a256098aa diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index bbc79896e..65e6c5e20 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -4,7 +4,7 @@ #ifndef PB_MESH_PB_H_INCLUDED #define PB_MESH_PB_H_INCLUDED #include -#include "localonly.pb.h" +#include "config.pb.h" #include "portnums.pb.h" #include "telemetry.pb.h" @@ -631,7 +631,7 @@ typedef struct _FromRadio { union { MyNodeInfo my_info; NodeInfo node_info; - LocalConfig config; + Config config; LogRecord log_record; uint32_t config_complete_id; bool rebooted; @@ -980,7 +980,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11) #define FromRadio_DEFAULT NULL #define FromRadio_payloadVariant_my_info_MSGTYPE MyNodeInfo #define FromRadio_payloadVariant_node_info_MSGTYPE NodeInfo -#define FromRadio_payloadVariant_config_MSGTYPE LocalConfig +#define FromRadio_payloadVariant_config_MSGTYPE Config #define FromRadio_payloadVariant_log_record_MSGTYPE LogRecord #define FromRadio_payloadVariant_packet_MSGTYPE MeshPacket From f63b876b71eb79991ff46d7877bccdbc1f135998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 16 Jun 2022 21:56:18 +0200 Subject: [PATCH 7/7] Send config chunks one by one --- src/mesh/PhoneAPI.cpp | 36 +++++++++++++++++++++++++++++++++--- src/mesh/PhoneAPI.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 406963951..25569b18f 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -148,13 +148,43 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) case STATE_SEND_CONFIG: fromRadioScratch.which_payloadVariant = FromRadio_config_tag; - fromRadioScratch.config = config; + switch (config_state) { + case Config_device_tag: + fromRadioScratch.config.which_payloadVariant = Config_device_tag; + fromRadioScratch.config.payloadVariant.device = config.device; + break; + case Config_position_tag: + fromRadioScratch.config.which_payloadVariant = Config_position_tag; + fromRadioScratch.config.payloadVariant.position = config.position; + break; + case Config_power_tag: + fromRadioScratch.config.which_payloadVariant = Config_power_tag; + fromRadioScratch.config.payloadVariant.power = config.power; + fromRadioScratch.config.payloadVariant.power.ls_secs = default_ls_secs; + break; + case Config_wifi_tag: + fromRadioScratch.config.which_payloadVariant = Config_wifi_tag; + fromRadioScratch.config.payloadVariant.wifi = config.wifi; + break; + case Config_display_tag: + fromRadioScratch.config.which_payloadVariant = Config_display_tag; + fromRadioScratch.config.payloadVariant.display = config.display; + break; + case Config_lora_tag: + fromRadioScratch.config.which_payloadVariant = Config_lora_tag; + fromRadioScratch.config.payloadVariant.lora = config.lora; + break; + } // NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. // So even if we internally use 0 to represent 'use default' we still need to send the value we are // using to the app (so that even old phone apps work with new device loads). - fromRadioScratch.config.power.ls_secs = default_ls_secs; - state = STATE_SEND_NODEINFO; + + config_state++; + // Advance when we have sent all of our config objects + if (config_state > Config_lora_tag) { + state = STATE_SEND_NODEINFO; + } break; case STATE_SEND_NODEINFO: { diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index f17ed26c0..3109a5e89 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -31,6 +31,8 @@ class PhoneAPI State state = STATE_SEND_NOTHING; + int8_t config_state = Config_device_tag; + /** * Each packet sent to the phone has an incrementing count */