Compare commits

..
Author SHA1 Message Date
Manuel e112c3e682 Merge branch 'develop' into t-display-s3-pro 2026-05-17 21:23:40 +01:00
ManuelandCopilot f1be5c4ff3 implemented SY6970 lipo charger
Co-authored-by: Copilot <copilot@github.com>
2026-05-17 22:21:34 +02:00
Manuel f6f5bfab80 Merge branch 'develop' into t-display-s3-pro 2026-05-11 10:37:31 +01:00
Manuel 3d6f8a3ace Merge branch 'develop' into t-display-s3-pro 2026-04-02 23:25:05 +02:00
Manuel 201baa892a Merge branch 'develop' into t-display-s3-pro 2026-03-24 21:22:46 +01:00
Manuel 29bfba10c7 Merge branch 'develop' into t-display-s3-pro 2026-03-15 14:12:56 +01:00
Manuel 32e9c828aa touch screen fix 2026-03-08 01:22:28 +01:00
Manuel b2cbe31f27 update hw-id 2026-03-07 17:11:17 +01:00
Manuel cdb97d0c3e Merge branch 'develop' into t-display-s3-pro 2026-03-07 17:04:14 +01:00
Manuel ac81a4f075 co-pilot fixes 2026-03-07 16:53:33 +01:00
Manuel c6db6c5a91 Merge branch 'develop' into t-display-s3-pro 2026-03-06 20:55:53 +01:00
Manuel 8705be7b38 T-Display S3 Pro LR1121 2026-03-06 20:39:04 +01:00
169 changed files with 1106 additions and 1893 deletions
+4 -4
View File
@@ -4,11 +4,11 @@ cli:
plugins: plugins:
sources: sources:
- id: trunk - id: trunk
ref: v1.10.0 ref: v1.9.0
uri: https://github.com/trunk-io/plugins uri: https://github.com/trunk-io/plugins
lint: lint:
enabled: enabled:
- checkov@3.2.529 - checkov@3.2.528
- renovate@43.150.0 - renovate@43.150.0
- prettier@3.8.3 - prettier@3.8.3
- trufflehog@3.95.3 - trufflehog@3.95.3
@@ -16,7 +16,7 @@ lint:
- bandit@1.9.4 - bandit@1.9.4
- trivy@0.70.0 - trivy@0.70.0
- taplo@0.10.0 - taplo@0.10.0
- ruff@0.15.13 - ruff@0.15.12
- isort@8.0.1 - isort@8.0.1
- markdownlint@0.48.0 - markdownlint@0.48.0
- oxipng@10.1.1 - oxipng@10.1.1
@@ -26,7 +26,7 @@ lint:
- hadolint@2.14.0 - hadolint@2.14.0
- shfmt@3.6.0 - shfmt@3.6.0
- shellcheck@0.11.0 - shellcheck@0.11.0
- black@26.5.1 - black@26.3.1
- git-diff-check - git-diff-check
- gitleaks@8.30.1 - gitleaks@8.30.1
- clang-format@16.0.3 - clang-format@16.0.3
+1 -1
View File
@@ -38,4 +38,4 @@ cp bin/device-install.* $OUTDIR/
cp bin/device-update.* $OUTDIR/ cp bin/device-update.* $OUTDIR/
echo "Copying manifest" echo "Copying manifest"
cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json || true
+4 -8
View File
@@ -293,12 +293,9 @@ if ("HAS_TFT", 1) in env.get("CPPDEFINES", []):
board_arch = infer_architecture(env.BoardConfig()) board_arch = infer_architecture(env.BoardConfig())
should_skip_manifest = board_arch is None should_skip_manifest = board_arch is None
# Most platforms can generate the manifest as part of the default 'buildprog' target. # For host/native envs, avoid depending on 'buildprog' (some targets don't define it)
# Typically this passes success/failure properly. mtjson_deps = [] if should_skip_manifest else ["buildprog"]
mtjson_deps = ["buildprog"] if not should_skip_manifest and platform.name == "espressif32":
if platform.name == "espressif32":
# On ESP32, we need to explicitly depend upon the binary to prevent fake-success upon failure.
mtjson_deps = ["$BUILD_DIR/${PROGNAME}.bin"]
# Build littlefs image as part of mtjson target # Build littlefs image as part of mtjson target
# Equivalent to `pio run -t buildfs` # Equivalent to `pio run -t buildfs`
target_lfs = env.DataToBin( target_lfs = env.DataToBin(
@@ -312,8 +309,7 @@ if should_skip_manifest:
env.AddCustomTarget( env.AddCustomTarget(
name="mtjson", name="mtjson",
# For host/native envs, avoid depending on 'buildprog' (some targets don't define it) dependencies=mtjson_deps,
dependencies=[],
actions=[skip_manifest], actions=[skip_manifest],
title="Meshtastic Manifest (skipped)", title="Meshtastic Manifest (skipped)",
description="mtjson generation is skipped for native environments", description="mtjson generation is skipped for native environments",
+1 -1
View File
@@ -7,7 +7,7 @@
"extra_flags": [ "extra_flags": [
"-D CDEBYTE_EORA_S3", "-D CDEBYTE_EORA_S3",
"-D ARDUINO_USB_CDC_ON_BOOT=1", "-D ARDUINO_USB_CDC_ON_BOOT=1",
"-D ARDUINO_USB_MODE=1", "-D ARDUINO_USB_MODE=0",
"-D ARDUINO_RUNNING_CORE=1", "-D ARDUINO_RUNNING_CORE=1",
"-D ARDUINO_EVENT_RUNNING_CORE=1", "-D ARDUINO_EVENT_RUNNING_CORE=1",
"-D BOARD_HAS_PSRAM" "-D BOARD_HAS_PSRAM"
+1 -1
View File
@@ -6,7 +6,7 @@
"core": "esp32", "core": "esp32",
"extra_flags": [ "extra_flags": [
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1",
"-DBOARD_HAS_PSRAM" "-DBOARD_HAS_PSRAM"
+1 -1
View File
@@ -8,7 +8,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -9,7 +9,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -9,7 +9,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -9,7 +9,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -8,7 +8,7 @@
"extra_flags": [ "extra_flags": [
"-DHELTEC_WIRELESS_TRACKER", "-DHELTEC_WIRELESS_TRACKER",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -7,7 +7,7 @@
"core": "esp32", "core": "esp32",
"extra_flags": [ "extra_flags": [
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -8,7 +8,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=0" "-DARDUINO_EVENT_RUNNING_CORE=0"
], ],
+1 -1
View File
@@ -9,7 +9,7 @@
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DLILYGO_TBEAM_1W", "-DLILYGO_TBEAM_1W",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -8,7 +8,7 @@
"extra_flags": [ "extra_flags": [
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+39
View File
@@ -0,0 +1,39 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [["0x303A", "0x1001"]],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": ["wifi", "bluetooth", "lora"],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": ["esp-builtin"],
"openocd_target": "esp32s3.cfg"
},
"frameworks": ["arduino", "espidf"],
"name": "LilyGO T-Display S3 Pro LR1121 (16 MB FLASH, 8 MB PSRAM)",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 921600
},
"url": "https://lilygo.cc/en-de/products/t-display-s3-pro-lr1121",
"vendor": "LilyGO"
}
+1 -1
View File
@@ -8,7 +8,7 @@
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DLILYGO_TBEAM_S3_CORE", "-DLILYGO_TBEAM_S3_CORE",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
+1 -1
View File
@@ -7,7 +7,7 @@
"extra_flags": [ "extra_flags": [
"-DLILYGO_T3S3_V1", "-DLILYGO_T3S3_V1",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1", "-DARDUINO_EVENT_RUNNING_CORE=1",
"-DBOARD_HAS_PSRAM" "-DBOARD_HAS_PSRAM"
+1 -1
View File
@@ -10,7 +10,7 @@
"-DBOARD_HAS_PSRAM", "-DBOARD_HAS_PSRAM",
"-DUNPHONE_SPIN=9", "-DUNPHONE_SPIN=9",
"-DARDUINO_USB_CDC_ON_BOOT=1", "-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1", "-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1", "-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1" "-DARDUINO_EVENT_RUNNING_CORE=1"
], ],
-7
View File
@@ -1,7 +0,0 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x640000,
app1, app, ota_1, 0x650000,0x640000,
spiffs, data, spiffs, 0xc90000,0x360000,
coredump, data, coredump,0xFF0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x640000
5 app1 app ota_1 0x650000 0x640000
6 spiffs data spiffs 0xc90000 0x360000
7 coredump data coredump 0xFF0000 0x10000
-7
View File
@@ -1,7 +0,0 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x330000,
app1, app, ota_1, 0x340000,0x330000,
spiffs, data, spiffs, 0x670000,0x180000,
coredump, data, coredump,0x7F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x330000
5 app1 app ota_1 0x340000 0x330000
6 spiffs data spiffs 0x670000 0x180000
7 coredump data coredump 0x7F0000 0x10000
+14 -3
View File
@@ -70,6 +70,17 @@ def esp32_create_combined_bin(source, target, env):
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)
# Enable Newlib Nano formatting to save space esp32_kind = env.GetProjectOption("custom_esp32_kind")
# ...but allow printf float support (compromise) if esp32_kind == "esp32":
env.Append(LINKFLAGS=["--specs=nano.specs", "-u", "_printf_float"]) # Free up some IRAM by removing auxiliary SPI flash chip drivers.
# Wrapped stub symbols are defined in src/platform/esp32/iram-quirk.c.
env.Append(
LINKFLAGS=[
"-Wl,--wrap=esp_flash_chip_gd",
"-Wl,--wrap=esp_flash_chip_issi",
"-Wl,--wrap=esp_flash_chip_winbond",
]
)
else:
# For newer ESP32 targets, using newlib nano works better.
env.Append(LINKFLAGS=["--specs=nano.specs", "-u", "_printf_float"])
-23
View File
@@ -1,23 +0,0 @@
#!/usr/bin/env python3
# trunk-ignore-all(ruff/F821)
# trunk-ignore-all(flake8/F821): For SConstruct imports
# force linker response file instead of command line arguments
Import("env")
def wrap_with_tempfile(command_key):
command = env.get(command_key)
if not command or not isinstance(command, str):
return
if "TEMPFILE(" in command:
return
env.Replace(**{command_key: "${TEMPFILE('%s')}" % command})
# Force SCons to spill long commands into response files on this target.
env.Replace(MAXLINELENGTH=8192)
for key in ("LINKCOM", "CXXLINKCOM", "SHLINKCOM", "SHCXXLINKCOM"):
wrap_with_tempfile(key)
+2 -2
View File
@@ -2,7 +2,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
default_envs = heltec-v3 default_envs = tbeam
extra_configs = extra_configs =
variants/*/*.ini variants/*/*.ini
@@ -127,7 +127,7 @@ lib_deps =
[device-ui_base] [device-ui_base]
lib_deps = lib_deps =
# renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master # renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master
https://github.com/meshtastic/device-ui/archive/4bf593a82100b911ff816dddf7158ffdee2114cd.zip https://github.com/meshtastic/device-ui/archive/91d4f76d9fc523fb86ea31ebf48fd4bcdaea43c9.zip
; Common libs for environmental measurements in telemetry module ; Common libs for environmental measurements in telemetry module
[environmental_base] [environmental_base]
+3 -2
View File
@@ -158,8 +158,9 @@ extern "C" void logLegacy(const char *level, const char *fmt, ...);
#include <RAK13800_W5100S.h> #include <RAK13800_W5100S.h>
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#if HAS_WIFI #if HAS_WIFI
+1 -1
View File
@@ -277,7 +277,7 @@ void fsInit()
*/ */
void setupSDCard() void setupSDCard()
{ {
#if defined(HAS_SDCARD) && !defined(SDCARD_USE_SOFT_SPI) && !defined(HAS_SD_MMC) #if defined(HAS_SDCARD) && !defined(SDCARD_USE_SOFT_SPI)
concurrency::LockGuard g(spiLock); concurrency::LockGuard g(spiLock);
SDHandler.begin(SPI_SCK, SPI_MISO, SPI_MOSI); SDHandler.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
if (!SD.begin(SDCARD_CS, SDHandler, SD_SPI_FREQUENCY)) { if (!SD.begin(SDCARD_CS, SDHandler, SD_SPI_FREQUENCY)) {
+181 -137
View File
@@ -24,13 +24,6 @@
#include "meshUtils.h" #include "meshUtils.h"
#include "power/PowerHAL.h" #include "power/PowerHAL.h"
#include "sleep.h" #include "sleep.h"
#ifdef ARCH_ESP32
// #include <driver/adc.h>
#include <esp_adc/adc_cali.h>
#include <esp_adc/adc_cali_scheme.h>
#include <esp_adc/adc_oneshot.h>
#include <esp_err.h>
#endif
#if defined(ARCH_PORTDUINO) #if defined(ARCH_PORTDUINO)
#include "api/WiFiServerAPI.h" #include "api/WiFiServerAPI.h"
@@ -70,8 +63,9 @@
#include <WiFi.h> #include <WiFi.h>
#endif #endif
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#endif #endif
@@ -83,86 +77,21 @@
#if defined(BATTERY_PIN) && defined(ARCH_ESP32) #if defined(BATTERY_PIN) && defined(ARCH_ESP32)
#ifndef BAT_MEASURE_ADC_UNIT // ADC1 is default #ifndef BAT_MEASURE_ADC_UNIT // ADC1 is default
static const adc_channel_t adc_channel = ADC_CHANNEL; static const adc1_channel_t adc_channel = ADC_CHANNEL;
static const adc_unit_t unit = ADC_UNIT_1; static const adc_unit_t unit = ADC_UNIT_1;
#else // ADC2 #else // ADC2
static const adc_channel_t adc_channel = ADC_CHANNEL; static const adc2_channel_t adc_channel = ADC_CHANNEL;
static const adc_unit_t unit = ADC_UNIT_2; static const adc_unit_t unit = ADC_UNIT_2;
RTC_NOINIT_ATTR uint64_t RTC_reg_b;
#endif // BAT_MEASURE_ADC_UNIT #endif // BAT_MEASURE_ADC_UNIT
static adc_oneshot_unit_handle_t adc_handle = nullptr; esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t));
static adc_cali_handle_t adc_cali_handle = nullptr;
static bool adc_calibrated = false;
#ifndef ADC_ATTENUATION #ifndef ADC_ATTENUATION
static const adc_atten_t atten = ADC_ATTEN_DB_12; static const adc_atten_t atten = ADC_ATTEN_DB_12;
#else #else
static const adc_atten_t atten = ADC_ATTENUATION; static const adc_atten_t atten = ADC_ATTENUATION;
#endif #endif
#ifdef ADC_BITWIDTH
static const adc_bitwidth_t adc_width = ADC_BITWIDTH;
#else
static const adc_bitwidth_t adc_width = ADC_BITWIDTH_DEFAULT;
#endif
static int adcBitWidthToBits(adc_bitwidth_t width)
{
switch (width) {
case ADC_BITWIDTH_9:
return 9;
case ADC_BITWIDTH_10:
return 10;
case ADC_BITWIDTH_11:
return 11;
case ADC_BITWIDTH_12:
return 12;
#ifdef ADC_BITWIDTH_13
case ADC_BITWIDTH_13:
return 13;
#endif
default:
return 12;
}
}
static bool initAdcCalibration()
{
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
adc_cali_curve_fitting_config_t cali_config = {
.unit_id = unit,
.atten = atten,
.bitwidth = adc_width,
};
esp_err_t ret = adc_cali_create_scheme_curve_fitting(&cali_config, &adc_cali_handle);
if (ret == ESP_OK) {
LOG_INFO("ADC calibration: curve fitting enabled");
return true;
}
if (ret != ESP_ERR_NOT_SUPPORTED) {
LOG_WARN("ADC calibration: curve fitting failed: %s", esp_err_to_name(ret));
}
#endif
#if ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
adc_cali_line_fitting_config_t cali_config = {
.unit_id = unit,
.atten = atten,
.bitwidth = adc_width,
.default_vref = DEFAULT_VREF,
};
esp_err_t ret = adc_cali_create_scheme_line_fitting(&cali_config, &adc_cali_handle);
if (ret == ESP_OK) {
LOG_INFO("ADC calibration: line fitting enabled");
return true;
}
if (ret != ESP_ERR_NOT_SUPPORTED) {
LOG_WARN("ADC calibration: line fitting failed: %s", esp_err_to_name(ret));
}
#endif
LOG_INFO("ADC calibration not supported; using approximate scaling");
return false;
}
#endif // BATTERY_PIN && ARCH_ESP32 #endif // BATTERY_PIN && ARCH_ESP32
#ifdef EXT_PWR_DETECT #ifdef EXT_PWR_DETECT
@@ -247,6 +176,12 @@ XPowersPPM *PPM = NULL;
#include "bq27220.h" #include "bq27220.h"
#endif #endif
#ifdef HAS_SY6970
#include "hardware/Arduino_HWIIC.h"
#include "power_chip/Arduino_SY6970.h"
Arduino_SY6970 *SY6970 = NULL;
#endif
#ifdef HAS_PMU #ifdef HAS_PMU
XPowersLibInterface *PMU = NULL; XPowersLibInterface *PMU = NULL;
#else #else
@@ -438,20 +373,8 @@ class AnalogBatteryLevel : public HasBatteryLevel
scaled *= operativeAdcMultiplier; scaled *= operativeAdcMultiplier;
#elif defined(ARCH_ESP32) // ADC block for espressif platforms #elif defined(ARCH_ESP32) // ADC block for espressif platforms
raw = espAdcRead(); raw = espAdcRead();
int voltage_mv = 0; scaled = esp_adc_cal_raw_to_voltage(raw, adc_characs);
if (adc_calibrated && adc_cali_handle) { scaled *= operativeAdcMultiplier;
if (adc_cali_raw_to_voltage(adc_cali_handle, raw, &voltage_mv) != ESP_OK) {
LOG_WARN("ADC calibration read failed; using raw value");
voltage_mv = 0;
}
}
if (voltage_mv == 0) {
// Fallback approximate conversion without calibration
const int bits = adcBitWidthToBits(adc_width);
const float max_code = powf(2.0f, bits) - 1.0f;
voltage_mv = (int)((raw / max_code) * DEFAULT_VREF);
}
scaled = voltage_mv * operativeAdcMultiplier;
#else // block for all other platforms #else // block for all other platforms
#ifdef ARCH_NRF52 #ifdef ARCH_NRF52
concurrency::LockGuard saadcGuard(concurrency::nrf52SaadcLock); concurrency::LockGuard saadcGuard(concurrency::nrf52SaadcLock);
@@ -493,22 +416,51 @@ class AnalogBatteryLevel : public HasBatteryLevel
uint32_t raw = 0; uint32_t raw = 0;
uint8_t raw_c = 0; // raw reading counter uint8_t raw_c = 0; // raw reading counter
if (!adc_handle) { #ifndef BAT_MEASURE_ADC_UNIT // ADC1
LOG_ERROR("ADC oneshot handle not initialized");
return 0;
}
for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) { for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) {
int val = 0; int val_ = adc1_get_raw(adc_channel);
esp_err_t err = adc_oneshot_read(adc_handle, adc_channel, &val); if (val_ >= 0) { // save only valid readings
if (err == ESP_OK) { raw += val_;
raw += val;
raw_c++; raw_c++;
}
// delayMicroseconds(100);
}
#else // ADC2
#ifdef CONFIG_IDF_TARGET_ESP32S3 // ESP32S3
// ADC2 wifi bug workaround not required, breaks compile
// On ESP32S3, ADC2 can take turns with Wifi (?)
int32_t adc_buf;
esp_err_t read_result;
// Multiple samples
for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) {
adc_buf = 0;
read_result = -1;
read_result = adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf);
if (read_result == ESP_OK) {
raw += adc_buf;
raw_c++; // Count valid samples
} else { } else {
LOG_DEBUG("ADC read failed: %s", esp_err_to_name(err)); LOG_DEBUG("An attempt to sample ADC2 failed");
} }
} }
#else // Other ESP32
int32_t adc_buf = 0;
for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) {
// ADC2 wifi bug workaround, see
// https://github.com/espressif/arduino-esp32/issues/102
WRITE_PERI_REG(SENS_SAR_READ_CTRL2_REG, RTC_reg_b);
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DATA_INV);
adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf);
raw += adc_buf;
raw_c++;
}
#endif // BAT_MEASURE_ADC_UNIT
#endif // End BAT_MEASURE_ADC_UNIT
return (raw / (raw_c < 1 ? 1 : raw_c)); return (raw / (raw_c < 1 ? 1 : raw_c));
} }
#endif #endif
@@ -720,31 +672,42 @@ bool Power::analogInit()
#ifdef ARCH_STM32WL #ifdef ARCH_STM32WL
analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS); analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS);
#elif defined(ARCH_ESP32) // ESP32 needs special analog stuff #elif defined(ARCH_ESP32) // ESP32 needs special analog stuff
adc_oneshot_unit_init_cfg_t init_config = {
.unit_id = unit,
};
if (!adc_handle) { #ifndef ADC_WIDTH // max resolution by default
esp_err_t err = adc_oneshot_new_unit(&init_config, &adc_handle); static const adc_bits_width_t width = ADC_WIDTH_BIT_12;
if (err != ESP_OK) { #else
LOG_ERROR("ADC oneshot init failed: %s", esp_err_to_name(err)); static const adc_bits_width_t width = ADC_WIDTH;
return false; #endif
} #ifndef BAT_MEASURE_ADC_UNIT // ADC1
adc1_config_width(width);
adc1_config_channel_atten(adc_channel, atten);
#else // ADC2
adc2_config_channel_atten(adc_channel, atten);
#ifndef CONFIG_IDF_TARGET_ESP32S3
// ADC2 wifi bug workaround
// Not required with ESP32S3, breaks compile
RTC_reg_b = READ_PERI_REG(SENS_SAR_READ_CTRL2_REG);
#endif
#endif
// calibrate ADC
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_characs);
// show ADC characterization base
if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) {
LOG_INFO("ADC config based on Two Point values stored in eFuse");
} else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
LOG_INFO("ADC config based on reference voltage stored in eFuse");
} }
#ifdef CONFIG_IDF_TARGET_ESP32S3
adc_oneshot_chan_cfg_t chan_cfg = { // ESP32S3
.atten = atten, else if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP_FIT) {
.bitwidth = adc_width, LOG_INFO("ADC config based on Two Point values and fitting curve "
}; "coefficients stored in eFuse");
esp_err_t err = adc_oneshot_config_channel(adc_handle, adc_channel, &chan_cfg);
if (err != ESP_OK) {
LOG_ERROR("ADC channel config failed: %s", esp_err_to_name(err));
return false;
} }
#endif
adc_calibrated = initAdcCalibration(); else {
#endif // ARCH_ESP32 LOG_INFO("ADC config based on default reference voltage");
}
#endif // ARCH_ESP32
// NRF52 ADC init moved to powerHAL_init in nrf52 platform // NRF52 ADC init moved to powerHAL_init in nrf52 platform
@@ -1634,7 +1597,7 @@ bool Power::cw2015Init()
} }
#endif #endif
#if defined(HAS_PPM) && HAS_PPM #ifdef HAS_PPM
/** /**
* Adapter class for BQ25896/BQ27220 Lipo battery charger. * Adapter class for BQ25896/BQ27220 Lipo battery charger.
@@ -1751,6 +1714,96 @@ class LipoCharger : public HasBatteryLevel
} }
}; };
#elif defined(HAS_SY6970)
/**
* Adapter class for SY6970 battery charger.
*/
class LipoCharger : public HasBatteryLevel
{
public:
/**
* Init the I2C SY6970 Lipo battery charger
*/
bool runOnce()
{
if (SY6970 == nullptr) {
SY6970 = new Arduino_SY6970(std::make_shared<Arduino_HWIIC>(Arduino_HWIIC(SDA, SCL, &Wire)), SY6970_DEVICE_ADDRESS);
bool result = SY6970->begin();
if (result) {
// some boards can boot with HIZ set, which suppresses normal input/battery behavior
result |=
SY6970->IIC_Write_Device_State(Arduino_IIC_Power::POWER_DEVICE_HIZ_MODE, Arduino_IIC_Power::POWER_DEVICE_OFF);
result |= SY6970->IIC_Write_Device_State(Arduino_IIC_Power::POWER_DEVICE_CHARGING_MODE,
Arduino_IIC_Power::POWER_DEVICE_ON);
result |= SY6970->IIC_Write_Device_State(Arduino_IIC_Power::POWER_DEVICE_ADC_MEASURE,
Arduino_IIC_Power::POWER_DEVICE_ON);
// clear watchdog timer once, then keep watchdog disabled
result |= SY6970->IIC_Write_Device_State(Arduino_IIC_Power::POWER_DEVICE_WATCHDOG_TIMER_RESET,
Arduino_IIC_Power::POWER_DEVICE_ON);
if (result) {
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_WATCHDOG_TIMER, 0);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_CHARGING_TARGET_VOLTAGE_LIMIT, 4284);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_MINIMUM_SYSTEM_VOLTAGE_LIMIT, 3300);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_INPUT_CURRENT_LIMIT, 500);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_FAST_CHARGING_CURRENT_LIMIT, 2112);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_PRECHARGE_CHARGING_CURRENT_LIMIT, 192);
SY6970->IIC_Write_Device_Value(Arduino_IIC_Power::POWER_DEVICE_TERMINATION_CHARGING_CURRENT_LIMIT, 320);
LOG_INFO("SY6970 init succeeded");
return true;
}
}
LOG_WARN("SY6970 init failed");
delete SY6970;
SY6970 = nullptr;
return false;
}
return true;
}
/**
* Battery state of charge, from 0 to 100 or -1 for unknown
*/
virtual int getBatteryPercent() override { return -1; }
/**
* The raw voltage of the battery in millivolts, or NAN if unknown
*/
virtual uint16_t getBattVoltage() override
{
double battVoltage = SY6970->IIC_Read_Device_Value(Arduino_IIC_Power::POWER_BATTERY_VOLTAGE);
return (battVoltage > 0.0) ? static_cast<uint16_t>(battVoltage) : 0;
}
/**
* return true if there is a battery installed in this unit
*/
virtual bool isBatteryConnect() override { return true; }
/**
* return true if there is an external power source detected
*/
virtual bool isVbusIn() override { return SY6970->IIC_Read_Device_Value(Arduino_IIC_Power::POWER_SYSTEM_VOLTAGE) > 4200.0; }
/**
* return true if the battery is currently charging
*/
virtual bool isCharging() override { return SY6970->IIC_Read_Device_Value(Arduino_IIC_Power::POWER_CHARGING_CURRENT) > 1.0; }
};
#else
/**
* The Lipo battery level sensor is unavailable - default to AnalogBatteryLevel
*/
bool Power::lipoChargerInit()
{
return false;
}
#endif
#if defined(HAS_PPM) || defined(HAS_SY6970)
LipoCharger lipoCharger; LipoCharger lipoCharger;
/** /**
@@ -1759,21 +1812,12 @@ LipoCharger lipoCharger;
bool Power::lipoChargerInit() bool Power::lipoChargerInit()
{ {
bool result = lipoCharger.runOnce(); bool result = lipoCharger.runOnce();
LOG_DEBUG("Power::lipoChargerInit lipo sensor is %s", result ? "ready" : "not ready yet"); LOG_DEBUG("Power::lipoChargerInit lipo charger is %s", result ? "ready" : "not ready yet");
if (!result) if (!result)
return false; return false;
batteryLevel = &lipoCharger; batteryLevel = &lipoCharger;
return true; return true;
} }
#else
/**
* The Lipo battery level sensor is unavailable - default to AnalogBatteryLevel
*/
bool Power::lipoChargerInit()
{
return false;
}
#endif #endif
#ifdef HELTEC_MESH_SOLAR #ifdef HELTEC_MESH_SOLAR
+1 -4
View File
@@ -274,6 +274,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define LTR553ALS_ADDR 0x23 #define LTR553ALS_ADDR 0x23
#define SEN5X_ADDR 0x69 #define SEN5X_ADDR 0x69
#define SCD30_ADDR 0x61 #define SCD30_ADDR 0x61
#define SY6970_ADDR 0x6A // same address as LSM6DS3
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ACCELEROMETER // ACCELEROMETER
@@ -561,9 +562,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HAS_SCREEN 0 #define HAS_SCREEN 0
#endif #endif
#ifndef USE_ETHERNET_DEFAULT
#define USE_ETHERNET_DEFAULT 0
#endif
#include "DebugConfiguration.h" #include "DebugConfiguration.h"
#include "RF95Configuration.h" #include "RF95Configuration.h"
+1
View File
@@ -97,6 +97,7 @@ class ScanI2C
CW2015, CW2015,
SCD30, SCD30,
ADS1115, ADS1115,
SY6970
} DeviceType; } DeviceType;
// typedef uint8_t DeviceAddress; // typedef uint8_t DeviceAddress;
+17 -1
View File
@@ -607,7 +607,23 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
break; break;
SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3", (uint8_t)addr.address); case LSM6DS3_ADDR: {
// 1) Try SY6970 signature first: REG14[5:3] == 0b001
uint8_t registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x14), 1);
if (((registerValue >> 3) & 0x07) == 0x01) {
type = SY6970;
logFoundDevice("SY6970", (uint8_t)addr.address);
break;
}
// 2) Fallback to LSM6DS3 signature: WHO_AM_I == 0x6A
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1);
if (registerValue == 0x6A) {
type = LSM6DS3;
logFoundDevice("LSM6DS3", (uint8_t)addr.address);
}
break;
}
SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700", (uint8_t)addr.address); SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700", (uint8_t)addr.address);
case TCA9555_ADDR: case TCA9555_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x01), 1); registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x01), 1);
+3 -8
View File
@@ -425,11 +425,6 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
#elif defined(USE_SSD1306) #elif defined(USE_SSD1306)
dispdev = new SSD1306Wire(address.address, -1, -1, geometry, dispdev = new SSD1306Wire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE); (address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
#if defined(OLED_Y_OFFSET_PAGES)
// Panels whose active window does not start at GDDRAM row 0 (e.g. 72x40
// modules on pages 3..7) need a fixed vertical page shift on every write.
static_cast<SSD1306Wire *>(dispdev)->setYOffset(OLED_Y_OFFSET_PAGES);
#endif
#elif defined(USE_SPISSD1306) #elif defined(USE_SPISSD1306)
dispdev = new SSD1306Spi(SSD1306_RESET, SSD1306_RS, SSD1306_NSS, GEOMETRY_64_48); dispdev = new SSD1306Spi(SSD1306_RESET, SSD1306_RS, SSD1306_NSS, GEOMETRY_64_48);
if (!dispdev->init()) { if (!dispdev->init()) {
@@ -915,7 +910,7 @@ int32_t Screen::runOnce()
#ifndef DISABLE_WELCOME_UNSET #ifndef DISABLE_WELCOME_UNSET
if (!NotificationRenderer::isOverlayBannerShowing() && config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET) { if (!NotificationRenderer::isOverlayBannerShowing() && config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
menuHandler::LoraRegionPicker(); menuHandler::LoraRegionPicker();
#else #else
menuHandler::OnboardMessage(); menuHandler::OnboardMessage();
@@ -1152,7 +1147,7 @@ void Screen::setFrames(FrameFocus focus)
#if defined(DISPLAY_CLOCK_FRAME) #if defined(DISPLAY_CLOCK_FRAME)
if (!hiddenFrames.clock) { if (!hiddenFrames.clock) {
fsi.positions.clock = numframes; fsi.positions.clock = numframes;
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
normalFrames[numframes++] = graphics::ClockRenderer::drawAnalogClockFrame; normalFrames[numframes++] = graphics::ClockRenderer::drawAnalogClockFrame;
#else #else
normalFrames[numframes++] = uiconfig.is_clockface_analog ? graphics::ClockRenderer::drawAnalogClockFrame normalFrames[numframes++] = uiconfig.is_clockface_analog ? graphics::ClockRenderer::drawAnalogClockFrame
@@ -1611,7 +1606,7 @@ void Screen::showFrame(FrameDirection direction)
void Screen::setFastFramerate() void Screen::setFastFramerate()
{ {
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
dispdev->clear(); dispdev->clear();
#if GRAPHICS_TFT_COLORING_ENABLED #if GRAPHICS_TFT_COLORING_ENABLED
prepareFrameColorRegions(); prepareFrameColorRegions();
+1 -1
View File
@@ -106,7 +106,7 @@
#define FONT_SMALL FONT_MEDIUM_LOCAL // Height: 19 #define FONT_SMALL FONT_MEDIUM_LOCAL // Height: 19
#define FONT_MEDIUM FONT_LARGE_LOCAL // Height: 28 #define FONT_MEDIUM FONT_LARGE_LOCAL // Height: 28
#define FONT_LARGE FONT_LARGE_LOCAL // Height: 28 #define FONT_LARGE FONT_LARGE_LOCAL // Height: 28
#elif defined(OLED_TINY) #elif defined(M5STACK_UNITC6L)
#define FONT_SMALL FONT_SMALL_LOCAL // Height: 13 #define FONT_SMALL FONT_SMALL_LOCAL // Height: 13
#define FONT_MEDIUM FONT_SMALL_LOCAL // Height: 13 #define FONT_MEDIUM FONT_SMALL_LOCAL // Height: 13
#define FONT_LARGE FONT_SMALL_LOCAL // Height: 13 #define FONT_LARGE FONT_SMALL_LOCAL // Height: 13
+1 -7
View File
@@ -31,12 +31,6 @@ ScreenResolution determineScreenResolution(int16_t screenheight, int16_t screenw
return ScreenResolution::UltraLow; return ScreenResolution::UltraLow;
} }
#ifdef DISPLAY_FORCE_SMALL_FONTS
if (screenwidth <= 160 && screenheight <= 80) {
return ScreenResolution::Low;
}
#endif
// Standard OLED screens // Standard OLED screens
if (screenwidth > 128 && screenheight <= 64) { if (screenwidth > 128 && screenheight <= 64) {
return ScreenResolution::Low; return ScreenResolution::Low;
@@ -246,7 +240,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
int batteryX = 1; int batteryX = 1;
int batteryY = HEADER_OFFSET_Y + 1; int batteryY = HEADER_OFFSET_Y + 1;
#if !defined(OLED_TINY) #if !defined(M5STACK_UNITC6L)
// === Battery Icons === // === Battery Icons ===
if (usbPowered && !isCharging) { // This is a basic check to determine USB Powered is flagged but not charging if (usbPowered && !isCharging) { // This is a basic check to determine USB Powered is flagged but not charging
batteryX += 1; batteryX += 1;
+1 -1
View File
@@ -1606,7 +1606,7 @@ bool TFTDisplay::connect()
attachInterrupt(digitalPinToInterrupt(SCREEN_TOUCH_INT), rak14014_tpIntHandle, FALLING); attachInterrupt(digitalPinToInterrupt(SCREEN_TOUCH_INT), rak14014_tpIntHandle, FALLING);
#elif defined(T_DECK) || defined(PICOMPUTER_S3) || defined(CHATTER_2) || defined(HELTEC_MESH_NODE_T096) #elif defined(T_DECK) || defined(PICOMPUTER_S3) || defined(CHATTER_2) || defined(HELTEC_MESH_NODE_T096)
tft->setRotation(1); // T-Deck has the TFT in landscape tft->setRotation(1); // T-Deck has the TFT in landscape
#elif defined(T_WATCH_S3) #elif defined(T_WATCH_S3) || defined(T_DISPLAY_S3_PRO)
tft->setRotation(2); // T-Watch S3 left-handed orientation tft->setRotation(2); // T-Watch S3 left-handed orientation
#elif ARCH_PORTDUINO || defined(SENSECAP_INDICATOR) || defined(T_LORA_PAGER) #elif ARCH_PORTDUINO || defined(SENSECAP_INDICATOR) || defined(T_LORA_PAGER)
tft->setRotation(0); // use config.yaml to set rotation tft->setRotation(0); // use config.yaml to set rotation
+2 -2
View File
@@ -460,7 +460,7 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
nameX = (SCREEN_WIDTH - textWidth) / 2; nameX = (SCREEN_WIDTH - textWidth) / 2;
display->drawString(nameX, getTextPositions(display)[line++], frequencyslot); display->drawString(nameX, getTextPositions(display)[line++], frequencyslot);
#if !defined(OLED_TINY) #if !defined(M5STACK_UNITC6L)
// === Fifth Row: Channel Utilization === // === Fifth Row: Channel Utilization ===
const char *chUtil = "ChUtil:"; const char *chUtil = "ChUtil:";
char chUtilPercentage[10]; char chUtilPercentage[10];
@@ -592,7 +592,7 @@ void drawSystemScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x
// Label // Label
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(labelX, getTextPositions(display)[line], label); display->drawString(labelX, getTextPositions(display)[line], label);
#if !defined(OLED_TINY) #if !defined(M5STACK_UNITC6L)
// Bar // Bar
int barY = getTextPositions(display)[line] + (FONT_HEIGHT_SMALL - barHeight) / 2; int barY = getTextPositions(display)[line] + (FONT_HEIGHT_SMALL - barHeight) / 2;
display->setColor(WHITE); display->setColor(WHITE);
+1 -1
View File
@@ -555,7 +555,7 @@ void menuHandler::TZPicker()
void menuHandler::clockMenu() void menuHandler::clockMenu()
{ {
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
static const char *optionsArray[] = {"Back", "Time Format", "Timezone"}; static const char *optionsArray[] = {"Back", "Time Format", "Timezone"};
#else #else
static const char *optionsArray[] = {"Back", "Clock Face", "Time Format", "Timezone"}; static const char *optionsArray[] = {"Back", "Clock Face", "Time Format", "Timezone"};
+4 -4
View File
@@ -26,7 +26,7 @@ extern bool haveGlyphs(const char *str);
// Global screen instance // Global screen instance
extern graphics::Screen *screen; extern graphics::Screen *screen;
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
static uint32_t lastSwitchTime = 0; static uint32_t lastSwitchTime = 0;
#endif #endif
namespace graphics namespace graphics
@@ -788,7 +788,7 @@ void drawDynamicListScreen_Nodes(OLEDDisplay *display, OLEDDisplayUiState *state
unsigned long now = millis(); unsigned long now = millis();
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
display->clear(); display->clear();
if (now - lastSwitchTime >= 3000) { if (now - lastSwitchTime >= 3000) {
display->display(); display->display();
@@ -824,7 +824,7 @@ void drawDynamicListScreen_Location(OLEDDisplay *display, OLEDDisplayUiState *st
unsigned long now = millis(); unsigned long now = millis();
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
display->clear(); display->clear();
if (now - lastSwitchTime >= 3000) { if (now - lastSwitchTime >= 3000) {
display->display(); display->display();
@@ -894,7 +894,7 @@ void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state,
double lat = DegD(ourSelfPos.latitude_i); double lat = DegD(ourSelfPos.latitude_i);
double lon = DegD(ourSelfPos.longitude_i); double lon = DegD(ourSelfPos.longitude_i);
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
display->clear(); display->clear();
uint32_t now = millis(); uint32_t now = millis();
if (now - lastSwitchTime >= 2000) { if (now - lastSwitchTime >= 2000) {
+1 -1
View File
@@ -728,7 +728,7 @@ void NotificationRenderer::drawNotificationBox(OLEDDisplay *display, OLEDDisplay
} }
int16_t boxTop = (display->height() / 2) - (boxHeight / 2); int16_t boxTop = (display->height() / 2) - (boxHeight / 2);
boxHeight += (currentResolution == ScreenResolution::High) ? 2 : 1; boxHeight += (currentResolution == ScreenResolution::High) ? 2 : 1;
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
if (visibleTotalLines == 1) { if (visibleTotalLines == 1) {
boxTop += 25; boxTop += 25;
} }
+6 -6
View File
@@ -25,7 +25,7 @@
// External variables // External variables
extern graphics::Screen *screen; extern graphics::Screen *screen;
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
static uint32_t lastSwitchTime = 0; static uint32_t lastSwitchTime = 0;
#endif #endif
namespace graphics namespace graphics
@@ -753,7 +753,7 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat
if (!node || node->num == nodeDB->getNodeNum() || !nodeInfoLiteIsFavorite(node)) if (!node || node->num == nodeDB->getNodeNum() || !nodeInfoLiteIsFavorite(node))
return; return;
display->clear(); display->clear();
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
uint32_t now = millis(); uint32_t now = millis();
if (now - lastSwitchTime >= 10000) // 10000 ms = 10 秒 if (now - lastSwitchTime >= 10000) // 10000 ms = 10 秒
{ {
@@ -959,7 +959,7 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat
if (seenStr[0]) { if (seenStr[0]) {
display->drawString(x, getTextPositions(display)[line++], seenStr); display->drawString(x, getTextPositions(display)[line++], seenStr);
} }
#if !defined(OLED_TINY) #if !defined(M5STACK_UNITC6L)
// === 4. Uptime (only show if metric is present) === // === 4. Uptime (only show if metric is present) ===
char uptimeStr[32] = ""; char uptimeStr[32] = "";
meshtastic_DeviceMetrics nodeMetrics; meshtastic_DeviceMetrics nodeMetrics;
@@ -1172,7 +1172,7 @@ void UIRenderer::drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *sta
} }
#endif #endif
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
line += 1; line += 1;
// === Node Identity === // === Node Identity ===
@@ -1456,7 +1456,7 @@ void UIRenderer::drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLED
// needs to be drawn relative to x and y // needs to be drawn relative to x and y
// draw centered icon left to right and centered above the one line of app text // draw centered icon left to right and centered above the one line of app text
#if defined(OLED_TINY) #if defined(M5STACK_UNITC6L)
display->drawXbm(x + (SCREEN_WIDTH - 50) / 2, y + (SCREEN_HEIGHT - 28) / 2, icon_width, icon_height, icon_bits); display->drawXbm(x + (SCREEN_WIDTH - 50) / 2, y + (SCREEN_HEIGHT - 28) / 2, icon_width, icon_height, icon_bits);
if (gBootSplashBoldPass) { if (gBootSplashBoldPass) {
display->drawXbm(x + (SCREEN_WIDTH - 50) / 2 + 1, y + (SCREEN_HEIGHT - 28) / 2, icon_width, icon_height, icon_bits); display->drawXbm(x + (SCREEN_WIDTH - 50) / 2 + 1, y + (SCREEN_HEIGHT - 28) / 2, icon_width, icon_height, icon_bits);
@@ -1666,7 +1666,7 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
} }
display->drawString(x, textPos[line++], altitudeLine); display->drawString(x, textPos[line++], altitudeLine);
} }
#if !defined(OLED_TINY) #if !defined(M5STACK_UNITC6L)
// === Draw Compass === // === Draw Compass ===
if (validHeading || statusLine1) { if (validHeading || statusLine1) {
// --- Compass Rendering: landscape (wide) screens use original side-aligned logic --- // --- Compass Rendering: landscape (wide) screens use original side-aligned logic ---
+1 -1
View File
@@ -318,7 +318,7 @@ const uint8_t chirpy_small[] = {0x7f, 0x41, 0x55, 0x55, 0x55, 0x55, 0x41, 0x7f};
#define connection_icon_height 5 #define connection_icon_height 5
const uint8_t connection_icon[] = {0x36, 0x41, 0x5D, 0x41, 0x36}; const uint8_t connection_icon[] = {0x36, 0x41, 0x5D, 0x41, 0x36};
#ifdef OLED_TINY #ifdef M5STACK_UNITC6L
#include "img/icon_small.xbm" #include "img/icon_small.xbm"
#else #else
#include "img/icon.xbm" #include "img/icon.xbm"
+4 -5
View File
@@ -53,11 +53,10 @@ void InkHUD::MessageStore::saveToFlash()
f.write(reinterpret_cast<const uint8_t *>(&m.timestamp), sizeof(m.timestamp)); // Write timestamp. 4 bytes f.write(reinterpret_cast<const uint8_t *>(&m.timestamp), sizeof(m.timestamp)); // Write timestamp. 4 bytes
f.write(reinterpret_cast<const uint8_t *>(&m.sender), sizeof(m.sender)); // Write sender NodeId. 4 Bytes f.write(reinterpret_cast<const uint8_t *>(&m.sender), sizeof(m.sender)); // Write sender NodeId. 4 Bytes
f.write(reinterpret_cast<const uint8_t *>(&m.channelIndex), sizeof(m.channelIndex)); // Write channel index. 1 Byte f.write(reinterpret_cast<const uint8_t *>(&m.channelIndex), sizeof(m.channelIndex)); // Write channel index. 1 Byte
f.write(reinterpret_cast<const uint8_t *>(m.text.c_str()), f.write(reinterpret_cast<const uint8_t *>(m.text.c_str()), min(MAX_MESSAGE_SIZE, m.text.size())); // Write message text
min((size_t)MAX_MESSAGE_SIZE, m.text.size())); // Write message text f.write('\0'); // Append null term
f.write('\0'); // Append null term LOG_DEBUG("Wrote message %u, length %u, text \"%s\"", static_cast<uint32_t>(i), min(MAX_MESSAGE_SIZE, m.text.size()),
LOG_DEBUG("Wrote message %u, length %u, text \"%s\"", static_cast<uint32_t>(i), m.text.c_str());
min((size_t)MAX_MESSAGE_SIZE, m.text.size()), m.text.c_str());
} }
// Release firmware's SPI lock, because SafeFile::close needs it // Release firmware's SPI lock, because SafeFile::close needs it
-2
View File
@@ -13,8 +13,6 @@
#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE #ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE
// REVISIT esp_adc_cal.h
// "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h"
#include <esp_adc_cal.h> #include <esp_adc_cal.h>
#include <soc/adc_channel.h> #include <soc/adc_channel.h>
+2 -2
View File
@@ -68,7 +68,7 @@ TLoraPagerKeyboard::TLoraPagerKeyboard()
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(UINT8_MAX), : TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(UINT8_MAX),
next_key(UINT8_MAX), last_tap(0L), char_idx(0), tap_interval(0) next_key(UINT8_MAX), last_tap(0L), char_idx(0), tap_interval(0)
{ {
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
ledcAttach(KB_BL_PIN, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH); ledcAttach(KB_BL_PIN, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH);
#else #else
ledcSetup(LEDC_BACKLIGHT_CHANNEL, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH); ledcSetup(LEDC_BACKLIGHT_CHANNEL, LEDC_BACKLIGHT_FREQ, LEDC_BACKLIGHT_BIT_WIDTH);
@@ -108,7 +108,7 @@ void TLoraPagerKeyboard::setBacklight(bool on)
uint32_t _brightness = 0; uint32_t _brightness = 0;
if (on) if (on)
_brightness = brightness; _brightness = brightness;
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
ledcWrite(KB_BL_PIN, _brightness); ledcWrite(KB_BL_PIN, _brightness);
#else #else
ledcWrite(LEDC_BACKLIGHT_CHANNEL, _brightness); ledcWrite(LEDC_BACKLIGHT_CHANNEL, _brightness);
-5
View File
@@ -753,11 +753,6 @@ void setup()
} }
} }
#endif #endif
#ifdef OLED_GEOMETRY_OVERRIDE
// Per-variant geometry (e.g. 72x40 micro-OLEDs). Takes precedence over the
// default GEOMETRY_128_64 set at the top of setup().
screen_geometry = OLED_GEOMETRY_OVERRIDE;
#endif
#endif #endif
#if !MESHTASTIC_EXCLUDE_I2C #if !MESHTASTIC_EXCLUDE_I2C
+3 -8
View File
@@ -927,7 +927,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32); strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32);
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR) || \ #if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR) || \
defined(ELECROW_PANEL) || defined(HELTEC_V4_TFT) || defined(HELTEC_V4_R8_TFT)) && \ defined(ELECROW_PANEL) || defined(HELTEC_V4_TFT) || defined(HELTEC_V4_R8_TFT) || defined(T_DISPLAY_S3_PRO)) && \
HAS_TFT HAS_TFT
// switch BT off by default; use TFT programming mode or hotkey to enable // switch BT off by default; use TFT programming mode or hotkey to enable
config.bluetooth.enabled = false; config.bluetooth.enabled = false;
@@ -985,10 +985,6 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
config.network.wifi_enabled = USERPREFS_NETWORK_WIFI_ENABLED; config.network.wifi_enabled = USERPREFS_NETWORK_WIFI_ENABLED;
#endif #endif
#if USE_ETHERNET_DEFAULT
config.network.eth_enabled = true;
#endif
#ifdef USERPREFS_NETWORK_WIFI_SSID #ifdef USERPREFS_NETWORK_WIFI_SSID
strncpy(config.network.wifi_ssid, USERPREFS_NETWORK_WIFI_SSID, sizeof(config.network.wifi_ssid)); strncpy(config.network.wifi_ssid, USERPREFS_NETWORK_WIFI_SSID, sizeof(config.network.wifi_ssid));
#endif #endif
@@ -1071,8 +1067,7 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.has_store_forward = true; moduleConfig.has_store_forward = true;
moduleConfig.has_telemetry = true; moduleConfig.has_telemetry = true;
moduleConfig.has_external_notification = true; moduleConfig.has_external_notification = true;
#if defined(PIN_BUZZER) || defined(PIN_VIBRATION) || defined(LED_NOTIFICATION) || defined(PCA_LED_NOTIFICATION) || \ #if defined(PIN_BUZZER) || defined(PIN_VIBRATION) || defined(LED_NOTIFICATION) || defined(PCA_LED_NOTIFICATION)
defined(NEOPIXEL_STATUS_NOTIFICATION_PIN)
moduleConfig.external_notification.enabled = true; moduleConfig.external_notification.enabled = true;
#endif #endif
#if defined(PIN_BUZZER) #if defined(PIN_BUZZER)
@@ -1093,7 +1088,7 @@ void NodeDB::installDefaultModuleConfig()
#endif #endif
#if defined(PIN_VIBRATION) #if defined(PIN_VIBRATION)
moduleConfig.external_notification.nag_timeout = 2; moduleConfig.external_notification.nag_timeout = 2;
#elif defined(PIN_BUZZER) || defined(LED_NOTIFICATION) || defined(NEOPIXEL_STATUS_NOTIFICATION_PIN) #elif defined(PIN_BUZZER) || defined(LED_NOTIFICATION)
moduleConfig.external_notification.nag_timeout = default_ringtone_nag_secs; moduleConfig.external_notification.nag_timeout = default_ringtone_nag_secs;
#endif #endif
+3 -2
View File
@@ -3,8 +3,9 @@
#include "ServerAPI.h" #include "ServerAPI.h"
#include <WiFi.h> #include <WiFi.h>
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
/** /**
+3 -5
View File
@@ -198,9 +198,7 @@ typedef enum _meshtastic_Config_DisplayConfig_OledType {
/* Can not be auto detected but set by proto. Used for 128x64 screens */ /* Can not be auto detected but set by proto. Used for 128x64 screens */
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 = 3, meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 = 3,
/* Can not be auto detected but set by proto. Used for 128x128 screens */ /* Can not be auto detected but set by proto. Used for 128x128 screens */
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_128 = 4, meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_128 = 4
/* Can not be auto detected but set by proto. Used for 64x128 rotated screens */
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_ROTATED = 5
} meshtastic_Config_DisplayConfig_OledType; } meshtastic_Config_DisplayConfig_OledType;
typedef enum _meshtastic_Config_DisplayConfig_DisplayMode { typedef enum _meshtastic_Config_DisplayConfig_DisplayMode {
@@ -722,8 +720,8 @@ extern "C" {
#define _meshtastic_Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((meshtastic_Config_DisplayConfig_DisplayUnits)(meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL+1)) #define _meshtastic_Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((meshtastic_Config_DisplayConfig_DisplayUnits)(meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL+1))
#define _meshtastic_Config_DisplayConfig_OledType_MIN meshtastic_Config_DisplayConfig_OledType_OLED_AUTO #define _meshtastic_Config_DisplayConfig_OledType_MIN meshtastic_Config_DisplayConfig_OledType_OLED_AUTO
#define _meshtastic_Config_DisplayConfig_OledType_MAX meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_ROTATED #define _meshtastic_Config_DisplayConfig_OledType_MAX meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_128
#define _meshtastic_Config_DisplayConfig_OledType_ARRAYSIZE ((meshtastic_Config_DisplayConfig_OledType)(meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_ROTATED+1)) #define _meshtastic_Config_DisplayConfig_OledType_ARRAYSIZE ((meshtastic_Config_DisplayConfig_OledType)(meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_128+1))
#define _meshtastic_Config_DisplayConfig_DisplayMode_MIN meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT #define _meshtastic_Config_DisplayConfig_DisplayMode_MIN meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT
#define _meshtastic_Config_DisplayConfig_DisplayMode_MAX meshtastic_Config_DisplayConfig_DisplayMode_COLOR #define _meshtastic_Config_DisplayConfig_DisplayMode_MAX meshtastic_Config_DisplayConfig_DisplayMode_COLOR
-4
View File
@@ -321,10 +321,6 @@ typedef enum _meshtastic_HardwareModel {
meshtastic_HardwareModel_HELTEC_MESH_NODE_T1 = 133, meshtastic_HardwareModel_HELTEC_MESH_NODE_T1 = 133,
/* B&Q Consulting Station G3: TBD */ /* B&Q Consulting Station G3: TBD */
meshtastic_HardwareModel_STATION_G3 = 134, meshtastic_HardwareModel_STATION_G3 = 134,
/* Lilygo T-Impulse-Plus */
meshtastic_HardwareModel_T_IMPULSE_PLUS = 135,
/* Lilygo T-Echo Card */
meshtastic_HardwareModel_T_ECHO_CARD = 136,
/* ------------------------------------------------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------------------------------------------------
Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits.
------------------------------------------------------------------------------------------------------------------------------------------ */ ------------------------------------------------------------------------------------------------------------------------------------------ */
@@ -144,7 +144,7 @@ typedef struct _meshtastic_ModuleConfig_MQTTConfig {
(the default official mqtt.meshtastic.org server can handle encrypted packets) (the default official mqtt.meshtastic.org server can handle encrypted packets)
Decrypted packets may be useful for external systems that want to consume meshtastic packets */ Decrypted packets may be useful for external systems that want to consume meshtastic packets */
bool encryption_enabled; bool encryption_enabled;
/* Deprecated: JSON packet support on MQTT was removed, and this field is ignored. */ /* Whether to send / consume json packets on MQTT */
bool json_enabled; bool json_enabled;
/* If true, we attempt to establish a secure connection using TLS */ /* If true, we attempt to establish a secure connection using TLS */
bool tls_enabled; bool tls_enabled;
+3 -2
View File
@@ -13,8 +13,9 @@
#include <WebServer.h> #include <WebServer.h>
#include <WiFi.h> #include <WiFi.h>
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
+3 -2
View File
@@ -12,8 +12,9 @@
#include <AsyncUDP.h> #include <AsyncUDP.h>
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server #define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server
+3 -2
View File
@@ -10,8 +10,9 @@
#include "target_specific.h" #include "target_specific.h"
#include <WiFi.h> #include <WiFi.h>
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#if HAS_ETHERNET && defined(USE_CH390D) #if HAS_ETHERNET && defined(USE_CH390D)
+3 -2
View File
@@ -9,8 +9,9 @@
#include <WiFi.h> #include <WiFi.h>
#endif #endif
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
extern bool needReconnect; extern bool needReconnect;
+1 -1
View File
@@ -262,7 +262,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
break; break;
} }
case meshtastic_AdminMessage_ota_request_tag: { case meshtastic_AdminMessage_ota_request_tag: {
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WIFI #if defined(ARCH_ESP32)
LOG_INFO("OTA Requested"); LOG_INFO("OTA Requested");
if (r->ota_request.ota_hash.size != 32) { if (r->ota_request.ota_hash.size != 32) {
@@ -206,10 +206,6 @@ void ExternalNotificationModule::setExternalState(uint8_t index, bool on)
#ifdef PCA_LED_NOTIFICATION #ifdef PCA_LED_NOTIFICATION
io.digitalWrite(PCA_LED_NOTIFICATION, on); io.digitalWrite(PCA_LED_NOTIFICATION, on);
#endif
#ifdef NEOPIXEL_STATUS_NOTIFICATION_PIN
notificationPixel.setPixelColor(0, on ? NEOPIXEL_STATUS_NOTIFICATION_COLOR : 0);
notificationPixel.show();
#endif #endif
break; break;
} }
@@ -328,12 +324,6 @@ ExternalNotificationModule::ExternalNotificationModule()
LOG_INFO("Use Pin %i in digital mode", output); LOG_INFO("Use Pin %i in digital mode", output);
pinMode(output, OUTPUT); pinMode(output, OUTPUT);
} }
#ifdef NEOPIXEL_STATUS_NOTIFICATION_PIN
LOG_INFO("Use WS2812 on GPIO %d as notification LED", NEOPIXEL_STATUS_NOTIFICATION_PIN);
notificationPixel.begin();
notificationPixel.clear();
notificationPixel.show();
#endif
setExternalState(0, false); setExternalState(0, false);
externalTurnedOn[0] = 0; externalTurnedOn[0] = 0;
if (moduleConfig.external_notification.output_vibra) { if (moduleConfig.external_notification.output_vibra) {
-17
View File
@@ -10,19 +10,6 @@
extern AmbientLightingThread *ambientLightingThread; extern AmbientLightingThread *ambientLightingThread;
#endif #endif
// Drive a single WS2812 as the notification LED (M1/M2-style LED_NOTIFICATION
// but addressable). A variant defines NEOPIXEL_STATUS_NOTIFICATION_PIN to
// enable. Colour defaults to green but can be overridden.
#ifdef NEOPIXEL_STATUS_NOTIFICATION_PIN
#include <Adafruit_NeoPixel.h>
#ifndef NEOPIXEL_STATUS_TYPE
#define NEOPIXEL_STATUS_TYPE (NEO_GRB + NEO_KHZ800)
#endif
#ifndef NEOPIXEL_STATUS_NOTIFICATION_COLOR
#define NEOPIXEL_STATUS_NOTIFICATION_COLOR 0x00FF00 // green
#endif
#endif
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6)
#include <NonBlockingRtttl.h> #include <NonBlockingRtttl.h>
#else #else
@@ -51,10 +38,6 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
CallbackObserver<ExternalNotificationModule, const InputEvent *>(this, &ExternalNotificationModule::handleInputEvent); CallbackObserver<ExternalNotificationModule, const InputEvent *>(this, &ExternalNotificationModule::handleInputEvent);
uint32_t output = 0; uint32_t output = 0;
#ifdef NEOPIXEL_STATUS_NOTIFICATION_PIN
Adafruit_NeoPixel notificationPixel = Adafruit_NeoPixel(1, NEOPIXEL_STATUS_NOTIFICATION_PIN, NEOPIXEL_STATUS_TYPE);
#endif
public: public:
ExternalNotificationModule(); ExternalNotificationModule();
-33
View File
@@ -17,29 +17,8 @@ StatusLEDModule::StatusLEDModule() : concurrency::OSThread("StatusLEDModule")
if (inputBroker) if (inputBroker)
inputObserver.observe(inputBroker); inputObserver.observe(inputBroker);
#endif #endif
#ifdef NEOPIXEL_STATUS_POWER_PIN
powerPixel.begin();
powerPixel.clear();
powerPixel.show();
#endif
#ifdef NEOPIXEL_STATUS_PAIRING_PIN
pairingPixel.begin();
pairingPixel.clear();
pairingPixel.show();
#endif
} }
// Helper: write a 1-pixel NeoPixel strand to `color` when stateOn, else clear.
// Kept as a static inline here (rather than a member) so it compiles out
// completely when no NeoPixel status pins are defined.
#if defined(NEOPIXEL_STATUS_POWER_PIN) || defined(NEOPIXEL_STATUS_PAIRING_PIN)
static inline void writeStatusPixel(Adafruit_NeoPixel &pixel, uint32_t color, bool stateOn)
{
pixel.setPixelColor(0, stateOn ? color : 0);
pixel.show();
}
#endif
int StatusLEDModule::handleStatusUpdate(const meshtastic::Status *arg) int StatusLEDModule::handleStatusUpdate(const meshtastic::Status *arg)
{ {
switch (arg->getStatusType()) { switch (arg->getStatusType()) {
@@ -197,12 +176,6 @@ int32_t StatusLEDModule::runOnce()
#ifdef LED_PAIRING #ifdef LED_PAIRING
digitalWrite(LED_PAIRING, PAIRING_LED_state); digitalWrite(LED_PAIRING, PAIRING_LED_state);
#endif #endif
#ifdef NEOPIXEL_STATUS_POWER_PIN
writeStatusPixel(powerPixel, NEOPIXEL_STATUS_POWER_COLOR, CHARGE_LED_state == LED_STATE_ON);
#endif
#ifdef NEOPIXEL_STATUS_PAIRING_PIN
writeStatusPixel(pairingPixel, NEOPIXEL_STATUS_PAIRING_COLOR, PAIRING_LED_state == LED_STATE_ON);
#endif
#ifdef RGB_LED_POWER #ifdef RGB_LED_POWER
if (!config.device.led_heartbeat_disabled) { if (!config.device.led_heartbeat_disabled) {
@@ -252,12 +225,6 @@ void StatusLEDModule::setPowerLED(bool LEDon)
#ifdef LED_PAIRING #ifdef LED_PAIRING
digitalWrite(LED_PAIRING, ledState); digitalWrite(LED_PAIRING, ledState);
#endif #endif
#ifdef NEOPIXEL_STATUS_POWER_PIN
writeStatusPixel(powerPixel, NEOPIXEL_STATUS_POWER_COLOR, LEDon);
#endif
#ifdef NEOPIXEL_STATUS_PAIRING_PIN
writeStatusPixel(pairingPixel, NEOPIXEL_STATUS_PAIRING_COLOR, LEDon);
#endif
#ifdef Battery_LED_1 #ifdef Battery_LED_1
digitalWrite(Battery_LED_1, ledState); digitalWrite(Battery_LED_1, ledState);
-26
View File
@@ -13,25 +13,6 @@
#include "input/InputBroker.h" #include "input/InputBroker.h"
#endif #endif
// WS2812/NeoPixel status-LED support. A variant may define
// NEOPIXEL_STATUS_POWER_PIN (required to enable the power/charge pixel)
// NEOPIXEL_STATUS_POWER_COLOR (optional, default red 0xFF0000)
// NEOPIXEL_STATUS_PAIRING_PIN / _COLOR (default blue 0x0000FF)
// Each pixel is a standalone 1-LED strand on its own GPIO — this mirrors how
// boards like the LilyGo T-Echo-Card expose three independent WS2812s.
#if defined(NEOPIXEL_STATUS_POWER_PIN) || defined(NEOPIXEL_STATUS_PAIRING_PIN)
#include <Adafruit_NeoPixel.h>
#ifndef NEOPIXEL_STATUS_TYPE
#define NEOPIXEL_STATUS_TYPE (NEO_GRB + NEO_KHZ800)
#endif
#ifndef NEOPIXEL_STATUS_POWER_COLOR
#define NEOPIXEL_STATUS_POWER_COLOR 0xFF0000 // red
#endif
#ifndef NEOPIXEL_STATUS_PAIRING_COLOR
#define NEOPIXEL_STATUS_PAIRING_COLOR 0x0000FF // blue
#endif
#endif
class StatusLEDModule : private concurrency::OSThread class StatusLEDModule : private concurrency::OSThread
{ {
bool slowTrack = false; bool slowTrack = false;
@@ -46,13 +27,6 @@ class StatusLEDModule : private concurrency::OSThread
void setPowerLED(bool); void setPowerLED(bool);
#ifdef NEOPIXEL_STATUS_POWER_PIN
Adafruit_NeoPixel powerPixel = Adafruit_NeoPixel(1, NEOPIXEL_STATUS_POWER_PIN, NEOPIXEL_STATUS_TYPE);
#endif
#ifdef NEOPIXEL_STATUS_PAIRING_PIN
Adafruit_NeoPixel pairingPixel = Adafruit_NeoPixel(1, NEOPIXEL_STATUS_PAIRING_PIN, NEOPIXEL_STATUS_TYPE);
#endif
protected: protected:
unsigned int my_interval = 1000; // interval in millisconds unsigned int my_interval = 1000; // interval in millisconds
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
+2 -2
View File
@@ -90,8 +90,8 @@ int32_t PaxcounterModule::runOnce()
configuration.blecounter = 1; configuration.blecounter = 1;
configuration.blescantime = 0; // infinite configuration.blescantime = 0; // infinite
configuration.wificounter = 1; configuration.wificounter = 1;
// configuration.wifi_channel_map = WIFI_CHANNEL_ALL; configuration.wifi_channel_map = WIFI_CHANNEL_ALL;
// configuration.wifi_channel_switch_interval = 50; configuration.wifi_channel_switch_interval = 50;
configuration.wifi_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.wifi_threshold, -80); configuration.wifi_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.wifi_threshold, -80);
configuration.ble_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.ble_threshold, -80); configuration.ble_rssi_threshold = Default::getConfiguredOrDefault(moduleConfig.paxcounter.ble_threshold, -80);
libpax_update_config(&configuration); libpax_update_config(&configuration);
+6 -2
View File
@@ -19,8 +19,12 @@
#include "mesh/wifi/WiFiAPClient.h" #include "mesh/wifi/WiFiAPClient.h"
#include <WiFi.h> #include <WiFi.h>
#endif #endif
#if HAS_ETHERNET && defined(ARCH_ESP32) #if HAS_ETHERNET && defined(USE_WS5500)
#include <ETH.h> #include <ETHClass2.h>
#define ETH ETH2
#elif HAS_ETHERNET && defined(USE_CH390D)
#include "ESP32_CH390.h"
#define ETH CH390
#endif // HAS_ETHERNET #endif // HAS_ETHERNET
#include "Default.h" #include "Default.h"
#if !defined(ARCH_NRF52) || NRF52_USE_JSON #if !defined(ARCH_NRF52) || NRF52_USE_JSON
+251 -192
View File
@@ -10,18 +10,23 @@
#include "mesh/PhoneAPI.h" #include "mesh/PhoneAPI.h"
#include "mesh/mesh-pb-constants.h" #include "mesh/mesh-pb-constants.h"
#include "sleep.h" #include "sleep.h"
#include <BLE2904.h> #include <NimBLEDevice.h>
#include <BLEAdvertising.h>
#include <BLEDevice.h>
#include <BLESecurity.h>
#include <BLEUtils.h>
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#ifdef NIMBLE_TWO
#include "NimBLEAdvertising.h"
#include "NimBLEExtAdvertising.h"
#include "PowerStatus.h" #include "PowerStatus.h"
#endif
#if defined(CONFIG_NIMBLE_CPP_IDF)
#include "host/ble_gap.h" #include "host/ble_gap.h"
#include "host/ble_store.h" #else
#include "nimble/nimble/host/include/host/ble_gap.h"
#endif
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
namespace namespace
{ {
@@ -29,6 +34,7 @@ constexpr uint16_t kPreferredBleMtu = 517;
constexpr uint16_t kPreferredBleTxOctets = 251; constexpr uint16_t kPreferredBleTxOctets = 251;
constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8; constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8;
} // namespace } // namespace
#endif
// Debugging options: careful, they slow things down quite a bit! // Debugging options: careful, they slow things down quite a bit!
// #define DEBUG_NIMBLE_ON_READ_TIMING // uncomment to time onRead duration // #define DEBUG_NIMBLE_ON_READ_TIMING // uncomment to time onRead duration
@@ -38,10 +44,10 @@ constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8;
#define NIMBLE_BLUETOOTH_TO_PHONE_QUEUE_SIZE 3 #define NIMBLE_BLUETOOTH_TO_PHONE_QUEUE_SIZE 3
#define NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE 3 #define NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE 3
BLECharacteristic *fromNumCharacteristic; NimBLECharacteristic *fromNumCharacteristic;
BLECharacteristic *BatteryCharacteristic; NimBLECharacteristic *BatteryCharacteristic;
BLECharacteristic *logRadioCharacteristic; NimBLECharacteristic *logRadioCharacteristic;
BLEServer *bleServer; NimBLEServer *bleServer;
static bool passkeyShowing; static bool passkeyShowing;
static std::atomic<uint16_t> nimbleBluetoothConnHandle{BLE_HS_CONN_HANDLE_NONE}; // BLE_HS_CONN_HANDLE_NONE means "no connection" static std::atomic<uint16_t> nimbleBluetoothConnHandle{BLE_HS_CONN_HANDLE_NONE}; // BLE_HS_CONN_HANDLE_NONE means "no connection"
@@ -112,8 +118,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
- Yes, we have to do some copy operations on pop because of this, but it's worth it to avoid cross-task memory management. - Yes, we have to do some copy operations on pop because of this, but it's worth it to avoid cross-task memory management.
NOTIFY IS BROKEN: NOTIFY IS BROKEN:
- Adding BLECharacteristic::PROPERTY_NOTIFY to FromRadioCharacteristic appears to break things. It is NOT backwards - Adding NIMBLE_PROPERTY::NOTIFY to FromRadioCharacteristic appears to break things. It is NOT backwards compatible.
compatible.
ZERO-SIZE READS: ZERO-SIZE READS:
- Returning a zero-size read from onRead breaks some clients during the config phase. So we have to block onRead until we - Returning a zero-size read from onRead breaks some clients during the config phase. So we have to block onRead until we
@@ -134,7 +139,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
std::mutex fromPhoneMutex; std::mutex fromPhoneMutex;
std::atomic<size_t> fromPhoneQueueSize{0}; std::atomic<size_t> fromPhoneQueueSize{0};
// We use array here (and pay the cost of memcpy) to avoid dynamic memory allocations and frees across FreeRTOS tasks. // We use array here (and pay the cost of memcpy) to avoid dynamic memory allocations and frees across FreeRTOS tasks.
std::array<BLEValue, NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE> fromPhoneQueue{}; std::array<NimBLEAttValue, NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE> fromPhoneQueue{};
/* Packets to phone (BLE onRead callback) */ /* Packets to phone (BLE onRead callback) */
std::mutex toPhoneMutex; std::mutex toPhoneMutex;
@@ -296,7 +301,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
LOG_DEBUG("NimbleBluetooth: handling ToRadio packet, fromPhoneQueueSize=%u", fromPhoneQueueSize.load()); LOG_DEBUG("NimbleBluetooth: handling ToRadio packet, fromPhoneQueueSize=%u", fromPhoneQueueSize.load());
// Pop the front of fromPhoneQueue, holding the mutex only briefly while we pop. // Pop the front of fromPhoneQueue, holding the mutex only briefly while we pop.
BLEValue val; NimBLEAttValue val;
{ // scope for fromPhoneMutex mutex { // scope for fromPhoneMutex mutex
std::lock_guard<std::mutex> guard(fromPhoneMutex); std::lock_guard<std::mutex> guard(fromPhoneMutex);
val = fromPhoneQueue[0]; val = fromPhoneQueue[0];
@@ -311,7 +316,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
fromPhoneQueueSize--; fromPhoneQueueSize--;
} }
handleToRadio(val.getData(), val.getLength()); handleToRadio(val.data(), val.length());
} }
} }
@@ -323,7 +328,9 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
PhoneAPI::onNowHasData(fromRadioNum); PhoneAPI::onNowHasData(fromRadioNum);
#ifdef DEBUG_NIMBLE_NOTIFY #ifdef DEBUG_NIMBLE_NOTIFY
int currentNotifyCount = notifyCount.fetch_add(1); int currentNotifyCount = notifyCount.fetch_add(1);
uint8_t cc = bleServer->getConnectedCount(); uint8_t cc = bleServer->getConnectedCount();
// This logging slows things down when there are lots of packets going to the phone, like initial connection: // This logging slows things down when there are lots of packets going to the phone, like initial connection:
LOG_DEBUG("BLE notify(%d) fromNum: %d connections: %d", currentNotifyCount, fromRadioNum, cc); LOG_DEBUG("BLE notify(%d) fromNum: %d connections: %d", currentNotifyCount, fromRadioNum, cc);
@@ -333,7 +340,13 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
put_le32(val, fromRadioNum); put_le32(val, fromRadioNum);
fromNumCharacteristic->setValue(val, sizeof(val)); fromNumCharacteristic->setValue(val, sizeof(val));
#ifdef NIMBLE_TWO
// NOTE: I don't have any NIMBLE_TWO devices, but this line makes me suspicious, and I suspect it needs to just be
// notify().
fromNumCharacteristic->notify(val, sizeof(val), BLE_HS_CONN_HANDLE_NONE);
#else
fromNumCharacteristic->notify(); fromNumCharacteristic->notify();
#endif
} }
/// Check the current underlying physical link to see if the client is currently connected /// Check the current underlying physical link to see if the client is currently connected
@@ -396,9 +409,14 @@ static BluetoothPhoneAPI *bluetoothPhoneAPI;
// Last ToRadio value received from the phone // Last ToRadio value received from the phone
static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE]; static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE];
class NimbleBluetoothToRadioCallback : public BLECharacteristicCallbacks class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks
{ {
void onWrite(BLECharacteristic *pCharacteristic) override #ifdef NIMBLE_TWO
virtual void onWrite(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo &connInfo) override
#else
virtual void onWrite(NimBLECharacteristic *pCharacteristic) override
#endif
{ {
// CAUTION: This callback runs in the NimBLE task!!! Don't do anything except communicate with the main task's runOnce. // CAUTION: This callback runs in the NimBLE task!!! Don't do anything except communicate with the main task's runOnce.
// Assumption: onWrite is serialized by NimBLE, so we don't need to lock here against multiple concurrent onWrite calls. // Assumption: onWrite is serialized by NimBLE, so we don't need to lock here against multiple concurrent onWrite calls.
@@ -410,17 +428,15 @@ class NimbleBluetoothToRadioCallback : public BLECharacteristicCallbacks
LOG_DEBUG("BLE onWrite(%d): start millis=%d", currentWriteCount, startMillis); LOG_DEBUG("BLE onWrite(%d): start millis=%d", currentWriteCount, startMillis);
#endif #endif
// Create a BLEValue and populate it with the received data auto val = pCharacteristic->getValue();
BLEValue val;
val.setValue(pCharacteristic->getData(), pCharacteristic->getLength());
if (memcmp(lastToRadio, val.getData(), val.getLength()) != 0) { if (memcmp(lastToRadio, val.data(), val.length()) != 0) {
if (bluetoothPhoneAPI->fromPhoneQueueSize < NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE) { if (bluetoothPhoneAPI->fromPhoneQueueSize < NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE) {
// Note: the comparison above is safe without a mutex because we are the only method that *increases* // Note: the comparison above is safe without a mutex because we are the only method that *increases*
// fromPhoneQueueSize. (It's okay if fromPhoneQueueSize *decreases* in the main task meanwhile.) // fromPhoneQueueSize. (It's okay if fromPhoneQueueSize *decreases* in the main task meanwhile.)
memcpy(lastToRadio, val.getData(), val.getLength()); memcpy(lastToRadio, val.data(), val.length());
{ // scope for fromPhoneMutex mutexv, pCharacteristic->getLen { // scope for fromPhoneMutex mutex
// Append to fromPhoneQueue, protected by fromPhoneMutex. Hold the mutex as briefly as possible. // Append to fromPhoneQueue, protected by fromPhoneMutex. Hold the mutex as briefly as possible.
std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->fromPhoneMutex); std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->fromPhoneMutex);
bluetoothPhoneAPI->fromPhoneQueue.at(bluetoothPhoneAPI->fromPhoneQueueSize) = val; bluetoothPhoneAPI->fromPhoneQueue.at(bluetoothPhoneAPI->fromPhoneQueueSize) = val;
@@ -434,21 +450,24 @@ class NimbleBluetoothToRadioCallback : public BLECharacteristicCallbacks
#ifdef DEBUG_NIMBLE_ON_WRITE_TIMING #ifdef DEBUG_NIMBLE_ON_WRITE_TIMING
int finishMillis = millis(); int finishMillis = millis();
LOG_DEBUG("BLE onWrite(%d): append to fromPhoneQueue took %u ms. numBytes=%d", currentWriteCount, LOG_DEBUG("BLE onWrite(%d): append to fromPhoneQueue took %u ms. numBytes=%d", currentWriteCount,
finishMillis - startMillis, val.getLength()); finishMillis - startMillis, val.length());
#endif #endif
} else { } else {
LOG_WARN("BLE onWrite(%d): Drop ToRadio packet, fromPhoneQueue full (%u bytes)", currentWriteCount, LOG_WARN("BLE onWrite(%d): Drop ToRadio packet, fromPhoneQueue full (%u bytes)", currentWriteCount, val.length());
val.getLength());
} }
} else { } else {
LOG_DEBUG("BLE onWrite(%d): Drop duplicate ToRadio packet (%u bytes)", currentWriteCount, val.getLength()); LOG_DEBUG("BLE onWrite(%d): Drop duplicate ToRadio packet (%u bytes)", currentWriteCount, val.length());
} }
} }
}; };
class NimbleBluetoothFromRadioCallback : public BLECharacteristicCallbacks class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks
{ {
void onRead(BLECharacteristic *pCharacteristic) override #ifdef NIMBLE_TWO
virtual void onRead(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo &connInfo) override
#else
virtual void onRead(NimBLECharacteristic *pCharacteristic) override
#endif
{ {
// CAUTION: This callback runs in the NimBLE task!!! Don't do anything except communicate with the main task's runOnce. // CAUTION: This callback runs in the NimBLE task!!! Don't do anything except communicate with the main task's runOnce.
@@ -554,46 +573,51 @@ class NimbleBluetoothFromRadioCallback : public BLECharacteristicCallbacks
} }
}; };
class NimbleBluetoothSecurityCallback : public BLESecurityCallbacks class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
{ {
void onPassKeyNotify(uint32_t passkey) override #ifdef NIMBLE_TWO
{ public:
LOG_INFO("*** Enter passkey %06u on the peer side ***", passkey); NimbleBluetoothServerCallback(NimbleBluetooth *ble) { this->ble = ble; }
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
meshtastic::BluetoothStatus newStatus(std::to_string(passkey));
bluetoothStatus->updateStatus(&newStatus);
#if HAS_SCREEN
if (screen) {
screen->startAlert([passkey](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
char btPIN[16] = "888888";
snprintf(btPIN, sizeof(btPIN), "%06u", passkey);
int x_offset = display->width() / 2;
int y_offset = display->height() <= 80 ? 0 : 12;
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(FONT_MEDIUM);
display->drawString(x_offset + x, y_offset + y, "Bluetooth");
#if !defined(OLED_TINY)
display->setFont(FONT_SMALL);
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM - 4 : y_offset + FONT_HEIGHT_MEDIUM + 5;
display->drawString(x_offset + x, y_offset + y, "Enter this code");
#endif
display->setFont(FONT_LARGE);
char pin[8];
snprintf(pin, sizeof(pin), "%.3s %.3s", btPIN, btPIN + 3);
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_SMALL - 5 : y_offset + FONT_HEIGHT_SMALL + 5;
display->drawString(x_offset + x, y_offset + y, pin);
display->setFont(FONT_SMALL); private:
char deviceName[64]; NimbleBluetooth *ble;
snprintf(deviceName, sizeof(deviceName), "Name: %s", getDeviceName());
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5; virtual uint32_t onPassKeyDisplay() override
display->drawString(x_offset + x, y_offset + y, deviceName); #else
}); virtual uint32_t onPassKeyRequest() override
#endif
{
uint32_t configuredPasskey = config.bluetooth.fixed_pin;
if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN) {
LOG_INFO("Use random passkey");
// This is the passkey to be entered on peer - we pick a number >100,000 to ensure 6 digits
configuredPasskey = random(100000, 999999);
}
LOG_INFO("*** Enter passkey %d on the peer side ***", configuredPasskey);
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
std::string passkey = std::to_string(configuredPasskey);
meshtastic::BluetoothStatus newStatus(passkey);
bluetoothStatus->updateStatus(&newStatus);
#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
if (screen) {
std::string ble_message = "Bluetooth\nPIN\n[M]" + passkey.substr(0, 3) + " " + passkey.substr(3, 6);
screen->showSimpleBanner(ble_message.c_str(), 30000);
} }
#endif #endif
passkeyShowing = true; passkeyShowing = true;
return configuredPasskey;
} }
void onAuthenticationComplete(ble_gap_conn_desc *desc) override
#ifdef NIMBLE_TWO
virtual void onAuthenticationComplete(NimBLEConnInfo &connInfo) override
#else
virtual void onAuthenticationComplete(ble_gap_conn_desc *desc) override
#endif
{ {
LOG_INFO("BLE authentication complete"); LOG_INFO("BLE authentication complete");
@@ -601,47 +625,58 @@ class NimbleBluetoothSecurityCallback : public BLESecurityCallbacks
bluetoothStatus->updateStatus(&newStatus); bluetoothStatus->updateStatus(&newStatus);
clearPairingDisplay(); clearPairingDisplay();
// Store the connection handle for future use
#ifdef NIMBLE_TWO
nimbleBluetoothConnHandle = connInfo.getConnHandle();
#else
nimbleBluetoothConnHandle = desc->conn_handle; nimbleBluetoothConnHandle = desc->conn_handle;
#endif
} }
};
class NimbleBluetoothServerCallback : public BLEServerCallbacks #ifdef NIMBLE_TWO
{ virtual void onConnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo) override
public:
explicit NimbleBluetoothServerCallback(NimbleBluetooth *ble) : ble(ble) {}
private:
NimbleBluetooth *ble;
void onConnect(BLEServer *pServer, struct ble_gap_conn_desc *desc)
{ {
BLEAddress peer_addr(desc->peer_id_addr); LOG_INFO("BLE incoming connection %s", connInfo.getAddress().toString().c_str());
LOG_INFO("BLE incoming connection %s", peer_addr.toString().c_str());
const uint16_t connHandle = desc->conn_handle; const uint16_t connHandle = connInfo.getConnHandle();
#if NIMBLE_ENABLE_2M_PHY && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6))
int phyResult =
ble_gap_set_prefered_le_phy(connHandle, BLE_GAP_LE_PHY_2M_MASK, BLE_GAP_LE_PHY_2M_MASK, BLE_GAP_LE_PHY_CODED_ANY);
if (phyResult == 0) {
LOG_INFO("BLE conn %u requested 2M PHY", connHandle);
} else {
LOG_WARN("Failed to prefer 2M PHY for conn %u, rc=%d", connHandle, phyResult);
}
#endif
// With Google Pixel 8 Android devices, this causes ESP32 device crash
// when phone reconnects. Disable this to make progress on the
// Arduino v3 migration while we investigate the Android compatibility
// issue.
#if 0
int dataLenResult = ble_gap_set_data_len(connHandle, kPreferredBleTxOctets, kPreferredBleTxTimeUs); int dataLenResult = ble_gap_set_data_len(connHandle, kPreferredBleTxOctets, kPreferredBleTxTimeUs);
if (dataLenResult == 0) { if (dataLenResult == 0) {
LOG_INFO("BLE conn %u requested data length %u bytes", connHandle, kPreferredBleTxOctets); LOG_INFO("BLE conn %u requested data length %u bytes", connHandle, kPreferredBleTxOctets);
} else { } else {
LOG_WARN("Failed to raise data length for conn %u, rc=%d", connHandle, dataLenResult); LOG_WARN("Failed to raise data length for conn %u, rc=%d", connHandle, dataLenResult);
} }
#endif
LOG_INFO("BLE conn %u peer MTU %u (target %u)", connHandle, pServer->getPeerMTU(connHandle), kPreferredBleMtu); LOG_INFO("BLE conn %u initial MTU %u (target %u)", connHandle, connInfo.getMTU(), kPreferredBleMtu);
pServer->updateConnParams(connHandle, 6, 12, 0, 200); pServer->updateConnParams(connHandle, 6, 12, 0, 200);
} }
#endif
void onDisconnect(BLEServer *pServer, struct ble_gap_conn_desc *desc) #ifdef NIMBLE_TWO
virtual void onDisconnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo, int reason) override
{ {
LOG_INFO("BLE disconnected"); LOG_INFO("BLE disconnect reason: %d", reason);
#else
virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc) override
{
LOG_INFO("BLE disconnect");
#endif
#ifdef NIMBLE_TWO
if (ble->isDeInit) if (ble->isDeInit)
return; return;
#else
if (nimbleBluetooth && nimbleBluetooth->isDeInit)
return;
#endif
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED); meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
bluetoothStatus->updateStatus(&newStatus); bluetoothStatus->updateStatus(&newStatus);
@@ -666,51 +701,43 @@ class NimbleBluetoothServerCallback : public BLEServerCallbacks
bluetoothPhoneAPI->writeCount = 0; bluetoothPhoneAPI->writeCount = 0;
} }
// Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection
memset(lastToRadio, 0, sizeof(lastToRadio)); memset(lastToRadio, 0, sizeof(lastToRadio));
nimbleBluetoothConnHandle = BLE_HS_CONN_HANDLE_NONE; nimbleBluetoothConnHandle = BLE_HS_CONN_HANDLE_NONE; // BLE_HS_CONN_HANDLE_NONE means "no connection"
#ifdef NIMBLE_TWO
// Restart Advertising
ble->startAdvertising(); ble->startAdvertising();
#else
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
if (!pAdvertising->start(0)) {
if (pAdvertising->isAdvertising()) {
LOG_DEBUG("BLE advertising already running");
} else {
LOG_ERROR("BLE failed to restart advertising");
}
}
#endif
} }
}; };
static NimbleBluetoothToRadioCallback *toRadioCallbacks; static NimbleBluetoothToRadioCallback *toRadioCallbacks;
static NimbleBluetoothFromRadioCallback *fromRadioCallbacks; static NimbleBluetoothFromRadioCallback *fromRadioCallbacks;
void NimbleBluetooth::startAdvertising()
{
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->stop();
pAdvertising->reset();
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
// if (powerStatus->getHasBattery() == 1) {
// pAdvertising->addServiceUUID(BLEUUID((uint16_t)0x180f));
// }
BLEAdvertisementData scan = BLEAdvertisementData();
scan.setName(getDeviceName());
pAdvertising->setScanResponseData(scan);
pAdvertising->setMinPreferred(0x06); // functions that help with iPhone connections issue
pAdvertising->setMaxPreferred(0x12);
if (!pAdvertising->start(0)) {
LOG_ERROR("BLE failed to start advertising");
} else {
LOG_DEBUG("BLE Advertising started");
}
}
void NimbleBluetooth::shutdown() void NimbleBluetooth::shutdown()
{ {
// No measurable power saving for ESP32 during light-sleep(?)
#ifndef ARCH_ESP32 #ifndef ARCH_ESP32
// Shutdown bluetooth for minimum power draw
LOG_INFO("Disable bluetooth"); LOG_INFO("Disable bluetooth");
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset(); pAdvertising->reset();
pAdvertising->stop(); pAdvertising->stop();
#endif #endif
} }
// Proper shutdown for ESP32. Needs reboot to reverse.
void NimbleBluetooth::deinit() void NimbleBluetooth::deinit()
{ {
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
@@ -720,19 +747,21 @@ void NimbleBluetooth::deinit()
#ifdef BLE_LED #ifdef BLE_LED
digitalWrite(BLE_LED, LED_STATE_OFF); digitalWrite(BLE_LED, LED_STATE_OFF);
#endif #endif
#ifndef NIMBLE_TWO
BLEDevice::deinit(true); NimBLEDevice::deinit();
#endif
#endif #endif
} }
// Has initial setup been completed
bool NimbleBluetooth::isActive() bool NimbleBluetooth::isActive()
{ {
return bleServer != nullptr; return bleServer;
} }
bool NimbleBluetooth::isConnected() bool NimbleBluetooth::isConnected()
{ {
return bleServer && bleServer->getConnectedCount() > 0; return bleServer->getConnectedCount() > 0;
} }
int NimbleBluetooth::getRssi() int NimbleBluetooth::getRssi()
@@ -745,9 +774,9 @@ int NimbleBluetooth::getRssi()
uint16_t connHandle = nimbleBluetoothConnHandle.load(); uint16_t connHandle = nimbleBluetoothConnHandle.load();
if (connHandle == BLE_HS_CONN_HANDLE_NONE) { if (connHandle == BLE_HS_CONN_HANDLE_NONE) {
const auto peers = bleServer->getPeerDevices(true); const auto peers = bleServer->getPeerDevices();
if (!peers.empty()) { if (!peers.empty()) {
connHandle = peers.begin()->first; connHandle = peers.front();
nimbleBluetoothConnHandle = connHandle; nimbleBluetoothConnHandle = connHandle;
} }
} }
@@ -775,84 +804,74 @@ void NimbleBluetooth::setup()
LOG_INFO("Init the NimBLE bluetooth module"); LOG_INFO("Init the NimBLE bluetooth module");
BLEDevice::init(getDeviceName()); NimBLEDevice::init(getDeviceName());
BLEDevice::setPower(ESP_PWR_LVL_P9); NimBLEDevice::setPower(ESP_PWR_LVL_P9);
int mtuResult = BLEDevice::setMTU(kPreferredBleMtu); #if NIMBLE_ENABLE_2M_PHY && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6))
int mtuResult = NimBLEDevice::setMTU(kPreferredBleMtu);
if (mtuResult == 0) { if (mtuResult == 0) {
LOG_INFO("BLE MTU request set to %u", kPreferredBleMtu); LOG_INFO("BLE MTU request set to %u", kPreferredBleMtu);
} else { } else {
LOG_WARN("Unable to request MTU %u, rc=%d", kPreferredBleMtu, mtuResult); LOG_WARN("Unable to request MTU %u, rc=%d", kPreferredBleMtu, mtuResult);
} }
BLESecurity *pSecurity = new BLESecurity(); int phyResult = ble_gap_set_prefered_default_le_phy(BLE_GAP_LE_PHY_2M_MASK, BLE_GAP_LE_PHY_2M_MASK);
pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); if (phyResult == 0) {
pSecurity->setRespEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); LOG_INFO("BLE default PHY preference set to 2M");
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
// Set IO capability to DisplayOnly for MITM authentication
pSecurity->setCapability(ESP_IO_CAP_OUT);
// Set the passkey
if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN) {
LOG_INFO("Use random passkey");
pSecurity->setPassKey(false); // generate a random passkey
} else {
LOG_INFO("Use fixed passkey");
pSecurity->setPassKey(true, config.bluetooth.fixed_pin);
}
// Enable authorization requirements:
// - bonding: true (for persistent storage of the keys)
// - MITM: true (enables Man-In-The-Middle protection for password prompts)
// - secure connection: true (enables secure connection for encryption)
pSecurity->setAuthenticationMode(true, true, true);
} else { } else {
// No IO capability for no PIN mode LOG_WARN("Failed to prefer 2M PHY by default, rc=%d", phyResult);
pSecurity->setCapability(ESP_IO_CAP_NONE);
// No PIN mode: no MITM protection
pSecurity->setAuthenticationMode(true, false, false);
}
// Set the security callbacks
BLEDevice::setSecurityCallbacks(new NimbleBluetoothSecurityCallback());
bleServer = BLEDevice::createServer();
// BLEDevice::createServer calls ble_svc_gap_init, which resets the device
// name to default, so set it again.
int nameRc = ble_svc_gap_device_name_set(BLEDevice::getDeviceName().c_str());
if (nameRc != 0) {
LOG_ERROR("ble_svc_gap_device_name_set: rc=%d %s", nameRc, BLEUtils::returnCodeToString(nameRc));
} }
bleServer->setCallbacks(new NimbleBluetoothServerCallback(this)); int dataLenResult = ble_gap_write_sugg_def_data_len(kPreferredBleTxOctets, kPreferredBleTxTimeUs);
if (dataLenResult == 0) {
LOG_INFO("BLE suggested data length set to %u bytes", kPreferredBleTxOctets);
} else {
LOG_WARN("Failed to raise suggested data length (%u/%u), rc=%d", kPreferredBleTxOctets, kPreferredBleTxTimeUs,
dataLenResult);
}
#endif
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_BOND | BLE_SM_PAIR_AUTHREQ_MITM | BLE_SM_PAIR_AUTHREQ_SC);
NimBLEDevice::setSecurityInitKey(BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID);
NimBLEDevice::setSecurityRespKey(BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID);
NimBLEDevice::setSecurityIOCap(BLE_HS_IO_DISPLAY_ONLY);
}
bleServer = NimBLEDevice::createServer();
#ifdef NIMBLE_TWO
NimbleBluetoothServerCallback *serverCallbacks = new NimbleBluetoothServerCallback(this);
#else
NimbleBluetoothServerCallback *serverCallbacks = new NimbleBluetoothServerCallback();
#endif
bleServer->setCallbacks(serverCallbacks, true);
setupService(); setupService();
startAdvertising(); startAdvertising();
} }
void NimbleBluetooth::setupService() void NimbleBluetooth::setupService()
{ {
BLEService *bleService = bleServer->createService(MESH_SERVICE_UUID); NimBLEService *bleService = bleServer->createService(MESH_SERVICE_UUID);
BLECharacteristic *ToRadioCharacteristic; NimBLECharacteristic *ToRadioCharacteristic;
BLECharacteristic *FromRadioCharacteristic; NimBLECharacteristic *FromRadioCharacteristic;
// Define the characteristics that the app is looking for // Define the characteristics that the app is looking for
if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) { if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, BLECharacteristic::PROPERTY_WRITE); ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE);
// Allow notifications so phones can stream FromRadio without polling. // Allow notifications so phones can stream FromRadio without polling.
FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, BLECharacteristic::PROPERTY_READ); FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ);
fromNumCharacteristic = fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ);
bleService->createCharacteristic(FROMNUM_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ); logRadioCharacteristic =
logRadioCharacteristic = bleService->createCharacteristic(LOGRADIO_UUID, BLECharacteristic::PROPERTY_NOTIFY | bleService->createCharacteristic(LOGRADIO_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ, 512U);
BLECharacteristic::PROPERTY_READ);
} else { } else {
ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, BLECharacteristic::PROPERTY_WRITE | ToRadioCharacteristic = bleService->createCharacteristic(
BLECharacteristic::PROPERTY_WRITE_AUTHEN | TORADIO_UUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_AUTHEN | NIMBLE_PROPERTY::WRITE_ENC);
BLECharacteristic::PROPERTY_WRITE_ENC); FromRadioCharacteristic = bleService->createCharacteristic(
FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, BLECharacteristic::PROPERTY_READ | FROMRADIO_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC);
BLECharacteristic::PROPERTY_READ_AUTHEN | fromNumCharacteristic =
BLECharacteristic::PROPERTY_READ_ENC); bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ |
fromNumCharacteristic = bleService->createCharacteristic( NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC);
FROMNUM_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_READ_AUTHEN | BLECharacteristic::PROPERTY_READ_ENC);
logRadioCharacteristic = bleService->createCharacteristic( logRadioCharacteristic = bleService->createCharacteristic(
LOGRADIO_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ | LOGRADIO_UUID,
BLECharacteristic::PROPERTY_READ_AUTHEN | BLECharacteristic::PROPERTY_READ_ENC); NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC, 512U);
} }
bluetoothPhoneAPI = new BluetoothPhoneAPI(); bluetoothPhoneAPI = new BluetoothPhoneAPI();
@@ -865,31 +884,76 @@ void NimbleBluetooth::setupService()
bleService->start(); bleService->start();
// Setup the battery service // Setup the battery service
BLEService *batteryService = bleServer->createService(BLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
BLE2904 *batteryLevelDescriptor = new BLE2904(); BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic)
batteryLevelDescriptor->setFormat(BLE2904::FORMAT_UINT8); (uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY, 1);
#ifdef NIMBLE_TWO
NimBLE2904 *batteryLevelDescriptor = BatteryCharacteristic->create2904();
#else
NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904);
#endif
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
batteryLevelDescriptor->setNamespace(1); batteryLevelDescriptor->setNamespace(1);
batteryLevelDescriptor->setUnit(0x27ad); batteryLevelDescriptor->setUnit(0x27ad);
BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic)
(uint16_t)0x2a19, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
BatteryCharacteristic->addDescriptor(batteryLevelDescriptor);
batteryService->start(); batteryService->start();
} }
void NimbleBluetooth::startAdvertising()
{
#ifdef NIMBLE_TWO
NimBLEExtAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
NimBLEExtAdvertisement legacyAdvertising;
legacyAdvertising.setLegacyAdvertising(true);
legacyAdvertising.setScannable(true);
legacyAdvertising.setConnectable(true);
legacyAdvertising.setFlags(BLE_HS_ADV_F_DISC_GEN);
if (powerStatus->getHasBattery() == 1) {
legacyAdvertising.setCompleteServices(NimBLEUUID((uint16_t)0x180f));
}
legacyAdvertising.setCompleteServices(NimBLEUUID(MESH_SERVICE_UUID));
legacyAdvertising.setMinInterval(500);
legacyAdvertising.setMaxInterval(1000);
NimBLEExtAdvertisement legacyScanResponse;
legacyScanResponse.setLegacyAdvertising(true);
legacyScanResponse.setConnectable(true);
legacyScanResponse.setName(getDeviceName());
if (!pAdvertising->setInstanceData(0, legacyAdvertising)) {
LOG_ERROR("BLE failed to set legacyAdvertising");
} else if (!pAdvertising->setScanResponseData(0, legacyScanResponse)) {
LOG_ERROR("BLE failed to set legacyScanResponse");
} else if (!pAdvertising->start(0, 0, 0)) {
LOG_ERROR("BLE failed to start legacyAdvertising");
}
#else
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset();
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
pAdvertising->addServiceUUID(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
pAdvertising->start(0);
#endif
}
/// Given a level between 0-100, update the BLE attribute /// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level) void updateBatteryLevel(uint8_t level)
{ {
if ((config.bluetooth.enabled == true) && bleServer && nimbleBluetooth->isConnected()) { if ((config.bluetooth.enabled == true) && bleServer && nimbleBluetooth->isConnected()) {
BatteryCharacteristic->setValue(&level, 1); BatteryCharacteristic->setValue(&level, 1);
#ifdef NIMBLE_TWO
BatteryCharacteristic->notify(&level, 1, BLE_HS_CONN_HANDLE_NONE);
#else
BatteryCharacteristic->notify(); BatteryCharacteristic->notify();
#endif
} }
} }
void NimbleBluetooth::clearBonds() void NimbleBluetooth::clearBonds()
{ {
LOG_INFO("Clearing bluetooth bonds!"); LOG_INFO("Clearing bluetooth bonds!");
ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_PEER_SEC, nullptr); NimBLEDevice::deleteAllBonds();
ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, nullptr);
} }
void NimbleBluetooth::sendLog(const uint8_t *logMessage, size_t length) void NimbleBluetooth::sendLog(const uint8_t *logMessage, size_t length)
@@ -897,16 +961,11 @@ void NimbleBluetooth::sendLog(const uint8_t *logMessage, size_t length)
if (!bleServer || !isConnected() || length > 512) { if (!bleServer || !isConnected() || length > 512) {
return; return;
} }
logRadioCharacteristic->setValue(logMessage, length); #ifdef NIMBLE_TWO
logRadioCharacteristic->notify(); logRadioCharacteristic->notify(logMessage, length, BLE_HS_CONN_HANDLE_NONE);
#else
logRadioCharacteristic->notify(logMessage, length, true);
#endif
} }
void clearNVS()
{
ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_PEER_SEC, nullptr);
ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, nullptr);
#ifdef ARCH_ESP32
ESP.restart();
#endif
}
#endif #endif
+5
View File
@@ -12,11 +12,16 @@ class NimbleBluetooth : BluetoothApi
bool isConnected(); bool isConnected();
int getRssi(); int getRssi();
void sendLog(const uint8_t *logMessage, size_t length); void sendLog(const uint8_t *logMessage, size_t length);
#if defined(NIMBLE_TWO)
void startAdvertising(); void startAdvertising();
#endif
bool isDeInit = false; bool isDeInit = false;
private: private:
void setupService(); void setupService();
#if !defined(NIMBLE_TWO)
void startAdvertising();
#endif
}; };
void setBluetoothEnable(bool enable); void setBluetoothEnable(bool enable);
-42
View File
@@ -1,42 +0,0 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "esp_attr.h"
#ifdef ESP32_FORCE_IRAM_MEMSET
/*
* T-Beam/classic ESP32 boot workaround
* ------------------------------------
* During early flash operations the ESP32 disables cache, but some IRAM flash
* code paths still reach libc memcpy/memset. If those resolve to flash-resident
* implementations, startup can panic with cache-disabled access errors.
*
* We wrap memcpy/memset for the T-Beam environment. Fast path uses the
* normal libc routines when cache is enabled; slow path uses IRAM-safe byte
* loops when cache is disabled.
*/
extern void *__real_memcpy(void *dst, const void *src, size_t n);
static inline bool IRAM_ATTR cache_is_enabled(void)
{
return (*(volatile uint32_t *)0x3FF00040u) & (1u << 3);
}
extern void *IRAM_ATTR __wrap_memcpy(void *dst, const void *src, size_t n)
{
if (cache_is_enabled()) {
return __real_memcpy(dst, src, n);
}
uint8_t *d = (uint8_t *)dst;
const uint8_t *s = (const uint8_t *)src;
while (n--) {
*d++ = *s++;
}
return dst;
}
#endif
-42
View File
@@ -1,42 +0,0 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "esp_attr.h"
#ifdef ESP32_FORCE_IRAM_MEMSET
/*
* T-Beam/classic ESP32 boot workaround
* ------------------------------------
* During early flash operations the ESP32 disables cache, but some IRAM flash
* code paths still reach libc memcpy/memset. If those resolve to flash-resident
* implementations, startup can panic with cache-disabled access errors.
*
* We wrap memcpy/memset for the T-Beam environment. Fast path uses the
* normal libc routines when cache is enabled; slow path uses IRAM-safe byte
* loops when cache is disabled.
*/
extern void *__real_memset(void *dst, int c, size_t n);
static inline bool IRAM_ATTR cache_is_enabled(void)
{
return (*(volatile uint32_t *)0x3FF00040u) & (1u << 3);
}
extern void *IRAM_ATTR __wrap_memset(void *dst, int c, size_t n)
{
if (cache_is_enabled()) {
return __real_memset(dst, c, n);
}
uint8_t *ptr = (uint8_t *)dst;
const uint8_t fill = (uint8_t)c;
while (n--) {
*ptr++ = fill;
}
return dst;
}
#endif
@@ -1,11 +0,0 @@
/* Arduino fix: catch esp_event's orphaned .text.handler_execute section and align to 4 bytes */
SECTIONS
{
.text.handler_execute ALIGN(4) :
{
KEEP(*(.text.handler_execute))
KEEP(*(.text.handler_execute.*))
. = ALIGN(4);
}
}
INSERT AFTER .flash.text;
+6 -21
View File
@@ -165,30 +165,17 @@ void esp32Setup()
// #define APP_WATCHDOG_SECS 45 // #define APP_WATCHDOG_SECS 45
#define APP_WATCHDOG_SECS 90 #define APP_WATCHDOG_SECS 90
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) #ifdef CONFIG_IDF_TARGET_ESP32C6
const esp_task_wdt_config_t wdt_config = { esp_task_wdt_config_t *wdt_config = (esp_task_wdt_config_t *)malloc(sizeof(esp_task_wdt_config_t));
.timeout_ms = APP_WATCHDOG_SECS * 1000, wdt_config->timeout_ms = APP_WATCHDOG_SECS * 1000;
.idle_core_mask = (1U << CONFIG_FREERTOS_NUMBER_OF_CORES) - 1U, wdt_config->trigger_panic = true;
.trigger_panic = true, res = esp_task_wdt_init(wdt_config);
};
res = esp_task_wdt_init(&wdt_config);
if (res == ESP_ERR_INVALID_STATE) {
LOG_WARN("Task watchdog already initialized, reconfiguring existing instance");
res = esp_task_wdt_reconfigure(&wdt_config);
}
assert(res == ESP_OK); assert(res == ESP_OK);
#else #else
res = esp_task_wdt_init(APP_WATCHDOG_SECS, true); res = esp_task_wdt_init(APP_WATCHDOG_SECS, true);
if (res == ESP_ERR_INVALID_STATE) {
LOG_WARN("Task watchdog already initialized, reusing existing instance");
res = ESP_OK;
}
assert(res == ESP_OK); assert(res == ESP_OK);
#endif #endif
res = esp_task_wdt_status(NULL); res = esp_task_wdt_add(NULL);
if (res == ESP_ERR_NOT_FOUND) {
res = esp_task_wdt_add(NULL);
}
assert(res == ESP_OK); assert(res == ESP_OK);
#if HAS_32768HZ #if HAS_32768HZ
@@ -271,10 +258,8 @@ void cpuDeepSleep(uint32_t msecToWake)
#endif #endif
variant_shutdown(); variant_shutdown();
#if SOC_PM_SUPPORT_RTC_PERIPH_PD
// We want RTC peripherals to stay on // We want RTC peripherals to stay on
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
#endif
esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
esp_deep_sleep_start(); // TBD mA sleep current (battery) esp_deep_sleep_start(); // TBD mA sleep current (battery)
@@ -3,63 +3,14 @@
#ifdef M5STACK_CARDPUTER_ADV #ifdef M5STACK_CARDPUTER_ADV
#include "AudioBoard.h" #include "AudioBoard.h"
#include <Wire.h>
DriverPins PinsAudioBoardES8311; DriverPins PinsAudioBoardES8311;
AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311); AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311);
// PI4IOE5V6408 on the optional Cap LoRa-1262 (and Cap LoRa868).
#define PI4IO_ADDR 0x43
#define PI4IO_REG_IO_DIR 0x03
#define PI4IO_REG_OUT_SET 0x05
#define PI4IO_REG_OUT_H_IM 0x07
static TwoWire *findLoraCapBus()
{
TwoWire *candidates[] = {&Wire1, &Wire};
for (size_t i = 0; i < sizeof(candidates) / sizeof(candidates[0]); ++i) {
candidates[i]->beginTransmission(PI4IO_ADDR);
if (candidates[i]->endTransmission() == 0) {
return candidates[i];
}
}
return nullptr;
}
static bool pi4ioWrite(TwoWire *bus, uint8_t reg, uint8_t val)
{
bus->beginTransmission(PI4IO_ADDR);
bus->write(reg);
bus->write(val);
uint8_t status = bus->endTransmission();
if (status != 0) {
LOG_DEBUG("PI4IO write reg=0x%02x val=0x%02x failed, I2C status=%u", reg, val, status);
return false;
}
return true;
}
static void initLoraCap()
{
TwoWire *bus = findLoraCapBus();
if (!bus) {
LOG_ERROR("Cap LoRa-1262 not found");
return;
}
bool ok = pi4ioWrite(bus, PI4IO_REG_IO_DIR, 0b00000001);
ok = ok && pi4ioWrite(bus, PI4IO_REG_OUT_H_IM, 0b00000000);
ok = ok && pi4ioWrite(bus, PI4IO_REG_OUT_SET, 0b00000001);
if (!ok) {
LOG_ERROR("Antenna switch init failed");
}
}
// M5stack Cardputer ADV specific init // M5stack Cardputer ADV specific init
void lateInitVariant() void lateInitVariant()
{ {
initLoraCap();
// AudioDriverLogger.begin(Serial, AudioDriverLogLevel::Debug); // AudioDriverLogger.begin(Serial, AudioDriverLogLevel::Debug);
// I2C: function, scl, sda // I2C: function, scl, sda
PinsAudioBoardES8311.addI2C(PinFunction::CODEC, Wire); PinsAudioBoardES8311.addI2C(PinFunction::CODEC, Wire);
+7 -4
View File
@@ -4,10 +4,8 @@
#include "configuration.h" #include "configuration.h"
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
// #include <driver/adc.h> // "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h
#include <esp_adc/adc_cali.h> #include <esp_adc_cal.h>
#include <esp_adc/adc_cali_scheme.h>
#include <esp_adc/adc_oneshot.h>
#include <soc/adc_channel.h> #include <soc/adc_channel.h>
#endif #endif
@@ -30,6 +28,11 @@
#define NUM_CELLS 1 #define NUM_CELLS 1
#endif #endif
#ifdef BAT_MEASURE_ADC_UNIT
extern RTC_NOINIT_ATTR uint64_t RTC_reg_b;
#include "soc/sens_reg.h" // needed for adc pin reset
#endif
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
#include "modules/Telemetry/Sensor/nullSensor.h" #include "modules/Telemetry/Sensor/nullSensor.h"
#if __has_include(<Adafruit_INA219.h>) #if __has_include(<Adafruit_INA219.h>)
+12 -30
View File
@@ -18,6 +18,8 @@
#include "target_specific.h" #include "target_specific.h"
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
// "esp_pm_config_esp32_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead"
#include "esp32/pm.h"
#include "esp_pm.h" #include "esp_pm.h"
#if HAS_WIFI #if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h" #include "mesh/wifi/WiFiAPClient.h"
@@ -144,31 +146,15 @@ void initDeepSleep()
// If we booted because our timer ran out or the user pressed reset, send those as fake events // If we booted because our timer ran out or the user pressed reset, send those as fake events
RESET_REASON hwReason = rtc_get_reset_reason(0); RESET_REASON hwReason = rtc_get_reset_reason(0);
#ifdef CONFIG_IDF_TARGET_ESP32P4
if (hwReason == BROWN_OUT_RESET)
reason = "brownout";
else if (hwReason == HP_CORE_HP_WDT_RESET)
reason = "taskWatchdog";
else if (hwReason == HP_CORE_LP_WDT_RESET)
reason = "intWatchdog";
else if (hwReason == CHIP_LP_WDT_RESET)
reason = "chipWatchdog";
else if (hwReason == SUPER_WDT_RESET)
reason = "superWatchdog";
else if (hwReason == HP_SYS_HP_WDT_RESET)
reason = "systemWatchdog";
else if (hwReason == HP_SYS_LP_WDT_RESET)
reason = "systemLowPowerWatchdog";
#else
if (hwReason == RTCWDT_BROWN_OUT_RESET) if (hwReason == RTCWDT_BROWN_OUT_RESET)
reason = "brownout"; reason = "brownout";
else if (hwReason == RTCWDT_RTC_RESET)
reason = "rtcWatchdog"; if (hwReason == TG0WDT_SYS_RESET)
else if (hwReason == TG0WDT_SYS_RESET)
reason = "taskWatchdog"; reason = "taskWatchdog";
else if (hwReason == TG1WDT_SYS_RESET)
if (hwReason == TG1WDT_SYS_RESET)
reason = "intWatchdog"; reason = "intWatchdog";
#endif
LOG_INFO("Booted, wake cause %d (boot count %d), reset_reason=%s", wakeCause, bootCount, reason); LOG_INFO("Booted, wake cause %d (boot count %d), reset_reason=%s", wakeCause, bootCount, reason);
#endif #endif
@@ -411,10 +397,8 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
// NOTE! ESP docs say we must disable bluetooth and wifi before light sleep // NOTE! ESP docs say we must disable bluetooth and wifi before light sleep
#if SOC_PM_SUPPORT_RTC_PERIPH_PD
// We want RTC peripherals to stay on // We want RTC peripherals to stay on
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
#endif
#if defined(BUTTON_PIN) && defined(BUTTON_NEED_PULLUP) #if defined(BUTTON_PIN) && defined(BUTTON_NEED_PULLUP)
gpio_pullup_en((gpio_num_t)BUTTON_PIN); gpio_pullup_en((gpio_num_t)BUTTON_PIN);
@@ -548,7 +532,11 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
*/ */
void enableModemSleep() void enableModemSleep()
{ {
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
static esp_pm_config_t esp32_config; // filled with zeros because bss static esp_pm_config_t esp32_config; // filled with zeros because bss
#else
static esp_pm_config_esp32_t esp32_config; // filled with zeros because bss
#endif
#if CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32S3
esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ; esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ;
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2
@@ -557,12 +545,6 @@ void enableModemSleep()
esp32_config.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ; esp32_config.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ;
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3
esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ;
#elif CONFIG_IDF_TARGET_ESP32P4
#if CONFIG_ESP32P4_REV_MIN_FULL < 300
esp32_config.max_freq_mhz = 360;
#else
esp32_config.max_freq_mhz = 400;
#endif
#else #else
esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
#endif #endif
@@ -580,8 +562,8 @@ bool shouldLoraWake(uint32_t msecToWake)
void enableLoraInterrupt() void enableLoraInterrupt()
{ {
#if SOC_PM_SUPPORT_EXT_WAKEUP && defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC)
esp_err_t res; esp_err_t res;
#if SOC_PM_SUPPORT_EXT_WAKEUP && defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC)
res = gpio_pulldown_en((gpio_num_t)LORA_DIO1); res = gpio_pulldown_en((gpio_num_t)LORA_DIO1);
if (res != ESP_OK) { if (res != ESP_OK) {
LOG_ERROR("gpio_pulldown_en(LORA_DIO1) result %d", res); LOG_ERROR("gpio_pulldown_en(LORA_DIO1) result %d", res);
+1 -1
View File
@@ -70,7 +70,7 @@
// Battery // Battery
#define BATTERY_PIN 34 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 34 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_6 #define ADC_CHANNEL ADC1_GPIO34_CHANNEL
#define ADC_ATTENUATION \ #define ADC_ATTENUATION \
ADC_ATTEN_DB_2_5 // 2_5-> 100mv-1250mv, 11-> 150mv-3100mv for ESP32 ADC_ATTEN_DB_2_5 // 2_5-> 100mv-1250mv, 11-> 150mv-3100mv for ESP32
// ESP32-S2/C3/S3 are different // ESP32-S2/C3/S3 are different
@@ -30,7 +30,7 @@
// Battery sense // Battery sense
#define BATTERY_PIN 35 #define BATTERY_PIN 35
#define ADC_MULTIPLIER 2.01 // 100k + 100k, and add 1% tolerance #define ADC_MULTIPLIER 2.01 // 100k + 100k, and add 1% tolerance
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION #define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION
// SPI // SPI
+1 -1
View File
@@ -3,7 +3,7 @@
#define I2C_SDA 4 #define I2C_SDA 4
#define I2C_SCL 5 #define I2C_SCL 5
#define BATTERY_PIN 34 #define BATTERY_PIN 34
#define ADC_CHANNEL ADC_CHANNEL_6 #define ADC_CHANNEL ADC1_GPIO34_CHANNEL
// GPS // GPS
#undef GPS_RX_PIN #undef GPS_RX_PIN
+1 -1
View File
@@ -11,7 +11,7 @@
// Note: On the ESP32 base version, gpio34-39 are input-only, and do not have internal pull-ups. // Note: On the ESP32 base version, gpio34-39 are input-only, and do not have internal pull-ups.
// If 39 is not being used for a button, it is suggested to remove the #define. // If 39 is not being used for a button, it is suggested to remove the #define.
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k) #define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards #define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
+1 -1
View File
@@ -11,7 +11,7 @@
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam #define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k) #define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards #define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
+15 -257
View File
@@ -4,9 +4,8 @@ extends = arduino_base
custom_esp32_kind = custom_esp32_kind =
custom_mtjson_part = custom_mtjson_part =
platform = platform =
# TODO renovate # renovate: datasource=custom.pio depName=platformio/espressif32 packageName=platformio/platform/espressif32
https://github.com/pioarduino/platform-espressif32/releases/download/55.03.38-1/platform-espressif32.zip platformio/espressif32@6.13.0
; https://github.com/pioarduino/platform-espressif32.git#develop
platform_packages = platform_packages =
# renovate: datasource=custom.pio depName=platformio/tool-mklittlefs packageName=platformio/tool/tool-mklittlefs # renovate: datasource=custom.pio depName=platformio/tool-mklittlefs packageName=platformio/tool/tool-mklittlefs
platformio/tool-mklittlefs@1.203.210628 platformio/tool-mklittlefs@1.203.210628
@@ -36,18 +35,20 @@ build_unflags =
-std=gnu++11 -std=gnu++11
build_flags = build_flags =
${arduino_base.build_flags} ${arduino_base.build_flags}
-flto
-Wall -Wall
-Wextra -Wextra
-Isrc/platform/esp32 -Isrc/platform/esp32
-std=gnu++17 -std=gnu++17
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
# DO NOT INCREASE THIS TO DEBUG. It appears to trigger a bug in ESP-IDF -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
# Bluetooth stack with Pixel 8 Android devices:
# https://github.com/espressif/esp-idf/issues/18126#issuecomment-4286197744
# Once the bug is resolved, we can remove this warning.
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO
-DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
-DAXP_DEBUG_PORT=Serial -DAXP_DEBUG_PORT=Serial
-DCONFIG_BT_NIMBLE_ENABLED
-DCONFIG_BT_NIMBLE_MAX_BONDS=6 # default is 3
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
-DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
-DSERIAL_BUFFER_SIZE=4096 -DSERIAL_BUFFER_SIZE=4096
-DSERIAL_HAS_ON_RECEIVE -DSERIAL_HAS_ON_RECEIVE
@@ -61,13 +62,16 @@ build_flags =
lib_deps = lib_deps =
${arduino_base.lib_deps} ${arduino_base.lib_deps}
${networking_base.lib_deps} ${networking_base.lib_deps}
${networking_extra.lib_deps}
${environmental_base.lib_deps} ${environmental_base.lib_deps}
${environmental_extra.lib_deps} ${environmental_extra.lib_deps}
${radiolib_base.lib_deps} ${radiolib_base.lib_deps}
# renovate: datasource=git-refs depName=meshtastic-esp32_https_server packageName=https://github.com/meshtastic/esp32_https_server gitBranch=master # renovate: datasource=git-refs depName=meshtastic-esp32_https_server packageName=https://github.com/meshtastic/esp32_https_server gitBranch=master
https://github.com/meshtastic/esp32_https_server/archive/0c71f380390ad483ff134ad938e07f6cf1226c5b.zip https://github.com/meshtastic/esp32_https_server/archive/0c71f380390ad483ff134ad938e07f6cf1226c5b.zip
# TODO renovate # renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino
https://github.com/mverch67/libpax/archive/6f52ee989301cdabaeef00bcbf93bff55708ce2f.zip h2zero/NimBLE-Arduino@1.4.3
# renovate: datasource=git-refs depName=libpax packageName=https://github.com/dbinfrago/libpax gitBranch=master
https://github.com/dbinfrago/libpax/archive/df424747f9acb86ab07c5a206ded1e8e3650726a.zip
# renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib # renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib
lewisxhe/XPowersLib@0.3.3 lewisxhe/XPowersLib@0.3.3
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto # renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
@@ -75,30 +79,7 @@ lib_deps =
lib_ignore = lib_ignore =
segger_rtt segger_rtt
; ESP32 BLE Arduino ESP32 BLE Arduino
; BLE
; Ignore select Bluetooth libs
NimBLE-Arduino
BluetoothSerial
SimpleBLE
WiFiProv
ArduinoOTA
; Ignore pioarduino esp32 libs we don't use
ESP_I2S
ESP_NOW
ESP_SR
Insights
Matter
OpenThread
RainMaker
;SPIFFS
USB
;NetworkClientSecure
Zigbee
Micro-RTSP
; testing below
mqtt
esp-mqtt
; leave this commented out to avoid breaking Windows ; leave this commented out to avoid breaking Windows
;upload_port = /dev/ttyUSB0 ;upload_port = /dev/ttyUSB0
@@ -111,226 +92,3 @@ lib_ignore =
; customize the partition table ; customize the partition table
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables ; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
board_build.partitions = partition-table.csv board_build.partitions = partition-table.csv
custom_component_remove =
espressif/esp_hosted
espressif/esp_wifi_remote
espressif/esp_modem
espressif/esp-dsp
espressif/esp32-camera
espressif/libsodium
espressif/esp-modbus
espressif/qrcode
espressif/esp_insights
espressif/esp_diag_data_store
espressif/esp_diagnostics
espressif/esp_rainmaker
espressif/rmaker_common
espressif/network_provisioning
chmorgan/esp-libhelix-mp3
espressif/esp-tflite-micro
espressif/esp-sr
espressif/esp_matter
espressif/esp-zboss-lib
espressif/esp-zigbee-lib
espressif/mqtt
custom_sdkconfig =
; CONFIG_LOG_DEFAULT_LEVEL=4
; CONFIG_LOG_MAXIMUM_LEVEL=4
'# CONFIG_BT_NIMBLE_LOG_LEVEL_INFO is not set'
CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR=y
CONFIG_LOG_COLORS=y
CONFIG_ARDUHAL_LOG_COLORS=y
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
;
; Compiler options
;
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=n
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y
CONFIG_COMPILER_CXX_EXCEPTIONS=n
CONFIG_COMPILER_STACK_CHECK_MODE_NORM=n
CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y
CONFIG_COMPILER_DISABLE_GCC12_WARNINGS=y
CONFIG_COMPILER_DISABLE_GCC13_WARNINGS=y
CONFIG_COMPILER_DISABLE_GCC14_WARNINGS=y
CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING=n
CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y
CONFIG_ESP_GDBSTUB_ENABLED=n
CONFIG_ESP_TASK_WDT_INIT=n
CONFIG_NEWLIB_NANO_FORMAT=y
; LIBC_NEWLIB_NANO_FORMAT is enabled via 'esp32_extra.py' to allow float support
CONFIG_ESP_COREDUMP_ENABLE=n
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n
CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y
CONFIG_ESP32_ENABLE_COREDUMP=n
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=n
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=n
CONFIG_FREERTOS_USE_TRACE_FACILITY=n
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y
CONFIG_ESP_WIFI_IRAM_OPT=n
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
CONFIG_SPIRAM_CACHE_LIBCHAR_IN_IRAM=n
CONFIG_SPIRAM_CACHE_LIBSTR_IN_IRAM=n
CONFIG_SPIRAM_CACHE_LIBMISC_IN_IRAM=n
CONFIG_SPIRAM_CACHE_LIBTIME_IN_IRAM=n
CONFIG_UNITY_ENABLE_FLOAT=n
CONFIG_UNITY_ENABLE_DOUBLE=n
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
CONFIG_SUPPORT_TERMIOS=n
CONFIG_VFS_SUPPORT_TERMIOS=n
CONFIG_VFS_SUPPORT_SELECT=n
CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=n
CONFIG_WS_TRANSPORT=n
CONFIG_PPP_SUPPORT=n
CONFIG_NETWORK_PROV_NETWORK_TYPE_WIFI=n
; CONFIG_LWIP_DHCPS=n
CONFIG_LWIP_PPP_SUPPORT=n
CONFIG_LWIP_IP_FORWARD=n
CONFIG_LWIP_IPV4_NAPT=n
;
; MBEDTLS
;
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
; Switch to custom CA bundle (for Meshtastic MQTT/etc) in the future
; https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/kconfig-reference.html#certificate-bundle-configuration
; CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y
; CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH=""
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=1
; #shame
CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION=y
CONFIG_MBEDTLS_SSL_RENEGOTIATION=n
CONFIG_MBEDTLS_SSL_PROTO_DTLS=n
CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=n
CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n
CONFIG_MBEDTLS_PKCS7_C=n
CONFIG_MBEDTLS_CAMELLIA_C=n
CONFIG_MBEDTLS_CCM_C=n
CONFIG_MBEDTLS_CMAC_C=n
CONFIG_MBEDTLS_SHA512_C=n
CONFIG_MBEDTLS_X509_CRL_PARSE_C=n
CONFIG_MBEDTLS_X509_CSR_PARSE_C=n
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=n
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=n
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=n
CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=n
CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=n
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=n
CONFIG_MDNS_ENABLE_CONSOLE_CLI=n
CONFIG_MDNS_PREDEF_NETIF_AP=n
; CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=n
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=n
CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=n
CONFIG_ESP_WIFI_ENABLE_SAE_H2E=n
CONFIG_OPENTHREAD_ENABLED=n
CONFIG_ZB_ENABLED=n
CONFIG_IEEE802154_ENABLED=n
CONFIG_ESP_INSIGHTS_ENABLED=n
CONFIG_HTTPD_WS_SUPPORT=n
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n
CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=n
; using esp-idf5-https_server library instead, for now?
CONFIG_ESP_HTTPS_SERVER_ENABLE=n
;
; Builtin ESP-MQTT, we don't use this (yet?)
;
CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_MQTT_TRANSPORT_WEBSOCKET=n
CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=n
CONFIG_MQTT_PROTOCOL_311=n
;
; Ethernet
; Disabled in esp32_common, re-enable on variants that need it
;
CONFIG_ETH_ENABLED=n
CONFIG_ARDUINO_SELECTIVE_Ethernet=n
;
; Bluetooth
;
CONFIG_BLE_MESH=n
CONFIG_BT_ENABLED=y
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_NIMBLE_NVS_PERSIST=y
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n
CONFIG_BT_CONTROLLER_ENABLED=y
CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192
CONFIG_BT_NIMBLE_MAX_CCCDS=20
CONFIG_BT_NIMBLE_MAX_BONDS=6
CONFIG_BT_NIMBLE_ENABLE_PERIODIC_SYNC=n
CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV=n
CONFIG_BT_NIMBLE_EXT_SCAN=n
CONFIG_BT_NIMBLE_EXT_ADV=n
CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER=n
CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY=n
CONFIG_BT_NIMBLE_BLUFI_ENABLE=n
CONFIG_BT_NIMBLE_PROX_SERVICE=n
CONFIG_BT_NIMBLE_ANS_SERVICE=n
CONFIG_BT_NIMBLE_CTS_SERVICE=n
CONFIG_BT_NIMBLE_HTP_SERVICE=n
CONFIG_BT_NIMBLE_IPSS_SERVICE=n
CONFIG_BT_NIMBLE_TPS_SERVICE=n
CONFIG_BT_NIMBLE_IAS_SERVICE=n
CONFIG_BT_NIMBLE_LLS_SERVICE=n
CONFIG_BT_NIMBLE_SPS_SERVICE=y
CONFIG_BT_NIMBLE_HR_SERVICE=n
CONFIG_BT_NIMBLE_HID_SERVICE=n
CONFIG_BT_NIMBLE_BAS_SERVICE=n
CONFIG_BT_NIMBLE_DIS_SERVICE=n
;
; Arduino selective compilation
; Disable unused Arduino libraries to save space
;
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
CONFIG_ARDUINO_SELECTIVE_SPI=y
CONFIG_ARDUINO_SELECTIVE_Wire=y
CONFIG_ARDUINO_SELECTIVE_ESP_SR=n
CONFIG_ARDUINO_SELECTIVE_EEPROM=y
CONFIG_ARDUINO_SELECTIVE_Preferences=y
CONFIG_ARDUINO_SELECTIVE_Ticker=y
CONFIG_ARDUINO_SELECTIVE_Update=y
CONFIG_ARDUINO_SELECTIVE_Zigbee=n
CONFIG_ARDUINO_SELECTIVE_FS=y
CONFIG_ARDUINO_SELECTIVE_SD=y
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
CONFIG_ARDUINO_SELECTIVE_SPIFFS=y
CONFIG_ARDUINO_SELECTIVE_FFat=n
CONFIG_ARDUINO_SELECTIVE_LittleFS=y
CONFIG_ARDUINO_SELECTIVE_Network=y
; CONFIG_ARDUINO_SELECTIVE_Ethernet=n
CONFIG_ARDUINO_SELECTIVE_PPP=n
CONFIG_ARDUINO_SELECTIVE_Hash=y
CONFIG_ARDUINO_SELECTIVE_ArduinoOTA=n
CONFIG_ARDUINO_SELECTIVE_AsyncUDP=y
CONFIG_ARDUINO_SELECTIVE_DNSServer=n
CONFIG_ARDUINO_SELECTIVE_ESPmDNS=y
CONFIG_ARDUINO_SELECTIVE_HTTPClient=n
CONFIG_ARDUINO_SELECTIVE_Matter=n
CONFIG_ARDUINO_SELECTIVE_NetBIOS=n
CONFIG_ARDUINO_SELECTIVE_WebServer=n
CONFIG_ARDUINO_SELECTIVE_WiFi=y
CONFIG_ARDUINO_SELECTIVE_NetworkClientSecure=y
CONFIG_ARDUINO_SELECTIVE_WiFiProv=n
CONFIG_ARDUINO_SELECTIVE_BLE=y
CONFIG_ARDUINO_SELECTIVE_BluetoothSerial=n
CONFIG_ARDUINO_SELECTIVE_SimpleBLE=n
CONFIG_ARDUINO_SELECTIVE_RainMaker=n
CONFIG_ARDUINO_SELECTIVE_OpenThread=n
CONFIG_ARDUINO_SELECTIVE_Insights=n
+2 -29
View File
@@ -11,39 +11,12 @@ build_src_filter =
build_flags = build_flags =
${esp32_common.build_flags} ${esp32_common.build_flags}
-mtext-section-literals
-D ESP32_FORCE_IRAM_MEMSET
-Wl,--wrap=memset
-Wl,--wrap=memcpy
-DMESHTASTIC_EXCLUDE_AUDIO=1 -DMESHTASTIC_EXCLUDE_AUDIO=1
-DMESHTASTIC_EXCLUDE_ACCELEROMETER=1 -DMESHTASTIC_EXCLUDE_ACCELEROMETER=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-DMESHTASTIC_EXCLUDE_WEBSERVER=1 -DMESHTASTIC_EXCLUDE_WEBSERVER=1
-DMESHTASTIC_EXCLUDE_RANGETEST=1 -DMESHTASTIC_EXCLUDE_RANGETEST=1
; HACK HACK HACK this is just a proof of concept ESP32+NimBLE but these
; includes need to be done properly somehow
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/porting/nimble/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/port/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/porting/npl/freertos/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/transport/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/services/gap/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/esp-hci/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/services/gatt/include
-I${platformio.packages_dir}/framework-espidf/components/bt/host/nimble/nimble/nimble/host/util/include
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
'# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set'
'# CONFIG_BTDM_CTRL_MODE_BTDM is not set'
'# CONFIG_BT_BLUEDROID_ENABLED is not set'
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y
; Override lib_deps to use environmental_extra_no_bsec instead of environmental_extra
; BSEC library uses ~3.5KB DRAM which causes overflow on original ESP32 targets
lib_deps = lib_deps =
${arduino_base.lib_deps} ${arduino_base.lib_deps}
${networking_base.lib_deps} ${networking_base.lib_deps}
@@ -51,8 +24,8 @@ lib_deps =
${radiolib_base.lib_deps} ${radiolib_base.lib_deps}
${environmental_base.lib_deps} ${environmental_base.lib_deps}
${environmental_extra_no_bsec.lib_deps} ${environmental_extra_no_bsec.lib_deps}
# TODO renovate # renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino
https://github.com/mverch67/libpax/archive/6f52ee989301cdabaeef00bcbf93bff55708ce2f.zip h2zero/NimBLE-Arduino@1.4.3
# renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib # renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib
lewisxhe/XPowersLib@0.3.3 lewisxhe/XPowersLib@0.3.3
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto # renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
+1 -1
View File
@@ -12,7 +12,7 @@
#define ADC_CTRL 21 #define ADC_CTRL 21
#define ADC_CTRL_ENABLED LOW #define ADC_CTRL_ENABLED LOW
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_1 #define ADC_CHANNEL ADC1_CHANNEL_1
// ratio of voltage divider = 3.20 (R1=100k, R2=220k) // ratio of voltage divider = 3.20 (R1=100k, R2=220k)
#define ADC_MULTIPLIER 3.2 #define ADC_MULTIPLIER 3.2
+1 -1
View File
@@ -92,7 +92,7 @@
#define PIN_EINK_MOSI 23 // EPD_MOSI #define PIN_EINK_MOSI 23 // EPD_MOSI
#define BATTERY_PIN 35 #define BATTERY_PIN 35
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
// https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/m5paper/M5_PAPER_SCH.pdf // https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/m5paper/M5_PAPER_SCH.pdf
// https://github.com/m5stack/M5Core-Ink/blob/master/examples/Basics/FactoryTest/FactoryTest.ino#L58 // https://github.com/m5stack/M5Core-Ink/blob/master/examples/Basics/FactoryTest/FactoryTest.ino#L58
// VBAT // VBAT
+1 -1
View File
@@ -33,7 +33,7 @@
#endif #endif
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity. #define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity.
#define ADC_MULTIPLIER 2 #define ADC_MULTIPLIER 2
@@ -7,7 +7,7 @@ build_flags =
-DVTABLES_IN_FLASH=1 -DVTABLES_IN_FLASH=1
-DCONFIG_DISABLE_HAL_LOCKS=1 -DCONFIG_DISABLE_HAL_LOCKS=1
-DHAS_STK8XXX=1 -DHAS_STK8XXX=1
; -O2 -O2
-I variants/esp32/radiomaster_900_bandit -I variants/esp32/radiomaster_900_bandit
board_build.f_cpu = 240000000L board_build.f_cpu = 240000000L
upload_protocol = esptool upload_protocol = esptool
+1 -1
View File
@@ -47,7 +47,7 @@ static const uint8_t SCK = 33;
#define PIN_VBAT WB_A0 #define PIN_VBAT WB_A0
#define BATTERY_PIN PIN_VBAT #define BATTERY_PIN PIN_VBAT
#define ADC_CHANNEL ADC_CHANNEL_0 #define ADC_CHANNEL ADC1_GPIO36_CHANNEL
// https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/ // https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/
+1 -1
View File
@@ -32,7 +32,7 @@
#endif #endif
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define BATTERY_SENSE_SAMPLES 30 // Set the number of samples, It has an effect of increasing sensitivity. #define BATTERY_SENSE_SAMPLES 30 // Set the number of samples, It has an effect of increasing sensitivity.
#define ADC_MULTIPLIER 6.45 #define ADC_MULTIPLIER 6.45
#define CELL_TYPE_LION // same curve for liion/lipo #define CELL_TYPE_LION // same curve for liion/lipo
-1
View File
@@ -16,7 +16,6 @@ board_check = true
build_flags = ${esp32_base.build_flags} build_flags = ${esp32_base.build_flags}
-D TBEAM_V10 -D TBEAM_V10
-I variants/esp32/tbeam -I variants/esp32/tbeam
upload_speed = 921600 upload_speed = 921600
[env:tbeam-displayshield] [env:tbeam-displayshield]
+1 -1
View File
@@ -6,7 +6,7 @@
#define BUTTON_PIN 39 #define BUTTON_PIN 39
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define USE_RF95 #define USE_RF95
#define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_DIO0 26 // a No connect on the SX1262 module
+1 -1
View File
@@ -1,5 +1,5 @@
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define I2C_SDA 21 // I2C pins for this board #define I2C_SDA 21 // I2C pins for this board
#define I2C_SCL 22 #define I2C_SCL 22
+1 -1
View File
@@ -1,5 +1,5 @@
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define I2C_SDA 21 // I2C pins for this board #define I2C_SDA 21 // I2C pins for this board
#define I2C_SCL 22 #define I2C_SCL 22
+1 -1
View File
@@ -1,5 +1,5 @@
#define BATTERY_PIN 35 #define BATTERY_PIN 35
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define BATTERY_SENSE_SAMPLES 30 #define BATTERY_SENSE_SAMPLES 30
// ratio of voltage divider = 2.0 (R42=100k, R43=100k) // ratio of voltage divider = 2.0 (R42=100k, R43=100k)
+1 -1
View File
@@ -1,7 +1,7 @@
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
// ratio of voltage divider = 2.0 (R42=100k, R43=100k) // ratio of voltage divider = 2.0 (R42=100k, R43=100k)
#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. #define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage.
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define I2C_SDA 21 // I2C pins for this board #define I2C_SDA 21 // I2C pins for this board
#define I2C_SCL 22 #define I2C_SCL 22
+1 -1
View File
@@ -22,7 +22,7 @@
#undef BAT_MEASURE_ADC_UNIT #undef BAT_MEASURE_ADC_UNIT
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_MULTIPLIER 1.34 // tracked resistance divider is 100k+470k, so it can not fillfull well on esp32 adc #define ADC_MULTIPLIER 1.34 // tracked resistance divider is 100k+470k, so it can not fillfull well on esp32 adc
#define ADC_CHANNEL ADC_CHANNEL_7 #define ADC_CHANNEL ADC1_GPIO35_CHANNEL
#define ADC_ATTENUATION ADC_ATTEN_DB_12 // lower dB for high resistance voltage divider #define ADC_ATTENUATION ADC_ATTEN_DB_12 // lower dB for high resistance voltage divider
#undef GPS_RX_PIN #undef GPS_RX_PIN
-13
View File
@@ -5,19 +5,6 @@ custom_esp32_kind = esp32c3
monitor_speed = 115200 monitor_speed = 115200
monitor_filters = esp32_c3_exception_decoder monitor_filters = esp32_c3_exception_decoder
build_flags =
${esp32_common.build_flags}
; Linker script to align text.handler_execute section to 4 bytes
-Wl,-Tsrc/platform/esp32/align-text.handler_execute-4.ld
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
; ESP32c3 doesn't support SD_MMC
CONFIG_ARDUINO_SELECTIVE_SD_MMC=n
; CONFIG_BT_NIMBLE_EXT_ADV=y
; CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257
; CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2
lib_deps = lib_deps =
${esp32_common.lib_deps} ${esp32_common.lib_deps}
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master # renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
+37 -21
View File
@@ -1,34 +1,50 @@
[esp32c6_base] [esp32c6_base]
extends = esp32_common extends = esp32_common
custom_esp32_kind = esp32c6 platform =
# Do not renovate until we have switched to pioarduino tagged builds
https://github.com/Jason2866/platform-espressif32/archive/22faa566df8c789000f8136cd8d0aca49617af55.zip
platform_packages =
# HACK: This release was automatically removed upstream
framework-arduinoespressif32 @ https://github.com/vidplace7/platform-espressif32/releases/download/meshtastic-esp32c6/framework-arduinoespressif32-all-release_v5.1-124d64e.zip
build_flags = build_flags =
${esp32_common.build_flags} ${arduino_base.build_flags}
; Linker script to align text.handler_execute section to 4 bytes -Wall
-Wl,-Tsrc/platform/esp32/align-text.handler_execute-4.ld -Wextra
; Exclude Paxcounter, it uses 'esp_vhci_host_send_packet' whch is not available on ESP32-C6 -Isrc/platform/esp32
; https://github.com/espressif/arduino-esp32/issues/11716 -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
-DSERIAL_BUFFER_SIZE=4096
-DLIBPAX_ARDUINO
-DLIBPAX_WIFI
-DLIBPAX_BLE
-DMESHTASTIC_EXCLUDE_WEBSERVER
;-DDEBUG_HEAP
; TEMP
-DHAS_BLUETOOTH=0
-DMESHTASTIC_EXCLUDE_PAXCOUNTER -DMESHTASTIC_EXCLUDE_PAXCOUNTER
-DMESHTASTIC_EXCLUDE_BLUETOOTH
lib_deps =
${arduino_base.lib_deps}
${networking_base.lib_deps}
${environmental_base.lib_deps}
${environmental_extra.lib_deps}
${radiolib_base.lib_deps}
# renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib
lewisxhe/XPowersLib@0.3.3
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
rweather/Crypto@0.4.0
build_src_filter = build_src_filter =
${esp32_common.build_src_filter} ${esp32_common.build_src_filter} -<mesh/http>
monitor_speed = 460800 monitor_speed = 460800
monitor_filters = esp32_c3_exception_decoder monitor_filters = esp32_c3_exception_decoder
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
; ESP32c6 doesn't support SD_MMC
CONFIG_ARDUINO_SELECTIVE_SD_MMC=n
; CONFIG_BT_NIMBLE_EXT_ADV=y
; CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257
; CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2
lib_ignore = lib_ignore =
${esp32_common.lib_ignore} ${esp32_common.lib_ignore}
NonBlockingRTTTL
NimBLE-Arduino
libpax libpax
lib_deps =
${esp32_common.lib_deps}
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
@@ -17,12 +17,28 @@ board_build.partitions = default_16MB.csv
;Normal method ;Normal method
upload_protocol = esptool upload_protocol = esptool
;upload_port = /dev/ttyACM2 ;upload_port = /dev/ttyACM2
build_unflags =
-D HAS_BLUETOOTH
-D MESHTASTIC_EXCLUDE_BLUETOOTH
-D HAS_WIFI
lib_deps =
${esp32c6_base.lib_deps}
# renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino
h2zero/NimBLE-Arduino@2.3.7
build_flags = build_flags =
${esp32c6_base.build_flags} ${esp32c6_base.build_flags}
-D M5STACK_UNITC6L -D M5STACK_UNITC6L
-I variants/esp32c6/m5stack_unitc6l -I variants/esp32c6/m5stack_unitc6l
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=1
-D HAS_BLUETOOTH=1
-DCONFIG_BT_NIMBLE_EXT_ADV=1
-DCONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2
-D NIMBLE_TWO
monitor_speed=115200 monitor_speed=115200
lib_ignore =
NonBlockingRTTTL
libpax
build_src_filter = build_src_filter =
${esp32c6_base.build_src_filter} +<../variants/esp32c6/m5stack_unitc6l> ${esp32c6_base.build_src_filter} +<../variants/esp32c6/m5stack_unitc6l>
+9 -11
View File
@@ -52,25 +52,23 @@ void c6l_init()
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_CHIP_RESET, &in_data); i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_CHIP_RESET, &in_data);
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IO_DIR, 0b11100000); // P5,P6,P7 as outputs i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IO_DIR, 0b11000000); // 0: input 1: output
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_H_IM, 0b00011100); // High-Impedance i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_H_IM, 0b00111100); // 使用到的引脚关闭High-Impedance
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_SEL, 0b11100011); // pull up/down select, 0 down, 1 up i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_SEL, 0b11000011); // pull up/down select, 0 down, 1 up
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_EN, 0b11100011); // pull up/down enable, 0 disable, 1 enable i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_EN, 0b11000011); // pull up/down enable, 0 disable, 1 enable
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IN_DEF_STA, 0b00000011); // P0 P1 default to high level; button press triggers the interrupt i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IN_DEF_STA, 0b00000011); // P0 P1 默认高电平, 按键按下触发中断
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_INT_MASK, 0b11111100); // P0 P1 interrupts enabled (0 = enable, 1 = disable) i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_INT_MASK, 0b11111100); // P0 P1 中断使能 0 enable, 1 disable
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, 0b10000000); // default output is 0 i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, 0b10000000); // 默认输出为0
vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_IRQ_STA, &in_data); // read IRQ_STA to clear the flag
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_IRQ_STA, &in_data); // 读取IRQ_STA清除标志
i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, &in_data); i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, &in_data);
setbit(in_data, 6); // enable SX_ANT_SW setbit(in_data, 6); // HIGH
setbit(in_data, 5); // enable SX_LNA_EN
i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, in_data); i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, in_data);
} }
@@ -48,9 +48,6 @@ void c6l_init();
#define SSD1306_RESET 15 #define SSD1306_RESET 15
// #define OLED_DG 1 // #define OLED_DG 1
#endif #endif
// Tiny OLED panel — opts into compile-time layout/font/feature substitutions
// gated on OLED_TINY across the graphics stack.
#define OLED_TINY
#define SCREEN_TRANSITION_FRAMERATE 10 #define SCREEN_TRANSITION_FRAMERATE 10
#define BRIGHTNESS_DEFAULT 130 // Medium Low Brightness #define BRIGHTNESS_DEFAULT 130 // Medium Low Brightness
-8
View File
@@ -8,11 +8,3 @@ build_flags =
-I variants/esp32c6/tlora_c6 -I variants/esp32c6/tlora_c6
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=1
; Disable screen + audio.
; ESP32-C6 with 4MB flash is TIGHT on space.
-DMESHTASTIC_EXCLUDE_SCREEN=1
-DMESHTASTIC_EXCLUDE_AUDIO=1
lib_ignore =
${esp32c6_base.lib_ignore}
ESP32 Codec2
-110
View File
@@ -1,110 +0,0 @@
[esp32p4_base]
extends = esp32_common
custom_esp32_kind = esp32p4
board_build.mcu = esp32p4
build_unflags=
-DHAS_UDP_MULTICAST=1
build_flags =
${esp32_common.build_flags}
-DMESHTASTIC_EXCLUDE_WIFI=1 ; TODO
-DMESHTASTIC_EXCLUDE_MQTT=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
build_src_filter =
${esp32_common.build_src_filter} -<libpax/> -<platform/stm32wl> -<nimble> -<mesh/http/> -<platform/rp2xx0> -<mesh/raspihttp> -<serialization/>
extra_scripts =
${esp32_common.extra_scripts}
extra_scripts/ld_response_file.py
; Override esp32_common component pruning: keep esp_hosted + esp_wifi_remote for P4 hosted BT
custom_component_remove =
espressif/esp_modem
espressif/esp-dsp
espressif/esp32-camera
espressif/libsodium
espressif/esp-modbus
espressif/qrcode
espressif/esp_insights
espressif/esp_diag_data_store
espressif/esp_diagnostics
espressif/esp_rainmaker
espressif/rmaker_common
espressif/network_provisioning
chmorgan/esp-libhelix-mp3
espressif/esp-tflite-micro
espressif/esp-sr
espressif/esp_matter
espressif/esp-zboss-lib
espressif/esp-zigbee-lib
espressif/mqtt
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
CONFIG_BT_CONTROLLER_DISABLED=y
CONFIG_ESP_WIFI_REMOTE_ENABLED=y
# esp_hosted core
CONFIG_ESP_HOSTED_ENABLED=y
# Board: custom (not Espressif EV board)
CONFIG_ESP_HOSTED_P4_DEV_BOARD_NONE=y
# Delay after C6 reset to allow boot (e.g. old v2.3.0 may be slow)
CONFIG_ESP_HOSTED_SDIO_RESET_DELAY_MS=1500
CONFIG_ESP_HOSTED_SDIO_OPTIMIZATION_RX_STREAMING_MODE=y
CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE=y
CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET="esp32c6"
CONFIG_ESP_HOSTED_CP_TARGET_ESP32C6=y
CONFIG_ESP_HOSTED_CP_TARGET_ESP32H2=n
CONFIG_ESP_HOSTED_PRIV_SDIO_OPTION=y
CONFIG_ESP_HOSTED_SPI_HOST_INTERFACE=n
CONFIG_ESP_HOSTED_TRANSPORT_SDIO=y
CONFIG_ESP_HOSTED_ENABLE_NIMBLE=y
CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y
CONFIG_ESP_HOSTED_NIMBLE_HCI_VHCI=y
CONFIG_ESP_HOSTED_ENABLE_PEER_DATA_TRANSFER=y
CONFIG_ESP_HOSTED_MAX_CUSTOM_MSG_HANDLERS=3
# OTA method: LittleFS
CONFIG_OTA_METHOD_LITTLEFS=y
# Skip version check — we force OTA regardless
# CONFIG_OTA_VERSION_CHECK_HOST_SLAVE is not set
# CONFIG_OTA_VERSION_CHECK_SLAVEFW_SLAVE is not set
# RX streaming mode
CONFIG_ESP_HOSTED_SLAVE_RESET_ON_EVERY_HOST_BOOTUP=y
;CONFIG_ESP_HOSTED_SLAVE_RESET_ONLY_IF_NECESSARY=y
# SOC_LCD (MUI / lovyanGFX)
CONFIG_SOC_LCD_I80_SUPPORTED=y
CONFIG_SOC_LCD_RGB_SUPPORTED=y
CONFIG_SOC_MIPI_DSI_SUPPORTED=y
# stack dump
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y ; remove for production version
;CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y; for production version
;CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y ; for target debugging
# Logger: verbose for experiment
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
lib_ignore =
${esp32_common.lib_ignore}
libpax
esp8266-oled-ssd1306
bsec2
esp32_idf5_https_server
esp_driver_cam
esp_http_server
; Override lib_deps to exclude environmental_extras
lib_deps =
${arduino_base.lib_deps}
${networking_base.lib_deps}
${networking_extra.lib_deps}
${environmental_base.lib_deps}
${radiolib_base.lib_deps}
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
rweather/Crypto@0.4.0
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
+5 -10
View File
@@ -12,18 +12,13 @@ build_flags =
-DHAS_BLUETOOTH=0 -DHAS_BLUETOOTH=0
-DMESHTASTIC_EXCLUDE_PAXCOUNTER -DMESHTASTIC_EXCLUDE_PAXCOUNTER
-DMESHTASTIC_EXCLUDE_BLUETOOTH -DMESHTASTIC_EXCLUDE_BLUETOOTH
-mtext-section-literals
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
lib_ignore =
${esp32_common.lib_ignore}
NimBLE-Arduino
libpax
lib_deps = lib_deps =
${esp32_common.lib_deps} ${esp32_common.lib_deps}
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master # renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
lib_ignore =
${esp32_common.lib_ignore}
NimBLE-Arduino
libpax
+1 -1
View File
@@ -7,7 +7,7 @@
#define BUTTON_PIN 0 // BOOT button #define BUTTON_PIN 0 // BOOT button
#define BATTERY_PIN 1 #define BATTERY_PIN 1
#define ADC_CHANNEL ADC_CHANNEL_0 #define ADC_CHANNEL ADC1_GPIO1_CHANNEL
#define ADC_MULTIPLIER 103.0 // Calibrated value #define ADC_MULTIPLIER 103.0 // Calibrated value
#define ADC_ATTENUATION ADC_ATTEN_DB_0 #define ADC_ATTENUATION ADC_ATTEN_DB_0
#define ADC_CTRL 37 #define ADC_CTRL 37
+1 -1
View File
@@ -18,7 +18,7 @@
// Battery voltage monitoring - TODO: test, currently untested, copied from T3S3 variant // Battery voltage monitoring - TODO: test, currently untested, copied from T3S3 variant
#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define ADC_CHANNEL ADC_CHANNEL_0 #define ADC_CHANNEL ADC1_GPIO1_CHANNEL
#define ADC_MULTIPLIER \ #define ADC_MULTIPLIER \
2.11 // ratio of voltage divider = 2.0 (R10=1M, R13=1M), plus some undervoltage correction - TODO: this was carried over from 2.11 // ratio of voltage divider = 2.0 (R10=1M, R13=1M), plus some undervoltage correction - TODO: this was carried over from
// the T3S3, test to see if the undervoltage correction is needed. // the T3S3, test to see if the undervoltage correction is needed.
@@ -11,11 +11,6 @@ build_flags =
-I variants/esp32s3/ELECROW-ThinkNode-G3 -I variants/esp32s3/ELECROW-ThinkNode-G3
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
custom_sdkconfig =
${esp32s3_base.custom_sdkconfig}
CONFIG_ETH_ENABLED=y
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
lib_ignore = lib_ignore =
Ethernet Ethernet

Some files were not shown because too many files have changed in this diff Show More