fix(build): restore nRF52 builds broken by observer-only dependencies

Three fork-introduced dependencies had leaked into non-ESP32 builds, breaking
every nRF52 and RP2040 target since 7e4f75c9 (2026-04-10):

- The `memory` CLI command called ESP.getFreeHeap()/heap_caps_* unguarded from
  shared CommonCLI.cpp. ESP32 output is unchanged; other platforms now report
  newlib arena stats, omitting min-ever-free and largest-free-block rather than
  substituting numbers that mean something different.
- The vendored PsychicMqttClient (ESP-IDF esp-mqtt) was pulled in by the LDF on
  nRF52; nrf52_base now lib_ignores it, matching how RP2040 variants ignore BLE.
- JWTHelper.cpp and MQTTMessageBuilder.cpp are excluded in arduino_base, but 22
  variants re-glob helpers/*.cpp after inheriting it, which undoes the exclusion.
  Guarding the file contents on WITH_MQTT_BRIDGE is robust against any variant's
  filter, and matches helpers/esp32/WebConfigServer.cpp.

Verified: RAK4631 repeater + room server, Heltec T114, T1000-E, Wio WM1110,
Xiao nRF52 and ThinkNode M1 all build. ESP32 observer builds are byte-identical
to before (RAM and flash), and the native suite stays at 267/267.

RP2040 still fails separately: four boards declare the pre-force_ap
startOTAUpdate signature. Not addressed here.
This commit is contained in:
agessaman committed 2026-08-03 11:27:36 -07:00
1 parent 126a2564ed
commit 45379ad742
4 files changed
+28

No files matched your search

+2
View File
@@ -104,6 +104,8 @@ build_flags = ${arduino_base.build_flags}
lib_deps =
${arduino_base.lib_deps}
https://github.com/oltaco/CustomLFS#0.2.2
; Vendored ESP-IDF MQTT client; the LDF otherwise pulls it into non-ESP builds.
lib_ignore = PsychicMqttClient
; ----------------- RP2040 ---------------------
[rp2040_base]
+13
View File
@@ -15,6 +15,8 @@
#include <WiFiClientSecure.h>
#include <esp_wifi.h>
#include <esp_heap_caps.h>
#else
#include <malloc.h> // mallinfo() for the `memory` command on nRF52/RP2040
#endif
#ifdef WITH_MQTT_BRIDGE
#include "bridges/MQTTBridge.h"
@@ -842,6 +844,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
strcpy(reply, "ERR: clock cannot go backwards");
}
} else if (memcmp(command, "memory", 6) == 0) {
#ifdef ESP_PLATFORM
sprintf(reply, "Free: %d, Min: %d, Max: %d, Queue: %d, IntFree: %d, IntMax: %d, PSRAM: %d/%d",
ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap(),
_callbacks->getQueueSize(),
@@ -849,6 +852,16 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
(int)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL),
(int)heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
(int)heap_caps_get_total_size(MALLOC_CAP_SPIRAM));
#else
// newlib arena stats — the portable equivalent on nRF52/RP2040. There is
// no min-ever-free or largest-free-block counterpart, so those fields are
// left out rather than filled with numbers that mean something different.
// Frags is the free-chunk count, the closest available fragmentation hint.
struct mallinfo mi = mallinfo();
sprintf(reply, "Free: %d, Used: %d, Arena: %d, Frags: %d, Queue: %d",
(int)mi.fordblks, (int)mi.uordblks, (int)mi.arena, (int)mi.ordblks,
_callbacks->getQueueSize());
#endif
} else if (memcmp(command, "start ota", 9) == 0) {
// Manual OTA: bring up the ElegantOTA web UI for a hand-uploaded binary.
// Plain "start ota" serves on the station IP when joined to WiFi, else
+6
View File
@@ -1,3 +1,8 @@
// MQTT-only translation unit. 22 variants re-glob helpers/*.cpp past the
// arduino_base exclusion, so the contents are guarded here rather than in
// the build filter — same idiom as helpers/esp32/WebConfigServer.cpp.
#ifdef WITH_MQTT_BRIDGE
#include "JWTHelper.h"
#include <ArduinoJson.h>
#include <SHA256.h>
@@ -196,3 +201,4 @@ size_t JWTHelper::createPayload(
return base64UrlEncode((uint8_t*)jsonBuffer, len, output, outputSize);
}
#endif // WITH_MQTT_BRIDGE
+7
View File
@@ -1,3 +1,8 @@
// MQTT-only translation unit. 22 variants re-glob helpers/*.cpp past the
// arduino_base exclusion, so the contents are guarded here rather than in
// the build filter — same idiom as helpers/esp32/WebConfigServer.cpp.
#ifdef WITH_MQTT_BRIDGE
#include "MQTTMessageBuilder.h"
#include "MQTTPayloadBuilder.h"
#include <ArduinoJson.h>
@@ -361,3 +366,5 @@ void MQTTMessageBuilder::packetToHex(mesh::Packet* packet, char* hex, size_t hex
// Convert serialized packet to hex
bytesToHex(raw_buf, raw_len, hex, hex_size);
}
#endif // WITH_MQTT_BRIDGE