* feat: add Raspberry Pi Pico 2 + W5500 + E22-900M30S variant Adds community variant for Raspberry Pi Pico 2 (RP2350, 4 MB flash) with external WIZnet W5500 Ethernet module and EBYTE E22-900M30S LoRa module (SX1262, 30 dBm PA, 868/915 MHz). Key details: - LoRa on SPI1: GP10/11/12/13 (SCK/MOSI/MISO/CS), RST=GP15, DIO1=GP14, BUSY=GP2, RXEN=GP3 (held HIGH via SX126X_ANT_SW) - W5500 on SPI0: GP16/17/18/19/20 (MISO/CS/SCK/MOSI/RST) - SX126X_DIO2_AS_RF_SWITCH: DIO2→TXEN bridge on module handles PA - SX126X_DIO3_TCXO_VOLTAGE 1.8: TCXO support via EBYTE_E22 flags - DHCP timeout reduced to 10 s to avoid blocking LoRa startup - GPS on UART1/Serial2: GP8 TX, GP9 RX - Reuses WIZNET_5500_EVB_PICO2 code paths for Ethernet init Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * pico2_w5500_e22: rename define and address review feedback Rename WIZNET_5500_EVB_PICO2 to PICO2_W5500_E22 so the variant-specific define matches the variant directory name and isn't confused with an on-board EVB SKU. Review fixes from PR #10135: - Gate the 10 s Ethernet DHCP timeout behind PICO2_W5500_E22 so other Ethernet builds keep the default 60 s behavior; apply the same timeout to reconnectETH() for consistency. - Drop the unused -D EBYTE_E22 flag; EBYTE_E22_900M30S already selects TX_GAIN_LORA / SX126X_MAX_POWER in src/configuration.h. - Rewrite "on-board W5500" comments to describe the external module. - Correct README TX_GAIN_LORA value (7, not 10) and drop the EBYTE_E22 row. * fix(pico2_w5500_e22): drop DEBUG_RP2040_PORT=Serial The arduino-pico framework hooks _write() when DEBUG_RP2040_PORT=Serial is set and dumps raw debug bytes onto USB CDC, corrupting any binary protobuf stream sent through StreamAPI (e.g. `meshtastic --port COMx`). The variant excludes BT and WiFi, so the primary client transport is Ethernet TCP via ethServerAPI — unaffected — but users who configure the node over USB serial would see protobuf decode failures from debug-byte interleaving. Removing the flag restores clean USB CDC. Debug output can still be enabled per-build by adding -D DEBUG_RP2040_PORT=Serial1 to redirect to UART0 instead of USB CDC. * style(pico2_w5500_e22): apply trunk fmt — fixes Trunk Check - variant.h: clang-format 16.0.3 (drop manual #define alignment) - README.md: prettier + add `text` language to fenced code blocks (markdownlint MD040) - wiring.svg: svgo optimization Resolves the Trunk Check Runner failure on this PR (3 unformatted files + 8 markdownlint issues). No functional changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(pico2_w5500_e22): address review — move to rp2350/diy, generic guards Maintainer feedback from NomDeTom on PR #10135: - Move the variant from variants/rp2350/ to variants/rp2350/diy/ to distinguish DIY from prebuilt boards (matches the variants/*/diy/ pattern; still discovered via the existing variants/*/diy/*/platformio.ini glob in the root platformio.ini). - Replace the board-name macro PICO2_W5500_E22 in shared code with a generic capability macro USE_ARDUINO_ETHERNET, defined from variant.h. DebugConfiguration.h / ethServerAPI.h / ethClient.cpp no longer reference a board name. - Drop the architecture.h hook entirely: variant.h now defines PRIVATE_HW, which the existing `#elif defined(PRIVATE_HW)` branch already handles. No functional change. Build verified: pico2_w5500_e22 SUCCESS (RAM 19.2%, Flash 28.1%). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(pico2_w5500_e22): drop unoptimized wiring.svg to fix trunk fmt check --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
211 lines
7.5 KiB
C++
211 lines
7.5 KiB
C++
#pragma once
|
|
|
|
#include "configuration.h"
|
|
|
|
// Forward declarations
|
|
#if defined(DEBUG_HEAP)
|
|
class MemGet;
|
|
extern MemGet memGet;
|
|
#endif
|
|
|
|
// DEBUG LED
|
|
#ifndef LED_STATE_ON
|
|
#define LED_STATE_ON 1
|
|
#endif
|
|
|
|
// WIFI LED
|
|
#ifndef WIFI_STATE_ON
|
|
#define WIFI_STATE_ON 1
|
|
#endif
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// DEBUG
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#ifdef CONSOLE_MAX_BAUD
|
|
#define SERIAL_BAUD CONSOLE_MAX_BAUD
|
|
#else
|
|
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
|
#endif
|
|
|
|
#define MESHTASTIC_LOG_LEVEL_DEBUG "DEBUG"
|
|
#define MESHTASTIC_LOG_LEVEL_INFO "INFO "
|
|
#define MESHTASTIC_LOG_LEVEL_WARN "WARN "
|
|
#define MESHTASTIC_LOG_LEVEL_ERROR "ERROR"
|
|
#define MESHTASTIC_LOG_LEVEL_CRIT "CRIT "
|
|
#define MESHTASTIC_LOG_LEVEL_TRACE "TRACE"
|
|
#define MESHTASTIC_LOG_LEVEL_HEAP "HEAP"
|
|
|
|
#include "SerialConsole.h"
|
|
|
|
// If defined we will include support for ARM ICE "semihosting" for a virtual
|
|
// console over the JTAG port (to replace the normal serial port)
|
|
// Note: Normally this flag is passed into the gcc commandline by platformio.ini.
|
|
// for an example see env:rak4631_dap.
|
|
// #ifndef USE_SEMIHOSTING
|
|
// #define USE_SEMIHOSTING
|
|
// #endif
|
|
|
|
#define DEBUG_PORT (*console) // Serial debug port
|
|
|
|
#ifdef USE_SEGGER
|
|
// #undef DEBUG_PORT
|
|
#define LOG_DEBUG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#define LOG_INFO(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#define LOG_WARN(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#define LOG_ERROR(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#define LOG_CRIT(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#define LOG_TRACE(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
#else
|
|
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
|
#define LOG_DEBUG(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_DEBUG, __VA_ARGS__)
|
|
#define LOG_INFO(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_INFO, __VA_ARGS__)
|
|
#define LOG_WARN(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_WARN, __VA_ARGS__)
|
|
#define LOG_ERROR(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_ERROR, __VA_ARGS__)
|
|
#define LOG_CRIT(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_CRIT, __VA_ARGS__)
|
|
#define LOG_TRACE(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_TRACE, __VA_ARGS__)
|
|
#else
|
|
#define LOG_DEBUG(...)
|
|
#define LOG_INFO(...)
|
|
#define LOG_WARN(...)
|
|
#define LOG_ERROR(...)
|
|
#define LOG_CRIT(...)
|
|
#define LOG_TRACE(...)
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(DEBUG_HEAP)
|
|
#define LOG_HEAP(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_HEAP, __VA_ARGS__)
|
|
|
|
// Macro-based heap debugging
|
|
#define DEBUG_HEAP_BEFORE auto heapBefore = memGet.getFreeHeap();
|
|
#define DEBUG_HEAP_AFTER(context, ptr) \
|
|
do { \
|
|
auto heapAfter = memGet.getFreeHeap(); \
|
|
if (heapBefore != heapAfter) { \
|
|
LOG_HEAP("Alloc in %s pointer 0x%x, size: %u, free: %u", context, ptr, heapBefore - heapAfter, heapAfter); \
|
|
} \
|
|
} while (0)
|
|
|
|
#else
|
|
#define LOG_HEAP(...)
|
|
#define DEBUG_HEAP_BEFORE
|
|
#define DEBUG_HEAP_AFTER(context, ptr)
|
|
#endif
|
|
|
|
/// A C wrapper for LOG_DEBUG that can be used from arduino C libs that don't know about C++ or meshtastic
|
|
extern "C" void logLegacy(const char *level, const char *fmt, ...);
|
|
|
|
#define SYSLOG_NILVALUE "-"
|
|
|
|
#define SYSLOG_CRIT 2 /* critical conditions */
|
|
#define SYSLOG_ERR 3 /* error conditions */
|
|
#define SYSLOG_WARN 4 /* warning conditions */
|
|
#define SYSLOG_INFO 6 /* informational */
|
|
#define SYSLOG_DEBUG 7 /* debug-level messages */
|
|
// trace does not go out to syslog (yet?)
|
|
|
|
#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
|
/* extract priority */
|
|
#define LOG_PRI(p) ((p)&LOG_PRIMASK)
|
|
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
|
|
|
|
/* facility codes */
|
|
#define LOGLEVEL_KERN (0 << 3) /* kernel messages */
|
|
#define LOGLEVEL_USER (1 << 3) /* random user-level messages */
|
|
#define LOGLEVEL_MAIL (2 << 3) /* mail system */
|
|
#define LOGLEVEL_DAEMON (3 << 3) /* system daemons */
|
|
#define LOGLEVEL_AUTH (4 << 3) /* security/authorization messages */
|
|
#define LOGLEVEL_SYSLOG (5 << 3) /* messages generated internally by syslogd */
|
|
#define LOGLEVEL_LPR (6 << 3) /* line printer subsystem */
|
|
#define LOGLEVEL_NEWS (7 << 3) /* network news subsystem */
|
|
#define LOGLEVEL_UUCP (8 << 3) /* UUCP subsystem */
|
|
#define LOGLEVEL_CRON (9 << 3) /* clock daemon */
|
|
#define LOGLEVEL_AUTHPRIV (10 << 3) /* security/authorization messages (private) */
|
|
#define LOGLEVEL_FTP (11 << 3) /* ftp daemon */
|
|
|
|
/* other codes through 15 reserved for system use */
|
|
#define LOGLEVEL_LOCAL0 (16 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL1 (17 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL2 (18 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL3 (19 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL4 (20 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL5 (21 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL6 (22 << 3) /* reserved for local use */
|
|
#define LOGLEVEL_LOCAL7 (23 << 3) /* reserved for local use */
|
|
|
|
#define LOG_NFACILITIES 24 /* current number of facilities */
|
|
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
|
|
/* facility of pri */
|
|
#define LOG_FAC(p) (((p)&LOG_FACMASK) >> 3)
|
|
|
|
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
|
|
#define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1) /* all priorities through pri */
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// AXP192 (Rev1-specific options)
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#define GPS_POWER_CTRL_CH 3
|
|
#define LORA_POWER_CTRL_CH 2
|
|
|
|
// Default Bluetooth PIN
|
|
#define defaultBLEPin 123456
|
|
|
|
#if HAS_ETHERNET && defined(USE_ARDUINO_ETHERNET)
|
|
#include <Ethernet.h> // arduino-libraries/Ethernet — supports W5500 auto-detect
|
|
#elif HAS_ETHERNET && defined(USE_CH390D)
|
|
#include <ESP32_CH390.h>
|
|
#elif HAS_ETHERNET && !defined(USE_WS5500)
|
|
#include <RAK13800_W5100S.h>
|
|
#endif // HAS_ETHERNET
|
|
|
|
#if HAS_ETHERNET && defined(ARCH_ESP32)
|
|
#include <ETH.h>
|
|
#endif // HAS_ETHERNET
|
|
|
|
#if HAS_WIFI
|
|
#include <WiFi.h>
|
|
#endif // HAS_WIFI
|
|
|
|
#if HAS_NETWORKING
|
|
|
|
namespace meshtastic
|
|
{
|
|
class Syslog
|
|
{
|
|
private:
|
|
UDP *_client;
|
|
IPAddress _ip;
|
|
const char *_server;
|
|
uint16_t _port;
|
|
const char *_deviceHostname;
|
|
const char *_appName;
|
|
uint16_t _priDefault;
|
|
uint8_t _priMask = 0xff;
|
|
bool _enabled = false;
|
|
|
|
bool _sendLog(uint16_t pri, const char *appName, const char *message);
|
|
|
|
public:
|
|
explicit Syslog(UDP &client);
|
|
|
|
Syslog &server(const char *server, uint16_t port);
|
|
Syslog &server(IPAddress ip, uint16_t port);
|
|
Syslog &deviceHostname(const char *deviceHostname);
|
|
Syslog &appName(const char *appName);
|
|
Syslog &defaultPriority(uint16_t pri = LOGLEVEL_KERN);
|
|
Syslog &logMask(uint8_t priMask);
|
|
|
|
void enable();
|
|
void disable();
|
|
bool isEnabled();
|
|
|
|
bool vlogf(uint16_t pri, const char *fmt, va_list args) __attribute__((format(printf, 3, 0)));
|
|
bool vlogf(uint16_t pri, const char *appName, const char *fmt, va_list args) __attribute__((format(printf, 3, 0)));
|
|
};
|
|
|
|
}; // namespace meshtastic
|
|
|
|
#endif // HAS_NETWORKING
|