From 15b474172a922a1c80769e75af1b15fb27f4061e Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 21 Jan 2026 17:33:50 +0800 Subject: [PATCH 01/67] Added compatibility with LilyGo T-Deck-Pro V1.1 --- src/detect/ScanI2C.h | 3 +- src/detect/ScanI2CTwoWire.cpp | 27 +++- src/graphics/EInkDisplay2.cpp | 3 + src/main.cpp | 4 + .../extra_variants/t_deck_pro/variant.cpp | 116 +++++++++++++++++- .../esp32s3/t-deck-pro-v1_1/pins_arduino.h | 19 +++ .../esp32s3/t-deck-pro-v1_1/platformio.ini | 41 +++++++ variants/esp32s3/t-deck-pro-v1_1/variant.h | 106 ++++++++++++++++ 8 files changed, 312 insertions(+), 7 deletions(-) create mode 100644 variants/esp32s3/t-deck-pro-v1_1/pins_arduino.h create mode 100644 variants/esp32s3/t-deck-pro-v1_1/platformio.ini create mode 100644 variants/esp32s3/t-deck-pro-v1_1/variant.h diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index dffcd8fb6..7b6fdc7a2 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -88,7 +88,8 @@ class ScanI2C BH1750, DA217, CHSC6X, - CST226SE + CST226SE, + CST3530, } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index c6ef34846..cb20a85c7 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -508,8 +508,33 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address); SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address); SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address); + case CST328_ADDR: - // Do we have the CST328 or the CST226SE + // Do we have the CST328 or the CST226SE,CST3530 + { + // T-Deck pro V1.1 new touch panel use CST3530 + int retry = 5; + while(retry--) { + uint8_t buffer[7]; + uint8_t r_cmd[] = {0x0d0,0x03,0x00,0x00}; + i2cBus->beginTransmission(addr.address); + i2cBus->write(r_cmd, sizeof(r_cmd)); + if(i2cBus->endTransmission() == 0){ + i2cBus->requestFrom((int)addr.address,7); + i2cBus->readBytes(buffer,7); + if(buffer[2] == 0xCA && buffer[3] == 0xCA){ + logFoundDevice("CST3530", (uint8_t)addr.address); + type = CST3530; + break; + } + } + uint8_t cmd1[] = {0xD0,0x00,0x04,0x00}; + i2cBus->beginTransmission(addr.address); + i2cBus->write(cmd1, sizeof(cmd1)); + i2cBus->endTransmission(); + delay(50); + } + } registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xAB), 1); if (registerValue == 0xA9) { type = CST226SE; diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 1678da793..6f53a56b9 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -104,8 +104,11 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) // End the update process - virtual method, overriden in derived class void EInkDisplay::endUpdate() { +#ifndef EINK_NOT_HIBERNATE // Power off display hardware, then deep-sleep (Except Wireless Paper V1.1, no deep-sleep) adafruitDisplay->hibernate(); +#endif + } // Write the buffer to the display memory diff --git a/src/main.cpp b/src/main.cpp index c1096a240..d28dbb809 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -413,6 +413,10 @@ void setup() digitalWrite(SDCARD_CS, HIGH); pinMode(PIN_EINK_CS, OUTPUT); digitalWrite(PIN_EINK_CS, HIGH); + pinMode(PIN_EINK_RES, OUTPUT); + digitalWrite(PIN_EINK_RES, HIGH); + pinMode(CST328_PIN_RST, OUTPUT); + digitalWrite(CST328_PIN_RST, HIGH); #elif defined(T_LORA_PAGER) pinMode(LORA_CS, OUTPUT); digitalWrite(LORA_CS, HIGH); diff --git a/src/platform/extra_variants/t_deck_pro/variant.cpp b/src/platform/extra_variants/t_deck_pro/variant.cpp index eae9335ce..77fba53b9 100644 --- a/src/platform/extra_variants/t_deck_pro/variant.cpp +++ b/src/platform/extra_variants/t_deck_pro/variant.cpp @@ -8,20 +8,126 @@ CSE_CST328 tsPanel = CSE_CST328(EINK_WIDTH, EINK_HEIGHT, &Wire, CST328_PIN_RST, CST328_PIN_INT); +static bool is_cst3530 = false; +volatile bool touch_isr = false; +#define CST3530_ADDR 0x1A + +bool read_cst3530_touch(int16_t *x, int16_t *y) { + uint8_t buffer[9] = {0}; + uint8_t r_cmd[] = {0xD0, 0x07, 0x00, 0x00}; + uint8_t clear_cmd[] = {0xD0, 0x00, 0x02, 0xAB}; + + Wire.beginTransmission(CST3530_ADDR); + Wire.write(r_cmd, sizeof(r_cmd)); + if (Wire.endTransmission() != 0) { + LOG_DEBUG("CST3530 I2C send addr failed"); + return false; + } + + int read_len = Wire.requestFrom((int)CST3530_ADDR, sizeof(buffer)); + if (read_len != sizeof(buffer)) { + LOG_DEBUG("CST3530 read len error: %d (expect 9)", read_len); + return false; + } + int actual_read = Wire.readBytes(buffer, sizeof(buffer)); + if (actual_read != sizeof(buffer)) { + LOG_DEBUG("CST3530 read bytes error: %d (expect 9)", actual_read); + return false; + } + + uint8_t report_typ = buffer[2]; + if (report_typ != 0xFF) { + return false; + } + + uint8_t touch_points = buffer[3] & 0x0F; + if (touch_points == 0 || touch_points > 1) { + LOG_DEBUG("CST3530 touch points invalid: %d", touch_points); + return false; + } + + *x = buffer[4] + ((uint16_t)(buffer[7] & 0x0F) << 8); + *y = buffer[5] + ((uint16_t)(buffer[7] & 0xF0) << 4); + + // LOG_DEBUG("CST3530 touch: num:%d x=%d,y=%d", touch_points, *x, *y); + + Wire.beginTransmission(CST3530_ADDR); + Wire.write(clear_cmd, sizeof(clear_cmd)); + if (Wire.endTransmission() != 0) { + LOG_DEBUG("CST3530 clear cmd failed"); + } + + return true; +} + bool readTouch(int16_t *x, int16_t *y) { - if (tsPanel.getTouches()) { - *x = tsPanel.getPoint(0).x; - *y = tsPanel.getPoint(0).y; - return true; + + if(is_cst3530){ + if(touch_isr){ + touch_isr = false; + return read_cst3530_touch(x, y); + } + return false; + }else{ + if (tsPanel.getTouches()) { + *x = tsPanel.getPoint(0).x; + *y = tsPanel.getPoint(0).y; + return true; + } } return false; } + +static void touchInterruptHandler(){ + touch_isr = true; +} + // T-Deck Pro specific init void lateInitVariant() { - tsPanel.begin(); + // Reset touch + pinMode(CST328_PIN_RST, OUTPUT); + digitalWrite(CST328_PIN_RST, HIGH); + delay(20); + digitalWrite(CST328_PIN_RST, LOW); + delay(80); + digitalWrite(CST328_PIN_RST, HIGH); + delay(20); + + int retry = 5; + uint8_t buffer[7]; + uint8_t r_cmd[] = {0x0d0,0x03,0x00,0x00}; + + // Probe touch chip + while(retry--) { + Wire.beginTransmission(CST3530_ADDR); + Wire.write(r_cmd, sizeof(r_cmd)); + if(Wire.endTransmission() == 0){ + Wire.requestFrom((int)CST3530_ADDR,7); + Wire.readBytes(buffer,7); + if(buffer[2] == 0xCA && buffer[3] == 0xCA){ + LOG_DEBUG("CST3530 detected"); + is_cst3530 = true; + + // The CST3530 will automatically enter sleep mode; + // polling should not be used, but rather an interrupt method should be employed. + pinMode(CST328_PIN_INT, INPUT); + attachInterrupt(digitalPinToInterrupt(CST328_PIN_INT), touchInterruptHandler, FALLING); + + break; + }else{ + LOG_DEBUG("CST3530 not response ~!"); + } + } + uint8_t cmd1[] = {0xD0,0x00,0x04,0x00}; + Wire.beginTransmission(CST3530_ADDR); + Wire.write(cmd1, sizeof(cmd1)); + Wire.endTransmission(); + delay(50); + } + touchScreenImpl1 = new TouchScreenImpl1(EINK_WIDTH, EINK_HEIGHT, readTouch); touchScreenImpl1->init(); } diff --git a/variants/esp32s3/t-deck-pro-v1_1/pins_arduino.h b/variants/esp32s3/t-deck-pro-v1_1/pins_arduino.h new file mode 100644 index 000000000..af0ba80b3 --- /dev/null +++ b/variants/esp32s3/t-deck-pro-v1_1/pins_arduino.h @@ -0,0 +1,19 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// used for keyboard, touch controller, beam sensor, and gyroscope +static const uint8_t SDA = 13; +static const uint8_t SCL = 14; + +// Default SPI will be mapped to Radio +static const uint8_t SS = 3; +static const uint8_t MOSI = 33; +static const uint8_t MISO = 47; +static const uint8_t SCK = 36; + +#endif /* Pins_Arduino_h */ diff --git a/variants/esp32s3/t-deck-pro-v1_1/platformio.ini b/variants/esp32s3/t-deck-pro-v1_1/platformio.ini new file mode 100644 index 000000000..b76522934 --- /dev/null +++ b/variants/esp32s3/t-deck-pro-v1_1/platformio.ini @@ -0,0 +1,41 @@ +[env:t-deck-pro-v1_1] +custom_meshtastic_hw_model = 102 +custom_meshtastic_hw_model_slug = T_DECK_PRO +custom_meshtastic_architecture = esp32-s3 +custom_meshtastic_actively_supported = true +custom_meshtastic_support_level = 1 +custom_meshtastic_display_name = LILYGO T-Deck Pro +custom_meshtastic_images = tdeck_pro.svg +custom_meshtastic_tags = LilyGo +custom_meshtastic_requires_dfu = true +custom_meshtastic_partition_scheme = 16MB + +extends = esp32s3_base +board = t-deck-pro +board_check = true +upload_protocol = esptool + +build_flags = + ${esp32s3_base.build_flags} -I variants/esp32s3/t-deck-pro-v1_1 + -D T_DECK_PRO + -D USE_EINK + -D EINK_DISPLAY_MODEL=GxEPD2_310_GDEQ031T10 + -D EINK_WIDTH=240 + -D EINK_HEIGHT=320 + ;-D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk + -D EINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted + -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated + -D EINK_NOT_HIBERNATE ; Disable hibernate to avoid issues with elink + +lib_deps = + ${esp32s3_base.lib_deps} + # renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2 + zinggjm/GxEPD2@1.6.5 + # renovate: datasource=git-refs depName=CSE_Touch packageName=https://github.com/CIRCUITSTATE/CSE_Touch gitBranch=main + https://github.com/CIRCUITSTATE/CSE_Touch/archive/b44f23b6f870b848f1fbe453c190879bc6cfaafa.zip + # renovate: datasource=github-tags depName=CSE_CST328 packageName=CIRCUITSTATE/CSE_CST328 + https://github.com/CIRCUITSTATE/CSE_CST328/archive/refs/tags/v0.0.4.zip + # renovate: datasource=git-refs depName=BQ27220 packageName=https://github.com/mverch67/BQ27220 gitBranch=main + https://github.com/mverch67/BQ27220/archive/07d92be846abd8a0258a50c23198dac0858b22ed.zip + # renovate: datasource=custom.pio depName=Adafruit DRV2605 packageName=adafruit/library/Adafruit DRV2605 Library + adafruit/Adafruit DRV2605 Library@1.2.4 diff --git a/variants/esp32s3/t-deck-pro-v1_1/variant.h b/variants/esp32s3/t-deck-pro-v1_1/variant.h new file mode 100644 index 000000000..8584fd8a1 --- /dev/null +++ b/variants/esp32s3/t-deck-pro-v1_1/variant.h @@ -0,0 +1,106 @@ +// Display (E-Ink) +#define PIN_EINK_CS 34 +#define PIN_EINK_BUSY 37 +#define PIN_EINK_DC 35 +#define PIN_EINK_RES 16 +#define PIN_EINK_SCLK 36 +#define PIN_EINK_MOSI 47 +#define TFT_BL 45 // option , default not backlight + +#define I2C_SDA SDA +#define I2C_SCL SCL + +// CST328 touch screen (implementation in src/platform/extra_variants/t_deck_pro/variant.cpp) +#define HAS_TOUCHSCREEN 1 +#define CST328_PIN_INT 12 +#define CST328_PIN_RST 38 + +#define USE_POWERSAVE +#define SLEEP_TIME 120 + +// GNNS +#define HAS_GPS 1 +#define GPS_BAUDRATE 38400 +#define PIN_GPS_EN 39 +#define GPS_EN_ACTIVE 1 +#define GPS_RX_PIN 44 +#define GPS_TX_PIN 43 +#define PIN_GPS_PPS 1 + +#define BUTTON_PIN 0 + +// vibration motor +#define HAS_DRV2605 +#define PIN_DRV_EN 2 + +// Have SPI interface SD card slot +#define HAS_SDCARD +#define SDCARD_USE_SPI1 +#define SPI_MOSI (33) +#define SPI_SCK (36) +#define SPI_MISO (47) +#define SPI_CS (48) +#define SDCARD_CS SPI_CS +#define SD_SPI_FREQUENCY 75000000U + +// TCA8418 keyboard +#define KB_BL_PIN 42 +#define CANNED_MESSAGE_MODULE_ENABLE 1 + +// microphone PCM5102A +#define PCM5102A_SCK 47 +#define PCM5102A_DIN 17 +#define PCM5102A_LRCK 18 + +// LTR_553ALS light sensor +#define HAS_LTR553ALS + +// gyroscope BHI260AP +// #define BOARD_1V8_EN 38 //Deck-Pro remove 1.8v en pin +#define HAS_BHI260AP + +// battery charger BQ25896 +#define HAS_PPM 1 +#define XPOWERS_CHIP_BQ25896 + +// battery quality management BQ27220 +#define HAS_BQ27220 1 +#define BQ27220_I2C_SDA SDA +#define BQ27220_I2C_SCL SCL +#define BQ27220_DESIGN_CAPACITY 1400 + +// LoRa +#define USE_SX1262 +#define USE_SX1268 + +#define LORA_EN 46 // LoRa enable pin +#define LORA_SCK 36 +#define LORA_MISO 47 +#define LORA_MOSI 33 +#define LORA_CS 3 + +#define LORA_DIO0 -1 // a No connect on the SX1262 module +#define LORA_RESET 4 +#define LORA_DIO1 5 // SX1262 IRQ +#define LORA_DIO2 6 // SX1262 BUSY +#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#define SX126X_CS LORA_CS // FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +// Not really an E22 but TTGO seems to be trying to clone that +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 2.4 +// Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface +// code) + +#define MODEM_POWER_EN 41 +#define MODEM_PWRKEY 40 +#define MODEM_RST 9 +#define MODEM_RI 7 +#define MODEM_DTR 8 +#define MODEM_RX 10 +#define MODEM_TX 11 + +#define HAS_PHYSICAL_KEYBOARD 1 \ No newline at end of file From 197226365b61fd7c90fa43735ad4b6737b571cb2 Mon Sep 17 00:00:00 2001 From: Bob Iannucci Date: Sun, 12 Apr 2026 20:41:25 -0700 Subject: [PATCH 02/67] fix(native): implement BinarySemaphorePosix with proper pthread synchronization (#9895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(native): implement BinarySemaphorePosix with proper pthread synchronization The BinarySemaphorePosix class (used on all Linux/portduino/native builds) had stub implementations: give() was a no-op and take() just called delay(msec) and returned false. This broke the cooperative thread scheduler on native platforms — threads could not wake the main loop, radio RX interrupts were missed, and telemetry never transmitted over the mesh. Replace the stubs with a proper binary semaphore using pthread_mutex_t + pthread_cond_t + bool signaled: - take(msec): pthread_cond_timedwait with CLOCK_REALTIME timeout, consumes signal atomically (binary semaphore semantics) - give(): sets signaled=true, signals condition variable - giveFromISR(): delegates to give(), sets pxHigherPriorityTaskWoken Tested on Raspberry Pi 3 Model B (ARM64, Debian Bookworm) with Adafruit LoRa Radio Bonnet (SX1276). Before fix: no radio TX/RX, no telemetry on mesh. After fix: bidirectional LoRa, MQTT gateway, telemetry all working. Co-Authored-By: Claude Opus 4.6 * ARCH_PORTDUINO * Refactor BinarySemaphorePosix header for ARCH_PORTDUINO * Change preprocessor directive from ifndef to ifdef * Gate new Semaphore code to Portduino and fix STM compilation * Binary Semaphore Posix better error handling --------- Co-authored-by: Claude Opus 4.6 Co-authored-by: Ben Meadors Co-authored-by: Jonathan Bennett --- src/concurrency/BinarySemaphorePosix.cpp | 78 +++++++++++++++++++++++- src/concurrency/BinarySemaphorePosix.h | 13 +++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/src/concurrency/BinarySemaphorePosix.cpp b/src/concurrency/BinarySemaphorePosix.cpp index dc49a489b..4bc60c31f 100644 --- a/src/concurrency/BinarySemaphorePosix.cpp +++ b/src/concurrency/BinarySemaphorePosix.cpp @@ -1,10 +1,85 @@ #include "concurrency/BinarySemaphorePosix.h" #include "configuration.h" +#include +#include + #ifndef HAS_FREE_RTOS namespace concurrency { +#ifdef ARCH_PORTDUINO + +BinarySemaphorePosix::BinarySemaphorePosix() +{ + if (pthread_mutex_init(&mutex, NULL) != 0) { + throw std::runtime_error("pthread_mutex_init failed"); + } + if (pthread_cond_init(&cond, NULL) != 0) { + pthread_mutex_destroy(&mutex); + throw std::runtime_error("pthread_cond_init failed"); + } + signaled = false; +} + +BinarySemaphorePosix::~BinarySemaphorePosix() +{ + pthread_cond_destroy(&cond); + pthread_mutex_destroy(&mutex); +} + +/** + * Returns false if we timed out + */ +bool BinarySemaphorePosix::take(uint32_t msec) +{ + pthread_mutex_lock(&mutex); + + if (!signaled) { + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + + ts.tv_sec += msec / 1000; + ts.tv_nsec += (msec % 1000) * 1000000L; + if (ts.tv_nsec >= 1000000000L) { + ts.tv_sec += 1; + ts.tv_nsec -= 1000000000L; + } + + while (!signaled) { + int rc = pthread_cond_timedwait(&cond, &mutex, &ts); + if (rc == ETIMEDOUT) + break; + if (rc != 0) { + // Some other error occurred + pthread_mutex_unlock(&mutex); + throw std::runtime_error("pthread_cond_timedwait failed: " + std::to_string(rc)); + } + } + } + + bool wasSignaled = signaled; + signaled = false; // consume the signal (binary semaphore) + + pthread_mutex_unlock(&mutex); + return wasSignaled; +} + +void BinarySemaphorePosix::give() +{ + pthread_mutex_lock(&mutex); + signaled = true; + pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); +} + +IRAM_ATTR void BinarySemaphorePosix::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) +{ + give(); + if (pxHigherPriorityTaskWoken) + *pxHigherPriorityTaskWoken = true; +} +#else BinarySemaphorePosix::BinarySemaphorePosix() {} @@ -22,7 +97,8 @@ bool BinarySemaphorePosix::take(uint32_t msec) void BinarySemaphorePosix::give() {} IRAM_ATTR void BinarySemaphorePosix::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) {} +#endif } // namespace concurrency -#endif \ No newline at end of file +#endif diff --git a/src/concurrency/BinarySemaphorePosix.h b/src/concurrency/BinarySemaphorePosix.h index 475b29874..80edb567b 100644 --- a/src/concurrency/BinarySemaphorePosix.h +++ b/src/concurrency/BinarySemaphorePosix.h @@ -2,6 +2,10 @@ #include "../freertosinc.h" +#ifdef ARCH_PORTDUINO +#include +#endif + namespace concurrency { @@ -9,7 +13,12 @@ namespace concurrency class BinarySemaphorePosix { - // SemaphoreHandle_t semaphore; + +#ifdef ARCH_PORTDUINO + pthread_mutex_t mutex; + pthread_cond_t cond; + bool signaled; +#endif public: BinarySemaphorePosix(); @@ -27,4 +36,4 @@ class BinarySemaphorePosix #endif -} // namespace concurrency \ No newline at end of file +} // namespace concurrency From 752723313078d787b3c559889437afc3329fb3c1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 13 Apr 2026 06:43:11 -0500 Subject: [PATCH 03/67] Enhance release notes generation with commit range comparison --- .github/workflows/main_matrix.yml | 6 ++- bin/generate_release_notes.py | 83 ++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index f0b16a31f..88395600a 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -301,10 +301,12 @@ jobs: id: release_notes run: | chmod +x ./bin/generate_release_notes.py - NOTES=$(./bin/generate_release_notes.py ${{ needs.version.outputs.long }}) + NOTES=$(./bin/generate_release_notes.py ${{ needs.version.outputs.long }} --compare-ref HEAD 2>release_notes.log) echo "notes<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + echo "### Release note range" >> $GITHUB_STEP_SUMMARY + cat release_notes.log >> $GITHUB_STEP_SUMMARY env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -466,7 +468,7 @@ jobs: - name: Generate release notes run: | chmod +x ./bin/generate_release_notes.py - ./bin/generate_release_notes.py ${{ needs.version.outputs.long }} > ./publish/release_notes.md + ./bin/generate_release_notes.py ${{ needs.version.outputs.long }} --compare-ref HEAD > ./publish/release_notes.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bin/generate_release_notes.py b/bin/generate_release_notes.py index d0f1147da..533ff6909 100755 --- a/bin/generate_release_notes.py +++ b/bin/generate_release_notes.py @@ -1,25 +1,31 @@ #!/usr/bin/env python3 -""" -Generate release notes from merged PRs on develop and master branches. -Categorizes PRs into Enhancements and Bug Fixes/Maintenance sections. -""" +"""Generate release notes from the actual release commit range.""" -import subprocess -import re +import argparse import json +import re +import subprocess import sys -from datetime import datetime -def get_last_release_tag(): - """Get the most recent release tag.""" +def get_last_release_tag(compare_ref, exclude_tag=None): + """Get the most recent version tag merged into compare_ref.""" result = subprocess.run( - ["git", "describe", "--tags", "--abbrev=0"], + ["git", "tag", "--merged", compare_ref, "--sort=-version:refname", "v*"], capture_output=True, text=True, check=True, ) - return result.stdout.strip() + + for line in result.stdout.splitlines(): + candidate = line.strip() + if not candidate: + continue + if exclude_tag and candidate == exclude_tag: + continue + return candidate + + raise subprocess.CalledProcessError(result.returncode, result.args, output=result.stdout, stderr=result.stderr) def get_tag_date(tag): @@ -33,18 +39,18 @@ def get_tag_date(tag): return result.stdout.strip() -def get_merged_prs_since_tag(tag, branch): - """Get all merged PRs since the given tag on the specified branch.""" - # Get commits since tag on the branch - look for PR numbers in parentheses +def get_merged_prs_in_range(tag, compare_ref): + """Get all merged PRs in the git range between tag and compare_ref.""" result = subprocess.run( [ "git", "log", - f"{tag}..origin/{branch}", + f"{tag}..{compare_ref}", "--oneline", ], capture_output=True, text=True, + check=True, ) prs = [] @@ -65,6 +71,25 @@ def get_merged_prs_since_tag(tag, branch): return prs +def parse_args(): + """Parse CLI arguments.""" + parser = argparse.ArgumentParser( + description="Generate release notes from the actual release commit range." + ) + parser.add_argument("new_version", help="Version that will be tagged for this release") + parser.add_argument( + "--base-tag", + dest="base_tag", + help="Existing version tag to diff from. Defaults to the latest version tag merged into the compare ref.", + ) + parser.add_argument( + "--compare-ref", + default="HEAD", + help="Git ref to diff to. Defaults to HEAD.", + ) + return parser.parse_args() + + def get_pr_details(pr_number): """Get PR details from GitHub API via gh CLI.""" try: @@ -268,28 +293,28 @@ def get_new_contributors(pr_details_list, tag, repo="meshtastic/firmware"): def main(): - if len(sys.argv) < 2: - print("Usage: generate_release_notes.py ", file=sys.stderr) - sys.exit(1) - - new_version = sys.argv[1] + args = parse_args() + new_version = args.new_version + compare_ref = args.compare_ref + current_tag = f"v{new_version}" # Get last release tag try: - last_tag = get_last_release_tag() + last_tag = args.base_tag or get_last_release_tag(compare_ref, exclude_tag=current_tag) except subprocess.CalledProcessError: print("Error: Could not find last release tag", file=sys.stderr) sys.exit(1) - # Collect PRs from both branches - all_pr_numbers = set() + print( + f"Resolved release note range: {last_tag}..{compare_ref}", + file=sys.stderr, + ) - for branch in ["develop", "master"]: - try: - prs = get_merged_prs_since_tag(last_tag, branch) - all_pr_numbers.update(prs) - except Exception as e: - print(f"Warning: Could not get PRs from {branch}: {e}", file=sys.stderr) + try: + all_pr_numbers = set(get_merged_prs_in_range(last_tag, compare_ref)) + except subprocess.CalledProcessError as e: + print(f"Error: Could not get PRs for range {last_tag}..{compare_ref}: {e}", file=sys.stderr) + sys.exit(1) # Get details for all PRs enhancements = [] From e42ff3590c7aad731a0f382ad5f605e002a5d181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 13 Apr 2026 15:48:30 +0200 Subject: [PATCH 04/67] fix last cppcheck issue (#10154) --- src/input/CardputerKeyboard.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/input/CardputerKeyboard.cpp b/src/input/CardputerKeyboard.cpp index ec1ed383a..1bd695461 100644 --- a/src/input/CardputerKeyboard.cpp +++ b/src/input/CardputerKeyboard.cpp @@ -121,7 +121,6 @@ void CardputerKeyboard::pressed(uint8_t key) modifierFlag = 0; } - uint8_t next_key = 0; int row = (key - 1) / 10; int col = (key - 1) % 10; From 96dd647882fd04fb70f796552763b4fea2712047 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 13 Apr 2026 14:50:51 -0500 Subject: [PATCH 05/67] Fix heap blowout on TBeams (#10155) * Fix heap blowout on TBeams * Update src/graphics/draw/MessageRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Set MESSAGE_HISTORY_LIMIT to 10 for original ESP32 to optimize RAM usage * Optimize message frame allocation to prevent excessive memory usage * Refine message history limits for resource-constrained builds and cap cached lines to prevent heap overflow * Update src/graphics/draw/MessageRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/MessageStore.h | 7 +++++++ src/graphics/draw/MessageRenderer.cpp | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/MessageStore.h b/src/MessageStore.h index 6203d8ed0..77271f1c9 100644 --- a/src/MessageStore.h +++ b/src/MessageStore.h @@ -21,8 +21,15 @@ // How many messages are stored (RAM + flash). // Define -DMESSAGE_HISTORY_LIMIT=N in build_flags to control memory usage. #ifndef MESSAGE_HISTORY_LIMIT +#if defined(ARCH_ESP32) && \ + !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2)) +// Baseline ESP32 (non-PSRAM variants) has limited heap; reduce message history on resource-constrained builds. +// Override with -DMESSAGE_HISTORY_LIMIT=N if needed. +#define MESSAGE_HISTORY_LIMIT 10 +#else #define MESSAGE_HISTORY_LIMIT 20 #endif +#endif // Internal alias used everywhere in code – do NOT redefine elsewhere. #define MAX_MESSAGES_SAVED MESSAGE_HISTORY_LIMIT diff --git a/src/graphics/draw/MessageRenderer.cpp b/src/graphics/draw/MessageRenderer.cpp index 501a7ae2c..2fd9bf541 100644 --- a/src/graphics/draw/MessageRenderer.cpp +++ b/src/graphics/draw/MessageRenderer.cpp @@ -422,6 +422,17 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 std::vector isMine; // track alignment std::vector isHeader; // track header lines std::vector ackForLine; + // Hard limit on total cached lines to prevent unbounded growth from a single long message. + // Reserve to the actual cache cap up front, because a single message can expand to many more + // wrapped display lines than a small per-message estimate would predict. For a display + // rendering only ~5-30 lines at a time, caching more than this limit wastes heap. Stop + // appending once we reach MAX_CACHED_LINES to prevent a single message from blowing out the + // heap. + constexpr size_t MAX_CACHED_LINES = 100U; // ~5-6KB for std::string overhead on 32-bit (if each ~50-60 bytes avg) + allLines.reserve(MAX_CACHED_LINES); + isMine.reserve(MAX_CACHED_LINES); + isHeader.reserve(MAX_CACHED_LINES); + ackForLine.reserve(MAX_CACHED_LINES); for (auto it = filtered.rbegin(); it != filtered.rend(); ++it) { const auto &m = *it; @@ -565,16 +576,23 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 int wrapWidth = mine ? rightTextWidth : leftTextWidth; std::vector wrapped = generateLines(display, "", msgText, wrapWidth); + // Per-message wrap-line limit: even if wrapping produces many lines, cap them to prevent + // a single long message from consuming most or all of the cache. + constexpr size_t MAX_WRAPPED_LINES_PER_MSG = 20U; + size_t wrappedCount = 0; for (auto &ln : wrapped) { - allLines.push_back(ln); + if (allLines.size() >= MAX_CACHED_LINES || wrappedCount >= MAX_WRAPPED_LINES_PER_MSG) + break; // Cache limit or per-message limit reached; stop adding lines from this message + allLines.emplace_back(std::move(ln)); isMine.push_back(mine); isHeader.push_back(false); ackForLine.push_back(AckStatus::NONE); + ++wrappedCount; } } // Cache lines and heights - cachedLines = allLines; + cachedLines.swap(allLines); cachedHeights = calculateLineHeights(cachedLines, emotes, isHeader); std::vector blocks = buildMessageBlocks(isHeader, isMine); From d6cf67b6bc176aefc38b637e72bf031a89198903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 14 Apr 2026 12:19:58 +0200 Subject: [PATCH 06/67] Clarify behavior when no radio instance is present Add comment explaining silent behavior when no radio instance is available. --- src/mesh/HardwareRNG.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/HardwareRNG.cpp b/src/mesh/HardwareRNG.cpp index b455128ac..f5a805487 100644 --- a/src/mesh/HardwareRNG.cpp +++ b/src/mesh/HardwareRNG.cpp @@ -48,7 +48,8 @@ bool mixWithLoRaEntropy(uint8_t *buffer, size_t length) // and return false so callers know no extra mixing occurred. RadioLibInterface *radio = RadioLibInterface::instance; if (!radio) { - LOG_ERROR("No radio instance available to provide entropy"); + // Intentionally silent: this path runs during portduinoSetup() before the + // console/SerialConsole is initialized, so LOG_* here would dereference a null pointer. return false; } From 125c1b7f13d91b6d9c0dc7504940dd45e1d5b864 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 14 Apr 2026 06:41:04 -0500 Subject: [PATCH 07/67] Make consoleInit() Reentrant, and initialize it earlier on native (#10156) --- src/SerialConsole.cpp | 3 +++ src/platform/portduino/PortduinoGlue.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index e24aa3c57..2a3f08cbc 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -30,6 +30,9 @@ SerialConsole *console; void consoleInit() { + if (console) { + return; + } auto sc = new SerialConsole(); // Must be dynamically allocated because we are now inheriting from thread #if defined(SERIAL_HAS_ON_RECEIVE) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 9e0a1b2a5..5f51ee083 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -182,6 +182,10 @@ void portduinoSetup() // Force stdout to be line buffered setvbuf(stdout, stdoutBuffer, _IOLBF, sizeof(stdoutBuffer)); + // We do this super early so that we can log from the rest of the init code + concurrency::hasBeenSetup = true; + consoleInit(); + if (portduino_config.force_simradio == true) { portduino_config.lora_module = use_simradio; } else if (configPath != nullptr) { From 01bd4cfb73bb7bc20ea4cf08c36d66c45b4bea35 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Tue, 14 Apr 2026 19:46:33 +0800 Subject: [PATCH 08/67] feat(stm32wl): add reboot-to-bootloader support via enter_dfu_mode_request (#10158) --- src/modules/AdminModule.cpp | 2 +- src/platform/stm32wl/main-stm32wl.cpp | 51 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 9a52a9aff..05bc0aa5d 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -480,7 +480,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta #if HAS_SCREEN IF_SCREEN(screen->showSimpleBanner("Device is rebooting\ninto DFU mode.", 0)); #endif -#if defined(ARCH_NRF52) || defined(ARCH_RP2040) +#if defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL) enterDfuMode(); #endif break; diff --git a/src/platform/stm32wl/main-stm32wl.cpp b/src/platform/stm32wl/main-stm32wl.cpp index 93080f840..241020126 100644 --- a/src/platform/stm32wl/main-stm32wl.cpp +++ b/src/platform/stm32wl/main-stm32wl.cpp @@ -4,6 +4,57 @@ #include #include +// ─── Bootloader redirect ────────────────────────────────────────────────────── +// +// Why .noinit + constructor instead of TAMP backup registers: +// +// The STM32duino startup sequence initialises clocks which may call +// __HAL_RCC_BACKUPRESET_FORCE/RELEASE when configuring the LSE oscillator, +// wiping the entire backup domain (including TAMP->BKP0R) before setup() +// ever runs. The backup-register approach therefore cannot reliably survive +// a soft reset in this toolchain. +// +// Solution: store the magic in a .noinit SRAM variable. +// - NVIC_SystemReset() does NOT clear SRAM. +// - The linker script skips zero-init for .noinit sections. +// - __attribute__((constructor)) fires before main()/HAL_Init(), so we can +// intercept and jump before anything disturbs peripheral state. + +#define BOOTLOADER_MAGIC 0xD00DB007UL +#define SYS_MEM_BASE 0x1FFF0000UL + +// Placed in .noinit — not zeroed at startup, survives NVIC_SystemReset(). +__attribute__((section(".noinit"), used)) volatile uint32_t g_bootloaderMagic; + +// Fires before main() / HAL_Init(). Must use only core Cortex-M registers. +__attribute__((constructor(101), used)) static void earlyBootCheck(void) +{ + if (g_bootloaderMagic != BOOTLOADER_MAGIC) + return; + g_bootloaderMagic = 0; + + SysTick->CTRL = 0; + SysTick->LOAD = 0; + SysTick->VAL = 0; + for (int i = 0; i < 8; i++) { + NVIC->ICER[i] = 0xFFFFFFFF; + NVIC->ICPR[i] = 0xFFFFFFFF; + } + __DSB(); + __ISB(); + SCB->VTOR = SYS_MEM_BASE; + __set_MSP(*(volatile uint32_t *)SYS_MEM_BASE); + ((void (*)(void))(*(volatile uint32_t *)(SYS_MEM_BASE + 4)))(); + while (1) + ; +} + +void enterDfuMode() +{ + g_bootloaderMagic = BOOTLOADER_MAGIC; + HAL_NVIC_SystemReset(); +} + void setBluetoothEnable(bool enable) {} void playStartMelody() {} From 00fccd87f9f8776f5b9dec0a898bbbd9a2fa66ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:27:05 +0200 Subject: [PATCH 09/67] Update protobufs (#10161) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/atak.pb.cpp | 51 + src/mesh/generated/meshtastic/atak.pb.h | 928 ++++++++++++++++++- src/mesh/generated/meshtastic/mesh.pb.cpp | 5 + src/mesh/generated/meshtastic/mesh.pb.h | 80 +- src/mesh/generated/meshtastic/portnums.pb.h | 2 + src/mesh/generated/meshtastic/telemetry.pb.h | 21 +- 7 files changed, 1064 insertions(+), 25 deletions(-) diff --git a/protobufs b/protobufs index e30092e61..940ac382a 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit e30092e6168b13341c2b7ec4be19c789ad5cd77f +Subproject commit 940ac382a7d143040da5a880237f84c48ee31f2b diff --git a/src/mesh/generated/meshtastic/atak.pb.cpp b/src/mesh/generated/meshtastic/atak.pb.cpp index bbafa33e2..3f1adea53 100644 --- a/src/mesh/generated/meshtastic/atak.pb.cpp +++ b/src/mesh/generated/meshtastic/atak.pb.cpp @@ -27,6 +27,33 @@ PB_BIND(meshtastic_PLI, meshtastic_PLI, AUTO) PB_BIND(meshtastic_AircraftTrack, meshtastic_AircraftTrack, AUTO) +PB_BIND(meshtastic_CotGeoPoint, meshtastic_CotGeoPoint, AUTO) + + +PB_BIND(meshtastic_DrawnShape, meshtastic_DrawnShape, 2) + + +PB_BIND(meshtastic_Marker, meshtastic_Marker, AUTO) + + +PB_BIND(meshtastic_RangeAndBearing, meshtastic_RangeAndBearing, AUTO) + + +PB_BIND(meshtastic_Route, meshtastic_Route, 2) + + +PB_BIND(meshtastic_Route_Link, meshtastic_Route_Link, AUTO) + + +PB_BIND(meshtastic_CasevacReport, meshtastic_CasevacReport, AUTO) + + +PB_BIND(meshtastic_EmergencyAlert, meshtastic_EmergencyAlert, AUTO) + + +PB_BIND(meshtastic_TaskRequest, meshtastic_TaskRequest, AUTO) + + PB_BIND(meshtastic_TAKPacketV2, meshtastic_TAKPacketV2, 2) @@ -41,3 +68,27 @@ PB_BIND(meshtastic_TAKPacketV2, meshtastic_TAKPacketV2, 2) + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesh/generated/meshtastic/atak.pb.h b/src/mesh/generated/meshtastic/atak.pb.h index c12b042f4..d25fa6543 100644 --- a/src/mesh/generated/meshtastic/atak.pb.h +++ b/src/mesh/generated/meshtastic/atak.pb.h @@ -241,7 +241,91 @@ typedef enum _meshtastic_CotType { /* b-f-t-r: File transfer request */ meshtastic_CotType_CotType_b_f_t_r = 74, /* b-f-t-a: File transfer acknowledgment */ - meshtastic_CotType_CotType_b_f_t_a = 75 + meshtastic_CotType_CotType_b_f_t_a = 75, + /* u-d-f-m: Freehand telestration / annotation. Anchor at event point, + geometry carried via DrawnShape.vertices. May be truncated to + MAX_VERTICES by the sender. */ + meshtastic_CotType_CotType_u_d_f_m = 76, + /* u-d-p: Closed polygon. Geometry carried via DrawnShape.vertices, + implicitly closed (receiver duplicates first vertex as needed). */ + meshtastic_CotType_CotType_u_d_p = 77, + /* b-m-p-s-m: Spot map marker (colored dot at a point of interest). */ + meshtastic_CotType_CotType_b_m_p_s_m = 78, + /* b-m-p-c: Checkpoint (intermediate route control point). */ + meshtastic_CotType_CotType_b_m_p_c = 79, + /* u-r-b-c-c: Ranging circle (range rings centered on the event point). */ + meshtastic_CotType_CotType_u_r_b_c_c = 80, + /* u-r-b-bullseye: Bullseye with configurable range rings and bearing + reference (magnetic / true / grid). */ + meshtastic_CotType_CotType_u_r_b_bullseye = 81, + /* a-f-G-E-V-A: Friendly armored vehicle, user-selectable self PLI. */ + meshtastic_CotType_CotType_a_f_G_E_V_A = 82, + /* a-n-A: Neutral aircraft (friendly/hostile/unknown already present). */ + meshtastic_CotType_CotType_a_n_A = 83, + /* --- 2525 quick-drop: artillery (4) ---------------------------------- */ + meshtastic_CotType_CotType_a_u_G_U_C_F = 84, + meshtastic_CotType_CotType_a_n_G_U_C_F = 85, + meshtastic_CotType_CotType_a_h_G_U_C_F = 86, + meshtastic_CotType_CotType_a_f_G_U_C_F = 87, + /* --- 2525 quick-drop: building (4) ----------------------------------- */ + meshtastic_CotType_CotType_a_u_G_I = 88, + meshtastic_CotType_CotType_a_n_G_I = 89, + meshtastic_CotType_CotType_a_h_G_I = 90, + meshtastic_CotType_CotType_a_f_G_I = 91, + /* --- 2525 quick-drop: mine (4) --------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_E_X_M = 92, + meshtastic_CotType_CotType_a_n_G_E_X_M = 93, + meshtastic_CotType_CotType_a_h_G_E_X_M = 94, + meshtastic_CotType_CotType_a_f_G_E_X_M = 95, + /* --- 2525 quick-drop: ship (3; a-f-S already at 17) ------------------ */ + meshtastic_CotType_CotType_a_u_S = 96, + meshtastic_CotType_CotType_a_n_S = 97, + meshtastic_CotType_CotType_a_h_S = 98, + /* --- 2525 quick-drop: sniper (4) ------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_U_C_I_d = 99, + meshtastic_CotType_CotType_a_n_G_U_C_I_d = 100, + meshtastic_CotType_CotType_a_h_G_U_C_I_d = 101, + meshtastic_CotType_CotType_a_f_G_U_C_I_d = 102, + /* --- 2525 quick-drop: tank (4) --------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_E_V_A_T = 103, + meshtastic_CotType_CotType_a_n_G_E_V_A_T = 104, + meshtastic_CotType_CotType_a_h_G_E_V_A_T = 105, + meshtastic_CotType_CotType_a_f_G_E_V_A_T = 106, + /* --- 2525 quick-drop: troops (3; a-f-G-U-C-I already at 2) ----------- */ + meshtastic_CotType_CotType_a_u_G_U_C_I = 107, + meshtastic_CotType_CotType_a_n_G_U_C_I = 108, + meshtastic_CotType_CotType_a_h_G_U_C_I = 109, + /* --- 2525 quick-drop: generic vehicle (3; a-u-G-E-V already at 69) --- */ + meshtastic_CotType_CotType_a_n_G_E_V = 110, + meshtastic_CotType_CotType_a_h_G_E_V = 111, + meshtastic_CotType_CotType_a_f_G_E_V = 112, + /* b-m-p-w-GOTO: Go To / bloodhound navigation target. */ + meshtastic_CotType_CotType_b_m_p_w_GOTO = 113, + /* b-m-p-c-ip: Initial point (mission planning). */ + meshtastic_CotType_CotType_b_m_p_c_ip = 114, + /* b-m-p-c-cp: Contact point (mission planning). */ + meshtastic_CotType_CotType_b_m_p_c_cp = 115, + /* b-m-p-s-p-op: Observation post. */ + meshtastic_CotType_CotType_b_m_p_s_p_op = 116, + /* u-d-v: 2D vehicle outline drawn on the map. */ + meshtastic_CotType_CotType_u_d_v = 117, + /* u-d-v-m: 3D vehicle model reference. */ + meshtastic_CotType_CotType_u_d_v_m = 118, + /* u-d-c-e: Non-circular ellipse (circle with distinct major/minor axes). */ + meshtastic_CotType_CotType_u_d_c_e = 119, + /* b-i-x-i: Quick Pic geotagged image marker. The image itself does not + ride on LoRa; this event references the image via iconset metadata. */ + meshtastic_CotType_CotType_b_i_x_i = 120, + /* b-t-f-d: GeoChat delivered receipt. Carried on the existing `chat` + payload_variant via GeoChat.receipt_for_uid + receipt_type. */ + meshtastic_CotType_CotType_b_t_f_d = 121, + /* b-t-f-r: GeoChat read receipt. Same wire slot as b-t-f-d. */ + meshtastic_CotType_CotType_b_t_f_r = 122, + /* b-a-o-c: Custom / generic emergency beacon. */ + meshtastic_CotType_CotType_b_a_o_c = 123, + /* t-s: Task / engage request. Structured payload carried via the new + TaskRequest typed variant. */ + meshtastic_CotType_CotType_t_s = 124 } meshtastic_CotType; /* Geopoint and altitude source */ @@ -256,10 +340,191 @@ typedef enum _meshtastic_GeoPointSource { meshtastic_GeoPointSource_GeoPointSource_NETWORK = 3 } meshtastic_GeoPointSource; +/* Receipt discriminator. Set alongside cot_type_id = b-t-f-d (delivered) + or b-t-f-r (read). ReceiptType_None is the default for a normal chat + message (cot_type_id = b-t-f). + + Receivers can detect a receipt by checking receipt_type != ReceiptType_None + without re-parsing the envelope cot_type_id. */ +typedef enum _meshtastic_GeoChat_ReceiptType { + meshtastic_GeoChat_ReceiptType_ReceiptType_None = 0, /* normal chat message */ + meshtastic_GeoChat_ReceiptType_ReceiptType_Delivered = 1, /* b-t-f-d delivered receipt */ + meshtastic_GeoChat_ReceiptType_ReceiptType_Read = 2 /* b-t-f-r read receipt */ +} meshtastic_GeoChat_ReceiptType; + +/* Shape kind discriminator. Drives receiver rendering and also controls + which optional fields below are meaningful. */ +typedef enum _meshtastic_DrawnShape_Kind { + /* Unspecified (do not use on the wire) */ + meshtastic_DrawnShape_Kind_Kind_Unspecified = 0, + /* u-d-c-c: User-drawn circle (uses major/minor/angle, anchor = event point) */ + meshtastic_DrawnShape_Kind_Kind_Circle = 1, + /* u-d-r: User-drawn rectangle (uses vertices = 4 corners) */ + meshtastic_DrawnShape_Kind_Kind_Rectangle = 2, + /* u-d-f: User-drawn polyline (uses vertices, not closed) */ + meshtastic_DrawnShape_Kind_Kind_Freeform = 3, + /* u-d-f-m: Freehand telestration / annotation (uses vertices, may be truncated) */ + meshtastic_DrawnShape_Kind_Kind_Telestration = 4, + /* u-d-p: Closed polygon (uses vertices, implicitly closed) */ + meshtastic_DrawnShape_Kind_Kind_Polygon = 5, + /* u-r-b-c-c: Ranging circle (major/minor/angle, stroke + optional fill) */ + meshtastic_DrawnShape_Kind_Kind_RangingCircle = 6, + /* u-r-b-bullseye: Bullseye ring with range rings and bearing reference */ + meshtastic_DrawnShape_Kind_Kind_Bullseye = 7, + /* u-d-c-e: Ellipse with distinct major/minor axes (same storage as + Kind_Circle — uses major_cm/minor_cm/angle_deg — but receivers + render it as a non-circular ellipse rather than a round circle). */ + meshtastic_DrawnShape_Kind_Kind_Ellipse = 8, + /* u-d-v: 2D vehicle outline drawn on the map. Vertices carry the + outline polygon; receivers draw it as a filled polygon. */ + meshtastic_DrawnShape_Kind_Kind_Vehicle2D = 9, + /* u-d-v-m: 3D vehicle model reference. Same vertex polygon as + Kind_Vehicle2D; receivers that support 3D rendering extrude it. */ + meshtastic_DrawnShape_Kind_Kind_Vehicle3D = 10 +} meshtastic_DrawnShape_Kind; + +/* Explicit stroke/fill/both discriminator. + + ATAK's source XML distinguishes "stroke-only polyline" from "closed shape + with both stroke and fill" by the presence of the element. + Both states can hash to all-zero color fields, so we carry the signal + explicitly. Parser sets this from (sawStrokeColor, sawFillColor) at the + end of parse; builder uses it to decide which of / + to emit in the reconstructed XML. */ +typedef enum _meshtastic_DrawnShape_StyleMode { + /* Unspecified — receiver infers from which color fields are non-zero. */ + meshtastic_DrawnShape_StyleMode_StyleMode_Unspecified = 0, + /* Stroke only. No in the source XML. Used for polylines, + ranging lines, bullseye rings. */ + meshtastic_DrawnShape_StyleMode_StyleMode_StrokeOnly = 1, + /* Fill only. No in the source XML. Rare but valid in + ATAK (solid region with no outline). */ + meshtastic_DrawnShape_StyleMode_StyleMode_FillOnly = 2, + /* Both stroke and fill present. Closed shapes: circle, rectangle, + polygon, ranging circle. */ + meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill = 3 +} meshtastic_DrawnShape_StyleMode; + +/* Marker kind. Used to pick sensible receiver defaults when the CoT type + alone is ambiguous (e.g. a-u-G could be a 2525 symbol or a custom icon + depending on the iconset path). */ +typedef enum _meshtastic_Marker_Kind { + /* Unspecified — fall back to TAKPacketV2.cot_type_id */ + meshtastic_Marker_Kind_Kind_Unspecified = 0, + /* b-m-p-s-m: Spot map marker */ + meshtastic_Marker_Kind_Kind_Spot = 1, + /* b-m-p-w: Route waypoint */ + meshtastic_Marker_Kind_Kind_Waypoint = 2, + /* b-m-p-c: Checkpoint */ + meshtastic_Marker_Kind_Kind_Checkpoint = 3, + /* b-m-p-s-p-i / b-m-p-s-p-loc: Self-position marker */ + meshtastic_Marker_Kind_Kind_SelfPosition = 4, + /* 2525B/C military symbol (iconsetpath = COT_MAPPING_2525B/...) */ + meshtastic_Marker_Kind_Kind_Symbol2525 = 5, + /* COT_MAPPING_SPOTMAP icon (e.g. colored dot) */ + meshtastic_Marker_Kind_Kind_SpotMap = 6, + /* Custom icon set (UUID/GroupName/filename.png) */ + meshtastic_Marker_Kind_Kind_CustomIcon = 7, + /* b-m-p-w-GOTO: Go To / bloodhound navigation waypoint. */ + meshtastic_Marker_Kind_Kind_GoToPoint = 8, + /* b-m-p-c-ip: Initial point (mission planning control point). */ + meshtastic_Marker_Kind_Kind_InitialPoint = 9, + /* b-m-p-c-cp: Contact point (mission planning control point). */ + meshtastic_Marker_Kind_Kind_ContactPoint = 10, + /* b-m-p-s-p-op: Observation post. */ + meshtastic_Marker_Kind_Kind_ObservationPost = 11, + /* b-i-x-i: Quick Pic geotagged image marker. iconset carries the + image reference (local filename or remote URL); the image itself + does not ride on the LoRa wire. */ + meshtastic_Marker_Kind_Kind_ImageMarker = 12 +} meshtastic_Marker_Kind; + +/* Travel method for the route. */ +typedef enum _meshtastic_Route_Method { + /* Unspecified / unknown */ + meshtastic_Route_Method_Method_Unspecified = 0, + /* Driving / vehicle */ + meshtastic_Route_Method_Method_Driving = 1, + /* Walking / foot */ + meshtastic_Route_Method_Method_Walking = 2, + /* Flying */ + meshtastic_Route_Method_Method_Flying = 3, + /* Swimming (individual) */ + meshtastic_Route_Method_Method_Swimming = 4, + /* Watercraft (boat) */ + meshtastic_Route_Method_Method_Watercraft = 5 +} meshtastic_Route_Method; + +/* Route direction (infil = ingress, exfil = egress). */ +typedef enum _meshtastic_Route_Direction { + /* Unspecified */ + meshtastic_Route_Direction_Direction_Unspecified = 0, + /* Infiltration (ingress) */ + meshtastic_Route_Direction_Direction_Infil = 1, + /* Exfiltration (egress) */ + meshtastic_Route_Direction_Direction_Exfil = 2 +} meshtastic_Route_Direction; + +/* Line 3: precedence / urgency. */ +typedef enum _meshtastic_CasevacReport_Precedence { + meshtastic_CasevacReport_Precedence_Precedence_Unspecified = 0, + meshtastic_CasevacReport_Precedence_Precedence_Urgent = 1, /* A - immediate, life-threatening */ + meshtastic_CasevacReport_Precedence_Precedence_UrgentSurgical = 2, /* B - needs surgery */ + meshtastic_CasevacReport_Precedence_Precedence_Priority = 3, /* C - within 4 hours */ + meshtastic_CasevacReport_Precedence_Precedence_Routine = 4, /* D - within 24 hours */ + meshtastic_CasevacReport_Precedence_Precedence_Convenience = 5 /* E - convenience */ +} meshtastic_CasevacReport_Precedence; + +/* Line 7: HLZ marking method. */ +typedef enum _meshtastic_CasevacReport_HlzMarking { + meshtastic_CasevacReport_HlzMarking_HlzMarking_Unspecified = 0, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Panels = 1, + meshtastic_CasevacReport_HlzMarking_HlzMarking_PyroSignal = 2, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Smoke = 3, + meshtastic_CasevacReport_HlzMarking_HlzMarking_None = 4, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Other = 5 +} meshtastic_CasevacReport_HlzMarking; + +/* Line 6: security situation at the pickup zone. */ +typedef enum _meshtastic_CasevacReport_Security { + meshtastic_CasevacReport_Security_Security_Unspecified = 0, + meshtastic_CasevacReport_Security_Security_NoEnemy = 1, /* N - no enemy activity */ + meshtastic_CasevacReport_Security_Security_PossibleEnemy = 2, /* P - possible enemy */ + meshtastic_CasevacReport_Security_Security_EnemyInArea = 3, /* E - enemy, approach with caution */ + meshtastic_CasevacReport_Security_Security_EnemyInArmedContact = 4 /* X - armed escort required */ +} meshtastic_CasevacReport_Security; + +typedef enum _meshtastic_EmergencyAlert_Type { + meshtastic_EmergencyAlert_Type_Type_Unspecified = 0, + meshtastic_EmergencyAlert_Type_Type_Alert911 = 1, /* b-a-o-tbl */ + meshtastic_EmergencyAlert_Type_Type_RingTheBell = 2, /* b-a-o-pan */ + meshtastic_EmergencyAlert_Type_Type_InContact = 3, /* b-a-o-opn */ + meshtastic_EmergencyAlert_Type_Type_GeoFenceBreached = 4, /* b-a-g */ + meshtastic_EmergencyAlert_Type_Type_Custom = 5, /* b-a-o-c */ + meshtastic_EmergencyAlert_Type_Type_Cancel = 6 /* b-a-o-can */ +} meshtastic_EmergencyAlert_Type; + +typedef enum _meshtastic_TaskRequest_Priority { + meshtastic_TaskRequest_Priority_Priority_Unspecified = 0, + meshtastic_TaskRequest_Priority_Priority_Low = 1, + meshtastic_TaskRequest_Priority_Priority_Normal = 2, + meshtastic_TaskRequest_Priority_Priority_High = 3, + meshtastic_TaskRequest_Priority_Priority_Critical = 4 +} meshtastic_TaskRequest_Priority; + +typedef enum _meshtastic_TaskRequest_Status { + meshtastic_TaskRequest_Status_Status_Unspecified = 0, + meshtastic_TaskRequest_Status_Status_Pending = 1, /* assigned, not yet acknowledged */ + meshtastic_TaskRequest_Status_Status_Acknowledged = 2, /* assignee has seen it */ + meshtastic_TaskRequest_Status_Status_InProgress = 3, /* assignee is working it */ + meshtastic_TaskRequest_Status_Status_Completed = 4, /* task done */ + meshtastic_TaskRequest_Status_Status_Cancelled = 5 /* cancelled before completion */ +} meshtastic_TaskRequest_Status; + /* Struct definitions */ /* ATAK GeoChat message */ typedef struct _meshtastic_GeoChat { - /* The text message */ + /* The text message. Empty for receipts. */ char message[200]; /* Uid recipient of the message */ bool has_to; @@ -267,6 +532,14 @@ typedef struct _meshtastic_GeoChat { /* Callsign of the recipient for the message */ bool has_to_callsign; char to_callsign[120]; + /* UID of the chat message this event is acknowledging. Empty for a + normal chat message; set for delivered / read receipts. Paired with + receipt_type so receivers can match the ack back to the original + outbound GeoChat by its event uid. */ + char receipt_for_uid[48]; + /* Receipt kind discriminator. See ReceiptType doc. Default ReceiptType_None + means this is a regular chat message, not a receipt. */ + meshtastic_GeoChat_ReceiptType receipt_type; } meshtastic_GeoChat; /* ATAK Group @@ -360,6 +633,284 @@ typedef struct _meshtastic_AircraftTrack { char cot_host_id[64]; } meshtastic_AircraftTrack; +/* Compact geographic vertex used by repeated vertex lists in TAK geometry + payloads. Named with a `Cot` prefix to avoid a namespace collision with + `meshtastic.GeoPoint` in `device_ui.proto`, which is an unrelated zoom/ + latitude/longitude type used by the on-device map UI. + + Encoded as a signed DELTA from TAKPacketV2.latitude_i / longitude_i (the + enclosing event's anchor point). The absolute coordinate is recovered by + the receiver as `event.latitude_i + vertex.lat_delta_i` (and likewise for + longitude). + + Why deltas: a 32-vertex telestration with vertices clustered within a few + hundred meters of the anchor has per-vertex deltas in the ±10^4 range. + Under sint32+zigzag those encode as 2 bytes each (tag+varint), versus the + 4 bytes that sfixed32 would always require. At 32 vertices that is ~128 + bytes of savings — the difference between fitting under the LoRa MTU or + not. Absolute coordinates (values ~10^9) would cost sint32 varint 5 bytes + per field, which is why TAKPacketV2's top-level latitude_i / longitude_i + stay sfixed32 — only small values win with sint32. */ +typedef struct _meshtastic_CotGeoPoint { + /* Latitude delta from TAKPacketV2.latitude_i, in 1e-7 degree units. + Add to the enclosing event's latitude_i to recover the absolute latitude. */ + int32_t lat_delta_i; + /* Longitude delta from TAKPacketV2.longitude_i, in 1e-7 degree units. */ + int32_t lon_delta_i; +} meshtastic_CotGeoPoint; + +/* User-drawn tactical graphic: circle, rectangle, polygon, polyline, freehand + telestration, ranging circle, or bullseye. + + Covers CoT types u-d-c-c, u-d-r, u-d-f, u-d-f-m, u-d-p, u-r-b-c-c, + u-r-b-bullseye. The shape's anchor position is carried on + TAKPacketV2.latitude_i/longitude_i; polyline/polygon vertices are in the + `vertices` repeated field as `CotGeoPoint` deltas from that anchor. + + Colors use the Team enum as a 14-color palette (see color encoding below) + with a fixed32 exact-ARGB fallback for custom user-picked colors that + don't map to a palette entry. */ +typedef struct _meshtastic_DrawnShape { + /* Shape kind (circle, rectangle, freeform, etc.) */ + meshtastic_DrawnShape_Kind kind; + /* Explicit stroke/fill/both discriminator. See StyleMode doc. */ + meshtastic_DrawnShape_StyleMode style; + /* Ellipse major radius in centimeters. 0 for non-ellipse kinds. */ + uint32_t major_cm; + /* Ellipse minor radius in centimeters. 0 for non-ellipse kinds. */ + uint32_t minor_cm; + /* Ellipse rotation angle in degrees. Valid values are 0..360 inclusive; + 0 and 360 are equivalent rotations. In proto3, an unset uint32 reads + as 0, so senders should emit 0 when the angle is unspecified. */ + uint16_t angle_deg; + /* Stroke color as a named palette entry from the Team enum. If + Unspecifed_Color, the exact ARGB is carried in stroke_argb. + Valid only when style is StrokeOnly or StrokeAndFill. */ + meshtastic_Team stroke_color; + /* Stroke color as an exact 32-bit ARGB bit pattern. Always populated + on the wire; readers MUST use this value when stroke_color == + Unspecifed_Color and MAY use it to recover the exact original bytes + even when a palette entry is set. */ + uint32_t stroke_argb; + /* Stroke weight in tenths of a unit (e.g. 30 = 3.0). Typical ATAK + range 10..60. */ + uint16_t stroke_weight_x10; + /* Fill color as a named palette entry. See stroke_color docs. + Valid only when style is FillOnly or StrokeAndFill. */ + meshtastic_Team fill_color; + /* Fill color exact ARGB fallback. See stroke_argb docs. */ + uint32_t fill_argb; + /* Whether labels are rendered on this shape. */ + bool labels_on; + /* Vertex list for polyline/polygon/rectangle shapes. Capped at 32 by + the nanopb pool; senders MUST truncate longer inputs and set + `truncated = true`. */ + pb_size_t vertices_count; + meshtastic_CotGeoPoint vertices[32]; + /* True if the sender truncated `vertices` to fit the pool. */ + bool truncated; /* --- Bullseye-only fields. All ignored unless kind == Kind_Bullseye. --- */ + /* Bullseye distance in meters * 10 (e.g. 3285 = 328.5 m). 0 = unset. */ + uint32_t bullseye_distance_dm; + /* Bullseye bearing reference: 0 unset, 1 Magnetic, 2 True, 3 Grid. */ + uint8_t bullseye_bearing_ref; + /* Bullseye attribute bit flags: + bit 0: rangeRingVisible + bit 1: hasRangeRings + bit 2: edgeToCenter + bit 3: mils */ + uint8_t bullseye_flags; + /* Bullseye reference UID (anchor marker). Empty = anchor is self. */ + char bullseye_uid_ref[48]; +} meshtastic_DrawnShape; + +/* Fixed point of interest: spot marker, waypoint, checkpoint, 2525 symbol, + or custom icon. + + Covers CoT types b-m-p-s-m, b-m-p-w, b-m-p-c, b-m-p-s-p-i, b-m-p-s-p-loc, + plus a-u-G / a-f-G / a-h-G / a-n-G with iconset paths. The marker position + is carried on TAKPacketV2.latitude_i/longitude_i; fields below carry only + the marker-specific metadata. */ +typedef struct _meshtastic_Marker { + /* Marker kind */ + meshtastic_Marker_Kind kind; + /* Marker color as a named palette entry. If Unspecifed_Color, the exact + ARGB is in color_argb. */ + meshtastic_Team color; + /* Marker color exact ARGB bit pattern. Always populated on the wire. */ + uint32_t color_argb; + /* Status readiness flag (ATAK ). */ + bool readiness; + /* Parent link UID (ATAK ). Empty = no parent. + For spot/waypoint markers this is typically the producing TAK user's UID. */ + char parent_uid[48]; + /* Parent CoT type (e.g. "a-f-G-U-C"). Usually the parent TAK user's type. */ + char parent_type[24]; + /* Parent callsign (e.g. "HOPE"). */ + char parent_callsign[24]; + /* Iconset path stored verbatim. ATAK emits three flavors: + Kind_Symbol2525 -> "COT_MAPPING_2525B//" + Kind_SpotMap -> "COT_MAPPING_SPOTMAP//" + Kind_CustomIcon -> "//.png" + Stored end-to-end without prefix stripping; the ~19 bytes saved by + stripping well-known prefixes are not worth the builder-side bug + surface, and the dict compresses the repetition effectively. */ + char iconset[80]; +} meshtastic_Marker; + +/* Range and bearing measurement line from the event anchor to a target point. + + Covers CoT type u-rb-a. The anchor position is on + TAKPacketV2.latitude_i/longitude_i; the target endpoint is carried as a + CotGeoPoint — same delta-from-anchor encoding used by DrawnShape.vertices + so a self-anchored RAB (common case) encodes in zero bytes. */ +typedef struct _meshtastic_RangeAndBearing { + /* Target/anchor endpoint (delta-encoded from TAKPacketV2.latitude_i/longitude_i). */ + bool has_anchor; + meshtastic_CotGeoPoint anchor; + /* Anchor UID (from ). Empty = free-standing. */ + char anchor_uid[48]; + /* Range in centimeters (value * 100). Range 0..4294 km. */ + uint32_t range_cm; + /* Bearing in degrees * 100 (0..36000). */ + uint16_t bearing_cdeg; + /* Stroke color as a Team palette entry. See DrawnShape.stroke_color doc. */ + meshtastic_Team stroke_color; + /* Stroke color exact ARGB fallback. */ + uint32_t stroke_argb; + /* Stroke weight * 10 (e.g. 30 = 3.0). */ + uint16_t stroke_weight_x10; +} meshtastic_RangeAndBearing; + +/* Route waypoint or control point. Each link corresponds to one ATAK + entry inside the b-m-r event. */ +typedef struct _meshtastic_Route_Link { + /* Waypoint position (delta-encoded from TAKPacketV2.latitude_i/longitude_i). */ + bool has_point; + meshtastic_CotGeoPoint point; + /* Optional UID (empty = receiver derives). */ + char uid[48]; + /* Optional display callsign (e.g. "CP1"). Empty for unnamed control points. */ + char callsign[16]; + /* Link role: 0 = waypoint (b-m-p-w), 1 = checkpoint (b-m-p-c). */ + uint8_t link_type; +} meshtastic_Route_Link; + +/* Named route consisting of ordered waypoints and control points. + + Covers CoT type b-m-r. The first waypoint's position is on + TAKPacketV2.latitude_i/longitude_i; subsequent waypoints and checkpoints + are in `links`. Link count is capped at 16 by the nanopb pool; senders + MUST truncate longer routes and set `truncated = true`. */ +typedef struct _meshtastic_Route { + /* Travel method */ + meshtastic_Route_Method method; + /* Direction (infil/exfil) */ + meshtastic_Route_Direction direction; + /* Waypoint name prefix (e.g. "CP"). */ + char prefix[8]; + /* Stroke weight * 10 (e.g. 30 = 3.0). 0 = default. */ + uint16_t stroke_weight_x10; + /* Ordered list of route control points. Capped at 16. */ + pb_size_t links_count; + meshtastic_Route_Link links[16]; + /* True if the sender truncated `links` to fit the pool. */ + bool truncated; +} meshtastic_Route; + +/* 9-line MEDEVAC request (CoT type b-r-f-h-c). + + Mirrors the ATAK MedLine tool's <_medevac_> detail element. Every field + is optional (proto3 default); senders omit lines they don't have. The + envelope (TAKPacketV2.uid, cot_type_id=b-r-f-h-c, latitude_i/longitude_i, + altitude, callsign) carries Line 1 (location) and Line 2 (callsign). + + All numeric fields are tight varints so a complete 9-line request fits + in well under 100 bytes of proto on the wire. */ +typedef struct _meshtastic_CasevacReport { + /* Line 3: precedence / urgency. */ + meshtastic_CasevacReport_Precedence precedence; + /* Line 4: special equipment required, as a bitfield. + bit 0: none + bit 1: hoist + bit 2: extraction equipment + bit 3: ventilator + bit 4: blood */ + uint8_t equipment_flags; + /* Line 5: number of litter (stretcher-bound) patients. */ + uint8_t litter_patients; + /* Line 5: number of ambulatory (walking-wounded) patients. */ + uint8_t ambulatory_patients; + /* Line 6: security situation at the PZ. */ + meshtastic_CasevacReport_Security security; + /* Line 7: HLZ marking method. */ + meshtastic_CasevacReport_HlzMarking hlz_marking; + /* Line 7 supplementary: short free-text describing the zone marker + (e.g. "Green smoke", "VS-17 panel west"). Capped tight in options. */ + char zone_marker[16]; + /* --- Line 8: patient nationality counts --- */ + uint8_t us_military; + uint8_t us_civilian; + uint8_t non_us_military; + uint8_t non_us_civilian; + uint8_t epw; /* enemy prisoner of war */ + uint8_t child; + /* Line 9: terrain and obstacles at the PZ, as a bitfield. + bit 0: slope + bit 1: rough + bit 2: loose + bit 3: trees + bit 4: wires + bit 5: other */ + uint8_t terrain_flags; + /* Line 2: radio frequency / callsign metadata (e.g. "38.90 Mhz" or + "Victor 6"). Capped tight in options. */ + char frequency[16]; +} meshtastic_CasevacReport; + +/* Emergency alert / 911 beacon (CoT types b-a-o-tbl, b-a-o-pan, b-a-o-opn, + b-a-o-can, b-a-o-c, b-a-g). + + Small, high-priority structured record. The CoT type string is still set + on cot_type_id so receivers that ignore payload_variant can still display + the alert from the enum alone; the typed fields let modern receivers show + the authoring unit and handle cancel-referencing without XML parsing. */ +typedef struct _meshtastic_EmergencyAlert { + /* Alert discriminator. */ + meshtastic_EmergencyAlert_Type type; + /* UID of the unit that raised the alert. Often the same as + TAKPacketV2.uid but can be a parent device uid when a tracker raises + an alert on behalf of a dismount. */ + char authoring_uid[48]; + /* For Type_Cancel: the uid of the alert being cancelled. Empty for + non-cancel alert types. */ + char cancel_reference_uid[48]; +} meshtastic_EmergencyAlert; + +/* Task / engage request (CoT type t-s). + + Mirrors ATAK's TaskCotReceiver / CotTaskBuilder workflow. The envelope + carries the task's originating uid (implicit requester), position, and + creation time; the fields below carry structured metadata the raw-detail + fallback currently loses. + + Fields are deliberately lean — this variant is closer to the MTU ceiling + than the others, so every string is capped in options. */ +typedef struct _meshtastic_TaskRequest { + /* Short tag for the task category (e.g. "engage", "observe", "recon", + "rescue"). Free text on the wire so ATAK-specific task taxonomies + don't need proto coordination; capped tight in options. */ + char task_type[12]; + /* UID of the target / map item being tasked. */ + char target_uid[32]; + /* UID of the assigned unit. Empty = unassigned / broadcast task. */ + char assignee_uid[32]; + meshtastic_TaskRequest_Priority priority; + meshtastic_TaskRequest_Status status; + /* Optional short note (reason, constraints, grid reference). Capped + tight in options to keep the worst-case under the LoRa MTU. */ + char note[48]; +} meshtastic_TaskRequest; + typedef PB_BYTES_ARRAY_T(220) meshtastic_TAKPacketV2_raw_detail_t; /* ATAK v2 packet with expanded CoT field support and zstd dictionary compression. Sent on ATAK_PLUGIN_V2 port. The wire payload is: @@ -413,6 +964,12 @@ typedef struct _meshtastic_TAKPacketV2 { char phone[20]; /* CoT event type string, only populated when cot_type_id is CotType_Other */ char cot_type_str[32]; + /* Optional remarks / free-text annotation from the element. + Populated for non-GeoChat payload types (shapes, markers, routes, etc.) + when the original CoT event carried non-empty remarks text. + GeoChat messages carry their text in GeoChat.message instead. + Empty string (proto3 default) means no remarks were present. */ + pb_callback_t remarks; pb_size_t which_payload_variant; union { /* Position report (true = PLI, no extra fields beyond the common ones above) */ @@ -421,8 +978,26 @@ typedef struct _meshtastic_TAKPacketV2 { meshtastic_GeoChat chat; /* Aircraft track data (ADS-B, military air) */ meshtastic_AircraftTrack aircraft; - /* Generic CoT detail XML for unmapped types */ + /* Generic CoT detail XML for unmapped types. Kept as a fallback for CoT + types not yet promoted to a typed variant; drawings, markers, ranging + tools, and routes have dedicated variants below and should not land here. */ meshtastic_TAKPacketV2_raw_detail_t raw_detail; + /* User-drawn tactical graphic: circle, rectangle, polygon, polyline, + telestration, ranging circle, or bullseye. See DrawnShape. */ + meshtastic_DrawnShape shape; + /* Fixed point of interest: spot marker, waypoint, checkpoint, 2525 + symbol, or custom icon. See Marker. */ + meshtastic_Marker marker; + /* Range and bearing measurement line. See RangeAndBearing. */ + meshtastic_RangeAndBearing rab; + /* Named route with ordered waypoints and control points. See Route. */ + meshtastic_Route route; + /* 9-line MEDEVAC request. See CasevacReport. */ + meshtastic_CasevacReport casevac; + /* Emergency beacon / 911 alert. See EmergencyAlert. */ + meshtastic_EmergencyAlert emergency; + /* Task / engage request. See TaskRequest. */ + meshtastic_TaskRequest task; } payload_variant; } meshtastic_TAKPacketV2; @@ -445,14 +1020,63 @@ extern "C" { #define _meshtastic_CotHow_ARRAYSIZE ((meshtastic_CotHow)(meshtastic_CotHow_CotHow_m_s+1)) #define _meshtastic_CotType_MIN meshtastic_CotType_CotType_Other -#define _meshtastic_CotType_MAX meshtastic_CotType_CotType_b_f_t_a -#define _meshtastic_CotType_ARRAYSIZE ((meshtastic_CotType)(meshtastic_CotType_CotType_b_f_t_a+1)) +#define _meshtastic_CotType_MAX meshtastic_CotType_CotType_t_s +#define _meshtastic_CotType_ARRAYSIZE ((meshtastic_CotType)(meshtastic_CotType_CotType_t_s+1)) #define _meshtastic_GeoPointSource_MIN meshtastic_GeoPointSource_GeoPointSource_Unspecified #define _meshtastic_GeoPointSource_MAX meshtastic_GeoPointSource_GeoPointSource_NETWORK #define _meshtastic_GeoPointSource_ARRAYSIZE ((meshtastic_GeoPointSource)(meshtastic_GeoPointSource_GeoPointSource_NETWORK+1)) +#define _meshtastic_GeoChat_ReceiptType_MIN meshtastic_GeoChat_ReceiptType_ReceiptType_None +#define _meshtastic_GeoChat_ReceiptType_MAX meshtastic_GeoChat_ReceiptType_ReceiptType_Read +#define _meshtastic_GeoChat_ReceiptType_ARRAYSIZE ((meshtastic_GeoChat_ReceiptType)(meshtastic_GeoChat_ReceiptType_ReceiptType_Read+1)) +#define _meshtastic_DrawnShape_Kind_MIN meshtastic_DrawnShape_Kind_Kind_Unspecified +#define _meshtastic_DrawnShape_Kind_MAX meshtastic_DrawnShape_Kind_Kind_Vehicle3D +#define _meshtastic_DrawnShape_Kind_ARRAYSIZE ((meshtastic_DrawnShape_Kind)(meshtastic_DrawnShape_Kind_Kind_Vehicle3D+1)) + +#define _meshtastic_DrawnShape_StyleMode_MIN meshtastic_DrawnShape_StyleMode_StyleMode_Unspecified +#define _meshtastic_DrawnShape_StyleMode_MAX meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill +#define _meshtastic_DrawnShape_StyleMode_ARRAYSIZE ((meshtastic_DrawnShape_StyleMode)(meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill+1)) + +#define _meshtastic_Marker_Kind_MIN meshtastic_Marker_Kind_Kind_Unspecified +#define _meshtastic_Marker_Kind_MAX meshtastic_Marker_Kind_Kind_ImageMarker +#define _meshtastic_Marker_Kind_ARRAYSIZE ((meshtastic_Marker_Kind)(meshtastic_Marker_Kind_Kind_ImageMarker+1)) + +#define _meshtastic_Route_Method_MIN meshtastic_Route_Method_Method_Unspecified +#define _meshtastic_Route_Method_MAX meshtastic_Route_Method_Method_Watercraft +#define _meshtastic_Route_Method_ARRAYSIZE ((meshtastic_Route_Method)(meshtastic_Route_Method_Method_Watercraft+1)) + +#define _meshtastic_Route_Direction_MIN meshtastic_Route_Direction_Direction_Unspecified +#define _meshtastic_Route_Direction_MAX meshtastic_Route_Direction_Direction_Exfil +#define _meshtastic_Route_Direction_ARRAYSIZE ((meshtastic_Route_Direction)(meshtastic_Route_Direction_Direction_Exfil+1)) + +#define _meshtastic_CasevacReport_Precedence_MIN meshtastic_CasevacReport_Precedence_Precedence_Unspecified +#define _meshtastic_CasevacReport_Precedence_MAX meshtastic_CasevacReport_Precedence_Precedence_Convenience +#define _meshtastic_CasevacReport_Precedence_ARRAYSIZE ((meshtastic_CasevacReport_Precedence)(meshtastic_CasevacReport_Precedence_Precedence_Convenience+1)) + +#define _meshtastic_CasevacReport_HlzMarking_MIN meshtastic_CasevacReport_HlzMarking_HlzMarking_Unspecified +#define _meshtastic_CasevacReport_HlzMarking_MAX meshtastic_CasevacReport_HlzMarking_HlzMarking_Other +#define _meshtastic_CasevacReport_HlzMarking_ARRAYSIZE ((meshtastic_CasevacReport_HlzMarking)(meshtastic_CasevacReport_HlzMarking_HlzMarking_Other+1)) + +#define _meshtastic_CasevacReport_Security_MIN meshtastic_CasevacReport_Security_Security_Unspecified +#define _meshtastic_CasevacReport_Security_MAX meshtastic_CasevacReport_Security_Security_EnemyInArmedContact +#define _meshtastic_CasevacReport_Security_ARRAYSIZE ((meshtastic_CasevacReport_Security)(meshtastic_CasevacReport_Security_Security_EnemyInArmedContact+1)) + +#define _meshtastic_EmergencyAlert_Type_MIN meshtastic_EmergencyAlert_Type_Type_Unspecified +#define _meshtastic_EmergencyAlert_Type_MAX meshtastic_EmergencyAlert_Type_Type_Cancel +#define _meshtastic_EmergencyAlert_Type_ARRAYSIZE ((meshtastic_EmergencyAlert_Type)(meshtastic_EmergencyAlert_Type_Type_Cancel+1)) + +#define _meshtastic_TaskRequest_Priority_MIN meshtastic_TaskRequest_Priority_Priority_Unspecified +#define _meshtastic_TaskRequest_Priority_MAX meshtastic_TaskRequest_Priority_Priority_Critical +#define _meshtastic_TaskRequest_Priority_ARRAYSIZE ((meshtastic_TaskRequest_Priority)(meshtastic_TaskRequest_Priority_Priority_Critical+1)) + +#define _meshtastic_TaskRequest_Status_MIN meshtastic_TaskRequest_Status_Status_Unspecified +#define _meshtastic_TaskRequest_Status_MAX meshtastic_TaskRequest_Status_Status_Cancelled +#define _meshtastic_TaskRequest_Status_ARRAYSIZE ((meshtastic_TaskRequest_Status)(meshtastic_TaskRequest_Status_Status_Cancelled+1)) + + +#define meshtastic_GeoChat_receipt_type_ENUMTYPE meshtastic_GeoChat_ReceiptType #define meshtastic_Group_role_ENUMTYPE meshtastic_MemberRole #define meshtastic_Group_team_ENUMTYPE meshtastic_Team @@ -461,6 +1085,30 @@ extern "C" { + +#define meshtastic_DrawnShape_kind_ENUMTYPE meshtastic_DrawnShape_Kind +#define meshtastic_DrawnShape_style_ENUMTYPE meshtastic_DrawnShape_StyleMode +#define meshtastic_DrawnShape_stroke_color_ENUMTYPE meshtastic_Team +#define meshtastic_DrawnShape_fill_color_ENUMTYPE meshtastic_Team + +#define meshtastic_Marker_kind_ENUMTYPE meshtastic_Marker_Kind +#define meshtastic_Marker_color_ENUMTYPE meshtastic_Team + +#define meshtastic_RangeAndBearing_stroke_color_ENUMTYPE meshtastic_Team + +#define meshtastic_Route_method_ENUMTYPE meshtastic_Route_Method +#define meshtastic_Route_direction_ENUMTYPE meshtastic_Route_Direction + + +#define meshtastic_CasevacReport_precedence_ENUMTYPE meshtastic_CasevacReport_Precedence +#define meshtastic_CasevacReport_security_ENUMTYPE meshtastic_CasevacReport_Security +#define meshtastic_CasevacReport_hlz_marking_ENUMTYPE meshtastic_CasevacReport_HlzMarking + +#define meshtastic_EmergencyAlert_type_ENUMTYPE meshtastic_EmergencyAlert_Type + +#define meshtastic_TaskRequest_priority_ENUMTYPE meshtastic_TaskRequest_Priority +#define meshtastic_TaskRequest_status_ENUMTYPE meshtastic_TaskRequest_Status + #define meshtastic_TAKPacketV2_cot_type_id_ENUMTYPE meshtastic_CotType #define meshtastic_TAKPacketV2_how_ENUMTYPE meshtastic_CotHow #define meshtastic_TAKPacketV2_team_ENUMTYPE meshtastic_Team @@ -471,26 +1119,46 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_TAKPacket_init_default {0, false, meshtastic_Contact_init_default, false, meshtastic_Group_init_default, false, meshtastic_Status_init_default, 0, {meshtastic_PLI_init_default}} -#define meshtastic_GeoChat_init_default {"", false, "", false, ""} +#define meshtastic_GeoChat_init_default {"", false, "", false, "", "", _meshtastic_GeoChat_ReceiptType_MIN} #define meshtastic_Group_init_default {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_default {0} #define meshtastic_Contact_init_default {"", ""} #define meshtastic_PLI_init_default {0, 0, 0, 0, 0} #define meshtastic_AircraftTrack_init_default {"", "", "", "", 0, "", 0, 0, ""} -#define meshtastic_TAKPacketV2_init_default {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", 0, {0}} +#define meshtastic_CotGeoPoint_init_default {0, 0} +#define meshtastic_DrawnShape_init_default {_meshtastic_DrawnShape_Kind_MIN, _meshtastic_DrawnShape_StyleMode_MIN, 0, 0, 0, _meshtastic_Team_MIN, 0, 0, _meshtastic_Team_MIN, 0, 0, 0, {meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default}, 0, 0, 0, 0, ""} +#define meshtastic_Marker_init_default {_meshtastic_Marker_Kind_MIN, _meshtastic_Team_MIN, 0, 0, "", "", "", ""} +#define meshtastic_RangeAndBearing_init_default {false, meshtastic_CotGeoPoint_init_default, "", 0, 0, _meshtastic_Team_MIN, 0, 0} +#define meshtastic_Route_init_default {_meshtastic_Route_Method_MIN, _meshtastic_Route_Direction_MIN, "", 0, 0, {meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default}, 0} +#define meshtastic_Route_Link_init_default {false, meshtastic_CotGeoPoint_init_default, "", "", 0} +#define meshtastic_CasevacReport_init_default {_meshtastic_CasevacReport_Precedence_MIN, 0, 0, 0, _meshtastic_CasevacReport_Security_MIN, _meshtastic_CasevacReport_HlzMarking_MIN, "", 0, 0, 0, 0, 0, 0, 0, ""} +#define meshtastic_EmergencyAlert_init_default {_meshtastic_EmergencyAlert_Type_MIN, "", ""} +#define meshtastic_TaskRequest_init_default {"", "", "", _meshtastic_TaskRequest_Priority_MIN, _meshtastic_TaskRequest_Status_MIN, ""} +#define meshtastic_TAKPacketV2_init_default {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", {{NULL}, NULL}, 0, {0}} #define meshtastic_TAKPacket_init_zero {0, false, meshtastic_Contact_init_zero, false, meshtastic_Group_init_zero, false, meshtastic_Status_init_zero, 0, {meshtastic_PLI_init_zero}} -#define meshtastic_GeoChat_init_zero {"", false, "", false, ""} +#define meshtastic_GeoChat_init_zero {"", false, "", false, "", "", _meshtastic_GeoChat_ReceiptType_MIN} #define meshtastic_Group_init_zero {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_zero {0} #define meshtastic_Contact_init_zero {"", ""} #define meshtastic_PLI_init_zero {0, 0, 0, 0, 0} #define meshtastic_AircraftTrack_init_zero {"", "", "", "", 0, "", 0, 0, ""} -#define meshtastic_TAKPacketV2_init_zero {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", 0, {0}} +#define meshtastic_CotGeoPoint_init_zero {0, 0} +#define meshtastic_DrawnShape_init_zero {_meshtastic_DrawnShape_Kind_MIN, _meshtastic_DrawnShape_StyleMode_MIN, 0, 0, 0, _meshtastic_Team_MIN, 0, 0, _meshtastic_Team_MIN, 0, 0, 0, {meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero}, 0, 0, 0, 0, ""} +#define meshtastic_Marker_init_zero {_meshtastic_Marker_Kind_MIN, _meshtastic_Team_MIN, 0, 0, "", "", "", ""} +#define meshtastic_RangeAndBearing_init_zero {false, meshtastic_CotGeoPoint_init_zero, "", 0, 0, _meshtastic_Team_MIN, 0, 0} +#define meshtastic_Route_init_zero {_meshtastic_Route_Method_MIN, _meshtastic_Route_Direction_MIN, "", 0, 0, {meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero}, 0} +#define meshtastic_Route_Link_init_zero {false, meshtastic_CotGeoPoint_init_zero, "", "", 0} +#define meshtastic_CasevacReport_init_zero {_meshtastic_CasevacReport_Precedence_MIN, 0, 0, 0, _meshtastic_CasevacReport_Security_MIN, _meshtastic_CasevacReport_HlzMarking_MIN, "", 0, 0, 0, 0, 0, 0, 0, ""} +#define meshtastic_EmergencyAlert_init_zero {_meshtastic_EmergencyAlert_Type_MIN, "", ""} +#define meshtastic_TaskRequest_init_zero {"", "", "", _meshtastic_TaskRequest_Priority_MIN, _meshtastic_TaskRequest_Status_MIN, ""} +#define meshtastic_TAKPacketV2_init_zero {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", {{NULL}, NULL}, 0, {0}} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_GeoChat_message_tag 1 #define meshtastic_GeoChat_to_tag 2 #define meshtastic_GeoChat_to_callsign_tag 3 +#define meshtastic_GeoChat_receipt_for_uid_tag 4 +#define meshtastic_GeoChat_receipt_type_tag 5 #define meshtastic_Group_role_tag 1 #define meshtastic_Group_team_tag 2 #define meshtastic_Status_battery_tag 1 @@ -517,6 +1185,74 @@ extern "C" { #define meshtastic_AircraftTrack_rssi_x10_tag 7 #define meshtastic_AircraftTrack_gps_tag 8 #define meshtastic_AircraftTrack_cot_host_id_tag 9 +#define meshtastic_CotGeoPoint_lat_delta_i_tag 1 +#define meshtastic_CotGeoPoint_lon_delta_i_tag 2 +#define meshtastic_DrawnShape_kind_tag 1 +#define meshtastic_DrawnShape_style_tag 2 +#define meshtastic_DrawnShape_major_cm_tag 3 +#define meshtastic_DrawnShape_minor_cm_tag 4 +#define meshtastic_DrawnShape_angle_deg_tag 5 +#define meshtastic_DrawnShape_stroke_color_tag 6 +#define meshtastic_DrawnShape_stroke_argb_tag 7 +#define meshtastic_DrawnShape_stroke_weight_x10_tag 8 +#define meshtastic_DrawnShape_fill_color_tag 9 +#define meshtastic_DrawnShape_fill_argb_tag 10 +#define meshtastic_DrawnShape_labels_on_tag 11 +#define meshtastic_DrawnShape_vertices_tag 12 +#define meshtastic_DrawnShape_truncated_tag 13 +#define meshtastic_DrawnShape_bullseye_distance_dm_tag 14 +#define meshtastic_DrawnShape_bullseye_bearing_ref_tag 15 +#define meshtastic_DrawnShape_bullseye_flags_tag 16 +#define meshtastic_DrawnShape_bullseye_uid_ref_tag 17 +#define meshtastic_Marker_kind_tag 1 +#define meshtastic_Marker_color_tag 2 +#define meshtastic_Marker_color_argb_tag 3 +#define meshtastic_Marker_readiness_tag 4 +#define meshtastic_Marker_parent_uid_tag 5 +#define meshtastic_Marker_parent_type_tag 6 +#define meshtastic_Marker_parent_callsign_tag 7 +#define meshtastic_Marker_iconset_tag 8 +#define meshtastic_RangeAndBearing_anchor_tag 1 +#define meshtastic_RangeAndBearing_anchor_uid_tag 2 +#define meshtastic_RangeAndBearing_range_cm_tag 3 +#define meshtastic_RangeAndBearing_bearing_cdeg_tag 4 +#define meshtastic_RangeAndBearing_stroke_color_tag 5 +#define meshtastic_RangeAndBearing_stroke_argb_tag 6 +#define meshtastic_RangeAndBearing_stroke_weight_x10_tag 7 +#define meshtastic_Route_Link_point_tag 1 +#define meshtastic_Route_Link_uid_tag 2 +#define meshtastic_Route_Link_callsign_tag 3 +#define meshtastic_Route_Link_link_type_tag 4 +#define meshtastic_Route_method_tag 1 +#define meshtastic_Route_direction_tag 2 +#define meshtastic_Route_prefix_tag 3 +#define meshtastic_Route_stroke_weight_x10_tag 4 +#define meshtastic_Route_links_tag 5 +#define meshtastic_Route_truncated_tag 6 +#define meshtastic_CasevacReport_precedence_tag 1 +#define meshtastic_CasevacReport_equipment_flags_tag 2 +#define meshtastic_CasevacReport_litter_patients_tag 3 +#define meshtastic_CasevacReport_ambulatory_patients_tag 4 +#define meshtastic_CasevacReport_security_tag 5 +#define meshtastic_CasevacReport_hlz_marking_tag 6 +#define meshtastic_CasevacReport_zone_marker_tag 7 +#define meshtastic_CasevacReport_us_military_tag 8 +#define meshtastic_CasevacReport_us_civilian_tag 9 +#define meshtastic_CasevacReport_non_us_military_tag 10 +#define meshtastic_CasevacReport_non_us_civilian_tag 11 +#define meshtastic_CasevacReport_epw_tag 12 +#define meshtastic_CasevacReport_child_tag 13 +#define meshtastic_CasevacReport_terrain_flags_tag 14 +#define meshtastic_CasevacReport_frequency_tag 15 +#define meshtastic_EmergencyAlert_type_tag 1 +#define meshtastic_EmergencyAlert_authoring_uid_tag 2 +#define meshtastic_EmergencyAlert_cancel_reference_uid_tag 3 +#define meshtastic_TaskRequest_task_type_tag 1 +#define meshtastic_TaskRequest_target_uid_tag 2 +#define meshtastic_TaskRequest_assignee_uid_tag 3 +#define meshtastic_TaskRequest_priority_tag 4 +#define meshtastic_TaskRequest_status_tag 5 +#define meshtastic_TaskRequest_note_tag 6 #define meshtastic_TAKPacketV2_cot_type_id_tag 1 #define meshtastic_TAKPacketV2_how_tag 2 #define meshtastic_TAKPacketV2_callsign_tag 3 @@ -540,10 +1276,18 @@ extern "C" { #define meshtastic_TAKPacketV2_endpoint_tag 21 #define meshtastic_TAKPacketV2_phone_tag 22 #define meshtastic_TAKPacketV2_cot_type_str_tag 23 +#define meshtastic_TAKPacketV2_remarks_tag 24 #define meshtastic_TAKPacketV2_pli_tag 30 #define meshtastic_TAKPacketV2_chat_tag 31 #define meshtastic_TAKPacketV2_aircraft_tag 32 #define meshtastic_TAKPacketV2_raw_detail_tag 33 +#define meshtastic_TAKPacketV2_shape_tag 34 +#define meshtastic_TAKPacketV2_marker_tag 35 +#define meshtastic_TAKPacketV2_rab_tag 36 +#define meshtastic_TAKPacketV2_route_tag 37 +#define meshtastic_TAKPacketV2_casevac_tag 38 +#define meshtastic_TAKPacketV2_emergency_tag 39 +#define meshtastic_TAKPacketV2_task_tag 40 /* Struct field encoding specification for nanopb */ #define meshtastic_TAKPacket_FIELDLIST(X, a) \ @@ -565,7 +1309,9 @@ X(a, STATIC, ONEOF, BYTES, (payload_variant,detail,payload_variant.detai #define meshtastic_GeoChat_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, message, 1) \ X(a, STATIC, OPTIONAL, STRING, to, 2) \ -X(a, STATIC, OPTIONAL, STRING, to_callsign, 3) +X(a, STATIC, OPTIONAL, STRING, to_callsign, 3) \ +X(a, STATIC, SINGULAR, STRING, receipt_for_uid, 4) \ +X(a, STATIC, SINGULAR, UENUM, receipt_type, 5) #define meshtastic_GeoChat_CALLBACK NULL #define meshtastic_GeoChat_DEFAULT NULL @@ -608,6 +1354,114 @@ X(a, STATIC, SINGULAR, STRING, cot_host_id, 9) #define meshtastic_AircraftTrack_CALLBACK NULL #define meshtastic_AircraftTrack_DEFAULT NULL +#define meshtastic_CotGeoPoint_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, SINT32, lat_delta_i, 1) \ +X(a, STATIC, SINGULAR, SINT32, lon_delta_i, 2) +#define meshtastic_CotGeoPoint_CALLBACK NULL +#define meshtastic_CotGeoPoint_DEFAULT NULL + +#define meshtastic_DrawnShape_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, kind, 1) \ +X(a, STATIC, SINGULAR, UENUM, style, 2) \ +X(a, STATIC, SINGULAR, UINT32, major_cm, 3) \ +X(a, STATIC, SINGULAR, UINT32, minor_cm, 4) \ +X(a, STATIC, SINGULAR, UINT32, angle_deg, 5) \ +X(a, STATIC, SINGULAR, UENUM, stroke_color, 6) \ +X(a, STATIC, SINGULAR, FIXED32, stroke_argb, 7) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 8) \ +X(a, STATIC, SINGULAR, UENUM, fill_color, 9) \ +X(a, STATIC, SINGULAR, FIXED32, fill_argb, 10) \ +X(a, STATIC, SINGULAR, BOOL, labels_on, 11) \ +X(a, STATIC, REPEATED, MESSAGE, vertices, 12) \ +X(a, STATIC, SINGULAR, BOOL, truncated, 13) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_distance_dm, 14) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_bearing_ref, 15) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_flags, 16) \ +X(a, STATIC, SINGULAR, STRING, bullseye_uid_ref, 17) +#define meshtastic_DrawnShape_CALLBACK NULL +#define meshtastic_DrawnShape_DEFAULT NULL +#define meshtastic_DrawnShape_vertices_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_Marker_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, kind, 1) \ +X(a, STATIC, SINGULAR, UENUM, color, 2) \ +X(a, STATIC, SINGULAR, FIXED32, color_argb, 3) \ +X(a, STATIC, SINGULAR, BOOL, readiness, 4) \ +X(a, STATIC, SINGULAR, STRING, parent_uid, 5) \ +X(a, STATIC, SINGULAR, STRING, parent_type, 6) \ +X(a, STATIC, SINGULAR, STRING, parent_callsign, 7) \ +X(a, STATIC, SINGULAR, STRING, iconset, 8) +#define meshtastic_Marker_CALLBACK NULL +#define meshtastic_Marker_DEFAULT NULL + +#define meshtastic_RangeAndBearing_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, anchor, 1) \ +X(a, STATIC, SINGULAR, STRING, anchor_uid, 2) \ +X(a, STATIC, SINGULAR, UINT32, range_cm, 3) \ +X(a, STATIC, SINGULAR, UINT32, bearing_cdeg, 4) \ +X(a, STATIC, SINGULAR, UENUM, stroke_color, 5) \ +X(a, STATIC, SINGULAR, FIXED32, stroke_argb, 6) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 7) +#define meshtastic_RangeAndBearing_CALLBACK NULL +#define meshtastic_RangeAndBearing_DEFAULT NULL +#define meshtastic_RangeAndBearing_anchor_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_Route_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, method, 1) \ +X(a, STATIC, SINGULAR, UENUM, direction, 2) \ +X(a, STATIC, SINGULAR, STRING, prefix, 3) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 4) \ +X(a, STATIC, REPEATED, MESSAGE, links, 5) \ +X(a, STATIC, SINGULAR, BOOL, truncated, 6) +#define meshtastic_Route_CALLBACK NULL +#define meshtastic_Route_DEFAULT NULL +#define meshtastic_Route_links_MSGTYPE meshtastic_Route_Link + +#define meshtastic_Route_Link_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, point, 1) \ +X(a, STATIC, SINGULAR, STRING, uid, 2) \ +X(a, STATIC, SINGULAR, STRING, callsign, 3) \ +X(a, STATIC, SINGULAR, UINT32, link_type, 4) +#define meshtastic_Route_Link_CALLBACK NULL +#define meshtastic_Route_Link_DEFAULT NULL +#define meshtastic_Route_Link_point_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_CasevacReport_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, precedence, 1) \ +X(a, STATIC, SINGULAR, UINT32, equipment_flags, 2) \ +X(a, STATIC, SINGULAR, UINT32, litter_patients, 3) \ +X(a, STATIC, SINGULAR, UINT32, ambulatory_patients, 4) \ +X(a, STATIC, SINGULAR, UENUM, security, 5) \ +X(a, STATIC, SINGULAR, UENUM, hlz_marking, 6) \ +X(a, STATIC, SINGULAR, STRING, zone_marker, 7) \ +X(a, STATIC, SINGULAR, UINT32, us_military, 8) \ +X(a, STATIC, SINGULAR, UINT32, us_civilian, 9) \ +X(a, STATIC, SINGULAR, UINT32, non_us_military, 10) \ +X(a, STATIC, SINGULAR, UINT32, non_us_civilian, 11) \ +X(a, STATIC, SINGULAR, UINT32, epw, 12) \ +X(a, STATIC, SINGULAR, UINT32, child, 13) \ +X(a, STATIC, SINGULAR, UINT32, terrain_flags, 14) \ +X(a, STATIC, SINGULAR, STRING, frequency, 15) +#define meshtastic_CasevacReport_CALLBACK NULL +#define meshtastic_CasevacReport_DEFAULT NULL + +#define meshtastic_EmergencyAlert_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, STRING, authoring_uid, 2) \ +X(a, STATIC, SINGULAR, STRING, cancel_reference_uid, 3) +#define meshtastic_EmergencyAlert_CALLBACK NULL +#define meshtastic_EmergencyAlert_DEFAULT NULL + +#define meshtastic_TaskRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, task_type, 1) \ +X(a, STATIC, SINGULAR, STRING, target_uid, 2) \ +X(a, STATIC, SINGULAR, STRING, assignee_uid, 3) \ +X(a, STATIC, SINGULAR, UENUM, priority, 4) \ +X(a, STATIC, SINGULAR, UENUM, status, 5) \ +X(a, STATIC, SINGULAR, STRING, note, 6) +#define meshtastic_TaskRequest_CALLBACK NULL +#define meshtastic_TaskRequest_DEFAULT NULL + #define meshtastic_TAKPacketV2_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, cot_type_id, 1) \ X(a, STATIC, SINGULAR, UENUM, how, 2) \ @@ -632,14 +1486,29 @@ X(a, STATIC, SINGULAR, STRING, tak_os, 20) \ X(a, STATIC, SINGULAR, STRING, endpoint, 21) \ X(a, STATIC, SINGULAR, STRING, phone, 22) \ X(a, STATIC, SINGULAR, STRING, cot_type_str, 23) \ +X(a, CALLBACK, SINGULAR, STRING, remarks, 24) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,pli,payload_variant.pli), 30) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,chat,payload_variant.chat), 31) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,aircraft,payload_variant.aircraft), 32) \ -X(a, STATIC, ONEOF, BYTES, (payload_variant,raw_detail,payload_variant.raw_detail), 33) -#define meshtastic_TAKPacketV2_CALLBACK NULL +X(a, STATIC, ONEOF, BYTES, (payload_variant,raw_detail,payload_variant.raw_detail), 33) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,shape,payload_variant.shape), 34) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,marker,payload_variant.marker), 35) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,rab,payload_variant.rab), 36) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,route,payload_variant.route), 37) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,casevac,payload_variant.casevac), 38) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,emergency,payload_variant.emergency), 39) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,task,payload_variant.task), 40) +#define meshtastic_TAKPacketV2_CALLBACK pb_default_field_callback #define meshtastic_TAKPacketV2_DEFAULT NULL #define meshtastic_TAKPacketV2_payload_variant_chat_MSGTYPE meshtastic_GeoChat #define meshtastic_TAKPacketV2_payload_variant_aircraft_MSGTYPE meshtastic_AircraftTrack +#define meshtastic_TAKPacketV2_payload_variant_shape_MSGTYPE meshtastic_DrawnShape +#define meshtastic_TAKPacketV2_payload_variant_marker_MSGTYPE meshtastic_Marker +#define meshtastic_TAKPacketV2_payload_variant_rab_MSGTYPE meshtastic_RangeAndBearing +#define meshtastic_TAKPacketV2_payload_variant_route_MSGTYPE meshtastic_Route +#define meshtastic_TAKPacketV2_payload_variant_casevac_MSGTYPE meshtastic_CasevacReport +#define meshtastic_TAKPacketV2_payload_variant_emergency_MSGTYPE meshtastic_EmergencyAlert +#define meshtastic_TAKPacketV2_payload_variant_task_MSGTYPE meshtastic_TaskRequest extern const pb_msgdesc_t meshtastic_TAKPacket_msg; extern const pb_msgdesc_t meshtastic_GeoChat_msg; @@ -648,6 +1517,15 @@ extern const pb_msgdesc_t meshtastic_Status_msg; extern const pb_msgdesc_t meshtastic_Contact_msg; extern const pb_msgdesc_t meshtastic_PLI_msg; extern const pb_msgdesc_t meshtastic_AircraftTrack_msg; +extern const pb_msgdesc_t meshtastic_CotGeoPoint_msg; +extern const pb_msgdesc_t meshtastic_DrawnShape_msg; +extern const pb_msgdesc_t meshtastic_Marker_msg; +extern const pb_msgdesc_t meshtastic_RangeAndBearing_msg; +extern const pb_msgdesc_t meshtastic_Route_msg; +extern const pb_msgdesc_t meshtastic_Route_Link_msg; +extern const pb_msgdesc_t meshtastic_CasevacReport_msg; +extern const pb_msgdesc_t meshtastic_EmergencyAlert_msg; +extern const pb_msgdesc_t meshtastic_TaskRequest_msg; extern const pb_msgdesc_t meshtastic_TAKPacketV2_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ @@ -658,18 +1536,36 @@ extern const pb_msgdesc_t meshtastic_TAKPacketV2_msg; #define meshtastic_Contact_fields &meshtastic_Contact_msg #define meshtastic_PLI_fields &meshtastic_PLI_msg #define meshtastic_AircraftTrack_fields &meshtastic_AircraftTrack_msg +#define meshtastic_CotGeoPoint_fields &meshtastic_CotGeoPoint_msg +#define meshtastic_DrawnShape_fields &meshtastic_DrawnShape_msg +#define meshtastic_Marker_fields &meshtastic_Marker_msg +#define meshtastic_RangeAndBearing_fields &meshtastic_RangeAndBearing_msg +#define meshtastic_Route_fields &meshtastic_Route_msg +#define meshtastic_Route_Link_fields &meshtastic_Route_Link_msg +#define meshtastic_CasevacReport_fields &meshtastic_CasevacReport_msg +#define meshtastic_EmergencyAlert_fields &meshtastic_EmergencyAlert_msg +#define meshtastic_TaskRequest_fields &meshtastic_TaskRequest_msg #define meshtastic_TAKPacketV2_fields &meshtastic_TAKPacketV2_msg /* Maximum encoded size of messages (where known) */ -#define MESHTASTIC_MESHTASTIC_ATAK_PB_H_MAX_SIZE meshtastic_TAKPacketV2_size +/* meshtastic_TAKPacketV2_size depends on runtime parameters */ +#define MESHTASTIC_MESHTASTIC_ATAK_PB_H_MAX_SIZE meshtastic_Route_size #define meshtastic_AircraftTrack_size 134 +#define meshtastic_CasevacReport_size 70 #define meshtastic_Contact_size 242 -#define meshtastic_GeoChat_size 444 +#define meshtastic_CotGeoPoint_size 12 +#define meshtastic_DrawnShape_size 553 +#define meshtastic_EmergencyAlert_size 100 +#define meshtastic_GeoChat_size 495 #define meshtastic_Group_size 4 +#define meshtastic_Marker_size 191 #define meshtastic_PLI_size 31 +#define meshtastic_RangeAndBearing_size 84 +#define meshtastic_Route_Link_size 83 +#define meshtastic_Route_size 1379 #define meshtastic_Status_size 3 -#define meshtastic_TAKPacketV2_size 1027 -#define meshtastic_TAKPacket_size 705 +#define meshtastic_TAKPacket_size 756 +#define meshtastic_TaskRequest_size 132 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/mesh.pb.cpp b/src/mesh/generated/meshtastic/mesh.pb.cpp index 7f1a738c6..3648d8850 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.cpp +++ b/src/mesh/generated/meshtastic/mesh.pb.cpp @@ -27,6 +27,9 @@ PB_BIND(meshtastic_KeyVerification, meshtastic_KeyVerification, AUTO) PB_BIND(meshtastic_StoreForwardPlusPlus, meshtastic_StoreForwardPlusPlus, 2) +PB_BIND(meshtastic_RemoteShell, meshtastic_RemoteShell, AUTO) + + PB_BIND(meshtastic_Waypoint, meshtastic_Waypoint, AUTO) @@ -129,6 +132,8 @@ PB_BIND(meshtastic_ChunkedPayloadResponse, meshtastic_ChunkedPayloadResponse, AU + + diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index fc6931d73..1c7eecd0d 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -308,8 +308,13 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_TDISPLAY_S3_PRO = 126, /* Heltec Mesh Node T096 board features an nRF52840 CPU and a TFT screen. */ meshtastic_HardwareModel_HELTEC_MESH_NODE_T096 = 127, - /* Seeed studio T1000-E Pro tracker card. NRF52840 w/ LR2021 radio, GPS, button, buzzer, and sensors. */ + /* Seeed studio T1000-E Pro tracker card. NRF52840 w/ LR2021 radio, + GPS, button, buzzer, and sensors. */ meshtastic_HardwareModel_TRACKER_T1000_E_PRO = 128, + /* Elecrow ThinkNode M7, M8 and M9 */ + meshtastic_HardwareModel_THINKNODE_M7 = 129, + meshtastic_HardwareModel_THINKNODE_M8 = 130, + meshtastic_HardwareModel_THINKNODE_M9 = 131, /* ------------------------------------------------------------------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------------------------------------------------------------------ */ @@ -513,6 +518,27 @@ typedef enum _meshtastic_StoreForwardPlusPlus_SFPP_message_type { meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF = 6 } meshtastic_StoreForwardPlusPlus_SFPP_message_type; +/* Frame op code for PTY session control and stream transport. + + Values 1-63 are client->server requests. + Values 64-127 are server->client responses/events. */ +typedef enum _meshtastic_RemoteShell_OpCode { + meshtastic_RemoteShell_OpCode_OP_UNSET = 0, + /* Client -> server */ + meshtastic_RemoteShell_OpCode_OPEN = 1, + meshtastic_RemoteShell_OpCode_INPUT = 2, + meshtastic_RemoteShell_OpCode_RESIZE = 3, + meshtastic_RemoteShell_OpCode_CLOSE = 4, + meshtastic_RemoteShell_OpCode_PING = 5, + meshtastic_RemoteShell_OpCode_ACK = 6, + /* Server -> client */ + meshtastic_RemoteShell_OpCode_OPEN_OK = 64, + meshtastic_RemoteShell_OpCode_OUTPUT = 65, + meshtastic_RemoteShell_OpCode_CLOSED = 66, + meshtastic_RemoteShell_OpCode_ERROR = 67, + meshtastic_RemoteShell_OpCode_PONG = 68 +} meshtastic_RemoteShell_OpCode; + /* The priority of this message for sending. Higher priorities are sent first (when managing the transmit queue). This field is never sent over the air, it is only used internally inside of a local device node. @@ -845,6 +871,27 @@ typedef struct _meshtastic_StoreForwardPlusPlus { uint32_t chain_count; } meshtastic_StoreForwardPlusPlus; +typedef PB_BYTES_ARRAY_T(200) meshtastic_RemoteShell_payload_t; +/* The actual over-the-mesh message doing RemoteShell */ +typedef struct _meshtastic_RemoteShell { + /* Structured frame operation. */ + meshtastic_RemoteShell_OpCode op; + /* Logical PTY session identifier. */ + uint32_t session_id; + /* Monotonic sequence number for this frame. */ + uint32_t seq; + /* Cumulative ack sequence number. */ + uint32_t ack_seq; + /* Opaque bytes payload for INPUT/OUTPUT/ERROR and other frame bodies. */ + meshtastic_RemoteShell_payload_t payload; + /* Terminal size columns used for OPEN/RESIZE signaling. */ + uint32_t cols; + /* Terminal size rows used for OPEN/RESIZE signaling. */ + uint32_t rows; + /* Bit flags for protocol extensions. */ + uint32_t flags; +} meshtastic_RemoteShell; + /* Waypoint message, used to share arbitrary locations across the mesh */ typedef struct _meshtastic_Waypoint { /* Id of the waypoint */ @@ -1385,6 +1432,10 @@ extern "C" { #define _meshtastic_StoreForwardPlusPlus_SFPP_message_type_MAX meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF #define _meshtastic_StoreForwardPlusPlus_SFPP_message_type_ARRAYSIZE ((meshtastic_StoreForwardPlusPlus_SFPP_message_type)(meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF+1)) +#define _meshtastic_RemoteShell_OpCode_MIN meshtastic_RemoteShell_OpCode_OP_UNSET +#define _meshtastic_RemoteShell_OpCode_MAX meshtastic_RemoteShell_OpCode_PONG +#define _meshtastic_RemoteShell_OpCode_ARRAYSIZE ((meshtastic_RemoteShell_OpCode)(meshtastic_RemoteShell_OpCode_PONG+1)) + #define _meshtastic_MeshPacket_Priority_MIN meshtastic_MeshPacket_Priority_UNSET #define _meshtastic_MeshPacket_Priority_MAX meshtastic_MeshPacket_Priority_MAX #define _meshtastic_MeshPacket_Priority_ARRAYSIZE ((meshtastic_MeshPacket_Priority)(meshtastic_MeshPacket_Priority_MAX+1)) @@ -1415,6 +1466,8 @@ extern "C" { #define meshtastic_StoreForwardPlusPlus_sfpp_message_type_ENUMTYPE meshtastic_StoreForwardPlusPlus_SFPP_message_type +#define meshtastic_RemoteShell_op_ENUMTYPE meshtastic_RemoteShell_OpCode + @@ -1459,6 +1512,7 @@ extern "C" { #define meshtastic_Data_init_default {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0} #define meshtastic_KeyVerification_init_default {0, {0, {0}}, {0, {0}}} #define meshtastic_StoreForwardPlusPlus_init_default {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0} +#define meshtastic_RemoteShell_init_default {_meshtastic_RemoteShell_OpCode_MIN, 0, 0, 0, {0, {0}}, 0, 0, 0} #define meshtastic_Waypoint_init_default {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_StatusMessage_init_default {""} #define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0} @@ -1492,6 +1546,7 @@ extern "C" { #define meshtastic_Data_init_zero {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0} #define meshtastic_KeyVerification_init_zero {0, {0, {0}}, {0, {0}}} #define meshtastic_StoreForwardPlusPlus_init_zero {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0} +#define meshtastic_RemoteShell_init_zero {_meshtastic_RemoteShell_OpCode_MIN, 0, 0, 0, {0, {0}}, 0, 0, 0} #define meshtastic_Waypoint_init_zero {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_StatusMessage_init_zero {""} #define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0} @@ -1581,6 +1636,14 @@ extern "C" { #define meshtastic_StoreForwardPlusPlus_encapsulated_from_tag 8 #define meshtastic_StoreForwardPlusPlus_encapsulated_rxtime_tag 9 #define meshtastic_StoreForwardPlusPlus_chain_count_tag 10 +#define meshtastic_RemoteShell_op_tag 1 +#define meshtastic_RemoteShell_session_id_tag 2 +#define meshtastic_RemoteShell_seq_tag 3 +#define meshtastic_RemoteShell_ack_seq_tag 4 +#define meshtastic_RemoteShell_payload_tag 5 +#define meshtastic_RemoteShell_cols_tag 6 +#define meshtastic_RemoteShell_rows_tag 7 +#define meshtastic_RemoteShell_flags_tag 8 #define meshtastic_Waypoint_id_tag 1 #define meshtastic_Waypoint_latitude_i_tag 2 #define meshtastic_Waypoint_longitude_i_tag 3 @@ -1813,6 +1876,18 @@ X(a, STATIC, SINGULAR, UINT32, chain_count, 10) #define meshtastic_StoreForwardPlusPlus_CALLBACK NULL #define meshtastic_StoreForwardPlusPlus_DEFAULT NULL +#define meshtastic_RemoteShell_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, op, 1) \ +X(a, STATIC, SINGULAR, UINT32, session_id, 2) \ +X(a, STATIC, SINGULAR, UINT32, seq, 3) \ +X(a, STATIC, SINGULAR, UINT32, ack_seq, 4) \ +X(a, STATIC, SINGULAR, BYTES, payload, 5) \ +X(a, STATIC, SINGULAR, UINT32, cols, 6) \ +X(a, STATIC, SINGULAR, UINT32, rows, 7) \ +X(a, STATIC, SINGULAR, UINT32, flags, 8) +#define meshtastic_RemoteShell_CALLBACK NULL +#define meshtastic_RemoteShell_DEFAULT NULL + #define meshtastic_Waypoint_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, id, 1) \ X(a, STATIC, OPTIONAL, SFIXED32, latitude_i, 2) \ @@ -2095,6 +2170,7 @@ extern const pb_msgdesc_t meshtastic_Routing_msg; extern const pb_msgdesc_t meshtastic_Data_msg; extern const pb_msgdesc_t meshtastic_KeyVerification_msg; extern const pb_msgdesc_t meshtastic_StoreForwardPlusPlus_msg; +extern const pb_msgdesc_t meshtastic_RemoteShell_msg; extern const pb_msgdesc_t meshtastic_Waypoint_msg; extern const pb_msgdesc_t meshtastic_StatusMessage_msg; extern const pb_msgdesc_t meshtastic_MqttClientProxyMessage_msg; @@ -2130,6 +2206,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_Data_fields &meshtastic_Data_msg #define meshtastic_KeyVerification_fields &meshtastic_KeyVerification_msg #define meshtastic_StoreForwardPlusPlus_fields &meshtastic_StoreForwardPlusPlus_msg +#define meshtastic_RemoteShell_fields &meshtastic_RemoteShell_msg #define meshtastic_Waypoint_fields &meshtastic_Waypoint_msg #define meshtastic_StatusMessage_fields &meshtastic_StatusMessage_msg #define meshtastic_MqttClientProxyMessage_fields &meshtastic_MqttClientProxyMessage_msg @@ -2185,6 +2262,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_NodeRemoteHardwarePin_size 29 #define meshtastic_Position_size 144 #define meshtastic_QueueStatus_size 23 +#define meshtastic_RemoteShell_size 241 #define meshtastic_RouteDiscovery_size 256 #define meshtastic_Routing_size 259 #define meshtastic_StatusMessage_size 81 diff --git a/src/mesh/generated/meshtastic/portnums.pb.h b/src/mesh/generated/meshtastic/portnums.pb.h index a474e5b92..494ef4a54 100644 --- a/src/mesh/generated/meshtastic/portnums.pb.h +++ b/src/mesh/generated/meshtastic/portnums.pb.h @@ -76,6 +76,8 @@ typedef enum _meshtastic_PortNum { meshtastic_PortNum_ALERT_APP = 11, /* Module/port for handling key verification requests. */ meshtastic_PortNum_KEY_VERIFICATION_APP = 12, + /* Module/port for handling primitive remote shell access. */ + meshtastic_PortNum_REMOTE_SHELL_APP = 13, /* Provides a 'ping' service that replies to any packet it receives. Also serves as a small example module. ENCODING: ASCII Plaintext */ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index f48d946a4..8c0fdd563 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -113,7 +113,9 @@ typedef enum _meshtastic_TelemetrySensorType { /* SCD30 CO2, humidity, temperature sensor */ meshtastic_TelemetrySensorType_SCD30 = 49, /* SHT family of sensors for temperature and humidity */ - meshtastic_TelemetrySensorType_SHTXX = 50 + meshtastic_TelemetrySensorType_SHTXX = 50, + /* DS248X Bridge for one-wire temperature sensors */ + meshtastic_TelemetrySensorType_DS248X = 51 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -206,6 +208,9 @@ typedef struct _meshtastic_EnvironmentMetrics { /* Soil temperature measured (*C) */ bool has_soil_temperature; float soil_temperature; + /* One-wire temperature (*C) */ + pb_size_t one_wire_temperature_count; + float one_wire_temperature[8]; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -491,8 +496,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHTXX -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHTXX+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_DS248X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_DS248X+1)) @@ -508,7 +513,7 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -519,7 +524,7 @@ extern "C" { #define meshtastic_Nau7802Config_init_default {0, 0} #define meshtastic_SEN5XState_init_default {0, 0, 0, false, 0, false, 0, false, 0} #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -558,6 +563,7 @@ extern "C" { #define meshtastic_EnvironmentMetrics_rainfall_24h_tag 20 #define meshtastic_EnvironmentMetrics_soil_moisture_tag 21 #define meshtastic_EnvironmentMetrics_soil_temperature_tag 22 +#define meshtastic_EnvironmentMetrics_one_wire_temperature_tag 23 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -683,7 +689,8 @@ X(a, STATIC, OPTIONAL, FLOAT, radiation, 18) \ X(a, STATIC, OPTIONAL, FLOAT, rainfall_1h, 19) \ X(a, STATIC, OPTIONAL, FLOAT, rainfall_24h, 20) \ X(a, STATIC, OPTIONAL, UINT32, soil_moisture, 21) \ -X(a, STATIC, OPTIONAL, FLOAT, soil_temperature, 22) +X(a, STATIC, OPTIONAL, FLOAT, soil_temperature, 22) \ +X(a, STATIC, REPEATED, FLOAT, one_wire_temperature, 23) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -852,7 +859,7 @@ extern const pb_msgdesc_t meshtastic_SEN5XState_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 150 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 113 +#define meshtastic_EnvironmentMetrics_size 161 #define meshtastic_HealthMetrics_size 11 #define meshtastic_HostMetrics_size 264 #define meshtastic_LocalStats_size 87 From 4587dc2d64e6d89d82e572917896ed6fedc51ab7 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Wed, 15 Apr 2026 00:55:11 +1000 Subject: [PATCH 10/67] Add RADIOLIB_EXCLUDE_LR2021 in places that excluded LR11x0 (#10112) To save resources, some devices where LR11x0 was never an option excluded it from compilation, using RADIOLIB_EXCLUDE_LR11X0 . As we will soon have LR2021 support, apply the same treatment to that chip to these devices, by adding RADIOLIB_EXCLUDE_LR2021 --- variants/esp32/heltec_wireless_bridge/platformio.ini | 1 + variants/esp32s3/link32_s3_v1/platformio.ini | 1 + variants/nrf52840/gat562_mesh_trial_tracker/platformio.ini | 1 + variants/nrf52840/meshlink/platformio.ini | 4 +++- variants/nrf52840/r1-neo/platformio.ini | 1 + variants/nrf52840/rak2560/platformio.ini | 1 + variants/nrf52840/rak3401_1watt/platformio.ini | 1 + variants/nrf52840/rak4631/platformio.ini | 1 + variants/nrf52840/rak4631_epaper/platformio.ini | 1 + variants/nrf52840/rak4631_epaper_onrxtx/platformio.ini | 1 + variants/nrf52840/rak4631_nomadstar_meteor_pro/platformio.ini | 1 + variants/nrf52840/rak_wismeshtag/platformio.ini | 1 + variants/stm32/stm32.ini | 1 + 13 files changed, 15 insertions(+), 1 deletion(-) diff --git a/variants/esp32/heltec_wireless_bridge/platformio.ini b/variants/esp32/heltec_wireless_bridge/platformio.ini index 6f9de7a84..42a35697c 100644 --- a/variants/esp32/heltec_wireless_bridge/platformio.ini +++ b/variants/esp32/heltec_wireless_bridge/platformio.ini @@ -10,6 +10,7 @@ build_flags = -D BOARD_HAS_PSRAM -D RADIOLIB_EXCLUDE_LR11X0=1 -D RADIOLIB_EXCLUDE_SX128X=1 + -D RADIOLIB_EXCLUDE_LR2021=1 -D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1 -D MESHTASTIC_EXCLUDE_DETECTIONSENSOR=1 -D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 diff --git a/variants/esp32s3/link32_s3_v1/platformio.ini b/variants/esp32s3/link32_s3_v1/platformio.ini index acce3dafb..b11ffaad0 100644 --- a/variants/esp32s3/link32_s3_v1/platformio.ini +++ b/variants/esp32s3/link32_s3_v1/platformio.ini @@ -11,3 +11,4 @@ build_flags = -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 diff --git a/variants/nrf52840/gat562_mesh_trial_tracker/platformio.ini b/variants/nrf52840/gat562_mesh_trial_tracker/platformio.ini index e7eede80f..cecca3d81 100644 --- a/variants/nrf52840/gat562_mesh_trial_tracker/platformio.ini +++ b/variants/nrf52840/gat562_mesh_trial_tracker/platformio.ini @@ -11,4 +11,5 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/gat562_mesh_trial_tracker> diff --git a/variants/nrf52840/meshlink/platformio.ini b/variants/nrf52840/meshlink/platformio.ini index 28122d9bd..f3dc6185c 100644 --- a/variants/nrf52840/meshlink/platformio.ini +++ b/variants/nrf52840/meshlink/platformio.ini @@ -12,6 +12,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/meshlink> debug_tool = jlink @@ -30,6 +31,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 -D USE_EINK -D EINK_DISPLAY_MODEL=GxEPD2_213_B74 -D EINK_WIDTH=250 @@ -51,4 +53,4 @@ lib_deps = debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ; Note: as of 6/2013 the serial/bootloader based programming takes approximately 30 seconds -;upload_protocol = jlink \ No newline at end of file +;upload_protocol = jlink diff --git a/variants/nrf52840/r1-neo/platformio.ini b/variants/nrf52840/r1-neo/platformio.ini index 85fe49cf1..0aaec2330 100644 --- a/variants/nrf52840/r1-neo/platformio.ini +++ b/variants/nrf52840/r1-neo/platformio.ini @@ -18,6 +18,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/r1-neo> + + lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nrf52840/rak2560/platformio.ini b/variants/nrf52840/rak2560/platformio.ini index 1703a13ae..54b66f4b2 100644 --- a/variants/nrf52840/rak2560/platformio.ini +++ b/variants/nrf52840/rak2560/platformio.ini @@ -18,6 +18,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 -DHAS_RAKPROT=1 ; Define if RAk OneWireSerial is used (disables GPS) build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak2560> + + + lib_deps = diff --git a/variants/nrf52840/rak3401_1watt/platformio.ini b/variants/nrf52840/rak3401_1watt/platformio.ini index bb8fa28df..889a17ed6 100644 --- a/variants/nrf52840/rak3401_1watt/platformio.ini +++ b/variants/nrf52840/rak3401_1watt/platformio.ini @@ -22,6 +22,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak3401_1watt> + lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nrf52840/rak4631/platformio.ini b/variants/nrf52840/rak4631/platformio.ini index 4a96fc8d9..179d73e92 100644 --- a/variants/nrf52840/rak4631/platformio.ini +++ b/variants/nrf52840/rak4631/platformio.ini @@ -21,6 +21,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} \ +<../variants/nrf52840/rak4631> \ + \ diff --git a/variants/nrf52840/rak4631_epaper/platformio.ini b/variants/nrf52840/rak4631_epaper/platformio.ini index caa6ea328..f71fb6301 100644 --- a/variants/nrf52840/rak4631_epaper/platformio.ini +++ b/variants/nrf52840/rak4631_epaper/platformio.ini @@ -11,6 +11,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak4631_epaper> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nrf52840/rak4631_epaper_onrxtx/platformio.ini b/variants/nrf52840/rak4631_epaper_onrxtx/platformio.ini index 84a582fd9..670b2c415 100644 --- a/variants/nrf52840/rak4631_epaper_onrxtx/platformio.ini +++ b/variants/nrf52840/rak4631_epaper_onrxtx/platformio.ini @@ -13,6 +13,7 @@ build_flags = ${nrf52840_base.build_flags} -D RADIOLIB_EXCLUDE_SX128X=1 -D RADIOLIB_EXCLUDE_SX127X=1 -D RADIOLIB_EXCLUDE_LR11X0=1 + -D RADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak4631_epaper_onrxtx> lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nrf52840/rak4631_nomadstar_meteor_pro/platformio.ini b/variants/nrf52840/rak4631_nomadstar_meteor_pro/platformio.ini index 9b15e668a..f1641e7e4 100644 --- a/variants/nrf52840/rak4631_nomadstar_meteor_pro/platformio.ini +++ b/variants/nrf52840/rak4631_nomadstar_meteor_pro/platformio.ini @@ -21,6 +21,7 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak4631_nomadstar_meteor_pro> + + lib_deps = ${nrf52840_base.lib_deps} diff --git a/variants/nrf52840/rak_wismeshtag/platformio.ini b/variants/nrf52840/rak_wismeshtag/platformio.ini index 1e6e63e60..07fd6e73f 100644 --- a/variants/nrf52840/rak_wismeshtag/platformio.ini +++ b/variants/nrf52840/rak_wismeshtag/platformio.ini @@ -19,5 +19,6 @@ build_flags = ${nrf52840_base.build_flags} -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 -DMESHTASTIC_EXCLUDE_WIFI=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak_wismeshtag> diff --git a/variants/stm32/stm32.ini b/variants/stm32/stm32.ini index d2c155398..542d08800 100644 --- a/variants/stm32/stm32.ini +++ b/variants/stm32/stm32.ini @@ -35,6 +35,7 @@ build_flags = -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 + -DRADIOLIB_EXCLUDE_LR2021=1 -DHAL_DAC_MODULE_ONLY -DHAL_RNG_MODULE_ENABLED -Wl,--wrap=__assert_func From 9e182a595c83fcd18ac9dc84f1684e09d43eff8e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 13 Apr 2026 06:43:11 -0500 Subject: [PATCH 11/67] Enhance release notes generation with commit range comparison --- .github/workflows/main_matrix.yml | 6 ++- bin/generate_release_notes.py | 83 ++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index f0b16a31f..88395600a 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -301,10 +301,12 @@ jobs: id: release_notes run: | chmod +x ./bin/generate_release_notes.py - NOTES=$(./bin/generate_release_notes.py ${{ needs.version.outputs.long }}) + NOTES=$(./bin/generate_release_notes.py ${{ needs.version.outputs.long }} --compare-ref HEAD 2>release_notes.log) echo "notes<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + echo "### Release note range" >> $GITHUB_STEP_SUMMARY + cat release_notes.log >> $GITHUB_STEP_SUMMARY env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -466,7 +468,7 @@ jobs: - name: Generate release notes run: | chmod +x ./bin/generate_release_notes.py - ./bin/generate_release_notes.py ${{ needs.version.outputs.long }} > ./publish/release_notes.md + ./bin/generate_release_notes.py ${{ needs.version.outputs.long }} --compare-ref HEAD > ./publish/release_notes.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bin/generate_release_notes.py b/bin/generate_release_notes.py index d0f1147da..533ff6909 100755 --- a/bin/generate_release_notes.py +++ b/bin/generate_release_notes.py @@ -1,25 +1,31 @@ #!/usr/bin/env python3 -""" -Generate release notes from merged PRs on develop and master branches. -Categorizes PRs into Enhancements and Bug Fixes/Maintenance sections. -""" +"""Generate release notes from the actual release commit range.""" -import subprocess -import re +import argparse import json +import re +import subprocess import sys -from datetime import datetime -def get_last_release_tag(): - """Get the most recent release tag.""" +def get_last_release_tag(compare_ref, exclude_tag=None): + """Get the most recent version tag merged into compare_ref.""" result = subprocess.run( - ["git", "describe", "--tags", "--abbrev=0"], + ["git", "tag", "--merged", compare_ref, "--sort=-version:refname", "v*"], capture_output=True, text=True, check=True, ) - return result.stdout.strip() + + for line in result.stdout.splitlines(): + candidate = line.strip() + if not candidate: + continue + if exclude_tag and candidate == exclude_tag: + continue + return candidate + + raise subprocess.CalledProcessError(result.returncode, result.args, output=result.stdout, stderr=result.stderr) def get_tag_date(tag): @@ -33,18 +39,18 @@ def get_tag_date(tag): return result.stdout.strip() -def get_merged_prs_since_tag(tag, branch): - """Get all merged PRs since the given tag on the specified branch.""" - # Get commits since tag on the branch - look for PR numbers in parentheses +def get_merged_prs_in_range(tag, compare_ref): + """Get all merged PRs in the git range between tag and compare_ref.""" result = subprocess.run( [ "git", "log", - f"{tag}..origin/{branch}", + f"{tag}..{compare_ref}", "--oneline", ], capture_output=True, text=True, + check=True, ) prs = [] @@ -65,6 +71,25 @@ def get_merged_prs_since_tag(tag, branch): return prs +def parse_args(): + """Parse CLI arguments.""" + parser = argparse.ArgumentParser( + description="Generate release notes from the actual release commit range." + ) + parser.add_argument("new_version", help="Version that will be tagged for this release") + parser.add_argument( + "--base-tag", + dest="base_tag", + help="Existing version tag to diff from. Defaults to the latest version tag merged into the compare ref.", + ) + parser.add_argument( + "--compare-ref", + default="HEAD", + help="Git ref to diff to. Defaults to HEAD.", + ) + return parser.parse_args() + + def get_pr_details(pr_number): """Get PR details from GitHub API via gh CLI.""" try: @@ -268,28 +293,28 @@ def get_new_contributors(pr_details_list, tag, repo="meshtastic/firmware"): def main(): - if len(sys.argv) < 2: - print("Usage: generate_release_notes.py ", file=sys.stderr) - sys.exit(1) - - new_version = sys.argv[1] + args = parse_args() + new_version = args.new_version + compare_ref = args.compare_ref + current_tag = f"v{new_version}" # Get last release tag try: - last_tag = get_last_release_tag() + last_tag = args.base_tag or get_last_release_tag(compare_ref, exclude_tag=current_tag) except subprocess.CalledProcessError: print("Error: Could not find last release tag", file=sys.stderr) sys.exit(1) - # Collect PRs from both branches - all_pr_numbers = set() + print( + f"Resolved release note range: {last_tag}..{compare_ref}", + file=sys.stderr, + ) - for branch in ["develop", "master"]: - try: - prs = get_merged_prs_since_tag(last_tag, branch) - all_pr_numbers.update(prs) - except Exception as e: - print(f"Warning: Could not get PRs from {branch}: {e}", file=sys.stderr) + try: + all_pr_numbers = set(get_merged_prs_in_range(last_tag, compare_ref)) + except subprocess.CalledProcessError as e: + print(f"Error: Could not get PRs for range {last_tag}..{compare_ref}: {e}", file=sys.stderr) + sys.exit(1) # Get details for all PRs enhancements = [] From a67eb15ad33e865220903c07866cbdc3fae11ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 13 Apr 2026 15:48:30 +0200 Subject: [PATCH 12/67] fix last cppcheck issue (#10154) --- src/input/CardputerKeyboard.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/input/CardputerKeyboard.cpp b/src/input/CardputerKeyboard.cpp index ec1ed383a..1bd695461 100644 --- a/src/input/CardputerKeyboard.cpp +++ b/src/input/CardputerKeyboard.cpp @@ -121,7 +121,6 @@ void CardputerKeyboard::pressed(uint8_t key) modifierFlag = 0; } - uint8_t next_key = 0; int row = (key - 1) / 10; int col = (key - 1) % 10; From d24d8806e13569d9dd88271cf8eef37736e58f97 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 13 Apr 2026 14:50:51 -0500 Subject: [PATCH 13/67] Fix heap blowout on TBeams (#10155) * Fix heap blowout on TBeams * Update src/graphics/draw/MessageRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Set MESSAGE_HISTORY_LIMIT to 10 for original ESP32 to optimize RAM usage * Optimize message frame allocation to prevent excessive memory usage * Refine message history limits for resource-constrained builds and cap cached lines to prevent heap overflow * Update src/graphics/draw/MessageRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/MessageStore.h | 7 +++++++ src/graphics/draw/MessageRenderer.cpp | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/MessageStore.h b/src/MessageStore.h index 6203d8ed0..77271f1c9 100644 --- a/src/MessageStore.h +++ b/src/MessageStore.h @@ -21,8 +21,15 @@ // How many messages are stored (RAM + flash). // Define -DMESSAGE_HISTORY_LIMIT=N in build_flags to control memory usage. #ifndef MESSAGE_HISTORY_LIMIT +#if defined(ARCH_ESP32) && \ + !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2)) +// Baseline ESP32 (non-PSRAM variants) has limited heap; reduce message history on resource-constrained builds. +// Override with -DMESSAGE_HISTORY_LIMIT=N if needed. +#define MESSAGE_HISTORY_LIMIT 10 +#else #define MESSAGE_HISTORY_LIMIT 20 #endif +#endif // Internal alias used everywhere in code – do NOT redefine elsewhere. #define MAX_MESSAGES_SAVED MESSAGE_HISTORY_LIMIT diff --git a/src/graphics/draw/MessageRenderer.cpp b/src/graphics/draw/MessageRenderer.cpp index 501a7ae2c..2fd9bf541 100644 --- a/src/graphics/draw/MessageRenderer.cpp +++ b/src/graphics/draw/MessageRenderer.cpp @@ -422,6 +422,17 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 std::vector isMine; // track alignment std::vector isHeader; // track header lines std::vector ackForLine; + // Hard limit on total cached lines to prevent unbounded growth from a single long message. + // Reserve to the actual cache cap up front, because a single message can expand to many more + // wrapped display lines than a small per-message estimate would predict. For a display + // rendering only ~5-30 lines at a time, caching more than this limit wastes heap. Stop + // appending once we reach MAX_CACHED_LINES to prevent a single message from blowing out the + // heap. + constexpr size_t MAX_CACHED_LINES = 100U; // ~5-6KB for std::string overhead on 32-bit (if each ~50-60 bytes avg) + allLines.reserve(MAX_CACHED_LINES); + isMine.reserve(MAX_CACHED_LINES); + isHeader.reserve(MAX_CACHED_LINES); + ackForLine.reserve(MAX_CACHED_LINES); for (auto it = filtered.rbegin(); it != filtered.rend(); ++it) { const auto &m = *it; @@ -565,16 +576,23 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 int wrapWidth = mine ? rightTextWidth : leftTextWidth; std::vector wrapped = generateLines(display, "", msgText, wrapWidth); + // Per-message wrap-line limit: even if wrapping produces many lines, cap them to prevent + // a single long message from consuming most or all of the cache. + constexpr size_t MAX_WRAPPED_LINES_PER_MSG = 20U; + size_t wrappedCount = 0; for (auto &ln : wrapped) { - allLines.push_back(ln); + if (allLines.size() >= MAX_CACHED_LINES || wrappedCount >= MAX_WRAPPED_LINES_PER_MSG) + break; // Cache limit or per-message limit reached; stop adding lines from this message + allLines.emplace_back(std::move(ln)); isMine.push_back(mine); isHeader.push_back(false); ackForLine.push_back(AckStatus::NONE); + ++wrappedCount; } } // Cache lines and heights - cachedLines = allLines; + cachedLines.swap(allLines); cachedHeights = calculateLineHeights(cachedLines, emotes, isHeader); std::vector blocks = buildMessageBlocks(isHeader, isMine); From 4059202a5c8d33e99dde76a538c67f8d46583958 Mon Sep 17 00:00:00 2001 From: Jennifer Sanchez <67692052+derpyspike@users.noreply.github.com> Date: Tue, 14 Apr 2026 20:11:36 +0200 Subject: [PATCH 14/67] Added support for Spreading Factors 5 and 6 on compatible radios (#10160) --- src/mesh/MeshRadio.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesh/MeshRadio.h b/src/mesh/MeshRadio.h index 3c3a4cf65..089b4b189 100644 --- a/src/mesh/MeshRadio.h +++ b/src/mesh/MeshRadio.h @@ -4,6 +4,7 @@ #include "MeshTypes.h" #include "PointerQueue.h" #include "configuration.h" +#include "detect/LoRaRadioType.h" // Sentinel marking the end of a modem preset array static constexpr meshtastic_Config_LoRaConfig_ModemPreset MODEM_PRESET_END = @@ -59,7 +60,7 @@ extern const RegionInfo *myRegion; extern void initRegion(); // Valid LoRa spread factor range and defaults -constexpr uint8_t LORA_SF_MIN = 7; +constexpr uint8_t LORA_SF_MIN = 5; constexpr uint8_t LORA_SF_MAX = 12; constexpr uint8_t LORA_SF_DEFAULT = 11; // LONG_FAST default @@ -71,10 +72,14 @@ constexpr uint8_t LORA_CR_DEFAULT = 5; // LONG_FAST default // Default bandwidth in kHz (LONG_FAST) constexpr float LORA_BW_DEFAULT_KHZ = 250.0f; -/// Clamp spread factor to the valid LoRa range [7, 12]. +/// Clamp spread factor to the valid LoRa range [5, 12]. /// Out-of-range values (including 0 from unset preset mode) return LORA_SF_DEFAULT. static inline uint8_t clampSpreadFactor(uint8_t sf) { + // We check for RF95 radios that are incompatible with Spreading Factors 5 and 6. + if (radioType == RF95_RADIO && (sf == 5 || sf == 6)) + return LORA_SF_DEFAULT; + if (sf < LORA_SF_MIN || sf > LORA_SF_MAX) return LORA_SF_DEFAULT; return sf; From 1341cd4078ecb7060df5d37ccd0c909c7e06f07f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:11:47 -0500 Subject: [PATCH 15/67] Automated version bumps (#10159) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- bin/org.meshtastic.meshtasticd.metainfo.xml | 3 +++ debian/changelog | 6 ++++++ version.properties | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/org.meshtastic.meshtasticd.metainfo.xml b/bin/org.meshtastic.meshtasticd.metainfo.xml index 0642fdb07..a1690186b 100644 --- a/bin/org.meshtastic.meshtasticd.metainfo.xml +++ b/bin/org.meshtastic.meshtasticd.metainfo.xml @@ -87,6 +87,9 @@ + + https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.23 + https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.22 diff --git a/debian/changelog b/debian/changelog index b13a2ae9d..c3f1424a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +meshtasticd (2.7.23.0) unstable; urgency=medium + + * Version 2.7.23 + + -- GitHub Actions Tue, 14 Apr 2026 12:29:48 +0000 + meshtasticd (2.7.22.0) unstable; urgency=medium * Version 2.7.22 diff --git a/version.properties b/version.properties index 8621dd9c9..4ee342bb8 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 7 -build = 22 +build = 23 From 47e129f4bdec33a5012851aa3546073aa87d9254 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:11:47 -0500 Subject: [PATCH 16/67] Automated version bumps (#10159) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- bin/org.meshtastic.meshtasticd.metainfo.xml | 3 +++ debian/changelog | 6 ++++++ version.properties | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/org.meshtastic.meshtasticd.metainfo.xml b/bin/org.meshtastic.meshtasticd.metainfo.xml index 0642fdb07..a1690186b 100644 --- a/bin/org.meshtastic.meshtasticd.metainfo.xml +++ b/bin/org.meshtastic.meshtasticd.metainfo.xml @@ -87,6 +87,9 @@ + + https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.23 + https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.22 diff --git a/debian/changelog b/debian/changelog index b13a2ae9d..c3f1424a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +meshtasticd (2.7.23.0) unstable; urgency=medium + + * Version 2.7.23 + + -- GitHub Actions Tue, 14 Apr 2026 12:29:48 +0000 + meshtasticd (2.7.22.0) unstable; urgency=medium * Version 2.7.22 diff --git a/version.properties b/version.properties index 8621dd9c9..4ee342bb8 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 7 -build = 22 +build = 23 From 0cab43fb43192cb81d585f3a0fded4fe1d286cc7 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 14 Apr 2026 14:32:48 -0500 Subject: [PATCH 17/67] Add PortduinoSetOptions to overwrite the realhardware bool (#10157) Co-authored-by: Ben Meadors --- src/platform/portduino/PortduinoGlue.cpp | 4 +++- variants/native/portduino.ini | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 5f51ee083..7833b3603 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -654,7 +654,9 @@ void portduinoSetup() if (verboseEnabled && portduino_config.logoutputlevel != level_trace) { portduino_config.logoutputlevel = level_debug; } - + if (portduino_config.lora_spi_dev != "") { + portduinoSetOptions({.realHardware = true}); + } return; } diff --git a/variants/native/portduino.ini b/variants/native/portduino.ini index 86b1fe60a..87d8431a3 100644 --- a/variants/native/portduino.ini +++ b/variants/native/portduino.ini @@ -2,7 +2,7 @@ [portduino_base] platform = # renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop - https://github.com/meshtastic/platform-native/archive/f566d364204416cdbf298e349213f7d551f793d9.zip + https://github.com/meshtastic/platform-native/archive/71ed55bb95feb3c43ebde1ec1e2e17643a424c04.zip framework = arduino build_src_filter = From 61bab08d9e8b142b5c0054ea355479b19d25ec97 Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 14 Apr 2026 14:52:57 -0400 Subject: [PATCH 18/67] Pioarduino 55.03.38-1 --- variants/esp32/esp32-common.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/esp32/esp32-common.ini b/variants/esp32/esp32-common.ini index e406f963e..52de2acd5 100644 --- a/variants/esp32/esp32-common.ini +++ b/variants/esp32/esp32-common.ini @@ -5,7 +5,7 @@ custom_esp32_kind = custom_mtjson_part = platform = # TODO renovate - https://github.com/pioarduino/platform-espressif32/releases/download/55.03.38/platform-espressif32.zip + https://github.com/pioarduino/platform-espressif32/releases/download/55.03.38-1/platform-espressif32.zip ; https://github.com/pioarduino/platform-espressif32.git#develop extra_scripts = From c1bee82bafd95a52289c5f603e91a8bbb2d36d2f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 21:07:15 -0500 Subject: [PATCH 19/67] Update platform-native digest to 71ed55b (#10165) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- variants/native/portduino.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/native/portduino.ini b/variants/native/portduino.ini index 86b1fe60a..87d8431a3 100644 --- a/variants/native/portduino.ini +++ b/variants/native/portduino.ini @@ -2,7 +2,7 @@ [portduino_base] platform = # renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop - https://github.com/meshtastic/platform-native/archive/f566d364204416cdbf298e349213f7d551f793d9.zip + https://github.com/meshtastic/platform-native/archive/71ed55bb95feb3c43ebde1ec1e2e17643a424c04.zip framework = arduino build_src_filter = From 026213aab74c13a55915eeb8d4a1089efe321e43 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 16 Apr 2026 17:58:54 +0800 Subject: [PATCH 20/67] feat(stm32): Add STM32 ADC support to AnalogBatteryLevel (#9369) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Integrate STM32 battery monitoring into AnalogBatteryLevel, supporting external GPIO ADC pins as well as internal VBAT channel. Features: - ADC reading using STM32 LL (Lower Layer) macros supporting external ADC channels and internal VBAT channel (AVBAT) - ADC compensation using STM32 LL macros with factory-calibrated VREFINT (AVREF) for accurate voltage measurement - LFP battery OCV curve for STM32WL using AVBAT (STM32 VDD absolute maximum supply voltage 3.9V, direct connection of Li-Po batteries is not supported) Internal VBAT channel implemented in: - Russell - RAK3172 In these variants, ADC_MULTIPLIER = (1.01f * 3) = 3.30 as there is a 3:1 internal divider (DS13105 Rev 12 §5.3.21), and a bit of tolerance as the actual 10% spec leads to readings much too high. Assisted-by: Claude:sonnet-4-5 Signed-off-by: Andrew Yong --- src/Power.cpp | 39 ++++++++++++++++++++++++++++---- src/power.h | 5 ++++ variants/stm32/rak3172/variant.h | 5 ++++ variants/stm32/russell/variant.h | 10 ++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index d82c870ed..26b961525 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -40,6 +40,22 @@ #include "concurrency/LockGuard.h" #endif +#if defined(ARCH_STM32WL) && defined(BATTERY_PIN) +#include "stm32yyxx_ll_adc.h" + +/* Analog read resolution */ +#if defined(LL_ADC_RESOLUTION_12B) +#define LL_ADC_RESOLUTION LL_ADC_RESOLUTION_12B +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#elif defined(LL_ADC_DS_DATA_WIDTH_12_BIT) +#define LL_ADC_RESOLUTION LL_ADC_DS_DATA_WIDTH_12_BIT +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#else +#error "ADC resolution could not be defined!" +#endif +#define ADC_RANGE (1 << BATTERY_SENSE_RESOLUTION_BITS) +#endif + #if defined(DEBUG_HEAP_MQTT) && !MESHTASTIC_EXCLUDE_MQTT #include "mqtt/MQTT.h" #include "target_specific.h" @@ -328,11 +344,17 @@ class AnalogBatteryLevel : public HasBatteryLevel float scaled = 0; battery_adcEnable(); -#ifdef ARCH_ESP32 // ADC block for espressif platforms +#ifdef ARCH_STM32WL + // STM32 ADC with VREFINT runtime calibration + Vref = __LL_ADC_CALC_VREFANALOG_VOLTAGE(analogRead(AVREF), LL_ADC_RESOLUTION); + raw = analogRead(BATTERY_PIN); + scaled = __LL_ADC_CALC_DATA_TO_VOLTAGE(Vref, raw, LL_ADC_RESOLUTION); + scaled *= operativeAdcMultiplier; +#elif defined(ARCH_ESP32) // ADC block for espressif platforms raw = espAdcRead(); scaled = esp_adc_cal_raw_to_voltage(raw, adc_characs); scaled *= operativeAdcMultiplier; -#else // block for all other platforms +#else // block for all other platforms #ifdef ARCH_NRF52 concurrency::LockGuard saadcGuard(concurrency::nrf52SaadcLock); #endif @@ -530,6 +552,11 @@ class AnalogBatteryLevel : public HasBatteryLevel bool initial_read_done = false; float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS); uint32_t last_read_time_ms = 0; +#ifdef ARCH_STM32WL + // 3300mV placeholder for STM32 errata where VREFINT factory calibration may be missing + // (e.g. STM32U0, see DS14756 Rev 3 §2.4.1 "VREFINT offset") + uint32_t Vref = 3300; +#endif #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && defined(HAS_RAKPROT) @@ -639,7 +666,9 @@ bool Power::analogInit() #define BATTERY_SENSE_RESOLUTION_BITS 10 #endif -#ifdef ARCH_ESP32 // ESP32 needs special analog stuff +#ifdef ARCH_STM32WL + analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS); +#elif defined(ARCH_ESP32) // ESP32 needs special analog stuff #ifndef ADC_WIDTH // max resolution by default static const adc_bits_width_t width = ADC_WIDTH_BIT_12; @@ -649,7 +678,7 @@ bool Power::analogInit() #ifndef BAT_MEASURE_ADC_UNIT // ADC1 adc1_config_width(width); adc1_config_channel_atten(adc_channel, atten); -#else // ADC2 +#else // ADC2 adc2_config_channel_atten(adc_channel, atten); #ifndef CONFIG_IDF_TARGET_ESP32S3 // ADC2 wifi bug workaround @@ -679,7 +708,7 @@ bool Power::analogInit() // NRF52 ADC init moved to powerHAL_init in nrf52 platform -#ifndef ARCH_ESP32 +#if !defined(ARCH_ESP32) && !defined(ARCH_STM32WL) analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS); #endif diff --git a/src/power.h b/src/power.h index b129e2b74..d46eaadd2 100644 --- a/src/power.h +++ b/src/power.h @@ -15,8 +15,13 @@ // Device specific curves go in variant.h #ifndef OCV_ARRAY +#if defined(ARCH_STM32WL) && BATTERY_PIN == AVBAT +// STM32 VDD/VBAT absolute maximum is 4V so use an LFP curve +#define OCV_ARRAY 3650, 3400, 3340, 3320, 3300, 3280, 3270, 3260, 3240, 3200, 2500 +#else #define OCV_ARRAY 4190, 4050, 3990, 3890, 3800, 3720, 3630, 3530, 3420, 3300, 3100 #endif +#endif /*Note: 12V lead acid is 6 cells, most board accept only 1 cell LiIon/LiPo*/ #ifndef NUM_CELLS diff --git a/variants/stm32/rak3172/variant.h b/variants/stm32/rak3172/variant.h index bd6decd4c..75e3e0c91 100644 --- a/variants/stm32/rak3172/variant.h +++ b/variants/stm32/rak3172/variant.h @@ -16,6 +16,11 @@ Do not expect a working Meshtastic device with this target. #define LED_POWER PA0 // Green LED #define LED_STATE_ON 1 +#define BATTERY_PIN AVBAT +// ADC_MULTIPLIER: 3.0 = internal 1:3 bridge divider (DS13105§3.18.3) +// Margin: 1.10 = AVBAT divider tolerance ±10% (Table 82) +#define ADC_MULTIPLIER (1.01f * 3) + #define RAK3172 #define SERIAL_PRINT_PORT 1 diff --git a/variants/stm32/russell/variant.h b/variants/stm32/russell/variant.h index 8773d5d8d..7b5d4e9a1 100644 --- a/variants/stm32/russell/variant.h +++ b/variants/stm32/russell/variant.h @@ -13,6 +13,16 @@ // #define EXT_CHRG_DETECT PA5 // #define EXT_PWR_DETECT PA4 +#define BATTERY_PIN AVBAT +// ADC_MULTIPLIER: 3.0 = internal 1:3 bridge divider (DS13105§3.18.3) +// Margin: 1.10 = AVBAT divider tolerance ±10% (Table 82) +#define ADC_MULTIPLIER (1.01f * 3) +/* +Sample OCV curve for Li-SOCl2 primary lithium cells (e.g. Saft cells have fresh OCV of 3.67V) +#define NUM_OCV_POINTS 11 +#define OCV_ARRAY 3670, 3650, 3630, 3610, 3590, 3560, 3530, 3480, 3400, 3200, 2500 +*/ + // Bosch Sensortec BME280 #define HAS_SENSOR 1 From edf660ccb399cb6d9d4490af6d7737bcf5013271 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 07:48:19 -0500 Subject: [PATCH 21/67] Update variants/esp32s3/t-deck-pro-v1_1/variant.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- variants/esp32s3/t-deck-pro-v1_1/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/esp32s3/t-deck-pro-v1_1/variant.h b/variants/esp32s3/t-deck-pro-v1_1/variant.h index 8584fd8a1..af761d64d 100644 --- a/variants/esp32s3/t-deck-pro-v1_1/variant.h +++ b/variants/esp32s3/t-deck-pro-v1_1/variant.h @@ -18,7 +18,7 @@ #define USE_POWERSAVE #define SLEEP_TIME 120 -// GNNS +// GNSS #define HAS_GPS 1 #define GPS_BAUDRATE 38400 #define PIN_GPS_EN 39 From 5cae9e0183b1f84ad9502c28eb175219decee7b4 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 07:48:35 -0500 Subject: [PATCH 22/67] Update src/platform/extra_variants/t_deck_pro/variant.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/platform/extra_variants/t_deck_pro/variant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/extra_variants/t_deck_pro/variant.cpp b/src/platform/extra_variants/t_deck_pro/variant.cpp index 77fba53b9..ff8e34ebd 100644 --- a/src/platform/extra_variants/t_deck_pro/variant.cpp +++ b/src/platform/extra_variants/t_deck_pro/variant.cpp @@ -80,7 +80,7 @@ bool readTouch(int16_t *x, int16_t *y) } -static void touchInterruptHandler(){ +static void IRAM_ATTR touchInterruptHandler(){ touch_isr = true; } From 7d957f8c7ba87905e1a7c25b652809642155cf6c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 07:48:50 -0500 Subject: [PATCH 23/67] Update variants/esp32s3/t-deck-pro-v1_1/platformio.ini Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- variants/esp32s3/t-deck-pro-v1_1/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/esp32s3/t-deck-pro-v1_1/platformio.ini b/variants/esp32s3/t-deck-pro-v1_1/platformio.ini index b76522934..1a9b20f76 100644 --- a/variants/esp32s3/t-deck-pro-v1_1/platformio.ini +++ b/variants/esp32s3/t-deck-pro-v1_1/platformio.ini @@ -30,7 +30,7 @@ build_flags = lib_deps = ${esp32s3_base.lib_deps} # renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2 - zinggjm/GxEPD2@1.6.5 + zinggjm/GxEPD2@1.6.8 # renovate: datasource=git-refs depName=CSE_Touch packageName=https://github.com/CIRCUITSTATE/CSE_Touch gitBranch=main https://github.com/CIRCUITSTATE/CSE_Touch/archive/b44f23b6f870b848f1fbe453c190879bc6cfaafa.zip # renovate: datasource=github-tags depName=CSE_CST328 packageName=CIRCUITSTATE/CSE_CST328 From d5af07e4584cef54c28a5247830b426931b43dc8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 07:49:08 -0500 Subject: [PATCH 24/67] Update src/main.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 6b714f1cf..937df88cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -374,8 +374,10 @@ void setup() digitalWrite(SDCARD_CS, HIGH); pinMode(PIN_EINK_CS, OUTPUT); digitalWrite(PIN_EINK_CS, HIGH); +#if PIN_EINK_RES >= 0 pinMode(PIN_EINK_RES, OUTPUT); digitalWrite(PIN_EINK_RES, HIGH); +#endif pinMode(CST328_PIN_RST, OUTPUT); digitalWrite(CST328_PIN_RST, HIGH); #elif defined(T_LORA_PAGER) From 79e7ed30f1f7b44da205bb1e37e5ff0202318a00 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 07:49:34 -0500 Subject: [PATCH 25/67] Update src/graphics/EInkDisplay2.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/graphics/EInkDisplay2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 96321f9c4..28b956bb1 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -105,10 +105,12 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) void EInkDisplay::endUpdate() { #ifndef EINK_NOT_HIBERNATE - // Power off display hardware, then deep-sleep (Except Wireless Paper V1.1, no deep-sleep) + // By default, power off the E-Ink display hardware and enter hibernate(). + // Boards/panels that define EINK_NOT_HIBERNATE intentionally skip this step. + // Skipping hibernate() can help avoid panel-specific wake/refresh or ghosting issues, + // but it typically trades lower power savings for that compatibility. adafruitDisplay->hibernate(); #endif - } // Write the buffer to the display memory From 0ee5777c1593cf35e7137740e930b74fffb61c5a Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 16 Apr 2026 10:35:05 +0800 Subject: [PATCH 26/67] stm32wl(mem): fix getFreeHeap() underreporting on dynamic sbrk heap mallinfo().fordblks counts only free bytes within the committed arena. On STM32WL (newlib sbrk heap) the arena grows lazily from _end toward SP, so fordblks reads near-zero at early boot even when ~48 KB of addressable space remains. This caused NodeDB::isFull() to fire prematurely and evict nodes on a freshly booted device. Fix getFreeHeap() to include uncommitted sbrk headroom (SP - sbrk(0)) so the returned value reflects true available memory throughout the boot lifecycle. Introduce MESHTASTIC_DYNAMIC_SBRK_HEAP as an opt-in build flag (set in stm32.ini) so the fix is gated to platforms with a dynamic sbrk heap rather than a static heap. Future platforms with the same heap model can opt in by adding this flag. Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 4.6 --- src/memGet.cpp | 22 +++++++++++++++++----- variants/stm32/stm32.ini | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/memGet.cpp b/src/memGet.cpp index 14e614014..570bbf5b2 100644 --- a/src/memGet.cpp +++ b/src/memGet.cpp @@ -10,8 +10,20 @@ #include "memGet.h" #include "configuration.h" -#ifdef ARCH_STM32WL +#if defined(MESHTASTIC_DYNAMIC_SBRK_HEAP) #include +#include // sbrk + +// Returns the uncommitted sbrk headroom: addressable space between the current heap +// break and the stack pointer that has not yet been committed to the arena. +// Currently used on: ARCH_STM32WL +static uint32_t sbrkHeadroom() +{ + uint32_t sp; + __asm volatile("mov %0, sp" : "=r"(sp)); + uint32_t heap_end = (uint32_t)sbrk(0); + return (sp > heap_end) ? (sp - heap_end) : 0; +} #endif MemGet memGet; @@ -28,9 +40,9 @@ uint32_t MemGet::getFreeHeap() return dbgHeapFree(); #elif defined(ARCH_RP2040) return rp2040.getFreeHeap(); -#elif defined(ARCH_STM32WL) +#elif defined(MESHTASTIC_DYNAMIC_SBRK_HEAP) // Currently: ARCH_STM32WL struct mallinfo m = mallinfo(); - return m.fordblks; // Total free space (bytes) + return m.fordblks + sbrkHeadroom(); // Free space within arena + uncommitted sbrk headroom #else // this platform does not have heap management function implemented return UINT32_MAX; @@ -49,9 +61,9 @@ uint32_t MemGet::getHeapSize() return dbgHeapTotal(); #elif defined(ARCH_RP2040) return rp2040.getTotalHeap(); -#elif defined(ARCH_STM32WL) +#elif defined(MESHTASTIC_DYNAMIC_SBRK_HEAP) // Currently: ARCH_STM32WL struct mallinfo m = mallinfo(); - return m.arena; // Non-mmapped space allocated (bytes) + return m.arena + sbrkHeadroom(); // Non-mmapped space allocated + uncommitted sbrk headroom #else // this platform does not have heap management function implemented return UINT32_MAX; diff --git a/variants/stm32/stm32.ini b/variants/stm32/stm32.ini index 542d08800..c49db27f3 100644 --- a/variants/stm32/stm32.ini +++ b/variants/stm32/stm32.ini @@ -36,6 +36,7 @@ build_flags = -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 -DRADIOLIB_EXCLUDE_LR2021=1 + -DMESHTASTIC_DYNAMIC_SBRK_HEAP -DHAL_DAC_MODULE_ONLY -DHAL_RNG_MODULE_ENABLED -Wl,--wrap=__assert_func From 31418ca8214145497c2b8c80552675b8232d68c1 Mon Sep 17 00:00:00 2001 From: Chloe Bethel Date: Thu, 16 Apr 2026 12:21:16 +0100 Subject: [PATCH 27/67] stm32wl: reserve 2KB of stack via linker script to match NRF52, change sbrkHeadroom to use the start of the reserved stack region instead of the current stack pointer The linker script was created by merging variants/STM32WLxx/WL54JCI_WL55JCI_WLE4J(8-B-C)I_WLE5J(8-B-C)I/ldscript.ld and system/ldscript.ld from stm32duino/Arduino_Core_STM32. --- src/memGet.cpp | 14 ++- variants/stm32/stm32.ini | 3 + variants/stm32/stm32wle5xx.ld | 204 ++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 variants/stm32/stm32wle5xx.ld diff --git a/src/memGet.cpp b/src/memGet.cpp index 570bbf5b2..42a3430f6 100644 --- a/src/memGet.cpp +++ b/src/memGet.cpp @@ -14,16 +14,22 @@ #include #include // sbrk +#ifdef ARCH_STM32WL // Returns the uncommitted sbrk headroom: addressable space between the current heap // break and the stack pointer that has not yet been committed to the arena. -// Currently used on: ARCH_STM32WL static uint32_t sbrkHeadroom() { - uint32_t sp; - __asm volatile("mov %0, sp" : "=r"(sp)); + // defined in STM32 linker script + extern char _estack; + extern char _Min_Stack_Size; + + uint32_t max_sp = (uint32_t)(&_estack - &_Min_Stack_Size); uint32_t heap_end = (uint32_t)sbrk(0); - return (sp > heap_end) ? (sp - heap_end) : 0; + return (max_sp > heap_end) ? (max_sp - heap_end) : 0; } +#else +#error Unsupported architecture! +#endif #endif MemGet memGet; diff --git a/variants/stm32/stm32.ini b/variants/stm32/stm32.ini index c49db27f3..1efe18e3d 100644 --- a/variants/stm32/stm32.ini +++ b/variants/stm32/stm32.ini @@ -58,3 +58,6 @@ lib_deps = lib_ignore = OneButton + +; Set a custom linker script with a higher MinStackSize value, to match NRF52. +board_build.ldscript = $PROJECT_DIR/variants/stm32/stm32wle5xx.ld \ No newline at end of file diff --git a/variants/stm32/stm32wle5xx.ld b/variants/stm32/stm32wle5xx.ld new file mode 100644 index 000000000..c13782926 --- /dev/null +++ b/variants/stm32/stm32wle5xx.ld @@ -0,0 +1,204 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : STM32CubeIDE +** +** Abstract : Linker script for STM32WL55xC Device +** 256Kbytes FLASH +** 64Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed as is without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© Copyright (c) 2020 STMicroelectronics. +** All rights reserved.

+** +** This software component is licensed by ST under BSD 3-Clause license, +** the "License"; You may not use this file except in compliance with the +** License. You may obtain a copy of the License at: +** opensource.org/licenses/BSD-3-Clause +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200 ; /* required amount of heap */ +/* Modified from original to 2KB, to match NRF52 */ +_Min_Stack_Size = 2048 ; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab (READONLY) : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM (READONLY) : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array (READONLY) : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array (READONLY) : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array (READONLY) : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* Define a noinit output section and mark it as NOLOAD to prevent + * putting its contents into the resulting .bin file (which is the + * default). */ + .noinit (NOLOAD) : + { + /* Ensure output is aligned */ + . = ALIGN(4); + /* Define a global _snoinit (and _enoinit below) symbol just in case + * code wants to iterate over all noinit variables for some reason */ + _snoinit = .; + /* Actually import the .noinit and .noinit* import sections */ + *(.noinit) + *(.noinit*) + . = ALIGN(4); + _enoinit = .; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} From 23f92c1cbd7eed5a2f2de097b68eb16789960cae Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Apr 2026 08:01:03 -0500 Subject: [PATCH 28/67] Add comprehensive guides for new module, sensor, and hardware variant development --- .github/copilot-instructions.md | 191 ++++++++++++++++++++++---- .github/prompts/new-module.prompt.md | 138 +++++++++++++++++++ .github/prompts/new-sensor.prompt.md | 149 ++++++++++++++++++++ .github/prompts/new-variant.prompt.md | 178 ++++++++++++++++++++++++ 4 files changed, 629 insertions(+), 27 deletions(-) create mode 100644 .github/prompts/new-module.prompt.md create mode 100644 .github/prompts/new-sensor.prompt.md create mode 100644 .github/prompts/new-variant.prompt.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 14601b058..24e11bd4d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -4,11 +4,11 @@ This document provides context and guidelines for AI assistants working with the ## Project Overview -Meshtastic is an open-source LoRa mesh networking project for long-range, low-power communication without relying on internet or cellular infrastructure. The firmware enables text messaging, location sharing, and telemetry over a decentralized mesh network. +Meshtastic is an open-source LoRa mesh networking project for long-range, low-power communication without relying on internet or cellular infrastructure. The firmware enables text messaging, location sharing, and telemetry over a decentralized mesh network. The project uses **C++17** as its language standard across all platforms. ### Supported Hardware Platforms -- **ESP32** (ESP32, ESP32-S3, ESP32-C3) - Most common platform +- **ESP32** (ESP32, ESP32-S3, ESP32-C3, ESP32-C6) - Most common platform - **nRF52** (nRF52840, nRF52833) - Low power Nordic chips - **RP2040/RP2350** - Raspberry Pi Pico variants - **STM32WL** - STM32 with integrated LoRa @@ -80,21 +80,46 @@ firmware/ │ │ ├── NodeDB.* # Node database management │ │ ├── Router.* # Packet routing │ │ ├── Channels.* # Channel management +│ │ ├── CryptoEngine.* # AES-CCM encryption │ │ ├── *Interface.* # Radio interface implementations +│ │ ├── api/ # WiFi/Ethernet server APIs (ServerAPI, PacketAPI) +│ │ ├── http/ # HTTP server (WebServer, ContentHandler) +│ │ ├── wifi/ # WiFi support (WiFiAPClient) +│ │ ├── eth/ # Ethernet support (ethClient) +│ │ ├── udp/ # UDP multicast +│ │ ├── compression/ # Message compression (unishox2) │ │ └── generated/ # Protobuf generated code │ ├── modules/ # Feature modules (Position, Telemetry, etc.) +│ │ └── Telemetry/ # Telemetry subsystem +│ │ └── Sensor/ # 50+ I2C sensor drivers │ ├── gps/ # GPS handling │ ├── graphics/ # Display drivers and UI -│ ├── platform/ # Platform-specific code -│ ├── input/ # Input device handling -│ └── concurrency/ # Threading utilities +│ │ └── niche/ # Specialized UIs (InkHUD e-ink framework) +│ ├── platform/ # Platform-specific code (esp32, nrf52, rp2xx0, stm32wl, portduino) +│ ├── input/ # Input device handling (InputBroker, keyboards, buttons) +│ ├── detect/ # I2C hardware auto-detection (80+ device types) +│ ├── motion/ # Accelerometer drivers (BMA423, BMI270, MPU6050, etc.) +│ ├── mqtt/ # MQTT bridge client +│ ├── power/ # Power HAL +│ ├── nimble/ # BLE via NimBLE +│ ├── buzz/ # Audio/notification (buzzer, RTTTL) +│ ├── serialization/ # JSON serialization, COBS encoding +│ ├── watchdog/ # Hardware watchdog thread +│ ├── concurrency/ # Threading utilities (OSThread, Lock) +│ ├── PowerFSM.* # Power finite state machine +│ └── Observer.h # Observer/Observable event pattern ├── variants/ # Hardware variant definitions │ ├── esp32/ # ESP32 variants │ ├── esp32s3/ # ESP32-S3 variants -│ ├── nrf52/ # nRF52 variants -│ └── rp2xxx/ # RP2040/RP2350 variants +│ ├── esp32c3/ # ESP32-C3 variants +│ ├── esp32c6/ # ESP32-C6 variants +│ ├── nrf52840/ # nRF52 variants +│ ├── rp2040/ # RP2040/RP2350 variants +│ ├── stm32/ # STM32WL variants +│ └── native/ # Linux/Portduino variants ├── protobufs/ # Protocol buffer definitions ├── boards/ # Custom PlatformIO board definitions +├── test/ # Unit tests (12 test suites) └── bin/ # Build and utility scripts ``` @@ -105,6 +130,7 @@ firmware/ - Follow existing code style - run `trunk fmt` before commits - Prefer `LOG_DEBUG`, `LOG_INFO`, `LOG_WARN`, `LOG_ERROR` for logging - Use `assert()` for invariants that should never fail +- C++17 features are available (`std::optional`, structured bindings, `if constexpr`, etc.) ### Naming Conventions @@ -118,70 +144,151 @@ firmware/ #### Module System -Modules inherit from `MeshModule` or `ProtobufModule` and implement: +Modules use a three-tier class hierarchy: -- `handleReceivedProtobuf()` - Process incoming packets -- `allocReply()` - Generate response packets -- `runOnce()` - Periodic task execution (returns next run interval in ms) +1. **`MeshModule`** - Base class. Implement `wantPacket()` and `handleReceived()`. Returns `ProcessMessage::STOP` or `ProcessMessage::CONTINUE`. +2. **`SinglePortModule`** - Handles a single portnum. Simplified `wantPacket()` that checks `decoded.portnum`. +3. **`ProtobufModule`** - Template for protobuf-based modules. Handles encoding/decoding automatically. + +Most modules also inherit from **`OSThread`** for periodic tasks (the "mixin" pattern): ```cpp -class MyModule : public ProtobufModule +class MyModule : public ProtobufModule, private concurrency::OSThread { + public: + MyModule(); + protected: virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_MyMessage *msg) override; - virtual int32_t runOnce() override; + virtual meshtastic_MeshPacket *allocReply() override; // Generate response packets + virtual int32_t runOnce() override; // Periodic task (returns next interval in ms) + virtual bool alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_MyMessage *msg); // Modify in-flight + virtual bool wantUIFrame(); // Request a UI display frame }; ``` +Modules are registered in `src/modules/Modules.cpp` guarded by `MESHTASTIC_EXCLUDE_*` flags. + +#### Observer/Observable Pattern + +Event-driven communication between subsystems uses `src/Observer.h`: + +```cpp +// Observable emits events +Observable newStatus; +newStatus.notifyObservers(&status); + +// Observer receives events via callback +CallbackObserver statusObserver = + CallbackObserver(this, &MyClass::handleStatusUpdate); +``` + #### Configuration Access - `config.*` - Device configuration (LoRa, position, power, etc.) - `moduleConfig.*` - Module-specific configuration - `channels.*` - Channel configuration and management +- `owner` - Device owner info +- `myNodeInfo` - Local node info #### Default Values Use the `Default` class helpers in `src/mesh/Default.h`: - `Default::getConfiguredOrDefaultMs(configured, default)` - Returns ms, using default if configured is 0 +- `Default::getConfiguredOrDefault(configured, default)` - Generic configured/default getter - `Default::getConfiguredOrMinimumValue(configured, min)` - Enforces minimum values - `Default::getConfiguredOrDefaultMsScaled(configured, default, numNodes)` - Scales based on network size #### Thread Safety -- Use `concurrency::Lock` for mutex protection +- Use `concurrency::Lock` and `concurrency::LockGuard` for mutex protection - Radio SPI access uses `SPILock` - Prefer `OSThread` for background tasks +### Hardware Detection + +`src/detect/ScanI2C` automatically enumerates 80+ I2C device types at boot including displays, sensors, RTCs, keyboards, PMUs, and touch controllers. This drives automatic initialization of the correct drivers. + +### Graphics/UI System + +Multiple display driver families in `src/graphics/`: + +- **OLED**: SSD1306, SH1106, ST7567 +- **TFT**: TFTDisplay (LovyanGFX-based) +- **E-Ink**: EInkDisplay2, EInkDynamicDisplay, EInkParallelDisplay + +**InkHUD** (`src/graphics/niche/InkHUD/`) is an event-driven e-ink UI framework: + +- Applet-based architecture — modular display tiles +- Read-only, static display optimized for minimal refreshes and low power +- Configured per-variant via `nicheGraphics.h` +- Separate PlatformIO config: `src/graphics/niche/InkHUD/PlatformioConfig.ini` + +### Input System + +`src/input/InputBroker` is the centralized input event dispatcher. Supports multiple input sources: buttons, keyboards (BBQ10, Cardputer, TCA8418), touch screens, rotary encoders, and matrix keyboards. + +### Power Management + +`src/PowerFSM.*` implements a finite state machine with states: `stateON`, `statePOWER`, `stateSERIAL`, `stateDARK`. Key events: `EVENT_PRESS`, `EVENT_WAKE_TIMER`, `EVENT_LOW_BATTERY`, `EVENT_RECEIVED_MSG`, `EVENT_SHUTDOWN`. Conditionally excluded with `MESHTASTIC_EXCLUDE_POWER_FSM` (falls back to `FakeFsm`). + +### Motion Sensors + +`src/motion/AccelerometerThread` provides background motion monitoring with automatic screen wake and double-tap button press detection. Supports 10+ accelerometer/gyroscope chips (BMA423, BMI270, MPU6050, LIS3DH, LSM6DS3, STK8XXX, QMA6100P, ICM20948, BMX160). + +### Telemetry Sensor Library + +`src/modules/Telemetry/Sensor/` contains 50+ I2C sensor drivers organized by category: + +- **Power monitoring**: INA219/226/260/3221, MAX17048 +- **Environmental**: BME280/680, SCD4X (CO₂), SEN5X (particulate) +- **Humidity/Temperature**: SHT3X/4X, AHT10, MCP9808, MLX90614 +- **Light**: BH1750, TSL2561/2591, VEML7700, LTR390UV, OPT3001 +- **Air quality**: PMSA003I, SFA30 +- **Specialized**: CGRadSens (radiation), NAU7802 (weight scale) + +### API/Networking + +`src/mesh/api/` provides a template-based `ServerAPI` for client communication over WiFi (`WiFiServerAPI`) and Ethernet (`ethServerAPI`). Default port: **4403**. HTTP server in `src/mesh/http/`. JSON serialization in `src/serialization/MeshPacketSerializer`. + ### Hardware Variants Each hardware variant has: - `variant.h` - Pin definitions and hardware capabilities - `platformio.ini` - Build configuration -- Optional: `pins_arduino.h`, `rfswitch.h` +- Optional: `pins_arduino.h`, `rfswitch.h`, `nicheGraphics.h` (for InkHUD variants) Key defines in variant.h: ```cpp #define USE_SX1262 // Radio chip selection #define HAS_GPS 1 // Hardware capabilities +#define HAS_SCREEN 1 // Display present #define LORA_CS 36 // Pin assignments #define SX126X_DIO1 14 // Radio-specific pins ``` ### Protobuf Messages -- Defined in `protobufs/meshtastic/*.proto` -- Generated code in `src/mesh/generated/` +- Defined in `protobufs/meshtastic/*.proto` (~32 proto files) +- Generated code in `src/mesh/generated/meshtastic/` - Regenerate with `bin/regen-protos.sh` - Message types prefixed with `meshtastic_` +- Nanopb `.options` files control field sizes and encoding ### Conditional Compilation ```cpp #if !MESHTASTIC_EXCLUDE_GPS // Feature exclusion +#if !MESHTASTIC_EXCLUDE_WIFI // Network feature exclusion +#if !MESHTASTIC_EXCLUDE_BLUETOOTH // BLE exclusion +#if !MESHTASTIC_EXCLUDE_POWER_FSM // Power FSM exclusion #ifdef ARCH_ESP32 // Architecture-specific +#ifdef ARCH_NRF52 // Nordic platform +#ifdef ARCH_RP2040 // Raspberry Pi Pico +#ifdef ARCH_PORTDUINO // Linux native #if defined(USE_SX1262) // Radio-specific #ifdef HAS_SCREEN // Hardware capability #if USERPREFS_EVENT_MODE // User preferences @@ -192,7 +299,7 @@ Key defines in variant.h: Uses **PlatformIO** with custom scripts: - `bin/platformio-pre.py` - Pre-build script -- `bin/platformio-custom.py` - Custom build logic +- `bin/platformio-custom.py` - Custom build logic, manifest generation Build commands: @@ -202,21 +309,38 @@ pio run -e tbeam -t upload # Build and upload pio run -e native # Build native/Linux version ``` +### Build Manifest + +`bin/platformio-custom.py` emits a build manifest with metadata: + +- `hasMui`, `hasInkHud` - UI capability flags (overridable via `custom_meshtastic_has_mui`, `custom_meshtastic_has_ink_hud`) +- Architecture normalization (e.g., `esp32s3` → `esp32-s3` for API compatibility) + ## Common Tasks ### Adding a New Module 1. Create `src/modules/MyModule.cpp` and `.h` -2. Inherit from appropriate base class -3. Register in `src/modules/Modules.cpp` -4. Add protobuf messages if needed in `protobufs/` +2. Inherit from appropriate base class (`MeshModule`, `SinglePortModule`, or `ProtobufModule`) +3. Mix in `concurrency::OSThread` if periodic work is needed +4. Register in `src/modules/Modules.cpp` guarded by `#if !MESHTASTIC_EXCLUDE_MYMODULE` +5. Add protobuf messages if needed in `protobufs/meshtastic/` +6. Add test suite in `test/test_mymodule/` if applicable ### Adding a New Hardware Variant 1. Create directory under `variants///` -2. Add `variant.h` with pin definitions -3. Add `platformio.ini` with build config -4. Reference common configs with `extends` +2. Add `variant.h` with pin definitions and hardware capability defines +3. Add `platformio.ini` with build config — use `extends` to reference common base (e.g., `esp32s3_base`) +4. Set `custom_meshtastic_support_level = 1` (PR builds) or `2` (merge builds) +5. For e-ink displays, add `nicheGraphics.h` for InkHUD configuration + +### Adding a New Telemetry Sensor + +1. Create driver in `src/modules/Telemetry/Sensor/` following existing sensor pattern +2. Register I2C address in `src/detect/ScanI2C` for auto-detection +3. Integrate with the appropriate telemetry module (Environment, Health, Power, AirQuality) +4. Add proto fields in `protobufs/meshtastic/telemetry.proto` if new data types are needed ### Modifying Configuration Defaults @@ -305,9 +429,22 @@ Most workflows can be triggered manually via `workflow_dispatch` for testing. ## Testing -- Unit tests in `test/` directory -- Run with `pio test -e native` -- Use `bin/test-simulator.sh` for simulation testing +Unit tests in `test/` directory with 12 test suites: + +- `test_crypto/` - Cryptography +- `test_mqtt/` - MQTT integration +- `test_radio/` - Radio interface +- `test_mesh_module/` - Module framework +- `test_meshpacket_serializer/` - Packet serialization +- `test_transmit_history/` - Retransmission tracking +- `test_atak/` - ATAK integration +- `test_default/` - Default configuration +- `test_http_content_handler/` - HTTP handling +- `test_serial/` - Serial communication + +Run with: `pio test -e native` + +Simulation testing: `bin/test-simulator.sh` ## Resources diff --git a/.github/prompts/new-module.prompt.md b/.github/prompts/new-module.prompt.md new file mode 100644 index 000000000..8569a622c --- /dev/null +++ b/.github/prompts/new-module.prompt.md @@ -0,0 +1,138 @@ +# New Meshtastic Module + +Guide for developing a new Meshtastic firmware module. + +## Module Hierarchy + +Choose the appropriate base class: + +1. **`MeshModule`** — Raw base class. Override `wantPacket()` and `handleReceived()`. Returns `ProcessMessage::STOP` or `ProcessMessage::CONTINUE`. +2. **`SinglePortModule`** — Handles a single `meshtastic_PortNum`. Constructor takes `(name, portNum)`. Simplified `wantPacket()` checking `decoded.portnum`. Use `allocDataPacket()` to create outgoing packets. +3. **`ProtobufModule`** — Template for protobuf-encoded modules. Constructor takes `(name, portNum, fields)`. Override `handleReceivedProtobuf()`. Use `allocDataProtobuf(payload)` to create outgoing packets. + +Most modules also mix in `concurrency::OSThread` for periodic background tasks. + +## Implementation Pattern + +```cpp +// src/modules/MyModule.h +#pragma once +#include "ProtobufModule.h" +#include "concurrency/OSThread.h" + +class MyModule : public ProtobufModule, private concurrency::OSThread +{ + public: + MyModule(); + + protected: + // Process incoming protobuf packet. Return true to stop further processing. + virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_MyMessage *msg) override; + + // Generate response packet (optional) + virtual meshtastic_MeshPacket *allocReply() override; + + // Periodic task — return next run interval in ms, or disable() + virtual int32_t runOnce() override; + + // Modify packet in-flight before delivery (optional) + virtual bool alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_MyMessage *msg); + + // Request a UI display frame (optional) + virtual bool wantUIFrame(); +}; +``` + +## Registration + +Register in `src/modules/Modules.cpp` inside `setupModules()`: + +```cpp +#if !MESHTASTIC_EXCLUDE_MYMODULE + new MyModule(); +#endif +``` + +If other code needs to reference the module instance: + +```cpp +#if !MESHTASTIC_EXCLUDE_MYMODULE + myModule = new MyModule(); +#endif +``` + +And declare the global in the header: + +```cpp +extern MyModule *myModule; +``` + +Some modules also conditionally instantiate based on `moduleConfig`: + +```cpp +#if !MESHTASTIC_EXCLUDE_MYMODULE + if (moduleConfig.has_my_module && moduleConfig.my_module.enabled) { + new MyModule(); + } +#endif +``` + +## Conditional Compilation + +Add a `MESHTASTIC_EXCLUDE_MYMODULE` guard. This allows the module to be excluded from constrained builds. The flag name must follow the pattern: `MESHTASTIC_EXCLUDE_` + uppercase module name. + +## Protobuf Messages (if needed) + +1. Define messages in `protobufs/meshtastic/` (e.g., `mymodule.proto`) +2. Add a `.options` file for nanopb field size constraints +3. Regenerate with `bin/regen-protos.sh` +4. Generated code appears in `src/mesh/generated/meshtastic/` +5. Assign a `meshtastic_PortNum` if the module uses a new port number + +## Timing and Defaults + +Use `Default` class helpers for configurable intervals: + +```cpp +int32_t MyModule::runOnce() +{ + uint32_t interval = Default::getConfiguredOrDefaultMs(moduleConfig.my_module.update_interval, + default_my_module_interval); + // ... do work ... + return interval; +} +``` + +On public/default channels, enforce minimums with `Default::getConfiguredOrMinimumValue()`. + +## Observer Pattern + +Subscribe to system events: + +```cpp +CallbackObserver statusObserver = + CallbackObserver(this, &MyModule::handleStatusUpdate); +``` + +## Testing + +Add test suite in `test/test_mymodule/`: + +``` +test/ +└── test_mymodule/ + └── test_main.cpp +``` + +Run with: `pio test -e native` + +## Checklist + +- [ ] Header and implementation files in `src/modules/` +- [ ] Inherit from appropriate base class (MeshModule / SinglePortModule / ProtobufModule) +- [ ] Mix in OSThread if periodic work is needed +- [ ] Register in `src/modules/Modules.cpp` with `MESHTASTIC_EXCLUDE_` guard +- [ ] Add protobuf definitions if needed (`protobufs/meshtastic/`) +- [ ] Use `Default::getConfiguredOrDefaultMs()` for timing +- [ ] Respect bandwidth limits on public channels +- [ ] Add test suite in `test/` diff --git a/.github/prompts/new-sensor.prompt.md b/.github/prompts/new-sensor.prompt.md new file mode 100644 index 000000000..e02fc2462 --- /dev/null +++ b/.github/prompts/new-sensor.prompt.md @@ -0,0 +1,149 @@ +# New Telemetry Sensor + +Guide for adding a new I2C telemetry sensor driver to Meshtastic firmware. + +## Overview + +Telemetry sensors live in `src/modules/Telemetry/Sensor/`. There are 50+ existing drivers organized by measurement type. Each sensor integrates with one of the telemetry modules: + +- **EnvironmentTelemetryModule** — Temperature, humidity, pressure, gas, light +- **AirQualityTelemetryModule** — Particulate matter, VOCs +- **PowerTelemetryModule** — Voltage, current, power monitoring +- **HealthTelemetryModule** — Heart rate, SpO2, body temperature + +## Sensor Driver Pattern + +Each sensor has a `.h` and `.cpp` file pair following this pattern: + +```cpp +// src/modules/Telemetry/Sensor/MySensor.h +#pragma once +#include "TelemetrySensor.h" +#include // Arduino/PlatformIO library + +class MySensor : virtual public TelemetrySensor +{ + private: + MySensorLibrary sensor; + + public: + MySensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MY_SENSOR, "MySensor") {} + + // Initialize sensor hardware. Return true on success. + virtual void setup() override; + + // Read sensor data into the telemetry protobuf. Return true on success. + virtual bool getMetrics(meshtastic_Telemetry *measurement) override; +}; +``` + +```cpp +// src/modules/Telemetry/Sensor/MySensor.cpp +#include "MySensor.h" +#include "TelemetrySensor.h" + +void MySensor::setup() +{ + sensor.begin(); + // Configure sensor parameters... +} + +bool MySensor::getMetrics(meshtastic_Telemetry *measurement) +{ + // Read from hardware + float value = sensor.readValue(); + + // Populate the appropriate protobuf variant + measurement->variant.environment_metrics.temperature = value; + // ... other fields ... + + return true; +} +``` + +## I2C Address Registration + +Register the sensor's I2C address(es) in `src/detect/ScanI2C` so it's auto-detected at boot: + +1. Add a `DeviceType` enum entry in `src/detect/ScanI2C.h` +2. Add the I2C address mapping in `src/detect/ScanI2CTwoWire.cpp` + +The scan runs at boot and populates a device map that telemetry modules use to decide which sensors to initialize. + +## Protobuf Fields + +If the sensor provides data not covered by existing telemetry fields: + +1. Add fields to the appropriate message in `protobufs/meshtastic/telemetry.proto`: + - `EnvironmentMetrics` — Environmental measurements + - `AirQualityMetrics` — Air quality data + - `PowerMetrics` — Power/energy data + - `HealthMetrics` — Health/biometric data +2. Add a `.options` constraint if needed (field sizes for nanopb) +3. Regenerate: `bin/regen-protos.sh` + +## Sensor Type Enum + +Add the sensor to `meshtastic_TelemetrySensorType` enum in `protobufs/meshtastic/telemetry.proto`: + +```protobuf +enum TelemetrySensorType { + // ... existing entries ... + MY_SENSOR = XX; +} +``` + +## Integration with Telemetry Module + +Wire the sensor into the appropriate telemetry module. For environment sensors, this is typically in `src/modules/Telemetry/EnvironmentTelemetry.cpp`: + +1. Include the sensor header +2. Add initialization in `setupSensor()` guarded by detection results +3. Call `getMetrics()` in the measurement collection path + +Example pattern from existing sensors: + +```cpp +#include "Sensor/MySensor.h" + +MySensor mySensor; + +// In setup: +if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MY_SENSOR].first > 0) { + mySensor.setup(); +} + +// In measurement collection: +if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MY_SENSOR].first > 0) { + mySensor.getMetrics(&measurement); +} +``` + +## Library Dependencies + +If the sensor needs an external library, add it to the `lib_deps` in the relevant base platformio.ini configs: + +```ini +lib_deps = + ${env.lib_deps} + mysensorlibrary@^1.0.0 +``` + +Or use a conditional dependency if it's platform-specific. + +## Unit Conversions + +If the sensor reports values in non-standard units, use `src/modules/Telemetry/UnitConversions.h` for conversion helpers (e.g., Celsius ↔ Fahrenheit, hPa ↔ inHg). + +## Checklist + +- [ ] Create `src/modules/Telemetry/Sensor/MySensor.h` and `.cpp` +- [ ] Inherit from `TelemetrySensor` base class +- [ ] Implement `setup()` and `getMetrics()` methods +- [ ] Add `meshtastic_TelemetrySensorType` enum entry in `telemetry.proto` +- [ ] Add I2C address to `src/detect/ScanI2C` for auto-detection +- [ ] Add protobuf fields in `telemetry.proto` if new data types needed +- [ ] Regenerate protos: `bin/regen-protos.sh` +- [ ] Wire into the appropriate telemetry module (Environment/AirQuality/Power/Health) +- [ ] Add library dependency if external library required +- [ ] Test on hardware or native build diff --git a/.github/prompts/new-variant.prompt.md b/.github/prompts/new-variant.prompt.md new file mode 100644 index 000000000..1a324cea9 --- /dev/null +++ b/.github/prompts/new-variant.prompt.md @@ -0,0 +1,178 @@ +# New Hardware Variant + +Guide for adding a new Meshtastic hardware variant to the firmware. + +## Directory Structure + +Create under `variants///`: + +``` +variants/ +├── esp32/ # ESP32 +├── esp32s3/ # ESP32-S3 +├── esp32c3/ # ESP32-C3 +├── esp32c6/ # ESP32-C6 +├── nrf52840/ # nRF52840 +├── rp2040/ # RP2040/RP2350 +├── stm32/ # STM32WL +└── native/ # Linux/Portduino +``` + +Each variant needs at minimum: + +- `variant.h` — Pin definitions and hardware capabilities +- `platformio.ini` — Build configuration + +Optional files: + +- `pins_arduino.h` — Arduino pin mapping overrides +- `rfswitch.h` — RF switch control for multi-band radios +- `nicheGraphics.h` — InkHUD e-ink configuration + +## variant.h Template + +```cpp +// Pin definitions +#define I2C_SDA 21 +#define I2C_SCL 22 + +// LoRa radio +#define USE_SX1262 // Radio chip: USE_SX1262, USE_SX1268, USE_SX1280, USE_RF95, USE_LLCC68, USE_LR1110, USE_LR1120, USE_LR1121 +#define LORA_CS 18 +#define LORA_SCK 5 +#define LORA_MOSI 27 +#define LORA_MISO 19 +#define LORA_DIO1 33 // SX126x: DIO1, SX128x: DIO1, RF95: IRQ +#define LORA_RESET 23 +#define LORA_BUSY 32 // SX126x/SX128x only +#define SX126X_DIO2_AS_RF_SWITCH // Common for SX1262 boards + +// GPS +#define HAS_GPS 1 +#define GPS_RX_PIN 34 +#define GPS_TX_PIN 12 +// #define PIN_GPS_EN 47 // Optional GPS enable pin +// #define GPS_BAUDRATE 9600 // Override default 9600 + +// Display +#define HAS_SCREEN 1 +// #define USE_SSD1306 // OLED type +// #define USE_SH1106 // Alternative OLED +// #define USE_ST7789 // TFT type +// #define SCREEN_WIDTH 128 +// #define SCREEN_HEIGHT 64 + +// LEDs +#define LED_PIN 2 // Status LED (optional) +// #define HAS_NEOPIXEL 1 // WS2812 support + +// Buttons +#define BUTTON_PIN 38 +// #define BUTTON_PIN_ALT 0 // Secondary button + +// Power management +// #define HAS_AXP192 1 // AXP192 PMU (T-Beam v1.0) +// #define HAS_AXP2101 1 // AXP2101 PMU (T-Beam v1.2+) +// #define BATTERY_PIN 35 // ADC battery voltage pin +// #define ADC_MULTIPLIER 2.0 // Voltage divider ratio + +// Optional I2C devices +// #define HAS_RTC 1 // Real-time clock +// #define HAS_TELEMETRY 1 // Enable telemetry sensor support +// #define HAS_SENSOR 1 // I2C sensors present +``` + +## platformio.ini Template + +```ini +[env:my_variant] +extends = esp32s3_base ; Use architecture-specific base +board = esp32-s3-devkitc-1 ; PlatformIO board definition (or custom in boards/) +board_level = extra ; Build level: extra, or omit for default +custom_meshtastic_support_level = 1 ; 1 = PR builds, 2 = merge builds only + +build_flags = + ${esp32s3_base.build_flags} + -D MY_VARIANT_SPECIFIC_FLAG=1 + -I variants/esp32s3/my_variant ; Include path for variant.h + +upload_speed = 921600 +``` + +### Common Base Configs + +- `esp32_base` / `esp32-common.ini` — ESP32 +- `esp32s3_base` — ESP32-S3 +- `esp32c3_base` — ESP32-C3 +- `esp32c6_base` — ESP32-C6 +- `nrf52840_base` / `nrf52.ini` — nRF52840 +- `rp2040_base` — RP2040/RP2350 + +### Support Levels + +- `custom_meshtastic_support_level = 1` — Built on every PR (actively supported) +- `custom_meshtastic_support_level = 2` — Built only on merge to main branches +- `board_level = extra` — Only built on full releases + +## Build Manifest Metadata + +`bin/platformio-custom.py` emits UI capability flags in the build manifest: + +- `custom_meshtastic_has_mui = true/false` — Override MUI detection +- `custom_meshtastic_has_ink_hud = true/false` — Override InkHUD detection +- Architecture names are normalized (e.g., `esp32s3` → `esp32-s3`) + +## InkHUD E-Ink Variants + +For e-ink display variants using the InkHUD framework, add `nicheGraphics.h`: + +```cpp +// nicheGraphics.h — InkHUD configuration for this variant +#define INKHUD // Enable InkHUD +// Configure display, applets, and refresh behavior per device +``` + +InkHUD has its own PlatformIO config: `src/graphics/niche/InkHUD/PlatformioConfig.ini` + +## I2C Device Detection + +If the variant has I2C devices, ensure `src/detect/ScanI2C` will detect them. The auto-detection system handles 80+ device types including displays, sensors, RTCs, keyboards, PMUs, and touch controllers at boot. + +## Custom Board Definitions + +If the PlatformIO board doesn't exist, create a custom board JSON in `boards/`: + +```json +{ + "build": { + "arduino": { "ldscript": "esp32s3_out.ld" }, + "core": "esp32", + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": ["wifi", "bluetooth"], + "frameworks": ["arduino", "espidf"], + "name": "My Custom Board", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608 + }, + "url": "https://example.com", + "vendor": "MyVendor" +} +``` + +## Checklist + +- [ ] Create `variants///variant.h` with pin definitions +- [ ] Create `variants///platformio.ini` extending correct base +- [ ] Set `custom_meshtastic_support_level` (1 or 2) +- [ ] Verify radio chip define matches hardware (`USE_SX1262`, etc.) +- [ ] Set hardware capability flags (`HAS_GPS`, `HAS_SCREEN`, etc.) +- [ ] Add custom board JSON in `boards/` if needed +- [ ] Test build: `pio run -e my_variant` +- [ ] For e-ink: add `nicheGraphics.h` with InkHUD config From fe90c497950884d7dca4177af7ff4c4622216da3 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 16 Apr 2026 23:39:37 +0800 Subject: [PATCH 29/67] fix/feat(stm32/russell): Serial2 build fix and BME680 support (#10097) * fix(stm32/russell): define ENABLE_HWSERIAL2 and Serial2 pins The Russell board variant was missed during Initial serialModule cleanup (PR #9465), which began requiring Serial2 to be explicitly defined via ENABLE_HWSERIAL2 and PIN_SERIAL2_TX/RX rather than relying on implicit defaults, causing a build error. Signed-off-by: Andrew Yong * feat(stm32/russell): add BME680 support, exclude modules to fit flash The BME680 is hardware footprint compatible with the BME280 already present on the Russell board, so add it as an additional lib dep to enable environment sensing (temperature, humidity, pressure, gas resistance). The STM32 target has very limited flash. Even traceroute alone causes overflow, so the following modules are excluded to stay within budget: - RANGETEST - DETECTIONSENSOR - EXTERNALNOTIFICATION - POWERSTRESS - NEIGHBORINFO - TRACEROUTE - WAYPOINT AIR_QUALITY_SENSOR is also excluded as it requires the BSEC2 library for real IAQ output, which alone overflows flash by ~44KB on this target. The Adafruit BME680 library is used instead for raw sensor readings. Signed-off-by: Andrew Yong --------- Signed-off-by: Andrew Yong Co-authored-by: Jonathan Bennett Co-authored-by: Ben Meadors --- variants/stm32/russell/platformio.ini | 10 ++++++++++ variants/stm32/russell/variant.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/variants/stm32/russell/platformio.ini b/variants/stm32/russell/platformio.ini index 0dd57a2c7..73cf7f81a 100644 --- a/variants/stm32/russell/platformio.ini +++ b/variants/stm32/russell/platformio.ini @@ -13,9 +13,19 @@ build_flags = ${stm32_base.build_flags} -Ivariants/stm32/russell -DPRIVATE_HW + -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 + -DMESHTASTIC_EXCLUDE_RANGETEST=1 + -DMESHTASTIC_EXCLUDE_DETECTIONSENSOR=1 + -DMESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION=1 + -DMESHTASTIC_EXCLUDE_POWERSTRESS=1 + -DMESHTASTIC_EXCLUDE_NEIGHBORINFO=1 + -DMESHTASTIC_EXCLUDE_TRACEROUTE=1 + -DMESHTASTIC_EXCLUDE_WAYPOINT=1 lib_deps = ${stm32_base.lib_deps} # renovate: datasource=custom.pio depName=Adafruit BME280 packageName=adafruit/library/Adafruit BME280 Library adafruit/Adafruit BME280 Library@2.3.0 + # renovate: datasource=custom.pio depName=Adafruit_BME680 packageName=adafruit/library/Adafruit BME680 Library + adafruit/Adafruit BME680 Library@2.0.6 upload_port = stlink diff --git a/variants/stm32/russell/variant.h b/variants/stm32/russell/variant.h index 7b5d4e9a1..d36826c15 100644 --- a/variants/stm32/russell/variant.h +++ b/variants/stm32/russell/variant.h @@ -30,6 +30,11 @@ Sample OCV curve for Li-SOCl2 primary lithium cells (e.g. Saft cells have fresh #define ENABLE_HWSERIAL1 #define PIN_SERIAL1_RX PB7 #define PIN_SERIAL1_TX PB6 + +// Debug serial (USART2) +#define ENABLE_HWSERIAL2 +#define PIN_SERIAL2_TX PA2 +#define PIN_SERIAL2_RX PA3 #define HAS_GPS 1 #define PIN_GPS_STANDBY PA15 #define GPS_RX_PIN PB7 From 466cc4cecddd11cd1bb0d0b166bd658d116832b3 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Apr 2026 08:41:06 -0700 Subject: [PATCH 30/67] Add Luckfox Pico Max Waveshare Pico LoRa config (#10175) Add a meshtasticd config for the Luckfox Pico Max with the Waveshare Pico LoRa SX1262 TCXO HAT. Tested on hardware with successful SX1262 init, broadcast, and direct messaging. --- ...fox-pico-max-ws-raspberry-pi-pico-hat.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bin/config.d/lora-luckfox-pico-max-ws-raspberry-pi-pico-hat.yaml diff --git a/bin/config.d/lora-luckfox-pico-max-ws-raspberry-pi-pico-hat.yaml b/bin/config.d/lora-luckfox-pico-max-ws-raspberry-pi-pico-hat.yaml new file mode 100644 index 000000000..e0cc6197b --- /dev/null +++ b/bin/config.d/lora-luckfox-pico-max-ws-raspberry-pi-pico-hat.yaml @@ -0,0 +1,31 @@ +# For use with Armbian luckfox-pico-max +# Waveshare LoRa HAT for Raspberry Pi Pico +# https://www.waveshare.com/wiki/Pico-LoRa-SX1262 + +Meta: + name: luckfox-pico-max-ws-raspberry-pi-pico-hat + support: community + compatible: + - luckfox-pico-max # Armbian + +Lora: + Module: sx1262 + DIO2_AS_RF_SWITCH: true + DIO3_TCXO_VOLTAGE: true + spidev: spidev0.0 + Busy: # GPIO1_C7 / GP2 + pin: 55 + gpiochip: 1 + line: 23 + CS: # GPIO1_C6 / GP3 + pin: 54 + gpiochip: 1 + line: 22 + Reset: # GPIO1_D1 / GP15 + pin: 57 + gpiochip: 1 + line: 25 + IRQ: # GPIO2_A2 / GP20 + pin: 66 + gpiochip: 2 + line: 2 From 2768080edf13973894f8608892a8d6ba8f9f68ea Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 16 Apr 2026 13:12:31 -0500 Subject: [PATCH 31/67] More cleanly remove LED_BUILTIN (#10179) * Test PR to remove LED_BUILTIN Comment out the LED_BUILTIN definition in platformio.ini * Add LED_BUILTIN definition to nrf52840.ini --- platformio.ini | 2 +- variants/nrf52840/nrf52840.ini | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 46170fe09..f0af061cb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,7 +58,7 @@ build_flags = -Wno-missing-field-initializers -DMESHTASTIC_EXCLUDE_POWERMON=1 -DMESHTASTIC_EXCLUDE_STATUS=1 -D MAX_THREADS=40 ; As we've split modules, we have more threads to manage - -DLED_BUILTIN=-1 + #-DLED_BUILTIN=-1 #-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now #-D OLED_PL=1 #-D DEBUG_HEAP=1 ; uncomment to add free heap space / memory leak debugging logs diff --git a/variants/nrf52840/nrf52840.ini b/variants/nrf52840/nrf52840.ini index 09b2ef97d..c5590cbc3 100644 --- a/variants/nrf52840/nrf52840.ini +++ b/variants/nrf52840/nrf52840.ini @@ -4,6 +4,7 @@ extends = nrf52_base build_flags = ${nrf52_base.build_flags} -DSERIAL_BUFFER_SIZE=4096 + -DLED_BUILTIN=-1 lib_deps = ${nrf52_base.lib_deps} @@ -79,4 +80,4 @@ debug_speed = 4000 ; The following is not needed because it automatically tries do this ;debug_server_ready_pattern = -.*GDB server started on port \d+.* -;debug_port = localhost:3333 \ No newline at end of file +;debug_port = localhost:3333 From 92263859a76ed8e5ec1b8c2800642b029c0c41bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 20:19:17 -0500 Subject: [PATCH 32/67] Update protobufs (#10184) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/atak.pb.cpp | 62 + src/mesh/generated/meshtastic/atak.pb.h | 1205 +++++++++++++++++- src/mesh/generated/meshtastic/mesh.pb.cpp | 5 + src/mesh/generated/meshtastic/mesh.pb.h | 88 +- src/mesh/generated/meshtastic/portnums.pb.h | 2 + src/mesh/generated/meshtastic/telemetry.pb.h | 21 +- 7 files changed, 1360 insertions(+), 25 deletions(-) diff --git a/protobufs b/protobufs index e30092e61..4d5b500df 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit e30092e6168b13341c2b7ec4be19c789ad5cd77f +Subproject commit 4d5b500df5af68a4f57d3e19705cc3bb1136358c diff --git a/src/mesh/generated/meshtastic/atak.pb.cpp b/src/mesh/generated/meshtastic/atak.pb.cpp index bbafa33e2..dda9fddaf 100644 --- a/src/mesh/generated/meshtastic/atak.pb.cpp +++ b/src/mesh/generated/meshtastic/atak.pb.cpp @@ -27,6 +27,42 @@ PB_BIND(meshtastic_PLI, meshtastic_PLI, AUTO) PB_BIND(meshtastic_AircraftTrack, meshtastic_AircraftTrack, AUTO) +PB_BIND(meshtastic_CotGeoPoint, meshtastic_CotGeoPoint, AUTO) + + +PB_BIND(meshtastic_DrawnShape, meshtastic_DrawnShape, 2) + + +PB_BIND(meshtastic_Marker, meshtastic_Marker, AUTO) + + +PB_BIND(meshtastic_RangeAndBearing, meshtastic_RangeAndBearing, AUTO) + + +PB_BIND(meshtastic_Route, meshtastic_Route, 2) + + +PB_BIND(meshtastic_Route_Link, meshtastic_Route_Link, AUTO) + + +PB_BIND(meshtastic_CasevacReport, meshtastic_CasevacReport, 2) + + +PB_BIND(meshtastic_ZMistEntry, meshtastic_ZMistEntry, AUTO) + + +PB_BIND(meshtastic_EmergencyAlert, meshtastic_EmergencyAlert, AUTO) + + +PB_BIND(meshtastic_TaskRequest, meshtastic_TaskRequest, AUTO) + + +PB_BIND(meshtastic_TAKEnvironment, meshtastic_TAKEnvironment, AUTO) + + +PB_BIND(meshtastic_SensorFov, meshtastic_SensorFov, AUTO) + + PB_BIND(meshtastic_TAKPacketV2, meshtastic_TAKPacketV2, 2) @@ -41,3 +77,29 @@ PB_BIND(meshtastic_TAKPacketV2, meshtastic_TAKPacketV2, 2) + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesh/generated/meshtastic/atak.pb.h b/src/mesh/generated/meshtastic/atak.pb.h index c12b042f4..d69b14009 100644 --- a/src/mesh/generated/meshtastic/atak.pb.h +++ b/src/mesh/generated/meshtastic/atak.pb.h @@ -241,7 +241,91 @@ typedef enum _meshtastic_CotType { /* b-f-t-r: File transfer request */ meshtastic_CotType_CotType_b_f_t_r = 74, /* b-f-t-a: File transfer acknowledgment */ - meshtastic_CotType_CotType_b_f_t_a = 75 + meshtastic_CotType_CotType_b_f_t_a = 75, + /* u-d-f-m: Freehand telestration / annotation. Anchor at event point, + geometry carried via DrawnShape.vertices. May be truncated to + MAX_VERTICES by the sender. */ + meshtastic_CotType_CotType_u_d_f_m = 76, + /* u-d-p: Closed polygon. Geometry carried via DrawnShape.vertices, + implicitly closed (receiver duplicates first vertex as needed). */ + meshtastic_CotType_CotType_u_d_p = 77, + /* b-m-p-s-m: Spot map marker (colored dot at a point of interest). */ + meshtastic_CotType_CotType_b_m_p_s_m = 78, + /* b-m-p-c: Checkpoint (intermediate route control point). */ + meshtastic_CotType_CotType_b_m_p_c = 79, + /* u-r-b-c-c: Ranging circle (range rings centered on the event point). */ + meshtastic_CotType_CotType_u_r_b_c_c = 80, + /* u-r-b-bullseye: Bullseye with configurable range rings and bearing + reference (magnetic / true / grid). */ + meshtastic_CotType_CotType_u_r_b_bullseye = 81, + /* a-f-G-E-V-A: Friendly armored vehicle, user-selectable self PLI. */ + meshtastic_CotType_CotType_a_f_G_E_V_A = 82, + /* a-n-A: Neutral aircraft (friendly/hostile/unknown already present). */ + meshtastic_CotType_CotType_a_n_A = 83, + /* --- 2525 quick-drop: artillery (4) ---------------------------------- */ + meshtastic_CotType_CotType_a_u_G_U_C_F = 84, + meshtastic_CotType_CotType_a_n_G_U_C_F = 85, + meshtastic_CotType_CotType_a_h_G_U_C_F = 86, + meshtastic_CotType_CotType_a_f_G_U_C_F = 87, + /* --- 2525 quick-drop: building (4) ----------------------------------- */ + meshtastic_CotType_CotType_a_u_G_I = 88, + meshtastic_CotType_CotType_a_n_G_I = 89, + meshtastic_CotType_CotType_a_h_G_I = 90, + meshtastic_CotType_CotType_a_f_G_I = 91, + /* --- 2525 quick-drop: mine (4) --------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_E_X_M = 92, + meshtastic_CotType_CotType_a_n_G_E_X_M = 93, + meshtastic_CotType_CotType_a_h_G_E_X_M = 94, + meshtastic_CotType_CotType_a_f_G_E_X_M = 95, + /* --- 2525 quick-drop: ship (3; a-f-S already at 17) ------------------ */ + meshtastic_CotType_CotType_a_u_S = 96, + meshtastic_CotType_CotType_a_n_S = 97, + meshtastic_CotType_CotType_a_h_S = 98, + /* --- 2525 quick-drop: sniper (4) ------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_U_C_I_d = 99, + meshtastic_CotType_CotType_a_n_G_U_C_I_d = 100, + meshtastic_CotType_CotType_a_h_G_U_C_I_d = 101, + meshtastic_CotType_CotType_a_f_G_U_C_I_d = 102, + /* --- 2525 quick-drop: tank (4) --------------------------------------- */ + meshtastic_CotType_CotType_a_u_G_E_V_A_T = 103, + meshtastic_CotType_CotType_a_n_G_E_V_A_T = 104, + meshtastic_CotType_CotType_a_h_G_E_V_A_T = 105, + meshtastic_CotType_CotType_a_f_G_E_V_A_T = 106, + /* --- 2525 quick-drop: troops (3; a-f-G-U-C-I already at 2) ----------- */ + meshtastic_CotType_CotType_a_u_G_U_C_I = 107, + meshtastic_CotType_CotType_a_n_G_U_C_I = 108, + meshtastic_CotType_CotType_a_h_G_U_C_I = 109, + /* --- 2525 quick-drop: generic vehicle (3; a-u-G-E-V already at 69) --- */ + meshtastic_CotType_CotType_a_n_G_E_V = 110, + meshtastic_CotType_CotType_a_h_G_E_V = 111, + meshtastic_CotType_CotType_a_f_G_E_V = 112, + /* b-m-p-w-GOTO: Go To / bloodhound navigation target. */ + meshtastic_CotType_CotType_b_m_p_w_GOTO = 113, + /* b-m-p-c-ip: Initial point (mission planning). */ + meshtastic_CotType_CotType_b_m_p_c_ip = 114, + /* b-m-p-c-cp: Contact point (mission planning). */ + meshtastic_CotType_CotType_b_m_p_c_cp = 115, + /* b-m-p-s-p-op: Observation post. */ + meshtastic_CotType_CotType_b_m_p_s_p_op = 116, + /* u-d-v: 2D vehicle outline drawn on the map. */ + meshtastic_CotType_CotType_u_d_v = 117, + /* u-d-v-m: 3D vehicle model reference. */ + meshtastic_CotType_CotType_u_d_v_m = 118, + /* u-d-c-e: Non-circular ellipse (circle with distinct major/minor axes). */ + meshtastic_CotType_CotType_u_d_c_e = 119, + /* b-i-x-i: Quick Pic geotagged image marker. The image itself does not + ride on LoRa; this event references the image via iconset metadata. */ + meshtastic_CotType_CotType_b_i_x_i = 120, + /* b-t-f-d: GeoChat delivered receipt. Carried on the existing `chat` + payload_variant via GeoChat.receipt_for_uid + receipt_type. */ + meshtastic_CotType_CotType_b_t_f_d = 121, + /* b-t-f-r: GeoChat read receipt. Same wire slot as b-t-f-d. */ + meshtastic_CotType_CotType_b_t_f_r = 122, + /* b-a-o-c: Custom / generic emergency beacon. */ + meshtastic_CotType_CotType_b_a_o_c = 123, + /* t-s: Task / engage request. Structured payload carried via the new + TaskRequest typed variant. */ + meshtastic_CotType_CotType_t_s = 124 } meshtastic_CotType; /* Geopoint and altitude source */ @@ -256,10 +340,204 @@ typedef enum _meshtastic_GeoPointSource { meshtastic_GeoPointSource_GeoPointSource_NETWORK = 3 } meshtastic_GeoPointSource; +/* Receipt discriminator. Set alongside cot_type_id = b-t-f-d (delivered) + or b-t-f-r (read). ReceiptType_None is the default for a normal chat + message (cot_type_id = b-t-f). + + Receivers can detect a receipt by checking receipt_type != ReceiptType_None + without re-parsing the envelope cot_type_id. */ +typedef enum _meshtastic_GeoChat_ReceiptType { + meshtastic_GeoChat_ReceiptType_ReceiptType_None = 0, /* normal chat message */ + meshtastic_GeoChat_ReceiptType_ReceiptType_Delivered = 1, /* b-t-f-d delivered receipt */ + meshtastic_GeoChat_ReceiptType_ReceiptType_Read = 2 /* b-t-f-r read receipt */ +} meshtastic_GeoChat_ReceiptType; + +/* Shape kind discriminator. Drives receiver rendering and also controls + which optional fields below are meaningful. */ +typedef enum _meshtastic_DrawnShape_Kind { + /* Unspecified (do not use on the wire) */ + meshtastic_DrawnShape_Kind_Kind_Unspecified = 0, + /* u-d-c-c: User-drawn circle (uses major/minor/angle, anchor = event point) */ + meshtastic_DrawnShape_Kind_Kind_Circle = 1, + /* u-d-r: User-drawn rectangle (uses vertices = 4 corners) */ + meshtastic_DrawnShape_Kind_Kind_Rectangle = 2, + /* u-d-f: User-drawn polyline (uses vertices, not closed) */ + meshtastic_DrawnShape_Kind_Kind_Freeform = 3, + /* u-d-f-m: Freehand telestration / annotation (uses vertices, may be truncated) */ + meshtastic_DrawnShape_Kind_Kind_Telestration = 4, + /* u-d-p: Closed polygon (uses vertices, implicitly closed) */ + meshtastic_DrawnShape_Kind_Kind_Polygon = 5, + /* u-r-b-c-c: Ranging circle (major/minor/angle, stroke + optional fill) */ + meshtastic_DrawnShape_Kind_Kind_RangingCircle = 6, + /* u-r-b-bullseye: Bullseye ring with range rings and bearing reference */ + meshtastic_DrawnShape_Kind_Kind_Bullseye = 7, + /* u-d-c-e: Ellipse with distinct major/minor axes (same storage as + Kind_Circle — uses major_cm/minor_cm/angle_deg — but receivers + render it as a non-circular ellipse rather than a round circle). */ + meshtastic_DrawnShape_Kind_Kind_Ellipse = 8, + /* u-d-v: 2D vehicle outline drawn on the map. Vertices carry the + outline polygon; receivers draw it as a filled polygon. */ + meshtastic_DrawnShape_Kind_Kind_Vehicle2D = 9, + /* u-d-v-m: 3D vehicle model reference. Same vertex polygon as + Kind_Vehicle2D; receivers that support 3D rendering extrude it. */ + meshtastic_DrawnShape_Kind_Kind_Vehicle3D = 10 +} meshtastic_DrawnShape_Kind; + +/* Explicit stroke/fill/both discriminator. + + ATAK's source XML distinguishes "stroke-only polyline" from "closed shape + with both stroke and fill" by the presence of the element. + Both states can hash to all-zero color fields, so we carry the signal + explicitly. Parser sets this from (sawStrokeColor, sawFillColor) at the + end of parse; builder uses it to decide which of / + to emit in the reconstructed XML. */ +typedef enum _meshtastic_DrawnShape_StyleMode { + /* Unspecified — receiver infers from which color fields are non-zero. */ + meshtastic_DrawnShape_StyleMode_StyleMode_Unspecified = 0, + /* Stroke only. No in the source XML. Used for polylines, + ranging lines, bullseye rings. */ + meshtastic_DrawnShape_StyleMode_StyleMode_StrokeOnly = 1, + /* Fill only. No in the source XML. Rare but valid in + ATAK (solid region with no outline). */ + meshtastic_DrawnShape_StyleMode_StyleMode_FillOnly = 2, + /* Both stroke and fill present. Closed shapes: circle, rectangle, + polygon, ranging circle. */ + meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill = 3 +} meshtastic_DrawnShape_StyleMode; + +/* Marker kind. Used to pick sensible receiver defaults when the CoT type + alone is ambiguous (e.g. a-u-G could be a 2525 symbol or a custom icon + depending on the iconset path). */ +typedef enum _meshtastic_Marker_Kind { + /* Unspecified — fall back to TAKPacketV2.cot_type_id */ + meshtastic_Marker_Kind_Kind_Unspecified = 0, + /* b-m-p-s-m: Spot map marker */ + meshtastic_Marker_Kind_Kind_Spot = 1, + /* b-m-p-w: Route waypoint */ + meshtastic_Marker_Kind_Kind_Waypoint = 2, + /* b-m-p-c: Checkpoint */ + meshtastic_Marker_Kind_Kind_Checkpoint = 3, + /* b-m-p-s-p-i / b-m-p-s-p-loc: Self-position marker */ + meshtastic_Marker_Kind_Kind_SelfPosition = 4, + /* 2525B/C military symbol (iconsetpath = COT_MAPPING_2525B/...) */ + meshtastic_Marker_Kind_Kind_Symbol2525 = 5, + /* COT_MAPPING_SPOTMAP icon (e.g. colored dot) */ + meshtastic_Marker_Kind_Kind_SpotMap = 6, + /* Custom icon set (UUID/GroupName/filename.png) */ + meshtastic_Marker_Kind_Kind_CustomIcon = 7, + /* b-m-p-w-GOTO: Go To / bloodhound navigation waypoint. */ + meshtastic_Marker_Kind_Kind_GoToPoint = 8, + /* b-m-p-c-ip: Initial point (mission planning control point). */ + meshtastic_Marker_Kind_Kind_InitialPoint = 9, + /* b-m-p-c-cp: Contact point (mission planning control point). */ + meshtastic_Marker_Kind_Kind_ContactPoint = 10, + /* b-m-p-s-p-op: Observation post. */ + meshtastic_Marker_Kind_Kind_ObservationPost = 11, + /* b-i-x-i: Quick Pic geotagged image marker. iconset carries the + image reference (local filename or remote URL); the image itself + does not ride on the LoRa wire. */ + meshtastic_Marker_Kind_Kind_ImageMarker = 12 +} meshtastic_Marker_Kind; + +/* Travel method for the route. */ +typedef enum _meshtastic_Route_Method { + /* Unspecified / unknown */ + meshtastic_Route_Method_Method_Unspecified = 0, + /* Driving / vehicle */ + meshtastic_Route_Method_Method_Driving = 1, + /* Walking / foot */ + meshtastic_Route_Method_Method_Walking = 2, + /* Flying */ + meshtastic_Route_Method_Method_Flying = 3, + /* Swimming (individual) */ + meshtastic_Route_Method_Method_Swimming = 4, + /* Watercraft (boat) */ + meshtastic_Route_Method_Method_Watercraft = 5 +} meshtastic_Route_Method; + +/* Route direction (infil = ingress, exfil = egress). */ +typedef enum _meshtastic_Route_Direction { + /* Unspecified */ + meshtastic_Route_Direction_Direction_Unspecified = 0, + /* Infiltration (ingress) */ + meshtastic_Route_Direction_Direction_Infil = 1, + /* Exfiltration (egress) */ + meshtastic_Route_Direction_Direction_Exfil = 2 +} meshtastic_Route_Direction; + +/* Line 3: precedence / urgency. */ +typedef enum _meshtastic_CasevacReport_Precedence { + meshtastic_CasevacReport_Precedence_Precedence_Unspecified = 0, + meshtastic_CasevacReport_Precedence_Precedence_Urgent = 1, /* A - immediate, life-threatening */ + meshtastic_CasevacReport_Precedence_Precedence_UrgentSurgical = 2, /* B - needs surgery */ + meshtastic_CasevacReport_Precedence_Precedence_Priority = 3, /* C - within 4 hours */ + meshtastic_CasevacReport_Precedence_Precedence_Routine = 4, /* D - within 24 hours */ + meshtastic_CasevacReport_Precedence_Precedence_Convenience = 5 /* E - convenience */ +} meshtastic_CasevacReport_Precedence; + +/* Line 7: HLZ marking method. */ +typedef enum _meshtastic_CasevacReport_HlzMarking { + meshtastic_CasevacReport_HlzMarking_HlzMarking_Unspecified = 0, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Panels = 1, + meshtastic_CasevacReport_HlzMarking_HlzMarking_PyroSignal = 2, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Smoke = 3, + meshtastic_CasevacReport_HlzMarking_HlzMarking_None = 4, + meshtastic_CasevacReport_HlzMarking_HlzMarking_Other = 5 +} meshtastic_CasevacReport_HlzMarking; + +/* Line 6: security situation at the pickup zone. */ +typedef enum _meshtastic_CasevacReport_Security { + meshtastic_CasevacReport_Security_Security_Unspecified = 0, + meshtastic_CasevacReport_Security_Security_NoEnemy = 1, /* N - no enemy activity */ + meshtastic_CasevacReport_Security_Security_PossibleEnemy = 2, /* P - possible enemy */ + meshtastic_CasevacReport_Security_Security_EnemyInArea = 3, /* E - enemy, approach with caution */ + meshtastic_CasevacReport_Security_Security_EnemyInArmedContact = 4 /* X - armed escort required */ +} meshtastic_CasevacReport_Security; + +typedef enum _meshtastic_EmergencyAlert_Type { + meshtastic_EmergencyAlert_Type_Type_Unspecified = 0, + meshtastic_EmergencyAlert_Type_Type_Alert911 = 1, /* b-a-o-tbl */ + meshtastic_EmergencyAlert_Type_Type_RingTheBell = 2, /* b-a-o-pan */ + meshtastic_EmergencyAlert_Type_Type_InContact = 3, /* b-a-o-opn */ + meshtastic_EmergencyAlert_Type_Type_GeoFenceBreached = 4, /* b-a-g */ + meshtastic_EmergencyAlert_Type_Type_Custom = 5, /* b-a-o-c */ + meshtastic_EmergencyAlert_Type_Type_Cancel = 6 /* b-a-o-can */ +} meshtastic_EmergencyAlert_Type; + +typedef enum _meshtastic_TaskRequest_Priority { + meshtastic_TaskRequest_Priority_Priority_Unspecified = 0, + meshtastic_TaskRequest_Priority_Priority_Low = 1, + meshtastic_TaskRequest_Priority_Priority_Normal = 2, + meshtastic_TaskRequest_Priority_Priority_High = 3, + meshtastic_TaskRequest_Priority_Priority_Critical = 4 +} meshtastic_TaskRequest_Priority; + +typedef enum _meshtastic_TaskRequest_Status { + meshtastic_TaskRequest_Status_Status_Unspecified = 0, + meshtastic_TaskRequest_Status_Status_Pending = 1, /* assigned, not yet acknowledged */ + meshtastic_TaskRequest_Status_Status_Acknowledged = 2, /* assignee has seen it */ + meshtastic_TaskRequest_Status_Status_InProgress = 3, /* assignee is working it */ + meshtastic_TaskRequest_Status_Status_Completed = 4, /* task done */ + meshtastic_TaskRequest_Status_Status_Cancelled = 5 /* cancelled before completion */ +} meshtastic_TaskRequest_Status; + +/* Coarse sensor category, inferred from `model` on parse when the source + XML doesn't label it. Receivers that render differently per sensor + class (thermal overlay vs daylight cone) use this. */ +typedef enum _meshtastic_SensorFov_SensorType { + meshtastic_SensorFov_SensorType_SensorType_Unspecified = 0, + meshtastic_SensorFov_SensorType_SensorType_Camera = 1, /* daylight / general optical */ + meshtastic_SensorFov_SensorType_SensorType_Thermal = 2, /* FLIR, thermal imager */ + meshtastic_SensorFov_SensorType_SensorType_Laser = 3, /* rangefinder, LRF, designator */ + meshtastic_SensorFov_SensorType_SensorType_Nvg = 4, /* night vision goggles */ + meshtastic_SensorFov_SensorType_SensorType_Rf = 5, /* radio/radar direction-finding */ + meshtastic_SensorFov_SensorType_SensorType_Other = 6 +} meshtastic_SensorFov_SensorType; + /* Struct definitions */ /* ATAK GeoChat message */ typedef struct _meshtastic_GeoChat { - /* The text message */ + /* The text message. Empty for receipts. */ char message[200]; /* Uid recipient of the message */ bool has_to; @@ -267,6 +545,14 @@ typedef struct _meshtastic_GeoChat { /* Callsign of the recipient for the message */ bool has_to_callsign; char to_callsign[120]; + /* UID of the chat message this event is acknowledging. Empty for a + normal chat message; set for delivered / read receipts. Paired with + receipt_type so receivers can match the ack back to the original + outbound GeoChat by its event uid. */ + char receipt_for_uid[48]; + /* Receipt kind discriminator. See ReceiptType doc. Default ReceiptType_None + means this is a regular chat message, not a receipt. */ + meshtastic_GeoChat_ReceiptType receipt_type; } meshtastic_GeoChat; /* ATAK Group @@ -360,6 +646,428 @@ typedef struct _meshtastic_AircraftTrack { char cot_host_id[64]; } meshtastic_AircraftTrack; +/* Compact geographic vertex used by repeated vertex lists in TAK geometry + payloads. Named with a `Cot` prefix to avoid a namespace collision with + `meshtastic.GeoPoint` in `device_ui.proto`, which is an unrelated zoom/ + latitude/longitude type used by the on-device map UI. + + Encoded as a signed DELTA from TAKPacketV2.latitude_i / longitude_i (the + enclosing event's anchor point). The absolute coordinate is recovered by + the receiver as `event.latitude_i + vertex.lat_delta_i` (and likewise for + longitude). + + Why deltas: a 32-vertex telestration with vertices clustered within a few + hundred meters of the anchor has per-vertex deltas in the ±10^4 range. + Under sint32+zigzag those encode as 2 bytes each (tag+varint), versus the + 4 bytes that sfixed32 would always require. At 32 vertices that is ~128 + bytes of savings — the difference between fitting under the LoRa MTU or + not. Absolute coordinates (values ~10^9) would cost sint32 varint 5 bytes + per field, which is why TAKPacketV2's top-level latitude_i / longitude_i + stay sfixed32 — only small values win with sint32. */ +typedef struct _meshtastic_CotGeoPoint { + /* Latitude delta from TAKPacketV2.latitude_i, in 1e-7 degree units. + Add to the enclosing event's latitude_i to recover the absolute latitude. */ + int32_t lat_delta_i; + /* Longitude delta from TAKPacketV2.longitude_i, in 1e-7 degree units. */ + int32_t lon_delta_i; +} meshtastic_CotGeoPoint; + +/* User-drawn tactical graphic: circle, rectangle, polygon, polyline, freehand + telestration, ranging circle, or bullseye. + + Covers CoT types u-d-c-c, u-d-r, u-d-f, u-d-f-m, u-d-p, u-r-b-c-c, + u-r-b-bullseye. The shape's anchor position is carried on + TAKPacketV2.latitude_i/longitude_i; polyline/polygon vertices are in the + `vertices` repeated field as `CotGeoPoint` deltas from that anchor. + + Colors use the Team enum as a 14-color palette (see color encoding below) + with a fixed32 exact-ARGB fallback for custom user-picked colors that + don't map to a palette entry. */ +typedef struct _meshtastic_DrawnShape { + /* Shape kind (circle, rectangle, freeform, etc.) */ + meshtastic_DrawnShape_Kind kind; + /* Explicit stroke/fill/both discriminator. See StyleMode doc. */ + meshtastic_DrawnShape_StyleMode style; + /* Ellipse major radius in centimeters. 0 for non-ellipse kinds. */ + uint32_t major_cm; + /* Ellipse minor radius in centimeters. 0 for non-ellipse kinds. */ + uint32_t minor_cm; + /* Ellipse rotation angle in degrees. Valid values are 0..360 inclusive; + 0 and 360 are equivalent rotations. In proto3, an unset uint32 reads + as 0, so senders should emit 0 when the angle is unspecified. */ + uint16_t angle_deg; + /* Stroke color as a named palette entry from the Team enum. If + Unspecifed_Color, the exact ARGB is carried in stroke_argb. + Valid only when style is StrokeOnly or StrokeAndFill. */ + meshtastic_Team stroke_color; + /* Stroke color as an exact 32-bit ARGB bit pattern. Always populated + on the wire; readers MUST use this value when stroke_color == + Unspecifed_Color and MAY use it to recover the exact original bytes + even when a palette entry is set. */ + uint32_t stroke_argb; + /* Stroke weight in tenths of a unit (e.g. 30 = 3.0). Typical ATAK + range 10..60. */ + uint16_t stroke_weight_x10; + /* Fill color as a named palette entry. See stroke_color docs. + Valid only when style is FillOnly or StrokeAndFill. */ + meshtastic_Team fill_color; + /* Fill color exact ARGB fallback. See stroke_argb docs. */ + uint32_t fill_argb; + /* Whether labels are rendered on this shape. */ + bool labels_on; + /* Vertex list for polyline/polygon/rectangle shapes. Capped at 32 by + the nanopb pool; senders MUST truncate longer inputs and set + `truncated = true`. */ + pb_size_t vertices_count; + meshtastic_CotGeoPoint vertices[32]; + /* True if the sender truncated `vertices` to fit the pool. */ + bool truncated; /* --- Bullseye-only fields. All ignored unless kind == Kind_Bullseye. --- */ + /* Bullseye distance in meters * 10 (e.g. 3285 = 328.5 m). 0 = unset. */ + uint32_t bullseye_distance_dm; + /* Bullseye bearing reference: 0 unset, 1 Magnetic, 2 True, 3 Grid. */ + uint8_t bullseye_bearing_ref; + /* Bullseye attribute bit flags: + bit 0: rangeRingVisible + bit 1: hasRangeRings + bit 2: edgeToCenter + bit 3: mils */ + uint8_t bullseye_flags; + /* Bullseye reference UID (anchor marker). Empty = anchor is self. */ + char bullseye_uid_ref[48]; +} meshtastic_DrawnShape; + +/* Fixed point of interest: spot marker, waypoint, checkpoint, 2525 symbol, + or custom icon. + + Covers CoT types b-m-p-s-m, b-m-p-w, b-m-p-c, b-m-p-s-p-i, b-m-p-s-p-loc, + plus a-u-G / a-f-G / a-h-G / a-n-G with iconset paths. The marker position + is carried on TAKPacketV2.latitude_i/longitude_i; fields below carry only + the marker-specific metadata. */ +typedef struct _meshtastic_Marker { + /* Marker kind */ + meshtastic_Marker_Kind kind; + /* Marker color as a named palette entry. If Unspecifed_Color, the exact + ARGB is in color_argb. */ + meshtastic_Team color; + /* Marker color exact ARGB bit pattern. Always populated on the wire. */ + uint32_t color_argb; + /* Status readiness flag (ATAK ). */ + bool readiness; + /* Parent link UID (ATAK ). Empty = no parent. + For spot/waypoint markers this is typically the producing TAK user's UID. */ + char parent_uid[48]; + /* Parent CoT type (e.g. "a-f-G-U-C"). Usually the parent TAK user's type. */ + char parent_type[24]; + /* Parent callsign (e.g. "HOPE"). */ + char parent_callsign[24]; + /* Iconset path stored verbatim. ATAK emits three flavors: + Kind_Symbol2525 -> "COT_MAPPING_2525B//" + Kind_SpotMap -> "COT_MAPPING_SPOTMAP//" + Kind_CustomIcon -> "//.png" + Stored end-to-end without prefix stripping; the ~19 bytes saved by + stripping well-known prefixes are not worth the builder-side bug + surface, and the dict compresses the repetition effectively. */ + char iconset[80]; +} meshtastic_Marker; + +/* Range and bearing measurement line from the event anchor to a target point. + + Covers CoT type u-rb-a. The anchor position is on + TAKPacketV2.latitude_i/longitude_i; the target endpoint is carried as a + CotGeoPoint — same delta-from-anchor encoding used by DrawnShape.vertices + so a self-anchored RAB (common case) encodes in zero bytes. */ +typedef struct _meshtastic_RangeAndBearing { + /* Target/anchor endpoint (delta-encoded from TAKPacketV2.latitude_i/longitude_i). */ + bool has_anchor; + meshtastic_CotGeoPoint anchor; + /* Anchor UID (from ). Empty = free-standing. */ + char anchor_uid[48]; + /* Range in centimeters (value * 100). Range 0..4294 km. */ + uint32_t range_cm; + /* Bearing in degrees * 100 (0..36000). */ + uint16_t bearing_cdeg; + /* Stroke color as a Team palette entry. See DrawnShape.stroke_color doc. */ + meshtastic_Team stroke_color; + /* Stroke color exact ARGB fallback. */ + uint32_t stroke_argb; + /* Stroke weight * 10 (e.g. 30 = 3.0). */ + uint16_t stroke_weight_x10; +} meshtastic_RangeAndBearing; + +/* Route waypoint or control point. Each link corresponds to one ATAK + entry inside the b-m-r event. */ +typedef struct _meshtastic_Route_Link { + /* Waypoint position (delta-encoded from TAKPacketV2.latitude_i/longitude_i). */ + bool has_point; + meshtastic_CotGeoPoint point; + /* Optional UID (empty = receiver derives). */ + char uid[48]; + /* Optional display callsign (e.g. "CP1"). Empty for unnamed control points. */ + char callsign[16]; + /* Link role: 0 = waypoint (b-m-p-w), 1 = checkpoint (b-m-p-c). */ + uint8_t link_type; +} meshtastic_Route_Link; + +/* Named route consisting of ordered waypoints and control points. + + Covers CoT type b-m-r. The first waypoint's position is on + TAKPacketV2.latitude_i/longitude_i; subsequent waypoints and checkpoints + are in `links`. Link count is capped at 16 by the nanopb pool; senders + MUST truncate longer routes and set `truncated = true`. */ +typedef struct _meshtastic_Route { + /* Travel method */ + meshtastic_Route_Method method; + /* Direction (infil/exfil) */ + meshtastic_Route_Direction direction; + /* Waypoint name prefix (e.g. "CP"). */ + char prefix[8]; + /* Stroke weight * 10 (e.g. 30 = 3.0). 0 = default. */ + uint16_t stroke_weight_x10; + /* Ordered list of route control points. Capped at 16. */ + pb_size_t links_count; + meshtastic_Route_Link links[16]; + /* True if the sender truncated `links` to fit the pool. */ + bool truncated; +} meshtastic_Route; + +/* 9-line MEDEVAC request (CoT type b-r-f-h-c). + + Mirrors the ATAK MedLine tool's <_medevac_> detail element. Every field + is optional (proto3 default); senders omit lines they don't have. The + envelope (TAKPacketV2.uid, cot_type_id=b-r-f-h-c, latitude_i/longitude_i, + altitude, callsign) carries Line 1 (location) and Line 2 (callsign). + + All numeric fields are tight varints so a complete 9-line request fits + in well under 100 bytes of proto on the wire. */ +typedef struct _meshtastic_CasevacReport { + /* Line 3: precedence / urgency. */ + meshtastic_CasevacReport_Precedence precedence; + /* Line 4: special equipment required, as a bitfield. + bit 0: none + bit 1: hoist + bit 2: extraction equipment + bit 3: ventilator + bit 4: blood */ + uint8_t equipment_flags; + /* Line 5: number of litter (stretcher-bound) patients. */ + uint8_t litter_patients; + /* Line 5: number of ambulatory (walking-wounded) patients. */ + uint8_t ambulatory_patients; + /* Line 6: security situation at the PZ. */ + meshtastic_CasevacReport_Security security; + /* Line 7: HLZ marking method. */ + meshtastic_CasevacReport_HlzMarking hlz_marking; + /* Line 7 supplementary: short free-text describing the zone marker + (e.g. "Green smoke", "VS-17 panel west"). Capped tight in options. */ + char zone_marker[16]; + /* --- Line 8: patient nationality counts --- */ + uint8_t us_military; + uint8_t us_civilian; + uint8_t non_us_military; + uint8_t non_us_civilian; + uint8_t epw; /* enemy prisoner of war */ + uint8_t child; + /* Line 9: terrain and obstacles at the PZ, as a bitfield. + bit 0: slope + bit 1: rough + bit 2: loose + bit 3: trees + bit 4: wires + bit 5: other */ + uint8_t terrain_flags; + /* Line 2: radio frequency / callsign metadata (e.g. "38.90 Mhz" or + "Victor 6"). Capped tight in options. */ + char frequency[16]; + /* Short title / MEDEVAC identifier (e.g. "EAGLE.15.181230"). Usually the + same as the envelope callsign but ATAK sometimes carries a distinct + ops-number here. */ + pb_callback_t title; + /* Primary medline free-text — the single most clinically important line + on a MEDLINE form (e.g. "2 urgent litter patients, smoke on approach"). + MUST be preserved under MTU pressure as long as any casevac is sent. */ + pb_callback_t medline_remarks; + /* Line 3 (newer ATAK format): patient counts by precedence level. + Coexists with the enum-style `precedence` field (tag 1) — older ATAK + emits a single enum, newer ATAK emits these counts, and both can be + set simultaneously. Senders populate whichever style(s) the source + XML had; receivers prefer counts when non-zero. */ + uint32_t urgent_count; + uint32_t urgent_surgical_count; + uint32_t priority_count; + uint32_t routine_count; + uint32_t convenience_count; + /* Line 4 supplementary: free-text description of non-standard equipment + (e.g. "Blood warmer"). Pairs with the `equipment_flags` bitfield. */ + pb_callback_t equipment_detail; + /* Line 1 override: MGRS grid when distinct from the event anchor point + (e.g. "34T CQ 12345 67890"). Event lat/lon/hae still carries the + numeric location; this field preserves the exact MGRS string the + medic entered. */ + pb_callback_t zone_protected_coord; + /* Line 9 supplementary: slope direction (e.g. "N", "NE", "SSW") when + `terrain_flags` bit 0 (slope) is set. */ + pb_callback_t terrain_slope_dir; + /* Line 9 supplementary: free-text description of "other" terrain hazards + (e.g. "Loose debris on west edge") when `terrain_flags` bit 5 (other) + is set. Tier-2 strippable under MTU pressure. */ + pb_callback_t terrain_other_detail; + /* Line 7 supplementary: how the zone is being marked right now + (e.g. "Orange smoke", "VS-17 panel"). Complements the structured + `hlz_marking` enum with a specific human-readable description. */ + pb_callback_t marked_by; + /* Nearby obstacles on the approach (e.g. "Power lines north of HLZ"). */ + pb_callback_t obstacles; + /* Wind direction and speed (e.g. "270 at 12 kts"). */ + pb_callback_t winds_are_from; + /* Friendly forces posture near the pickup zone + (e.g. "Squad east of HLZ"). */ + pb_callback_t friendlies; + /* Known or suspected enemy positions near the pickup zone + (e.g. "Possible enemy on south ridge"). */ + pb_callback_t enemy; + /* Free-text description of the HLZ itself + (e.g. "Primary HLZ is soccer field"). */ + pb_callback_t hlz_remarks; + /* Per-patient clinical records. Each entry is one patient's ZMIST card + (Zap number / Mechanism / Injuries / Signs / Treatment). Repeatable — + a mass-casualty event can carry 1-6 entries in practice, limited by + the 237 B LoRa MTU. */ + pb_callback_t zmist; +} meshtastic_CasevacReport; + +/* Per-patient clinical summary record — one entry per patient in a CASEVAC. + Maps directly to ATAK's child element inside . + All fields are optional free-text; senders populate what they have. */ +typedef struct _meshtastic_ZMistEntry { + /* Patient identifier / sequence label (e.g. "ZMIST-1", "ZMIST-2"). */ + pb_callback_t title; + /* Zap number — unique patient tracking ID (often a terse code like + "Gunshot" or a serial). */ + pb_callback_t z; + /* Mechanism of injury (e.g. "Penetrating trauma", "Blast injury"). */ + pb_callback_t m; + /* Injuries observed (e.g. "Left thigh", "Concussion"). */ + pb_callback_t i; + /* Signs / vital stats (e.g. "Stable", "Priority", "BP 110/70"). */ + pb_callback_t s; + /* Treatment given (e.g. "Tourniquet 1810Z", "O2 administered"). */ + pb_callback_t t; +} meshtastic_ZMistEntry; + +/* Emergency alert / 911 beacon (CoT types b-a-o-tbl, b-a-o-pan, b-a-o-opn, + b-a-o-can, b-a-o-c, b-a-g). + + Small, high-priority structured record. The CoT type string is still set + on cot_type_id so receivers that ignore payload_variant can still display + the alert from the enum alone; the typed fields let modern receivers show + the authoring unit and handle cancel-referencing without XML parsing. */ +typedef struct _meshtastic_EmergencyAlert { + /* Alert discriminator. */ + meshtastic_EmergencyAlert_Type type; + /* UID of the unit that raised the alert. Often the same as + TAKPacketV2.uid but can be a parent device uid when a tracker raises + an alert on behalf of a dismount. */ + char authoring_uid[48]; + /* For Type_Cancel: the uid of the alert being cancelled. Empty for + non-cancel alert types. */ + char cancel_reference_uid[48]; +} meshtastic_EmergencyAlert; + +/* Task / engage request (CoT type t-s). + + Mirrors ATAK's TaskCotReceiver / CotTaskBuilder workflow. The envelope + carries the task's originating uid (implicit requester), position, and + creation time; the fields below carry structured metadata the raw-detail + fallback currently loses. + + Fields are deliberately lean — this variant is closer to the MTU ceiling + than the others, so every string is capped in options. */ +typedef struct _meshtastic_TaskRequest { + /* Short tag for the task category (e.g. "engage", "observe", "recon", + "rescue"). Free text on the wire so ATAK-specific task taxonomies + don't need proto coordination; capped tight in options. */ + char task_type[12]; + /* UID of the target / map item being tasked. */ + char target_uid[32]; + /* UID of the assigned unit. Empty = unassigned / broadcast task. */ + char assignee_uid[32]; + meshtastic_TaskRequest_Priority priority; + meshtastic_TaskRequest_Status status; + /* Optional short note (reason, constraints, grid reference). Capped + tight in options to keep the worst-case under the LoRa MTU. */ + char note[48]; +} meshtastic_TaskRequest; + +/* Weather annotation from CoT detail element. + + Attaches to any TAKPacketV2 regardless of payload_variant — an Aircraft, + PLI, or Marker can all carry observed conditions at the emitting station. + ATAK-CIV ships an XSD for but no dedicated handler, so the + element round-trips through the generic detail pipeline; this message + promotes it to a first-class structured field. + + Target wire cost: ~6-8 bytes compressed with a fully populated instance. + + Named `TAKEnvironment` (not just `Environment`) because the bare name + collides with `SwiftUI.Environment` — every SwiftUI view in a consuming + iOS app uses the `@Environment` property wrapper, and importing the + generated proto module would make `Environment` ambiguous in every one + of those files. The `TAK` prefix matches the convention used by the + outer `TAKPacketV2` wrapper and is unambiguous across all target + languages (Swift, Kotlin, Python, TypeScript, C#). */ +typedef struct _meshtastic_TAKEnvironment { + /* Temperature in deci-degrees Celsius. 225 = 22.5°C. + Range covers -50°C to +50°C (-500 to +500) which spans every realistic + outdoor TAK deployment. sint32 because negative temps are common in + cold-weather ops. */ + int32_t temperature_c_x10; + /* Wind direction in whole degrees, 0-359. "Direction FROM" per + meteorological convention (matches CoT / ATAK). */ + uint32_t wind_direction_deg; + /* Wind speed in cm/s. Matches the unit of TAKPacketV2.speed for + consistency. 1200 = 12.00 m/s = ~27 mph. */ + uint32_t wind_speed_cm_s; +} meshtastic_TAKEnvironment; + +/* Sensor field-of-view cone from CoT detail element. + + Encodes the 8 geometry attributes that ATAK-CIV's SensorDetailHandler + reads from the wire; drops the 9 visual-styling attributes that are + receiver-side render hints (fovAlpha, fovRed/Green/Blue, strokeColor, + strokeWeight, displayMagneticReference, hideFov, fovLabels, rangeLines). + The receiving ATAK client restores those from its own defaults, same as + every other CoT carried over Meshtastic today. + + Attaches to any TAKPacketV2 — a PLI with a sensor on the operator's head, + an Aircraft with a FLIR turret, a Marker dropped on a UAV. + Target wire cost: ~7-14 bytes compressed (dominated by model string). */ +typedef struct _meshtastic_SensorFov { + meshtastic_SensorFov_SensorType type; + /* Azimuth in whole degrees, 0-359. "Pointing direction" of the cone axis, + measured clockwise from true north. Whole degrees match ATAK-CIV's + SensorDetailHandler default (270°) and save varint bytes over centi-deg. */ + uint32_t azimuth_deg; + /* Maximum range of the cone in meters. + Optional — if unset, receivers should use the ATAK-CIV default of 100m. */ + bool has_range_m; + uint32_t range_m; + /* Horizontal field of view in whole degrees (cone's angular width). + ATAK-CIV default is 45°. */ + uint32_t fov_horizontal_deg; + /* Vertical field of view in whole degrees. ATAK-CIV default is 45°. + Optional — a value of 0 means "not set / use horizontal FOV". */ + uint32_t fov_vertical_deg; + /* Elevation angle in whole degrees. Positive = up, negative = down. + Range -90 to +90. sint32 for varint efficiency on small negatives. */ + int32_t elevation_deg; + /* Roll (camera tilt) in whole degrees, -180 to +180. + Optional — use 0 if the sensor doesn't track roll. */ + int32_t roll_deg; + /* Free-form device model identifier, e.g. "FLIR-Boson-640", "SEEK". + Optional — empty string means "unknown model" (ATAK-CIV default). */ + pb_callback_t model; +} meshtastic_SensorFov; + typedef PB_BYTES_ARRAY_T(220) meshtastic_TAKPacketV2_raw_detail_t; /* ATAK v2 packet with expanded CoT field support and zstd dictionary compression. Sent on ATAK_PLUGIN_V2 port. The wire payload is: @@ -413,6 +1121,20 @@ typedef struct _meshtastic_TAKPacketV2 { char phone[20]; /* CoT event type string, only populated when cot_type_id is CotType_Other */ char cot_type_str[32]; + /* Optional remarks / free-text annotation from the element. + Populated for non-GeoChat payload types (shapes, markers, routes, etc.) + when the original CoT event carried non-empty remarks text. + GeoChat messages carry their text in GeoChat.message instead. + Empty string (proto3 default) means no remarks were present. */ + pb_callback_t remarks; + /* Observed weather conditions (temperature, wind). From . + Type is `TAKEnvironment`, not `Environment`, to avoid colliding with + SwiftUI's `@Environment` property wrapper in iOS consumers. */ + bool has_environment; + meshtastic_TAKEnvironment environment; + /* Sensor field-of-view cone (camera, FLIR, laser, etc.). From . */ + bool has_sensor_fov; + meshtastic_SensorFov sensor_fov; pb_size_t which_payload_variant; union { /* Position report (true = PLI, no extra fields beyond the common ones above) */ @@ -421,8 +1143,26 @@ typedef struct _meshtastic_TAKPacketV2 { meshtastic_GeoChat chat; /* Aircraft track data (ADS-B, military air) */ meshtastic_AircraftTrack aircraft; - /* Generic CoT detail XML for unmapped types */ + /* Generic CoT detail XML for unmapped types. Kept as a fallback for CoT + types not yet promoted to a typed variant; drawings, markers, ranging + tools, and routes have dedicated variants below and should not land here. */ meshtastic_TAKPacketV2_raw_detail_t raw_detail; + /* User-drawn tactical graphic: circle, rectangle, polygon, polyline, + telestration, ranging circle, or bullseye. See DrawnShape. */ + meshtastic_DrawnShape shape; + /* Fixed point of interest: spot marker, waypoint, checkpoint, 2525 + symbol, or custom icon. See Marker. */ + meshtastic_Marker marker; + /* Range and bearing measurement line. See RangeAndBearing. */ + meshtastic_RangeAndBearing rab; + /* Named route with ordered waypoints and control points. See Route. */ + meshtastic_Route route; + /* 9-line MEDEVAC request. See CasevacReport. */ + meshtastic_CasevacReport casevac; + /* Emergency beacon / 911 alert. See EmergencyAlert. */ + meshtastic_EmergencyAlert emergency; + /* Task / engage request. See TaskRequest. */ + meshtastic_TaskRequest task; } payload_variant; } meshtastic_TAKPacketV2; @@ -445,14 +1185,67 @@ extern "C" { #define _meshtastic_CotHow_ARRAYSIZE ((meshtastic_CotHow)(meshtastic_CotHow_CotHow_m_s+1)) #define _meshtastic_CotType_MIN meshtastic_CotType_CotType_Other -#define _meshtastic_CotType_MAX meshtastic_CotType_CotType_b_f_t_a -#define _meshtastic_CotType_ARRAYSIZE ((meshtastic_CotType)(meshtastic_CotType_CotType_b_f_t_a+1)) +#define _meshtastic_CotType_MAX meshtastic_CotType_CotType_t_s +#define _meshtastic_CotType_ARRAYSIZE ((meshtastic_CotType)(meshtastic_CotType_CotType_t_s+1)) #define _meshtastic_GeoPointSource_MIN meshtastic_GeoPointSource_GeoPointSource_Unspecified #define _meshtastic_GeoPointSource_MAX meshtastic_GeoPointSource_GeoPointSource_NETWORK #define _meshtastic_GeoPointSource_ARRAYSIZE ((meshtastic_GeoPointSource)(meshtastic_GeoPointSource_GeoPointSource_NETWORK+1)) +#define _meshtastic_GeoChat_ReceiptType_MIN meshtastic_GeoChat_ReceiptType_ReceiptType_None +#define _meshtastic_GeoChat_ReceiptType_MAX meshtastic_GeoChat_ReceiptType_ReceiptType_Read +#define _meshtastic_GeoChat_ReceiptType_ARRAYSIZE ((meshtastic_GeoChat_ReceiptType)(meshtastic_GeoChat_ReceiptType_ReceiptType_Read+1)) +#define _meshtastic_DrawnShape_Kind_MIN meshtastic_DrawnShape_Kind_Kind_Unspecified +#define _meshtastic_DrawnShape_Kind_MAX meshtastic_DrawnShape_Kind_Kind_Vehicle3D +#define _meshtastic_DrawnShape_Kind_ARRAYSIZE ((meshtastic_DrawnShape_Kind)(meshtastic_DrawnShape_Kind_Kind_Vehicle3D+1)) + +#define _meshtastic_DrawnShape_StyleMode_MIN meshtastic_DrawnShape_StyleMode_StyleMode_Unspecified +#define _meshtastic_DrawnShape_StyleMode_MAX meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill +#define _meshtastic_DrawnShape_StyleMode_ARRAYSIZE ((meshtastic_DrawnShape_StyleMode)(meshtastic_DrawnShape_StyleMode_StyleMode_StrokeAndFill+1)) + +#define _meshtastic_Marker_Kind_MIN meshtastic_Marker_Kind_Kind_Unspecified +#define _meshtastic_Marker_Kind_MAX meshtastic_Marker_Kind_Kind_ImageMarker +#define _meshtastic_Marker_Kind_ARRAYSIZE ((meshtastic_Marker_Kind)(meshtastic_Marker_Kind_Kind_ImageMarker+1)) + +#define _meshtastic_Route_Method_MIN meshtastic_Route_Method_Method_Unspecified +#define _meshtastic_Route_Method_MAX meshtastic_Route_Method_Method_Watercraft +#define _meshtastic_Route_Method_ARRAYSIZE ((meshtastic_Route_Method)(meshtastic_Route_Method_Method_Watercraft+1)) + +#define _meshtastic_Route_Direction_MIN meshtastic_Route_Direction_Direction_Unspecified +#define _meshtastic_Route_Direction_MAX meshtastic_Route_Direction_Direction_Exfil +#define _meshtastic_Route_Direction_ARRAYSIZE ((meshtastic_Route_Direction)(meshtastic_Route_Direction_Direction_Exfil+1)) + +#define _meshtastic_CasevacReport_Precedence_MIN meshtastic_CasevacReport_Precedence_Precedence_Unspecified +#define _meshtastic_CasevacReport_Precedence_MAX meshtastic_CasevacReport_Precedence_Precedence_Convenience +#define _meshtastic_CasevacReport_Precedence_ARRAYSIZE ((meshtastic_CasevacReport_Precedence)(meshtastic_CasevacReport_Precedence_Precedence_Convenience+1)) + +#define _meshtastic_CasevacReport_HlzMarking_MIN meshtastic_CasevacReport_HlzMarking_HlzMarking_Unspecified +#define _meshtastic_CasevacReport_HlzMarking_MAX meshtastic_CasevacReport_HlzMarking_HlzMarking_Other +#define _meshtastic_CasevacReport_HlzMarking_ARRAYSIZE ((meshtastic_CasevacReport_HlzMarking)(meshtastic_CasevacReport_HlzMarking_HlzMarking_Other+1)) + +#define _meshtastic_CasevacReport_Security_MIN meshtastic_CasevacReport_Security_Security_Unspecified +#define _meshtastic_CasevacReport_Security_MAX meshtastic_CasevacReport_Security_Security_EnemyInArmedContact +#define _meshtastic_CasevacReport_Security_ARRAYSIZE ((meshtastic_CasevacReport_Security)(meshtastic_CasevacReport_Security_Security_EnemyInArmedContact+1)) + +#define _meshtastic_EmergencyAlert_Type_MIN meshtastic_EmergencyAlert_Type_Type_Unspecified +#define _meshtastic_EmergencyAlert_Type_MAX meshtastic_EmergencyAlert_Type_Type_Cancel +#define _meshtastic_EmergencyAlert_Type_ARRAYSIZE ((meshtastic_EmergencyAlert_Type)(meshtastic_EmergencyAlert_Type_Type_Cancel+1)) + +#define _meshtastic_TaskRequest_Priority_MIN meshtastic_TaskRequest_Priority_Priority_Unspecified +#define _meshtastic_TaskRequest_Priority_MAX meshtastic_TaskRequest_Priority_Priority_Critical +#define _meshtastic_TaskRequest_Priority_ARRAYSIZE ((meshtastic_TaskRequest_Priority)(meshtastic_TaskRequest_Priority_Priority_Critical+1)) + +#define _meshtastic_TaskRequest_Status_MIN meshtastic_TaskRequest_Status_Status_Unspecified +#define _meshtastic_TaskRequest_Status_MAX meshtastic_TaskRequest_Status_Status_Cancelled +#define _meshtastic_TaskRequest_Status_ARRAYSIZE ((meshtastic_TaskRequest_Status)(meshtastic_TaskRequest_Status_Status_Cancelled+1)) + +#define _meshtastic_SensorFov_SensorType_MIN meshtastic_SensorFov_SensorType_SensorType_Unspecified +#define _meshtastic_SensorFov_SensorType_MAX meshtastic_SensorFov_SensorType_SensorType_Other +#define _meshtastic_SensorFov_SensorType_ARRAYSIZE ((meshtastic_SensorFov_SensorType)(meshtastic_SensorFov_SensorType_SensorType_Other+1)) + + +#define meshtastic_GeoChat_receipt_type_ENUMTYPE meshtastic_GeoChat_ReceiptType #define meshtastic_Group_role_ENUMTYPE meshtastic_MemberRole #define meshtastic_Group_team_ENUMTYPE meshtastic_Team @@ -461,6 +1254,34 @@ extern "C" { + +#define meshtastic_DrawnShape_kind_ENUMTYPE meshtastic_DrawnShape_Kind +#define meshtastic_DrawnShape_style_ENUMTYPE meshtastic_DrawnShape_StyleMode +#define meshtastic_DrawnShape_stroke_color_ENUMTYPE meshtastic_Team +#define meshtastic_DrawnShape_fill_color_ENUMTYPE meshtastic_Team + +#define meshtastic_Marker_kind_ENUMTYPE meshtastic_Marker_Kind +#define meshtastic_Marker_color_ENUMTYPE meshtastic_Team + +#define meshtastic_RangeAndBearing_stroke_color_ENUMTYPE meshtastic_Team + +#define meshtastic_Route_method_ENUMTYPE meshtastic_Route_Method +#define meshtastic_Route_direction_ENUMTYPE meshtastic_Route_Direction + + +#define meshtastic_CasevacReport_precedence_ENUMTYPE meshtastic_CasevacReport_Precedence +#define meshtastic_CasevacReport_security_ENUMTYPE meshtastic_CasevacReport_Security +#define meshtastic_CasevacReport_hlz_marking_ENUMTYPE meshtastic_CasevacReport_HlzMarking + + +#define meshtastic_EmergencyAlert_type_ENUMTYPE meshtastic_EmergencyAlert_Type + +#define meshtastic_TaskRequest_priority_ENUMTYPE meshtastic_TaskRequest_Priority +#define meshtastic_TaskRequest_status_ENUMTYPE meshtastic_TaskRequest_Status + + +#define meshtastic_SensorFov_type_ENUMTYPE meshtastic_SensorFov_SensorType + #define meshtastic_TAKPacketV2_cot_type_id_ENUMTYPE meshtastic_CotType #define meshtastic_TAKPacketV2_how_ENUMTYPE meshtastic_CotHow #define meshtastic_TAKPacketV2_team_ENUMTYPE meshtastic_Team @@ -471,26 +1292,52 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_TAKPacket_init_default {0, false, meshtastic_Contact_init_default, false, meshtastic_Group_init_default, false, meshtastic_Status_init_default, 0, {meshtastic_PLI_init_default}} -#define meshtastic_GeoChat_init_default {"", false, "", false, ""} +#define meshtastic_GeoChat_init_default {"", false, "", false, "", "", _meshtastic_GeoChat_ReceiptType_MIN} #define meshtastic_Group_init_default {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_default {0} #define meshtastic_Contact_init_default {"", ""} #define meshtastic_PLI_init_default {0, 0, 0, 0, 0} #define meshtastic_AircraftTrack_init_default {"", "", "", "", 0, "", 0, 0, ""} -#define meshtastic_TAKPacketV2_init_default {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", 0, {0}} +#define meshtastic_CotGeoPoint_init_default {0, 0} +#define meshtastic_DrawnShape_init_default {_meshtastic_DrawnShape_Kind_MIN, _meshtastic_DrawnShape_StyleMode_MIN, 0, 0, 0, _meshtastic_Team_MIN, 0, 0, _meshtastic_Team_MIN, 0, 0, 0, {meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default, meshtastic_CotGeoPoint_init_default}, 0, 0, 0, 0, ""} +#define meshtastic_Marker_init_default {_meshtastic_Marker_Kind_MIN, _meshtastic_Team_MIN, 0, 0, "", "", "", ""} +#define meshtastic_RangeAndBearing_init_default {false, meshtastic_CotGeoPoint_init_default, "", 0, 0, _meshtastic_Team_MIN, 0, 0} +#define meshtastic_Route_init_default {_meshtastic_Route_Method_MIN, _meshtastic_Route_Direction_MIN, "", 0, 0, {meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default, meshtastic_Route_Link_init_default}, 0} +#define meshtastic_Route_Link_init_default {false, meshtastic_CotGeoPoint_init_default, "", "", 0} +#define meshtastic_CasevacReport_init_default {_meshtastic_CasevacReport_Precedence_MIN, 0, 0, 0, _meshtastic_CasevacReport_Security_MIN, _meshtastic_CasevacReport_HlzMarking_MIN, "", 0, 0, 0, 0, 0, 0, 0, "", {{NULL}, NULL}, {{NULL}, NULL}, 0, 0, 0, 0, 0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define meshtastic_ZMistEntry_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define meshtastic_EmergencyAlert_init_default {_meshtastic_EmergencyAlert_Type_MIN, "", ""} +#define meshtastic_TaskRequest_init_default {"", "", "", _meshtastic_TaskRequest_Priority_MIN, _meshtastic_TaskRequest_Status_MIN, ""} +#define meshtastic_TAKEnvironment_init_default {0, 0, 0} +#define meshtastic_SensorFov_init_default {_meshtastic_SensorFov_SensorType_MIN, 0, false, 0, 0, 0, 0, 0, {{NULL}, NULL}} +#define meshtastic_TAKPacketV2_init_default {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", {{NULL}, NULL}, false, meshtastic_TAKEnvironment_init_default, false, meshtastic_SensorFov_init_default, 0, {0}} #define meshtastic_TAKPacket_init_zero {0, false, meshtastic_Contact_init_zero, false, meshtastic_Group_init_zero, false, meshtastic_Status_init_zero, 0, {meshtastic_PLI_init_zero}} -#define meshtastic_GeoChat_init_zero {"", false, "", false, ""} +#define meshtastic_GeoChat_init_zero {"", false, "", false, "", "", _meshtastic_GeoChat_ReceiptType_MIN} #define meshtastic_Group_init_zero {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_zero {0} #define meshtastic_Contact_init_zero {"", ""} #define meshtastic_PLI_init_zero {0, 0, 0, 0, 0} #define meshtastic_AircraftTrack_init_zero {"", "", "", "", 0, "", 0, 0, ""} -#define meshtastic_TAKPacketV2_init_zero {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", 0, {0}} +#define meshtastic_CotGeoPoint_init_zero {0, 0} +#define meshtastic_DrawnShape_init_zero {_meshtastic_DrawnShape_Kind_MIN, _meshtastic_DrawnShape_StyleMode_MIN, 0, 0, 0, _meshtastic_Team_MIN, 0, 0, _meshtastic_Team_MIN, 0, 0, 0, {meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero, meshtastic_CotGeoPoint_init_zero}, 0, 0, 0, 0, ""} +#define meshtastic_Marker_init_zero {_meshtastic_Marker_Kind_MIN, _meshtastic_Team_MIN, 0, 0, "", "", "", ""} +#define meshtastic_RangeAndBearing_init_zero {false, meshtastic_CotGeoPoint_init_zero, "", 0, 0, _meshtastic_Team_MIN, 0, 0} +#define meshtastic_Route_init_zero {_meshtastic_Route_Method_MIN, _meshtastic_Route_Direction_MIN, "", 0, 0, {meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero, meshtastic_Route_Link_init_zero}, 0} +#define meshtastic_Route_Link_init_zero {false, meshtastic_CotGeoPoint_init_zero, "", "", 0} +#define meshtastic_CasevacReport_init_zero {_meshtastic_CasevacReport_Precedence_MIN, 0, 0, 0, _meshtastic_CasevacReport_Security_MIN, _meshtastic_CasevacReport_HlzMarking_MIN, "", 0, 0, 0, 0, 0, 0, 0, "", {{NULL}, NULL}, {{NULL}, NULL}, 0, 0, 0, 0, 0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define meshtastic_ZMistEntry_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}} +#define meshtastic_EmergencyAlert_init_zero {_meshtastic_EmergencyAlert_Type_MIN, "", ""} +#define meshtastic_TaskRequest_init_zero {"", "", "", _meshtastic_TaskRequest_Priority_MIN, _meshtastic_TaskRequest_Status_MIN, ""} +#define meshtastic_TAKEnvironment_init_zero {0, 0, 0} +#define meshtastic_SensorFov_init_zero {_meshtastic_SensorFov_SensorType_MIN, 0, false, 0, 0, 0, 0, 0, {{NULL}, NULL}} +#define meshtastic_TAKPacketV2_init_zero {_meshtastic_CotType_MIN, _meshtastic_CotHow_MIN, "", _meshtastic_Team_MIN, _meshtastic_MemberRole_MIN, 0, 0, 0, 0, 0, 0, _meshtastic_GeoPointSource_MIN, _meshtastic_GeoPointSource_MIN, "", "", 0, "", "", "", "", "", "", "", {{NULL}, NULL}, false, meshtastic_TAKEnvironment_init_zero, false, meshtastic_SensorFov_init_zero, 0, {0}} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_GeoChat_message_tag 1 #define meshtastic_GeoChat_to_tag 2 #define meshtastic_GeoChat_to_callsign_tag 3 +#define meshtastic_GeoChat_receipt_for_uid_tag 4 +#define meshtastic_GeoChat_receipt_type_tag 5 #define meshtastic_Group_role_tag 1 #define meshtastic_Group_team_tag 2 #define meshtastic_Status_battery_tag 1 @@ -517,6 +1364,109 @@ extern "C" { #define meshtastic_AircraftTrack_rssi_x10_tag 7 #define meshtastic_AircraftTrack_gps_tag 8 #define meshtastic_AircraftTrack_cot_host_id_tag 9 +#define meshtastic_CotGeoPoint_lat_delta_i_tag 1 +#define meshtastic_CotGeoPoint_lon_delta_i_tag 2 +#define meshtastic_DrawnShape_kind_tag 1 +#define meshtastic_DrawnShape_style_tag 2 +#define meshtastic_DrawnShape_major_cm_tag 3 +#define meshtastic_DrawnShape_minor_cm_tag 4 +#define meshtastic_DrawnShape_angle_deg_tag 5 +#define meshtastic_DrawnShape_stroke_color_tag 6 +#define meshtastic_DrawnShape_stroke_argb_tag 7 +#define meshtastic_DrawnShape_stroke_weight_x10_tag 8 +#define meshtastic_DrawnShape_fill_color_tag 9 +#define meshtastic_DrawnShape_fill_argb_tag 10 +#define meshtastic_DrawnShape_labels_on_tag 11 +#define meshtastic_DrawnShape_vertices_tag 12 +#define meshtastic_DrawnShape_truncated_tag 13 +#define meshtastic_DrawnShape_bullseye_distance_dm_tag 14 +#define meshtastic_DrawnShape_bullseye_bearing_ref_tag 15 +#define meshtastic_DrawnShape_bullseye_flags_tag 16 +#define meshtastic_DrawnShape_bullseye_uid_ref_tag 17 +#define meshtastic_Marker_kind_tag 1 +#define meshtastic_Marker_color_tag 2 +#define meshtastic_Marker_color_argb_tag 3 +#define meshtastic_Marker_readiness_tag 4 +#define meshtastic_Marker_parent_uid_tag 5 +#define meshtastic_Marker_parent_type_tag 6 +#define meshtastic_Marker_parent_callsign_tag 7 +#define meshtastic_Marker_iconset_tag 8 +#define meshtastic_RangeAndBearing_anchor_tag 1 +#define meshtastic_RangeAndBearing_anchor_uid_tag 2 +#define meshtastic_RangeAndBearing_range_cm_tag 3 +#define meshtastic_RangeAndBearing_bearing_cdeg_tag 4 +#define meshtastic_RangeAndBearing_stroke_color_tag 5 +#define meshtastic_RangeAndBearing_stroke_argb_tag 6 +#define meshtastic_RangeAndBearing_stroke_weight_x10_tag 7 +#define meshtastic_Route_Link_point_tag 1 +#define meshtastic_Route_Link_uid_tag 2 +#define meshtastic_Route_Link_callsign_tag 3 +#define meshtastic_Route_Link_link_type_tag 4 +#define meshtastic_Route_method_tag 1 +#define meshtastic_Route_direction_tag 2 +#define meshtastic_Route_prefix_tag 3 +#define meshtastic_Route_stroke_weight_x10_tag 4 +#define meshtastic_Route_links_tag 5 +#define meshtastic_Route_truncated_tag 6 +#define meshtastic_CasevacReport_precedence_tag 1 +#define meshtastic_CasevacReport_equipment_flags_tag 2 +#define meshtastic_CasevacReport_litter_patients_tag 3 +#define meshtastic_CasevacReport_ambulatory_patients_tag 4 +#define meshtastic_CasevacReport_security_tag 5 +#define meshtastic_CasevacReport_hlz_marking_tag 6 +#define meshtastic_CasevacReport_zone_marker_tag 7 +#define meshtastic_CasevacReport_us_military_tag 8 +#define meshtastic_CasevacReport_us_civilian_tag 9 +#define meshtastic_CasevacReport_non_us_military_tag 10 +#define meshtastic_CasevacReport_non_us_civilian_tag 11 +#define meshtastic_CasevacReport_epw_tag 12 +#define meshtastic_CasevacReport_child_tag 13 +#define meshtastic_CasevacReport_terrain_flags_tag 14 +#define meshtastic_CasevacReport_frequency_tag 15 +#define meshtastic_CasevacReport_title_tag 16 +#define meshtastic_CasevacReport_medline_remarks_tag 17 +#define meshtastic_CasevacReport_urgent_count_tag 18 +#define meshtastic_CasevacReport_urgent_surgical_count_tag 19 +#define meshtastic_CasevacReport_priority_count_tag 20 +#define meshtastic_CasevacReport_routine_count_tag 21 +#define meshtastic_CasevacReport_convenience_count_tag 22 +#define meshtastic_CasevacReport_equipment_detail_tag 23 +#define meshtastic_CasevacReport_zone_protected_coord_tag 24 +#define meshtastic_CasevacReport_terrain_slope_dir_tag 25 +#define meshtastic_CasevacReport_terrain_other_detail_tag 26 +#define meshtastic_CasevacReport_marked_by_tag 27 +#define meshtastic_CasevacReport_obstacles_tag 28 +#define meshtastic_CasevacReport_winds_are_from_tag 29 +#define meshtastic_CasevacReport_friendlies_tag 30 +#define meshtastic_CasevacReport_enemy_tag 31 +#define meshtastic_CasevacReport_hlz_remarks_tag 32 +#define meshtastic_CasevacReport_zmist_tag 33 +#define meshtastic_ZMistEntry_title_tag 1 +#define meshtastic_ZMistEntry_z_tag 2 +#define meshtastic_ZMistEntry_m_tag 3 +#define meshtastic_ZMistEntry_i_tag 4 +#define meshtastic_ZMistEntry_s_tag 5 +#define meshtastic_ZMistEntry_t_tag 6 +#define meshtastic_EmergencyAlert_type_tag 1 +#define meshtastic_EmergencyAlert_authoring_uid_tag 2 +#define meshtastic_EmergencyAlert_cancel_reference_uid_tag 3 +#define meshtastic_TaskRequest_task_type_tag 1 +#define meshtastic_TaskRequest_target_uid_tag 2 +#define meshtastic_TaskRequest_assignee_uid_tag 3 +#define meshtastic_TaskRequest_priority_tag 4 +#define meshtastic_TaskRequest_status_tag 5 +#define meshtastic_TaskRequest_note_tag 6 +#define meshtastic_TAKEnvironment_temperature_c_x10_tag 1 +#define meshtastic_TAKEnvironment_wind_direction_deg_tag 2 +#define meshtastic_TAKEnvironment_wind_speed_cm_s_tag 3 +#define meshtastic_SensorFov_type_tag 1 +#define meshtastic_SensorFov_azimuth_deg_tag 2 +#define meshtastic_SensorFov_range_m_tag 3 +#define meshtastic_SensorFov_fov_horizontal_deg_tag 4 +#define meshtastic_SensorFov_fov_vertical_deg_tag 5 +#define meshtastic_SensorFov_elevation_deg_tag 6 +#define meshtastic_SensorFov_roll_deg_tag 7 +#define meshtastic_SensorFov_model_tag 8 #define meshtastic_TAKPacketV2_cot_type_id_tag 1 #define meshtastic_TAKPacketV2_how_tag 2 #define meshtastic_TAKPacketV2_callsign_tag 3 @@ -540,10 +1490,20 @@ extern "C" { #define meshtastic_TAKPacketV2_endpoint_tag 21 #define meshtastic_TAKPacketV2_phone_tag 22 #define meshtastic_TAKPacketV2_cot_type_str_tag 23 +#define meshtastic_TAKPacketV2_remarks_tag 24 +#define meshtastic_TAKPacketV2_environment_tag 25 +#define meshtastic_TAKPacketV2_sensor_fov_tag 26 #define meshtastic_TAKPacketV2_pli_tag 30 #define meshtastic_TAKPacketV2_chat_tag 31 #define meshtastic_TAKPacketV2_aircraft_tag 32 #define meshtastic_TAKPacketV2_raw_detail_tag 33 +#define meshtastic_TAKPacketV2_shape_tag 34 +#define meshtastic_TAKPacketV2_marker_tag 35 +#define meshtastic_TAKPacketV2_rab_tag 36 +#define meshtastic_TAKPacketV2_route_tag 37 +#define meshtastic_TAKPacketV2_casevac_tag 38 +#define meshtastic_TAKPacketV2_emergency_tag 39 +#define meshtastic_TAKPacketV2_task_tag 40 /* Struct field encoding specification for nanopb */ #define meshtastic_TAKPacket_FIELDLIST(X, a) \ @@ -565,7 +1525,9 @@ X(a, STATIC, ONEOF, BYTES, (payload_variant,detail,payload_variant.detai #define meshtastic_GeoChat_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, message, 1) \ X(a, STATIC, OPTIONAL, STRING, to, 2) \ -X(a, STATIC, OPTIONAL, STRING, to_callsign, 3) +X(a, STATIC, OPTIONAL, STRING, to_callsign, 3) \ +X(a, STATIC, SINGULAR, STRING, receipt_for_uid, 4) \ +X(a, STATIC, SINGULAR, UENUM, receipt_type, 5) #define meshtastic_GeoChat_CALLBACK NULL #define meshtastic_GeoChat_DEFAULT NULL @@ -608,6 +1570,162 @@ X(a, STATIC, SINGULAR, STRING, cot_host_id, 9) #define meshtastic_AircraftTrack_CALLBACK NULL #define meshtastic_AircraftTrack_DEFAULT NULL +#define meshtastic_CotGeoPoint_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, SINT32, lat_delta_i, 1) \ +X(a, STATIC, SINGULAR, SINT32, lon_delta_i, 2) +#define meshtastic_CotGeoPoint_CALLBACK NULL +#define meshtastic_CotGeoPoint_DEFAULT NULL + +#define meshtastic_DrawnShape_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, kind, 1) \ +X(a, STATIC, SINGULAR, UENUM, style, 2) \ +X(a, STATIC, SINGULAR, UINT32, major_cm, 3) \ +X(a, STATIC, SINGULAR, UINT32, minor_cm, 4) \ +X(a, STATIC, SINGULAR, UINT32, angle_deg, 5) \ +X(a, STATIC, SINGULAR, UENUM, stroke_color, 6) \ +X(a, STATIC, SINGULAR, FIXED32, stroke_argb, 7) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 8) \ +X(a, STATIC, SINGULAR, UENUM, fill_color, 9) \ +X(a, STATIC, SINGULAR, FIXED32, fill_argb, 10) \ +X(a, STATIC, SINGULAR, BOOL, labels_on, 11) \ +X(a, STATIC, REPEATED, MESSAGE, vertices, 12) \ +X(a, STATIC, SINGULAR, BOOL, truncated, 13) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_distance_dm, 14) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_bearing_ref, 15) \ +X(a, STATIC, SINGULAR, UINT32, bullseye_flags, 16) \ +X(a, STATIC, SINGULAR, STRING, bullseye_uid_ref, 17) +#define meshtastic_DrawnShape_CALLBACK NULL +#define meshtastic_DrawnShape_DEFAULT NULL +#define meshtastic_DrawnShape_vertices_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_Marker_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, kind, 1) \ +X(a, STATIC, SINGULAR, UENUM, color, 2) \ +X(a, STATIC, SINGULAR, FIXED32, color_argb, 3) \ +X(a, STATIC, SINGULAR, BOOL, readiness, 4) \ +X(a, STATIC, SINGULAR, STRING, parent_uid, 5) \ +X(a, STATIC, SINGULAR, STRING, parent_type, 6) \ +X(a, STATIC, SINGULAR, STRING, parent_callsign, 7) \ +X(a, STATIC, SINGULAR, STRING, iconset, 8) +#define meshtastic_Marker_CALLBACK NULL +#define meshtastic_Marker_DEFAULT NULL + +#define meshtastic_RangeAndBearing_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, anchor, 1) \ +X(a, STATIC, SINGULAR, STRING, anchor_uid, 2) \ +X(a, STATIC, SINGULAR, UINT32, range_cm, 3) \ +X(a, STATIC, SINGULAR, UINT32, bearing_cdeg, 4) \ +X(a, STATIC, SINGULAR, UENUM, stroke_color, 5) \ +X(a, STATIC, SINGULAR, FIXED32, stroke_argb, 6) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 7) +#define meshtastic_RangeAndBearing_CALLBACK NULL +#define meshtastic_RangeAndBearing_DEFAULT NULL +#define meshtastic_RangeAndBearing_anchor_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_Route_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, method, 1) \ +X(a, STATIC, SINGULAR, UENUM, direction, 2) \ +X(a, STATIC, SINGULAR, STRING, prefix, 3) \ +X(a, STATIC, SINGULAR, UINT32, stroke_weight_x10, 4) \ +X(a, STATIC, REPEATED, MESSAGE, links, 5) \ +X(a, STATIC, SINGULAR, BOOL, truncated, 6) +#define meshtastic_Route_CALLBACK NULL +#define meshtastic_Route_DEFAULT NULL +#define meshtastic_Route_links_MSGTYPE meshtastic_Route_Link + +#define meshtastic_Route_Link_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, point, 1) \ +X(a, STATIC, SINGULAR, STRING, uid, 2) \ +X(a, STATIC, SINGULAR, STRING, callsign, 3) \ +X(a, STATIC, SINGULAR, UINT32, link_type, 4) +#define meshtastic_Route_Link_CALLBACK NULL +#define meshtastic_Route_Link_DEFAULT NULL +#define meshtastic_Route_Link_point_MSGTYPE meshtastic_CotGeoPoint + +#define meshtastic_CasevacReport_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, precedence, 1) \ +X(a, STATIC, SINGULAR, UINT32, equipment_flags, 2) \ +X(a, STATIC, SINGULAR, UINT32, litter_patients, 3) \ +X(a, STATIC, SINGULAR, UINT32, ambulatory_patients, 4) \ +X(a, STATIC, SINGULAR, UENUM, security, 5) \ +X(a, STATIC, SINGULAR, UENUM, hlz_marking, 6) \ +X(a, STATIC, SINGULAR, STRING, zone_marker, 7) \ +X(a, STATIC, SINGULAR, UINT32, us_military, 8) \ +X(a, STATIC, SINGULAR, UINT32, us_civilian, 9) \ +X(a, STATIC, SINGULAR, UINT32, non_us_military, 10) \ +X(a, STATIC, SINGULAR, UINT32, non_us_civilian, 11) \ +X(a, STATIC, SINGULAR, UINT32, epw, 12) \ +X(a, STATIC, SINGULAR, UINT32, child, 13) \ +X(a, STATIC, SINGULAR, UINT32, terrain_flags, 14) \ +X(a, STATIC, SINGULAR, STRING, frequency, 15) \ +X(a, CALLBACK, SINGULAR, STRING, title, 16) \ +X(a, CALLBACK, SINGULAR, STRING, medline_remarks, 17) \ +X(a, STATIC, SINGULAR, UINT32, urgent_count, 18) \ +X(a, STATIC, SINGULAR, UINT32, urgent_surgical_count, 19) \ +X(a, STATIC, SINGULAR, UINT32, priority_count, 20) \ +X(a, STATIC, SINGULAR, UINT32, routine_count, 21) \ +X(a, STATIC, SINGULAR, UINT32, convenience_count, 22) \ +X(a, CALLBACK, SINGULAR, STRING, equipment_detail, 23) \ +X(a, CALLBACK, SINGULAR, STRING, zone_protected_coord, 24) \ +X(a, CALLBACK, SINGULAR, STRING, terrain_slope_dir, 25) \ +X(a, CALLBACK, SINGULAR, STRING, terrain_other_detail, 26) \ +X(a, CALLBACK, SINGULAR, STRING, marked_by, 27) \ +X(a, CALLBACK, SINGULAR, STRING, obstacles, 28) \ +X(a, CALLBACK, SINGULAR, STRING, winds_are_from, 29) \ +X(a, CALLBACK, SINGULAR, STRING, friendlies, 30) \ +X(a, CALLBACK, SINGULAR, STRING, enemy, 31) \ +X(a, CALLBACK, SINGULAR, STRING, hlz_remarks, 32) \ +X(a, CALLBACK, REPEATED, MESSAGE, zmist, 33) +#define meshtastic_CasevacReport_CALLBACK pb_default_field_callback +#define meshtastic_CasevacReport_DEFAULT NULL +#define meshtastic_CasevacReport_zmist_MSGTYPE meshtastic_ZMistEntry + +#define meshtastic_ZMistEntry_FIELDLIST(X, a) \ +X(a, CALLBACK, SINGULAR, STRING, title, 1) \ +X(a, CALLBACK, SINGULAR, STRING, z, 2) \ +X(a, CALLBACK, SINGULAR, STRING, m, 3) \ +X(a, CALLBACK, SINGULAR, STRING, i, 4) \ +X(a, CALLBACK, SINGULAR, STRING, s, 5) \ +X(a, CALLBACK, SINGULAR, STRING, t, 6) +#define meshtastic_ZMistEntry_CALLBACK pb_default_field_callback +#define meshtastic_ZMistEntry_DEFAULT NULL + +#define meshtastic_EmergencyAlert_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, STRING, authoring_uid, 2) \ +X(a, STATIC, SINGULAR, STRING, cancel_reference_uid, 3) +#define meshtastic_EmergencyAlert_CALLBACK NULL +#define meshtastic_EmergencyAlert_DEFAULT NULL + +#define meshtastic_TaskRequest_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, task_type, 1) \ +X(a, STATIC, SINGULAR, STRING, target_uid, 2) \ +X(a, STATIC, SINGULAR, STRING, assignee_uid, 3) \ +X(a, STATIC, SINGULAR, UENUM, priority, 4) \ +X(a, STATIC, SINGULAR, UENUM, status, 5) \ +X(a, STATIC, SINGULAR, STRING, note, 6) +#define meshtastic_TaskRequest_CALLBACK NULL +#define meshtastic_TaskRequest_DEFAULT NULL + +#define meshtastic_TAKEnvironment_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, SINT32, temperature_c_x10, 1) \ +X(a, STATIC, SINGULAR, UINT32, wind_direction_deg, 2) \ +X(a, STATIC, SINGULAR, UINT32, wind_speed_cm_s, 3) +#define meshtastic_TAKEnvironment_CALLBACK NULL +#define meshtastic_TAKEnvironment_DEFAULT NULL + +#define meshtastic_SensorFov_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, type, 1) \ +X(a, STATIC, SINGULAR, UINT32, azimuth_deg, 2) \ +X(a, STATIC, OPTIONAL, UINT32, range_m, 3) \ +X(a, STATIC, SINGULAR, UINT32, fov_horizontal_deg, 4) \ +X(a, STATIC, SINGULAR, UINT32, fov_vertical_deg, 5) \ +X(a, STATIC, SINGULAR, SINT32, elevation_deg, 6) \ +X(a, STATIC, SINGULAR, SINT32, roll_deg, 7) \ +X(a, CALLBACK, SINGULAR, STRING, model, 8) +#define meshtastic_SensorFov_CALLBACK pb_default_field_callback +#define meshtastic_SensorFov_DEFAULT NULL + #define meshtastic_TAKPacketV2_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, cot_type_id, 1) \ X(a, STATIC, SINGULAR, UENUM, how, 2) \ @@ -632,14 +1750,33 @@ X(a, STATIC, SINGULAR, STRING, tak_os, 20) \ X(a, STATIC, SINGULAR, STRING, endpoint, 21) \ X(a, STATIC, SINGULAR, STRING, phone, 22) \ X(a, STATIC, SINGULAR, STRING, cot_type_str, 23) \ +X(a, CALLBACK, SINGULAR, STRING, remarks, 24) \ +X(a, STATIC, OPTIONAL, MESSAGE, environment, 25) \ +X(a, STATIC, OPTIONAL, MESSAGE, sensor_fov, 26) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,pli,payload_variant.pli), 30) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,chat,payload_variant.chat), 31) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,aircraft,payload_variant.aircraft), 32) \ -X(a, STATIC, ONEOF, BYTES, (payload_variant,raw_detail,payload_variant.raw_detail), 33) -#define meshtastic_TAKPacketV2_CALLBACK NULL +X(a, STATIC, ONEOF, BYTES, (payload_variant,raw_detail,payload_variant.raw_detail), 33) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,shape,payload_variant.shape), 34) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,marker,payload_variant.marker), 35) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,rab,payload_variant.rab), 36) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,route,payload_variant.route), 37) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,casevac,payload_variant.casevac), 38) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,emergency,payload_variant.emergency), 39) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,task,payload_variant.task), 40) +#define meshtastic_TAKPacketV2_CALLBACK pb_default_field_callback #define meshtastic_TAKPacketV2_DEFAULT NULL +#define meshtastic_TAKPacketV2_environment_MSGTYPE meshtastic_TAKEnvironment +#define meshtastic_TAKPacketV2_sensor_fov_MSGTYPE meshtastic_SensorFov #define meshtastic_TAKPacketV2_payload_variant_chat_MSGTYPE meshtastic_GeoChat #define meshtastic_TAKPacketV2_payload_variant_aircraft_MSGTYPE meshtastic_AircraftTrack +#define meshtastic_TAKPacketV2_payload_variant_shape_MSGTYPE meshtastic_DrawnShape +#define meshtastic_TAKPacketV2_payload_variant_marker_MSGTYPE meshtastic_Marker +#define meshtastic_TAKPacketV2_payload_variant_rab_MSGTYPE meshtastic_RangeAndBearing +#define meshtastic_TAKPacketV2_payload_variant_route_MSGTYPE meshtastic_Route +#define meshtastic_TAKPacketV2_payload_variant_casevac_MSGTYPE meshtastic_CasevacReport +#define meshtastic_TAKPacketV2_payload_variant_emergency_MSGTYPE meshtastic_EmergencyAlert +#define meshtastic_TAKPacketV2_payload_variant_task_MSGTYPE meshtastic_TaskRequest extern const pb_msgdesc_t meshtastic_TAKPacket_msg; extern const pb_msgdesc_t meshtastic_GeoChat_msg; @@ -648,6 +1785,18 @@ extern const pb_msgdesc_t meshtastic_Status_msg; extern const pb_msgdesc_t meshtastic_Contact_msg; extern const pb_msgdesc_t meshtastic_PLI_msg; extern const pb_msgdesc_t meshtastic_AircraftTrack_msg; +extern const pb_msgdesc_t meshtastic_CotGeoPoint_msg; +extern const pb_msgdesc_t meshtastic_DrawnShape_msg; +extern const pb_msgdesc_t meshtastic_Marker_msg; +extern const pb_msgdesc_t meshtastic_RangeAndBearing_msg; +extern const pb_msgdesc_t meshtastic_Route_msg; +extern const pb_msgdesc_t meshtastic_Route_Link_msg; +extern const pb_msgdesc_t meshtastic_CasevacReport_msg; +extern const pb_msgdesc_t meshtastic_ZMistEntry_msg; +extern const pb_msgdesc_t meshtastic_EmergencyAlert_msg; +extern const pb_msgdesc_t meshtastic_TaskRequest_msg; +extern const pb_msgdesc_t meshtastic_TAKEnvironment_msg; +extern const pb_msgdesc_t meshtastic_SensorFov_msg; extern const pb_msgdesc_t meshtastic_TAKPacketV2_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ @@ -658,18 +1807,42 @@ extern const pb_msgdesc_t meshtastic_TAKPacketV2_msg; #define meshtastic_Contact_fields &meshtastic_Contact_msg #define meshtastic_PLI_fields &meshtastic_PLI_msg #define meshtastic_AircraftTrack_fields &meshtastic_AircraftTrack_msg +#define meshtastic_CotGeoPoint_fields &meshtastic_CotGeoPoint_msg +#define meshtastic_DrawnShape_fields &meshtastic_DrawnShape_msg +#define meshtastic_Marker_fields &meshtastic_Marker_msg +#define meshtastic_RangeAndBearing_fields &meshtastic_RangeAndBearing_msg +#define meshtastic_Route_fields &meshtastic_Route_msg +#define meshtastic_Route_Link_fields &meshtastic_Route_Link_msg +#define meshtastic_CasevacReport_fields &meshtastic_CasevacReport_msg +#define meshtastic_ZMistEntry_fields &meshtastic_ZMistEntry_msg +#define meshtastic_EmergencyAlert_fields &meshtastic_EmergencyAlert_msg +#define meshtastic_TaskRequest_fields &meshtastic_TaskRequest_msg +#define meshtastic_TAKEnvironment_fields &meshtastic_TAKEnvironment_msg +#define meshtastic_SensorFov_fields &meshtastic_SensorFov_msg #define meshtastic_TAKPacketV2_fields &meshtastic_TAKPacketV2_msg /* Maximum encoded size of messages (where known) */ -#define MESHTASTIC_MESHTASTIC_ATAK_PB_H_MAX_SIZE meshtastic_TAKPacketV2_size +/* meshtastic_CasevacReport_size depends on runtime parameters */ +/* meshtastic_ZMistEntry_size depends on runtime parameters */ +/* meshtastic_SensorFov_size depends on runtime parameters */ +/* meshtastic_TAKPacketV2_size depends on runtime parameters */ +#define MESHTASTIC_MESHTASTIC_ATAK_PB_H_MAX_SIZE meshtastic_Route_size #define meshtastic_AircraftTrack_size 134 #define meshtastic_Contact_size 242 -#define meshtastic_GeoChat_size 444 +#define meshtastic_CotGeoPoint_size 12 +#define meshtastic_DrawnShape_size 553 +#define meshtastic_EmergencyAlert_size 100 +#define meshtastic_GeoChat_size 495 #define meshtastic_Group_size 4 +#define meshtastic_Marker_size 191 #define meshtastic_PLI_size 31 +#define meshtastic_RangeAndBearing_size 84 +#define meshtastic_Route_Link_size 83 +#define meshtastic_Route_size 1379 #define meshtastic_Status_size 3 -#define meshtastic_TAKPacketV2_size 1027 -#define meshtastic_TAKPacket_size 705 +#define meshtastic_TAKEnvironment_size 18 +#define meshtastic_TAKPacket_size 756 +#define meshtastic_TaskRequest_size 132 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/mesh.pb.cpp b/src/mesh/generated/meshtastic/mesh.pb.cpp index 7f1a738c6..3648d8850 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.cpp +++ b/src/mesh/generated/meshtastic/mesh.pb.cpp @@ -27,6 +27,9 @@ PB_BIND(meshtastic_KeyVerification, meshtastic_KeyVerification, AUTO) PB_BIND(meshtastic_StoreForwardPlusPlus, meshtastic_StoreForwardPlusPlus, 2) +PB_BIND(meshtastic_RemoteShell, meshtastic_RemoteShell, AUTO) + + PB_BIND(meshtastic_Waypoint, meshtastic_Waypoint, AUTO) @@ -129,6 +132,8 @@ PB_BIND(meshtastic_ChunkedPayloadResponse, meshtastic_ChunkedPayloadResponse, AU + + diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index fc6931d73..d7ff32cb4 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -308,8 +308,13 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_TDISPLAY_S3_PRO = 126, /* Heltec Mesh Node T096 board features an nRF52840 CPU and a TFT screen. */ meshtastic_HardwareModel_HELTEC_MESH_NODE_T096 = 127, - /* Seeed studio T1000-E Pro tracker card. NRF52840 w/ LR2021 radio, GPS, button, buzzer, and sensors. */ + /* Seeed studio T1000-E Pro tracker card. NRF52840 w/ LR2021 radio, + GPS, button, buzzer, and sensors. */ meshtastic_HardwareModel_TRACKER_T1000_E_PRO = 128, + /* Elecrow ThinkNode M7, M8 and M9 */ + meshtastic_HardwareModel_THINKNODE_M7 = 129, + meshtastic_HardwareModel_THINKNODE_M8 = 130, + meshtastic_HardwareModel_THINKNODE_M9 = 131, /* ------------------------------------------------------------------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------------------------------------------------------------------ */ @@ -513,6 +518,27 @@ typedef enum _meshtastic_StoreForwardPlusPlus_SFPP_message_type { meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF = 6 } meshtastic_StoreForwardPlusPlus_SFPP_message_type; +/* Frame op code for PTY session control and stream transport. + + Values 1-63 are client->server requests. + Values 64-127 are server->client responses/events. */ +typedef enum _meshtastic_RemoteShell_OpCode { + meshtastic_RemoteShell_OpCode_OP_UNSET = 0, + /* Client -> server */ + meshtastic_RemoteShell_OpCode_OPEN = 1, + meshtastic_RemoteShell_OpCode_INPUT = 2, + meshtastic_RemoteShell_OpCode_RESIZE = 3, + meshtastic_RemoteShell_OpCode_CLOSE = 4, + meshtastic_RemoteShell_OpCode_PING = 5, + meshtastic_RemoteShell_OpCode_ACK = 6, + /* Server -> client */ + meshtastic_RemoteShell_OpCode_OPEN_OK = 64, + meshtastic_RemoteShell_OpCode_OUTPUT = 65, + meshtastic_RemoteShell_OpCode_CLOSED = 66, + meshtastic_RemoteShell_OpCode_ERROR = 67, + meshtastic_RemoteShell_OpCode_PONG = 68 +} meshtastic_RemoteShell_OpCode; + /* The priority of this message for sending. Higher priorities are sent first (when managing the transmit queue). This field is never sent over the air, it is only used internally inside of a local device node. @@ -845,6 +871,31 @@ typedef struct _meshtastic_StoreForwardPlusPlus { uint32_t chain_count; } meshtastic_StoreForwardPlusPlus; +typedef PB_BYTES_ARRAY_T(200) meshtastic_RemoteShell_payload_t; +/* The actual over-the-mesh message doing RemoteShell */ +typedef struct _meshtastic_RemoteShell { + /* Structured frame operation. */ + meshtastic_RemoteShell_OpCode op; + /* Logical PTY session identifier. */ + uint32_t session_id; + /* Monotonic sequence number for this frame. */ + uint32_t seq; + /* Cumulative ack sequence number. */ + uint32_t ack_seq; + /* Opaque bytes payload for INPUT/OUTPUT/ERROR and other frame bodies. */ + meshtastic_RemoteShell_payload_t payload; + /* Terminal size columns used for OPEN/RESIZE signaling. */ + uint32_t cols; + /* Terminal size rows used for OPEN/RESIZE signaling. */ + uint32_t rows; + /* Bit flags for protocol extensions. */ + uint32_t flags; + /* The last sequence number TX'd. */ + uint32_t last_tx_seq; + /* The last sequence number RX'd. */ + uint32_t last_rx_seq; +} meshtastic_RemoteShell; + /* Waypoint message, used to share arbitrary locations across the mesh */ typedef struct _meshtastic_Waypoint { /* Id of the waypoint */ @@ -1385,6 +1436,10 @@ extern "C" { #define _meshtastic_StoreForwardPlusPlus_SFPP_message_type_MAX meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF #define _meshtastic_StoreForwardPlusPlus_SFPP_message_type_ARRAYSIZE ((meshtastic_StoreForwardPlusPlus_SFPP_message_type)(meshtastic_StoreForwardPlusPlus_SFPP_message_type_LINK_PROVIDE_SECONDHALF+1)) +#define _meshtastic_RemoteShell_OpCode_MIN meshtastic_RemoteShell_OpCode_OP_UNSET +#define _meshtastic_RemoteShell_OpCode_MAX meshtastic_RemoteShell_OpCode_PONG +#define _meshtastic_RemoteShell_OpCode_ARRAYSIZE ((meshtastic_RemoteShell_OpCode)(meshtastic_RemoteShell_OpCode_PONG+1)) + #define _meshtastic_MeshPacket_Priority_MIN meshtastic_MeshPacket_Priority_UNSET #define _meshtastic_MeshPacket_Priority_MAX meshtastic_MeshPacket_Priority_MAX #define _meshtastic_MeshPacket_Priority_ARRAYSIZE ((meshtastic_MeshPacket_Priority)(meshtastic_MeshPacket_Priority_MAX+1)) @@ -1415,6 +1470,8 @@ extern "C" { #define meshtastic_StoreForwardPlusPlus_sfpp_message_type_ENUMTYPE meshtastic_StoreForwardPlusPlus_SFPP_message_type +#define meshtastic_RemoteShell_op_ENUMTYPE meshtastic_RemoteShell_OpCode + @@ -1459,6 +1516,7 @@ extern "C" { #define meshtastic_Data_init_default {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0} #define meshtastic_KeyVerification_init_default {0, {0, {0}}, {0, {0}}} #define meshtastic_StoreForwardPlusPlus_init_default {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0} +#define meshtastic_RemoteShell_init_default {_meshtastic_RemoteShell_OpCode_MIN, 0, 0, 0, {0, {0}}, 0, 0, 0, 0, 0} #define meshtastic_Waypoint_init_default {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_StatusMessage_init_default {""} #define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0} @@ -1492,6 +1550,7 @@ extern "C" { #define meshtastic_Data_init_zero {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, 0} #define meshtastic_KeyVerification_init_zero {0, {0, {0}}, {0, {0}}} #define meshtastic_StoreForwardPlusPlus_init_zero {_meshtastic_StoreForwardPlusPlus_SFPP_message_type_MIN, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, 0, 0, 0, 0, 0} +#define meshtastic_RemoteShell_init_zero {_meshtastic_RemoteShell_OpCode_MIN, 0, 0, 0, {0, {0}}, 0, 0, 0, 0, 0} #define meshtastic_Waypoint_init_zero {0, false, 0, false, 0, 0, 0, "", "", 0} #define meshtastic_StatusMessage_init_zero {""} #define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0} @@ -1581,6 +1640,16 @@ extern "C" { #define meshtastic_StoreForwardPlusPlus_encapsulated_from_tag 8 #define meshtastic_StoreForwardPlusPlus_encapsulated_rxtime_tag 9 #define meshtastic_StoreForwardPlusPlus_chain_count_tag 10 +#define meshtastic_RemoteShell_op_tag 1 +#define meshtastic_RemoteShell_session_id_tag 2 +#define meshtastic_RemoteShell_seq_tag 3 +#define meshtastic_RemoteShell_ack_seq_tag 4 +#define meshtastic_RemoteShell_payload_tag 5 +#define meshtastic_RemoteShell_cols_tag 6 +#define meshtastic_RemoteShell_rows_tag 7 +#define meshtastic_RemoteShell_flags_tag 8 +#define meshtastic_RemoteShell_last_tx_seq_tag 9 +#define meshtastic_RemoteShell_last_rx_seq_tag 10 #define meshtastic_Waypoint_id_tag 1 #define meshtastic_Waypoint_latitude_i_tag 2 #define meshtastic_Waypoint_longitude_i_tag 3 @@ -1813,6 +1882,20 @@ X(a, STATIC, SINGULAR, UINT32, chain_count, 10) #define meshtastic_StoreForwardPlusPlus_CALLBACK NULL #define meshtastic_StoreForwardPlusPlus_DEFAULT NULL +#define meshtastic_RemoteShell_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, op, 1) \ +X(a, STATIC, SINGULAR, UINT32, session_id, 2) \ +X(a, STATIC, SINGULAR, UINT32, seq, 3) \ +X(a, STATIC, SINGULAR, UINT32, ack_seq, 4) \ +X(a, STATIC, SINGULAR, BYTES, payload, 5) \ +X(a, STATIC, SINGULAR, UINT32, cols, 6) \ +X(a, STATIC, SINGULAR, UINT32, rows, 7) \ +X(a, STATIC, SINGULAR, UINT32, flags, 8) \ +X(a, STATIC, SINGULAR, UINT32, last_tx_seq, 9) \ +X(a, STATIC, SINGULAR, UINT32, last_rx_seq, 10) +#define meshtastic_RemoteShell_CALLBACK NULL +#define meshtastic_RemoteShell_DEFAULT NULL + #define meshtastic_Waypoint_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, id, 1) \ X(a, STATIC, OPTIONAL, SFIXED32, latitude_i, 2) \ @@ -2095,6 +2178,7 @@ extern const pb_msgdesc_t meshtastic_Routing_msg; extern const pb_msgdesc_t meshtastic_Data_msg; extern const pb_msgdesc_t meshtastic_KeyVerification_msg; extern const pb_msgdesc_t meshtastic_StoreForwardPlusPlus_msg; +extern const pb_msgdesc_t meshtastic_RemoteShell_msg; extern const pb_msgdesc_t meshtastic_Waypoint_msg; extern const pb_msgdesc_t meshtastic_StatusMessage_msg; extern const pb_msgdesc_t meshtastic_MqttClientProxyMessage_msg; @@ -2130,6 +2214,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_Data_fields &meshtastic_Data_msg #define meshtastic_KeyVerification_fields &meshtastic_KeyVerification_msg #define meshtastic_StoreForwardPlusPlus_fields &meshtastic_StoreForwardPlusPlus_msg +#define meshtastic_RemoteShell_fields &meshtastic_RemoteShell_msg #define meshtastic_Waypoint_fields &meshtastic_Waypoint_msg #define meshtastic_StatusMessage_fields &meshtastic_StatusMessage_msg #define meshtastic_MqttClientProxyMessage_fields &meshtastic_MqttClientProxyMessage_msg @@ -2185,6 +2270,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_NodeRemoteHardwarePin_size 29 #define meshtastic_Position_size 144 #define meshtastic_QueueStatus_size 23 +#define meshtastic_RemoteShell_size 253 #define meshtastic_RouteDiscovery_size 256 #define meshtastic_Routing_size 259 #define meshtastic_StatusMessage_size 81 diff --git a/src/mesh/generated/meshtastic/portnums.pb.h b/src/mesh/generated/meshtastic/portnums.pb.h index a474e5b92..494ef4a54 100644 --- a/src/mesh/generated/meshtastic/portnums.pb.h +++ b/src/mesh/generated/meshtastic/portnums.pb.h @@ -76,6 +76,8 @@ typedef enum _meshtastic_PortNum { meshtastic_PortNum_ALERT_APP = 11, /* Module/port for handling key verification requests. */ meshtastic_PortNum_KEY_VERIFICATION_APP = 12, + /* Module/port for handling primitive remote shell access. */ + meshtastic_PortNum_REMOTE_SHELL_APP = 13, /* Provides a 'ping' service that replies to any packet it receives. Also serves as a small example module. ENCODING: ASCII Plaintext */ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index f48d946a4..8c0fdd563 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -113,7 +113,9 @@ typedef enum _meshtastic_TelemetrySensorType { /* SCD30 CO2, humidity, temperature sensor */ meshtastic_TelemetrySensorType_SCD30 = 49, /* SHT family of sensors for temperature and humidity */ - meshtastic_TelemetrySensorType_SHTXX = 50 + meshtastic_TelemetrySensorType_SHTXX = 50, + /* DS248X Bridge for one-wire temperature sensors */ + meshtastic_TelemetrySensorType_DS248X = 51 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -206,6 +208,9 @@ typedef struct _meshtastic_EnvironmentMetrics { /* Soil temperature measured (*C) */ bool has_soil_temperature; float soil_temperature; + /* One-wire temperature (*C) */ + pb_size_t one_wire_temperature_count; + float one_wire_temperature[8]; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -491,8 +496,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SHTXX -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SHTXX+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_DS248X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_DS248X+1)) @@ -508,7 +513,7 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -519,7 +524,7 @@ extern "C" { #define meshtastic_Nau7802Config_init_default {0, 0} #define meshtastic_SEN5XState_init_default {0, 0, 0, false, 0, false, 0, false, 0} #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -558,6 +563,7 @@ extern "C" { #define meshtastic_EnvironmentMetrics_rainfall_24h_tag 20 #define meshtastic_EnvironmentMetrics_soil_moisture_tag 21 #define meshtastic_EnvironmentMetrics_soil_temperature_tag 22 +#define meshtastic_EnvironmentMetrics_one_wire_temperature_tag 23 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -683,7 +689,8 @@ X(a, STATIC, OPTIONAL, FLOAT, radiation, 18) \ X(a, STATIC, OPTIONAL, FLOAT, rainfall_1h, 19) \ X(a, STATIC, OPTIONAL, FLOAT, rainfall_24h, 20) \ X(a, STATIC, OPTIONAL, UINT32, soil_moisture, 21) \ -X(a, STATIC, OPTIONAL, FLOAT, soil_temperature, 22) +X(a, STATIC, OPTIONAL, FLOAT, soil_temperature, 22) \ +X(a, STATIC, REPEATED, FLOAT, one_wire_temperature, 23) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -852,7 +859,7 @@ extern const pb_msgdesc_t meshtastic_SEN5XState_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 150 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 113 +#define meshtastic_EnvironmentMetrics_size 161 #define meshtastic_HealthMetrics_size 11 #define meshtastic_HostMetrics_size 264 #define meshtastic_LocalStats_size 87 From f14ef121ef2afb0b1a9fcd356cdf9aa7766ff55c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 20:19:30 -0500 Subject: [PATCH 33/67] Update meshtastic-st7789 digest to 92bae2e (#10182) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- variants/esp32s3/heltec_vision_master_t190/platformio.ini | 2 +- variants/esp32s3/m5stack_cardputer_adv/platformio.ini | 2 +- variants/nrf52840/heltec_mesh_node_t114/platformio.ini | 2 +- variants/nrf52840/heltec_mesh_solar/platformio.ini | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/variants/esp32s3/heltec_vision_master_t190/platformio.ini b/variants/esp32s3/heltec_vision_master_t190/platformio.ini index be1ea192d..3dab9f93c 100644 --- a/variants/esp32s3/heltec_vision_master_t190/platformio.ini +++ b/variants/esp32s3/heltec_vision_master_t190/platformio.ini @@ -20,5 +20,5 @@ build_flags = lib_deps = ${esp32s3_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main - https://github.com/meshtastic/st7789/archive/a787beea5c6c8f864ba6787eb432bbefc575e6ad.zip + https://github.com/meshtastic/st7789/archive/92bae2e4a307afb430c3b0bc3d661c55ee1565f0.zip upload_speed = 921600 diff --git a/variants/esp32s3/m5stack_cardputer_adv/platformio.ini b/variants/esp32s3/m5stack_cardputer_adv/platformio.ini index 7da039cd4..3b378ed94 100644 --- a/variants/esp32s3/m5stack_cardputer_adv/platformio.ini +++ b/variants/esp32s3/m5stack_cardputer_adv/platformio.ini @@ -16,7 +16,7 @@ build_src_filter = lib_deps = ${esp32s3_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main - https://github.com/meshtastic/st7789/archive/a787beea5c6c8f864ba6787eb432bbefc575e6ad.zip + https://github.com/meshtastic/st7789/archive/92bae2e4a307afb430c3b0bc3d661c55ee1565f0.zip # renovate: datasource=github-tags depName=pschatzmann_arduino-audio-driver packageName=pschatzmann/arduino-audio-driver https://github.com/pschatzmann/arduino-audio-driver/archive/v0.2.1.zip # renovate: datasource=git-refs depName=ESP8266Audio packageName=https://github.com/meshtastic/ESP8266Audio gitBranch=meshtastic-2.0.0-dacfix diff --git a/variants/nrf52840/heltec_mesh_node_t114/platformio.ini b/variants/nrf52840/heltec_mesh_node_t114/platformio.ini index ef8bd4a17..c9f998240 100644 --- a/variants/nrf52840/heltec_mesh_node_t114/platformio.ini +++ b/variants/nrf52840/heltec_mesh_node_t114/platformio.ini @@ -23,4 +23,4 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/heltec_ lib_deps = ${nrf52840_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main - https://github.com/meshtastic/st7789/archive/a787beea5c6c8f864ba6787eb432bbefc575e6ad.zip + https://github.com/meshtastic/st7789/archive/92bae2e4a307afb430c3b0bc3d661c55ee1565f0.zip diff --git a/variants/nrf52840/heltec_mesh_solar/platformio.ini b/variants/nrf52840/heltec_mesh_solar/platformio.ini index 1b15c0758..1b6f59a68 100644 --- a/variants/nrf52840/heltec_mesh_solar/platformio.ini +++ b/variants/nrf52840/heltec_mesh_solar/platformio.ini @@ -132,4 +132,4 @@ build_flags = ${heltec_mesh_solar_base.build_flags} lib_deps = ${heltec_mesh_solar_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main - https://github.com/meshtastic/st7789/archive/a787beea5c6c8f864ba6787eb432bbefc575e6ad.zip + https://github.com/meshtastic/st7789/archive/92bae2e4a307afb430c3b0bc3d661c55ee1565f0.zip From 8e55a6e4c1c46500af964197f4c944226bfa03ff Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 20:19:52 -0500 Subject: [PATCH 34/67] Update meshtastic/device-ui digest to 5305670 (#10183) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 437e6f34c..3cd0cc9d0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -126,7 +126,7 @@ lib_deps = [device-ui_base] lib_deps = # renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master - https://github.com/meshtastic/device-ui/archive/1897dd17fceb1f101bb1a3245680aa3439edcfdd.zip + https://github.com/meshtastic/device-ui/archive/5305670b68eb5b92d14e62b5b536969ca4bb441f.zip ; Common libs for environmental measurements in telemetry module [environmental_base] From 3a87e746a82b9f1319f93f2bab938a0a543ccdd4 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 16 Apr 2026 21:34:28 -0500 Subject: [PATCH 35/67] No longer need undefines, thanks to #10179 (#10180) --- platformio.ini | 1 - variants/esp32/chatter2/platformio.ini | 1 - variants/esp32/diy/9m2ibr_aprs_lora_tracker/platformio.ini | 1 - variants/esp32/diy/hydra/platformio.ini | 1 - variants/esp32/diy/v1/platformio.ini | 1 - variants/esp32/heltec_v2.1/platformio.ini | 1 - variants/esp32/heltec_v2/platformio.ini | 1 - variants/esp32/nano-g1-explorer/platformio.ini | 1 - variants/esp32/nano-g1/platformio.ini | 1 - variants/esp32/radiomaster_900_bandit/platformio.ini | 1 - variants/esp32/radiomaster_900_bandit_micro/platformio.ini | 1 - variants/esp32/radiomaster_900_bandit_nano/platformio.ini | 1 - variants/esp32/station-g1/platformio.ini | 1 - variants/esp32/tbeam/platformio.ini | 1 - variants/esp32/tlora_v1/platformio.ini | 1 - variants/esp32/tlora_v2_1_16/platformio.ini | 2 +- variants/esp32/tlora_v2_1_16_tcxo/platformio.ini | 1 - variants/esp32/tlora_v3_3_0_tcxo/platformio.ini | 1 - variants/esp32c6/tlora_c6/platformio.ini | 1 - variants/esp32s3/heltec_capsule_sensor_v3/platformio.ini | 1 - variants/esp32s3/heltec_sensor_hub/platformio.ini | 1 - variants/esp32s3/heltec_v3/platformio.ini | 1 - variants/esp32s3/heltec_v4/platformio.ini | 1 - variants/esp32s3/heltec_wsl_v3/platformio.ini | 1 - variants/rp2040/rpipicow/platformio.ini | 1 - 25 files changed, 1 insertion(+), 25 deletions(-) diff --git a/platformio.ini b/platformio.ini index 637f7e517..b9cf568e3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,7 +58,6 @@ build_flags = -Wno-missing-field-initializers -DMESHTASTIC_EXCLUDE_POWERMON=1 -DMESHTASTIC_EXCLUDE_STATUS=1 -D MAX_THREADS=40 ; As we've split modules, we have more threads to manage - #-DLED_BUILTIN=-1 #-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now #-D OLED_PL=1 #-D DEBUG_HEAP=1 ; uncomment to add free heap space / memory leak debugging logs diff --git a/variants/esp32/chatter2/platformio.ini b/variants/esp32/chatter2/platformio.ini index 62d23b1e6..a14e407a1 100644 --- a/variants/esp32/chatter2/platformio.ini +++ b/variants/esp32/chatter2/platformio.ini @@ -8,7 +8,6 @@ build_flags = -I variants/esp32/chatter2 -DMESHTASTIC_EXCLUDE_WEBSERVER=1 -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 - -ULED_BUILTIN lib_deps = ${esp32_base.lib_deps} diff --git a/variants/esp32/diy/9m2ibr_aprs_lora_tracker/platformio.ini b/variants/esp32/diy/9m2ibr_aprs_lora_tracker/platformio.ini index 3fdb738fc..2ddc5a2db 100644 --- a/variants/esp32/diy/9m2ibr_aprs_lora_tracker/platformio.ini +++ b/variants/esp32/diy/9m2ibr_aprs_lora_tracker/platformio.ini @@ -10,7 +10,6 @@ build_flags = -D EBYTE_E22 -D EBYTE_E22_900M30S ; Assume Tx power curve is identical to 900M30S as there is no documentation -I variants/esp32/diy/9m2ibr_aprs_lora_tracker - -ULED_BUILTIN build_src_filter = ${esp32_base.build_src_filter} +<../variants/esp32/diy/9m2ibr_aprs_lora_tracker> \ No newline at end of file diff --git a/variants/esp32/diy/hydra/platformio.ini b/variants/esp32/diy/hydra/platformio.ini index f23224f0b..3afd17e01 100644 --- a/variants/esp32/diy/hydra/platformio.ini +++ b/variants/esp32/diy/hydra/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D DIY_V1 -I variants/esp32/diy/hydra - -ULED_BUILTIN diff --git a/variants/esp32/diy/v1/platformio.ini b/variants/esp32/diy/v1/platformio.ini index 6be2bfd09..3d31fc24a 100644 --- a/variants/esp32/diy/v1/platformio.ini +++ b/variants/esp32/diy/v1/platformio.ini @@ -17,4 +17,3 @@ build_flags = -D DIY_V1 -D EBYTE_E22 -I variants/esp32/diy/v1 - -ULED_BUILTIN diff --git a/variants/esp32/heltec_v2.1/platformio.ini b/variants/esp32/heltec_v2.1/platformio.ini index 9fcb2388a..1f7caa16f 100644 --- a/variants/esp32/heltec_v2.1/platformio.ini +++ b/variants/esp32/heltec_v2.1/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D HELTEC_V2_1 -I variants/esp32/heltec_v2.1 - -ULED_BUILTIN diff --git a/variants/esp32/heltec_v2/platformio.ini b/variants/esp32/heltec_v2/platformio.ini index fc9e05115..5f15fb321 100644 --- a/variants/esp32/heltec_v2/platformio.ini +++ b/variants/esp32/heltec_v2/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D HELTEC_V2_0 -I variants/esp32/heltec_v2 - -ULED_BUILTIN diff --git a/variants/esp32/nano-g1-explorer/platformio.ini b/variants/esp32/nano-g1-explorer/platformio.ini index b27ebf28e..6f57897a8 100644 --- a/variants/esp32/nano-g1-explorer/platformio.ini +++ b/variants/esp32/nano-g1-explorer/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D NANO_G1_EXPLORER -I variants/esp32/nano-g1-explorer - -ULED_BUILTIN diff --git a/variants/esp32/nano-g1/platformio.ini b/variants/esp32/nano-g1/platformio.ini index b2e392dbd..82d0f5e73 100644 --- a/variants/esp32/nano-g1/platformio.ini +++ b/variants/esp32/nano-g1/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D NANO_G1 -I variants/esp32/nano-g1 - -ULED_BUILTIN diff --git a/variants/esp32/radiomaster_900_bandit/platformio.ini b/variants/esp32/radiomaster_900_bandit/platformio.ini index 0012f49d3..6729235ed 100644 --- a/variants/esp32/radiomaster_900_bandit/platformio.ini +++ b/variants/esp32/radiomaster_900_bandit/platformio.ini @@ -9,7 +9,6 @@ build_flags = -DHAS_STK8XXX=1 -O2 -I variants/esp32/radiomaster_900_bandit - -ULED_BUILTIN board_build.f_cpu = 240000000L upload_protocol = esptool lib_deps = diff --git a/variants/esp32/radiomaster_900_bandit_micro/platformio.ini b/variants/esp32/radiomaster_900_bandit_micro/platformio.ini index e58d06f1e..32e9280e1 100644 --- a/variants/esp32/radiomaster_900_bandit_micro/platformio.ini +++ b/variants/esp32/radiomaster_900_bandit_micro/platformio.ini @@ -13,6 +13,5 @@ build_flags = -DCONFIG_DISABLE_HAL_LOCKS=1 -O2 -I variants/esp32/radiomaster_900_bandit_nano - -ULED_BUILTIN board_build.f_cpu = 240000000L upload_protocol = esptool diff --git a/variants/esp32/radiomaster_900_bandit_nano/platformio.ini b/variants/esp32/radiomaster_900_bandit_nano/platformio.ini index 7b3d187bf..924447ee4 100644 --- a/variants/esp32/radiomaster_900_bandit_nano/platformio.ini +++ b/variants/esp32/radiomaster_900_bandit_nano/platformio.ini @@ -16,6 +16,5 @@ build_flags = -DCONFIG_DISABLE_HAL_LOCKS=1 -O2 -I variants/esp32/radiomaster_900_bandit_nano - -ULED_BUILTIN board_build.f_cpu = 240000000L upload_protocol = esptool diff --git a/variants/esp32/station-g1/platformio.ini b/variants/esp32/station-g1/platformio.ini index 5a7f33485..20e29764c 100644 --- a/variants/esp32/station-g1/platformio.ini +++ b/variants/esp32/station-g1/platformio.ini @@ -14,4 +14,3 @@ build_flags = ${esp32_base.build_flags} -D STATION_G1 -I variants/esp32/station-g1 - -ULED_BUILTIN diff --git a/variants/esp32/tbeam/platformio.ini b/variants/esp32/tbeam/platformio.ini index c9e6cce1f..96e9879ce 100644 --- a/variants/esp32/tbeam/platformio.ini +++ b/variants/esp32/tbeam/platformio.ini @@ -16,7 +16,6 @@ board_check = true build_flags = ${esp32_base.build_flags} -D TBEAM_V10 -I variants/esp32/tbeam - -ULED_BUILTIN upload_speed = 921600 [env:tbeam-displayshield] diff --git a/variants/esp32/tlora_v1/platformio.ini b/variants/esp32/tlora_v1/platformio.ini index 5f72d634e..c45cc2ce9 100644 --- a/variants/esp32/tlora_v1/platformio.ini +++ b/variants/esp32/tlora_v1/platformio.ini @@ -13,5 +13,4 @@ build_flags = ${esp32_base.build_flags} -D TLORA_V1 -I variants/esp32/tlora_v1 - -ULED_BUILTIN upload_speed = 115200 diff --git a/variants/esp32/tlora_v2_1_16/platformio.ini b/variants/esp32/tlora_v2_1_16/platformio.ini index 2ea9bbb50..a41c5016e 100644 --- a/variants/esp32/tlora_v2_1_16/platformio.ini +++ b/variants/esp32/tlora_v2_1_16/platformio.ini @@ -12,7 +12,7 @@ extends = esp32_base board = ttgo-lora32-v21 board_check = true build_flags = - ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 -ULED_BUILTIN + ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 upload_speed = 115200 [env:sugarcube] diff --git a/variants/esp32/tlora_v2_1_16_tcxo/platformio.ini b/variants/esp32/tlora_v2_1_16_tcxo/platformio.ini index 235ac7007..3cb64c976 100644 --- a/variants/esp32/tlora_v2_1_16_tcxo/platformio.ini +++ b/variants/esp32/tlora_v2_1_16_tcxo/platformio.ini @@ -7,5 +7,4 @@ build_flags = -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 -D LORA_TCXO_GPIO=33 - -ULED_BUILTIN upload_speed = 115200 diff --git a/variants/esp32/tlora_v3_3_0_tcxo/platformio.ini b/variants/esp32/tlora_v3_3_0_tcxo/platformio.ini index 38f14ffc5..d3669ce55 100644 --- a/variants/esp32/tlora_v3_3_0_tcxo/platformio.ini +++ b/variants/esp32/tlora_v3_3_0_tcxo/platformio.ini @@ -7,4 +7,3 @@ build_flags = -I variants/esp32/tlora_v2_1_16 -D LORA_TCXO_GPIO=12 -D BUTTON_PIN=0 - -ULED_BUILTIN \ No newline at end of file diff --git a/variants/esp32c6/tlora_c6/platformio.ini b/variants/esp32c6/tlora_c6/platformio.ini index 174e5e297..6b402d7c5 100644 --- a/variants/esp32c6/tlora_c6/platformio.ini +++ b/variants/esp32c6/tlora_c6/platformio.ini @@ -8,4 +8,3 @@ build_flags = -I variants/esp32c6/tlora_c6 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 - -ULED_BUILTIN diff --git a/variants/esp32s3/heltec_capsule_sensor_v3/platformio.ini b/variants/esp32s3/heltec_capsule_sensor_v3/platformio.ini index 6dd828433..0bb21581a 100644 --- a/variants/esp32s3/heltec_capsule_sensor_v3/platformio.ini +++ b/variants/esp32s3/heltec_capsule_sensor_v3/platformio.ini @@ -6,5 +6,4 @@ board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3 -D HELTEC_CAPSULE_SENSOR_V3 - -ULED_BUILTIN ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output diff --git a/variants/esp32s3/heltec_sensor_hub/platformio.ini b/variants/esp32s3/heltec_sensor_hub/platformio.ini index 9a5384ccd..ab99e51ed 100644 --- a/variants/esp32s3/heltec_sensor_hub/platformio.ini +++ b/variants/esp32s3/heltec_sensor_hub/platformio.ini @@ -7,4 +7,3 @@ build_flags = ${esp32s3_base.build_flags} -I variants/esp32s3/heltec_sensor_hub -D HELTEC_SENSOR_HUB - -ULED_BUILTIN diff --git a/variants/esp32s3/heltec_v3/platformio.ini b/variants/esp32s3/heltec_v3/platformio.ini index fe31df094..2f53c8756 100644 --- a/variants/esp32s3/heltec_v3/platformio.ini +++ b/variants/esp32s3/heltec_v3/platformio.ini @@ -18,4 +18,3 @@ build_flags = ${esp32s3_base.build_flags} -D HELTEC_V3 -I variants/esp32s3/heltec_v3 - -ULED_BUILTIN diff --git a/variants/esp32s3/heltec_v4/platformio.ini b/variants/esp32s3/heltec_v4/platformio.ini index 0336bf983..5a5004a45 100644 --- a/variants/esp32s3/heltec_v4/platformio.ini +++ b/variants/esp32s3/heltec_v4/platformio.ini @@ -8,7 +8,6 @@ build_flags = -D HELTEC_V4 -D HAS_LORA_FEM=1 -I variants/esp32s3/heltec_v4 - -ULED_BUILTIN [env:heltec-v4] diff --git a/variants/esp32s3/heltec_wsl_v3/platformio.ini b/variants/esp32s3/heltec_wsl_v3/platformio.ini index 873300c3c..0903a6bc7 100644 --- a/variants/esp32s3/heltec_wsl_v3/platformio.ini +++ b/variants/esp32s3/heltec_wsl_v3/platformio.ini @@ -17,4 +17,3 @@ build_flags = ${esp32s3_base.build_flags} -D HELTEC_WSL_V3 -I variants/esp32s3/heltec_wsl_v3 - -ULED_BUILTIN diff --git a/variants/rp2040/rpipicow/platformio.ini b/variants/rp2040/rpipicow/platformio.ini index 9b4b29a5b..99e02a1aa 100644 --- a/variants/rp2040/rpipicow/platformio.ini +++ b/variants/rp2040/rpipicow/platformio.ini @@ -22,7 +22,6 @@ build_flags = -D HW_SPI1_DEVICE -D HAS_UDP_MULTICAST=1 -fexceptions # for exception handling in MQTT - -ULED_BUILTIN build_src_filter = ${rp2040_base.build_src_filter} + lib_deps = ${rp2040_base.lib_deps} From 6208c243f96d72c5a401ee2a2f30c3a8e4ead2ec Mon Sep 17 00:00:00 2001 From: Jason P Date: Fri, 17 Apr 2026 08:42:56 -0500 Subject: [PATCH 36/67] BaseUI: Implementation of Status Message for Favorite and NodeList views (#9504) * Implementation of Status Message * Change drawNodeInfo to drawFavoriteNode * Truncate overflow on Favorite frame * Set MAX_RECENT_STATUSMESSAGES to 5 to meet memory usage targets --- platformio.ini | 1 - src/graphics/Screen.cpp | 4 +- src/graphics/draw/NodeListRenderer.cpp | 40 +++++++++++++++++- src/graphics/draw/UIRenderer.cpp | 56 +++++++++++++++++++++++++- src/graphics/draw/UIRenderer.h | 2 +- src/modules/StatusMessageModule.cpp | 15 ++++++- src/modules/StatusMessageModule.h | 15 ++++++- 7 files changed, 124 insertions(+), 9 deletions(-) diff --git a/platformio.ini b/platformio.ini index b9cf568e3..0205d1ad8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -56,7 +56,6 @@ build_flags = -Wno-missing-field-initializers -DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware -DMESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE=1 -DMESHTASTIC_EXCLUDE_POWERMON=1 - -DMESHTASTIC_EXCLUDE_STATUS=1 -D MAX_THREADS=40 ; As we've split modules, we have more threads to manage #-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now #-D OLED_PL=1 diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 55ec93db5..fa9d98a0e 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1197,7 +1197,7 @@ void Screen::setFrames(FrameFocus focus) for (size_t i = 0; i < nodeDB->getNumMeshNodes(); i++) { const meshtastic_NodeInfoLite *n = nodeDB->getMeshNodeByIndex(i); if (n && n->num != nodeDB->getNodeNum() && n->is_favorite) { - favoriteFrames.push_back(graphics::UIRenderer::drawNodeInfo); + favoriteFrames.push_back(graphics::UIRenderer::drawFavoriteNode); } } @@ -1226,7 +1226,7 @@ void Screen::setFrames(FrameFocus focus) static OverlayCallback overlays[] = {graphics::UIRenderer::drawNavigationBar, NotificationRenderer::drawBannercallback}; ui->setOverlays(overlays, sizeof(overlays) / sizeof(overlays[0])); - prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list just changed) + prevFrame = -1; // Force drawFavoriteNode to pick a new node (because our list just changed) // Focus on a specific frame, in the frame set we just created switch (focus) { diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index 98644ee3b..654c27222 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -3,6 +3,9 @@ #include "CompassRenderer.h" #include "NodeDB.h" #include "NodeListRenderer.h" +#if !MESHTASTIC_EXCLUDE_STATUS +#include "modules/StatusMessageModule.h" +#endif #include "UIRenderer.h" #include "gps/GeoCoord.h" #include "gps/RTC.h" // for getTime() function @@ -92,8 +95,41 @@ std::string getSafeNodeName(OLEDDisplay *display, meshtastic_NodeInfoLite *node, // 1) Choose target candidate (long vs short) only if present const char *raw = nullptr; - if (node && node->has_user) { - raw = config.display.use_long_node_name ? node->user.long_name : node->user.short_name; + +#if !MESHTASTIC_EXCLUDE_STATUS + // If long-name mode is enabled, and we have a recent status for this node, + // prefer "(short_name) statusText" as the raw candidate. + std::string composedFromStatus; + if (config.display.use_long_node_name && node && node->has_user && statusMessageModule) { + const auto &recent = statusMessageModule->getRecentReceived(); + const StatusMessageModule::RecentStatus *found = nullptr; + for (auto it = recent.rbegin(); it != recent.rend(); ++it) { + if (it->fromNodeId == node->num && !it->statusText.empty()) { + found = &(*it); + break; + } + } + + if (found) { + const char *shortName = node->user.short_name; + composedFromStatus.reserve(4 + (shortName ? std::strlen(shortName) : 0) + 1 + found->statusText.size()); + composedFromStatus += "("; + if (shortName && *shortName) { + composedFromStatus += shortName; + } + composedFromStatus += ") "; + composedFromStatus += found->statusText; + + raw = composedFromStatus.c_str(); // safe for now; we'll sanitize immediately into std::string + } + } +#endif + + // If we didn't compose from status, use normal long/short selection + if (!raw) { + if (node && node->has_user) { + raw = config.display.use_long_node_name ? node->user.long_name : node->user.short_name; + } } // 2) Preserve UTF-8 names so emotes can be detected and rendered. diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index e3a4d13a2..78d109881 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -5,6 +5,9 @@ #include "MeshService.h" #include "NodeDB.h" #include "NodeListRenderer.h" +#if !MESHTASTIC_EXCLUDE_STATUS +#include "modules/StatusMessageModule.h" +#endif #include "UIRenderer.h" #include "airtime.h" #include "gps/GeoCoord.h" @@ -290,7 +293,7 @@ void UIRenderer::drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const mes // * Favorite Node Info * // ********************** // cppcheck-suppress constParameterPointer; signature must match FrameCallback typedef from OLEDDisplayUi library -void UIRenderer::drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { if (favoritedNodes.empty()) return; @@ -342,6 +345,57 @@ void UIRenderer::drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, i UIRenderer::drawStringWithEmotes(display, x, getTextPositions(display)[line++], username, FONT_HEIGHT_SMALL, 1, false); } +#if !MESHTASTIC_EXCLUDE_STATUS + // === Optional: Last received StatusMessage line for this node === + // Display it directly under the username line (if we have one). + if (statusMessageModule) { + const auto &recent = statusMessageModule->getRecentReceived(); + const StatusMessageModule::RecentStatus *found = nullptr; + + // Search newest-to-oldest + for (auto it = recent.rbegin(); it != recent.rend(); ++it) { + if (it->fromNodeId == node->num && !it->statusText.empty()) { + found = &(*it); + break; + } + } + + if (found) { + std::string statusLine = std::string(" Status: ") + found->statusText; + { + const int screenW = display->getWidth(); + const int ellipseW = display->getStringWidth("..."); + int w = display->getStringWidth(statusLine.c_str()); + + // Only do work if it overflows + if (w > screenW) { + bool truncated = false; + if (ellipseW > screenW) { + statusLine.clear(); + } else { + while (!statusLine.empty()) { + // remove one char (byte) at a time + statusLine.pop_back(); + truncated = true; + + // Measure candidate with ellipsis appended + std::string candidate = statusLine + "..."; + if (display->getStringWidth(candidate.c_str()) <= screenW) { + statusLine = std::move(candidate); + break; + } + } + if (statusLine.empty() && ellipseW <= screenW) { + statusLine = "..."; + } + } + } + } + display->drawString(x, getTextPositions(display)[line++], statusLine.c_str()); + } + } +#endif + // === 2. Signal and Hops (combined on one line, if available) === char signalHopsStr[32] = ""; bool haveSignal = false; diff --git a/src/graphics/draw/UIRenderer.h b/src/graphics/draw/UIRenderer.h index a0bb0d849..a705d944d 100644 --- a/src/graphics/draw/UIRenderer.h +++ b/src/graphics/draw/UIRenderer.h @@ -50,7 +50,7 @@ class UIRenderer // Navigation bar overlay static void drawNavigationBar(OLEDDisplay *display, OLEDDisplayUiState *state); - static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); + static void drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); diff --git a/src/modules/StatusMessageModule.cpp b/src/modules/StatusMessageModule.cpp index 139a74d8e..0707a4f7d 100644 --- a/src/modules/StatusMessageModule.cpp +++ b/src/modules/StatusMessageModule.cpp @@ -29,10 +29,23 @@ int32_t StatusMessageModule::runOnce() ProcessMessage StatusMessageModule::handleReceived(const meshtastic_MeshPacket &mp) { if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { - meshtastic_StatusMessage incomingMessage; + meshtastic_StatusMessage incomingMessage = meshtastic_StatusMessage_init_zero; + if (pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, meshtastic_StatusMessage_fields, &incomingMessage)) { + LOG_INFO("Received a NodeStatus message %s", incomingMessage.status); + + RecentStatus entry; + entry.fromNodeId = mp.from; + entry.statusText = incomingMessage.status; + + recentReceived.push_back(std::move(entry)); + + // Keep only last MAX_RECENT_STATUSMESSAGES + if (recentReceived.size() > MAX_RECENT_STATUSMESSAGES) { + recentReceived.erase(recentReceived.begin()); // drop oldest + } } } return ProcessMessage::CONTINUE; diff --git a/src/modules/StatusMessageModule.h b/src/modules/StatusMessageModule.h index c9ff54018..5090066e6 100644 --- a/src/modules/StatusMessageModule.h +++ b/src/modules/StatusMessageModule.h @@ -2,10 +2,11 @@ #if !MESHTASTIC_EXCLUDE_STATUS #include "SinglePortModule.h" #include "configuration.h" +#include +#include class StatusMessageModule : public SinglePortModule, private concurrency::OSThread { - public: /** Constructor * name is for debugging output @@ -19,16 +20,28 @@ class StatusMessageModule : public SinglePortModule, private concurrency::OSThre this->setInterval(1000 * 12 * 60 * 60); } // TODO: If we have a string, set the initial delay (15 minutes maybe) + + // Keep vector from reallocating as we fill up to MAX_RECENT_STATUSMESSAGES + recentReceived.reserve(MAX_RECENT_STATUSMESSAGES); } virtual int32_t runOnce() override; + struct RecentStatus { + uint32_t fromNodeId; // mp.from + std::string statusText; // incomingMessage.status + }; + + const std::vector &getRecentReceived() const { return recentReceived; } + protected: /** Called to handle a particular incoming message */ virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override; private: + static constexpr size_t MAX_RECENT_STATUSMESSAGES = 5; + std::vector recentReceived; }; extern StatusMessageModule *statusMessageModule; From 2c8dec2fbdaea2860851841a0fbd38eb129da13c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 19:48:07 -0500 Subject: [PATCH 37/67] Update meshtastic/device-ui digest to 56e1da4 (#10195) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 3cd0cc9d0..4d66cf538 100644 --- a/platformio.ini +++ b/platformio.ini @@ -126,7 +126,7 @@ lib_deps = [device-ui_base] lib_deps = # renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master - https://github.com/meshtastic/device-ui/archive/5305670b68eb5b92d14e62b5b536969ca4bb441f.zip + https://github.com/meshtastic/device-ui/archive/56e1da4e7d30abcd746a2092a30e422f8cf5fc2b.zip ; Common libs for environmental measurements in telemetry module [environmental_base] From aab4cd086f87606f1bb381fcb28dab8e6efba0e9 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Sat, 18 Apr 2026 07:53:22 -0400 Subject: [PATCH 38/67] Compass improvements/refactoring (#10166) * Infinite calibration loop fix * Save calibration * Screen refresh * reduce repeated code * reduce repeated code to reduce flash * fix Waypoint compass size and no fix no heading labels * Don't show compass unless we have a heading and location * If no calculated heading from moving, we should have no heading * Slow walking calculated heading and auto stale heading when not moving * Triming flash space * cleanup * show "?" when no location or heading for distance and heading screen * cleanup * Stale heading logic * final trim * Compass Calibration screen redesign * Trunk Fix * Compile fix * patch * Update src/motion/MotionSensor.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update WaypointModule.cpp --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/graphics/Screen.cpp | 102 +++++++++- src/graphics/Screen.h | 10 +- src/graphics/draw/CompassRenderer.cpp | 76 ++++++-- src/graphics/draw/CompassRenderer.h | 5 +- src/graphics/draw/NodeListRenderer.cpp | 71 ++++--- src/graphics/draw/NodeListRenderer.h | 6 +- src/graphics/draw/UIRenderer.cpp | 231 ++++++++++++---------- src/modules/WaypointModule.cpp | 156 +++++++++------ src/motion/BMM150Sensor.cpp | 24 +-- src/motion/BMX160Sensor.cpp | 68 +------ src/motion/BMX160Sensor.h | 3 +- src/motion/ICM20948Sensor.cpp | 88 ++------- src/motion/ICM20948Sensor.h | 3 +- src/motion/MotionSensor.cpp | 259 +++++++++++++++++++++++-- src/motion/MotionSensor.h | 18 +- 15 files changed, 721 insertions(+), 399 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index fa9d98a0e..0fc34ddb3 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -60,6 +60,7 @@ along with this program. If not, see . #include "main.h" #include "mesh-pb-constants.h" #include "mesh/Channels.h" +#include "mesh/Default.h" #include "mesh/generated/meshtastic/deviceonly.pb.h" #include "modules/ExternalNotificationModule.h" #include "modules/TextMessageModule.h" @@ -98,6 +99,7 @@ namespace graphics // This means the *visible* area (sh1106 can address 132, but shows 128 for example) #define IDLE_FRAMERATE 1 // in fps +#define COMPASS_ACTIVE_FRAMERATE 20 // DEBUG #define NUM_EXTRA_FRAMES 3 // text message and debug frame @@ -135,6 +137,60 @@ static bool heartbeat = false; extern bool hasUnreadMessage; +static inline float wrapHeading360(float heading) +{ + if (heading < 0.0f) { + heading += 360.0f; + } else if (heading >= 360.0f) { + heading -= 360.0f; + } + return heading; +} + +void Screen::setHeading(float heading) +{ + const float wrappedHeading = wrapHeading360(heading); + + if (!hasCompass) { + hasCompass = true; + compassHeading = wrappedHeading; + return; + } + + // Interpolate using shortest-path angular delta to avoid jumps around 0/360. + float delta = wrappedHeading - compassHeading; + if (delta > 180.0f) { + delta -= 360.0f; + } else if (delta < -180.0f) { + delta += 360.0f; + } + + // Adaptive filtering: + // - Strong damping for tiny deltas (jitter) + // - Faster response for larger turns + const float absDelta = (delta >= 0.0f) ? delta : -delta; + if (absDelta < 1.0f) { + return; + } + + float alpha = 0.35f; + if (absDelta > 25.0f) { + alpha = 0.85f; + } else if (absDelta > 10.0f) { + alpha = 0.65f; + } + + float step = delta * alpha; + const float maxStep = 12.0f; + if (step > maxStep) { + step = maxStep; + } else if (step < -maxStep) { + step = -maxStep; + } + + compassHeading = wrapHeading360(compassHeading + step); +} + // ============================== // Overlay Alert Banner Renderer // ============================== @@ -272,10 +328,25 @@ static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int float Screen::estimatedHeading(double lat, double lon) { static double oldLat, oldLon; - static float b; + static float b = -1.0f; + static uint32_t lastHeadingAtMs = 0; + const uint32_t now = millis(); + const uint32_t gpsUpdateIntervalSecs = + Default::getConfiguredOrDefault(config.position.gps_update_interval, default_gps_update_interval); + uint32_t effectiveUpdateIntervalSecs = gpsUpdateIntervalSecs; + if (config.position.position_broadcast_smart_enabled) { + const uint32_t smartMinIntervalSecs = Default::getConfiguredOrDefault( + config.position.broadcast_smart_minimum_interval_secs, default_broadcast_smart_minimum_interval_secs); + if (smartMinIntervalSecs > effectiveUpdateIntervalSecs) { + effectiveUpdateIntervalSecs = smartMinIntervalSecs; + } + } + // Two expected update windows; keep arithmetic 32-bit to avoid pulling in larger 64-bit helpers. + const uint32_t headingStaleMs = + (effectiveUpdateIntervalSecs > (UINT32_MAX / 2000U)) ? UINT32_MAX : (effectiveUpdateIntervalSecs * 2000U); if (oldLat == 0) { - // just prepare for next time + // Need at least two position points before we can infer heading. oldLat = lat; oldLon = lon; @@ -283,12 +354,20 @@ float Screen::estimatedHeading(double lat, double lon) } float d = GeoCoord::latLongToMeter(oldLat, oldLon, lat, lon); - if (d < 10) // haven't moved enough, just keep current bearing + if (d < 10) { // haven't moved enough, keep previous heading (invalid until first real movement) + if (lastHeadingAtMs != 0 && (now - lastHeadingAtMs) >= headingStaleMs) { + // Heading is stale after prolonged no-movement; force reacquire. + b = -1.0f; + oldLat = lat; + oldLon = lon; + } return b; + } b = GeoCoord::bearing(oldLat, oldLon, lat, lon) * RAD_TO_DEG; oldLat = lat; oldLon = lon; + lastHeadingAtMs = now; return b; } @@ -923,9 +1002,22 @@ int32_t Screen::runOnce() // but we should only call setTargetFPS when framestate changes, because // otherwise that breaks animations. - if (targetFramerate != IDLE_FRAMERATE && ui->getUiState()->frameState == FIXED) { + uint32_t desiredFramerate = IDLE_FRAMERATE; +#if HAS_GPS && !defined(USE_EINK) + if (showingNormalScreen && hasCompass) { + const uint8_t currentFrame = ui->getUiState()->currentFrame; + if ((framesetInfo.positions.gps != 255 && currentFrame == framesetInfo.positions.gps) || + (framesetInfo.positions.waypoint != 255 && currentFrame == framesetInfo.positions.waypoint) || + (framesetInfo.positions.firstFavorite != 255 && currentFrame >= framesetInfo.positions.firstFavorite && + currentFrame <= framesetInfo.positions.lastFavorite)) { + desiredFramerate = COMPASS_ACTIVE_FRAMERATE; + } + } +#endif + + if (targetFramerate != desiredFramerate && ui->getUiState()->frameState == FIXED) { // oldFrameState = ui->getUiState()->frameState; - targetFramerate = IDLE_FRAMERATE; + targetFramerate = desiredFramerate; ui->setTargetFPS(targetFramerate); forceDisplay(); diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index e259f7691..5a1a2d6da 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -330,15 +330,11 @@ class Screen : public concurrency::OSThread // Function to allow the AccelerometerThread to set the heading if a sensor provides it // Mutex needed? - void setHeading(long _heading) - { - hasCompass = true; - compassHeading = fmod(_heading, 360); - } + void setHeading(float heading); bool hasHeading() { return hasCompass; } - long getHeading() { return compassHeading; } + float getHeading() { return compassHeading; } void setEndCalibration(uint32_t _endCalibrationAt) { endCalibrationAt = _endCalibrationAt; } uint32_t getEndCalibration() { return endCalibrationAt; } @@ -782,4 +778,4 @@ extern std::vector functionSymbol; extern std::string functionSymbolString; extern graphics::Screen *screen; -#endif \ No newline at end of file +#endif diff --git a/src/graphics/draw/CompassRenderer.cpp b/src/graphics/draw/CompassRenderer.cpp index 42600ce96..fe54d68e7 100644 --- a/src/graphics/draw/CompassRenderer.cpp +++ b/src/graphics/draw/CompassRenderer.cpp @@ -1,10 +1,6 @@ #include "configuration.h" #if HAS_SCREEN #include "CompassRenderer.h" -#include "NodeDB.h" -#include "UIRenderer.h" -#include "configuration.h" -#include "gps/GeoCoord.h" #include "graphics/ScreenFonts.h" #include "graphics/SharedUIDisplay.h" #include @@ -21,8 +17,8 @@ struct Point { void rotate(float angle) { - float cos_a = cos(angle); - float sin_a = sin(angle); + float cos_a = cosf(angle); + float sin_a = sinf(angle); float new_x = x * cos_a - y * sin_a; float new_y = x * sin_a + y * cos_a; x = new_x; @@ -51,21 +47,30 @@ void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, if (currentResolution == ScreenResolution::High) { radius += 4; } - Point north(0, -radius); - if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) - north.rotate(-myHeading); - north.translate(compassX, compassY); + float northX = 0.0f; + float northY = -radius; + if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) { + const float c = cosf(-myHeading); + const float s = sinf(-myHeading); + const float rx = northX * c - northY * s; + const float ry = northX * s + northY * c; + northX = rx; + northY = ry; + } + northX += compassX; + northY += compassY; display->setFont(FONT_SMALL); display->setTextAlignment(TEXT_ALIGN_CENTER); display->setColor(BLACK); + const int16_t nLabelWidth = display->getStringWidth("N"); if (currentResolution == ScreenResolution::High) { - display->fillRect(north.x - 8, north.y - 1, display->getStringWidth("N") + 3, FONT_HEIGHT_SMALL - 6); + display->fillRect(northX - 8, northY - 1, nLabelWidth + 3, FONT_HEIGHT_SMALL - 6); } else { - display->fillRect(north.x - 4, north.y - 1, display->getStringWidth("N") + 2, FONT_HEIGHT_SMALL - 6); + display->fillRect(northX - 4, northY - 1, nLabelWidth + 2, FONT_HEIGHT_SMALL - 6); } display->setColor(WHITE); - display->drawString(north.x, north.y - 3, "N"); + display->drawString(northX, northY - 3, "N"); } void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian) @@ -113,11 +118,46 @@ void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, f display->fillTriangle(tip.x, tip.y, right.x, right.y, tail.x, tail.y); } -float estimatedHeading(double lat, double lon) +bool getHeadingRadians(double lat, double lon, float &headingRadian) { - // Simple magnetic declination estimation - // This is a very basic implementation - the original might be more sophisticated - return 0.0f; // Return 0 for now, indicating no heading available + headingRadian = 0.0f; + + if (uiconfig.compass_mode == meshtastic_CompassMode_FREEZE_HEADING) + return true; + + if (!screen) + return false; + + if (screen->hasHeading()) { + headingRadian = screen->getHeading() * DEG_TO_RAD; + return true; + } + + const float estimatedHeadingDeg = screen->estimatedHeading(lat, lon); + if (!(estimatedHeadingDeg >= 0.0f)) + return false; + + headingRadian = estimatedHeadingDeg * DEG_TO_RAD; + return true; +} + +float adjustBearingForCompassMode(float bearingRadian, float headingRadian) +{ + if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) + return bearingRadian - headingRadian; + + return bearingRadian; +} + +float radiansToDegrees360(float angleRadian) +{ + constexpr float fullTurnDeg = 360.0f; + float degrees = angleRadian * RAD_TO_DEG; + if (degrees < 0.0f) + degrees += fullTurnDeg; + else if (degrees >= fullTurnDeg) + degrees -= fullTurnDeg; + return degrees; } uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight) @@ -137,4 +177,4 @@ uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight) } // namespace CompassRenderer } // namespace graphics -#endif \ No newline at end of file +#endif diff --git a/src/graphics/draw/CompassRenderer.h b/src/graphics/draw/CompassRenderer.h index ca7532b66..d77623847 100644 --- a/src/graphics/draw/CompassRenderer.h +++ b/src/graphics/draw/CompassRenderer.h @@ -1,7 +1,6 @@ #pragma once #include "graphics/Screen.h" -#include "mesh/generated/meshtastic/mesh.pb.h" #include #include @@ -25,7 +24,9 @@ void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, u void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, float bearing); // Navigation and location functions -float estimatedHeading(double lat, double lon); +bool getHeadingRadians(double lat, double lon, float &headingRadian); +float adjustBearingForCompassMode(float bearingRadian, float headingRadian); +float radiansToDegrees360(float angleRadian); uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight); } // namespace CompassRenderer diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index 654c27222..e0c5df124 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -409,14 +409,13 @@ void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16 } } - if (strlen(distStr) > 0) { - int offset = (currentResolution == ScreenResolution::High) - ? (isLeftCol ? 7 : 10) // Offset for Wide Screens (Left Column:Right Column) - : (isLeftCol ? 4 : 7); // Offset for Narrow Screens (Left Column:Right Column) - int rightEdge = x + columnWidth - offset; - int textWidth = display->getStringWidth(distStr); - display->drawString(rightEdge - textWidth, y, distStr); - } + const char *distanceLabel = (strlen(distStr) > 0) ? distStr : "?"; + int offset = (currentResolution == ScreenResolution::High) + ? (isLeftCol ? 7 : 10) // Offset for Wide Screens (Left Column:Right Column) + : (isLeftCol ? 4 : 7); // Offset for Narrow Screens (Left Column:Right Column) + int rightEdge = x + columnWidth - offset; + int textWidth = display->getStringWidth(distanceLabel); + display->drawString(rightEdge - textWidth, y, distanceLabel); } void drawEntryDynamic_Nodes(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth) @@ -467,8 +466,8 @@ void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16 } } -void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, float myHeading, - double userLat, double userLon) +void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, + float myHeadingRadian, double userLat, double userLon) { if (!nodeDB->hasValidPosition(node)) return; @@ -482,11 +481,11 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16 double nodeLat = node->position.latitude_i * 1e-7; double nodeLon = node->position.longitude_i * 1e-7; float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon); - float bearingToNode = RAD_TO_DEG * bearing; - float relativeBearing = fmod((bearingToNode - myHeading + 360), 360); + float relativeBearing = CompassRenderer::adjustBearingForCompassMode(bearing, myHeadingRadian); + float relativeBearingDeg = CompassRenderer::radiansToDegrees360(relativeBearing); // Shrink size by 2px int size = FONT_HEIGHT_SMALL - 5; - CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing); + CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearingDeg); /* float angle = relativeBearing * DEG_TO_RAD; float halfSize = size / 2.0; @@ -516,12 +515,27 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16 */ } +void drawCompassUnknown(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, float, double, + double) +{ + if (!nodeDB->hasValidPosition(node)) + return; + + bool isLeftCol = (x < SCREEN_WIDTH / 2); + int arrowXOffset = (currentResolution == ScreenResolution::High) ? (isLeftCol ? 22 : 24) : (isLeftCol ? 12 : 18); + int centerX = x + columnWidth - arrowXOffset; + + display->setFont(FONT_SMALL); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(centerX, y, "?"); +} + // ============================= // Main Screen Functions // ============================= void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y, const char *title, - EntryRenderer renderer, NodeExtrasRenderer extras, float heading, double lat, double lon) + EntryRenderer renderer, NodeExtrasRenderer extras, float headingRadian, double lat, double lon) { const int COMMON_HEADER_HEIGHT = FONT_HEIGHT_SMALL - 1; const int rowYOffset = FONT_HEIGHT_SMALL - 3; @@ -606,7 +620,7 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t renderer(display, node, xPos, yPos, columnWidth); if (extras) - extras(display, node, xPos, yPos, columnWidth, heading, lat, lon); + extras(display, node, xPos, yPos, columnWidth, headingRadian, lat, lon); lastNodeY = max(lastNodeY, yPos + FONT_HEIGHT_SMALL); yOffset += rowYOffset; @@ -801,9 +815,13 @@ void drawDistanceScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t #endif void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - float heading = 0; - bool validHeading = false; + float headingRadian = 0.0f; auto ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum()); + if (!ourNode || !nodeDB->hasValidPosition(ourNode)) { + drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassUnknown, headingRadian, 0.0, 0.0); + return; + } + double lat = DegD(ourNode->position.latitude_i); double lon = DegD(ourNode->position.longitude_i); @@ -815,21 +833,12 @@ void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, lastSwitchTime = now; } #endif - if (uiconfig.compass_mode != meshtastic_CompassMode_FREEZE_HEADING) { -#if HAS_GPS - if (screen->hasHeading()) { - heading = screen->getHeading(); // degrees - validHeading = true; - } else { - heading = screen->estimatedHeading(lat, lon); - validHeading = !isnan(heading); - } -#endif - - if (!validHeading) - return; + if (!CompassRenderer::getHeadingRadians(lat, lon, headingRadian)) { + drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassUnknown, headingRadian, lat, lon); + return; } - drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassArrow, heading, lat, lon); + + drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassArrow, headingRadian, lat, lon); } /// Draw a series of fields in a column, wrapping to multiple columns if needed diff --git a/src/graphics/draw/NodeListRenderer.h b/src/graphics/draw/NodeListRenderer.h index be80a7d80..4aa217141 100644 --- a/src/graphics/draw/NodeListRenderer.h +++ b/src/graphics/draw/NodeListRenderer.h @@ -32,7 +32,7 @@ enum ListMode_Location { MODE_DISTANCE = 0, MODE_BEARING = 1, MODE_COUNT_LOCATIO // Main node list screen function void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y, const char *title, - EntryRenderer renderer, NodeExtrasRenderer extras = nullptr, float heading = 0, double lat = 0, + EntryRenderer renderer, NodeExtrasRenderer extras = nullptr, float headingRadian = 0, double lat = 0, double lon = 0); // Entry renderers @@ -43,8 +43,8 @@ void drawEntryDynamic_Nodes(OLEDDisplay *display, meshtastic_NodeInfoLite *node, void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth); // Extras renderers -void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, float myHeading, - double userLat, double userLon); +void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, + float myHeadingRadian, double userLat, double userLon); // Screen frame functions void drawLastHeardScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index 78d109881..b94c25a27 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -41,6 +41,15 @@ static inline void drawSatelliteIcon(OLEDDisplay *display, int16_t x, int16_t y) } } +static void drawCompassStatusText(OLEDDisplay *display, int16_t compassX, int16_t compassY, const char *statusLine1, + const char *statusLine2) +{ + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(compassX, compassY - FONT_HEIGHT_SMALL, statusLine1); + display->drawString(compassX, compassY, statusLine2); + display->setTextAlignment(TEXT_ALIGN_LEFT); +} + void graphics::UIRenderer::rebuildFavoritedNodes() { favoritedNodes.clear(); @@ -692,51 +701,54 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat display->drawString(x, getTextPositions(display)[line++], batLine); } + bool showCompass = false; + float myHeading = 0.0f; + float bearing = 0.0f; + const bool hasOwnPositionFix = (ourNode && nodeDB->hasValidPosition(ourNode)); + const bool hasNodePositionFix = nodeDB->hasValidPosition(node); + const char *statusLine1 = nullptr; + const char *statusLine2 = nullptr; + if (hasOwnPositionFix && hasNodePositionFix) { + const auto &op = ourNode->position; + showCompass = CompassRenderer::getHeadingRadians(DegD(op.latitude_i), DegD(op.longitude_i), myHeading); + if (showCompass) { + const auto &p = node->position; + bearing = GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i)); + bearing = CompassRenderer::adjustBearingForCompassMode(bearing, myHeading); + } else { + statusLine1 = "No"; + statusLine2 = "Heading"; + } + } else if (!hasOwnPositionFix || !hasNodePositionFix) { + statusLine1 = "No"; + statusLine2 = "Fix"; + } + // --- Compass Rendering: landscape (wide) screens use the original side-aligned logic --- if (SCREEN_WIDTH > SCREEN_HEIGHT) { - bool showCompass = false; - if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading()) && nodeDB->hasValidPosition(node)) { - showCompass = true; - } - if (showCompass) { + if (showCompass || statusLine1) { const int16_t topY = getTextPositions(display)[1]; const int16_t bottomY = SCREEN_HEIGHT - (FONT_HEIGHT_SMALL - 1); const int16_t usableHeight = bottomY - topY - 5; int16_t compassRadius = usableHeight / 2; if (compassRadius < 8) compassRadius = 8; - const int16_t compassDiam = compassRadius * 2; const int16_t compassX = x + SCREEN_WIDTH - compassRadius - 8; const int16_t compassY = topY + (usableHeight / 2) + ((FONT_HEIGHT_SMALL - 1) / 2) + 2; - - const auto &op = ourNode->position; - float myHeading = screen->hasHeading() ? screen->getHeading() * PI / 180 - : screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i)); - - const auto &p = node->position; - /* unused - float d = - GeoCoord::latLongToMeter(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i)); - */ - float bearing = GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i)); - if (uiconfig.compass_mode == meshtastic_CompassMode_FREEZE_HEADING) { - myHeading = 0; - } else { - bearing -= myHeading; - } + const int16_t compassDiam = compassRadius * 2; display->drawCircle(compassX, compassY, compassRadius); - CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, compassRadius); - CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, bearing); + if (showCompass) { + CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, compassRadius); + CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, bearing); + } else { + drawCompassStatusText(display, compassX, compassY, statusLine1, statusLine2); + } } // else show nothing } else { // Portrait or square: put compass at the bottom and centered, scaled to fit available space - bool showCompass = false; - if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading()) && nodeDB->hasValidPosition(node)) { - showCompass = true; - } - if (showCompass) { + if (showCompass || statusLine1) { int yBelowContent = (line > 0 && line <= 5) ? (getTextPositions(display)[line - 1] + FONT_HEIGHT_SMALL + 2) : getTextPositions(display)[1]; const int margin = 4; @@ -747,8 +759,8 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat #else const int navBarHeight = 0; #endif - int availableHeight = SCREEN_HEIGHT - yBelowContent - navBarHeight - margin; // --------- END PATCH FOR EINK NAV BAR ----------- + int availableHeight = SCREEN_HEIGHT - yBelowContent - navBarHeight - margin; if (availableHeight < FONT_HEIGHT_SMALL * 2) return; @@ -762,25 +774,13 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat int compassX = x + SCREEN_WIDTH / 2; int compassY = yBelowContent + availableHeight / 2; - const auto &op = ourNode->position; - float myHeading = 0; - if (uiconfig.compass_mode != meshtastic_CompassMode_FREEZE_HEADING) { - myHeading = screen->hasHeading() ? screen->getHeading() * PI / 180 - : screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i)); - } - graphics::CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, compassRadius); - - const auto &p = node->position; - /* unused - float d = - GeoCoord::latLongToMeter(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i)); - */ - float bearing = GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i)); - if (uiconfig.compass_mode != meshtastic_CompassMode_FREEZE_HEADING) - bearing -= myHeading; - graphics::CompassRenderer::drawNodeHeading(display, compassX, compassY, compassRadius * 2, bearing); - display->drawCircle(compassX, compassY, compassRadius); + if (showCompass) { + graphics::CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, compassRadius); + graphics::CompassRenderer::drawNodeHeading(display, compassX, compassY, compassRadius * 2, bearing); + } else { + drawCompassStatusText(display, compassX, compassY, statusLine1, statusLine2); + } } // else show nothing } @@ -1216,6 +1216,7 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU // === Header === graphics::drawCommonHeader(display, x, y, titleStr); + const int *textPos = getTextPositions(display); // === First Row: My Location === #if HAS_GPS @@ -1230,12 +1231,12 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU } else { displayLine = config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off"; } - drawSatelliteIcon(display, x, getTextPositions(display)[line]); + drawSatelliteIcon(display, x, textPos[line]); int xOffset = (currentResolution == ScreenResolution::High) ? 6 : 0; - display->drawString(x + 11 + xOffset, getTextPositions(display)[line++], displayLine); + display->drawString(x + 11 + xOffset, textPos[line++], displayLine); } else { // Onboard GPS - UIRenderer::drawGps(display, 0, getTextPositions(display)[line++], gpsStatus); + UIRenderer::drawGps(display, 0, textPos[line++], gpsStatus); } config.display.heading_bold = origBold; @@ -1244,18 +1245,36 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU geoCoord.updateCoords(int32_t(gpsStatus->getLatitude()), int32_t(gpsStatus->getLongitude()), int32_t(gpsStatus->getAltitude())); - // === Determine Compass Heading === - float heading = 0; + meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum()); + const bool hasOwnPositionFix = (ourNode && nodeDB->hasValidPosition(ourNode)); + const bool hasLiveGpsFix = + (gpsStatus && gpsStatus->getHasLock() && (gpsStatus->getLatitude() != 0 || gpsStatus->getLongitude() != 0)); + const bool hasSensorHeading = screen->hasHeading(); + float heading = 0.0f; bool validHeading = false; - if (uiconfig.compass_mode == meshtastic_CompassMode_FREEZE_HEADING) { - validHeading = true; - } else { - if (screen->hasHeading()) { - heading = radians(screen->getHeading()); - validHeading = true; + const char *statusLine1 = nullptr; + const char *statusLine2 = nullptr; + if (hasSensorHeading || hasLiveGpsFix || hasOwnPositionFix) { + double headingLat = 0.0; + double headingLon = 0.0; + if (hasLiveGpsFix) { + headingLat = DegD(gpsStatus->getLatitude()); + headingLon = DegD(gpsStatus->getLongitude()); + } else if (hasOwnPositionFix) { + const auto &op = ourNode->position; + headingLat = DegD(op.latitude_i); + headingLon = DegD(op.longitude_i); + } + validHeading = CompassRenderer::getHeadingRadians(headingLat, headingLon, heading); + } + + if (!validHeading) { + if (hasSensorHeading || hasLiveGpsFix || hasOwnPositionFix) { + statusLine1 = "No"; + statusLine2 = "Heading"; } else { - heading = screen->estimatedHeading(geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7); - validHeading = !isnan(heading); + statusLine1 = "No"; + statusLine2 = "Fix"; } } @@ -1273,18 +1292,18 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU getUptimeStr(delta, "Last: ", uptimeStr, sizeof(uptimeStr), true); #endif - display->drawString(0, getTextPositions(display)[line++], uptimeStr); + display->drawString(0, textPos[line++], uptimeStr); } else { - display->drawString(0, getTextPositions(display)[line++], "Last: ?"); + display->drawString(0, textPos[line++], "Last: ?"); } // === Third Row: Line 1 GPS Info === - UIRenderer::drawGpsCoordinates(display, x, getTextPositions(display)[line++], gpsStatus, "line1"); + UIRenderer::drawGpsCoordinates(display, x, textPos[line++], gpsStatus, "line1"); if (uiconfig.gps_format != meshtastic_DeviceUIConfig_GpsCoordinateFormat_OLC && uiconfig.gps_format != meshtastic_DeviceUIConfig_GpsCoordinateFormat_MLS) { // === Fourth Row: Line 2 GPS Info === - UIRenderer::drawGpsCoordinates(display, x, getTextPositions(display)[line++], gpsStatus, "line2"); + UIRenderer::drawGpsCoordinates(display, x, textPos[line++], gpsStatus, "line2"); } // === Final Row: Altitude === @@ -1295,14 +1314,14 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU } else { snprintf(altitudeLine, sizeof(altitudeLine), "Alt: %.0im", alt); } - display->drawString(x, getTextPositions(display)[line++], altitudeLine); + display->drawString(x, textPos[line++], altitudeLine); } #if !defined(M5STACK_UNITC6L) - // === Draw Compass if heading is valid === - if (validHeading) { + // === Draw Compass === + if (validHeading || statusLine1) { // --- Compass Rendering: landscape (wide) screens use original side-aligned logic --- if (SCREEN_WIDTH > SCREEN_HEIGHT) { - const int16_t topY = getTextPositions(display)[1]; + const int16_t topY = textPos[1]; const int16_t bottomY = SCREEN_HEIGHT - (FONT_HEIGHT_SMALL - 1); // nav row height const int16_t usableHeight = bottomY - topY - 5; @@ -1315,29 +1334,33 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU // Center vertically and nudge down slightly to keep "N" clear of header const int16_t compassY = topY + (usableHeight / 2) + ((FONT_HEIGHT_SMALL - 1) / 2) + 2; - CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, -heading); display->drawCircle(compassX, compassY, compassRadius); + if (validHeading) { + CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, -heading); - // "N" label - float northAngle = 0; - if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) - northAngle = -heading; - float radius = compassRadius; - int16_t nX = compassX + (radius - 1) * sin(northAngle); - int16_t nY = compassY - (radius - 1) * cos(northAngle); - int16_t nLabelWidth = display->getStringWidth("N") + 2; - int16_t nLabelHeightBox = FONT_HEIGHT_SMALL + 1; + // "N" label + float northAngle = 0; + if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) + northAngle = -heading; + float radius = compassRadius; + int16_t nX = compassX + (radius - 1) * sin(northAngle); + int16_t nY = compassY - (radius - 1) * cos(northAngle); + int16_t nLabelWidth = display->getStringWidth("N") + 2; + int16_t nLabelHeightBox = FONT_HEIGHT_SMALL + 1; - display->setColor(BLACK); - display->fillRect(nX - nLabelWidth / 2, nY - nLabelHeightBox / 2, nLabelWidth, nLabelHeightBox); - display->setColor(WHITE); - display->setFont(FONT_SMALL); - display->setTextAlignment(TEXT_ALIGN_CENTER); - display->drawString(nX, nY - FONT_HEIGHT_SMALL / 2, "N"); + display->setColor(BLACK); + display->fillRect(nX - nLabelWidth / 2, nY - nLabelHeightBox / 2, nLabelWidth, nLabelHeightBox); + display->setColor(WHITE); + display->setFont(FONT_SMALL); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(nX, nY - FONT_HEIGHT_SMALL / 2, "N"); + } else { + drawCompassStatusText(display, compassX, compassY, statusLine1, statusLine2); + } } else { // Portrait or square: put compass at the bottom and centered, scaled to fit available space // For E-Ink screens, account for navigation bar at the bottom! - int yBelowContent = getTextPositions(display)[5] + FONT_HEIGHT_SMALL + 2; + int yBelowContent = textPos[5] + FONT_HEIGHT_SMALL + 2; const int margin = 4; int availableHeight = #if defined(USE_EINK) @@ -1358,25 +1381,29 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU int compassX = x + SCREEN_WIDTH / 2; int compassY = yBelowContent + availableHeight / 2; - CompassRenderer::drawNodeHeading(display, compassX, compassY, compassRadius * 2, -heading); display->drawCircle(compassX, compassY, compassRadius); + if (validHeading) { + CompassRenderer::drawNodeHeading(display, compassX, compassY, compassRadius * 2, -heading); - // "N" label - float northAngle = 0; - if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) - northAngle = -heading; - float radius = compassRadius; - int16_t nX = compassX + (radius - 1) * sin(northAngle); - int16_t nY = compassY - (radius - 1) * cos(northAngle); - int16_t nLabelWidth = display->getStringWidth("N") + 2; - int16_t nLabelHeightBox = FONT_HEIGHT_SMALL + 1; + // "N" label + float northAngle = 0; + if (uiconfig.compass_mode != meshtastic_CompassMode_FIXED_RING) + northAngle = -heading; + float radius = compassRadius; + int16_t nX = compassX + (radius - 1) * sin(northAngle); + int16_t nY = compassY - (radius - 1) * cos(northAngle); + int16_t nLabelWidth = display->getStringWidth("N") + 2; + int16_t nLabelHeightBox = FONT_HEIGHT_SMALL + 1; - display->setColor(BLACK); - display->fillRect(nX - nLabelWidth / 2, nY - nLabelHeightBox / 2, nLabelWidth, nLabelHeightBox); - display->setColor(WHITE); - display->setFont(FONT_SMALL); - display->setTextAlignment(TEXT_ALIGN_CENTER); - display->drawString(nX, nY - FONT_HEIGHT_SMALL / 2, "N"); + display->setColor(BLACK); + display->fillRect(nX - nLabelWidth / 2, nY - nLabelHeightBox / 2, nLabelWidth, nLabelHeightBox); + display->setColor(WHITE); + display->setFont(FONT_SMALL); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(nX, nY - FONT_HEIGHT_SMALL / 2, "N"); + } else { + drawCompassStatusText(display, compassX, compassY, statusLine1, statusLine2); + } } } #endif diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index 4db80ba18..632727b92 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -15,15 +15,6 @@ WaypointModule *waypointModule; -static inline float degToRad(float deg) -{ - return deg * PI / 180.0f; -} -static inline float radToDeg(float rad) -{ - return rad * 180.0f / PI; -} - ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp) { #if defined(DEBUG_PORT) && !defined(DEBUG_MUTE) @@ -91,9 +82,7 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, // === Header === graphics::drawCommonHeader(display, x, y, titleStr); - - const int w = display->getWidth(); - const int h = display->getHeight(); + const int *textPos = graphics::getTextPositions(display); // Decode the waypoint const meshtastic_MeshPacket &mp = devicestate.rx_waypoint; @@ -108,71 +97,118 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, getTimeAgoStr(sinceReceived(&mp), lastStr, sizeof(lastStr)); // Will contain distance information, passed as a field to drawColumns - char distStr[20]; + char distStr[20] = ""; // Get our node, to use our own position meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum()); - // Dimensions / co-ordinates for the compass/circle - const uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(w, h); - const int16_t compassX = x + w - (compassDiam / 2) - 5; - const int16_t compassY = (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) - ? y + h / 2 - : y + FONT_HEIGHT_SMALL + (h - FONT_HEIGHT_SMALL) / 2; + // Match compass sizing/placement to favorite node screen logic. + const int w = display->getWidth(); + int16_t compassRadius = 8; + int16_t compassX = x + w - compassRadius - 8; + int16_t compassY = y + display->getHeight() / 2; - // If our node has a position: - if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading())) { - const meshtastic_PositionLite &op = ourNode->position; - float myHeading; - if (uiconfig.compass_mode == meshtastic_CompassMode_FREEZE_HEADING) { - myHeading = 0; - } else { - if (screen->hasHeading()) - myHeading = degToRad(screen->getHeading()); - else - myHeading = screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i)); + if (SCREEN_WIDTH > SCREEN_HEIGHT) { + const int16_t topY = textPos[1]; + const int16_t bottomY = SCREEN_HEIGHT - (FONT_HEIGHT_SMALL - 1); + const int16_t usableHeight = bottomY - topY - 5; + compassRadius = usableHeight / 2; + if (compassRadius < 8) + compassRadius = 8; + compassX = x + SCREEN_WIDTH - compassRadius - 8; + compassY = topY + (usableHeight / 2) + ((FONT_HEIGHT_SMALL - 1) / 2) + 2; + } else { + // Waypoint content uses rows 1..4, so place the compass below that block. + const int yBelowContent = textPos[4] + FONT_HEIGHT_SMALL + 2; + const int margin = 4; +#if defined(USE_EINK) + const int iconSize = (graphics::currentResolution == graphics::ScreenResolution::High) ? 16 : 8; + const int navBarHeight = iconSize + 6; +#else + const int navBarHeight = 0; +#endif + const int availableHeight = SCREEN_HEIGHT - yBelowContent - navBarHeight - margin; + if (availableHeight > 0) { + compassRadius = availableHeight / 2; + if (compassRadius < 8) + compassRadius = 8; + if (compassRadius * 2 > SCREEN_WIDTH - 16) + compassRadius = (SCREEN_WIDTH - 16) / 2; + if (compassRadius < 8) + compassRadius = 8; + compassX = x + SCREEN_WIDTH / 2; + compassY = yBelowContent + availableHeight / 2; } - graphics::CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, (compassDiam / 2)); + } + const uint16_t compassDiam = compassRadius * 2; - // Compass bearing to waypoint - float bearingToOther = - GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(wp.latitude_i), DegD(wp.longitude_i)); - // If the top of the compass is a static north then bearingToOther can be drawn on the compass directly - // If the top of the compass is not a static north we need adjust bearingToOther based on heading - if (uiconfig.compass_mode != meshtastic_CompassMode_FREEZE_HEADING) - bearingToOther -= myHeading; - graphics::CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, bearingToOther); + const bool hasOwnPositionFix = (ourNode && nodeDB->hasValidPosition(ourNode)); + const char *statusLine1 = nullptr; + const char *statusLine2 = nullptr; - float bearingToOtherDegrees = (bearingToOther < 0) ? bearingToOther + 2 * PI : bearingToOther; - bearingToOtherDegrees = radToDeg(bearingToOtherDegrees); + // Distance only needs our own position fix; compass/bearing additionally needs heading. + if (hasOwnPositionFix) { + const meshtastic_PositionLite &op = ourNode->position; + const float d = + GeoCoord::latLongToMeter(DegD(wp.latitude_i), DegD(wp.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i)); - // Distance to Waypoint - float d = GeoCoord::latLongToMeter(DegD(wp.latitude_i), DegD(wp.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i)); + // Always show distance once we have an own-position fix, even without heading. if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) { float feet = d * METERS_TO_FEET; - snprintf(distStr, sizeof(distStr), feet < (2 * MILES_TO_FEET) ? "%.0fft %.0f°" : "%.1fmi %.0f°", - feet < (2 * MILES_TO_FEET) ? feet : feet / MILES_TO_FEET, bearingToOtherDegrees); + snprintf(distStr, sizeof(distStr), feet < (2 * MILES_TO_FEET) ? "%.0fft" : "%.1fmi", + feet < (2 * MILES_TO_FEET) ? feet : feet / MILES_TO_FEET); } else { - snprintf(distStr, sizeof(distStr), d < 2000 ? "%.0fm %.0f°" : "%.1fkm %.0f°", d < 2000 ? d : d / 1000, - bearingToOtherDegrees); + snprintf(distStr, sizeof(distStr), d < 2000 ? "%.0fm" : "%.1fkm", d < 2000 ? d : d / 1000); } + + float myHeading = 0.0f; + const bool hasHeading = + graphics::CompassRenderer::getHeadingRadians(DegD(op.latitude_i), DegD(op.longitude_i), myHeading); + if (hasHeading) { + // Draw compass circle + display->drawCircle(compassX, compassY, compassRadius); + graphics::CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading, compassRadius); + + // Compass bearing to waypoint + float bearingToOther = + GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(wp.latitude_i), DegD(wp.longitude_i)); + bearingToOther = graphics::CompassRenderer::adjustBearingForCompassMode(bearingToOther, myHeading); + graphics::CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, bearingToOther); + + const float bearingToOtherDegrees = graphics::CompassRenderer::radiansToDegrees360(bearingToOther); + + // Distance to waypoint with relative bearing when heading is available. + if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) { + float feet = d * METERS_TO_FEET; + snprintf(distStr, sizeof(distStr), feet < (2 * MILES_TO_FEET) ? "%.0fft %.0f°" : "%.1fmi %.0f°", + feet < (2 * MILES_TO_FEET) ? feet : feet / MILES_TO_FEET, bearingToOtherDegrees); + } else { + snprintf(distStr, sizeof(distStr), d < 2000 ? "%.0fm %.0f°" : "%.1fkm %.0f°", d < 2000 ? d : d / 1000, + bearingToOtherDegrees); + } + + } else { + statusLine1 = "No"; + statusLine2 = "Heading"; + } + } else { + // No own fix yet, so compass/bearing data would be misleading. + statusLine1 = "No"; + statusLine2 = "Fix"; } - else { - display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?"); - - // ? in the distance field - snprintf(distStr, sizeof(distStr), "? %s ?°", - (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) ? "mi" : "km"); + if (statusLine1) { + display->drawCircle(compassX, compassY, compassRadius); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(compassX, compassY - FONT_HEIGHT_SMALL, statusLine1); + display->drawString(compassX, compassY, statusLine2); } - // Draw compass circle - display->drawCircle(compassX, compassY, compassDiam / 2); - display->setTextAlignment(TEXT_ALIGN_LEFT); // Something above me changes to a different alignment, forcing a fix here! - display->drawString(0, graphics::getTextPositions(display)[line++], lastStr); - display->drawString(0, graphics::getTextPositions(display)[line++], wp.name); - display->drawString(0, graphics::getTextPositions(display)[line++], wp.description); - display->drawString(0, graphics::getTextPositions(display)[line++], distStr); + display->drawString(0, textPos[line++], lastStr); + display->drawString(0, textPos[line++], wp.name); + display->drawString(0, textPos[line++], wp.description); + if (distStr[0]) + display->drawString(0, textPos[line++], distStr); } #endif diff --git a/src/motion/BMM150Sensor.cpp b/src/motion/BMM150Sensor.cpp index 4b3a1215c..f48d20288 100644 --- a/src/motion/BMM150Sensor.cpp +++ b/src/motion/BMM150Sensor.cpp @@ -7,9 +7,6 @@ extern graphics::Screen *screen; #endif -// Flag when an interrupt has been detected -volatile static bool BMM150_IRQ = false; - BMM150Sensor::BMM150Sensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {} bool BMM150Sensor::init() @@ -23,24 +20,7 @@ int32_t BMM150Sensor::runOnce() { #if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN float heading = sensor->getCompassDegree(); - - switch (config.display.compass_orientation) { - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0_INVERTED: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0: - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90_INVERTED: - heading += 90; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180_INVERTED: - heading += 180; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270_INVERTED: - heading += 270; - break; - } + heading = applyCompassOrientation(heading); if (screen) screen->setHeading(heading); #endif @@ -90,4 +70,4 @@ bool BMM150Singleton::init(ScanI2C::FoundDevice device) return true; } -#endif \ No newline at end of file +#endif diff --git a/src/motion/BMX160Sensor.cpp b/src/motion/BMX160Sensor.cpp index 5888c20be..02303faa4 100644 --- a/src/motion/BMX160Sensor.cpp +++ b/src/motion/BMX160Sensor.cpp @@ -16,6 +16,7 @@ bool BMX160Sensor::init() if (sensor.begin()) { // set output data rate sensor.ODR_Config(BMX160_ACCEL_ODR_100HZ, BMX160_GYRO_ODR_100HZ); + loadMagnetometerCalibration(compassCalibrationFileName, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); LOG_DEBUG("BMX160 init ok"); return true; } @@ -33,42 +34,12 @@ int32_t BMX160Sensor::runOnce() sensor.getAllData(&magAccel, NULL, &gAccel); if (doCalibration) { - - if (!showingScreen) { - powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration - showingScreen = true; - if (screen) - screen->startAlert((FrameCallback)drawFrameCalibration); - } - - if (magAccel.x > highestX) - highestX = magAccel.x; - if (magAccel.x < lowestX) - lowestX = magAccel.x; - if (magAccel.y > highestY) - highestY = magAccel.y; - if (magAccel.y < lowestY) - lowestY = magAccel.y; - if (magAccel.z > highestZ) - highestZ = magAccel.z; - if (magAccel.z < lowestZ) - lowestZ = magAccel.z; - - uint32_t now = millis(); - if (now > endCalibrationAt) { - doCalibration = false; - endCalibrationAt = 0; - showingScreen = false; - if (screen) - screen->endAlert(); - } - - // LOG_DEBUG("BMX160 min_x: %.4f, max_X: %.4f, min_Y: %.4f, max_Y: %.4f, min_Z: %.4f, max_Z: %.4f", lowestX, highestX, - // lowestY, highestY, lowestZ, highestZ); + beginCalibrationDisplay(showingScreen); + updateCalibrationExtrema(magAccel.x, magAccel.y, magAccel.z, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); + finishCalibrationIfExpired(showingScreen, compassCalibrationFileName, highestX, lowestX, highestY, lowestY, highestZ, + lowestZ); } - int highestRealX = highestX - (highestX + lowestX) / 2; - magAccel.x -= (highestX + lowestX) / 2; magAccel.y -= (highestY + lowestY) / 2; magAccel.z -= (highestZ + lowestZ) / 2; @@ -88,23 +59,7 @@ int32_t BMX160Sensor::runOnce() float heading = FusionCompassCalculateHeading(FusionConventionNed, ga, ma); - switch (config.display.compass_orientation) { - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0_INVERTED: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0: - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90_INVERTED: - heading += 90; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180_INVERTED: - heading += 180; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270_INVERTED: - heading += 270; - break; - } + heading = applyCompassOrientation(heading); if (screen) screen->setHeading(heading); #endif @@ -119,15 +74,8 @@ void BMX160Sensor::calibrate(uint16_t forSeconds) sBmx160SensorData_t gAccel; LOG_DEBUG("BMX160 calibration started for %is", forSeconds); sensor.getAllData(&magAccel, NULL, &gAccel); - highestX = magAccel.x, lowestX = magAccel.x; - highestY = magAccel.y, lowestY = magAccel.y; - highestZ = magAccel.z, lowestZ = magAccel.z; - - doCalibration = true; - uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided - endCalibrationAt = millis() + calibrateFor; - if (screen) - screen->setEndCalibration(endCalibrationAt); + seedCalibrationExtrema(magAccel.x, magAccel.y, magAccel.z, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); + startCalibrationWindow(forSeconds); #endif } diff --git a/src/motion/BMX160Sensor.h b/src/motion/BMX160Sensor.h index ddca5767c..d60477521 100644 --- a/src/motion/BMX160Sensor.h +++ b/src/motion/BMX160Sensor.h @@ -17,6 +17,7 @@ class BMX160Sensor : public MotionSensor private: RAK_BMX160 sensor; bool showingScreen = false; + static constexpr const char *compassCalibrationFileName = "/prefs/compass_bmx160.dat"; float highestX = 0, lowestX = 0, highestY = 0, lowestY = 0, highestZ = 0, lowestZ = 0; public: @@ -39,4 +40,4 @@ class BMX160Sensor : public MotionSensor #endif -#endif \ No newline at end of file +#endif diff --git a/src/motion/ICM20948Sensor.cpp b/src/motion/ICM20948Sensor.cpp index ecada2085..e44994a60 100644 --- a/src/motion/ICM20948Sensor.cpp +++ b/src/motion/ICM20948Sensor.cpp @@ -26,7 +26,11 @@ bool ICM20948Sensor::init() return false; // Enable simple Wake on Motion - return sensor->setWakeOnMotion(); + bool wakeOnMotionOk = sensor->setWakeOnMotion(); + if (wakeOnMotionOk) { + loadMagnetometerCalibration(compassCalibrationFileName, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); + } + return wakeOnMotionOk; } #ifdef ICM_20948_INT_PIN @@ -47,7 +51,8 @@ int32_t ICM20948Sensor::runOnce() int32_t ICM20948Sensor::runOnce() { #if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN - if (screen && !screen->isScreenOn() && !config.display.wake_on_tap_or_motion && !config.device.double_tap_as_button_press) { + if (screen && !doCalibration && !screen->isScreenOn() && !config.display.wake_on_tap_or_motion && + !config.device.double_tap_as_button_press) { if (!isAsleep) { LOG_DEBUG("sleeping IMU"); sensor->sleep(true); @@ -69,38 +74,10 @@ int32_t ICM20948Sensor::runOnce() } if (doCalibration) { - - if (!showingScreen) { - powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration - showingScreen = true; - if (screen) - screen->startAlert((FrameCallback)drawFrameCalibration); - } - - if (magX > highestX) - highestX = magX; - if (magX < lowestX) - lowestX = magX; - if (magY > highestY) - highestY = magY; - if (magY < lowestY) - lowestY = magY; - if (magZ > highestZ) - highestZ = magZ; - if (magZ < lowestZ) - lowestZ = magZ; - - uint32_t now = millis(); - if (now > endCalibrationAt) { - doCalibration = false; - endCalibrationAt = 0; - showingScreen = false; - if (screen) - screen->endAlert(); - } - - // LOG_DEBUG("ICM20948 min_x: %.4f, max_X: %.4f, min_Y: %.4f, max_Y: %.4f, min_Z: %.4f, max_Z: %.4f", lowestX, highestX, - // lowestY, highestY, lowestZ, highestZ); + beginCalibrationDisplay(showingScreen); + updateCalibrationExtrema(magX, magY, magZ, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); + finishCalibrationIfExpired(showingScreen, compassCalibrationFileName, highestX, lowestX, highestY, lowestY, highestZ, + lowestZ); } magX -= (highestX + lowestX) / 2; @@ -122,23 +99,7 @@ int32_t ICM20948Sensor::runOnce() float heading = FusionCompassCalculateHeading(FusionConventionNed, ga, ma); - switch (config.display.compass_orientation) { - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0_INVERTED: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_0: - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90_INVERTED: - heading += 90; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180_INVERTED: - heading += 180; - break; - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270: - case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270_INVERTED: - heading += 270; - break; - } + heading = applyCompassOrientation(heading); if (screen) screen->setHeading(heading); #endif @@ -169,26 +130,16 @@ int32_t ICM20948Sensor::runOnce() void ICM20948Sensor::calibrate(uint16_t forSeconds) { #if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN - LOG_DEBUG("Old calibration data: highestX = %f, lowestX = %f, highestY = %f, lowestY = %f, highestZ = %f, lowestZ = %f", - highestX, lowestX, highestY, lowestY, highestZ, lowestZ); - LOG_DEBUG("BMX160 calibration started for %is", forSeconds); + LOG_DEBUG("ICM20948 cal start %is", forSeconds); if (sensor->dataReady()) { sensor->getAGMT(); - highestX = sensor->agmt.mag.axes.x; - lowestX = sensor->agmt.mag.axes.x; - highestY = sensor->agmt.mag.axes.y; - lowestY = sensor->agmt.mag.axes.y; - highestZ = sensor->agmt.mag.axes.z; - lowestZ = sensor->agmt.mag.axes.z; + seedCalibrationExtrema(sensor->agmt.mag.axes.x, sensor->agmt.mag.axes.y, sensor->agmt.mag.axes.z, highestX, lowestX, + highestY, lowestY, highestZ, lowestZ); } else { - highestX = 0, lowestX = 0, highestY = 0, lowestY = 0, highestZ = 0, lowestZ = 0; + seedCalibrationExtrema(0.0f, 0.0f, 0.0f, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); } - doCalibration = true; - uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided - endCalibrationAt = millis() + calibrateFor; - if (screen) - screen->setEndCalibration(endCalibrationAt); + startCalibrationWindow(forSeconds); #endif } // ---------------------------------------------------------------------- @@ -314,11 +265,6 @@ bool ICM20948Singleton::setWakeOnMotion() status = intEnableWOM(true); LOG_DEBUG("ICM20948 init set intEnableWOM - %s", statusString()); return status == ICM_20948_Stat_Ok; - - // Clear any current interrupts - ICM20948_IRQ = false; - clearInterrupts(); - return true; } #endif diff --git a/src/motion/ICM20948Sensor.h b/src/motion/ICM20948Sensor.h index 091cb9a1e..d8369b3ca 100644 --- a/src/motion/ICM20948Sensor.h +++ b/src/motion/ICM20948Sensor.h @@ -83,6 +83,7 @@ class ICM20948Sensor : public MotionSensor ICM20948Singleton *sensor = nullptr; bool showingScreen = false; bool isAsleep = false; + static constexpr const char *compassCalibrationFileName = "/prefs/compass_icm20948.dat"; #ifdef MUZI_BASE float highestX = 449.000000, lowestX = -140.000000, highestY = 422.000000, lowestY = -232.000000, highestZ = 749.000000, lowestZ = 98.000000; @@ -103,4 +104,4 @@ class ICM20948Sensor : public MotionSensor #endif -#endif \ No newline at end of file +#endif diff --git a/src/motion/MotionSensor.cpp b/src/motion/MotionSensor.cpp index d0bfe4e2c..83231aea9 100644 --- a/src/motion/MotionSensor.cpp +++ b/src/motion/MotionSensor.cpp @@ -1,10 +1,37 @@ #include "MotionSensor.h" +#include "FSCommon.h" +#include "SPILock.h" +#include "SafeFile.h" #include "graphics/draw/CompassRenderer.h" #if !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C char timeRemainingBuffer[12]; +namespace +{ +constexpr uint32_t COMPASS_CALIBRATION_MAGIC = 0x4D43414CL; // "MCAL" +constexpr uint16_t COMPASS_CALIBRATION_VERSION = 1; + +struct CompassCalibrationRecord { + uint32_t magic; + uint16_t version; + uint16_t reserved; + float highestX; + float lowestX; + float highestY; + float lowestY; + float highestZ; + float lowestZ; +}; + +bool isRangeValid(float highest, float lowest) +{ + // NaN/Inf guard without pulling in extra math helpers. + return (highest == highest) && (lowest == lowest) && (highest > lowest); +} +} // namespace + // screen is defined in main.cpp extern graphics::Screen *screen; @@ -32,33 +59,237 @@ ScanI2C::I2CPort MotionSensor::devicePort() return device.address.port; } +bool MotionSensor::saveMagnetometerCalibration(const char *filePath, float highestX, float lowestX, float highestY, float lowestY, + float highestZ, float lowestZ) +{ +#ifdef FSCom + if (!isRangeValid(highestX, lowestX) || !isRangeValid(highestY, lowestY) || !isRangeValid(highestZ, lowestZ)) { + return false; + } + + FSCom.mkdir("/prefs"); + CompassCalibrationRecord record = { + COMPASS_CALIBRATION_MAGIC, COMPASS_CALIBRATION_VERSION, 0, highestX, lowestX, highestY, lowestY, highestZ, lowestZ}; + + auto file = SafeFile(filePath, true); + const size_t written = file.write(reinterpret_cast(&record), sizeof(record)); + return (written == sizeof(record)) && file.close(); +#else + return false; +#endif +} + +bool MotionSensor::loadMagnetometerCalibration(const char *filePath, float &highestX, float &lowestX, float &highestY, + float &lowestY, float &highestZ, float &lowestZ) +{ +#ifdef FSCom + CompassCalibrationRecord record = {}; + size_t bytesRead = 0; + + spiLock->lock(); + auto file = FSCom.open(filePath, FILE_O_READ); + if (!file) { + spiLock->unlock(); + return false; + } + bytesRead = file.read(reinterpret_cast(&record), sizeof(record)); + file.close(); + spiLock->unlock(); + + const bool headerValid = (bytesRead == sizeof(record)) && (record.magic == COMPASS_CALIBRATION_MAGIC) && + (record.version == COMPASS_CALIBRATION_VERSION) && (record.reserved == 0U); + const bool rangeValid = isRangeValid(record.highestX, record.lowestX) && isRangeValid(record.highestY, record.lowestY) && + isRangeValid(record.highestZ, record.lowestZ); + if (!headerValid || !rangeValid) { + return false; + } + + highestX = record.highestX; + lowestX = record.lowestX; + highestY = record.highestY; + lowestY = record.lowestY; + highestZ = record.highestZ; + lowestZ = record.lowestZ; + + return true; +#else + return false; +#endif +} + +void MotionSensor::beginCalibrationDisplay(bool &showingScreen) +{ +#if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN + if (!showingScreen) { + powerFSM.trigger(EVENT_PRESS); // keep screen alive during calibration + showingScreen = true; + if (screen) + screen->startAlert((FrameCallback)drawFrameCalibration); + } +#else + (void)showingScreen; +#endif +} + +void MotionSensor::finishCalibrationIfExpired(bool &showingScreen, const char *filePath, float highestX, float lowestX, + float highestY, float lowestY, float highestZ, float lowestZ) +{ + const uint32_t now = millis(); + if ((int32_t)(now - endCalibrationAt) < 0) + return; + + doCalibration = false; + endCalibrationAt = 0; + showingScreen = false; + saveMagnetometerCalibration(filePath, highestX, lowestX, highestY, lowestY, highestZ, lowestZ); + +#if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN + if (screen) { + screen->setEndCalibration(0); + screen->endAlert(); + } +#endif +} + +void MotionSensor::startCalibrationWindow(uint16_t forSeconds) +{ + doCalibration = true; + const uint32_t calibrateFor = static_cast(forSeconds) * 1000U; + endCalibrationAt = millis() + calibrateFor; +#if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN + if (screen) + screen->setEndCalibration(endCalibrationAt); +#endif +} + +void MotionSensor::seedCalibrationExtrema(float x, float y, float z, float &highestX, float &lowestX, float &highestY, + float &lowestY, float &highestZ, float &lowestZ) +{ + highestX = lowestX = x; + highestY = lowestY = y; + highestZ = lowestZ = z; +} + +void MotionSensor::updateCalibrationExtrema(float x, float y, float z, float &highestX, float &lowestX, float &highestY, + float &lowestY, float &highestZ, float &lowestZ) +{ + if (x > highestX) + highestX = x; + if (x < lowestX) + lowestX = x; + if (y > highestY) + highestY = y; + if (y < lowestY) + lowestY = y; + if (z > highestZ) + highestZ = z; + if (z < lowestZ) + lowestZ = z; +} + +float MotionSensor::applyCompassOrientation(float heading) +{ + switch (config.display.compass_orientation) { + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90: + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_90_INVERTED: + return heading + 90; + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180: + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_180_INVERTED: + return heading + 180; + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270: + case meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270_INVERTED: + return heading + 270; + default: + return heading; + } +} + #if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN void MotionSensor::drawFrameCalibration(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { if (screen == nullptr) return; - // int x_offset = display->width() / 2; - // int y_offset = display->height() <= 80 ? 0 : 32; - display->setTextAlignment(TEXT_ALIGN_LEFT); - display->setFont(FONT_MEDIUM); - display->drawString(x, y, "Calibrating\nCompass"); - uint8_t timeRemaining = (screen->getEndCalibration() - millis()) / 1000; - sprintf(timeRemainingBuffer, "( %02d )", timeRemaining); - display->setFont(FONT_SMALL); - display->drawString(x, y + 40, timeRemainingBuffer); + const int16_t width = display->getWidth(); + const int16_t height = display->getHeight(); + const bool compactLayout = (height <= 80); + const int16_t margin = 4; + + const uint32_t now = millis(); + const uint32_t endCalibrationAt = screen->getEndCalibration(); + uint32_t timeRemaining = 0; + if (endCalibrationAt > now) { + timeRemaining = (endCalibrationAt - now + 999) / 1000; + } int16_t compassX = 0, compassY = 0; - uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(display->getWidth(), display->getHeight()); + uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(width, height); + const int16_t compassRadius = compassDiam / 2; // coordinates for the center of the compass/circle if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) { - compassX = x + display->getWidth() - compassDiam / 2 - 5; - compassY = y + display->getHeight() / 2; + compassX = x + width - compassRadius - margin; + compassY = y + height / 2; } else { - compassX = x + display->getWidth() - compassDiam / 2 - 5; - compassY = y + FONT_HEIGHT_SMALL + (display->getHeight() - FONT_HEIGHT_SMALL) / 2; + compassX = x + width - compassRadius - margin; + compassY = y + FONT_HEIGHT_SMALL + (height - FONT_HEIGHT_SMALL) / 2; } + + const int16_t textLeft = x + 1; + const int16_t textRight = compassX - compassRadius - margin; + const int16_t textWidth = textRight - textLeft; + int16_t lineY = y; + + display->setTextAlignment(TEXT_ALIGN_LEFT); + if (textWidth > 12) { + const char *title = "Cal"; + const char *line1 = "Figure-8"; + const char *line2 = "Rotate axes"; + const char *line3 = "Away from metal"; + + display->setFont(FONT_SMALL); + if (!compactLayout && display->getStringWidth("Compass Calibration") <= textWidth) { + display->setFont(FONT_MEDIUM); + title = "Compass Calibration"; + line1 = "Move in figure-8"; + line2 = "Rotate all axes"; + line3 = "Keep from metal"; + display->drawString(textLeft, lineY, title); + lineY += FONT_HEIGHT_MEDIUM; + display->setFont(FONT_SMALL); + } else if (display->getStringWidth("Compass Cal") <= textWidth) { + title = "Compass Cal"; + if (textWidth >= display->getStringWidth("Move in figure-8")) { + line1 = "Move in figure-8"; + line2 = "Rotate all axes"; + line3 = "Keep from metal"; + } + display->drawString(textLeft, lineY, title); + lineY += FONT_HEIGHT_SMALL; + } else { + display->drawString(textLeft, lineY, title); + lineY += FONT_HEIGHT_SMALL; + } + + display->drawString(textLeft, lineY, line1); + lineY += FONT_HEIGHT_SMALL; + display->drawString(textLeft, lineY, line2); + lineY += FONT_HEIGHT_SMALL; + if (!compactLayout || textWidth >= display->getStringWidth(line3)) { + display->drawString(textLeft, lineY, line3); + } + } + + if (textWidth >= display->getStringWidth("000s left")) { + snprintf(timeRemainingBuffer, sizeof(timeRemainingBuffer), "%lus left", (unsigned long)timeRemaining); + } else { + snprintf(timeRemainingBuffer, sizeof(timeRemainingBuffer), "%lus", (unsigned long)timeRemaining); + } + display->setFont(FONT_SMALL); + if (textWidth > 12) { + display->drawString(textLeft, y + height - FONT_HEIGHT_SMALL - 1, timeRemainingBuffer); + } + display->drawCircle(compassX, compassY, compassDiam / 2); graphics::CompassRenderer::drawCompassNorth(display, compassX, compassY, screen->getHeading() * PI / 180, (compassDiam / 2)); } diff --git a/src/motion/MotionSensor.h b/src/motion/MotionSensor.h index 8eb3bf95b..71b71f73a 100644 --- a/src/motion/MotionSensor.h +++ b/src/motion/MotionSensor.h @@ -2,7 +2,7 @@ #ifndef _MOTION_SENSOR_H_ #define _MOTION_SENSOR_H_ -#define MOTION_SENSOR_CHECK_INTERVAL_MS 100 +#define MOTION_SENSOR_CHECK_INTERVAL_MS 50 #define MOTION_SENSOR_CLICK_THRESHOLD 40 #include "../configuration.h" @@ -54,6 +54,20 @@ class MotionSensor static void drawFrameCalibration(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); #endif + bool saveMagnetometerCalibration(const char *filePath, float highestX, float lowestX, float highestY, float lowestY, + float highestZ, float lowestZ); + bool loadMagnetometerCalibration(const char *filePath, float &highestX, float &lowestX, float &highestY, float &lowestY, + float &highestZ, float &lowestZ); + void beginCalibrationDisplay(bool &showingScreen); + void finishCalibrationIfExpired(bool &showingScreen, const char *filePath, float highestX, float lowestX, float highestY, + float lowestY, float highestZ, float lowestZ); + void startCalibrationWindow(uint16_t forSeconds); + static void seedCalibrationExtrema(float x, float y, float z, float &highestX, float &lowestX, float &highestY, + float &lowestY, float &highestZ, float &lowestZ); + static void updateCalibrationExtrema(float x, float y, float z, float &highestX, float &lowestX, float &highestY, + float &lowestY, float &highestZ, float &lowestZ); + static float applyCompassOrientation(float heading); + ScanI2C::FoundDevice device; // Do calibration if true @@ -63,4 +77,4 @@ class MotionSensor #endif -#endif \ No newline at end of file +#endif From c8dac1034869067b3cce43ccc7b75eb150c7a557 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 18 Apr 2026 08:17:44 -0500 Subject: [PATCH 39/67] Add MCP server for interacting with meshtastic devices and testing framework / TUI (#10194) * Start of MCP server and test suite * Add MCP server for interacting with meshtastic devices and testing framework / TUI * Update mcp-server/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix mcp-server review feedback from thread Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/91dc128a-ed50-4d07-8bb2-3dc6623a05f7 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Enhance StreamAPI and PhoneAPI for improved log record handling and concurrency control * Semgrep fixes * Trunk and semgrep fixes * optimize pio streaming tee file writes Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/04e26c6b-6a2b-45be-bbeb-79ae4d0be633 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * chore: remove redundant log handle assignment Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/04e26c6b-6a2b-45be-bbeb-79ae4d0be633 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Consolidate type imports and remove placeholder test files * Add tests for config persistence and more exchange messages * Refactor position test to validate on-demand request/reply behavior * Remove position request/reply test and update README for telemetry behavior * Fix transmit history file to get removed on factory reset --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .claude/commands/README.md | 49 + .claude/commands/diagnose.md | 55 + .claude/commands/repro.md | 65 + .claude/commands/test.md | 42 + .github/copilot-instructions.md | 160 ++ .github/prompts/mcp-diagnose.prompt.md | 57 + .github/prompts/mcp-repro.prompt.md | 67 + .github/prompts/mcp-test.prompt.md | 51 + .gitignore | 2 + .mcp.json | 11 + .trunk/configs/.bandit | 28 +- AGENTS.md | 113 ++ mcp-server/.gitignore | 26 + mcp-server/README.md | 270 +++ mcp-server/pyproject.toml | 39 + mcp-server/run-tests.sh | 236 +++ mcp-server/src/meshtastic_mcp/__init__.py | 3 + mcp-server/src/meshtastic_mcp/__main__.py | 11 + mcp-server/src/meshtastic_mcp/admin.py | 377 ++++ mcp-server/src/meshtastic_mcp/boards.py | 159 ++ mcp-server/src/meshtastic_mcp/cli/__init__.py | 6 + .../src/meshtastic_mcp/cli/_flashlog.py | 73 + mcp-server/src/meshtastic_mcp/cli/_fwlog.py | 96 + mcp-server/src/meshtastic_mcp/cli/_history.py | 127 ++ .../src/meshtastic_mcp/cli/_reproducer.py | 214 ++ mcp-server/src/meshtastic_mcp/cli/test_tui.py | 1782 +++++++++++++++++ mcp-server/src/meshtastic_mcp/config.py | 137 ++ mcp-server/src/meshtastic_mcp/connection.py | 84 + mcp-server/src/meshtastic_mcp/devices.py | 75 + mcp-server/src/meshtastic_mcp/flash.py | 447 +++++ mcp-server/src/meshtastic_mcp/hw_tools.py | 243 +++ mcp-server/src/meshtastic_mcp/info.py | 103 + mcp-server/src/meshtastic_mcp/pio.py | 295 +++ mcp-server/src/meshtastic_mcp/registry.py | 98 + .../src/meshtastic_mcp/serial_session.py | 216 ++ mcp-server/src/meshtastic_mcp/server.py | 590 ++++++ mcp-server/src/meshtastic_mcp/userprefs.py | 532 +++++ mcp-server/tests/README.md | 116 ++ mcp-server/tests/__init__.py | 0 mcp-server/tests/_port_discovery.py | 118 ++ mcp-server/tests/admin/__init__.py | 0 .../tests/admin/test_channel_url_roundtrip.py | 57 + .../tests/admin/test_config_roundtrip.py | 106 + .../tests/admin/test_owner_survives_reboot.py | 59 + mcp-server/tests/conftest.py | 1041 ++++++++++ mcp-server/tests/fleet/__init__.py | 0 .../fleet/test_psk_seed_isolates_runs.py | 43 + mcp-server/tests/mesh/__init__.py | 0 mcp-server/tests/mesh/_receive.py | 220 ++ mcp-server/tests/mesh/test_bidirectional.py | 83 + .../tests/mesh/test_broadcast_delivers.py | 45 + mcp-server/tests/mesh/test_direct_with_ack.py | 105 + mcp-server/tests/mesh/test_mesh_formation.py | 39 + mcp-server/tests/mesh/test_traceroute.py | 147 ++ mcp-server/tests/monitor/__init__.py | 0 .../tests/monitor/test_boot_log_no_panic.py | 63 + mcp-server/tests/provisioning/__init__.py | 0 .../provisioning/test_admin_key_baked.py | 83 + .../test_bake_region_modem_slot.py | 60 + .../test_unset_region_blocks_tx.py | 108 + .../test_userprefs_survive_factory_reset.py | 90 + mcp-server/tests/telemetry/__init__.py | 0 .../test_device_telemetry_broadcast.py | 77 + .../telemetry/test_telemetry_request_reply.py | 187 ++ mcp-server/tests/test_00_bake.py | 291 +++ mcp-server/tests/tool_coverage.py | 145 ++ mcp-server/tests/unit/__init__.py | 0 mcp-server/tests/unit/test_boards.py | 72 + mcp-server/tests/unit/test_pio_wrapper.py | 61 + mcp-server/tests/unit/test_testing_profile.py | 120 ++ mcp-server/tests/unit/test_userprefs_parse.py | 115 ++ src/mesh/NodeDB.cpp | 7 + src/mesh/PhoneAPI.cpp | 20 +- src/mesh/StreamAPI.cpp | 45 +- src/mesh/StreamAPI.h | 24 + src/mesh/TransmitHistory.cpp | 21 + src/mesh/TransmitHistory.h | 7 + 77 files changed, 10701 insertions(+), 13 deletions(-) create mode 100644 .claude/commands/README.md create mode 100644 .claude/commands/diagnose.md create mode 100644 .claude/commands/repro.md create mode 100644 .claude/commands/test.md create mode 100644 .github/prompts/mcp-diagnose.prompt.md create mode 100644 .github/prompts/mcp-repro.prompt.md create mode 100644 .github/prompts/mcp-test.prompt.md create mode 100644 .mcp.json create mode 100644 AGENTS.md create mode 100644 mcp-server/.gitignore create mode 100644 mcp-server/README.md create mode 100644 mcp-server/pyproject.toml create mode 100755 mcp-server/run-tests.sh create mode 100644 mcp-server/src/meshtastic_mcp/__init__.py create mode 100644 mcp-server/src/meshtastic_mcp/__main__.py create mode 100644 mcp-server/src/meshtastic_mcp/admin.py create mode 100644 mcp-server/src/meshtastic_mcp/boards.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/__init__.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/_flashlog.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/_fwlog.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/_history.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/_reproducer.py create mode 100644 mcp-server/src/meshtastic_mcp/cli/test_tui.py create mode 100644 mcp-server/src/meshtastic_mcp/config.py create mode 100644 mcp-server/src/meshtastic_mcp/connection.py create mode 100644 mcp-server/src/meshtastic_mcp/devices.py create mode 100644 mcp-server/src/meshtastic_mcp/flash.py create mode 100644 mcp-server/src/meshtastic_mcp/hw_tools.py create mode 100644 mcp-server/src/meshtastic_mcp/info.py create mode 100644 mcp-server/src/meshtastic_mcp/pio.py create mode 100644 mcp-server/src/meshtastic_mcp/registry.py create mode 100644 mcp-server/src/meshtastic_mcp/serial_session.py create mode 100644 mcp-server/src/meshtastic_mcp/server.py create mode 100644 mcp-server/src/meshtastic_mcp/userprefs.py create mode 100644 mcp-server/tests/README.md create mode 100644 mcp-server/tests/__init__.py create mode 100644 mcp-server/tests/_port_discovery.py create mode 100644 mcp-server/tests/admin/__init__.py create mode 100644 mcp-server/tests/admin/test_channel_url_roundtrip.py create mode 100644 mcp-server/tests/admin/test_config_roundtrip.py create mode 100644 mcp-server/tests/admin/test_owner_survives_reboot.py create mode 100644 mcp-server/tests/conftest.py create mode 100644 mcp-server/tests/fleet/__init__.py create mode 100644 mcp-server/tests/fleet/test_psk_seed_isolates_runs.py create mode 100644 mcp-server/tests/mesh/__init__.py create mode 100644 mcp-server/tests/mesh/_receive.py create mode 100644 mcp-server/tests/mesh/test_bidirectional.py create mode 100644 mcp-server/tests/mesh/test_broadcast_delivers.py create mode 100644 mcp-server/tests/mesh/test_direct_with_ack.py create mode 100644 mcp-server/tests/mesh/test_mesh_formation.py create mode 100644 mcp-server/tests/mesh/test_traceroute.py create mode 100644 mcp-server/tests/monitor/__init__.py create mode 100644 mcp-server/tests/monitor/test_boot_log_no_panic.py create mode 100644 mcp-server/tests/provisioning/__init__.py create mode 100644 mcp-server/tests/provisioning/test_admin_key_baked.py create mode 100644 mcp-server/tests/provisioning/test_bake_region_modem_slot.py create mode 100644 mcp-server/tests/provisioning/test_unset_region_blocks_tx.py create mode 100644 mcp-server/tests/provisioning/test_userprefs_survive_factory_reset.py create mode 100644 mcp-server/tests/telemetry/__init__.py create mode 100644 mcp-server/tests/telemetry/test_device_telemetry_broadcast.py create mode 100644 mcp-server/tests/telemetry/test_telemetry_request_reply.py create mode 100644 mcp-server/tests/test_00_bake.py create mode 100644 mcp-server/tests/tool_coverage.py create mode 100644 mcp-server/tests/unit/__init__.py create mode 100644 mcp-server/tests/unit/test_boards.py create mode 100644 mcp-server/tests/unit/test_pio_wrapper.py create mode 100644 mcp-server/tests/unit/test_testing_profile.py create mode 100644 mcp-server/tests/unit/test_userprefs_parse.py diff --git a/.claude/commands/README.md b/.claude/commands/README.md new file mode 100644 index 000000000..3767dac98 --- /dev/null +++ b/.claude/commands/README.md @@ -0,0 +1,49 @@ +# Claude Code slash commands for the mcp-server test suite + +Three AI-assisted workflows wrapping `mcp-server/run-tests.sh` and the meshtastic MCP tools. Each one has a twin in `.github/prompts/` for Copilot users. + +| Slash command | What it does | Copilot equivalent | +| --------------------- | ------------------------------------------------------------------------- | ---------------------------------------- | +| `/test [args]` | Runs the test suite (auto-detects hardware) and interprets failures | `.github/prompts/mcp-test.prompt.md` | +| `/diagnose [role]` | Read-only device health report via the meshtastic MCP tools | `.github/prompts/mcp-diagnose.prompt.md` | +| `/repro [n=5]` | Re-runs one test N times, diffs firmware logs between passes and failures | `.github/prompts/mcp-repro.prompt.md` | + +## Why two surfaces + +The Claude Code commands and Copilot prompts cover the same three workflows but each speaks its host's idiom: + +- **Claude Code** (`/test`) uses `$ARGUMENTS` for pass-through, has direct access to Bash + all MCP tools registered in the user's settings, and runs in the terminal context. +- **Copilot** (`/mcp-test`) runs in VS Code's agent mode; it has terminal + MCP access too but typically asks the operator to confirm inputs interactively. + +A contributor using either IDE gets equivalent assistance. Keep the two in sync when behavior changes — the diff of intent should be minimal. + +## House rules + +- **No destructive writes without explicit operator approval.** Skills that could reflash, factory-reset, or reboot a device must describe the action and stop — the operator authorizes. +- **Interpret failures, don't just echo them.** The skill body should pull firmware log lines from `mcp-server/tests/report.html` (the `Meshtastic debug` section, attached by `tests/conftest.py::pytest_runtest_makereport`) and classify the failure. +- **Keep MCP tool calls sequential per port.** SerialInterface holds an exclusive port lock; two parallel tool calls on the same port deadlock. +- **Never speculate about root cause.** If the evidence doesn't support a classification, say "unknown" and list what you'd need to disambiguate. + +## Adding a new command + +1. Write the Claude Code version at `.claude/commands/.md` with YAML frontmatter: + + ```yaml + --- + description: one-line purpose (used for auto-invocation by the model) + argument-hint: [optional-hint] + --- + ``` + +2. Write the Copilot equivalent at `.github/prompts/mcp-.prompt.md` with: + + ```yaml + --- + mode: agent + description: ... + --- + ``` + +3. Add the row to the table above. Cross-link in both bodies. + +4. Smoke-test on Claude Code first (`/` should appear in autocomplete), then in VS Code Copilot (`/mcp-` in Chat). diff --git a/.claude/commands/diagnose.md b/.claude/commands/diagnose.md new file mode 100644 index 000000000..45aa937a5 --- /dev/null +++ b/.claude/commands/diagnose.md @@ -0,0 +1,55 @@ +--- +description: Produce a device health report using the meshtastic MCP tools (device_info, list_nodes, get_config, short serial log capture) +argument-hint: [role=all|nrf52|esp32s3|] +--- + +# `/diagnose` — device health report + +Call the meshtastic MCP tool bundle and format a structured health report for one or all detected devices. Zero guesswork for the operator. + +## What to do + +1. **Enumerate hardware.** Call `mcp__meshtastic__list_devices(include_unknown=True)`. For each entry where `likely_meshtastic=True`, capture `port`, `vid`, `pid`, `description`. + +2. **Filter by `$ARGUMENTS`**: + - No args, `all` → every likely-meshtastic device. + - `nrf52` → only devices with `vid == 0x239a`. + - `esp32s3` → only devices with `vid == 0x303a` or `vid == 0x10c4`. + - A `/dev/cu.*` path → only that one port. + - Anything else → treat as a substring match against the `port` string. + +3. **For each selected device, in sequence (NOT parallel — SerialInterface holds an exclusive port lock):** + - `mcp__meshtastic__device_info(port=

)` — captures `my_node_num`, `long_name`, `short_name`, `firmware_version`, `hw_model`, `region`, `num_nodes`, `primary_channel`. + - `mcp__meshtastic__list_nodes(port=

)` — count of peers, which ones have `publicKey` set, SNR/RSSI distribution. + - `mcp__meshtastic__get_config(section="lora", port=

)` — region, preset, channel_num, tx_power, hop_limit. + - Optionally, if the device seems unhappy (fails to connect, `num_nodes==1` when ≥2 are plugged in, missing firmware*version), open a short firmware log window: `mcp__meshtastic__serial_open(port=

, env=)`, wait 3s, `serial_read(session_id=, max_lines=100)`, `serial_close(session_id=)`. The env should be inferred from the VID map in `mcp-server/run-tests.sh` (nrf52 → rak4631, esp32s3 → heltec-v3) unless `MESHTASTIC_MCP_ENV*` is set. + +4. **Render per-device report** as: + + ```text + [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 + owner : Meshtastic 40eb / 40eb + region/band : US, channel 88, LONG_FAST + tx_power : 30 dBm, hop_limit=3 + peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) + primary ch : McpTest + firmware : no panics in last 3s; NodeInfoModule emitted 2 broadcasts + ``` + + Keep it scannable. If a field is missing or abnormal (no pubkey for a known peer, region=UNSET, num_nodes inconsistent with the hub), flag it inline with a short `⚠︎ `. + +5. **Cross-device correlation** (only when >1 device is inspected): + - Do both sides see each other in `nodesByNum`? If one does and the other doesn't, that's asymmetric NodeInfo — flag it. + - Do the LoRa configs match? (region, channel_num, modem_preset should all agree; mismatch = no mesh) + - Do the primary channel NAMES match? Mismatch = different PSK = no decode. + +6. **Suggest next actions only for specific, recognisable failure modes**: + - Stale PKI pubkey one-way → "run `/test tests/mesh/test_direct_with_ack.py` — the retry + nodeinfo-ping heals this in the test path." + - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." + - Device unreachable → point at touch_1200bps + the CP2102-wedged-driver note in run-tests.sh. + +## What NOT to do + +- No writes. No `set_config`, no `reboot`, no `factory_reset`. This is a read-only diagnostic skill — if the operator wants to change state, they'll ask explicitly. +- No `flash` / `erase_and_flash`. Those are separate escalations. +- No holding SerialInterface across tool calls — open, query, close; next device. The port lock is exclusive. diff --git a/.claude/commands/repro.md b/.claude/commands/repro.md new file mode 100644 index 000000000..52dcf222b --- /dev/null +++ b/.claude/commands/repro.md @@ -0,0 +1,65 @@ +--- +description: Re-run a specific test N times in isolation to triage flakes, diff firmware logs between passes and failures +argument-hint: [count=5] +--- + +# `/repro` — flakiness triage for one test + +Re-run a single pytest node ID N times in isolation, track pass rate, and surface what's _different_ in the firmware logs between the passing attempts and the failing ones. Turns "it's flaky, I guess" into "it fails when X, passes when Y." + +## What to do + +1. **Parse `$ARGUMENTS`**: first token is the pytest node id (e.g. `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[nrf52->esp32s3]`); second token is an integer count (default `5`, cap at `20`). If the first token doesn't look like a test path (no `::` and no `tests/` prefix), treat the whole `$ARGUMENTS` as a `-k` filter instead. + +2. **Sanity-check the hub first** (so we're not measuring "nothing plugged in" N times): call `mcp__meshtastic__list_devices`. If the test name contains `nrf52` or `esp32s3` and the matching VID isn't present, stop and report — re-running won't help. + +3. **Loop N times**. For each iteration: + + ```bash + ./mcp-server/run-tests.sh --tb=short -p no:cacheprovider + ``` + + Capture: exit code, duration, and (on failure) the `Meshtastic debug` firmware log section from `mcp-server/tests/report.html`. `-p no:cacheprovider` suppresses pytest's `.pytest_cache` writes so iterations don't influence each other. + +4. **Track a small structured tally**: + + ```text + attempt 1: PASS (42s) + attempt 2: FAIL (128s) ← firmware log 200-line tail captured + attempt 3: PASS (39s) + attempt 4: FAIL (121s) + attempt 5: PASS (41s) + -------------------------------------- + pass rate: 3/5 (60%) | mean duration: 74s + ``` + +5. **On mixed outcomes**: diff the firmware log tails between a representative passing attempt and a representative failing attempt. Focus on: + - Error-level lines only present in failures (`PKI_UNKNOWN_PUBKEY`, `Alloc an err=`, `Skip send`, `No suitable channel`) + - Timing around the assertion event — did a broadcast go out, was there an ACK, did NAK fire? + - Device state fields that changed (nodesByNum entries, region/preset, channel_num) + + Surface the top 3 differences as a "passes when / fails when" table. Don't dump full logs — pull specific lines with uptime timestamps. + +6. **Classify the flake** into one of: + - **LoRa airtime collision** → pass rate improves with fewer concurrent transmitters; propose a `time.sleep` gap or retry bump in the test body. + - **PKI key staleness** → fails on first attempt, passes after self-heal; existing retry loop in `test_direct_with_ack.py` handles this. + - **NodeInfo cooldown** → `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs `broadcast_nodeinfo_ping()` warmup. + - **Hardware-specific** (one direction fails, other passes; one device's firmware is older; driver wedged) → specific recovery pointer. + - **Genuinely unknown** → say so; don't invent a root cause. + +7. **Report back** with: + - Pass rate and mean duration. + - Classification + evidence (the specific log lines that support it). + - A suggested next step (re-run with specific args, open `/diagnose`, edit a specific test file, nothing). + +## Examples + +- `/repro tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[esp32s3->nrf52] 10` — runs 10 times, diffs firmware logs. +- `/repro broadcast_delivers` — no `::`, no `tests/`, so interpreted as `-k broadcast_delivers`; runs every matching test the default 5 times. +- `/repro tests/telemetry/test_device_telemetry_broadcast.py 3` — shorter run for a slow test. + +## Constraints + +- Don't exceed `count=20` per invocation — airtime and USB wear add up. If the user asks for 50, negotiate down. +- Don't rebuild firmware as part of triage; flakes that only reproduce under different firmware belong in a separate session. +- If the FIRST attempt fails AND the rest all pass, that's a classic "state leak from a prior test" → say so and suggest running with `--force-bake` or starting from a clean state rather than chasing the first failure. diff --git a/.claude/commands/test.md b/.claude/commands/test.md new file mode 100644 index 000000000..986ee1f31 --- /dev/null +++ b/.claude/commands/test.md @@ -0,0 +1,42 @@ +--- +description: Run the mcp-server test suite (auto-detects devices) and interpret the results +argument-hint: [pytest-args] +--- + +# `/test` — mcp-server test runner with interpretation + +Run `mcp-server/run-tests.sh` and make sense of the output so the operator doesn't have to. + +## What to do + +1. **Invoke the wrapper.** From the firmware repo root, run: + + ```bash + ./mcp-server/run-tests.sh $ARGUMENTS + ``` + + The wrapper auto-detects connected Meshtastic devices, maps each to its PlatformIO env, exports the required `MESHTASTIC_MCP_ENV_*` env vars, and invokes pytest. If the user passed no arguments, the wrapper supplies a sensible default set (`tests/ --html=tests/report.html --self-contained-html --junitxml=tests/junit.xml -v --tb=short`). A `--report-log=tests/reportlog.jsonl` arg is always appended (unless the operator passed their own). `--assume-baked` is deliberately NOT in the defaults — `test_00_bake.py` has its own skip-if-already-baked check and runs the ~8 s verification by default. Operators can opt into the fast path with `--assume-baked`, or force a reflash with `--force-bake`. + +2. **Read the pre-flight header.** First ~6 lines print the detected hub (role → port → env). If that line reads `detected hub : (none)`, the wrapper will narrow to `tests/unit` only — say so explicitly in your summary so the operator knows hardware tiers were skipped. + +3. **On pass**: one-line summary of the form `N passed, M skipped in `. Don't enumerate the 52 test names — the user can read those. Do mention if any test was SKIPPED for a NON-placeholder reason (e.g. "role not present on hub" is worth flagging). + +4. **On failure**: for every FAILED test, open `mcp-server/tests/report.html` and extract the `Meshtastic debug` section for that test. pytest-html embeds the firmware log stream + device state dump there; the 200-line firmware log tail is usually enough to explain the failure. Summarise: which test, one-line assertion message, the firmware log lines that matter (things like `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`). + +5. **Classify the failure** as one of: + - **Transient/flake**: LoRa collision, timing-sensitive assertion, first-attempt NAK + successful retry pattern. Propose `/repro ` to confirm. + - **Environmental**: device unreachable, port busy, CP2102 driver wedged. Suggest the specific recovery (replug USB, `touch_1200bps`, check `git status userPrefs.jsonc`). + - **Regression**: same assertion fails repeatedly, firmware log shows a new/unusual error. Surface the diff between expected and observed, identify the module likely responsible. + +6. **Never run destructive recovery automatically.** If a failure looks like it needs a reflash, factory*reset, or USB replug, \_describe what to do* — don't execute. The operator decides. + +## Arguments handling + +- No args → wrapper's defaults (full suite). +- `$ARGUMENTS` passed verbatim to the wrapper, which passes them to pytest. +- Common operator invocations: `/test tests/mesh`, `/test tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip`, `/test --force-bake`, `/test -k telemetry`. + +## Side-effects to mention in summary + +- The session fixture snapshots `userPrefs.jsonc` at session start and restores at teardown (plus on `atexit`). After a clean run, `git status userPrefs.jsonc` should be empty. If the wrapper's pre-flight printed a warning about a stale sidecar, call that out — means a prior session crashed. +- `mcp-server/tests/report.html` and `junit.xml` are regenerated on every run; the HTML is self-contained (shareable). diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 24e11bd4d..d12244229 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -429,6 +429,8 @@ Most workflows can be triggered manually via `workflow_dispatch` for testing. ## Testing +### Native unit tests (C++) + Unit tests in `test/` directory with 12 test suites: - `test_crypto/` - Cryptography @@ -446,6 +448,164 @@ Run with: `pio test -e native` Simulation testing: `bin/test-simulator.sh` +### Hardware-in-the-loop tests (`mcp-server/tests/`) + +Separate pytest suite that exercises real USB-connected Meshtastic devices. See the **MCP Server & Hardware Test Harness** section below for invocation, tier layout, and agent usage rules. + +## MCP Server & Hardware Test Harness + +The `mcp-server/` directory houses a firmware-aware [MCP](https://modelcontextprotocol.io/) server plus a pytest-based integration suite. AI agents that speak MCP get a well-defined tool surface for flashing, configuring, and inspecting physical Meshtastic devices — use it instead of hand-rolling `pio` or `meshtastic --port` calls where possible. `mcp-server/README.md` is the operator-facing setup doc; this section is the agent-facing usage contract. + +The repo registers the server via `.mcp.json` at the repo root — Claude Code picks it up automatically once `mcp-server/.venv/` is built (`cd mcp-server && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'`). + +### When to use which surface + +| Goal | Tool | +| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| Find a connected device | `mcp__meshtastic__list_devices` | +| Read a live node's config/state | `mcp__meshtastic__device_info`, `list_nodes`, `get_config` | +| Mutate a device (owner, region, channels, reboot) | `set_owner`, `set_config`, `set_channel_url`, `reboot`, `shutdown`, `factory_reset` — all require `confirm=True` | +| Flash firmware to a variant | `pio_flash` (any arch) or `erase_and_flash` (ESP32 factory install) | +| Stream serial logs while debugging | `serial_open` → `serial_read` loop → `serial_close` | +| Administer `userPrefs.jsonc` build-time constants | `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest` | +| Run the regression suite | `./mcp-server/run-tests.sh` (or `/test` slash command) | +| Diagnose a specific device | `/diagnose [role]` slash command (read-only) | +| Triage a flaky test | `/repro [count]` slash command | + +**One MCP call per port at a time.** `SerialInterface` holds an exclusive OS-level lock on the serial port for its lifetime. If a `serial_*` session is open on `/dev/cu.usbmodem101`, calling `device_info` on the same port will fail fast pointing at the active session. Sequence calls: open → read/mutate → close, then next device. Never parallelize tool calls on the same port. + +### MCP tool surface (~32 tools) + +Grouped by purpose. Full argument shapes in `mcp-server/README.md`; a few high-value signatures are called out here. + +- **Discovery & metadata**: `list_devices`, `list_boards`, `get_board` +- **Build & flash**: `build`, `clean`, `pio_flash`, `erase_and_flash` (ESP32 only), `update_flash` (ESP32 OTA), `touch_1200bps` +- **Serial sessions** (long-running, 10k-line ring buffer): `serial_open`, `serial_read`, `serial_list`, `serial_close` +- **Device reads**: `device_info`, `list_nodes` +- **Device writes** (all require `confirm=True`): `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `reboot`, `shutdown`, `factory_reset`, `set_debug_log_api` +- **userPrefs admin** (build-time constants, not runtime config): `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest`, `userprefs_testing_profile` +- **Vendor escape hatches**: `esptool_chip_info`, `esptool_erase_flash`, `esptool_raw`, `nrfutil_dfu`, `nrfutil_raw`, `picotool_info`, `picotool_load`, `picotool_raw` + +`confirm=True` is a tool-level gate on top of whatever permission prompt your MCP host shows. **Don't bypass it** by asking the host to auto-approve — it exists specifically because MCP hosts sometimes remember "always allow this tool" and that's dangerous for `factory_reset` and `erase_and_flash`. + +### Hardware test suite (`mcp-server/run-tests.sh`) + +The wrapper auto-detects connected devices (VID → role map: `0x239A` → `nrf52`, `0x303A`/`0x10C4` → `esp32s3`), maps each role to a PlatformIO env (`nrf52` → `rak4631`, `esp32s3` → `heltec-v3`, overridable via `MESHTASTIC_MCP_ENV_`), then invokes pytest. Zero pre-flight config needed from the operator. + +Suite tiers (collected + run in this order via `pytest_collection_modifyitems`): + +1. `tests/unit/` — pure Python (boards parse, pio wrapper, userPrefs parse, testing profile). No hardware. +2. `tests/test_00_bake.py` — flashes each detected device with current `userPrefs.jsonc` merged with the session's test profile. Has its own skip-if-already-baked check comparing region + primary channel to the session profile; skips cheaply on warm devices. +3. `tests/mesh/` — multi-device mesh: bidirectional send, broadcast delivery, direct-with-ACK, mesh formation within 60s. Parametrized `[nrf52->esp32s3]` and `[esp32s3->nrf52]`. +4. `tests/telemetry/` — `DEVICE_METRICS_APP` broadcast timing. +5. `tests/monitor/` — boot-log panic check. +6. `tests/fleet/` — PSK seed session isolation. +7. `tests/admin/` — channel URL roundtrip, owner persistence across reboot. +8. `tests/provisioning/` — region + modem + slot bake, admin key presence, `UNSET` region blocks TX, userPrefs survive factory reset. + +Invocation patterns: + +```bash +./mcp-server/run-tests.sh # full suite (auto-bake-if-needed) +./mcp-server/run-tests.sh --force-bake # reflash before testing +./mcp-server/run-tests.sh --assume-baked # skip bake (caller vouches for device state) +./mcp-server/run-tests.sh tests/mesh # one tier +./mcp-server/run-tests.sh tests/mesh/test_direct_with_ack.py # one file +./mcp-server/run-tests.sh -k telemetry # name filter +``` + +**No hardware detected?** The wrapper auto-narrows to `tests/unit/` only and prints `detected hub : (none)` in the pre-flight header. Agents interpreting the output should call this out explicitly — a 52-test green run without hardware is qualitatively different from a 12-unit-test green run. + +**Artifacts every run produces:** + +- `mcp-server/tests/report.html` — self-contained pytest-html. Each test gets a `Meshtastic debug` section with the tail of firmware log + device state dump. **Open this first** on failures; it's the canonical evidence source. +- `mcp-server/tests/junit.xml` — CI-parseable. +- `mcp-server/tests/reportlog.jsonl` — pytest-reportlog stream (`$report_type` keyed JSONL). Consumed by the live TUI. +- `mcp-server/tests/fwlog.jsonl` — firmware log mirror from the `meshtastic.log.line` pubsub topic. Populated by the `_firmware_log_stream` autouse session fixture. + +### Live TUI (`meshtastic-mcp-test-tui`) + +A Textual-based live view that wraps `run-tests.sh`. Tails reportlog for per-test state, streams firmware logs, polls device state at startup + post-run (gated out of the active run because `hub_devices` holds exclusive port locks). Key bindings: + +| Key | Action | +| --- | ------------------------------------------------------------------------------------------------------------ | +| `r` | re-run focused test (leaf → that node id; internal node → directory or `-k`) | +| `f` | filter tree by substring | +| `d` | failure detail modal (pulls `longrepr` + captured stdout from the reportlog) | +| `g` | export reproducer bundle (tar.gz with README, test_report.json, time-filtered fwlog, devices.json, env.json) | +| `l` | toggle firmware log pane | +| `x` | tool coverage modal | +| `c` | cross-run history sparkline | +| `q` | quit (SIGINT → SIGTERM → SIGKILL escalation, 5-s windows each) | + +Launch: + +```bash +cd mcp-server +.venv/bin/meshtastic-mcp-test-tui # full suite +.venv/bin/meshtastic-mcp-test-tui tests/mesh # args pass through to pytest +``` + +The plain CLI stays primary; the TUI is for operators who want a live dashboard. Both consume the same `run-tests.sh`. + +### Slash commands (Claude Code + Copilot) + +Three AI-assisted workflows wrap the test harness. Claude Code operators get `/test`, `/diagnose`, `/repro`; Copilot operators get `/mcp-test`, `/mcp-diagnose`, `/mcp-repro`. Bodies: + +- `.claude/commands/{test,diagnose,repro}.md` +- `.github/prompts/mcp-{test,diagnose,repro}.prompt.md` + +`.claude/commands/README.md` is the index. + +House rules for agents running these prompts: + +- **Interpret failures, don't just echo them.** Pull firmware log tails from `report.html` and classify each failure as transient / environmental / regression. Use the exact format in `.claude/commands/test.md`. +- **No destructive writes without operator approval.** Any skill that could reflash, factory-reset, or reboot a device must describe the action and stop. The operator authorizes. +- **Sequential MCP calls per port.** See above. +- **"Unknown" is a valid classification.** If evidence doesn't support a root cause, say so and list what would disambiguate. Do not invent. + +### Key fixtures (test authors + agents debugging) + +`mcp-server/tests/conftest.py` provides: + +- **`_session_userprefs`** (autouse session) — snapshots `userPrefs.jsonc` at session start, merges the session test profile via `userprefs.merge_active(test_profile)`, restores at teardown. Four layers of safety: pytest teardown + `atexit` + sidecar file (`userPrefs.jsonc.mcp-session-bak`) + startup self-heal in `run-tests.sh`. **Do not edit `userPrefs.jsonc` from inside a test.** +- **`_firmware_log_stream`** (autouse session) — subscribes to `meshtastic.log.line` pubsub on every connected `SerialInterface` and mirrors lines to `tests/fwlog.jsonl`. Drives the TUI firmware-log pane. +- **`_debug_log_buffer`** (autouse per-test) — captures last 200 firmware log lines + device state for attachment to the pytest-html `Meshtastic debug` section on failure. +- **`hub_devices`** (session) — `dict[role, SerialInterface]` with session-long exclusive port locks. Reason the TUI's device poller is gated to startup + post-run only. +- **`baked_mesh`** — parametrized mesh-pair fixture; depends on `test_00_bake`. `pytest_generate_tests` in `conftest.py` auto-generates `[nrf52->esp32s3]` and `[esp32s3->nrf52]` variants. +- **`test_profile`** — session-scoped dict: region, primary channel, admin key, PSK seed. Derived from `MESHTASTIC_MCP_SEED` (defaults to `mcp--`). + +### Firmware integration points tied to the test harness + +Two firmware changes exist specifically so the test harness works reliably. **Keep these in mind when touching related code.** + +- **`src/mesh/StreamAPI.cpp` + `StreamAPI.h`** — `emitLogRecord` uses a dedicated `fromRadioScratchLog` + `txBufLog` pair and a `concurrency::Lock streamLock`. Before this fix, `debug_log_api_enabled=true` would tear `FromRadio` protobufs on the serial transport because `emitTxBuffer` and `emitLogRecord` shared a single scratch buffer. The conftest enables the log stream session-wide; without this fix the device would corrupt its own FromRadio replies mid-session. +- **`src/mesh/PhoneAPI.cpp`** — `ToRadio` `Heartbeat(nonce=1)` triggers `nodeInfoModule->sendOurNodeInfo(NODENUM_BROADCAST, true, 0, true)` for serial clients, mirroring the pre-existing behavior for TCP/UDP clients in `PacketAPI.cpp`. The mesh tests rely on this to force a NodeInfo broadcast right after connect so the peer discovers them before the test's first assertion. + +If you're modifying `StreamAPI`, `PhoneAPI`, `NodeInfoModule`, or `userPrefs` flow, run `./mcp-server/run-tests.sh` at minimum before asking for review. + +### Recovery playbooks + +| Symptom | First check | Fix | +| ---------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `userPrefs.jsonc` dirty after test run | `git status --porcelain userPrefs.jsonc` | If non-empty, re-run `./mcp-server/run-tests.sh` once — the pre-flight self-heal restores from sidecar. If still dirty, `git checkout userPrefs.jsonc`. | +| Port busy / wedged CP2102 on macOS | `lsof /dev/cu.usbserial-0001` | Kill the holder. USB replug if the kernel still reports busy. Often a stale `pio device monitor` or zombie `meshtastic_mcp` process. | +| nRF52 appears unresponsive | `list_devices` shows VID `0x239A` but `device_info` times out | `touch_1200bps(port=...)` drops it into the DFU bootloader → `pio_flash` re-installs. | +| Multiple MCP server processes | `ps aux \| grep meshtastic_mcp` shows >1 | Kill all but the one your MCP host spawned. Zombies hold ports and break tests. | +| Mesh formation fails, one side sees peer but other doesn't | `/diagnose` (or `list_nodes` on both sides) | Asymmetric NodeInfo. `test_direct_with_ack` has a heal path; `/repro` it a few times. If persistent, both devices' clocks may be out of sync with their NodeInfo cooldown. | +| "role not present on hub" in skip reasons | `list_devices` | Expected if a device is unplugged. Reconnect before re-running the tier. | +| Tests fail only on first attempt then pass on rerun | — | State leak from a prior session. Run with `--force-bake` to reset to a known state. | + +### Never do these without asking + +- `factory_reset` — wipes node identity; regenerates PKI keypair. Mesh peers will reject old DMs until re-exchange. Legitimate only when the operator explicitly wants it. +- `erase_and_flash` — full chip erase; destroys all on-device state. +- `esptool_erase_flash` / `esptool_raw` write/erase — bypasses pio's safety chain. +- `set_config` on `lora.region` — changes regulatory domain; requires physical-location context the operator has and the agent doesn't. +- `reboot` / `shutdown` mid-test — breaks fixture invariants. +- `push -f`, `rebase -i`, `reset --hard`, or any history-rewriting git operation. +- Clicking computer-use tools on web links in Mail/Messages/PDFs — open URLs via the claude-in-chrome MCP so the extension's link-safety checks apply. + ## Resources - [Documentation](https://meshtastic.org/docs/) diff --git a/.github/prompts/mcp-diagnose.prompt.md b/.github/prompts/mcp-diagnose.prompt.md new file mode 100644 index 000000000..c86826030 --- /dev/null +++ b/.github/prompts/mcp-diagnose.prompt.md @@ -0,0 +1,57 @@ +--- +mode: agent +description: Device health report via the meshtastic MCP tools (Copilot equivalent of the Claude Code /diagnose slash command) +--- + +# `/mcp-diagnose` — device health report + +Equivalent of `.claude/commands/diagnose.md`. Use when the operator asks to "check the devices", "what's the mesh looking like", "is nrf52 alive", etc. + +This prompt assumes the meshtastic MCP server is registered with your VS Code Copilot agent. If it isn't, fall back to running `./mcp-server/run-tests.sh tests/unit` plus a short `device_info` script via the terminal. + +## What to do + +1. **Enumerate hardware** via the `list_devices` MCP tool (with `include_unknown=True`). For each entry where `likely_meshtastic=True`, capture `port`, `vid`, `pid`, `description`. + +2. **Apply the operator's filter** (if any): + - No filter → every likely-meshtastic device. + - `nrf52` → `vid == 0x239a` + - `esp32s3` → `vid == 0x303a` or `vid == 0x10c4` + - A `/dev/cu.*` path → only that port. + - Anything else → substring match on port. + +3. **For each selected device, in sequence (don't parallelize — SerialInterface holds an exclusive port lock):** + - `device_info(port=

)` → `my_node_num`, `long_name`, `short_name`, `firmware_version`, `hw_model`, `region`, `num_nodes`, `primary_channel` + - `list_nodes(port=

)` → peer count, which peers have `publicKey`, SNR/RSSI distribution + - `get_config(section="lora", port=

)` → region, preset, channel_num, tx_power, hop_limit + - If anything looks off (can't connect, `num_nodes` wrong, missing `firmware_version`), open a short firmware-log window: `serial_open(port=

, env=)`, wait 3 seconds, `serial_read(session_id, max_lines=100)`, `serial_close(session_id)`. Infer env from VID (0x239a → `rak4631`, 0x303a/0x10c4 → `heltec-v3`) unless an `MESHTASTIC_MCP_ENV_` env var overrides it. + +4. **Render per-device report** as a compact block: + + ```text + [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 + owner : Meshtastic 40eb / 40eb + region/band : US, channel 88, LONG_FAST + tx_power : 30 dBm, hop_limit=3 + peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) + primary ch : McpTest + firmware : no panics in last 3s + ``` + + Flag abnormalities inline with `⚠︎ ` — missing pubkey on a known peer, region UNSET, mismatched channel name, etc. + +5. **Cross-device correlation** (when >1 device selected): + - Do both see each other in `nodesByNum`? + - Do `region`, `channel_num`, `modem_preset` match across devices? + - Do the primary channel names match? (Different name → different PSK → no decode.) + +6. **Suggest next steps only for recognizable failure modes**, never speculatively: + - Stale PKI one-way → "`/mcp-test tests/mesh/test_direct_with_ack.py` — the test's retry+nodeinfo-ping heals this." + - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." + - Device unreachable → refer operator to the touch_1200bps + CP2102-wedged-driver notes in `run-tests.sh`. + +## Hard constraints + +- **Read-only.** No `set_config`, no `reboot`, no `factory_reset`, no `flash`. If the operator wants mutation, they'll escalate explicitly. +- **Open/query/close per device.** Never hold multiple SerialInterfaces to the same port. The port lock is exclusive. +- **Don't infer env beyond the VID map** — if the operator has an unusual board, ask them which env to use rather than guessing. diff --git a/.github/prompts/mcp-repro.prompt.md b/.github/prompts/mcp-repro.prompt.md new file mode 100644 index 000000000..be2963c33 --- /dev/null +++ b/.github/prompts/mcp-repro.prompt.md @@ -0,0 +1,67 @@ +--- +mode: agent +description: Re-run a specific test N times to triage flakes; diff firmware logs between passes and failures (Copilot equivalent of the Claude Code /repro slash command) +--- + +# `/mcp-repro` — flakiness triage for one test + +Equivalent of `.claude/commands/repro.md`. Use when the operator says "that one test is flaky — dig in", "repro the direct_with_ack failure", "why does X sometimes fail?". + +## What to do + +1. **Parse the operator's input** into two pieces: + - **Test identifier** — either a pytest node id (has `::` or starts with `tests/`) or a `-k`-style filter (plain substring like `direct_with_ack`). + - **Count** — integer, default `5`, cap at `20`. If the operator asks for 50, negotiate down and explain (airtime + USB wear). + +2. **Sanity-check the hub** via the `list_devices` MCP tool. If the test name references `nrf52` or `esp32s3` and the matching VID isn't present, stop and report — re-running won't help. + +3. **Loop** N times. Each iteration: + + ```bash + ./mcp-server/run-tests.sh --tb=short -p no:cacheprovider + ``` + + `-p no:cacheprovider` keeps pytest from caching anything between iterations. Capture: exit code, duration, and (on failure) the `Meshtastic debug` firmware-log section from `mcp-server/tests/report.html`. + +4. **Tally** results as you go: + + ```text + attempt 1: PASS (42s) + attempt 2: FAIL (128s) ← fw log captured + attempt 3: PASS (39s) + attempt 4: FAIL (121s) + attempt 5: PASS (41s) + -------------------------------------------------- + pass rate: 3/5 (60%) | mean duration: 74s + ``` + +5. **On mixed outcomes, diff the firmware logs** between one representative pass and one representative fail. Focus on: + - Error-level lines present only in failures (`PKI_UNKNOWN_PUBKEY`, `Alloc an err=`, `Skip send`, `No suitable channel`, `NAK`) + - Timing around the assertion point (broadcast sent? ACK received? retry fired?) + - Device-state fields that changed between attempts + + Surface the top 3 differences as a compact "passes when / fails when" table with uptime timestamps. Don't dump full logs. + +6. **Classify** the flake into one of: + - **LoRa airtime collision** — pass rate improves with fewer concurrent transmitters. Suggest a `time.sleep` gap or retry bump in the test body. + - **PKI key staleness** — first attempt fails, subsequent ones pass; existing retry-loop pattern in `test_direct_with_ack.py` is the fix. + - **NodeInfo cooldown** — `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs a `broadcast_nodeinfo_ping()` warmup. + - **Hardware-specific** — one direction consistently fails, firmware versions differ, CP2102 driver wedged, etc. + - **Unknown** — say so. Don't invent a root cause. + +7. **Report back** with: + - Pass rate + mean duration. + - Classification + the specific log evidence for it. + - A concrete next step (tighter assertion, more retries, open `/mcp-diagnose`, file a bug, nothing). + +## Examples + +- `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[esp32s3->nrf52] 10` — 10 runs of that parametrized case. +- `broadcast_delivers` — no `::`, no `tests/`; treat as `-k broadcast_delivers`; runs every match 5 times. +- `tests/telemetry/test_device_telemetry_broadcast.py 3` — shorter count for a slow test. + +## Notes + +- If the FIRST attempt fails and the rest pass, that's a state-leak signature — suggest starting from `--force-bake` or a clean device state rather than chasing the first-failure firmware logs. +- If ALL N fail, this isn't a flake — it's a regression. Say so, stop iterating, escalate to `/mcp-test` for full-suite context. +- Don't rebuild firmware during triage. Flakes that only reproduce under different firmware belong in a separate session with a plan. diff --git a/.github/prompts/mcp-test.prompt.md b/.github/prompts/mcp-test.prompt.md new file mode 100644 index 000000000..092ad3d85 --- /dev/null +++ b/.github/prompts/mcp-test.prompt.md @@ -0,0 +1,51 @@ +--- +mode: agent +description: Run the mcp-server test suite and interpret results (Copilot equivalent of the Claude Code /test slash command) +--- + +# `/mcp-test` — mcp-server test runner with interpretation + +Equivalent of the Claude Code `/test` slash command in `.claude/commands/test.md`. Use this when the operator asks you to "run the tests", "check the mcp test suite", "run the mesh tests", etc. + +## What to do + +1. **Invoke the wrapper** from the firmware repo root: + + ```bash + ./mcp-server/run-tests.sh [pytest-args] + ``` + + If the operator specified a subset (e.g. "just the mesh tests"), pass it through as `tests/mesh` or a pytest `-k filter`. If they said nothing, use the wrapper's defaults (full suite with pytest-html report). + + The wrapper auto-detects connected Meshtastic devices, maps each to its PlatformIO env, exports the required env vars, and invokes pytest. Zero pre-flight config needed from the operator. + +2. **Read the pre-flight header** (first few lines of wrapper output). The `detected hub :` line lists role → port → env mappings. If it reads `(none)`, the wrapper narrowed to `tests/unit` only — call that out explicitly so the operator knows hardware tiers were skipped. + +3. **On pass**: one-line summary like `N passed, M skipped in `. Don't enumerate test names. DO mention any non-placeholder SKIPs (things like "role not present on hub") because they indicate missing hardware or setup issues. + +4. **On failure**: open `mcp-server/tests/report.html` (pytest-html output, self-contained) and extract the `Meshtastic debug` section for each failed test. That section includes a firmware log stream (last 200 lines) and device state dump. For each failure, summarise: + - test name + - one-line assertion message + - the specific firmware log lines that explain why (look for `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`, `No suitable channel`) + +5. **Classify each failure** as one of: + - **Transient flake** — LoRa collision, first-attempt NAK with self-heal pattern, timing-sensitive assertion. Suggest `/mcp-repro ` to confirm. + - **Environmental** — device unreachable, port busy, CP2102 driver wedged on macOS. Suggest specific recovery (USB replug, `touch_1200bps`, `git status userPrefs.jsonc`). + - **Regression** — same assertion fails repeatedly on re-runs, firmware log shows novel errors. Identify the firmware module likely responsible. + +6. **Do NOT run destructive recovery automatically**. If a failure looks like it needs a reflash, factory*reset, or replug — \_describe the steps* and let the operator decide. Never burn airtime or flash cycles without approval. + +## Arguments convention + +Operators generally invoke this prompt either with no arguments (full suite) or with a specific subset. Examples: + +- `tests/mesh` — one tier +- `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip` — one test +- `--force-bake` — reflash devices first +- `-k telemetry` — name-filter + +## Side-effects to confirm in your summary + +- `userPrefs.jsonc` should be clean after a successful run. The session fixture in `mcp-server/tests/conftest.py` (`_session_userprefs`) snapshots and restores. Check `git status --porcelain userPrefs.jsonc` and report if it's non-empty. +- `mcp-server/tests/report.html` and `junit.xml` regenerate on every run. +- The wrapper prints a warning if a `.mcp-session-bak` sidecar was left over from a crashed prior session and auto-restores from it — mention that if it happened. diff --git a/.gitignore b/.gitignore index 43cee78db..f1eb9d852 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ CMakeLists.txt # PYTHONPATH used by the Nix shell .python3 +.claude/scheduled_tasks.lock +userPrefs.jsonc.mcp-session-bak diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 000000000..c5cf2e55e --- /dev/null +++ b/.mcp.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "meshtastic": { + "command": "./mcp-server/.venv/bin/python", + "args": ["-m", "meshtastic_mcp"], + "env": { + "MESHTASTIC_FIRMWARE_ROOT": "." + } + } + } +} diff --git a/.trunk/configs/.bandit b/.trunk/configs/.bandit index d286ded89..c70e7743b 100644 --- a/.trunk/configs/.bandit +++ b/.trunk/configs/.bandit @@ -1,2 +1,28 @@ [bandit] -skips = B101 \ No newline at end of file +# Rule IDs: https://bandit.readthedocs.io/en/latest/plugins/index.html +# +# B101 assert_used +# pytest assertions + internal invariants; required for pytest. +# B110 try_except_pass +# best-effort cleanup paths (atexit handlers, pubsub unsubscribe, +# session-end file close, socket shutdown). Logging inside the +# except block would be worse than the silent pass — teardown is +# already at end-of-session and the surrounding caller has context. +# B112 try_except_continue +# defensive loops over flaky sources (pubsub handlers, device +# re-enumeration polls). One failed iteration shouldn't abort the loop. +# B404 import_subprocess +# mcp-server wraps PlatformIO, esptool, nrfutil, picotool, and the +# pytest test-runner — subprocess is a load-bearing import here, not +# a smell. The "consider possible security implications" advisory is +# redundant given the file-level review already applied. +# B603 subprocess_without_shell_equals_true +# all subprocess calls use a static argv list; `shell=False` is the +# default and we never string-interpolate user input into the command. +# B606 start_process_with_no_shell +# same invariant as B603 — running a binary via argv list (not +# `shell=True`) is the safe pattern bandit is asking for. +# +# Higher-severity checks (B102 exec_used, B301 pickle, B307 eval, +# B602 shell=True, etc.) remain enabled. +skips = B101,B110,B112,B404,B603,B606 \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..cd043c087 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,113 @@ +# Agent instructions + +This repository is the [Meshtastic](https://meshtastic.org) firmware — a C++17 embedded codebase targeting ESP32 / nRF52 / RP2040 / STM32WL / Linux-Portduino LoRa mesh radios — plus a Python MCP server in `mcp-server/` that AI agents use to flash, configure, and test connected devices. + +## Primary instruction file + +**Read `.github/copilot-instructions.md` first.** That file is the canonical agent-facing document for this repo. It covers project layout, coding conventions (naming, module framework, Observer pattern, thread safety), the build system, CI/CD, the native C++ test suite, and — most importantly for automation work — the **MCP Server & Hardware Test Harness** section. Read it top-to-bottom before starting any non-trivial change. + +This file (`AGENTS.md`) is a short pointer + quick reference for agents that don't read `.github/copilot-instructions.md` by default. + +## Quick command reference + +| Action | Command | +| -------------------------------- | ----------------------------------------------------------------------------------- | +| Build a firmware variant | `pio run -e ` (e.g. `pio run -e rak4631`, `pio run -e heltec-v3`) | +| Clean + rebuild | `pio run -e -t clean && pio run -e ` | +| Flash a device | `pio run -e -t upload --upload-port ` (or use the `pio_flash` MCP tool) | +| Run firmware unit tests (native) | `pio test -e native` | +| Run MCP hardware tests | `./mcp-server/run-tests.sh` | +| Live TUI test runner | `mcp-server/.venv/bin/meshtastic-mcp-test-tui` | +| Format before commit | `trunk fmt` | +| Regenerate protobuf bindings | `bin/regen-protos.sh` | +| Generate CI matrix | `./bin/generate_ci_matrix.py all [--level pr]` | + +## MCP server (device + test automation) + +The `mcp-server/` package exposes ~32 MCP tools for device discovery, building, flashing, serial monitoring, and live-node administration. Tools are grouped as: + +- **Discovery**: `list_devices`, `list_boards`, `get_board` +- **Build & flash**: `build`, `clean`, `pio_flash`, `erase_and_flash` (ESP32 factory), `update_flash` (ESP32 OTA), `touch_1200bps` +- **Serial sessions**: `serial_open`, `serial_read`, `serial_list`, `serial_close` +- **Device reads**: `device_info`, `list_nodes` +- **Device writes** (require `confirm=True`): `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `reboot`, `shutdown`, `factory_reset`, `set_debug_log_api` +- **userPrefs admin**: `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest`, `userprefs_testing_profile` +- **Vendor escape hatches**: `esptool_*`, `nrfutil_*`, `picotool_*` + +Setup: `cd mcp-server && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'`. The repo registers the server via `.mcp.json` — Claude Code picks it up automatically. + +See `mcp-server/README.md` for argument shapes and the **MCP Server & Hardware Test Harness** section of `.github/copilot-instructions.md` for agent usage rules (tool surface, fixture contract, firmware integration points, recovery playbooks). + +## Slash commands (AI-assisted workflows) + +Three test-and-diagnose workflows exist as slash commands: + +- **`/test` (Claude Code) / `/mcp-test` (Copilot)** — run the hardware test suite and interpret failures +- **`/diagnose` / `/mcp-diagnose`** — read-only device health report +- **`/repro` / `/mcp-repro`** — flakiness triage: re-run one test N times, diff firmware logs between passes and failures + +Bodies live in `.claude/commands/` and `.github/prompts/` respectively. `.claude/commands/README.md` is the index. + +## House rules + +- **No destructive device operations without operator approval.** `factory_reset`, `erase_and_flash`, `reboot`, `shutdown`, history-rewriting git ops — describe the action and stop. Operator authorizes. +- **One MCP call per serial port at a time.** The port lock is exclusive; concurrent calls deadlock. Sequence: open → read/mutate → close, then next device. +- **`userPrefs.jsonc` is session state during tests.** The `_session_userprefs` fixture snapshots + restores it; never edit it from inside a test. +- **Don't speculate about firmware root causes.** When evidence doesn't support a classification, say "unknown" and list what would disambiguate. +- **Run `trunk fmt` before proposing a commit.** The `trunk_check` CI gate will reject unformatted code. +- **`confirm=True` on destructive MCP tools is a real gate, not a formality.** Don't bypass it via auto-approve settings. + +## Typical agent workflows + +### Flashing a device + +1. `list_devices` → find the port + likely VID +2. `list_boards` → confirm the env, or use the known default for the hardware +3. `pio_flash(env=..., port=..., confirm=True)` for any arch, or `erase_and_flash(env=..., port=..., confirm=True)` for an ESP32 factory install + +### Inspecting live node state + +1. `device_info(port=...)` — short summary (node num, firmware version, region, peer count) +2. `list_nodes(port=...)` — full peer table (SNR, RSSI, pubkey presence, last_heard) +3. `get_config(section="lora", port=...)` — LoRa settings for cross-device comparison + +Sequence these; don't parallelize on the same port. + +### Testing a firmware change + +1. Build locally: `pio run -e ` +2. Flash the test device: `pio_flash(env=..., port=..., confirm=True)` +3. Run the suite: `./mcp-server/run-tests.sh tests/` or `/test tests/` +4. On failure, open `mcp-server/tests/report.html` → `Meshtastic debug` section for the firmware log tail + device state dump +5. Iterate + +### Debugging a flaky test + +1. `/repro [count]` — re-runs the test N times, diffs firmware logs between passes and failures +2. If the first attempt always fails and the rest pass, that's a state-leak pattern → suggest `--force-bake` or a clean device state, don't chase the first failure +3. If all N fail, this isn't a flake — it's a regression. Stop iterating and escalate to `/test` for full-suite context. + +## Where to look + +| Path | What's there | +| --------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `src/` | Firmware C++ source (`mesh/`, `modules/`, `platform/`, `graphics/`, `gps/`, `motion/`, `mqtt/`, …) | +| `src/mesh/` | Core: NodeDB, Router, Channels, CryptoEngine, radio interfaces, StreamAPI, PhoneAPI | +| `src/modules/` | Feature modules; `Telemetry/Sensor/` has 50+ I2C sensor drivers | +| `variants/` | 200+ hardware variant definitions (`variant.h` + `platformio.ini` per board) | +| `protobufs/` | `.proto` definitions; regenerate with `bin/regen-protos.sh` | +| `test/` | Firmware unit tests (12 suites; `pio test -e native`) | +| `mcp-server/` | Python MCP server + pytest hardware integration tests | +| `mcp-server/tests/` | Tiered pytest suite: `unit/`, `mesh/`, `telemetry/`, `monitor/`, `fleet/`, `admin/`, `provisioning/` | +| `.claude/commands/` | Claude Code slash command bodies | +| `.github/prompts/` | Copilot prompt bodies (mirrors of the Claude Code ones) | +| `.github/copilot-instructions.md` | **Primary agent instructions — read this** | +| `.github/workflows/` | CI pipelines | +| `.mcp.json` | MCP server registration for Claude Code | + +## Recovery one-liners + +- **`userPrefs.jsonc` dirty after a test run?** Re-run `./mcp-server/run-tests.sh` once (pre-flight self-heals from the sidecar). If still dirty: `git checkout userPrefs.jsonc`. +- **nRF52 not responding?** `mcp__meshtastic__touch_1200bps(port=...)` drops it into the DFU bootloader, then `pio_flash` re-installs. +- **Port busy?** `lsof ` to find the holder. Usually a stale `pio device monitor` or zombie `meshtastic_mcp` process. Kill it. +- **Multiple MCP servers running?** `ps aux | grep meshtastic_mcp` — zombies hold ports. Kill all but the one your host spawned. diff --git a/mcp-server/.gitignore b/mcp-server/.gitignore new file mode 100644 index 000000000..f5180bc71 --- /dev/null +++ b/mcp-server/.gitignore @@ -0,0 +1,26 @@ +.venv/ +__pycache__/ +*.py[cod] +*.egg-info/ +.pytest_cache/ +.mypy_cache/ +dist/ +build/ + +# Test harness artifacts +tests/report.html +tests/junit.xml +tests/reportlog.jsonl +tests/fwlog.jsonl +# Subprocess-output tee from pio/esptool/nrfutil/picotool (live flash +# progress for the TUI; also a post-run diagnostic for plain CLI runs). +tests/flash.log +tests/tool_coverage.json +tests/.coverage +htmlcov/ +# Persistent run counter for meshtastic-mcp-test-tui header. +tests/.tui-runs +# Cross-run history (TUI duration sparkline). +tests/.history/ +# Reproducer bundles (TUI `x` export on failed tests). +tests/reproducers/ diff --git a/mcp-server/README.md b/mcp-server/README.md new file mode 100644 index 000000000..7d5fc551a --- /dev/null +++ b/mcp-server/README.md @@ -0,0 +1,270 @@ +# Meshtastic MCP Server + +An [MCP](https://modelcontextprotocol.io) server for working with the Meshtastic firmware repo and connected devices. Lets Claude Code / Claude Desktop: + +- Discover USB-connected Meshtastic devices +- Enumerate PlatformIO board variants (166+) with Meshtastic metadata +- Build, clean, flash, erase-and-flash (factory), and OTA-update firmware +- Read serial logs via `pio device monitor` (with board-specific exception decoders) +- Trigger 1200bps touch-reset for bootloader entry (nRF52, ESP32-S3, RP2040) +- Query and administer a running node via the [`meshtastic` Python API](https://github.com/meshtastic/python): owner name, config (LocalConfig + ModuleConfig), channels, messaging, reboot/shutdown/factory-reset +- Call `esptool`, `nrfutil`, `picotool` directly when PlatformIO doesn't cover the operation + +## Design principle + +**PlatformIO first.** Its `pio run -t upload` knows the correct protocol, offsets, and post-build chain for every variant in `variants/`. Direct vendor-tool wrappers (`esptool_*`, `nrfutil_*`, `picotool_*`) exist as escape hatches for operations pio doesn't cover (blank-chip erase, DFU `.zip` packages, BOOTSEL-mode inspection). + +## Prerequisites + +- Python ≥ 3.11 +- [PlatformIO Core](https://platformio.org/install/cli) — `pio` on `$PATH` or at `~/.platformio/penv/bin/pio` +- The Meshtastic firmware repo checked out somewhere (set via `MESHTASTIC_FIRMWARE_ROOT`) +- Optional: `esptool`, `nrfutil`, `picotool` on `$PATH` (or under the firmware venv at `.venv/bin/`) if you want to use the direct-tool wrappers + +## Install + +```bash +cd /mcp-server +python3 -m venv .venv +.venv/bin/pip install -e . +``` + +Verify: + +```bash +MESHTASTIC_FIRMWARE_ROOT= .venv/bin/python -m meshtastic_mcp +``` + +The server blocks on stdin (that's correct — it speaks MCP over stdio). Ctrl-C to exit. + +## Register with Claude Code + +Edit `~/.claude/settings.json` (global) or `/.claude/settings.local.json` (project-only): + +```json +{ + "mcpServers": { + "meshtastic": { + "command": "/mcp-server/.venv/bin/python", + "args": ["-m", "meshtastic_mcp"], + "env": { + "MESHTASTIC_FIRMWARE_ROOT": "" + } + } + } +} +``` + +Replace `` with the absolute path, e.g. `/Users/you/GitHub/firmware`. Restart Claude Code after editing. + +## Register with Claude Desktop + +Same `mcpServers` block, but in `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). + +## Tools (38) + +### Discovery & metadata + +| Tool | What it does | +| -------------- | ------------------------------------------------------------------------------------------ | +| `list_devices` | USB/serial port listing, flags likely-Meshtastic candidates | +| `list_boards` | PlatformIO envs with `custom_meshtastic_*` metadata; filters by arch/supported/query/level | +| `get_board` | Full env dict incl. raw pio config | + +### Build & flash + +| Tool | What it does | +| ----------------- | -------------------------------------------------------------------- | +| `build` | `pio run -e ` (+ mtjson target) | +| `clean` | `pio run -e -t clean` | +| `pio_flash` | `pio run -e -t upload --upload-port ` — any architecture | +| `erase_and_flash` | ESP32 full factory flash via `bin/device-install.sh` | +| `update_flash` | ESP32 OTA app-partition update via `bin/device-update.sh` | +| `touch_1200bps` | 1200-baud open/close to trigger USB CDC bootloader entry | + +### Serial log sessions + +Backed by long-running `pio device monitor` subprocesses with a 10k-line ring buffer per session and board-specific filters (`esp32_exception_decoder` auto-selected when you pass `env=`). + +| Tool | What it does | +| -------------- | ------------------------------------------------------------------ | +| `serial_open` | Start a monitor session; returns `session_id` | +| `serial_read` | Cursor-based pull; reports `dropped` if lines aged out of the ring | +| `serial_list` | All active sessions | +| `serial_close` | Terminate a session | + +### Device reads + +| Tool | What it does | +| ------------- | --------------------------------------------------------------------------- | +| `device_info` | my_node_num, long/short name, firmware version, region, channel, node count | +| `list_nodes` | Full node database with position, SNR, RSSI, last_heard, battery | + +_The tool tables below document 38 currently registered MCP server tools._ + +### Device writes + +| Tool | What it does | +| ------------------- | -------------------------------------------------------------------------- | +| `set_owner` | Long name + optional short name (≤4 chars) | +| `get_config` | One section or all (LocalConfig + ModuleConfig) | +| `set_config` | Dot-path field write: `lora.region`=`"US"`, `device.role`=`"ROUTER"`, etc. | +| `get_channel_url` | Primary-only or include_all=admin URL | +| `set_channel_url` | Import channels from a Meshtastic URL | +| `set_debug_log_api` | Enable or disable debug logging for the Meshtastic Python API client | +| `send_text` | Broadcast or direct text message | +| `reboot` | `localNode.reboot(secs)` — requires `confirm=True` | +| `shutdown` | `localNode.shutdown(secs)` — requires `confirm=True` | +| `factory_reset` | `localNode.factoryReset(full?)` — requires `confirm=True` | + +### Direct hardware tools (escape hatches) + +| Tool | What it does | +| --------------------- | --------------------------------------------------------- | +| `esptool_chip_info` | Read chip, MAC, crystal, flash size | +| `esptool_erase_flash` | Full-chip erase (destructive) | +| `esptool_raw` | Pass-through; confirm=True required for write/erase/merge | +| `nrfutil_dfu` | DFU-flash a `.zip` package | +| `nrfutil_raw` | Pass-through | +| `picotool_info` | Read Pico BOOTSEL-mode info | +| `picotool_load` | Load a UF2 | +| `picotool_raw` | Pass-through | + +## Safety + +- **All destructive flash/admin tools require `confirm=True`** as a tool-level gate, on top of any permission prompt from Claude. +- **Serial port is exclusive.** If a `serial_*` session is active on a port, `device_info`/admin tools on the same port will fail fast with a pointer at the active `session_id`. Close the session first. +- **Flash confirmation by architecture**: `erase_and_flash` / `update_flash` error if the env's architecture isn't ESP32 — use `pio_flash` for nRF52/RP2040/STM32. + +## Environment variables + +| Var | Default | Purpose | +| -------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------- | +| `MESHTASTIC_FIRMWARE_ROOT` | walks up from cwd for `platformio.ini` | Pin the firmware repo | +| `MESHTASTIC_PIO_BIN` | `~/.platformio/penv/bin/pio` → `$PATH` `pio` → `platformio` | Override `pio` location | +| `MESHTASTIC_ESPTOOL_BIN` | `/.venv/bin/esptool` → `$PATH` | Override esptool | +| `MESHTASTIC_NRFUTIL_BIN` | `$PATH` | Override nrfutil | +| `MESHTASTIC_PICOTOOL_BIN` | `$PATH` | Override picotool | +| `MESHTASTIC_MCP_SEED` | `mcp--` | PSK seed for test-harness session (CI override) | +| `MESHTASTIC_MCP_FLASH_LOG` | `/tests/flash.log` | Tee target for pio/esptool/nrfutil subprocess output (TUI tails it) | + +## Hardware Test Suite + +`mcp-server/tests/` holds a pytest-based integration suite that exercises +real USB-connected Meshtastic devices against the MCP server surface. Separate +from the native C++ unit tests in the firmware repo's top-level `test/` +directory — this one validates the device-facing behavior end-to-end. + +### Invocation + +```bash +./mcp-server/run-tests.sh # full suite (auto-detect + auto-bake-if-needed) +./mcp-server/run-tests.sh --force-bake # reflash devices before testing +./mcp-server/run-tests.sh --assume-baked # skip the bake step (caller vouches for state) +./mcp-server/run-tests.sh tests/mesh # one tier +./mcp-server/run-tests.sh tests/mesh/test_traceroute.py # one file +./mcp-server/run-tests.sh -k telemetry # pytest name filter +``` + +The wrapper auto-detects connected devices (VID `0x239A` → `nrf52` → env +`rak4631`; `0x303A` or `0x10C4` → `esp32s3` → env `heltec-v3`), exports +`MESHTASTIC_MCP_ENV_` env vars, and invokes pytest. Overrides via +per-role env vars: `MESHTASTIC_MCP_ENV_NRF52=heltec-mesh-node-t114 ./run-tests.sh`. + +No hardware connected? The wrapper narrows to `tests/unit/` only and says so +in the pre-flight header. + +### Tiers (run in this order) + +- **`bake`** (`tests/test_00_bake.py`) — flashes both hub roles with the + session's test profile. Has a skip-if-already-baked check (region + channel + match); `--force-bake` overrides. +- **`unit`** — pure Python, no hardware. boards / PIO wrapper / + userPrefs-parse / testing-profile fixtures. +- **`mesh`** — 2-device mesh: formation, broadcast delivery, direct+ACK, + traceroute, bidirectional. Parametrized over both directions. +- **`telemetry`** — periodic telemetry broadcast + on-demand request/reply + (`TELEMETRY_APP` with `wantResponse=True`). +- **`monitor`** — boot log has no panic markers within 60 s of reboot. +- **`fleet`** — PSK-seed isolation: two labs with different seeds never + overlap. +- **`admin`** — owner persistence across reboot, channel URL round-trip, + `lora.hop_limit` persistence. +- **`provisioning`** — region/channel baking, userPrefs survive + `factory_reset(full=False)`. + +### Artifacts (regenerated every run, under `tests/`) + +- `report.html` — self-contained pytest-html report. Each test gets a + **Meshtastic debug** section attached on failure with a 200-line firmware + log tail + device-state dump. Open this first on failures. +- `junit.xml` — CI-parseable. +- `reportlog.jsonl` — `pytest-reportlog` event stream; consumed by the TUI. +- `fwlog.jsonl` — firmware log mirror (`meshtastic.log.line` pubsub → JSONL). +- `flash.log` — tee of all pio / esptool / nrfutil / picotool subprocess + output during the run (driven by `MESHTASTIC_MCP_FLASH_LOG`). + +### Live TUI + +```bash +.venv/bin/meshtastic-mcp-test-tui +.venv/bin/meshtastic-mcp-test-tui tests/mesh # pytest args pass through +``` + +Textual-based wrapper over `run-tests.sh` with a live test tree, tier +counters, pytest output pane, firmware-log pane, and a device-status strip. +Key bindings: `r` re-run focused, `f` filter, `d` failure detail, `g` open +`report.html`, `x` export reproducer bundle, `l` cycle fw-log filter, `q` +quit (SIGINT → SIGTERM → SIGKILL escalation). + +### Slash commands + +Three AI-assisted workflows are wired up for Claude Code operators +(`.claude/commands/`) and Copilot operators (`.github/prompts/`): +`/test` (run + interpret), `/diagnose` (read-only health report), `/repro` +(flake triage, N-times re-run with log diff). + +### House rules (for human + agent contributors) + +- Session-scoped fixtures in `tests/conftest.py` snapshot + restore + `userPrefs.jsonc`; **never edit `userPrefs.jsonc` from inside a test**. + Use the `test_profile` / `no_region_profile` fixtures for ephemeral + overrides. +- `SerialInterface` holds an **exclusive port lock**; sequence calls + open → mutate → close, then next device. No parallel calls to the + same port. +- Directed PKI-encrypted sends need **bilateral NodeInfo warmup** — + both sides must hold the other's current pubkey. See + `tests/mesh/_receive.py::nudge_nodeinfo_port` and the three directed- + send tests (`test_direct_with_ack`, `test_traceroute`, + `test_telemetry_request_reply`) for the canonical pattern. + +## Layout + +```text +mcp-server/ +├── pyproject.toml +├── README.md +└── src/meshtastic_mcp/ + ├── __main__.py # entry: python -m meshtastic_mcp + ├── server.py # FastMCP app + @app.tool() registrations (thin) + ├── config.py # firmware_root, pio_bin, esptool_bin, etc. + ├── pio.py # subprocess wrapper (timeouts, JSON, tail_lines) + ├── devices.py # list_devices (findPorts + comports) + ├── boards.py # list_boards / get_board (pio project config parse + cache) + ├── flash.py # build, clean, flash, erase_and_flash, update_flash, touch_1200bps + ├── serial_session.py # SerialSession + reader thread + ring buffer + ├── registry.py # session registry + per-port locks + ├── connection.py # connect(port) ctx mgr — SerialInterface + port lock + ├── info.py # device_info, list_nodes + ├── admin.py # set_owner, get/set_config, channels, send_text, reboot/shutdown/factory_reset + └── hw_tools.py # esptool / nrfutil / picotool wrappers +``` + +## Troubleshooting + +- **"Could not locate Meshtastic firmware root"** — set `MESHTASTIC_FIRMWARE_ROOT`. +- **"Could not find `pio`"** — install PlatformIO or set `MESHTASTIC_PIO_BIN`. +- **"Port is held by serial session ..."** — call `serial_close(session_id)` or `serial_list` to find it. +- **`factory.bin` not found after build** — the env may not be ESP32; only ESP32 envs produce a `.factory.bin`. +- **`touch_1200bps` reported `new_port: null`** — the device may not have 1200bps-reset stdio, or the bootloader re-uses the same port name. Check `list_devices` manually. diff --git a/mcp-server/pyproject.toml b/mcp-server/pyproject.toml new file mode 100644 index 000000000..d73bf795f --- /dev/null +++ b/mcp-server/pyproject.toml @@ -0,0 +1,39 @@ +[project] +name = "meshtastic-mcp" +version = "0.1.0" +description = "MCP server for Meshtastic firmware development: device discovery, PlatformIO tooling, flashing, serial monitoring, and device administration via the meshtastic Python API." +readme = "README.md" +requires-python = ">=3.11" +license = { text = "GPL-3.0-only" } +authors = [{ name = "thebentern" }] +dependencies = ["mcp>=1.2", "pyserial>=3.5", "meshtastic>=2.7.8"] + +[project.optional-dependencies] +dev = ["pytest>=7"] +test = [ + "pytest>=8", + "pytest-html>=4", + "pytest-reportlog>=0.4", + "pytest-timeout>=2.3", + "coverage[toml]>=7", + "pyyaml>=6", + # textual is required by the `meshtastic-mcp-test-tui` script (see + # `src/meshtastic_mcp/cli/test_tui.py`). Bundled into `test` rather than a + # separate `[tui]` extra because v1 expects test operators are the only + # consumers; revisit if install cost pushes back. + "textual>=0.50", +] + +[project.scripts] +meshtastic-mcp = "meshtastic_mcp.__main__:main" +# Live TUI wrapping run-tests.sh — shells out to the same script the plain +# CLI uses, tails pytest-reportlog for per-test state, and polls the device +# list at startup + post-run (port lock forces it to stay idle during the run). +meshtastic-mcp-test-tui = "meshtastic_mcp.cli.test_tui:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/meshtastic_mcp"] diff --git a/mcp-server/run-tests.sh b/mcp-server/run-tests.sh new file mode 100755 index 000000000..292e6e3a2 --- /dev/null +++ b/mcp-server/run-tests.sh @@ -0,0 +1,236 @@ +#!/usr/bin/env bash +# mcp-server hardware test runner. +# +# Auto-detects connected Meshtastic devices, maps each to its PlatformIO env +# via the same role table the pytest fixtures use, exports the right +# MESHTASTIC_MCP_ENV_* env vars, and invokes pytest. +# +# Usage: +# ./run-tests.sh # full suite, default pytest args +# ./run-tests.sh tests/mesh # subset (any pytest args pass through) +# ./run-tests.sh --force-bake # override one default with another +# MESHTASTIC_MCP_ENV_NRF52=foo ./run-tests.sh # override env per role +# MESHTASTIC_MCP_SEED=ci-run-42 ./run-tests.sh # override PSK seed +# +# If zero supported devices are detected, only the unit tier runs. +# +# Also restores `userPrefs.jsonc` from the session-backup sidecar if a prior +# run exited abnormally (belt to conftest.py's atexit suspenders). + +set -euo pipefail + +# cd to the script's directory so relative paths resolve consistently no +# matter where the user invoked from. +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +cd "$SCRIPT_DIR" + +VENV_PY="$SCRIPT_DIR/.venv/bin/python" +if [[ ! -x $VENV_PY ]]; then + echo "error: $VENV_PY not found or not executable." >&2 + echo " Bootstrap the venv first:" >&2 + echo " cd $SCRIPT_DIR && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'" >&2 + exit 2 +fi + +# Resolve firmware root the same way conftest.py does (this script sits in +# mcp-server/, firmware repo root is one level up). +FIRMWARE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +USERPREFS_PATH="$FIRMWARE_ROOT/userPrefs.jsonc" +USERPREFS_SIDECAR="$USERPREFS_PATH.mcp-session-bak" + +# ---------- Pre-flight: recover stale userPrefs.jsonc from prior crash ---- +# If conftest.py's atexit hook didn't fire (SIGKILL, kernel panic, OS +# restart), the sidecar is the ground truth. Self-heal before running so we +# don't bake the previous run's dirty state into this run's firmware. +if [[ -f $USERPREFS_SIDECAR ]]; then + echo "[pre-flight] found $USERPREFS_SIDECAR from a prior abnormal exit;" >&2 + echo " restoring userPrefs.jsonc before starting." >&2 + cp "$USERPREFS_SIDECAR" "$USERPREFS_PATH" + rm -f "$USERPREFS_SIDECAR" +fi + +# If userPrefs.jsonc has uncommitted changes BEFORE the run starts, that's +# worth warning about — tests will snapshot this dirty state and restore to +# it at the end, which may not be what the operator wants. +if command -v git >/dev/null 2>&1; then + cd "$FIRMWARE_ROOT" + # Capture the git status into a local first — SC2312 flags command + # substitution inside `[[ -n ... ]]` because the exit code of `git + # status` is masked. A two-step assignment makes the failure path + # explicit (non-git, missing file) and keeps the bracket test clean. + _git_status_porcelain="$(git status --porcelain userPrefs.jsonc 2>/dev/null || true)" + if [[ -n $_git_status_porcelain ]]; then + echo "[pre-flight] warning: userPrefs.jsonc has uncommitted changes." >&2 + echo " Tests will snapshot THIS state and restore to it" >&2 + echo " at teardown. If that's not intended, run:" >&2 + echo " git checkout userPrefs.jsonc" >&2 + echo " and re-invoke." >&2 + fi + cd "$SCRIPT_DIR" +fi + +# ---------- Seed default -------------------------------------------------- +# Per-machine default so repeated runs from the same operator land on the +# same PSK (makes --assume-baked valid across invocations). Operator can +# override with an explicit env var if they want isolation (e.g. CI). +if [[ -z ${MESHTASTIC_MCP_SEED-} ]]; then + WHO="$(whoami 2>/dev/null || echo anon)" + HOST="$(hostname -s 2>/dev/null || echo host)" + export MESHTASTIC_MCP_SEED="mcp-${WHO}-${HOST}" +fi + +# ---------- Flash progress log -------------------------------------------- +# pio.py / hw_tools.py tee subprocess output (pio run -t upload, esptool, +# nrfutil, picotool) to this file line-by-line as it arrives when this env +# var is set. The TUI tails it so the operator sees live flash progress +# instead of 3 minutes of silence during `test_00_bake.py`. Plain CLI users +# also benefit — the log is a post-run diagnostic even without the TUI. +# Truncate at session start so each run gets a clean log. +export MESHTASTIC_MCP_FLASH_LOG="$SCRIPT_DIR/tests/flash.log" +: >"$MESHTASTIC_MCP_FLASH_LOG" + +# ---------- Detect connected hardware ------------------------------------- +# In-process call to the same Python API the test fixtures use, so the +# script never drifts from what pytest sees. Returns a JSON object +# {role: port, ...}. +ROLES_JSON="$( + "$VENV_PY" - <<'PY' +import json +import sys + +sys.path.insert(0, "src") +from meshtastic_mcp import devices + +# Role → canonical VID map. Kept in sync with +# `tests/conftest.py::hub_profile` defaults; if that changes, this must too. +ROLE_BY_VID = { + 0x239A: "nrf52", # Adafruit / RAK nRF52 native USB (app + DFU) + 0x303A: "esp32s3", # Espressif native USB (ESP32-S3) + 0x10C4: "esp32s3", # CP2102 USB-UART (common on Heltec/LilyGO ESP32 boards) +} + +out: dict[str, str] = {} +for dev in devices.list_devices(include_unknown=True): + vid_raw = dev.get("vid") or "" + try: + if isinstance(vid_raw, str) and vid_raw.startswith("0x"): + vid = int(vid_raw, 16) + else: + vid = int(vid_raw) + except (TypeError, ValueError): + continue + role = ROLE_BY_VID.get(vid) + # First port wins per role — matches hub_devices fixture semantics. + if role and role not in out: + out[role] = dev["port"] + +json.dump(out, sys.stdout) +PY +)" + +# ---------- Map role → pio env -------------------------------------------- +# Honor MESHTASTIC_MCP_ENV_ operator overrides; fall back to the +# same defaults hardcoded in tests/conftest.py::_DEFAULT_ROLE_ENVS. +resolve_env() { + local role="$1" + local default="$2" + local upper + upper="$(echo "$role" | tr '[:lower:]' '[:upper:]')" + local var="MESHTASTIC_MCP_ENV_${upper}" + eval "local override=\${$var:-}" + if [[ -n $override ]]; then + echo "$override" + else + echo "$default" + fi +} + +NRF52_PORT="$(echo "$ROLES_JSON" | "$VENV_PY" -c 'import json,sys; print(json.loads(sys.stdin.read()).get("nrf52", ""))')" +ESP32S3_PORT="$(echo "$ROLES_JSON" | "$VENV_PY" -c 'import json,sys; print(json.loads(sys.stdin.read()).get("esp32s3", ""))')" + +DETECTED="" +if [[ -n $NRF52_PORT ]]; then + NRF52_ENV="$(resolve_env nrf52 rak4631)" + export MESHTASTIC_MCP_ENV_NRF52="$NRF52_ENV" + DETECTED="${DETECTED} nrf52 @ ${NRF52_PORT} -> env=${NRF52_ENV}\n" +fi +if [[ -n $ESP32S3_PORT ]]; then + ESP32S3_ENV="$(resolve_env esp32s3 heltec-v3)" + export MESHTASTIC_MCP_ENV_ESP32S3="$ESP32S3_ENV" + DETECTED="${DETECTED} esp32s3 @ ${ESP32S3_PORT} -> env=${ESP32S3_ENV}\n" +fi + +# ---------- Pre-flight summary -------------------------------------------- +# Surface what pytest is about to do with respect to the bake phase: the +# operator should see "will verify + bake if needed" by default, so a +# 3-minute flash appearing mid-run isn't a surprise. Detection of the +# explicit overrides is best-effort — we just scan $@ for the known flags. +_bake_mode="auto (verify + bake if needed)" +for _arg in "$@"; do + case "$_arg" in + --assume-baked) _bake_mode="skip (--assume-baked)" ;; + --force-bake) _bake_mode="force (--force-bake)" ;; + *) ;; # any other arg: pass-through; bake mode unchanged + esac +done + +echo "mcp-server test runner" +echo " firmware root : $FIRMWARE_ROOT" +echo " seed : $MESHTASTIC_MCP_SEED" +echo " bake : $_bake_mode" +if [[ -n $DETECTED ]]; then + echo " detected hub :" + printf "%b" "$DETECTED" +else + echo " detected hub : (none)" +fi +echo + +# ---------- Invoke pytest ------------------------------------------------- +# If no devices detected, only the unit tier would produce meaningful +# PASS/FAIL — every hardware test would SKIP with "role not present". We +# narrow to tests/unit explicitly so the summary reads as "no hardware, +# unit suite only" instead of "big skip count looks suspicious". +if [[ -z $DETECTED && $# -eq 0 ]]; then + echo "[pre-flight] no supported devices detected; running unit tier only." + echo + exec "$VENV_PY" -m pytest tests/unit -v --report-log=tests/reportlog.jsonl +fi + +# Default pytest args when the user passed none. Power users can invoke +# `./run-tests.sh tests/mesh -v --tb=long` and skip all of these defaults. +# +# NOTE: `--assume-baked` is DELIBERATELY omitted here. `tests/test_00_bake.py` +# has an internal skip-if-already-baked check (`_bake_role`: query device_info, +# compare region + primary_channel to the session profile, skip on match). +# So the fast path is ~8-10 s of verification overhead when the devices are +# already baked — negligible next to the 2-6 min suite runtime. Letting +# test_00_bake.py run means a fresh device, a re-seeded session, or a post- +# factory-reset device gets flashed automatically instead of silently +# skipping half the hardware tests with "not baked with session profile" +# errors. Power users who know their hardware is current and want to shave +# those seconds can pass `--assume-baked` explicitly. +if [[ $# -eq 0 ]]; then + set -- tests/ \ + --html=tests/report.html --self-contained-html \ + --junitxml=tests/junit.xml \ + -v --tb=short +fi + +# Always emit `tests/reportlog.jsonl` (unless the operator explicitly passed +# their own `--report-log=...`). Consumers — notably the +# `meshtastic-mcp-test-tui` TUI — tail the reportlog for live per-test state. +# Appending here means power-user invocations like `./run-tests.sh tests/mesh` +# also produce it, not just the all-defaults invocation. +_has_report_log=0 +for _arg in "$@"; do + case "$_arg" in + --report-log | --report-log=*) _has_report_log=1 ;; + *) ;; # any other arg: no-op; loop continues + esac +done +if [[ $_has_report_log -eq 0 ]]; then + set -- "$@" --report-log=tests/reportlog.jsonl +fi + +exec "$VENV_PY" -m pytest "$@" diff --git a/mcp-server/src/meshtastic_mcp/__init__.py b/mcp-server/src/meshtastic_mcp/__init__.py new file mode 100644 index 000000000..bd696afe0 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/__init__.py @@ -0,0 +1,3 @@ +"""Meshtastic MCP server — device discovery, PlatformIO tooling, and device admin.""" + +__version__ = "0.1.0" diff --git a/mcp-server/src/meshtastic_mcp/__main__.py b/mcp-server/src/meshtastic_mcp/__main__.py new file mode 100644 index 000000000..4ed67db38 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/__main__.py @@ -0,0 +1,11 @@ +"""Entry point for `python -m meshtastic_mcp`.""" + +from meshtastic_mcp.server import app + + +def main() -> None: + app.run() + + +if __name__ == "__main__": + main() diff --git a/mcp-server/src/meshtastic_mcp/admin.py b/mcp-server/src/meshtastic_mcp/admin.py new file mode 100644 index 000000000..6da92d860 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/admin.py @@ -0,0 +1,377 @@ +"""Device administration: owner, config, channels, messaging, admin actions. + +All operations use the same `connect()` context manager so port selection, +port-busy detection, and cleanup are handled uniformly. + +Config writes use a dot-path: the first segment names a section (e.g. +`"lora"` in LocalConfig or `"mqtt"` in LocalModuleConfig), remaining segments +walk protobuf fields. Enum fields accept their string names (`"US"` for +`lora.region`) so callers don't need to know the numeric values. +""" + +from __future__ import annotations + +from typing import Any + +from google.protobuf import descriptor as pb_descriptor +from google.protobuf import json_format +from meshtastic.protobuf import localonly_pb2 + +from .connection import connect + + +class AdminError(RuntimeError): + pass + + +LOCAL_CONFIG_SECTIONS = {f.name for f in localonly_pb2.LocalConfig.DESCRIPTOR.fields} +MODULE_CONFIG_SECTIONS = { + f.name for f in localonly_pb2.LocalModuleConfig.DESCRIPTOR.fields +} + + +def _require_confirm(confirm: bool, operation: str) -> None: + if not confirm: + raise AdminError(f"{operation} is destructive and requires confirm=True.") + + +def _message_to_dict(msg: Any) -> dict[str, Any]: + # `including_default_value_fields` was renamed to + # `always_print_fields_with_no_presence` in protobuf 5.26+. Pick whichever + # kwarg the installed version accepts so we work against both. + kwargs: dict[str, Any] = {"preserving_proto_field_name": True} + import inspect + + sig = inspect.signature(json_format.MessageToDict) + if "always_print_fields_with_no_presence" in sig.parameters: + kwargs["always_print_fields_with_no_presence"] = False + elif "including_default_value_fields" in sig.parameters: + kwargs["including_default_value_fields"] = False + return json_format.MessageToDict(msg, **kwargs) + + +# ---------- owner ---------------------------------------------------------- + + +def set_owner( + long_name: str, + short_name: str | None = None, + port: str | None = None, +) -> dict[str, Any]: + if short_name is not None and len(short_name) > 4: + raise AdminError("short_name must be 4 characters or fewer") + with connect(port=port) as iface: + iface.localNode.setOwner(long_name=long_name, short_name=short_name) + return { + "ok": True, + "long_name": long_name, + "short_name": short_name, + } + + +# ---------- config reads --------------------------------------------------- + + +def _section_container(node, section: str) -> tuple[Any, str]: + """Return (container_message, parent_name) for a section name. + + Parent is 'localConfig' or 'moduleConfig' so callers know where to call + writeConfig() after mutating. + """ + if section in LOCAL_CONFIG_SECTIONS: + return getattr(node.localConfig, section), "localConfig" + if section in MODULE_CONFIG_SECTIONS: + return getattr(node.moduleConfig, section), "moduleConfig" + raise AdminError( + f"Unknown config section: {section!r}. " + f"Valid sections: {sorted(LOCAL_CONFIG_SECTIONS | MODULE_CONFIG_SECTIONS)}" + ) + + +def get_config(section: str | None = None, port: str | None = None) -> dict[str, Any]: + """Read one or all config sections. + + `section` may be any name in LocalConfig (device, lora, position, power, + network, display, bluetooth, security) or LocalModuleConfig (mqtt, serial, + telemetry, ...). Omit `section` or pass `"all"` for everything. + """ + with connect(port=port) as iface: + node = iface.localNode + if section in (None, "all"): + lc = _message_to_dict(node.localConfig) + mc = _message_to_dict(node.moduleConfig) + return { + "config": { + "localConfig": lc, + "moduleConfig": mc, + } + } + container, _parent = _section_container(node, section) + return {"config": {section: _message_to_dict(container)}} + + +# ---------- config writes -------------------------------------------------- + + +def _coerce_enum(field: pb_descriptor.FieldDescriptor, value: Any) -> int: + """Accept an enum value as either its int or its string name.""" + enum_type = field.enum_type + if isinstance(value, bool): + raise AdminError(f"{field.name}: expected enum {enum_type.name}, got bool") + if isinstance(value, int): + if enum_type.values_by_number.get(value) is None: + raise AdminError( + f"{field.name}: {value} is not a valid {enum_type.name} value" + ) + return value + if isinstance(value, str): + upper = value.upper() + ev = enum_type.values_by_name.get(upper) + if ev is None: + valid = sorted(enum_type.values_by_name.keys()) + raise AdminError( + f"{field.name}: {value!r} is not a valid {enum_type.name}. " + f"Valid: {valid}" + ) + return ev.number + raise AdminError( + f"{field.name}: expected enum {enum_type.name}, got {type(value).__name__}" + ) + + +def _coerce_scalar(field: pb_descriptor.FieldDescriptor, value: Any) -> Any: + t = field.type + FT = pb_descriptor.FieldDescriptor + if t == FT.TYPE_ENUM: + return _coerce_enum(field, value) + if t == FT.TYPE_BOOL: + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.strip().lower() in ("true", "yes", "1", "on") + if isinstance(value, int): + return bool(value) + if t in ( + FT.TYPE_INT32, + FT.TYPE_INT64, + FT.TYPE_UINT32, + FT.TYPE_UINT64, + FT.TYPE_SINT32, + FT.TYPE_SINT64, + FT.TYPE_FIXED32, + FT.TYPE_FIXED64, + ): + return int(value) + if t in (FT.TYPE_FLOAT, FT.TYPE_DOUBLE): + return float(value) + if t == FT.TYPE_STRING: + return str(value) + if t == FT.TYPE_BYTES: + if isinstance(value, (bytes, bytearray)): + return bytes(value) + return str(value).encode("utf-8") + raise AdminError( + f"{field.name}: unsupported field type {t}. Use raw protobuf for this field." + ) + + +def _walk_to_field( + root_msg: Any, path_segments: list[str] +) -> tuple[Any, pb_descriptor.FieldDescriptor]: + """Walk `root_msg` by field names until the leaf; return (parent_msg, leaf_field_descriptor).""" + msg = root_msg + for i, name in enumerate(path_segments): + desc = msg.DESCRIPTOR + field = desc.fields_by_name.get(name) + if field is None: + trail = ".".join(path_segments[:i] or [""]) + valid = [f.name for f in desc.fields] + raise AdminError(f"No field {name!r} in {trail}. Valid: {valid}") + is_last = i == len(path_segments) - 1 + if is_last: + return msg, field + if field.type != pb_descriptor.FieldDescriptor.TYPE_MESSAGE: + raise AdminError( + f"{'.'.join(path_segments[:i+1])} is a scalar; cannot descend into it" + ) + msg = getattr(msg, name) + # path_segments was empty + raise AdminError("Empty config path") + + +def set_config(path: str, value: Any, port: str | None = None) -> dict[str, Any]: + """Set a single config field by dot-path and write it to the device. + + Examples: + set_config("lora.region", "US") + set_config("lora.modem_preset", "LONG_FAST") + set_config("device.role", "ROUTER") + set_config("mqtt.enabled", True) + set_config("mqtt.address", "mqtt.example.com") + + """ + segments = [s for s in path.split(".") if s] + if not segments: + raise AdminError("path cannot be empty") + section = segments[0] + + with connect(port=port) as iface: + node = iface.localNode + container, parent_name = _section_container(node, section) + + # Treat the section as the root; the rest of the path walks into it. + leaf_parent, field = _walk_to_field(container, segments[1:] or []) + # Use `is_repeated` (modern upb protobuf API) rather than the + # deprecated `label == LABEL_REPEATED` check — the C-extension + # FieldDescriptor in protobuf >= 5.x doesn't expose `.label` at + # all, and `is_repeated` is the supported replacement that works + # across both the pure-python and upb backends. + if field.is_repeated: + raise AdminError( + f"{path!r} is a repeated field; v1 only supports scalar sets. " + "Use the raw meshtastic CLI for now." + ) + old_raw = getattr(leaf_parent, field.name) + coerced = _coerce_scalar(field, value) + try: + setattr(leaf_parent, field.name, coerced) + except (TypeError, ValueError) as exc: + raise AdminError(f"{path}: {exc}") from exc + + node.writeConfig(section) + + # Stringify enums for the response (so the caller can see the change in + # the same vocabulary they used to set it). + if field.type == pb_descriptor.FieldDescriptor.TYPE_ENUM: + try: + old_display = field.enum_type.values_by_number[old_raw].name + new_display = field.enum_type.values_by_number[coerced].name + except Exception: + old_display, new_display = old_raw, coerced + else: + old_display, new_display = old_raw, coerced + + return { + "ok": True, + "path": path, + "section": section, + "parent": parent_name, + "old_value": old_display, + "new_value": new_display, + } + + +# ---------- channels ------------------------------------------------------- + + +def get_channel_url( + include_all: bool = False, port: str | None = None +) -> dict[str, Any]: + with connect(port=port) as iface: + url = iface.localNode.getURL(includeAll=include_all) + return {"url": url} + + +def set_channel_url(url: str, port: str | None = None) -> dict[str, Any]: + with connect(port=port) as iface: + # setURL replaces the channel set from the URL's contents. It does not + # return a count; we infer by counting non-DISABLED channels after. + iface.localNode.setURL(url) + channels = iface.localNode.channels or [] + active = sum(1 for c in channels if getattr(c, "role", 0) != 0) + return {"ok": True, "channels_imported": active} + + +# ---------- messaging ------------------------------------------------------ + + +def send_text( + text: str, + to: str | int | None = None, + channel_index: int = 0, + want_ack: bool = False, + port: str | None = None, +) -> dict[str, Any]: + destination = to if to is not None else "^all" + with connect(port=port) as iface: + packet = iface.sendText( + text, + destinationId=destination, + wantAck=want_ack, + channelIndex=channel_index, + ) + packet_id = getattr(packet, "id", None) + return {"ok": True, "packet_id": packet_id, "destination": destination} + + +# ---------- diagnostics ---------------------------------------------------- + + +def set_debug_log_api(enabled: bool, port: str | None = None) -> dict[str, Any]: + """Toggle `config.security.debug_log_api_enabled` on the local node. + + When enabled, firmware emits log lines as protobuf `LogRecord` messages + over the StreamAPI instead of raw text. meshtastic-python surfaces them + on pubsub topic `meshtastic.log.line`, which flows through the SAME + SerialInterface our tests already hold open — no `pio device monitor` + needed, no port-contention with admin/info calls. + + Firmware gate: `src/SerialConsole.cpp` (`usingProtobufs && + config.security.debug_log_api_enabled`). Setting persists in NVS; it + survives reboot. `factory_reset(full=False)` clears it unless it's + re-applied after reset. + + Previously-documented concurrency hazard (emitLogRecord sharing the + main packet-emission buffers) has been fixed — see `StreamAPI.h` + where the log path now owns dedicated `fromRadioScratchLog` / + `txBufLog` buffers, and `StreamAPI::emitTxBuffer` + + `StreamAPI::emitLogRecord` both serialize their `stream->write` + calls via `streamLock`. Leaving the flag on under traffic is safe. + """ + with connect(port=port) as iface: + sec = iface.localNode.localConfig.security + sec.debug_log_api_enabled = bool(enabled) + iface.localNode.writeConfig("security") + return {"ok": True, "debug_log_api_enabled": bool(enabled)} + + +# ---------- admin actions -------------------------------------------------- + + +def reboot( + port: str | None = None, confirm: bool = False, seconds: int = 10 +) -> dict[str, Any]: + _require_confirm(confirm, "reboot") + with connect(port=port) as iface: + iface.localNode.reboot(secs=seconds) + return {"ok": True, "rebooting_in_s": seconds} + + +def shutdown( + port: str | None = None, confirm: bool = False, seconds: int = 10 +) -> dict[str, Any]: + _require_confirm(confirm, "shutdown") + with connect(port=port) as iface: + iface.localNode.shutdown(secs=seconds) + return {"ok": True, "shutting_down_in_s": seconds} + + +def factory_reset( + port: str | None = None, confirm: bool = False, full: bool = False +) -> dict[str, Any]: + """Tell the node to factory-reset its config. + + Works around a meshtastic-python 2.7.8 bug: `Node.factoryReset(full=True)` + internally does `p.factory_reset_config = True` where the field is + int32. protobuf 5.x rejects bool→int assignment as a TypeError. We build + the AdminMessage directly with int values (1=non-full, 2=full) and call + `_sendAdmin` to sidestep the SDK bug entirely. + """ + _require_confirm(confirm, "factory_reset") + from meshtastic.protobuf import admin_pb2 # type: ignore[import-untyped] + + with connect(port=port) as iface: + msg = admin_pb2.AdminMessage() + msg.factory_reset_config = 2 if full else 1 + iface.localNode._sendAdmin(msg) + return {"ok": True, "full": full} diff --git a/mcp-server/src/meshtastic_mcp/boards.py b/mcp-server/src/meshtastic_mcp/boards.py new file mode 100644 index 000000000..df5024800 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/boards.py @@ -0,0 +1,159 @@ +"""Board / PlatformIO env enumeration. + +Parses `pio project config --json-output` — a nested list of +`[section_name, [[key, value], ...]]` pairs — into a dict keyed by env name, +extracting the `custom_meshtastic_*` metadata the firmware variants expose. + +The parsed config is cached and invalidated when `platformio.ini`'s mtime +changes, so subsequent calls don't pay the 1–2s pio startup cost. +""" + +from __future__ import annotations + +import threading +from typing import Any + +from . import config, pio + +_CACHE_LOCK = threading.Lock() +_CACHE: dict[str, Any] = {"mtime": None, "envs": None} + + +def _parse_bool(value: Any) -> bool: + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.strip().lower() in ("true", "yes", "1", "on") + return bool(value) + + +def _parse_int(value: Any) -> int | None: + try: + return int(value) + except (TypeError, ValueError): + return None + + +def _parse_tags(value: Any) -> list[str]: + if value is None: + return [] + if isinstance(value, list): + return [str(v).strip() for v in value if str(v).strip()] + return [t.strip() for t in str(value).replace(",", " ").split() if t.strip()] + + +def _env_record(env_name: str, items: list[list[Any]]) -> dict[str, Any]: + """Build a normalized dict for one env section.""" + d = dict(items) + return { + "env": env_name, + "architecture": d.get("custom_meshtastic_architecture"), + "hw_model": _parse_int(d.get("custom_meshtastic_hw_model")), + "hw_model_slug": d.get("custom_meshtastic_hw_model_slug"), + "display_name": d.get("custom_meshtastic_display_name"), + "actively_supported": _parse_bool( + d.get("custom_meshtastic_actively_supported") + ), + "support_level": _parse_int(d.get("custom_meshtastic_support_level")), + "board_level": d.get("board_level"), # "pr", "extra", or None + "tags": _parse_tags(d.get("custom_meshtastic_tags")), + "images": _parse_tags(d.get("custom_meshtastic_images")), + "board": d.get("board"), + "upload_speed": _parse_int(d.get("upload_speed")), + "upload_protocol": d.get("upload_protocol"), + "monitor_speed": _parse_int(d.get("monitor_speed")), + "monitor_filters": d.get("monitor_filters") or [], + "_raw": d, # Full dict for get_board + } + + +def _load_all() -> dict[str, dict[str, Any]]: + """Parse `pio project config` into `{env_name: record}`.""" + raw = pio.run_json(["project", "config"], timeout=pio.TIMEOUT_PROJECT_CONFIG) + result: dict[str, dict[str, Any]] = {} + for section_name, items in raw: + if not isinstance(section_name, str) or not section_name.startswith("env:"): + continue + env_name = section_name.split(":", 1)[1] + result[env_name] = _env_record(env_name, items) + return result + + +def _get_cached() -> dict[str, dict[str, Any]]: + root = config.firmware_root() + platformio_ini = root / "platformio.ini" + try: + mtime = platformio_ini.stat().st_mtime + except FileNotFoundError: + mtime = None + + with _CACHE_LOCK: + if _CACHE["envs"] is not None and _CACHE["mtime"] == mtime: + return _CACHE["envs"] + envs = _load_all() + _CACHE["envs"] = envs + _CACHE["mtime"] = mtime + return envs + + +def invalidate_cache() -> None: + with _CACHE_LOCK: + _CACHE["envs"] = None + _CACHE["mtime"] = None + + +def _public_record(rec: dict[str, Any]) -> dict[str, Any]: + """Strip the `_raw` field for list outputs.""" + return {k: v for k, v in rec.items() if not k.startswith("_")} + + +def list_boards( + architecture: str | None = None, + actively_supported_only: bool = False, + query: str | None = None, + board_level: str | None = None, # "release" | "pr" | "extra" +) -> list[dict[str, Any]]: + """Enumerate PlatformIO envs with Meshtastic metadata. + + Filters are cumulative (AND). `board_level="release"` means envs with no + explicit `board_level` set (the default release targets). + """ + envs = _get_cached() + q = query.lower().strip() if query else None + + out = [] + for rec in envs.values(): + if architecture and rec.get("architecture") != architecture: + continue + if actively_supported_only and not rec.get("actively_supported"): + continue + if board_level is not None: + rec_level = rec.get("board_level") + if board_level == "release": + if rec_level not in (None, ""): + continue + elif rec_level != board_level: + continue + if q: + display = (rec.get("display_name") or "").lower() + env_name = rec.get("env", "").lower() + slug = (rec.get("hw_model_slug") or "").lower() + if q not in display and q not in env_name and q not in slug: + continue + out.append(_public_record(rec)) + + out.sort(key=lambda r: (r.get("architecture") or "", r.get("env"))) + return out + + +def get_board(env: str) -> dict[str, Any]: + """Full metadata for one env, including the raw pio config dict.""" + envs = _get_cached() + rec = envs.get(env) + if rec is None: + raise KeyError( + f"Unknown env: {env!r}. Use list_boards() to see available envs." + ) + public = _public_record(rec) + public["raw_config"] = rec["_raw"] + return public diff --git a/mcp-server/src/meshtastic_mcp/cli/__init__.py b/mcp-server/src/meshtastic_mcp/cli/__init__.py new file mode 100644 index 000000000..04729b643 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/__init__.py @@ -0,0 +1,6 @@ +"""Command-line entry points that sit alongside the MCP server. + +Modules here are loaded on-demand by `[project.scripts]` entries in +`pyproject.toml`. They are NOT imported by `meshtastic_mcp.server` or the +admin/info tool surface — the MCP server stays pure stdio JSON-RPC. +""" diff --git a/mcp-server/src/meshtastic_mcp/cli/_flashlog.py b/mcp-server/src/meshtastic_mcp/cli/_flashlog.py new file mode 100644 index 000000000..889183bb3 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_flashlog.py @@ -0,0 +1,73 @@ +"""Flash progress log tailer for ``meshtastic-mcp-test-tui``. + +``pio.py`` / ``hw_tools.py`` tee subprocess output (``pio run -t upload``, +``esptool erase_flash``, ``nrfutil dfu``, etc.) to ``tests/flash.log`` +line-by-line as it arrives — controlled by the ``MESHTASTIC_MCP_FLASH_LOG`` +env var that ``run-tests.sh`` sets. The TUI tails that file so the operator +sees live flash progress in the pytest pane instead of 3 minutes of silence +during ``test_00_bake``. + +Separate from ``_fwlog.py`` because that one parses JSONL, this one +streams plain text lines. Same daemon-thread + EOF-backoff structure. +""" + +from __future__ import annotations + +import pathlib +import threading +import time +from typing import Callable + + +class FlashLogTailer(threading.Thread): + """Tail a plain-text log file, publish each stripped line via ``post``. + + ``post`` is invoked with a single ``str`` for every new line. Lines are + stripped of trailing newlines; empty lines after stripping are dropped. + + The file may not exist yet when this thread starts — it's truncated by + ``run-tests.sh`` at session start, but if the tailer races the shell, + we tolerate FileNotFoundError for up to ``wait_s`` seconds. + """ + + def __init__( + self, + path: pathlib.Path, + post: Callable[[str], None], + stop: threading.Event, + *, + wait_s: float = 30.0, + ) -> None: + super().__init__(daemon=True, name="flashlog-tail") + self._path = path + self._post = post + self._stop = stop + self._wait_s = wait_s + + def run(self) -> None: + deadline = time.monotonic() + self._wait_s + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8", errors="replace") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.rstrip("\r\n") + if not line: + continue + try: + self._post(line) + except Exception: + # A post failure (e.g. closed app) is terminal for this + # thread but we still want to close the file handle. + return + finally: + fh.close() diff --git a/mcp-server/src/meshtastic_mcp/cli/_fwlog.py b/mcp-server/src/meshtastic_mcp/cli/_fwlog.py new file mode 100644 index 000000000..7db20f81c --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_fwlog.py @@ -0,0 +1,96 @@ +"""Firmware log tail worker for ``meshtastic-mcp-test-tui``. + +Complements v1's reportlog-tail worker. ``tests/conftest.py`` owns a +session-scoped autouse fixture (``_firmware_log_stream``) that mirrors +every ``meshtastic.log.line`` pubsub event to ``tests/fwlog.jsonl`` — +one JSON object per line: + + {"ts": 1729100000.123, "port": "/dev/cu.usbmodem1101", "line": "..."} + +The TUI tails that file from a worker thread; each new line becomes a +:class:`FirmwareLogLine` message posted to the App. Same pattern as the +reportlog tail worker — truncate on launch, tolerate missing file for +30 s, back off at EOF. + +Kept in its own module so the (large) ``test_tui.py`` stays focused on +the Textual App shell. +""" + +from __future__ import annotations + +import json +import pathlib +import threading +import time +from typing import Any, Callable + + +class FirmwareLogTailer(threading.Thread): + """Tail ``tests/fwlog.jsonl``, publish parsed records via ``post``. + + ``post`` is the App's ``post_message`` (or any callable that accepts a + single payload arg). We pass parsed dicts rather than constructing + Textual Message objects here — keeps this module free of the + textual dependency so it's unit-testable in a bare venv. + + Parameters + ---------- + path: + Path to ``tests/fwlog.jsonl``. The file may not exist yet at + startup — pytest only creates it once the session fixture runs. + post: + Callable invoked with a dict ``{"ts", "port", "line"}`` for every + new line parsed from the file. + stop: + An event the App sets to signal shutdown. + wait_s: + How long to poll for the file's creation before giving up. Default + 30 s; pytest collection on a cold cache can be slow. + + """ + + def __init__( + self, + path: pathlib.Path, + post: Callable[[dict[str, Any]], None], + stop: threading.Event, + *, + wait_s: float = 30.0, + ) -> None: + super().__init__(daemon=True, name="fwlog-tail") + self._path = path + self._post = post + self._stop = stop + self._wait_s = wait_s + + def run(self) -> None: + deadline = time.monotonic() + self._wait_s + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.strip() + if not line: + continue + try: + record = json.loads(line) + except json.JSONDecodeError: + continue + # Defensive: require the three fields we rely on. + if not isinstance(record, dict): + continue + if "line" not in record: + continue + self._post(record) + finally: + fh.close() diff --git a/mcp-server/src/meshtastic_mcp/cli/_history.py b/mcp-server/src/meshtastic_mcp/cli/_history.py new file mode 100644 index 000000000..639dcec5f --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_history.py @@ -0,0 +1,127 @@ +"""Cross-run history for ``meshtastic-mcp-test-tui``. + +Persists one JSON object per pytest run to +``mcp-server/tests/.history/runs.jsonl``. The TUI reads the last N +entries on launch to render a duration sparkline in the header — a +quick read on whether the suite is slowing down over time. + +Schema (keep small; the file can grow for months): + + {"run": 42, "ts": 1729100000.0, "duration_s": 387.2, + "passed": 52, "failed": 0, "skipped": 23, "exit_code": 0, + "seed": "mcp-user-host"} +""" + +from __future__ import annotations + +import json +import pathlib +import time +from dataclasses import asdict, dataclass +from typing import Iterable + +# Sparkline glyphs, low → high. 8 levels is the Unicode convention. +_SPARK_BLOCKS = "▁▂▃▄▅▆▇█" + + +@dataclass +class RunRecord: + run: int + ts: float + duration_s: float + passed: int + failed: int + skipped: int + exit_code: int + seed: str + + +class HistoryStore: + """Append-only JSONL store with bounded read. + + Writes are fsynced after each append (the file is tiny; fsync cost + is negligible and protects against truncation on a crash). + """ + + def __init__(self, path: pathlib.Path, *, keep_last: int = 50) -> None: + self._path = path + self._keep_last = keep_last + + def append(self, record: RunRecord) -> None: + try: + self._path.parent.mkdir(parents=True, exist_ok=True) + with self._path.open("a", encoding="utf-8") as fh: + fh.write(json.dumps(asdict(record)) + "\n") + fh.flush() + except Exception: + # Non-fatal: history is cosmetic. + pass + + def read_recent(self) -> list[RunRecord]: + """Return the last ``keep_last`` records in chronological order.""" + if not self._path.is_file(): + return [] + try: + lines = self._path.read_text(encoding="utf-8").splitlines() + except OSError: + return [] + out: list[RunRecord] = [] + # Parse tail-first so we don't waste work on a huge history. + for line in lines[-self._keep_last :]: + line = line.strip() + if not line: + continue + try: + raw = json.loads(line) + except json.JSONDecodeError: + continue + try: + out.append(RunRecord(**raw)) + except TypeError: + # Schema drift; skip the record rather than crash. + continue + return out + + def record_run( + self, + *, + run: int, + duration_s: float, + passed: int, + failed: int, + skipped: int, + exit_code: int, + seed: str, + ) -> RunRecord: + rec = RunRecord( + run=run, + ts=time.time(), + duration_s=float(duration_s), + passed=int(passed), + failed=int(failed), + skipped=int(skipped), + exit_code=int(exit_code), + seed=seed, + ) + self.append(rec) + return rec + + +def sparkline(values: Iterable[float], *, width: int = 20) -> str: + """Render a Unicode block-character sparkline from the last ``width`` values. + + Returns an empty string for empty input so the header handles + "no history yet" gracefully. + """ + buf = [v for v in values if v >= 0][-width:] + if not buf: + return "" + lo, hi = min(buf), max(buf) + if hi - lo < 1e-9: + return _SPARK_BLOCKS[len(_SPARK_BLOCKS) // 2] * len(buf) + n = len(_SPARK_BLOCKS) - 1 + out = [] + for v in buf: + idx = int(round((v - lo) / (hi - lo) * n)) + out.append(_SPARK_BLOCKS[max(0, min(n, idx))]) + return "".join(out) diff --git a/mcp-server/src/meshtastic_mcp/cli/_reproducer.py b/mcp-server/src/meshtastic_mcp/cli/_reproducer.py new file mode 100644 index 000000000..420da3c76 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_reproducer.py @@ -0,0 +1,214 @@ +"""Reproducer bundle builder for ``meshtastic-mcp-test-tui``. + +When the operator presses ``x`` on a failed test leaf, we package the +minimum viable failure context into a tarball under +``mcp-server/tests/reproducers/``: + +:: + + repro--.tar.gz + ├── README.md human-readable overview + ├── test_report.json the failing TestReport event from reportlog + ├── fwlog.jsonl firmware log filtered to the failure window + ├── devices.json per-device device_info + lora config snapshot + └── env.json seed, run #, pytest version, platform, hostname + +Separate module so the logic can be unit-tested without Textual. The +TUI glue is thin — one key binding calls :func:`build_reproducer_bundle` +with the focused test's state and shows the path in a modal. +""" + +from __future__ import annotations + +import io +import json +import pathlib +import platform +import re +import socket +import tarfile +import time +from dataclasses import dataclass +from typing import Any, Iterable + + +@dataclass +class ReproContext: + """Everything :func:`build_reproducer_bundle` needs. Shaped to map + cleanly onto the state the TUI already tracks — no extra data + collection required at export time.""" + + nodeid: str + longrepr: str + sections: list[tuple[str, str]] + start_ts: float | None + stop_ts: float | None + seed: str + run_number: int + exit_code: int | None + fwlog_path: pathlib.Path + output_dir: pathlib.Path + extra_device_rows: list[dict[str, Any]] # [{role, port, info, ...}, ...] + + +def _short_nodeid(nodeid: str) -> str: + """Collapse a pytest nodeid into a filename-safe slug (<= 60 chars).""" + # Drop the file path prefix; keep test name + parametrization. + tail = nodeid.split("::", 1)[-1] if "::" in nodeid else nodeid + slug = re.sub(r"[^A-Za-z0-9_.\-]", "_", tail) + return slug[:60].strip("_.-") or "test" + + +def _filtered_fwlog( + fwlog_path: pathlib.Path, + start_ts: float | None, + stop_ts: float | None, + *, + pad_s: float = 5.0, +) -> bytes: + """Return fwlog.jsonl lines whose ``ts`` lies in [start-pad, stop+pad].""" + if not fwlog_path.is_file(): + return b"" + if start_ts is None or stop_ts is None: + # Without a time window, include the whole file — rare; happens + # when a test fails in setup before pytest emitted a start ts. + try: + return fwlog_path.read_bytes() + except OSError: + return b"" + lo, hi = start_ts - pad_s, stop_ts + pad_s + out = io.BytesIO() + try: + with fwlog_path.open("r", encoding="utf-8") as fh: + for line in fh: + stripped = line.strip() + if not stripped: + continue + try: + record = json.loads(stripped) + except json.JSONDecodeError: + continue + ts = record.get("ts") + if not isinstance(ts, (int, float)): + continue + if lo <= ts <= hi: + out.write(line.encode("utf-8")) + except OSError: + return b"" + return out.getvalue() + + +def _readme(ctx: ReproContext) -> str: + t = time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()) + return f"""# Reproducer bundle + +Exported by `meshtastic-mcp-test-tui` on {t}. + +## Failing test + +- **nodeid:** `{ctx.nodeid}` +- **seed:** `{ctx.seed}` +- **run #:** {ctx.run_number} +- **suite exit code (at export time):** {ctx.exit_code if ctx.exit_code is not None else "in progress"} + +## Files in this archive + +| File | Contents | +|---|---| +| `test_report.json` | The pytest-reportlog `TestReport` event for the failing test — includes `longrepr`, captured `sections` (stdout/stderr/log), `duration`, `location`, `keywords`. | +| `fwlog.jsonl` | Firmware log lines (from `meshtastic.log.line` pubsub) filtered to [start−5s, stop+5s] around the test's run window. Each line is `{{ts, port, line}}`. | +| `devices.json` | Per-device snapshot at export time: `device_info` + `lora` config per detected role. | +| `env.json` | Python version, platform, hostname, seed, run number. | + +## How to triage + +1. Open `test_report.json` and read `longrepr` + `sections` — most failures explain themselves there. +2. If the failure is a mesh/telemetry assertion, `fwlog.jsonl` is where the answer usually lives. Grep for `Error=`, `NAK`, `PKI_UNKNOWN_PUBKEY`, `Skip send`, `Guru Meditation`, or the uptime timestamps around the assertion event. +3. Compare `devices.json` against the expected state (e.g. `num_nodes >= 2`, `primary_channel == "McpTest"`, `region == "US"`). If fields disagree with the seed-derived USERPREFS profile, the device probably wasn't baked with this session's profile. + +## Reproducing locally + +```bash +cd mcp-server +MESHTASTIC_MCP_SEED='{ctx.seed}' .venv/bin/pytest '{ctx.nodeid}' --tb=long -v +``` +""" + + +def build_reproducer_bundle(ctx: ReproContext) -> pathlib.Path: + """Build a tarball under ``ctx.output_dir`` and return its path. + + Parent dirs are created as needed. Errors during optional sections + (devices, env) are swallowed — the bundle is still useful without + them; refusing to export because the device poller had a hiccup + would be worse than the export missing a file. + """ + ctx.output_dir.mkdir(parents=True, exist_ok=True) + ts = int(time.time()) + slug = _short_nodeid(ctx.nodeid) + archive_path = ctx.output_dir / f"repro-{ts}-{slug}.tar.gz" + + with tarfile.open(archive_path, "w:gz") as tar: + + def _add(name: str, data: bytes) -> None: + info = tarfile.TarInfo(name=name) + info.size = len(data) + info.mtime = ts + tar.addfile(info, io.BytesIO(data)) + + # README + _add("README.md", _readme(ctx).encode("utf-8")) + + # test_report.json — reconstruct from the fields the TUI stashes. + test_report = { + "nodeid": ctx.nodeid, + "outcome": "failed", + "longrepr": ctx.longrepr, + "sections": [list(s) for s in ctx.sections], + "start": ctx.start_ts, + "stop": ctx.stop_ts, + } + _add( + "test_report.json", + json.dumps(test_report, indent=2, default=str).encode("utf-8"), + ) + + # fwlog.jsonl (filtered) + _add("fwlog.jsonl", _filtered_fwlog(ctx.fwlog_path, ctx.start_ts, ctx.stop_ts)) + + # devices.json + try: + devices_payload = json.dumps( + ctx.extra_device_rows or [], indent=2, default=str + ) + except Exception: + devices_payload = "[]" + _add("devices.json", devices_payload.encode("utf-8")) + + # env.json + try: + from importlib.metadata import version as _pkg_version + + pytest_version = _pkg_version("pytest") + except Exception: + pytest_version = "unknown" + env_payload = { + "seed": ctx.seed, + "run": ctx.run_number, + "exit_code": ctx.exit_code, + "export_ts": ts, + "python": platform.python_version(), + "pytest": pytest_version, + "platform": f"{platform.system()} {platform.release()} {platform.machine()}", + "hostname": socket.gethostname(), + } + _add("env.json", json.dumps(env_payload, indent=2).encode("utf-8")) + + return archive_path + + +def iter_entries(archive_path: pathlib.Path) -> Iterable[str]: + """Yield member names — used by callers that want to confirm the bundle shape.""" + with tarfile.open(archive_path, "r:gz") as tar: + for m in tar.getmembers(): + yield m.name diff --git a/mcp-server/src/meshtastic_mcp/cli/test_tui.py b/mcp-server/src/meshtastic_mcp/cli/test_tui.py new file mode 100644 index 000000000..33201101b --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/test_tui.py @@ -0,0 +1,1782 @@ +"""Textual TUI wrapping `mcp-server/run-tests.sh`. + +Launch: ``meshtastic-mcp-test-tui [pytest-args]`` + +The TUI *wraps* ``run-tests.sh``; it never replaces it. Same script, same +env-var resolution, same ``userPrefs.jsonc`` session fixture. Four data +sources drive live state: + +1. ``tests/reportlog.jsonl`` — written by ``pytest-reportlog``. Tailed in a + worker thread; each JSON line is published as a :class:`ReportLogEvent` + message. This is the authoritative source for tree population + per-test + outcome. +2. The pytest subprocess ``stdout`` + ``stderr`` streams — line-by-line, + published as :class:`PytestLine` messages and rendered verbatim in the + pytest pane. +3. ``tests/fwlog.jsonl`` — firmware log stream. Written by the + ``_firmware_log_stream`` autouse session fixture in ``conftest.py`` + (mirrors every ``meshtastic.log.line`` pubsub event), tailed by the + :class:`FirmwareLogTailer` worker, displayed in a wrap-enabled + RichLog with cycleable port filter. +4. ``devices.list_devices()`` + ``info.device_info(port)`` — polled only at + startup and again after ``RunFinished``. Device polling while pytest + holds a SerialInterface would deadlock on the exclusive port lock; the + existing ``hub_devices`` fixture is session-scoped so there is no safe + "between tests" window. The header reflects this with a "(stale)" + marker while the run is active. + +Key bindings (see :class:`TestTuiApp.BINDINGS`): + ``r`` re-run focused ``f`` filter tree ``d`` failure detail + ``g`` open report.html ``l`` cycle firmware-log port filter + ``x`` export reproducer bundle ``c`` tool-coverage panel + ``q`` / Ctrl-C graceful quit with SIGINT → SIGTERM → SIGKILL escalation + +Shipped today (v1 + v2 slice): test tree + tier counters with progress bars, +pytest tail, live firmware log with port filter, device strip with +"currently running" status column, failure-detail modal, reproducer bundle +export (filters fwlog by test's start/stop timestamps), tool-coverage +modal, cross-run history sparkline in the header, clean SIGINT +propagation. Still open (see the plan file): mesh topology mini-diagram +and airtime / channel-utilization gauges. +""" + +from __future__ import annotations + +import argparse +import json +import os +import pathlib +import signal +import subprocess +import sys +import threading +import time +from dataclasses import dataclass, field +from typing import Any, Iterator + +# --------------------------------------------------------------------------- +# Configuration constants +# --------------------------------------------------------------------------- + +# Tier names that map nodeids like "tests//..." to counter buckets. +# Order here == display order in the tier-counters table. Matches the order +# `pytest_collection_modifyitems` in `conftest.py` uses: +# bake → unit → mesh → telemetry → monitor → fleet → admin → provisioning +# so the counters table reads top-to-bottom in execution order. +# +# "bake" is the synthetic tier for `tests/test_00_bake.py` — the file sits +# at the `tests/` root rather than under a tier subdirectory, so without +# this mapping `_tier_of_nodeid` would return "other" and the bake outcomes +# would be silently dropped from both the tier table and the history +# record (which sums tier counters to compute passed/failed/skipped). +TIERS = ( + "bake", + "unit", + "mesh", + "telemetry", + "monitor", + "fleet", + "admin", + "provisioning", +) + +# Relative paths from the mcp-server root. +_REPORTLOG_RELATIVE = "tests/reportlog.jsonl" +_FWLOG_RELATIVE = "tests/fwlog.jsonl" +# pio / esptool / nrfutil / picotool tee subprocess output here when +# `MESHTASTIC_MCP_FLASH_LOG` is set (see `pio._run_capturing`). run-tests.sh +# sets that env var; the TUI also sets it for direct `_spawn_pytest` calls +# so `r`-key re-runs that skip the wrapper still get tee'd output. +_FLASHLOG_RELATIVE = "tests/flash.log" +_REPORT_HTML_RELATIVE = "tests/report.html" +_TOOL_COVERAGE_RELATIVE = "tests/tool_coverage.json" +_HISTORY_RELATIVE = "tests/.history/runs.jsonl" +_REPRODUCERS_RELATIVE = "tests/reproducers" +_RUN_TESTS_RELATIVE = "run-tests.sh" +_RUN_COUNTER_RELATIVE = "tests/.tui-runs" + +# Graceful-shutdown budgets (seconds) for the pytest subprocess when the +# user hits `q`. Matches what the existing CLI's atexit + userprefs sidecar +# self-heal expects. +_SIGINT_GRACE_S = 5.0 +_SIGTERM_GRACE_S = 5.0 + + +# --------------------------------------------------------------------------- +# Path resolution +# --------------------------------------------------------------------------- + + +def _mcp_server_root() -> pathlib.Path: + """Locate the mcp-server directory (the one containing run-tests.sh).""" + here = pathlib.Path(__file__).resolve() + # Walk up until we find pyproject.toml with a matching project name, or + # default to the three-up ancestor (src/meshtastic_mcp/cli/test_tui.py → + # .../mcp-server). The walk-up protects against unusual checkouts. + for parent in (here.parent, *here.parents): + if (parent / "pyproject.toml").is_file() and ( + parent / "run-tests.sh" + ).is_file(): + return parent + return here.parents[3] + + +# --------------------------------------------------------------------------- +# Data classes +# --------------------------------------------------------------------------- + + +@dataclass +class LeafReport: + """Per-test state drawn from reportlog events. + + Outcomes mirror pytest's: "passed" | "failed" | "skipped" | "running". + """ + + nodeid: str + tier: str + outcome: str = "pending" + duration_s: float = 0.0 + longrepr: str = "" + # Captured stdout / stderr / firmware-log sections from the test's + # `TestReport.sections` — shown in the failure-detail modal. + sections: list[tuple[str, str]] = field(default_factory=list) + # Wall-clock start/stop from the TestReport event. Used by the + # reproducer exporter (`x`) to filter `tests/fwlog.jsonl` down to + # just the lines around the failure window. + start_ts: float | None = None + stop_ts: float | None = None + + +@dataclass +class TierCounters: + tier: str + passed: int = 0 + failed: int = 0 + skipped: int = 0 + running: int = 0 + remaining: int = 0 + + +@dataclass +class DeviceRow: + role: str | None + port: str + vid: str + pid: str + description: str + # Populated from info.device_info when available; empty dict when we + # haven't queried (or when the poller is paused). + info: dict[str, Any] = field(default_factory=dict) + + +@dataclass +class State: + """Shared state owned by the App; written by workers under `lock`. + + UI code reads via Textual Message handlers which run on the UI thread + in the order workers called `post_message` — so reads don't need the + lock themselves. + """ + + lock: threading.Lock = field(default_factory=threading.Lock) + tiers: dict[str, TierCounters] = field( + default_factory=lambda: {t: TierCounters(tier=t) for t in TIERS} + ) + leaves: dict[str, LeafReport] = field(default_factory=dict) + # Ordered list of nodeids in the order they were first seen — lets us + # rebuild the tree deterministically. + nodeid_order: list[str] = field(default_factory=list) + devices: list[DeviceRow] = field(default_factory=list) + run_active: bool = False + exit_code: int | None = None + # nodeid of the currently-running test. Set on `when="setup"` + + # outcome="passed" (body about to execute); cleared on `when="call"` + # (any outcome) or on `when="setup"` + outcome="failed" (no body + # window). Drives the device-table "Status" column so the operator + # can see which test is touching a given device right now. + running_nodeid: str | None = None + # `time.monotonic()` captured when `running_nodeid` was set. Surfaced + # as live-updating elapsed-time ("RUNNING: test_bake_nrf52 (1:23)") so + # an operator staring at a ~3 min `test_00_bake` or a `mesh_formation` + # with a 60 s ceiling has concrete evidence the test isn't stuck. + running_started_at: float | None = None + + +# --------------------------------------------------------------------------- +# Helpers +# --------------------------------------------------------------------------- + + +def _tier_of_nodeid(nodeid: str) -> str: + """Map a pytest nodeid to its tier bucket. Unknown → 'other'. + + `tests/test_00_bake.py::...` is special-cased to the synthetic `bake` + tier — it's a top-level file (no tier subdirectory) so the generic + "second path segment" logic would miss it and route the bake outcomes + into the non-existent `other` bucket. + """ + parts = nodeid.split("/", 2) + if len(parts) >= 2 and parts[0] == "tests": + # Bake file sits at `tests/test_00_bake.py` — dedicated bucket. + if parts[1].startswith("test_00_bake"): + return "bake" + candidate = parts[1] + if candidate in TIERS: + return candidate + return "other" + + +def _file_of_nodeid(nodeid: str) -> str: + """Extract the test file name (e.g. 'test_boards.py') from a nodeid.""" + left = nodeid.split("::", 1)[0] + return left.rsplit("/", 1)[-1] + + +def _testname_of_nodeid(nodeid: str) -> str: + """Extract the 'test_foo[param]' suffix from a nodeid, or the full thing.""" + if "::" in nodeid: + return nodeid.split("::", 1)[1] + return nodeid + + +def _roles_from_nodeid(nodeid: str) -> set[str]: + """Infer which device roles a parametrized test touches. + + Patterns we recognize (from the existing ``conftest.py`` parametrization + in ``pytest_generate_tests``): + + - ``test_foo[nrf52]`` → {"nrf52"} (baked_single) + - ``test_foo[nrf52->esp32s3]`` → {"nrf52", "esp32s3"} (mesh_pair) + + Unparametrized tests (no bracket) return an empty set — the caller + should fall back to "this test involves ALL detected devices" rather + than pretending it touches none. + """ + if "[" not in nodeid or not nodeid.endswith("]"): + return set() + try: + inner = nodeid.rsplit("[", 1)[1][:-1] + except Exception: + return set() + # Split on "->" for directed mesh pairs; otherwise treat as single role. + parts = [p.strip() for p in inner.split("->")] if "->" in inner else [inner.strip()] + return {p for p in parts if p} + + +def _parse_events(path: pathlib.Path) -> Iterator[dict[str, Any]]: + """Yield parsed JSON dicts from a reportlog file, skipping malformed lines. + + Used for smoke-testing the parser against a finished file; the live + worker has its own tail loop. + """ + if not path.is_file(): + return + with path.open("r", encoding="utf-8") as fh: + for line in fh: + line = line.strip() + if not line: + continue + try: + yield json.loads(line) + except json.JSONDecodeError: + continue + + +def _load_run_number(counter_path: pathlib.Path) -> int: + """Bump + persist a monotonic run counter used in the TUI header.""" + try: + n = int(counter_path.read_text().strip()) + except Exception: + n = 0 + n += 1 + try: + counter_path.parent.mkdir(parents=True, exist_ok=True) + counter_path.write_text(str(n)) + except Exception: + # Non-fatal: the counter is cosmetic. + pass + return n + + +def _resolve_seed() -> str: + """Mirror the default-seed resolution from run-tests.sh. + + Operator can override via MESHTASTIC_MCP_SEED. Matches the + per-user/per-host default so repeated invocations land on the same PSK + (makes --assume-baked valid across invocations). + """ + if explicit := os.environ.get("MESHTASTIC_MCP_SEED"): + return explicit + try: + who = os.environ.get("USER") or os.environ.get("LOGNAME") or "anon" + except Exception: + who = "anon" + try: + import socket + + host = socket.gethostname().split(".", 1)[0] + except Exception: + host = "host" + return f"mcp-{who}-{host}" + + +def _format_duration(seconds: float) -> str: + if seconds < 60: + return f"{seconds:5.1f}s" + m, s = divmod(int(seconds), 60) + return f"{m:d}:{s:02d}" + + +# --------------------------------------------------------------------------- +# Textual imports (lazy — only when main() runs, so `_parse_events` can be +# imported by smoke tests without requiring textual installed in every env) +# --------------------------------------------------------------------------- + + +def _import_textual() -> Any: + """Return a namespace carrying every Textual class we use. + + Deferred import keeps `_parse_events` + `_tier_of_nodeid` importable + from tests / smoke scripts without pulling in the UI stack. + """ + import textual + from textual.app import App, ComposeResult + from textual.binding import Binding + from textual.containers import Horizontal, Vertical + from textual.message import Message + from textual.screen import ModalScreen + from textual.widgets import DataTable, Footer, Input, RichLog, Static, Tree + + ns = argparse.Namespace() + ns.App = App + ns.Binding = Binding + ns.ComposeResult = ComposeResult + ns.DataTable = DataTable + ns.Footer = Footer + ns.Horizontal = Horizontal + ns.Input = Input + ns.Message = Message + ns.ModalScreen = ModalScreen + ns.RichLog = RichLog + ns.Static = Static + ns.Tree = Tree + ns.Vertical = Vertical + ns.textual = textual + return ns + + +# --------------------------------------------------------------------------- +# main() — the important scaffolding lives here so that when we bail out +# before entering the Textual event loop (missing terminal, --help, etc.) +# nothing has grabbed the screen yet. +# --------------------------------------------------------------------------- + + +def main(argv: list[str] | None = None) -> int: + """Entry point for `meshtastic-mcp-test-tui`.""" + argv = list(argv if argv is not None else sys.argv[1:]) + + parser = argparse.ArgumentParser( + prog="meshtastic-mcp-test-tui", + description=( + "Live Textual TUI wrapping mcp-server/run-tests.sh. " + "Passes any unrecognized arguments through to pytest." + ), + allow_abbrev=False, + ) + parser.add_argument( + "--no-tui", + action="store_true", + help=( + "Skip the TUI and exec run-tests.sh directly. Useful as a health " + "check that the wrapper argv+env resolution is working." + ), + ) + args, pytest_args = parser.parse_known_args(argv) + + root = _mcp_server_root() + run_tests = root / _RUN_TESTS_RELATIVE + reportlog = root / _REPORTLOG_RELATIVE + fwlog = root / _FWLOG_RELATIVE + flashlog = root / _FLASHLOG_RELATIVE + counter = root / _RUN_COUNTER_RELATIVE + + if not run_tests.is_file(): + print( + f"error: could not locate {_RUN_TESTS_RELATIVE} relative to " + f"{root}. Is this the mcp-server checkout?", + file=sys.stderr, + ) + return 2 + + # Always clear stale log files before launching pytest. The TUI's tail + # workers race pytest file-creation; starting from a known-empty state + # avoids mid-line-decode confusion from the prior run. The fwlog session + # fixture also truncates on its end, and run-tests.sh truncates the + # flashlog — triple-truncate is deliberate (whichever side creates the + # file first, it starts empty). + for p in (reportlog, fwlog, flashlog): + try: + p.unlink(missing_ok=True) + except Exception: + pass + + # Compute + persist the run counter for the header (cosmetic). + run_number = _load_run_number(counter) + seed = _resolve_seed() + # Export the seed so the subprocess inherits the SAME value the TUI + # displays. run-tests.sh computes its own fallback if unset, and we'd + # end up with a header / wrapper-header mismatch if we let that happen. + os.environ.setdefault("MESHTASTIC_MCP_SEED", seed) + # Turn on subprocess-output tee'ing so `pio._run_capturing` writes each + # line of pio / esptool / nrfutil / picotool output to `tests/flash.log` + # as it arrives. The TUI tails that file and routes each line to the + # pytest pane so the operator sees live flash progress during long + # `pio run -t upload` / `esptool erase_flash` operations. run-tests.sh + # also sets this when invoked directly — `setdefault` so the wrapper's + # value wins when present. + os.environ.setdefault("MESHTASTIC_MCP_FLASH_LOG", str(flashlog)) + + # --no-tui: exec run-tests.sh directly. Useful for diagnosing wrapper + # env / argv handling without getting into Textual's alternate screen. + if args.no_tui: + cmd = [str(run_tests), *pytest_args] + os.execv(str(run_tests), cmd) # noqa: S606 — intentional + + # Textual UI import is deferred so `--help` and `--no-tui` do not pay + # the ~40 MB startup cost. + try: + tx = _import_textual() + except ImportError as exc: + print( + f"error: textual is not installed ({exc}). Install with: " + f"pip install -e '.[test]'", + file=sys.stderr, + ) + return 2 + + # Narrow-terminal warning (see plan §8 risk 2). Textual itself degrades, + # but a heads-up helps a first-time user. + term = os.environ.get("TERM", "") + if term in ("", "dumb", "screen") and not os.environ.get("TEXTUAL_NO_TERM_HINT"): + print( + f"[hint] TERM={term!r} may render poorly. Try " + f"`TERM=xterm-256color meshtastic-mcp-test-tui ...` if the layout " + f"looks broken.", + file=sys.stderr, + ) + + app = _build_app( + tx=tx, + root=root, + run_tests=run_tests, + reportlog=reportlog, + fwlog=fwlog, + flashlog=flashlog, + seed=seed, + run_number=run_number, + pytest_args=pytest_args, + ) + + # App.run() returns the subprocess exit code via `app.exit(returncode)`. + return_value = app.run() + if isinstance(return_value, int): + return return_value + return 0 + + +# --------------------------------------------------------------------------- +# Everything below is only reachable once Textual is importable. `tx` is +# the namespace returned by `_import_textual()` so we don't scatter `from +# textual import ...` across the file. +# --------------------------------------------------------------------------- + + +def _build_app( + *, + tx: Any, + root: pathlib.Path, + run_tests: pathlib.Path, + reportlog: pathlib.Path, + fwlog: pathlib.Path, + flashlog: pathlib.Path, + seed: str, + run_number: int, + pytest_args: list[str], +) -> Any: + """Assemble TestTuiApp with its Textual-dependent inner classes. + + Keeping the class definitions inside a factory means `main()` can + short-circuit (--no-tui, terminal-check, argparse error) before we + force Textual's import cost. + """ + + # Helper modules — lazy-imported here so the top-of-file import cost + # only kicks in when main() has decided to run the TUI. + from . import _flashlog as _flashlog_mod + from . import _fwlog as _fwlog_mod + from . import _history as _history_mod + from . import _reproducer as _reproducer_mod + + # ---------------- Messages ---------------- + + class ReportLogEvent(tx.Message): + def __init__(self, event: dict[str, Any]) -> None: + self.event = event + super().__init__() + + class PytestLine(tx.Message): + def __init__(self, source: str, line: str) -> None: + self.source = source # "stdout" | "stderr" + self.line = line + super().__init__() + + class FirmwareLogLine(tx.Message): + def __init__(self, record: dict[str, Any]) -> None: + # {"ts": float, "port": str | None, "line": str} + self.record = record + super().__init__() + + class FlashLogLine(tx.Message): + """Plain-text line from `tests/flash.log` — pio / esptool / nrfutil / + picotool output tee'd by `pio._run_capturing`. Routed to the pytest + pane so the operator sees live flash progress during `test_00_bake` + instead of 3 minutes of pytest-captured silence.""" + + def __init__(self, line: str) -> None: + self.line = line + super().__init__() + + class DeviceSnapshot(tx.Message): + def __init__(self, rows: list[DeviceRow]) -> None: + self.rows = rows + super().__init__() + + class RunFinished(tx.Message): + def __init__(self, returncode: int) -> None: + self.returncode = returncode + super().__init__() + + # ---------------- Workers ---------------- + + class ReportlogWorker(threading.Thread): + """Tail `reportlog.jsonl`, publish each event.""" + + def __init__(self, app: Any, path: pathlib.Path, stop: threading.Event) -> None: + super().__init__(daemon=True, name="reportlog-tail") + self._app = app + self._path = path + self._stop = stop + + def run(self) -> None: + # Wait up to 30 s for pytest to create the file (first call on + # a cold cache can be slow). + wait_deadline = time.monotonic() + 30.0 + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > wait_deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.strip() + if not line: + continue + try: + event = json.loads(line) + except json.JSONDecodeError: + continue + self._app.post_message(ReportLogEvent(event)) + finally: + fh.close() + + class SubprocessReaderWorker(threading.Thread): + """Read one stream line-by-line and publish PytestLine messages.""" + + def __init__( + self, + app: Any, + stream: Any, + source: str, + stop: threading.Event, + ) -> None: + super().__init__(daemon=True, name=f"subprocess-{source}") + self._app = app + self._stream = stream + self._source = source + self._stop = stop + + def run(self) -> None: + try: + for line in iter(self._stream.readline, ""): + if self._stop.is_set(): + break + self._app.post_message( + PytestLine(source=self._source, line=line.rstrip("\n")) + ) + except Exception: + # stream closed / subprocess died; not fatal. + pass + + class DevicePollerWorker(threading.Thread): + """Poll list_devices() + device_info() at startup and after RunFinished. + + Deliberately NOT polling during the run — `hub_devices` is a + session-scoped fixture holding SerialInterfaces across the whole + session, and device_info() would deadlock on the exclusive port + lock. Header shows "(stale)" during the gap. + """ + + def __init__(self, app: Any, state: State, stop: threading.Event) -> None: + super().__init__(daemon=True, name="device-poller") + self._app = app + self._state = state + self._stop = stop + self._trigger = threading.Event() + + def trigger(self) -> None: + self._trigger.set() + + def run(self) -> None: + # Perform one poll at startup; then wait for explicit triggers. + self._poll_once() + while not self._stop.is_set(): + if self._trigger.wait(timeout=0.5): + self._trigger.clear() + if self._stop.is_set(): + break + with self._state.lock: + active = self._state.run_active + if active: + continue + self._poll_once() + + def _poll_once(self) -> None: + try: + from meshtastic_mcp import devices as devices_mod + from meshtastic_mcp import info as info_mod + except Exception as exc: # pragma: no cover + self._app.post_message( + PytestLine( + source="stderr", line=f"[tui] device import failed: {exc!r}" + ) + ) + return + rows: list[DeviceRow] = [] + try: + raw = devices_mod.list_devices(include_unknown=True) + except Exception as exc: + self._app.post_message( + PytestLine( + source="stderr", line=f"[tui] list_devices failed: {exc!r}" + ) + ) + return + for d in raw: + vid_raw = d.get("vid") or "" + try: + vid_i = ( + int(vid_raw, 16) + if isinstance(vid_raw, str) and vid_raw.startswith("0x") + else int(vid_raw) + ) + except (TypeError, ValueError): + vid_i = 0 + role = None + if vid_i == 0x239A: + role = "nrf52" + elif vid_i in (0x303A, 0x10C4): + role = "esp32s3" + if not role and not d.get("likely_meshtastic"): + continue + row = DeviceRow( + role=role, + port=d.get("port", ""), + vid=str(vid_raw), + pid=str(d.get("pid") or ""), + description=d.get("description", "") or "", + ) + if role: + try: + row.info = info_mod.device_info(port=row.port, timeout_s=6.0) + except Exception as exc: + row.info = {"error": repr(exc)} + rows.append(row) + self._app.post_message(DeviceSnapshot(rows=rows)) + + # ---------------- Modals ---------------- + + class FailureDetailScreen(tx.ModalScreen): + """Show a failed test's longrepr + captured sections.""" + + BINDINGS = [tx.Binding("escape,q", "dismiss", "close")] + + def __init__(self, leaf: LeafReport, report_html: pathlib.Path) -> None: + self._leaf = leaf + self._report_html = report_html + super().__init__() + + def compose(self) -> Any: + yield tx.Static( + f"[bold]{self._leaf.nodeid}[/bold] " + f"outcome=[red]{self._leaf.outcome}[/red] " + f"duration={_format_duration(self._leaf.duration_s)}", + id="failure-detail-header", + ) + log = tx.RichLog( + highlight=False, markup=False, wrap=False, id="failure-detail-log" + ) + yield log + yield tx.Static( + f"[dim]Full HTML report: {self._report_html}[/dim] [esc] close", + id="failure-detail-footer", + ) + + def on_mount(self) -> None: + log = self.query_one("#failure-detail-log", tx.RichLog) + if self._leaf.longrepr: + log.write(self._leaf.longrepr) + log.write("") + for section_name, section_text in self._leaf.sections: + log.write(f"--- {section_name} ---") + log.write(section_text) + log.write("") + if not self._leaf.longrepr and not self._leaf.sections: + log.write("(no longrepr or captured sections in reportlog event)") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + class FilterInputScreen(tx.ModalScreen[str]): + """Prompt the user for a tree filter substring (empty clears).""" + + BINDINGS = [tx.Binding("escape", "cancel", "cancel")] + + def compose(self) -> Any: + yield tx.Static("filter test tree (substring, empty = clear):") + yield tx.Input(placeholder="nodeid substring", id="filter-input") + + def on_input_submitted(self, event: Any) -> None: + self.dismiss(event.value.strip()) + + def action_cancel(self) -> None: + self.dismiss(None) + + class CoverageModal(tx.ModalScreen): + """Read `tests/tool_coverage.json` (written by `tests/tool_coverage.py` + at `pytest_sessionfinish`) and render a two-column summary of which + MCP tools got exercised by the run. `(no coverage data yet)` while + the run is in flight.""" + + BINDINGS = [tx.Binding("escape,q,c", "dismiss", "close")] + + def __init__(self, coverage_path: pathlib.Path) -> None: + self._path = coverage_path + super().__init__() + + def compose(self) -> Any: + yield tx.Static("[bold]MCP tool coverage[/bold]", id="coverage-header") + yield tx.RichLog( + highlight=False, markup=True, wrap=False, id="coverage-log" + ) + yield tx.Static( + f"[dim]{self._path}[/dim] [esc] close", + id="coverage-footer", + ) + + def on_mount(self) -> None: + log = self.query_one("#coverage-log", tx.RichLog) + if not self._path.is_file(): + log.write("(no coverage data — tool_coverage.json not written yet)") + log.write("") + log.write("Coverage is emitted at pytest_sessionfinish; this") + log.write("file appears after the suite completes.") + return + try: + data = json.loads(self._path.read_text(encoding="utf-8")) + except Exception as exc: + log.write(f"[red]failed to read {self._path}:[/red] {exc!r}") + return + calls = data.get("calls") or {} + if not calls: + log.write("(tool_coverage.json present but no calls recorded)") + return + exercised = sorted( + ((n, c) for n, c in calls.items() if c > 0), key=lambda x: -x[1] + ) + unexercised = sorted(n for n, c in calls.items() if c == 0) + log.write(f"[b]{len(exercised)} / {len(calls)} MCP tools exercised[/b]") + log.write("") + log.write("[green]exercised[/green] (count):") + for name, count in exercised: + log.write(f" {count:>4} {name}") + if unexercised: + log.write("") + log.write("[dim]not exercised:[/dim]") + for name in unexercised: + log.write(f" {name}") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + class ReproducerResultModal(tx.ModalScreen): + """Show the exported reproducer tarball path with a short instruction.""" + + BINDINGS = [tx.Binding("escape,q,enter", "dismiss", "close")] + + def __init__( + self, archive_path: pathlib.Path, error: str | None = None + ) -> None: + self._archive = archive_path + self._error = error + super().__init__() + + def compose(self) -> Any: + if self._error: + yield tx.Static(f"[red]Reproducer export failed:[/red] {self._error}") + else: + yield tx.Static("[bold green]Reproducer bundle written[/bold green]") + yield tx.Static(f"[cyan]{self._archive}[/cyan]") + yield tx.Static("") + yield tx.Static( + "Contains: README.md, test_report.json, fwlog.jsonl (time-filtered)," + ) + yield tx.Static( + "devices.json, env.json. Attach to an issue / paste the path in chat." + ) + yield tx.Static("") + yield tx.Static("[dim][esc] close[/dim]") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + # ---------------- App ---------------- + + class TestTuiApp(tx.App): + CSS = """ + Screen { layout: vertical; } + #header-bar { height: 2; padding: 0 1; background: $panel; } + #tier-table { height: auto; max-height: 11; } + #body { height: 1fr; } + #tree-pane { width: 50%; border-right: solid $primary-background; } + #right-pane { width: 50%; layout: vertical; } + #pytest-pane { height: 50%; border-bottom: solid $primary-background; } + #fwlog-header { height: 1; padding: 0 1; background: $panel; } + #fwlog-pane { height: 1fr; } + Tree { height: 100%; } + RichLog { height: 100%; } + #device-table { height: auto; max-height: 6; } + """ + + TITLE = "mcp-server test runner" + + BINDINGS = [ + tx.Binding("r", "rerun_focused", "re-run focused"), + tx.Binding("f", "filter_tree", "filter"), + tx.Binding("d", "failure_detail", "failure detail"), + tx.Binding("g", "open_html_report", "open report.html"), + tx.Binding("x", "export_reproducer", "export reproducer"), + tx.Binding("c", "coverage_panel", "coverage"), + tx.Binding("l", "cycle_fwlog_filter", "fw log filter"), + tx.Binding("q,ctrl+c", "quit_app", "quit"), + ] + + def __init__(self) -> None: + super().__init__() + self._state = State() + self._root = root + self._run_tests = run_tests + self._reportlog = reportlog + self._fwlog = fwlog + self._flashlog = flashlog + self._report_html = root / _REPORT_HTML_RELATIVE + self._tool_coverage = root / _TOOL_COVERAGE_RELATIVE + self._repro_dir = root / _REPRODUCERS_RELATIVE + self._seed = seed + self._run_number = run_number + self._pytest_args = pytest_args + self._start_time = time.monotonic() + self._proc: subprocess.Popen[str] | None = None + self._stop = threading.Event() + self._reportlog_worker: ReportlogWorker | None = None + self._stdout_worker: SubprocessReaderWorker | None = None + self._stderr_worker: SubprocessReaderWorker | None = None + self._device_worker: DevicePollerWorker | None = None + self._fwlog_worker: _fwlog_mod.FirmwareLogTailer | None = None + self._flashlog_worker: _flashlog_mod.FlashLogTailer | None = None + self._tree_filter: str = "" + self._sigint_count = 0 + # Firmware-log port filter: None = all, else exact port match. + self._fwlog_filter: str | None = None + # Ordered set of distinct ports we've seen firmware log lines + # from — the `l` key cycles through these. + self._fwlog_ports: list[str] = [] + # Cross-run history. + self._history_store = _history_mod.HistoryStore( + root / _HISTORY_RELATIVE, keep_last=40 + ) + self._history_cache = self._history_store.read_recent() + + # -------- composition / mount -------- + + def compose(self) -> Any: + yield tx.Static(self._header_text(), id="header-bar") + tier_table = tx.DataTable(id="tier-table", show_cursor=False) + yield tier_table + with tx.Horizontal(id="body"): + with tx.Vertical(id="tree-pane"): + yield tx.Tree("tests", id="test-tree") + with tx.Vertical(id="right-pane"): + with tx.Vertical(id="pytest-pane"): + yield tx.RichLog( + id="pytest-log", + highlight=False, + markup=False, + wrap=False, + max_lines=5000, + ) + yield tx.Static(self._fwlog_header_text(), id="fwlog-header") + with tx.Vertical(id="fwlog-pane"): + yield tx.RichLog( + id="fwlog-log", + highlight=False, + markup=False, + # `wrap=True` so long firmware log lines (some + # hit ~200 chars — full packet hex dumps plus + # source tags) don't get truncated at the + # right edge. The right pane is ~50% of the + # terminal so even a wide terminal has a + # ~90-char cap; plain truncation dropped the + # uptime counter or packet id off the end. + wrap=True, + max_lines=5000, + ) + yield tx.DataTable(id="device-table", show_cursor=False) + yield tx.Footer() + + def _fwlog_header_text(self) -> str: + filt = self._fwlog_filter or "(all ports)" + return f"firmware log filter: [b]{filt}[/b] [l] cycle" + + def on_mount(self) -> None: + # Tier-counters table. `add_column` (singular) lets us pick + # the key explicitly — `add_columns` (plural) in textual 8.x + # returns auto-generated keys that are tedious to track + # separately, and update_cell(column_key=

)` — captures `my_node_num`, `long_name`, `short_name`, `firmware_version`, `hw_model`, `region`, `num_nodes`, `primary_channel`. + - `mcp__meshtastic__list_nodes(port=

)` — count of peers, which ones have `publicKey` set, SNR/RSSI distribution. + - `mcp__meshtastic__get_config(section="lora", port=

)` — region, preset, channel_num, tx_power, hop_limit. + - Optionally, if the device seems unhappy (fails to connect, `num_nodes==1` when ≥2 are plugged in, missing firmware*version), open a short firmware log window: `mcp__meshtastic__serial_open(port=

, env=)`, wait 3s, `serial_read(session_id=, max_lines=100)`, `serial_close(session_id=)`. The env should be inferred from the VID map in `mcp-server/run-tests.sh` (nrf52 → rak4631, esp32s3 → heltec-v3) unless `MESHTASTIC_MCP_ENV*` is set. + +4. **Render per-device report** as: + + ```text + [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 + owner : Meshtastic 40eb / 40eb + region/band : US, channel 88, LONG_FAST + tx_power : 30 dBm, hop_limit=3 + peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) + primary ch : McpTest + firmware : no panics in last 3s; NodeInfoModule emitted 2 broadcasts + ``` + + Keep it scannable. If a field is missing or abnormal (no pubkey for a known peer, region=UNSET, num_nodes inconsistent with the hub), flag it inline with a short `⚠︎ `. + +5. **Cross-device correlation** (only when >1 device is inspected): + - Do both sides see each other in `nodesByNum`? If one does and the other doesn't, that's asymmetric NodeInfo — flag it. + - Do the LoRa configs match? (region, channel_num, modem_preset should all agree; mismatch = no mesh) + - Do the primary channel NAMES match? Mismatch = different PSK = no decode. + +6. **Suggest next actions only for specific, recognisable failure modes**: + - Stale PKI pubkey one-way → "run `/test tests/mesh/test_direct_with_ack.py` — the retry + nodeinfo-ping heals this in the test path." + - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." + - Device unreachable → point at touch_1200bps + the CP2102-wedged-driver note in run-tests.sh. + +## What NOT to do + +- No writes. No `set_config`, no `reboot`, no `factory_reset`. This is a read-only diagnostic skill — if the operator wants to change state, they'll ask explicitly. +- No `flash` / `erase_and_flash`. Those are separate escalations. +- No holding SerialInterface across tool calls — open, query, close; next device. The port lock is exclusive. diff --git a/.claude/commands/repro.md b/.claude/commands/repro.md new file mode 100644 index 000000000..52dcf222b --- /dev/null +++ b/.claude/commands/repro.md @@ -0,0 +1,65 @@ +--- +description: Re-run a specific test N times in isolation to triage flakes, diff firmware logs between passes and failures +argument-hint: [count=5] +--- + +# `/repro` — flakiness triage for one test + +Re-run a single pytest node ID N times in isolation, track pass rate, and surface what's _different_ in the firmware logs between the passing attempts and the failing ones. Turns "it's flaky, I guess" into "it fails when X, passes when Y." + +## What to do + +1. **Parse `$ARGUMENTS`**: first token is the pytest node id (e.g. `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[nrf52->esp32s3]`); second token is an integer count (default `5`, cap at `20`). If the first token doesn't look like a test path (no `::` and no `tests/` prefix), treat the whole `$ARGUMENTS` as a `-k` filter instead. + +2. **Sanity-check the hub first** (so we're not measuring "nothing plugged in" N times): call `mcp__meshtastic__list_devices`. If the test name contains `nrf52` or `esp32s3` and the matching VID isn't present, stop and report — re-running won't help. + +3. **Loop N times**. For each iteration: + + ```bash + ./mcp-server/run-tests.sh --tb=short -p no:cacheprovider + ``` + + Capture: exit code, duration, and (on failure) the `Meshtastic debug` firmware log section from `mcp-server/tests/report.html`. `-p no:cacheprovider` suppresses pytest's `.pytest_cache` writes so iterations don't influence each other. + +4. **Track a small structured tally**: + + ```text + attempt 1: PASS (42s) + attempt 2: FAIL (128s) ← firmware log 200-line tail captured + attempt 3: PASS (39s) + attempt 4: FAIL (121s) + attempt 5: PASS (41s) + -------------------------------------- + pass rate: 3/5 (60%) | mean duration: 74s + ``` + +5. **On mixed outcomes**: diff the firmware log tails between a representative passing attempt and a representative failing attempt. Focus on: + - Error-level lines only present in failures (`PKI_UNKNOWN_PUBKEY`, `Alloc an err=`, `Skip send`, `No suitable channel`) + - Timing around the assertion event — did a broadcast go out, was there an ACK, did NAK fire? + - Device state fields that changed (nodesByNum entries, region/preset, channel_num) + + Surface the top 3 differences as a "passes when / fails when" table. Don't dump full logs — pull specific lines with uptime timestamps. + +6. **Classify the flake** into one of: + - **LoRa airtime collision** → pass rate improves with fewer concurrent transmitters; propose a `time.sleep` gap or retry bump in the test body. + - **PKI key staleness** → fails on first attempt, passes after self-heal; existing retry loop in `test_direct_with_ack.py` handles this. + - **NodeInfo cooldown** → `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs `broadcast_nodeinfo_ping()` warmup. + - **Hardware-specific** (one direction fails, other passes; one device's firmware is older; driver wedged) → specific recovery pointer. + - **Genuinely unknown** → say so; don't invent a root cause. + +7. **Report back** with: + - Pass rate and mean duration. + - Classification + evidence (the specific log lines that support it). + - A suggested next step (re-run with specific args, open `/diagnose`, edit a specific test file, nothing). + +## Examples + +- `/repro tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[esp32s3->nrf52] 10` — runs 10 times, diffs firmware logs. +- `/repro broadcast_delivers` — no `::`, no `tests/`, so interpreted as `-k broadcast_delivers`; runs every matching test the default 5 times. +- `/repro tests/telemetry/test_device_telemetry_broadcast.py 3` — shorter run for a slow test. + +## Constraints + +- Don't exceed `count=20` per invocation — airtime and USB wear add up. If the user asks for 50, negotiate down. +- Don't rebuild firmware as part of triage; flakes that only reproduce under different firmware belong in a separate session. +- If the FIRST attempt fails AND the rest all pass, that's a classic "state leak from a prior test" → say so and suggest running with `--force-bake` or starting from a clean state rather than chasing the first failure. diff --git a/.claude/commands/test.md b/.claude/commands/test.md new file mode 100644 index 000000000..986ee1f31 --- /dev/null +++ b/.claude/commands/test.md @@ -0,0 +1,42 @@ +--- +description: Run the mcp-server test suite (auto-detects devices) and interpret the results +argument-hint: [pytest-args] +--- + +# `/test` — mcp-server test runner with interpretation + +Run `mcp-server/run-tests.sh` and make sense of the output so the operator doesn't have to. + +## What to do + +1. **Invoke the wrapper.** From the firmware repo root, run: + + ```bash + ./mcp-server/run-tests.sh $ARGUMENTS + ``` + + The wrapper auto-detects connected Meshtastic devices, maps each to its PlatformIO env, exports the required `MESHTASTIC_MCP_ENV_*` env vars, and invokes pytest. If the user passed no arguments, the wrapper supplies a sensible default set (`tests/ --html=tests/report.html --self-contained-html --junitxml=tests/junit.xml -v --tb=short`). A `--report-log=tests/reportlog.jsonl` arg is always appended (unless the operator passed their own). `--assume-baked` is deliberately NOT in the defaults — `test_00_bake.py` has its own skip-if-already-baked check and runs the ~8 s verification by default. Operators can opt into the fast path with `--assume-baked`, or force a reflash with `--force-bake`. + +2. **Read the pre-flight header.** First ~6 lines print the detected hub (role → port → env). If that line reads `detected hub : (none)`, the wrapper will narrow to `tests/unit` only — say so explicitly in your summary so the operator knows hardware tiers were skipped. + +3. **On pass**: one-line summary of the form `N passed, M skipped in `. Don't enumerate the 52 test names — the user can read those. Do mention if any test was SKIPPED for a NON-placeholder reason (e.g. "role not present on hub" is worth flagging). + +4. **On failure**: for every FAILED test, open `mcp-server/tests/report.html` and extract the `Meshtastic debug` section for that test. pytest-html embeds the firmware log stream + device state dump there; the 200-line firmware log tail is usually enough to explain the failure. Summarise: which test, one-line assertion message, the firmware log lines that matter (things like `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`). + +5. **Classify the failure** as one of: + - **Transient/flake**: LoRa collision, timing-sensitive assertion, first-attempt NAK + successful retry pattern. Propose `/repro ` to confirm. + - **Environmental**: device unreachable, port busy, CP2102 driver wedged. Suggest the specific recovery (replug USB, `touch_1200bps`, check `git status userPrefs.jsonc`). + - **Regression**: same assertion fails repeatedly, firmware log shows a new/unusual error. Surface the diff between expected and observed, identify the module likely responsible. + +6. **Never run destructive recovery automatically.** If a failure looks like it needs a reflash, factory*reset, or USB replug, \_describe what to do* — don't execute. The operator decides. + +## Arguments handling + +- No args → wrapper's defaults (full suite). +- `$ARGUMENTS` passed verbatim to the wrapper, which passes them to pytest. +- Common operator invocations: `/test tests/mesh`, `/test tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip`, `/test --force-bake`, `/test -k telemetry`. + +## Side-effects to mention in summary + +- The session fixture snapshots `userPrefs.jsonc` at session start and restores at teardown (plus on `atexit`). After a clean run, `git status userPrefs.jsonc` should be empty. If the wrapper's pre-flight printed a warning about a stale sidecar, call that out — means a prior session crashed. +- `mcp-server/tests/report.html` and `junit.xml` are regenerated on every run; the HTML is self-contained (shareable). diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 24e11bd4d..d12244229 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -429,6 +429,8 @@ Most workflows can be triggered manually via `workflow_dispatch` for testing. ## Testing +### Native unit tests (C++) + Unit tests in `test/` directory with 12 test suites: - `test_crypto/` - Cryptography @@ -446,6 +448,164 @@ Run with: `pio test -e native` Simulation testing: `bin/test-simulator.sh` +### Hardware-in-the-loop tests (`mcp-server/tests/`) + +Separate pytest suite that exercises real USB-connected Meshtastic devices. See the **MCP Server & Hardware Test Harness** section below for invocation, tier layout, and agent usage rules. + +## MCP Server & Hardware Test Harness + +The `mcp-server/` directory houses a firmware-aware [MCP](https://modelcontextprotocol.io/) server plus a pytest-based integration suite. AI agents that speak MCP get a well-defined tool surface for flashing, configuring, and inspecting physical Meshtastic devices — use it instead of hand-rolling `pio` or `meshtastic --port` calls where possible. `mcp-server/README.md` is the operator-facing setup doc; this section is the agent-facing usage contract. + +The repo registers the server via `.mcp.json` at the repo root — Claude Code picks it up automatically once `mcp-server/.venv/` is built (`cd mcp-server && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'`). + +### When to use which surface + +| Goal | Tool | +| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| Find a connected device | `mcp__meshtastic__list_devices` | +| Read a live node's config/state | `mcp__meshtastic__device_info`, `list_nodes`, `get_config` | +| Mutate a device (owner, region, channels, reboot) | `set_owner`, `set_config`, `set_channel_url`, `reboot`, `shutdown`, `factory_reset` — all require `confirm=True` | +| Flash firmware to a variant | `pio_flash` (any arch) or `erase_and_flash` (ESP32 factory install) | +| Stream serial logs while debugging | `serial_open` → `serial_read` loop → `serial_close` | +| Administer `userPrefs.jsonc` build-time constants | `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest` | +| Run the regression suite | `./mcp-server/run-tests.sh` (or `/test` slash command) | +| Diagnose a specific device | `/diagnose [role]` slash command (read-only) | +| Triage a flaky test | `/repro [count]` slash command | + +**One MCP call per port at a time.** `SerialInterface` holds an exclusive OS-level lock on the serial port for its lifetime. If a `serial_*` session is open on `/dev/cu.usbmodem101`, calling `device_info` on the same port will fail fast pointing at the active session. Sequence calls: open → read/mutate → close, then next device. Never parallelize tool calls on the same port. + +### MCP tool surface (~32 tools) + +Grouped by purpose. Full argument shapes in `mcp-server/README.md`; a few high-value signatures are called out here. + +- **Discovery & metadata**: `list_devices`, `list_boards`, `get_board` +- **Build & flash**: `build`, `clean`, `pio_flash`, `erase_and_flash` (ESP32 only), `update_flash` (ESP32 OTA), `touch_1200bps` +- **Serial sessions** (long-running, 10k-line ring buffer): `serial_open`, `serial_read`, `serial_list`, `serial_close` +- **Device reads**: `device_info`, `list_nodes` +- **Device writes** (all require `confirm=True`): `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `reboot`, `shutdown`, `factory_reset`, `set_debug_log_api` +- **userPrefs admin** (build-time constants, not runtime config): `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest`, `userprefs_testing_profile` +- **Vendor escape hatches**: `esptool_chip_info`, `esptool_erase_flash`, `esptool_raw`, `nrfutil_dfu`, `nrfutil_raw`, `picotool_info`, `picotool_load`, `picotool_raw` + +`confirm=True` is a tool-level gate on top of whatever permission prompt your MCP host shows. **Don't bypass it** by asking the host to auto-approve — it exists specifically because MCP hosts sometimes remember "always allow this tool" and that's dangerous for `factory_reset` and `erase_and_flash`. + +### Hardware test suite (`mcp-server/run-tests.sh`) + +The wrapper auto-detects connected devices (VID → role map: `0x239A` → `nrf52`, `0x303A`/`0x10C4` → `esp32s3`), maps each role to a PlatformIO env (`nrf52` → `rak4631`, `esp32s3` → `heltec-v3`, overridable via `MESHTASTIC_MCP_ENV_`), then invokes pytest. Zero pre-flight config needed from the operator. + +Suite tiers (collected + run in this order via `pytest_collection_modifyitems`): + +1. `tests/unit/` — pure Python (boards parse, pio wrapper, userPrefs parse, testing profile). No hardware. +2. `tests/test_00_bake.py` — flashes each detected device with current `userPrefs.jsonc` merged with the session's test profile. Has its own skip-if-already-baked check comparing region + primary channel to the session profile; skips cheaply on warm devices. +3. `tests/mesh/` — multi-device mesh: bidirectional send, broadcast delivery, direct-with-ACK, mesh formation within 60s. Parametrized `[nrf52->esp32s3]` and `[esp32s3->nrf52]`. +4. `tests/telemetry/` — `DEVICE_METRICS_APP` broadcast timing. +5. `tests/monitor/` — boot-log panic check. +6. `tests/fleet/` — PSK seed session isolation. +7. `tests/admin/` — channel URL roundtrip, owner persistence across reboot. +8. `tests/provisioning/` — region + modem + slot bake, admin key presence, `UNSET` region blocks TX, userPrefs survive factory reset. + +Invocation patterns: + +```bash +./mcp-server/run-tests.sh # full suite (auto-bake-if-needed) +./mcp-server/run-tests.sh --force-bake # reflash before testing +./mcp-server/run-tests.sh --assume-baked # skip bake (caller vouches for device state) +./mcp-server/run-tests.sh tests/mesh # one tier +./mcp-server/run-tests.sh tests/mesh/test_direct_with_ack.py # one file +./mcp-server/run-tests.sh -k telemetry # name filter +``` + +**No hardware detected?** The wrapper auto-narrows to `tests/unit/` only and prints `detected hub : (none)` in the pre-flight header. Agents interpreting the output should call this out explicitly — a 52-test green run without hardware is qualitatively different from a 12-unit-test green run. + +**Artifacts every run produces:** + +- `mcp-server/tests/report.html` — self-contained pytest-html. Each test gets a `Meshtastic debug` section with the tail of firmware log + device state dump. **Open this first** on failures; it's the canonical evidence source. +- `mcp-server/tests/junit.xml` — CI-parseable. +- `mcp-server/tests/reportlog.jsonl` — pytest-reportlog stream (`$report_type` keyed JSONL). Consumed by the live TUI. +- `mcp-server/tests/fwlog.jsonl` — firmware log mirror from the `meshtastic.log.line` pubsub topic. Populated by the `_firmware_log_stream` autouse session fixture. + +### Live TUI (`meshtastic-mcp-test-tui`) + +A Textual-based live view that wraps `run-tests.sh`. Tails reportlog for per-test state, streams firmware logs, polls device state at startup + post-run (gated out of the active run because `hub_devices` holds exclusive port locks). Key bindings: + +| Key | Action | +| --- | ------------------------------------------------------------------------------------------------------------ | +| `r` | re-run focused test (leaf → that node id; internal node → directory or `-k`) | +| `f` | filter tree by substring | +| `d` | failure detail modal (pulls `longrepr` + captured stdout from the reportlog) | +| `g` | export reproducer bundle (tar.gz with README, test_report.json, time-filtered fwlog, devices.json, env.json) | +| `l` | toggle firmware log pane | +| `x` | tool coverage modal | +| `c` | cross-run history sparkline | +| `q` | quit (SIGINT → SIGTERM → SIGKILL escalation, 5-s windows each) | + +Launch: + +```bash +cd mcp-server +.venv/bin/meshtastic-mcp-test-tui # full suite +.venv/bin/meshtastic-mcp-test-tui tests/mesh # args pass through to pytest +``` + +The plain CLI stays primary; the TUI is for operators who want a live dashboard. Both consume the same `run-tests.sh`. + +### Slash commands (Claude Code + Copilot) + +Three AI-assisted workflows wrap the test harness. Claude Code operators get `/test`, `/diagnose`, `/repro`; Copilot operators get `/mcp-test`, `/mcp-diagnose`, `/mcp-repro`. Bodies: + +- `.claude/commands/{test,diagnose,repro}.md` +- `.github/prompts/mcp-{test,diagnose,repro}.prompt.md` + +`.claude/commands/README.md` is the index. + +House rules for agents running these prompts: + +- **Interpret failures, don't just echo them.** Pull firmware log tails from `report.html` and classify each failure as transient / environmental / regression. Use the exact format in `.claude/commands/test.md`. +- **No destructive writes without operator approval.** Any skill that could reflash, factory-reset, or reboot a device must describe the action and stop. The operator authorizes. +- **Sequential MCP calls per port.** See above. +- **"Unknown" is a valid classification.** If evidence doesn't support a root cause, say so and list what would disambiguate. Do not invent. + +### Key fixtures (test authors + agents debugging) + +`mcp-server/tests/conftest.py` provides: + +- **`_session_userprefs`** (autouse session) — snapshots `userPrefs.jsonc` at session start, merges the session test profile via `userprefs.merge_active(test_profile)`, restores at teardown. Four layers of safety: pytest teardown + `atexit` + sidecar file (`userPrefs.jsonc.mcp-session-bak`) + startup self-heal in `run-tests.sh`. **Do not edit `userPrefs.jsonc` from inside a test.** +- **`_firmware_log_stream`** (autouse session) — subscribes to `meshtastic.log.line` pubsub on every connected `SerialInterface` and mirrors lines to `tests/fwlog.jsonl`. Drives the TUI firmware-log pane. +- **`_debug_log_buffer`** (autouse per-test) — captures last 200 firmware log lines + device state for attachment to the pytest-html `Meshtastic debug` section on failure. +- **`hub_devices`** (session) — `dict[role, SerialInterface]` with session-long exclusive port locks. Reason the TUI's device poller is gated to startup + post-run only. +- **`baked_mesh`** — parametrized mesh-pair fixture; depends on `test_00_bake`. `pytest_generate_tests` in `conftest.py` auto-generates `[nrf52->esp32s3]` and `[esp32s3->nrf52]` variants. +- **`test_profile`** — session-scoped dict: region, primary channel, admin key, PSK seed. Derived from `MESHTASTIC_MCP_SEED` (defaults to `mcp--`). + +### Firmware integration points tied to the test harness + +Two firmware changes exist specifically so the test harness works reliably. **Keep these in mind when touching related code.** + +- **`src/mesh/StreamAPI.cpp` + `StreamAPI.h`** — `emitLogRecord` uses a dedicated `fromRadioScratchLog` + `txBufLog` pair and a `concurrency::Lock streamLock`. Before this fix, `debug_log_api_enabled=true` would tear `FromRadio` protobufs on the serial transport because `emitTxBuffer` and `emitLogRecord` shared a single scratch buffer. The conftest enables the log stream session-wide; without this fix the device would corrupt its own FromRadio replies mid-session. +- **`src/mesh/PhoneAPI.cpp`** — `ToRadio` `Heartbeat(nonce=1)` triggers `nodeInfoModule->sendOurNodeInfo(NODENUM_BROADCAST, true, 0, true)` for serial clients, mirroring the pre-existing behavior for TCP/UDP clients in `PacketAPI.cpp`. The mesh tests rely on this to force a NodeInfo broadcast right after connect so the peer discovers them before the test's first assertion. + +If you're modifying `StreamAPI`, `PhoneAPI`, `NodeInfoModule`, or `userPrefs` flow, run `./mcp-server/run-tests.sh` at minimum before asking for review. + +### Recovery playbooks + +| Symptom | First check | Fix | +| ---------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `userPrefs.jsonc` dirty after test run | `git status --porcelain userPrefs.jsonc` | If non-empty, re-run `./mcp-server/run-tests.sh` once — the pre-flight self-heal restores from sidecar. If still dirty, `git checkout userPrefs.jsonc`. | +| Port busy / wedged CP2102 on macOS | `lsof /dev/cu.usbserial-0001` | Kill the holder. USB replug if the kernel still reports busy. Often a stale `pio device monitor` or zombie `meshtastic_mcp` process. | +| nRF52 appears unresponsive | `list_devices` shows VID `0x239A` but `device_info` times out | `touch_1200bps(port=...)` drops it into the DFU bootloader → `pio_flash` re-installs. | +| Multiple MCP server processes | `ps aux \| grep meshtastic_mcp` shows >1 | Kill all but the one your MCP host spawned. Zombies hold ports and break tests. | +| Mesh formation fails, one side sees peer but other doesn't | `/diagnose` (or `list_nodes` on both sides) | Asymmetric NodeInfo. `test_direct_with_ack` has a heal path; `/repro` it a few times. If persistent, both devices' clocks may be out of sync with their NodeInfo cooldown. | +| "role not present on hub" in skip reasons | `list_devices` | Expected if a device is unplugged. Reconnect before re-running the tier. | +| Tests fail only on first attempt then pass on rerun | — | State leak from a prior session. Run with `--force-bake` to reset to a known state. | + +### Never do these without asking + +- `factory_reset` — wipes node identity; regenerates PKI keypair. Mesh peers will reject old DMs until re-exchange. Legitimate only when the operator explicitly wants it. +- `erase_and_flash` — full chip erase; destroys all on-device state. +- `esptool_erase_flash` / `esptool_raw` write/erase — bypasses pio's safety chain. +- `set_config` on `lora.region` — changes regulatory domain; requires physical-location context the operator has and the agent doesn't. +- `reboot` / `shutdown` mid-test — breaks fixture invariants. +- `push -f`, `rebase -i`, `reset --hard`, or any history-rewriting git operation. +- Clicking computer-use tools on web links in Mail/Messages/PDFs — open URLs via the claude-in-chrome MCP so the extension's link-safety checks apply. + ## Resources - [Documentation](https://meshtastic.org/docs/) diff --git a/.github/prompts/mcp-diagnose.prompt.md b/.github/prompts/mcp-diagnose.prompt.md new file mode 100644 index 000000000..c86826030 --- /dev/null +++ b/.github/prompts/mcp-diagnose.prompt.md @@ -0,0 +1,57 @@ +--- +mode: agent +description: Device health report via the meshtastic MCP tools (Copilot equivalent of the Claude Code /diagnose slash command) +--- + +# `/mcp-diagnose` — device health report + +Equivalent of `.claude/commands/diagnose.md`. Use when the operator asks to "check the devices", "what's the mesh looking like", "is nrf52 alive", etc. + +This prompt assumes the meshtastic MCP server is registered with your VS Code Copilot agent. If it isn't, fall back to running `./mcp-server/run-tests.sh tests/unit` plus a short `device_info` script via the terminal. + +## What to do + +1. **Enumerate hardware** via the `list_devices` MCP tool (with `include_unknown=True`). For each entry where `likely_meshtastic=True`, capture `port`, `vid`, `pid`, `description`. + +2. **Apply the operator's filter** (if any): + - No filter → every likely-meshtastic device. + - `nrf52` → `vid == 0x239a` + - `esp32s3` → `vid == 0x303a` or `vid == 0x10c4` + - A `/dev/cu.*` path → only that port. + - Anything else → substring match on port. + +3. **For each selected device, in sequence (don't parallelize — SerialInterface holds an exclusive port lock):** + - `device_info(port=

)` → `my_node_num`, `long_name`, `short_name`, `firmware_version`, `hw_model`, `region`, `num_nodes`, `primary_channel` + - `list_nodes(port=

)` → peer count, which peers have `publicKey`, SNR/RSSI distribution + - `get_config(section="lora", port=

)` → region, preset, channel_num, tx_power, hop_limit + - If anything looks off (can't connect, `num_nodes` wrong, missing `firmware_version`), open a short firmware-log window: `serial_open(port=

, env=)`, wait 3 seconds, `serial_read(session_id, max_lines=100)`, `serial_close(session_id)`. Infer env from VID (0x239a → `rak4631`, 0x303a/0x10c4 → `heltec-v3`) unless an `MESHTASTIC_MCP_ENV_` env var overrides it. + +4. **Render per-device report** as a compact block: + + ```text + [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 + owner : Meshtastic 40eb / 40eb + region/band : US, channel 88, LONG_FAST + tx_power : 30 dBm, hop_limit=3 + peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) + primary ch : McpTest + firmware : no panics in last 3s + ``` + + Flag abnormalities inline with `⚠︎ ` — missing pubkey on a known peer, region UNSET, mismatched channel name, etc. + +5. **Cross-device correlation** (when >1 device selected): + - Do both see each other in `nodesByNum`? + - Do `region`, `channel_num`, `modem_preset` match across devices? + - Do the primary channel names match? (Different name → different PSK → no decode.) + +6. **Suggest next steps only for recognizable failure modes**, never speculatively: + - Stale PKI one-way → "`/mcp-test tests/mesh/test_direct_with_ack.py` — the test's retry+nodeinfo-ping heals this." + - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." + - Device unreachable → refer operator to the touch_1200bps + CP2102-wedged-driver notes in `run-tests.sh`. + +## Hard constraints + +- **Read-only.** No `set_config`, no `reboot`, no `factory_reset`, no `flash`. If the operator wants mutation, they'll escalate explicitly. +- **Open/query/close per device.** Never hold multiple SerialInterfaces to the same port. The port lock is exclusive. +- **Don't infer env beyond the VID map** — if the operator has an unusual board, ask them which env to use rather than guessing. diff --git a/.github/prompts/mcp-repro.prompt.md b/.github/prompts/mcp-repro.prompt.md new file mode 100644 index 000000000..be2963c33 --- /dev/null +++ b/.github/prompts/mcp-repro.prompt.md @@ -0,0 +1,67 @@ +--- +mode: agent +description: Re-run a specific test N times to triage flakes; diff firmware logs between passes and failures (Copilot equivalent of the Claude Code /repro slash command) +--- + +# `/mcp-repro` — flakiness triage for one test + +Equivalent of `.claude/commands/repro.md`. Use when the operator says "that one test is flaky — dig in", "repro the direct_with_ack failure", "why does X sometimes fail?". + +## What to do + +1. **Parse the operator's input** into two pieces: + - **Test identifier** — either a pytest node id (has `::` or starts with `tests/`) or a `-k`-style filter (plain substring like `direct_with_ack`). + - **Count** — integer, default `5`, cap at `20`. If the operator asks for 50, negotiate down and explain (airtime + USB wear). + +2. **Sanity-check the hub** via the `list_devices` MCP tool. If the test name references `nrf52` or `esp32s3` and the matching VID isn't present, stop and report — re-running won't help. + +3. **Loop** N times. Each iteration: + + ```bash + ./mcp-server/run-tests.sh --tb=short -p no:cacheprovider + ``` + + `-p no:cacheprovider` keeps pytest from caching anything between iterations. Capture: exit code, duration, and (on failure) the `Meshtastic debug` firmware-log section from `mcp-server/tests/report.html`. + +4. **Tally** results as you go: + + ```text + attempt 1: PASS (42s) + attempt 2: FAIL (128s) ← fw log captured + attempt 3: PASS (39s) + attempt 4: FAIL (121s) + attempt 5: PASS (41s) + -------------------------------------------------- + pass rate: 3/5 (60%) | mean duration: 74s + ``` + +5. **On mixed outcomes, diff the firmware logs** between one representative pass and one representative fail. Focus on: + - Error-level lines present only in failures (`PKI_UNKNOWN_PUBKEY`, `Alloc an err=`, `Skip send`, `No suitable channel`, `NAK`) + - Timing around the assertion point (broadcast sent? ACK received? retry fired?) + - Device-state fields that changed between attempts + + Surface the top 3 differences as a compact "passes when / fails when" table with uptime timestamps. Don't dump full logs. + +6. **Classify** the flake into one of: + - **LoRa airtime collision** — pass rate improves with fewer concurrent transmitters. Suggest a `time.sleep` gap or retry bump in the test body. + - **PKI key staleness** — first attempt fails, subsequent ones pass; existing retry-loop pattern in `test_direct_with_ack.py` is the fix. + - **NodeInfo cooldown** — `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs a `broadcast_nodeinfo_ping()` warmup. + - **Hardware-specific** — one direction consistently fails, firmware versions differ, CP2102 driver wedged, etc. + - **Unknown** — say so. Don't invent a root cause. + +7. **Report back** with: + - Pass rate + mean duration. + - Classification + the specific log evidence for it. + - A concrete next step (tighter assertion, more retries, open `/mcp-diagnose`, file a bug, nothing). + +## Examples + +- `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip[esp32s3->nrf52] 10` — 10 runs of that parametrized case. +- `broadcast_delivers` — no `::`, no `tests/`; treat as `-k broadcast_delivers`; runs every match 5 times. +- `tests/telemetry/test_device_telemetry_broadcast.py 3` — shorter count for a slow test. + +## Notes + +- If the FIRST attempt fails and the rest pass, that's a state-leak signature — suggest starting from `--force-bake` or a clean device state rather than chasing the first-failure firmware logs. +- If ALL N fail, this isn't a flake — it's a regression. Say so, stop iterating, escalate to `/mcp-test` for full-suite context. +- Don't rebuild firmware during triage. Flakes that only reproduce under different firmware belong in a separate session with a plan. diff --git a/.github/prompts/mcp-test.prompt.md b/.github/prompts/mcp-test.prompt.md new file mode 100644 index 000000000..092ad3d85 --- /dev/null +++ b/.github/prompts/mcp-test.prompt.md @@ -0,0 +1,51 @@ +--- +mode: agent +description: Run the mcp-server test suite and interpret results (Copilot equivalent of the Claude Code /test slash command) +--- + +# `/mcp-test` — mcp-server test runner with interpretation + +Equivalent of the Claude Code `/test` slash command in `.claude/commands/test.md`. Use this when the operator asks you to "run the tests", "check the mcp test suite", "run the mesh tests", etc. + +## What to do + +1. **Invoke the wrapper** from the firmware repo root: + + ```bash + ./mcp-server/run-tests.sh [pytest-args] + ``` + + If the operator specified a subset (e.g. "just the mesh tests"), pass it through as `tests/mesh` or a pytest `-k filter`. If they said nothing, use the wrapper's defaults (full suite with pytest-html report). + + The wrapper auto-detects connected Meshtastic devices, maps each to its PlatformIO env, exports the required env vars, and invokes pytest. Zero pre-flight config needed from the operator. + +2. **Read the pre-flight header** (first few lines of wrapper output). The `detected hub :` line lists role → port → env mappings. If it reads `(none)`, the wrapper narrowed to `tests/unit` only — call that out explicitly so the operator knows hardware tiers were skipped. + +3. **On pass**: one-line summary like `N passed, M skipped in `. Don't enumerate test names. DO mention any non-placeholder SKIPs (things like "role not present on hub") because they indicate missing hardware or setup issues. + +4. **On failure**: open `mcp-server/tests/report.html` (pytest-html output, self-contained) and extract the `Meshtastic debug` section for each failed test. That section includes a firmware log stream (last 200 lines) and device state dump. For each failure, summarise: + - test name + - one-line assertion message + - the specific firmware log lines that explain why (look for `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`, `No suitable channel`) + +5. **Classify each failure** as one of: + - **Transient flake** — LoRa collision, first-attempt NAK with self-heal pattern, timing-sensitive assertion. Suggest `/mcp-repro ` to confirm. + - **Environmental** — device unreachable, port busy, CP2102 driver wedged on macOS. Suggest specific recovery (USB replug, `touch_1200bps`, `git status userPrefs.jsonc`). + - **Regression** — same assertion fails repeatedly on re-runs, firmware log shows novel errors. Identify the firmware module likely responsible. + +6. **Do NOT run destructive recovery automatically**. If a failure looks like it needs a reflash, factory*reset, or replug — \_describe the steps* and let the operator decide. Never burn airtime or flash cycles without approval. + +## Arguments convention + +Operators generally invoke this prompt either with no arguments (full suite) or with a specific subset. Examples: + +- `tests/mesh` — one tier +- `tests/mesh/test_direct_with_ack.py::test_direct_with_ack_roundtrip` — one test +- `--force-bake` — reflash devices first +- `-k telemetry` — name-filter + +## Side-effects to confirm in your summary + +- `userPrefs.jsonc` should be clean after a successful run. The session fixture in `mcp-server/tests/conftest.py` (`_session_userprefs`) snapshots and restores. Check `git status --porcelain userPrefs.jsonc` and report if it's non-empty. +- `mcp-server/tests/report.html` and `junit.xml` regenerate on every run. +- The wrapper prints a warning if a `.mcp-session-bak` sidecar was left over from a crashed prior session and auto-restores from it — mention that if it happened. diff --git a/.gitignore b/.gitignore index 43cee78db..f1eb9d852 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ CMakeLists.txt # PYTHONPATH used by the Nix shell .python3 +.claude/scheduled_tasks.lock +userPrefs.jsonc.mcp-session-bak diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 000000000..c5cf2e55e --- /dev/null +++ b/.mcp.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "meshtastic": { + "command": "./mcp-server/.venv/bin/python", + "args": ["-m", "meshtastic_mcp"], + "env": { + "MESHTASTIC_FIRMWARE_ROOT": "." + } + } + } +} diff --git a/.trunk/configs/.bandit b/.trunk/configs/.bandit index d286ded89..c70e7743b 100644 --- a/.trunk/configs/.bandit +++ b/.trunk/configs/.bandit @@ -1,2 +1,28 @@ [bandit] -skips = B101 \ No newline at end of file +# Rule IDs: https://bandit.readthedocs.io/en/latest/plugins/index.html +# +# B101 assert_used +# pytest assertions + internal invariants; required for pytest. +# B110 try_except_pass +# best-effort cleanup paths (atexit handlers, pubsub unsubscribe, +# session-end file close, socket shutdown). Logging inside the +# except block would be worse than the silent pass — teardown is +# already at end-of-session and the surrounding caller has context. +# B112 try_except_continue +# defensive loops over flaky sources (pubsub handlers, device +# re-enumeration polls). One failed iteration shouldn't abort the loop. +# B404 import_subprocess +# mcp-server wraps PlatformIO, esptool, nrfutil, picotool, and the +# pytest test-runner — subprocess is a load-bearing import here, not +# a smell. The "consider possible security implications" advisory is +# redundant given the file-level review already applied. +# B603 subprocess_without_shell_equals_true +# all subprocess calls use a static argv list; `shell=False` is the +# default and we never string-interpolate user input into the command. +# B606 start_process_with_no_shell +# same invariant as B603 — running a binary via argv list (not +# `shell=True`) is the safe pattern bandit is asking for. +# +# Higher-severity checks (B102 exec_used, B301 pickle, B307 eval, +# B602 shell=True, etc.) remain enabled. +skips = B101,B110,B112,B404,B603,B606 \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..cd043c087 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,113 @@ +# Agent instructions + +This repository is the [Meshtastic](https://meshtastic.org) firmware — a C++17 embedded codebase targeting ESP32 / nRF52 / RP2040 / STM32WL / Linux-Portduino LoRa mesh radios — plus a Python MCP server in `mcp-server/` that AI agents use to flash, configure, and test connected devices. + +## Primary instruction file + +**Read `.github/copilot-instructions.md` first.** That file is the canonical agent-facing document for this repo. It covers project layout, coding conventions (naming, module framework, Observer pattern, thread safety), the build system, CI/CD, the native C++ test suite, and — most importantly for automation work — the **MCP Server & Hardware Test Harness** section. Read it top-to-bottom before starting any non-trivial change. + +This file (`AGENTS.md`) is a short pointer + quick reference for agents that don't read `.github/copilot-instructions.md` by default. + +## Quick command reference + +| Action | Command | +| -------------------------------- | ----------------------------------------------------------------------------------- | +| Build a firmware variant | `pio run -e ` (e.g. `pio run -e rak4631`, `pio run -e heltec-v3`) | +| Clean + rebuild | `pio run -e -t clean && pio run -e ` | +| Flash a device | `pio run -e -t upload --upload-port ` (or use the `pio_flash` MCP tool) | +| Run firmware unit tests (native) | `pio test -e native` | +| Run MCP hardware tests | `./mcp-server/run-tests.sh` | +| Live TUI test runner | `mcp-server/.venv/bin/meshtastic-mcp-test-tui` | +| Format before commit | `trunk fmt` | +| Regenerate protobuf bindings | `bin/regen-protos.sh` | +| Generate CI matrix | `./bin/generate_ci_matrix.py all [--level pr]` | + +## MCP server (device + test automation) + +The `mcp-server/` package exposes ~32 MCP tools for device discovery, building, flashing, serial monitoring, and live-node administration. Tools are grouped as: + +- **Discovery**: `list_devices`, `list_boards`, `get_board` +- **Build & flash**: `build`, `clean`, `pio_flash`, `erase_and_flash` (ESP32 factory), `update_flash` (ESP32 OTA), `touch_1200bps` +- **Serial sessions**: `serial_open`, `serial_read`, `serial_list`, `serial_close` +- **Device reads**: `device_info`, `list_nodes` +- **Device writes** (require `confirm=True`): `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `reboot`, `shutdown`, `factory_reset`, `set_debug_log_api` +- **userPrefs admin**: `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest`, `userprefs_testing_profile` +- **Vendor escape hatches**: `esptool_*`, `nrfutil_*`, `picotool_*` + +Setup: `cd mcp-server && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'`. The repo registers the server via `.mcp.json` — Claude Code picks it up automatically. + +See `mcp-server/README.md` for argument shapes and the **MCP Server & Hardware Test Harness** section of `.github/copilot-instructions.md` for agent usage rules (tool surface, fixture contract, firmware integration points, recovery playbooks). + +## Slash commands (AI-assisted workflows) + +Three test-and-diagnose workflows exist as slash commands: + +- **`/test` (Claude Code) / `/mcp-test` (Copilot)** — run the hardware test suite and interpret failures +- **`/diagnose` / `/mcp-diagnose`** — read-only device health report +- **`/repro` / `/mcp-repro`** — flakiness triage: re-run one test N times, diff firmware logs between passes and failures + +Bodies live in `.claude/commands/` and `.github/prompts/` respectively. `.claude/commands/README.md` is the index. + +## House rules + +- **No destructive device operations without operator approval.** `factory_reset`, `erase_and_flash`, `reboot`, `shutdown`, history-rewriting git ops — describe the action and stop. Operator authorizes. +- **One MCP call per serial port at a time.** The port lock is exclusive; concurrent calls deadlock. Sequence: open → read/mutate → close, then next device. +- **`userPrefs.jsonc` is session state during tests.** The `_session_userprefs` fixture snapshots + restores it; never edit it from inside a test. +- **Don't speculate about firmware root causes.** When evidence doesn't support a classification, say "unknown" and list what would disambiguate. +- **Run `trunk fmt` before proposing a commit.** The `trunk_check` CI gate will reject unformatted code. +- **`confirm=True` on destructive MCP tools is a real gate, not a formality.** Don't bypass it via auto-approve settings. + +## Typical agent workflows + +### Flashing a device + +1. `list_devices` → find the port + likely VID +2. `list_boards` → confirm the env, or use the known default for the hardware +3. `pio_flash(env=..., port=..., confirm=True)` for any arch, or `erase_and_flash(env=..., port=..., confirm=True)` for an ESP32 factory install + +### Inspecting live node state + +1. `device_info(port=...)` — short summary (node num, firmware version, region, peer count) +2. `list_nodes(port=...)` — full peer table (SNR, RSSI, pubkey presence, last_heard) +3. `get_config(section="lora", port=...)` — LoRa settings for cross-device comparison + +Sequence these; don't parallelize on the same port. + +### Testing a firmware change + +1. Build locally: `pio run -e ` +2. Flash the test device: `pio_flash(env=..., port=..., confirm=True)` +3. Run the suite: `./mcp-server/run-tests.sh tests/` or `/test tests/` +4. On failure, open `mcp-server/tests/report.html` → `Meshtastic debug` section for the firmware log tail + device state dump +5. Iterate + +### Debugging a flaky test + +1. `/repro [count]` — re-runs the test N times, diffs firmware logs between passes and failures +2. If the first attempt always fails and the rest pass, that's a state-leak pattern → suggest `--force-bake` or a clean device state, don't chase the first failure +3. If all N fail, this isn't a flake — it's a regression. Stop iterating and escalate to `/test` for full-suite context. + +## Where to look + +| Path | What's there | +| --------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `src/` | Firmware C++ source (`mesh/`, `modules/`, `platform/`, `graphics/`, `gps/`, `motion/`, `mqtt/`, …) | +| `src/mesh/` | Core: NodeDB, Router, Channels, CryptoEngine, radio interfaces, StreamAPI, PhoneAPI | +| `src/modules/` | Feature modules; `Telemetry/Sensor/` has 50+ I2C sensor drivers | +| `variants/` | 200+ hardware variant definitions (`variant.h` + `platformio.ini` per board) | +| `protobufs/` | `.proto` definitions; regenerate with `bin/regen-protos.sh` | +| `test/` | Firmware unit tests (12 suites; `pio test -e native`) | +| `mcp-server/` | Python MCP server + pytest hardware integration tests | +| `mcp-server/tests/` | Tiered pytest suite: `unit/`, `mesh/`, `telemetry/`, `monitor/`, `fleet/`, `admin/`, `provisioning/` | +| `.claude/commands/` | Claude Code slash command bodies | +| `.github/prompts/` | Copilot prompt bodies (mirrors of the Claude Code ones) | +| `.github/copilot-instructions.md` | **Primary agent instructions — read this** | +| `.github/workflows/` | CI pipelines | +| `.mcp.json` | MCP server registration for Claude Code | + +## Recovery one-liners + +- **`userPrefs.jsonc` dirty after a test run?** Re-run `./mcp-server/run-tests.sh` once (pre-flight self-heals from the sidecar). If still dirty: `git checkout userPrefs.jsonc`. +- **nRF52 not responding?** `mcp__meshtastic__touch_1200bps(port=...)` drops it into the DFU bootloader, then `pio_flash` re-installs. +- **Port busy?** `lsof ` to find the holder. Usually a stale `pio device monitor` or zombie `meshtastic_mcp` process. Kill it. +- **Multiple MCP servers running?** `ps aux | grep meshtastic_mcp` — zombies hold ports. Kill all but the one your host spawned. diff --git a/mcp-server/.gitignore b/mcp-server/.gitignore new file mode 100644 index 000000000..f5180bc71 --- /dev/null +++ b/mcp-server/.gitignore @@ -0,0 +1,26 @@ +.venv/ +__pycache__/ +*.py[cod] +*.egg-info/ +.pytest_cache/ +.mypy_cache/ +dist/ +build/ + +# Test harness artifacts +tests/report.html +tests/junit.xml +tests/reportlog.jsonl +tests/fwlog.jsonl +# Subprocess-output tee from pio/esptool/nrfutil/picotool (live flash +# progress for the TUI; also a post-run diagnostic for plain CLI runs). +tests/flash.log +tests/tool_coverage.json +tests/.coverage +htmlcov/ +# Persistent run counter for meshtastic-mcp-test-tui header. +tests/.tui-runs +# Cross-run history (TUI duration sparkline). +tests/.history/ +# Reproducer bundles (TUI `x` export on failed tests). +tests/reproducers/ diff --git a/mcp-server/README.md b/mcp-server/README.md new file mode 100644 index 000000000..7d5fc551a --- /dev/null +++ b/mcp-server/README.md @@ -0,0 +1,270 @@ +# Meshtastic MCP Server + +An [MCP](https://modelcontextprotocol.io) server for working with the Meshtastic firmware repo and connected devices. Lets Claude Code / Claude Desktop: + +- Discover USB-connected Meshtastic devices +- Enumerate PlatformIO board variants (166+) with Meshtastic metadata +- Build, clean, flash, erase-and-flash (factory), and OTA-update firmware +- Read serial logs via `pio device monitor` (with board-specific exception decoders) +- Trigger 1200bps touch-reset for bootloader entry (nRF52, ESP32-S3, RP2040) +- Query and administer a running node via the [`meshtastic` Python API](https://github.com/meshtastic/python): owner name, config (LocalConfig + ModuleConfig), channels, messaging, reboot/shutdown/factory-reset +- Call `esptool`, `nrfutil`, `picotool` directly when PlatformIO doesn't cover the operation + +## Design principle + +**PlatformIO first.** Its `pio run -t upload` knows the correct protocol, offsets, and post-build chain for every variant in `variants/`. Direct vendor-tool wrappers (`esptool_*`, `nrfutil_*`, `picotool_*`) exist as escape hatches for operations pio doesn't cover (blank-chip erase, DFU `.zip` packages, BOOTSEL-mode inspection). + +## Prerequisites + +- Python ≥ 3.11 +- [PlatformIO Core](https://platformio.org/install/cli) — `pio` on `$PATH` or at `~/.platformio/penv/bin/pio` +- The Meshtastic firmware repo checked out somewhere (set via `MESHTASTIC_FIRMWARE_ROOT`) +- Optional: `esptool`, `nrfutil`, `picotool` on `$PATH` (or under the firmware venv at `.venv/bin/`) if you want to use the direct-tool wrappers + +## Install + +```bash +cd /mcp-server +python3 -m venv .venv +.venv/bin/pip install -e . +``` + +Verify: + +```bash +MESHTASTIC_FIRMWARE_ROOT= .venv/bin/python -m meshtastic_mcp +``` + +The server blocks on stdin (that's correct — it speaks MCP over stdio). Ctrl-C to exit. + +## Register with Claude Code + +Edit `~/.claude/settings.json` (global) or `/.claude/settings.local.json` (project-only): + +```json +{ + "mcpServers": { + "meshtastic": { + "command": "/mcp-server/.venv/bin/python", + "args": ["-m", "meshtastic_mcp"], + "env": { + "MESHTASTIC_FIRMWARE_ROOT": "" + } + } + } +} +``` + +Replace `` with the absolute path, e.g. `/Users/you/GitHub/firmware`. Restart Claude Code after editing. + +## Register with Claude Desktop + +Same `mcpServers` block, but in `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). + +## Tools (38) + +### Discovery & metadata + +| Tool | What it does | +| -------------- | ------------------------------------------------------------------------------------------ | +| `list_devices` | USB/serial port listing, flags likely-Meshtastic candidates | +| `list_boards` | PlatformIO envs with `custom_meshtastic_*` metadata; filters by arch/supported/query/level | +| `get_board` | Full env dict incl. raw pio config | + +### Build & flash + +| Tool | What it does | +| ----------------- | -------------------------------------------------------------------- | +| `build` | `pio run -e ` (+ mtjson target) | +| `clean` | `pio run -e -t clean` | +| `pio_flash` | `pio run -e -t upload --upload-port ` — any architecture | +| `erase_and_flash` | ESP32 full factory flash via `bin/device-install.sh` | +| `update_flash` | ESP32 OTA app-partition update via `bin/device-update.sh` | +| `touch_1200bps` | 1200-baud open/close to trigger USB CDC bootloader entry | + +### Serial log sessions + +Backed by long-running `pio device monitor` subprocesses with a 10k-line ring buffer per session and board-specific filters (`esp32_exception_decoder` auto-selected when you pass `env=`). + +| Tool | What it does | +| -------------- | ------------------------------------------------------------------ | +| `serial_open` | Start a monitor session; returns `session_id` | +| `serial_read` | Cursor-based pull; reports `dropped` if lines aged out of the ring | +| `serial_list` | All active sessions | +| `serial_close` | Terminate a session | + +### Device reads + +| Tool | What it does | +| ------------- | --------------------------------------------------------------------------- | +| `device_info` | my_node_num, long/short name, firmware version, region, channel, node count | +| `list_nodes` | Full node database with position, SNR, RSSI, last_heard, battery | + +_The tool tables below document 38 currently registered MCP server tools._ + +### Device writes + +| Tool | What it does | +| ------------------- | -------------------------------------------------------------------------- | +| `set_owner` | Long name + optional short name (≤4 chars) | +| `get_config` | One section or all (LocalConfig + ModuleConfig) | +| `set_config` | Dot-path field write: `lora.region`=`"US"`, `device.role`=`"ROUTER"`, etc. | +| `get_channel_url` | Primary-only or include_all=admin URL | +| `set_channel_url` | Import channels from a Meshtastic URL | +| `set_debug_log_api` | Enable or disable debug logging for the Meshtastic Python API client | +| `send_text` | Broadcast or direct text message | +| `reboot` | `localNode.reboot(secs)` — requires `confirm=True` | +| `shutdown` | `localNode.shutdown(secs)` — requires `confirm=True` | +| `factory_reset` | `localNode.factoryReset(full?)` — requires `confirm=True` | + +### Direct hardware tools (escape hatches) + +| Tool | What it does | +| --------------------- | --------------------------------------------------------- | +| `esptool_chip_info` | Read chip, MAC, crystal, flash size | +| `esptool_erase_flash` | Full-chip erase (destructive) | +| `esptool_raw` | Pass-through; confirm=True required for write/erase/merge | +| `nrfutil_dfu` | DFU-flash a `.zip` package | +| `nrfutil_raw` | Pass-through | +| `picotool_info` | Read Pico BOOTSEL-mode info | +| `picotool_load` | Load a UF2 | +| `picotool_raw` | Pass-through | + +## Safety + +- **All destructive flash/admin tools require `confirm=True`** as a tool-level gate, on top of any permission prompt from Claude. +- **Serial port is exclusive.** If a `serial_*` session is active on a port, `device_info`/admin tools on the same port will fail fast with a pointer at the active `session_id`. Close the session first. +- **Flash confirmation by architecture**: `erase_and_flash` / `update_flash` error if the env's architecture isn't ESP32 — use `pio_flash` for nRF52/RP2040/STM32. + +## Environment variables + +| Var | Default | Purpose | +| -------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------- | +| `MESHTASTIC_FIRMWARE_ROOT` | walks up from cwd for `platformio.ini` | Pin the firmware repo | +| `MESHTASTIC_PIO_BIN` | `~/.platformio/penv/bin/pio` → `$PATH` `pio` → `platformio` | Override `pio` location | +| `MESHTASTIC_ESPTOOL_BIN` | `/.venv/bin/esptool` → `$PATH` | Override esptool | +| `MESHTASTIC_NRFUTIL_BIN` | `$PATH` | Override nrfutil | +| `MESHTASTIC_PICOTOOL_BIN` | `$PATH` | Override picotool | +| `MESHTASTIC_MCP_SEED` | `mcp--` | PSK seed for test-harness session (CI override) | +| `MESHTASTIC_MCP_FLASH_LOG` | `/tests/flash.log` | Tee target for pio/esptool/nrfutil subprocess output (TUI tails it) | + +## Hardware Test Suite + +`mcp-server/tests/` holds a pytest-based integration suite that exercises +real USB-connected Meshtastic devices against the MCP server surface. Separate +from the native C++ unit tests in the firmware repo's top-level `test/` +directory — this one validates the device-facing behavior end-to-end. + +### Invocation + +```bash +./mcp-server/run-tests.sh # full suite (auto-detect + auto-bake-if-needed) +./mcp-server/run-tests.sh --force-bake # reflash devices before testing +./mcp-server/run-tests.sh --assume-baked # skip the bake step (caller vouches for state) +./mcp-server/run-tests.sh tests/mesh # one tier +./mcp-server/run-tests.sh tests/mesh/test_traceroute.py # one file +./mcp-server/run-tests.sh -k telemetry # pytest name filter +``` + +The wrapper auto-detects connected devices (VID `0x239A` → `nrf52` → env +`rak4631`; `0x303A` or `0x10C4` → `esp32s3` → env `heltec-v3`), exports +`MESHTASTIC_MCP_ENV_` env vars, and invokes pytest. Overrides via +per-role env vars: `MESHTASTIC_MCP_ENV_NRF52=heltec-mesh-node-t114 ./run-tests.sh`. + +No hardware connected? The wrapper narrows to `tests/unit/` only and says so +in the pre-flight header. + +### Tiers (run in this order) + +- **`bake`** (`tests/test_00_bake.py`) — flashes both hub roles with the + session's test profile. Has a skip-if-already-baked check (region + channel + match); `--force-bake` overrides. +- **`unit`** — pure Python, no hardware. boards / PIO wrapper / + userPrefs-parse / testing-profile fixtures. +- **`mesh`** — 2-device mesh: formation, broadcast delivery, direct+ACK, + traceroute, bidirectional. Parametrized over both directions. +- **`telemetry`** — periodic telemetry broadcast + on-demand request/reply + (`TELEMETRY_APP` with `wantResponse=True`). +- **`monitor`** — boot log has no panic markers within 60 s of reboot. +- **`fleet`** — PSK-seed isolation: two labs with different seeds never + overlap. +- **`admin`** — owner persistence across reboot, channel URL round-trip, + `lora.hop_limit` persistence. +- **`provisioning`** — region/channel baking, userPrefs survive + `factory_reset(full=False)`. + +### Artifacts (regenerated every run, under `tests/`) + +- `report.html` — self-contained pytest-html report. Each test gets a + **Meshtastic debug** section attached on failure with a 200-line firmware + log tail + device-state dump. Open this first on failures. +- `junit.xml` — CI-parseable. +- `reportlog.jsonl` — `pytest-reportlog` event stream; consumed by the TUI. +- `fwlog.jsonl` — firmware log mirror (`meshtastic.log.line` pubsub → JSONL). +- `flash.log` — tee of all pio / esptool / nrfutil / picotool subprocess + output during the run (driven by `MESHTASTIC_MCP_FLASH_LOG`). + +### Live TUI + +```bash +.venv/bin/meshtastic-mcp-test-tui +.venv/bin/meshtastic-mcp-test-tui tests/mesh # pytest args pass through +``` + +Textual-based wrapper over `run-tests.sh` with a live test tree, tier +counters, pytest output pane, firmware-log pane, and a device-status strip. +Key bindings: `r` re-run focused, `f` filter, `d` failure detail, `g` open +`report.html`, `x` export reproducer bundle, `l` cycle fw-log filter, `q` +quit (SIGINT → SIGTERM → SIGKILL escalation). + +### Slash commands + +Three AI-assisted workflows are wired up for Claude Code operators +(`.claude/commands/`) and Copilot operators (`.github/prompts/`): +`/test` (run + interpret), `/diagnose` (read-only health report), `/repro` +(flake triage, N-times re-run with log diff). + +### House rules (for human + agent contributors) + +- Session-scoped fixtures in `tests/conftest.py` snapshot + restore + `userPrefs.jsonc`; **never edit `userPrefs.jsonc` from inside a test**. + Use the `test_profile` / `no_region_profile` fixtures for ephemeral + overrides. +- `SerialInterface` holds an **exclusive port lock**; sequence calls + open → mutate → close, then next device. No parallel calls to the + same port. +- Directed PKI-encrypted sends need **bilateral NodeInfo warmup** — + both sides must hold the other's current pubkey. See + `tests/mesh/_receive.py::nudge_nodeinfo_port` and the three directed- + send tests (`test_direct_with_ack`, `test_traceroute`, + `test_telemetry_request_reply`) for the canonical pattern. + +## Layout + +```text +mcp-server/ +├── pyproject.toml +├── README.md +└── src/meshtastic_mcp/ + ├── __main__.py # entry: python -m meshtastic_mcp + ├── server.py # FastMCP app + @app.tool() registrations (thin) + ├── config.py # firmware_root, pio_bin, esptool_bin, etc. + ├── pio.py # subprocess wrapper (timeouts, JSON, tail_lines) + ├── devices.py # list_devices (findPorts + comports) + ├── boards.py # list_boards / get_board (pio project config parse + cache) + ├── flash.py # build, clean, flash, erase_and_flash, update_flash, touch_1200bps + ├── serial_session.py # SerialSession + reader thread + ring buffer + ├── registry.py # session registry + per-port locks + ├── connection.py # connect(port) ctx mgr — SerialInterface + port lock + ├── info.py # device_info, list_nodes + ├── admin.py # set_owner, get/set_config, channels, send_text, reboot/shutdown/factory_reset + └── hw_tools.py # esptool / nrfutil / picotool wrappers +``` + +## Troubleshooting + +- **"Could not locate Meshtastic firmware root"** — set `MESHTASTIC_FIRMWARE_ROOT`. +- **"Could not find `pio`"** — install PlatformIO or set `MESHTASTIC_PIO_BIN`. +- **"Port is held by serial session ..."** — call `serial_close(session_id)` or `serial_list` to find it. +- **`factory.bin` not found after build** — the env may not be ESP32; only ESP32 envs produce a `.factory.bin`. +- **`touch_1200bps` reported `new_port: null`** — the device may not have 1200bps-reset stdio, or the bootloader re-uses the same port name. Check `list_devices` manually. diff --git a/mcp-server/pyproject.toml b/mcp-server/pyproject.toml new file mode 100644 index 000000000..d73bf795f --- /dev/null +++ b/mcp-server/pyproject.toml @@ -0,0 +1,39 @@ +[project] +name = "meshtastic-mcp" +version = "0.1.0" +description = "MCP server for Meshtastic firmware development: device discovery, PlatformIO tooling, flashing, serial monitoring, and device administration via the meshtastic Python API." +readme = "README.md" +requires-python = ">=3.11" +license = { text = "GPL-3.0-only" } +authors = [{ name = "thebentern" }] +dependencies = ["mcp>=1.2", "pyserial>=3.5", "meshtastic>=2.7.8"] + +[project.optional-dependencies] +dev = ["pytest>=7"] +test = [ + "pytest>=8", + "pytest-html>=4", + "pytest-reportlog>=0.4", + "pytest-timeout>=2.3", + "coverage[toml]>=7", + "pyyaml>=6", + # textual is required by the `meshtastic-mcp-test-tui` script (see + # `src/meshtastic_mcp/cli/test_tui.py`). Bundled into `test` rather than a + # separate `[tui]` extra because v1 expects test operators are the only + # consumers; revisit if install cost pushes back. + "textual>=0.50", +] + +[project.scripts] +meshtastic-mcp = "meshtastic_mcp.__main__:main" +# Live TUI wrapping run-tests.sh — shells out to the same script the plain +# CLI uses, tails pytest-reportlog for per-test state, and polls the device +# list at startup + post-run (port lock forces it to stay idle during the run). +meshtastic-mcp-test-tui = "meshtastic_mcp.cli.test_tui:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/meshtastic_mcp"] diff --git a/mcp-server/run-tests.sh b/mcp-server/run-tests.sh new file mode 100755 index 000000000..292e6e3a2 --- /dev/null +++ b/mcp-server/run-tests.sh @@ -0,0 +1,236 @@ +#!/usr/bin/env bash +# mcp-server hardware test runner. +# +# Auto-detects connected Meshtastic devices, maps each to its PlatformIO env +# via the same role table the pytest fixtures use, exports the right +# MESHTASTIC_MCP_ENV_* env vars, and invokes pytest. +# +# Usage: +# ./run-tests.sh # full suite, default pytest args +# ./run-tests.sh tests/mesh # subset (any pytest args pass through) +# ./run-tests.sh --force-bake # override one default with another +# MESHTASTIC_MCP_ENV_NRF52=foo ./run-tests.sh # override env per role +# MESHTASTIC_MCP_SEED=ci-run-42 ./run-tests.sh # override PSK seed +# +# If zero supported devices are detected, only the unit tier runs. +# +# Also restores `userPrefs.jsonc` from the session-backup sidecar if a prior +# run exited abnormally (belt to conftest.py's atexit suspenders). + +set -euo pipefail + +# cd to the script's directory so relative paths resolve consistently no +# matter where the user invoked from. +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +cd "$SCRIPT_DIR" + +VENV_PY="$SCRIPT_DIR/.venv/bin/python" +if [[ ! -x $VENV_PY ]]; then + echo "error: $VENV_PY not found or not executable." >&2 + echo " Bootstrap the venv first:" >&2 + echo " cd $SCRIPT_DIR && python3 -m venv .venv && .venv/bin/pip install -e '.[test]'" >&2 + exit 2 +fi + +# Resolve firmware root the same way conftest.py does (this script sits in +# mcp-server/, firmware repo root is one level up). +FIRMWARE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +USERPREFS_PATH="$FIRMWARE_ROOT/userPrefs.jsonc" +USERPREFS_SIDECAR="$USERPREFS_PATH.mcp-session-bak" + +# ---------- Pre-flight: recover stale userPrefs.jsonc from prior crash ---- +# If conftest.py's atexit hook didn't fire (SIGKILL, kernel panic, OS +# restart), the sidecar is the ground truth. Self-heal before running so we +# don't bake the previous run's dirty state into this run's firmware. +if [[ -f $USERPREFS_SIDECAR ]]; then + echo "[pre-flight] found $USERPREFS_SIDECAR from a prior abnormal exit;" >&2 + echo " restoring userPrefs.jsonc before starting." >&2 + cp "$USERPREFS_SIDECAR" "$USERPREFS_PATH" + rm -f "$USERPREFS_SIDECAR" +fi + +# If userPrefs.jsonc has uncommitted changes BEFORE the run starts, that's +# worth warning about — tests will snapshot this dirty state and restore to +# it at the end, which may not be what the operator wants. +if command -v git >/dev/null 2>&1; then + cd "$FIRMWARE_ROOT" + # Capture the git status into a local first — SC2312 flags command + # substitution inside `[[ -n ... ]]` because the exit code of `git + # status` is masked. A two-step assignment makes the failure path + # explicit (non-git, missing file) and keeps the bracket test clean. + _git_status_porcelain="$(git status --porcelain userPrefs.jsonc 2>/dev/null || true)" + if [[ -n $_git_status_porcelain ]]; then + echo "[pre-flight] warning: userPrefs.jsonc has uncommitted changes." >&2 + echo " Tests will snapshot THIS state and restore to it" >&2 + echo " at teardown. If that's not intended, run:" >&2 + echo " git checkout userPrefs.jsonc" >&2 + echo " and re-invoke." >&2 + fi + cd "$SCRIPT_DIR" +fi + +# ---------- Seed default -------------------------------------------------- +# Per-machine default so repeated runs from the same operator land on the +# same PSK (makes --assume-baked valid across invocations). Operator can +# override with an explicit env var if they want isolation (e.g. CI). +if [[ -z ${MESHTASTIC_MCP_SEED-} ]]; then + WHO="$(whoami 2>/dev/null || echo anon)" + HOST="$(hostname -s 2>/dev/null || echo host)" + export MESHTASTIC_MCP_SEED="mcp-${WHO}-${HOST}" +fi + +# ---------- Flash progress log -------------------------------------------- +# pio.py / hw_tools.py tee subprocess output (pio run -t upload, esptool, +# nrfutil, picotool) to this file line-by-line as it arrives when this env +# var is set. The TUI tails it so the operator sees live flash progress +# instead of 3 minutes of silence during `test_00_bake.py`. Plain CLI users +# also benefit — the log is a post-run diagnostic even without the TUI. +# Truncate at session start so each run gets a clean log. +export MESHTASTIC_MCP_FLASH_LOG="$SCRIPT_DIR/tests/flash.log" +: >"$MESHTASTIC_MCP_FLASH_LOG" + +# ---------- Detect connected hardware ------------------------------------- +# In-process call to the same Python API the test fixtures use, so the +# script never drifts from what pytest sees. Returns a JSON object +# {role: port, ...}. +ROLES_JSON="$( + "$VENV_PY" - <<'PY' +import json +import sys + +sys.path.insert(0, "src") +from meshtastic_mcp import devices + +# Role → canonical VID map. Kept in sync with +# `tests/conftest.py::hub_profile` defaults; if that changes, this must too. +ROLE_BY_VID = { + 0x239A: "nrf52", # Adafruit / RAK nRF52 native USB (app + DFU) + 0x303A: "esp32s3", # Espressif native USB (ESP32-S3) + 0x10C4: "esp32s3", # CP2102 USB-UART (common on Heltec/LilyGO ESP32 boards) +} + +out: dict[str, str] = {} +for dev in devices.list_devices(include_unknown=True): + vid_raw = dev.get("vid") or "" + try: + if isinstance(vid_raw, str) and vid_raw.startswith("0x"): + vid = int(vid_raw, 16) + else: + vid = int(vid_raw) + except (TypeError, ValueError): + continue + role = ROLE_BY_VID.get(vid) + # First port wins per role — matches hub_devices fixture semantics. + if role and role not in out: + out[role] = dev["port"] + +json.dump(out, sys.stdout) +PY +)" + +# ---------- Map role → pio env -------------------------------------------- +# Honor MESHTASTIC_MCP_ENV_ operator overrides; fall back to the +# same defaults hardcoded in tests/conftest.py::_DEFAULT_ROLE_ENVS. +resolve_env() { + local role="$1" + local default="$2" + local upper + upper="$(echo "$role" | tr '[:lower:]' '[:upper:]')" + local var="MESHTASTIC_MCP_ENV_${upper}" + eval "local override=\${$var:-}" + if [[ -n $override ]]; then + echo "$override" + else + echo "$default" + fi +} + +NRF52_PORT="$(echo "$ROLES_JSON" | "$VENV_PY" -c 'import json,sys; print(json.loads(sys.stdin.read()).get("nrf52", ""))')" +ESP32S3_PORT="$(echo "$ROLES_JSON" | "$VENV_PY" -c 'import json,sys; print(json.loads(sys.stdin.read()).get("esp32s3", ""))')" + +DETECTED="" +if [[ -n $NRF52_PORT ]]; then + NRF52_ENV="$(resolve_env nrf52 rak4631)" + export MESHTASTIC_MCP_ENV_NRF52="$NRF52_ENV" + DETECTED="${DETECTED} nrf52 @ ${NRF52_PORT} -> env=${NRF52_ENV}\n" +fi +if [[ -n $ESP32S3_PORT ]]; then + ESP32S3_ENV="$(resolve_env esp32s3 heltec-v3)" + export MESHTASTIC_MCP_ENV_ESP32S3="$ESP32S3_ENV" + DETECTED="${DETECTED} esp32s3 @ ${ESP32S3_PORT} -> env=${ESP32S3_ENV}\n" +fi + +# ---------- Pre-flight summary -------------------------------------------- +# Surface what pytest is about to do with respect to the bake phase: the +# operator should see "will verify + bake if needed" by default, so a +# 3-minute flash appearing mid-run isn't a surprise. Detection of the +# explicit overrides is best-effort — we just scan $@ for the known flags. +_bake_mode="auto (verify + bake if needed)" +for _arg in "$@"; do + case "$_arg" in + --assume-baked) _bake_mode="skip (--assume-baked)" ;; + --force-bake) _bake_mode="force (--force-bake)" ;; + *) ;; # any other arg: pass-through; bake mode unchanged + esac +done + +echo "mcp-server test runner" +echo " firmware root : $FIRMWARE_ROOT" +echo " seed : $MESHTASTIC_MCP_SEED" +echo " bake : $_bake_mode" +if [[ -n $DETECTED ]]; then + echo " detected hub :" + printf "%b" "$DETECTED" +else + echo " detected hub : (none)" +fi +echo + +# ---------- Invoke pytest ------------------------------------------------- +# If no devices detected, only the unit tier would produce meaningful +# PASS/FAIL — every hardware test would SKIP with "role not present". We +# narrow to tests/unit explicitly so the summary reads as "no hardware, +# unit suite only" instead of "big skip count looks suspicious". +if [[ -z $DETECTED && $# -eq 0 ]]; then + echo "[pre-flight] no supported devices detected; running unit tier only." + echo + exec "$VENV_PY" -m pytest tests/unit -v --report-log=tests/reportlog.jsonl +fi + +# Default pytest args when the user passed none. Power users can invoke +# `./run-tests.sh tests/mesh -v --tb=long` and skip all of these defaults. +# +# NOTE: `--assume-baked` is DELIBERATELY omitted here. `tests/test_00_bake.py` +# has an internal skip-if-already-baked check (`_bake_role`: query device_info, +# compare region + primary_channel to the session profile, skip on match). +# So the fast path is ~8-10 s of verification overhead when the devices are +# already baked — negligible next to the 2-6 min suite runtime. Letting +# test_00_bake.py run means a fresh device, a re-seeded session, or a post- +# factory-reset device gets flashed automatically instead of silently +# skipping half the hardware tests with "not baked with session profile" +# errors. Power users who know their hardware is current and want to shave +# those seconds can pass `--assume-baked` explicitly. +if [[ $# -eq 0 ]]; then + set -- tests/ \ + --html=tests/report.html --self-contained-html \ + --junitxml=tests/junit.xml \ + -v --tb=short +fi + +# Always emit `tests/reportlog.jsonl` (unless the operator explicitly passed +# their own `--report-log=...`). Consumers — notably the +# `meshtastic-mcp-test-tui` TUI — tail the reportlog for live per-test state. +# Appending here means power-user invocations like `./run-tests.sh tests/mesh` +# also produce it, not just the all-defaults invocation. +_has_report_log=0 +for _arg in "$@"; do + case "$_arg" in + --report-log | --report-log=*) _has_report_log=1 ;; + *) ;; # any other arg: no-op; loop continues + esac +done +if [[ $_has_report_log -eq 0 ]]; then + set -- "$@" --report-log=tests/reportlog.jsonl +fi + +exec "$VENV_PY" -m pytest "$@" diff --git a/mcp-server/src/meshtastic_mcp/__init__.py b/mcp-server/src/meshtastic_mcp/__init__.py new file mode 100644 index 000000000..bd696afe0 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/__init__.py @@ -0,0 +1,3 @@ +"""Meshtastic MCP server — device discovery, PlatformIO tooling, and device admin.""" + +__version__ = "0.1.0" diff --git a/mcp-server/src/meshtastic_mcp/__main__.py b/mcp-server/src/meshtastic_mcp/__main__.py new file mode 100644 index 000000000..4ed67db38 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/__main__.py @@ -0,0 +1,11 @@ +"""Entry point for `python -m meshtastic_mcp`.""" + +from meshtastic_mcp.server import app + + +def main() -> None: + app.run() + + +if __name__ == "__main__": + main() diff --git a/mcp-server/src/meshtastic_mcp/admin.py b/mcp-server/src/meshtastic_mcp/admin.py new file mode 100644 index 000000000..6da92d860 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/admin.py @@ -0,0 +1,377 @@ +"""Device administration: owner, config, channels, messaging, admin actions. + +All operations use the same `connect()` context manager so port selection, +port-busy detection, and cleanup are handled uniformly. + +Config writes use a dot-path: the first segment names a section (e.g. +`"lora"` in LocalConfig or `"mqtt"` in LocalModuleConfig), remaining segments +walk protobuf fields. Enum fields accept their string names (`"US"` for +`lora.region`) so callers don't need to know the numeric values. +""" + +from __future__ import annotations + +from typing import Any + +from google.protobuf import descriptor as pb_descriptor +from google.protobuf import json_format +from meshtastic.protobuf import localonly_pb2 + +from .connection import connect + + +class AdminError(RuntimeError): + pass + + +LOCAL_CONFIG_SECTIONS = {f.name for f in localonly_pb2.LocalConfig.DESCRIPTOR.fields} +MODULE_CONFIG_SECTIONS = { + f.name for f in localonly_pb2.LocalModuleConfig.DESCRIPTOR.fields +} + + +def _require_confirm(confirm: bool, operation: str) -> None: + if not confirm: + raise AdminError(f"{operation} is destructive and requires confirm=True.") + + +def _message_to_dict(msg: Any) -> dict[str, Any]: + # `including_default_value_fields` was renamed to + # `always_print_fields_with_no_presence` in protobuf 5.26+. Pick whichever + # kwarg the installed version accepts so we work against both. + kwargs: dict[str, Any] = {"preserving_proto_field_name": True} + import inspect + + sig = inspect.signature(json_format.MessageToDict) + if "always_print_fields_with_no_presence" in sig.parameters: + kwargs["always_print_fields_with_no_presence"] = False + elif "including_default_value_fields" in sig.parameters: + kwargs["including_default_value_fields"] = False + return json_format.MessageToDict(msg, **kwargs) + + +# ---------- owner ---------------------------------------------------------- + + +def set_owner( + long_name: str, + short_name: str | None = None, + port: str | None = None, +) -> dict[str, Any]: + if short_name is not None and len(short_name) > 4: + raise AdminError("short_name must be 4 characters or fewer") + with connect(port=port) as iface: + iface.localNode.setOwner(long_name=long_name, short_name=short_name) + return { + "ok": True, + "long_name": long_name, + "short_name": short_name, + } + + +# ---------- config reads --------------------------------------------------- + + +def _section_container(node, section: str) -> tuple[Any, str]: + """Return (container_message, parent_name) for a section name. + + Parent is 'localConfig' or 'moduleConfig' so callers know where to call + writeConfig() after mutating. + """ + if section in LOCAL_CONFIG_SECTIONS: + return getattr(node.localConfig, section), "localConfig" + if section in MODULE_CONFIG_SECTIONS: + return getattr(node.moduleConfig, section), "moduleConfig" + raise AdminError( + f"Unknown config section: {section!r}. " + f"Valid sections: {sorted(LOCAL_CONFIG_SECTIONS | MODULE_CONFIG_SECTIONS)}" + ) + + +def get_config(section: str | None = None, port: str | None = None) -> dict[str, Any]: + """Read one or all config sections. + + `section` may be any name in LocalConfig (device, lora, position, power, + network, display, bluetooth, security) or LocalModuleConfig (mqtt, serial, + telemetry, ...). Omit `section` or pass `"all"` for everything. + """ + with connect(port=port) as iface: + node = iface.localNode + if section in (None, "all"): + lc = _message_to_dict(node.localConfig) + mc = _message_to_dict(node.moduleConfig) + return { + "config": { + "localConfig": lc, + "moduleConfig": mc, + } + } + container, _parent = _section_container(node, section) + return {"config": {section: _message_to_dict(container)}} + + +# ---------- config writes -------------------------------------------------- + + +def _coerce_enum(field: pb_descriptor.FieldDescriptor, value: Any) -> int: + """Accept an enum value as either its int or its string name.""" + enum_type = field.enum_type + if isinstance(value, bool): + raise AdminError(f"{field.name}: expected enum {enum_type.name}, got bool") + if isinstance(value, int): + if enum_type.values_by_number.get(value) is None: + raise AdminError( + f"{field.name}: {value} is not a valid {enum_type.name} value" + ) + return value + if isinstance(value, str): + upper = value.upper() + ev = enum_type.values_by_name.get(upper) + if ev is None: + valid = sorted(enum_type.values_by_name.keys()) + raise AdminError( + f"{field.name}: {value!r} is not a valid {enum_type.name}. " + f"Valid: {valid}" + ) + return ev.number + raise AdminError( + f"{field.name}: expected enum {enum_type.name}, got {type(value).__name__}" + ) + + +def _coerce_scalar(field: pb_descriptor.FieldDescriptor, value: Any) -> Any: + t = field.type + FT = pb_descriptor.FieldDescriptor + if t == FT.TYPE_ENUM: + return _coerce_enum(field, value) + if t == FT.TYPE_BOOL: + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.strip().lower() in ("true", "yes", "1", "on") + if isinstance(value, int): + return bool(value) + if t in ( + FT.TYPE_INT32, + FT.TYPE_INT64, + FT.TYPE_UINT32, + FT.TYPE_UINT64, + FT.TYPE_SINT32, + FT.TYPE_SINT64, + FT.TYPE_FIXED32, + FT.TYPE_FIXED64, + ): + return int(value) + if t in (FT.TYPE_FLOAT, FT.TYPE_DOUBLE): + return float(value) + if t == FT.TYPE_STRING: + return str(value) + if t == FT.TYPE_BYTES: + if isinstance(value, (bytes, bytearray)): + return bytes(value) + return str(value).encode("utf-8") + raise AdminError( + f"{field.name}: unsupported field type {t}. Use raw protobuf for this field." + ) + + +def _walk_to_field( + root_msg: Any, path_segments: list[str] +) -> tuple[Any, pb_descriptor.FieldDescriptor]: + """Walk `root_msg` by field names until the leaf; return (parent_msg, leaf_field_descriptor).""" + msg = root_msg + for i, name in enumerate(path_segments): + desc = msg.DESCRIPTOR + field = desc.fields_by_name.get(name) + if field is None: + trail = ".".join(path_segments[:i] or [""]) + valid = [f.name for f in desc.fields] + raise AdminError(f"No field {name!r} in {trail}. Valid: {valid}") + is_last = i == len(path_segments) - 1 + if is_last: + return msg, field + if field.type != pb_descriptor.FieldDescriptor.TYPE_MESSAGE: + raise AdminError( + f"{'.'.join(path_segments[:i+1])} is a scalar; cannot descend into it" + ) + msg = getattr(msg, name) + # path_segments was empty + raise AdminError("Empty config path") + + +def set_config(path: str, value: Any, port: str | None = None) -> dict[str, Any]: + """Set a single config field by dot-path and write it to the device. + + Examples: + set_config("lora.region", "US") + set_config("lora.modem_preset", "LONG_FAST") + set_config("device.role", "ROUTER") + set_config("mqtt.enabled", True) + set_config("mqtt.address", "mqtt.example.com") + + """ + segments = [s for s in path.split(".") if s] + if not segments: + raise AdminError("path cannot be empty") + section = segments[0] + + with connect(port=port) as iface: + node = iface.localNode + container, parent_name = _section_container(node, section) + + # Treat the section as the root; the rest of the path walks into it. + leaf_parent, field = _walk_to_field(container, segments[1:] or []) + # Use `is_repeated` (modern upb protobuf API) rather than the + # deprecated `label == LABEL_REPEATED` check — the C-extension + # FieldDescriptor in protobuf >= 5.x doesn't expose `.label` at + # all, and `is_repeated` is the supported replacement that works + # across both the pure-python and upb backends. + if field.is_repeated: + raise AdminError( + f"{path!r} is a repeated field; v1 only supports scalar sets. " + "Use the raw meshtastic CLI for now." + ) + old_raw = getattr(leaf_parent, field.name) + coerced = _coerce_scalar(field, value) + try: + setattr(leaf_parent, field.name, coerced) + except (TypeError, ValueError) as exc: + raise AdminError(f"{path}: {exc}") from exc + + node.writeConfig(section) + + # Stringify enums for the response (so the caller can see the change in + # the same vocabulary they used to set it). + if field.type == pb_descriptor.FieldDescriptor.TYPE_ENUM: + try: + old_display = field.enum_type.values_by_number[old_raw].name + new_display = field.enum_type.values_by_number[coerced].name + except Exception: + old_display, new_display = old_raw, coerced + else: + old_display, new_display = old_raw, coerced + + return { + "ok": True, + "path": path, + "section": section, + "parent": parent_name, + "old_value": old_display, + "new_value": new_display, + } + + +# ---------- channels ------------------------------------------------------- + + +def get_channel_url( + include_all: bool = False, port: str | None = None +) -> dict[str, Any]: + with connect(port=port) as iface: + url = iface.localNode.getURL(includeAll=include_all) + return {"url": url} + + +def set_channel_url(url: str, port: str | None = None) -> dict[str, Any]: + with connect(port=port) as iface: + # setURL replaces the channel set from the URL's contents. It does not + # return a count; we infer by counting non-DISABLED channels after. + iface.localNode.setURL(url) + channels = iface.localNode.channels or [] + active = sum(1 for c in channels if getattr(c, "role", 0) != 0) + return {"ok": True, "channels_imported": active} + + +# ---------- messaging ------------------------------------------------------ + + +def send_text( + text: str, + to: str | int | None = None, + channel_index: int = 0, + want_ack: bool = False, + port: str | None = None, +) -> dict[str, Any]: + destination = to if to is not None else "^all" + with connect(port=port) as iface: + packet = iface.sendText( + text, + destinationId=destination, + wantAck=want_ack, + channelIndex=channel_index, + ) + packet_id = getattr(packet, "id", None) + return {"ok": True, "packet_id": packet_id, "destination": destination} + + +# ---------- diagnostics ---------------------------------------------------- + + +def set_debug_log_api(enabled: bool, port: str | None = None) -> dict[str, Any]: + """Toggle `config.security.debug_log_api_enabled` on the local node. + + When enabled, firmware emits log lines as protobuf `LogRecord` messages + over the StreamAPI instead of raw text. meshtastic-python surfaces them + on pubsub topic `meshtastic.log.line`, which flows through the SAME + SerialInterface our tests already hold open — no `pio device monitor` + needed, no port-contention with admin/info calls. + + Firmware gate: `src/SerialConsole.cpp` (`usingProtobufs && + config.security.debug_log_api_enabled`). Setting persists in NVS; it + survives reboot. `factory_reset(full=False)` clears it unless it's + re-applied after reset. + + Previously-documented concurrency hazard (emitLogRecord sharing the + main packet-emission buffers) has been fixed — see `StreamAPI.h` + where the log path now owns dedicated `fromRadioScratchLog` / + `txBufLog` buffers, and `StreamAPI::emitTxBuffer` + + `StreamAPI::emitLogRecord` both serialize their `stream->write` + calls via `streamLock`. Leaving the flag on under traffic is safe. + """ + with connect(port=port) as iface: + sec = iface.localNode.localConfig.security + sec.debug_log_api_enabled = bool(enabled) + iface.localNode.writeConfig("security") + return {"ok": True, "debug_log_api_enabled": bool(enabled)} + + +# ---------- admin actions -------------------------------------------------- + + +def reboot( + port: str | None = None, confirm: bool = False, seconds: int = 10 +) -> dict[str, Any]: + _require_confirm(confirm, "reboot") + with connect(port=port) as iface: + iface.localNode.reboot(secs=seconds) + return {"ok": True, "rebooting_in_s": seconds} + + +def shutdown( + port: str | None = None, confirm: bool = False, seconds: int = 10 +) -> dict[str, Any]: + _require_confirm(confirm, "shutdown") + with connect(port=port) as iface: + iface.localNode.shutdown(secs=seconds) + return {"ok": True, "shutting_down_in_s": seconds} + + +def factory_reset( + port: str | None = None, confirm: bool = False, full: bool = False +) -> dict[str, Any]: + """Tell the node to factory-reset its config. + + Works around a meshtastic-python 2.7.8 bug: `Node.factoryReset(full=True)` + internally does `p.factory_reset_config = True` where the field is + int32. protobuf 5.x rejects bool→int assignment as a TypeError. We build + the AdminMessage directly with int values (1=non-full, 2=full) and call + `_sendAdmin` to sidestep the SDK bug entirely. + """ + _require_confirm(confirm, "factory_reset") + from meshtastic.protobuf import admin_pb2 # type: ignore[import-untyped] + + with connect(port=port) as iface: + msg = admin_pb2.AdminMessage() + msg.factory_reset_config = 2 if full else 1 + iface.localNode._sendAdmin(msg) + return {"ok": True, "full": full} diff --git a/mcp-server/src/meshtastic_mcp/boards.py b/mcp-server/src/meshtastic_mcp/boards.py new file mode 100644 index 000000000..df5024800 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/boards.py @@ -0,0 +1,159 @@ +"""Board / PlatformIO env enumeration. + +Parses `pio project config --json-output` — a nested list of +`[section_name, [[key, value], ...]]` pairs — into a dict keyed by env name, +extracting the `custom_meshtastic_*` metadata the firmware variants expose. + +The parsed config is cached and invalidated when `platformio.ini`'s mtime +changes, so subsequent calls don't pay the 1–2s pio startup cost. +""" + +from __future__ import annotations + +import threading +from typing import Any + +from . import config, pio + +_CACHE_LOCK = threading.Lock() +_CACHE: dict[str, Any] = {"mtime": None, "envs": None} + + +def _parse_bool(value: Any) -> bool: + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.strip().lower() in ("true", "yes", "1", "on") + return bool(value) + + +def _parse_int(value: Any) -> int | None: + try: + return int(value) + except (TypeError, ValueError): + return None + + +def _parse_tags(value: Any) -> list[str]: + if value is None: + return [] + if isinstance(value, list): + return [str(v).strip() for v in value if str(v).strip()] + return [t.strip() for t in str(value).replace(",", " ").split() if t.strip()] + + +def _env_record(env_name: str, items: list[list[Any]]) -> dict[str, Any]: + """Build a normalized dict for one env section.""" + d = dict(items) + return { + "env": env_name, + "architecture": d.get("custom_meshtastic_architecture"), + "hw_model": _parse_int(d.get("custom_meshtastic_hw_model")), + "hw_model_slug": d.get("custom_meshtastic_hw_model_slug"), + "display_name": d.get("custom_meshtastic_display_name"), + "actively_supported": _parse_bool( + d.get("custom_meshtastic_actively_supported") + ), + "support_level": _parse_int(d.get("custom_meshtastic_support_level")), + "board_level": d.get("board_level"), # "pr", "extra", or None + "tags": _parse_tags(d.get("custom_meshtastic_tags")), + "images": _parse_tags(d.get("custom_meshtastic_images")), + "board": d.get("board"), + "upload_speed": _parse_int(d.get("upload_speed")), + "upload_protocol": d.get("upload_protocol"), + "monitor_speed": _parse_int(d.get("monitor_speed")), + "monitor_filters": d.get("monitor_filters") or [], + "_raw": d, # Full dict for get_board + } + + +def _load_all() -> dict[str, dict[str, Any]]: + """Parse `pio project config` into `{env_name: record}`.""" + raw = pio.run_json(["project", "config"], timeout=pio.TIMEOUT_PROJECT_CONFIG) + result: dict[str, dict[str, Any]] = {} + for section_name, items in raw: + if not isinstance(section_name, str) or not section_name.startswith("env:"): + continue + env_name = section_name.split(":", 1)[1] + result[env_name] = _env_record(env_name, items) + return result + + +def _get_cached() -> dict[str, dict[str, Any]]: + root = config.firmware_root() + platformio_ini = root / "platformio.ini" + try: + mtime = platformio_ini.stat().st_mtime + except FileNotFoundError: + mtime = None + + with _CACHE_LOCK: + if _CACHE["envs"] is not None and _CACHE["mtime"] == mtime: + return _CACHE["envs"] + envs = _load_all() + _CACHE["envs"] = envs + _CACHE["mtime"] = mtime + return envs + + +def invalidate_cache() -> None: + with _CACHE_LOCK: + _CACHE["envs"] = None + _CACHE["mtime"] = None + + +def _public_record(rec: dict[str, Any]) -> dict[str, Any]: + """Strip the `_raw` field for list outputs.""" + return {k: v for k, v in rec.items() if not k.startswith("_")} + + +def list_boards( + architecture: str | None = None, + actively_supported_only: bool = False, + query: str | None = None, + board_level: str | None = None, # "release" | "pr" | "extra" +) -> list[dict[str, Any]]: + """Enumerate PlatformIO envs with Meshtastic metadata. + + Filters are cumulative (AND). `board_level="release"` means envs with no + explicit `board_level` set (the default release targets). + """ + envs = _get_cached() + q = query.lower().strip() if query else None + + out = [] + for rec in envs.values(): + if architecture and rec.get("architecture") != architecture: + continue + if actively_supported_only and not rec.get("actively_supported"): + continue + if board_level is not None: + rec_level = rec.get("board_level") + if board_level == "release": + if rec_level not in (None, ""): + continue + elif rec_level != board_level: + continue + if q: + display = (rec.get("display_name") or "").lower() + env_name = rec.get("env", "").lower() + slug = (rec.get("hw_model_slug") or "").lower() + if q not in display and q not in env_name and q not in slug: + continue + out.append(_public_record(rec)) + + out.sort(key=lambda r: (r.get("architecture") or "", r.get("env"))) + return out + + +def get_board(env: str) -> dict[str, Any]: + """Full metadata for one env, including the raw pio config dict.""" + envs = _get_cached() + rec = envs.get(env) + if rec is None: + raise KeyError( + f"Unknown env: {env!r}. Use list_boards() to see available envs." + ) + public = _public_record(rec) + public["raw_config"] = rec["_raw"] + return public diff --git a/mcp-server/src/meshtastic_mcp/cli/__init__.py b/mcp-server/src/meshtastic_mcp/cli/__init__.py new file mode 100644 index 000000000..04729b643 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/__init__.py @@ -0,0 +1,6 @@ +"""Command-line entry points that sit alongside the MCP server. + +Modules here are loaded on-demand by `[project.scripts]` entries in +`pyproject.toml`. They are NOT imported by `meshtastic_mcp.server` or the +admin/info tool surface — the MCP server stays pure stdio JSON-RPC. +""" diff --git a/mcp-server/src/meshtastic_mcp/cli/_flashlog.py b/mcp-server/src/meshtastic_mcp/cli/_flashlog.py new file mode 100644 index 000000000..889183bb3 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_flashlog.py @@ -0,0 +1,73 @@ +"""Flash progress log tailer for ``meshtastic-mcp-test-tui``. + +``pio.py`` / ``hw_tools.py`` tee subprocess output (``pio run -t upload``, +``esptool erase_flash``, ``nrfutil dfu``, etc.) to ``tests/flash.log`` +line-by-line as it arrives — controlled by the ``MESHTASTIC_MCP_FLASH_LOG`` +env var that ``run-tests.sh`` sets. The TUI tails that file so the operator +sees live flash progress in the pytest pane instead of 3 minutes of silence +during ``test_00_bake``. + +Separate from ``_fwlog.py`` because that one parses JSONL, this one +streams plain text lines. Same daemon-thread + EOF-backoff structure. +""" + +from __future__ import annotations + +import pathlib +import threading +import time +from typing import Callable + + +class FlashLogTailer(threading.Thread): + """Tail a plain-text log file, publish each stripped line via ``post``. + + ``post`` is invoked with a single ``str`` for every new line. Lines are + stripped of trailing newlines; empty lines after stripping are dropped. + + The file may not exist yet when this thread starts — it's truncated by + ``run-tests.sh`` at session start, but if the tailer races the shell, + we tolerate FileNotFoundError for up to ``wait_s`` seconds. + """ + + def __init__( + self, + path: pathlib.Path, + post: Callable[[str], None], + stop: threading.Event, + *, + wait_s: float = 30.0, + ) -> None: + super().__init__(daemon=True, name="flashlog-tail") + self._path = path + self._post = post + self._stop = stop + self._wait_s = wait_s + + def run(self) -> None: + deadline = time.monotonic() + self._wait_s + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8", errors="replace") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.rstrip("\r\n") + if not line: + continue + try: + self._post(line) + except Exception: + # A post failure (e.g. closed app) is terminal for this + # thread but we still want to close the file handle. + return + finally: + fh.close() diff --git a/mcp-server/src/meshtastic_mcp/cli/_fwlog.py b/mcp-server/src/meshtastic_mcp/cli/_fwlog.py new file mode 100644 index 000000000..7db20f81c --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_fwlog.py @@ -0,0 +1,96 @@ +"""Firmware log tail worker for ``meshtastic-mcp-test-tui``. + +Complements v1's reportlog-tail worker. ``tests/conftest.py`` owns a +session-scoped autouse fixture (``_firmware_log_stream``) that mirrors +every ``meshtastic.log.line`` pubsub event to ``tests/fwlog.jsonl`` — +one JSON object per line: + + {"ts": 1729100000.123, "port": "/dev/cu.usbmodem1101", "line": "..."} + +The TUI tails that file from a worker thread; each new line becomes a +:class:`FirmwareLogLine` message posted to the App. Same pattern as the +reportlog tail worker — truncate on launch, tolerate missing file for +30 s, back off at EOF. + +Kept in its own module so the (large) ``test_tui.py`` stays focused on +the Textual App shell. +""" + +from __future__ import annotations + +import json +import pathlib +import threading +import time +from typing import Any, Callable + + +class FirmwareLogTailer(threading.Thread): + """Tail ``tests/fwlog.jsonl``, publish parsed records via ``post``. + + ``post`` is the App's ``post_message`` (or any callable that accepts a + single payload arg). We pass parsed dicts rather than constructing + Textual Message objects here — keeps this module free of the + textual dependency so it's unit-testable in a bare venv. + + Parameters + ---------- + path: + Path to ``tests/fwlog.jsonl``. The file may not exist yet at + startup — pytest only creates it once the session fixture runs. + post: + Callable invoked with a dict ``{"ts", "port", "line"}`` for every + new line parsed from the file. + stop: + An event the App sets to signal shutdown. + wait_s: + How long to poll for the file's creation before giving up. Default + 30 s; pytest collection on a cold cache can be slow. + + """ + + def __init__( + self, + path: pathlib.Path, + post: Callable[[dict[str, Any]], None], + stop: threading.Event, + *, + wait_s: float = 30.0, + ) -> None: + super().__init__(daemon=True, name="fwlog-tail") + self._path = path + self._post = post + self._stop = stop + self._wait_s = wait_s + + def run(self) -> None: + deadline = time.monotonic() + self._wait_s + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.strip() + if not line: + continue + try: + record = json.loads(line) + except json.JSONDecodeError: + continue + # Defensive: require the three fields we rely on. + if not isinstance(record, dict): + continue + if "line" not in record: + continue + self._post(record) + finally: + fh.close() diff --git a/mcp-server/src/meshtastic_mcp/cli/_history.py b/mcp-server/src/meshtastic_mcp/cli/_history.py new file mode 100644 index 000000000..639dcec5f --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_history.py @@ -0,0 +1,127 @@ +"""Cross-run history for ``meshtastic-mcp-test-tui``. + +Persists one JSON object per pytest run to +``mcp-server/tests/.history/runs.jsonl``. The TUI reads the last N +entries on launch to render a duration sparkline in the header — a +quick read on whether the suite is slowing down over time. + +Schema (keep small; the file can grow for months): + + {"run": 42, "ts": 1729100000.0, "duration_s": 387.2, + "passed": 52, "failed": 0, "skipped": 23, "exit_code": 0, + "seed": "mcp-user-host"} +""" + +from __future__ import annotations + +import json +import pathlib +import time +from dataclasses import asdict, dataclass +from typing import Iterable + +# Sparkline glyphs, low → high. 8 levels is the Unicode convention. +_SPARK_BLOCKS = "▁▂▃▄▅▆▇█" + + +@dataclass +class RunRecord: + run: int + ts: float + duration_s: float + passed: int + failed: int + skipped: int + exit_code: int + seed: str + + +class HistoryStore: + """Append-only JSONL store with bounded read. + + Writes are fsynced after each append (the file is tiny; fsync cost + is negligible and protects against truncation on a crash). + """ + + def __init__(self, path: pathlib.Path, *, keep_last: int = 50) -> None: + self._path = path + self._keep_last = keep_last + + def append(self, record: RunRecord) -> None: + try: + self._path.parent.mkdir(parents=True, exist_ok=True) + with self._path.open("a", encoding="utf-8") as fh: + fh.write(json.dumps(asdict(record)) + "\n") + fh.flush() + except Exception: + # Non-fatal: history is cosmetic. + pass + + def read_recent(self) -> list[RunRecord]: + """Return the last ``keep_last`` records in chronological order.""" + if not self._path.is_file(): + return [] + try: + lines = self._path.read_text(encoding="utf-8").splitlines() + except OSError: + return [] + out: list[RunRecord] = [] + # Parse tail-first so we don't waste work on a huge history. + for line in lines[-self._keep_last :]: + line = line.strip() + if not line: + continue + try: + raw = json.loads(line) + except json.JSONDecodeError: + continue + try: + out.append(RunRecord(**raw)) + except TypeError: + # Schema drift; skip the record rather than crash. + continue + return out + + def record_run( + self, + *, + run: int, + duration_s: float, + passed: int, + failed: int, + skipped: int, + exit_code: int, + seed: str, + ) -> RunRecord: + rec = RunRecord( + run=run, + ts=time.time(), + duration_s=float(duration_s), + passed=int(passed), + failed=int(failed), + skipped=int(skipped), + exit_code=int(exit_code), + seed=seed, + ) + self.append(rec) + return rec + + +def sparkline(values: Iterable[float], *, width: int = 20) -> str: + """Render a Unicode block-character sparkline from the last ``width`` values. + + Returns an empty string for empty input so the header handles + "no history yet" gracefully. + """ + buf = [v for v in values if v >= 0][-width:] + if not buf: + return "" + lo, hi = min(buf), max(buf) + if hi - lo < 1e-9: + return _SPARK_BLOCKS[len(_SPARK_BLOCKS) // 2] * len(buf) + n = len(_SPARK_BLOCKS) - 1 + out = [] + for v in buf: + idx = int(round((v - lo) / (hi - lo) * n)) + out.append(_SPARK_BLOCKS[max(0, min(n, idx))]) + return "".join(out) diff --git a/mcp-server/src/meshtastic_mcp/cli/_reproducer.py b/mcp-server/src/meshtastic_mcp/cli/_reproducer.py new file mode 100644 index 000000000..420da3c76 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_reproducer.py @@ -0,0 +1,214 @@ +"""Reproducer bundle builder for ``meshtastic-mcp-test-tui``. + +When the operator presses ``x`` on a failed test leaf, we package the +minimum viable failure context into a tarball under +``mcp-server/tests/reproducers/``: + +:: + + repro--.tar.gz + ├── README.md human-readable overview + ├── test_report.json the failing TestReport event from reportlog + ├── fwlog.jsonl firmware log filtered to the failure window + ├── devices.json per-device device_info + lora config snapshot + └── env.json seed, run #, pytest version, platform, hostname + +Separate module so the logic can be unit-tested without Textual. The +TUI glue is thin — one key binding calls :func:`build_reproducer_bundle` +with the focused test's state and shows the path in a modal. +""" + +from __future__ import annotations + +import io +import json +import pathlib +import platform +import re +import socket +import tarfile +import time +from dataclasses import dataclass +from typing import Any, Iterable + + +@dataclass +class ReproContext: + """Everything :func:`build_reproducer_bundle` needs. Shaped to map + cleanly onto the state the TUI already tracks — no extra data + collection required at export time.""" + + nodeid: str + longrepr: str + sections: list[tuple[str, str]] + start_ts: float | None + stop_ts: float | None + seed: str + run_number: int + exit_code: int | None + fwlog_path: pathlib.Path + output_dir: pathlib.Path + extra_device_rows: list[dict[str, Any]] # [{role, port, info, ...}, ...] + + +def _short_nodeid(nodeid: str) -> str: + """Collapse a pytest nodeid into a filename-safe slug (<= 60 chars).""" + # Drop the file path prefix; keep test name + parametrization. + tail = nodeid.split("::", 1)[-1] if "::" in nodeid else nodeid + slug = re.sub(r"[^A-Za-z0-9_.\-]", "_", tail) + return slug[:60].strip("_.-") or "test" + + +def _filtered_fwlog( + fwlog_path: pathlib.Path, + start_ts: float | None, + stop_ts: float | None, + *, + pad_s: float = 5.0, +) -> bytes: + """Return fwlog.jsonl lines whose ``ts`` lies in [start-pad, stop+pad].""" + if not fwlog_path.is_file(): + return b"" + if start_ts is None or stop_ts is None: + # Without a time window, include the whole file — rare; happens + # when a test fails in setup before pytest emitted a start ts. + try: + return fwlog_path.read_bytes() + except OSError: + return b"" + lo, hi = start_ts - pad_s, stop_ts + pad_s + out = io.BytesIO() + try: + with fwlog_path.open("r", encoding="utf-8") as fh: + for line in fh: + stripped = line.strip() + if not stripped: + continue + try: + record = json.loads(stripped) + except json.JSONDecodeError: + continue + ts = record.get("ts") + if not isinstance(ts, (int, float)): + continue + if lo <= ts <= hi: + out.write(line.encode("utf-8")) + except OSError: + return b"" + return out.getvalue() + + +def _readme(ctx: ReproContext) -> str: + t = time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()) + return f"""# Reproducer bundle + +Exported by `meshtastic-mcp-test-tui` on {t}. + +## Failing test + +- **nodeid:** `{ctx.nodeid}` +- **seed:** `{ctx.seed}` +- **run #:** {ctx.run_number} +- **suite exit code (at export time):** {ctx.exit_code if ctx.exit_code is not None else "in progress"} + +## Files in this archive + +| File | Contents | +|---|---| +| `test_report.json` | The pytest-reportlog `TestReport` event for the failing test — includes `longrepr`, captured `sections` (stdout/stderr/log), `duration`, `location`, `keywords`. | +| `fwlog.jsonl` | Firmware log lines (from `meshtastic.log.line` pubsub) filtered to [start−5s, stop+5s] around the test's run window. Each line is `{{ts, port, line}}`. | +| `devices.json` | Per-device snapshot at export time: `device_info` + `lora` config per detected role. | +| `env.json` | Python version, platform, hostname, seed, run number. | + +## How to triage + +1. Open `test_report.json` and read `longrepr` + `sections` — most failures explain themselves there. +2. If the failure is a mesh/telemetry assertion, `fwlog.jsonl` is where the answer usually lives. Grep for `Error=`, `NAK`, `PKI_UNKNOWN_PUBKEY`, `Skip send`, `Guru Meditation`, or the uptime timestamps around the assertion event. +3. Compare `devices.json` against the expected state (e.g. `num_nodes >= 2`, `primary_channel == "McpTest"`, `region == "US"`). If fields disagree with the seed-derived USERPREFS profile, the device probably wasn't baked with this session's profile. + +## Reproducing locally + +```bash +cd mcp-server +MESHTASTIC_MCP_SEED='{ctx.seed}' .venv/bin/pytest '{ctx.nodeid}' --tb=long -v +``` +""" + + +def build_reproducer_bundle(ctx: ReproContext) -> pathlib.Path: + """Build a tarball under ``ctx.output_dir`` and return its path. + + Parent dirs are created as needed. Errors during optional sections + (devices, env) are swallowed — the bundle is still useful without + them; refusing to export because the device poller had a hiccup + would be worse than the export missing a file. + """ + ctx.output_dir.mkdir(parents=True, exist_ok=True) + ts = int(time.time()) + slug = _short_nodeid(ctx.nodeid) + archive_path = ctx.output_dir / f"repro-{ts}-{slug}.tar.gz" + + with tarfile.open(archive_path, "w:gz") as tar: + + def _add(name: str, data: bytes) -> None: + info = tarfile.TarInfo(name=name) + info.size = len(data) + info.mtime = ts + tar.addfile(info, io.BytesIO(data)) + + # README + _add("README.md", _readme(ctx).encode("utf-8")) + + # test_report.json — reconstruct from the fields the TUI stashes. + test_report = { + "nodeid": ctx.nodeid, + "outcome": "failed", + "longrepr": ctx.longrepr, + "sections": [list(s) for s in ctx.sections], + "start": ctx.start_ts, + "stop": ctx.stop_ts, + } + _add( + "test_report.json", + json.dumps(test_report, indent=2, default=str).encode("utf-8"), + ) + + # fwlog.jsonl (filtered) + _add("fwlog.jsonl", _filtered_fwlog(ctx.fwlog_path, ctx.start_ts, ctx.stop_ts)) + + # devices.json + try: + devices_payload = json.dumps( + ctx.extra_device_rows or [], indent=2, default=str + ) + except Exception: + devices_payload = "[]" + _add("devices.json", devices_payload.encode("utf-8")) + + # env.json + try: + from importlib.metadata import version as _pkg_version + + pytest_version = _pkg_version("pytest") + except Exception: + pytest_version = "unknown" + env_payload = { + "seed": ctx.seed, + "run": ctx.run_number, + "exit_code": ctx.exit_code, + "export_ts": ts, + "python": platform.python_version(), + "pytest": pytest_version, + "platform": f"{platform.system()} {platform.release()} {platform.machine()}", + "hostname": socket.gethostname(), + } + _add("env.json", json.dumps(env_payload, indent=2).encode("utf-8")) + + return archive_path + + +def iter_entries(archive_path: pathlib.Path) -> Iterable[str]: + """Yield member names — used by callers that want to confirm the bundle shape.""" + with tarfile.open(archive_path, "r:gz") as tar: + for m in tar.getmembers(): + yield m.name diff --git a/mcp-server/src/meshtastic_mcp/cli/test_tui.py b/mcp-server/src/meshtastic_mcp/cli/test_tui.py new file mode 100644 index 000000000..33201101b --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/test_tui.py @@ -0,0 +1,1782 @@ +"""Textual TUI wrapping `mcp-server/run-tests.sh`. + +Launch: ``meshtastic-mcp-test-tui [pytest-args]`` + +The TUI *wraps* ``run-tests.sh``; it never replaces it. Same script, same +env-var resolution, same ``userPrefs.jsonc`` session fixture. Four data +sources drive live state: + +1. ``tests/reportlog.jsonl`` — written by ``pytest-reportlog``. Tailed in a + worker thread; each JSON line is published as a :class:`ReportLogEvent` + message. This is the authoritative source for tree population + per-test + outcome. +2. The pytest subprocess ``stdout`` + ``stderr`` streams — line-by-line, + published as :class:`PytestLine` messages and rendered verbatim in the + pytest pane. +3. ``tests/fwlog.jsonl`` — firmware log stream. Written by the + ``_firmware_log_stream`` autouse session fixture in ``conftest.py`` + (mirrors every ``meshtastic.log.line`` pubsub event), tailed by the + :class:`FirmwareLogTailer` worker, displayed in a wrap-enabled + RichLog with cycleable port filter. +4. ``devices.list_devices()`` + ``info.device_info(port)`` — polled only at + startup and again after ``RunFinished``. Device polling while pytest + holds a SerialInterface would deadlock on the exclusive port lock; the + existing ``hub_devices`` fixture is session-scoped so there is no safe + "between tests" window. The header reflects this with a "(stale)" + marker while the run is active. + +Key bindings (see :class:`TestTuiApp.BINDINGS`): + ``r`` re-run focused ``f`` filter tree ``d`` failure detail + ``g`` open report.html ``l`` cycle firmware-log port filter + ``x`` export reproducer bundle ``c`` tool-coverage panel + ``q`` / Ctrl-C graceful quit with SIGINT → SIGTERM → SIGKILL escalation + +Shipped today (v1 + v2 slice): test tree + tier counters with progress bars, +pytest tail, live firmware log with port filter, device strip with +"currently running" status column, failure-detail modal, reproducer bundle +export (filters fwlog by test's start/stop timestamps), tool-coverage +modal, cross-run history sparkline in the header, clean SIGINT +propagation. Still open (see the plan file): mesh topology mini-diagram +and airtime / channel-utilization gauges. +""" + +from __future__ import annotations + +import argparse +import json +import os +import pathlib +import signal +import subprocess +import sys +import threading +import time +from dataclasses import dataclass, field +from typing import Any, Iterator + +# --------------------------------------------------------------------------- +# Configuration constants +# --------------------------------------------------------------------------- + +# Tier names that map nodeids like "tests//..." to counter buckets. +# Order here == display order in the tier-counters table. Matches the order +# `pytest_collection_modifyitems` in `conftest.py` uses: +# bake → unit → mesh → telemetry → monitor → fleet → admin → provisioning +# so the counters table reads top-to-bottom in execution order. +# +# "bake" is the synthetic tier for `tests/test_00_bake.py` — the file sits +# at the `tests/` root rather than under a tier subdirectory, so without +# this mapping `_tier_of_nodeid` would return "other" and the bake outcomes +# would be silently dropped from both the tier table and the history +# record (which sums tier counters to compute passed/failed/skipped). +TIERS = ( + "bake", + "unit", + "mesh", + "telemetry", + "monitor", + "fleet", + "admin", + "provisioning", +) + +# Relative paths from the mcp-server root. +_REPORTLOG_RELATIVE = "tests/reportlog.jsonl" +_FWLOG_RELATIVE = "tests/fwlog.jsonl" +# pio / esptool / nrfutil / picotool tee subprocess output here when +# `MESHTASTIC_MCP_FLASH_LOG` is set (see `pio._run_capturing`). run-tests.sh +# sets that env var; the TUI also sets it for direct `_spawn_pytest` calls +# so `r`-key re-runs that skip the wrapper still get tee'd output. +_FLASHLOG_RELATIVE = "tests/flash.log" +_REPORT_HTML_RELATIVE = "tests/report.html" +_TOOL_COVERAGE_RELATIVE = "tests/tool_coverage.json" +_HISTORY_RELATIVE = "tests/.history/runs.jsonl" +_REPRODUCERS_RELATIVE = "tests/reproducers" +_RUN_TESTS_RELATIVE = "run-tests.sh" +_RUN_COUNTER_RELATIVE = "tests/.tui-runs" + +# Graceful-shutdown budgets (seconds) for the pytest subprocess when the +# user hits `q`. Matches what the existing CLI's atexit + userprefs sidecar +# self-heal expects. +_SIGINT_GRACE_S = 5.0 +_SIGTERM_GRACE_S = 5.0 + + +# --------------------------------------------------------------------------- +# Path resolution +# --------------------------------------------------------------------------- + + +def _mcp_server_root() -> pathlib.Path: + """Locate the mcp-server directory (the one containing run-tests.sh).""" + here = pathlib.Path(__file__).resolve() + # Walk up until we find pyproject.toml with a matching project name, or + # default to the three-up ancestor (src/meshtastic_mcp/cli/test_tui.py → + # .../mcp-server). The walk-up protects against unusual checkouts. + for parent in (here.parent, *here.parents): + if (parent / "pyproject.toml").is_file() and ( + parent / "run-tests.sh" + ).is_file(): + return parent + return here.parents[3] + + +# --------------------------------------------------------------------------- +# Data classes +# --------------------------------------------------------------------------- + + +@dataclass +class LeafReport: + """Per-test state drawn from reportlog events. + + Outcomes mirror pytest's: "passed" | "failed" | "skipped" | "running". + """ + + nodeid: str + tier: str + outcome: str = "pending" + duration_s: float = 0.0 + longrepr: str = "" + # Captured stdout / stderr / firmware-log sections from the test's + # `TestReport.sections` — shown in the failure-detail modal. + sections: list[tuple[str, str]] = field(default_factory=list) + # Wall-clock start/stop from the TestReport event. Used by the + # reproducer exporter (`x`) to filter `tests/fwlog.jsonl` down to + # just the lines around the failure window. + start_ts: float | None = None + stop_ts: float | None = None + + +@dataclass +class TierCounters: + tier: str + passed: int = 0 + failed: int = 0 + skipped: int = 0 + running: int = 0 + remaining: int = 0 + + +@dataclass +class DeviceRow: + role: str | None + port: str + vid: str + pid: str + description: str + # Populated from info.device_info when available; empty dict when we + # haven't queried (or when the poller is paused). + info: dict[str, Any] = field(default_factory=dict) + + +@dataclass +class State: + """Shared state owned by the App; written by workers under `lock`. + + UI code reads via Textual Message handlers which run on the UI thread + in the order workers called `post_message` — so reads don't need the + lock themselves. + """ + + lock: threading.Lock = field(default_factory=threading.Lock) + tiers: dict[str, TierCounters] = field( + default_factory=lambda: {t: TierCounters(tier=t) for t in TIERS} + ) + leaves: dict[str, LeafReport] = field(default_factory=dict) + # Ordered list of nodeids in the order they were first seen — lets us + # rebuild the tree deterministically. + nodeid_order: list[str] = field(default_factory=list) + devices: list[DeviceRow] = field(default_factory=list) + run_active: bool = False + exit_code: int | None = None + # nodeid of the currently-running test. Set on `when="setup"` + + # outcome="passed" (body about to execute); cleared on `when="call"` + # (any outcome) or on `when="setup"` + outcome="failed" (no body + # window). Drives the device-table "Status" column so the operator + # can see which test is touching a given device right now. + running_nodeid: str | None = None + # `time.monotonic()` captured when `running_nodeid` was set. Surfaced + # as live-updating elapsed-time ("RUNNING: test_bake_nrf52 (1:23)") so + # an operator staring at a ~3 min `test_00_bake` or a `mesh_formation` + # with a 60 s ceiling has concrete evidence the test isn't stuck. + running_started_at: float | None = None + + +# --------------------------------------------------------------------------- +# Helpers +# --------------------------------------------------------------------------- + + +def _tier_of_nodeid(nodeid: str) -> str: + """Map a pytest nodeid to its tier bucket. Unknown → 'other'. + + `tests/test_00_bake.py::...` is special-cased to the synthetic `bake` + tier — it's a top-level file (no tier subdirectory) so the generic + "second path segment" logic would miss it and route the bake outcomes + into the non-existent `other` bucket. + """ + parts = nodeid.split("/", 2) + if len(parts) >= 2 and parts[0] == "tests": + # Bake file sits at `tests/test_00_bake.py` — dedicated bucket. + if parts[1].startswith("test_00_bake"): + return "bake" + candidate = parts[1] + if candidate in TIERS: + return candidate + return "other" + + +def _file_of_nodeid(nodeid: str) -> str: + """Extract the test file name (e.g. 'test_boards.py') from a nodeid.""" + left = nodeid.split("::", 1)[0] + return left.rsplit("/", 1)[-1] + + +def _testname_of_nodeid(nodeid: str) -> str: + """Extract the 'test_foo[param]' suffix from a nodeid, or the full thing.""" + if "::" in nodeid: + return nodeid.split("::", 1)[1] + return nodeid + + +def _roles_from_nodeid(nodeid: str) -> set[str]: + """Infer which device roles a parametrized test touches. + + Patterns we recognize (from the existing ``conftest.py`` parametrization + in ``pytest_generate_tests``): + + - ``test_foo[nrf52]`` → {"nrf52"} (baked_single) + - ``test_foo[nrf52->esp32s3]`` → {"nrf52", "esp32s3"} (mesh_pair) + + Unparametrized tests (no bracket) return an empty set — the caller + should fall back to "this test involves ALL detected devices" rather + than pretending it touches none. + """ + if "[" not in nodeid or not nodeid.endswith("]"): + return set() + try: + inner = nodeid.rsplit("[", 1)[1][:-1] + except Exception: + return set() + # Split on "->" for directed mesh pairs; otherwise treat as single role. + parts = [p.strip() for p in inner.split("->")] if "->" in inner else [inner.strip()] + return {p for p in parts if p} + + +def _parse_events(path: pathlib.Path) -> Iterator[dict[str, Any]]: + """Yield parsed JSON dicts from a reportlog file, skipping malformed lines. + + Used for smoke-testing the parser against a finished file; the live + worker has its own tail loop. + """ + if not path.is_file(): + return + with path.open("r", encoding="utf-8") as fh: + for line in fh: + line = line.strip() + if not line: + continue + try: + yield json.loads(line) + except json.JSONDecodeError: + continue + + +def _load_run_number(counter_path: pathlib.Path) -> int: + """Bump + persist a monotonic run counter used in the TUI header.""" + try: + n = int(counter_path.read_text().strip()) + except Exception: + n = 0 + n += 1 + try: + counter_path.parent.mkdir(parents=True, exist_ok=True) + counter_path.write_text(str(n)) + except Exception: + # Non-fatal: the counter is cosmetic. + pass + return n + + +def _resolve_seed() -> str: + """Mirror the default-seed resolution from run-tests.sh. + + Operator can override via MESHTASTIC_MCP_SEED. Matches the + per-user/per-host default so repeated invocations land on the same PSK + (makes --assume-baked valid across invocations). + """ + if explicit := os.environ.get("MESHTASTIC_MCP_SEED"): + return explicit + try: + who = os.environ.get("USER") or os.environ.get("LOGNAME") or "anon" + except Exception: + who = "anon" + try: + import socket + + host = socket.gethostname().split(".", 1)[0] + except Exception: + host = "host" + return f"mcp-{who}-{host}" + + +def _format_duration(seconds: float) -> str: + if seconds < 60: + return f"{seconds:5.1f}s" + m, s = divmod(int(seconds), 60) + return f"{m:d}:{s:02d}" + + +# --------------------------------------------------------------------------- +# Textual imports (lazy — only when main() runs, so `_parse_events` can be +# imported by smoke tests without requiring textual installed in every env) +# --------------------------------------------------------------------------- + + +def _import_textual() -> Any: + """Return a namespace carrying every Textual class we use. + + Deferred import keeps `_parse_events` + `_tier_of_nodeid` importable + from tests / smoke scripts without pulling in the UI stack. + """ + import textual + from textual.app import App, ComposeResult + from textual.binding import Binding + from textual.containers import Horizontal, Vertical + from textual.message import Message + from textual.screen import ModalScreen + from textual.widgets import DataTable, Footer, Input, RichLog, Static, Tree + + ns = argparse.Namespace() + ns.App = App + ns.Binding = Binding + ns.ComposeResult = ComposeResult + ns.DataTable = DataTable + ns.Footer = Footer + ns.Horizontal = Horizontal + ns.Input = Input + ns.Message = Message + ns.ModalScreen = ModalScreen + ns.RichLog = RichLog + ns.Static = Static + ns.Tree = Tree + ns.Vertical = Vertical + ns.textual = textual + return ns + + +# --------------------------------------------------------------------------- +# main() — the important scaffolding lives here so that when we bail out +# before entering the Textual event loop (missing terminal, --help, etc.) +# nothing has grabbed the screen yet. +# --------------------------------------------------------------------------- + + +def main(argv: list[str] | None = None) -> int: + """Entry point for `meshtastic-mcp-test-tui`.""" + argv = list(argv if argv is not None else sys.argv[1:]) + + parser = argparse.ArgumentParser( + prog="meshtastic-mcp-test-tui", + description=( + "Live Textual TUI wrapping mcp-server/run-tests.sh. " + "Passes any unrecognized arguments through to pytest." + ), + allow_abbrev=False, + ) + parser.add_argument( + "--no-tui", + action="store_true", + help=( + "Skip the TUI and exec run-tests.sh directly. Useful as a health " + "check that the wrapper argv+env resolution is working." + ), + ) + args, pytest_args = parser.parse_known_args(argv) + + root = _mcp_server_root() + run_tests = root / _RUN_TESTS_RELATIVE + reportlog = root / _REPORTLOG_RELATIVE + fwlog = root / _FWLOG_RELATIVE + flashlog = root / _FLASHLOG_RELATIVE + counter = root / _RUN_COUNTER_RELATIVE + + if not run_tests.is_file(): + print( + f"error: could not locate {_RUN_TESTS_RELATIVE} relative to " + f"{root}. Is this the mcp-server checkout?", + file=sys.stderr, + ) + return 2 + + # Always clear stale log files before launching pytest. The TUI's tail + # workers race pytest file-creation; starting from a known-empty state + # avoids mid-line-decode confusion from the prior run. The fwlog session + # fixture also truncates on its end, and run-tests.sh truncates the + # flashlog — triple-truncate is deliberate (whichever side creates the + # file first, it starts empty). + for p in (reportlog, fwlog, flashlog): + try: + p.unlink(missing_ok=True) + except Exception: + pass + + # Compute + persist the run counter for the header (cosmetic). + run_number = _load_run_number(counter) + seed = _resolve_seed() + # Export the seed so the subprocess inherits the SAME value the TUI + # displays. run-tests.sh computes its own fallback if unset, and we'd + # end up with a header / wrapper-header mismatch if we let that happen. + os.environ.setdefault("MESHTASTIC_MCP_SEED", seed) + # Turn on subprocess-output tee'ing so `pio._run_capturing` writes each + # line of pio / esptool / nrfutil / picotool output to `tests/flash.log` + # as it arrives. The TUI tails that file and routes each line to the + # pytest pane so the operator sees live flash progress during long + # `pio run -t upload` / `esptool erase_flash` operations. run-tests.sh + # also sets this when invoked directly — `setdefault` so the wrapper's + # value wins when present. + os.environ.setdefault("MESHTASTIC_MCP_FLASH_LOG", str(flashlog)) + + # --no-tui: exec run-tests.sh directly. Useful for diagnosing wrapper + # env / argv handling without getting into Textual's alternate screen. + if args.no_tui: + cmd = [str(run_tests), *pytest_args] + os.execv(str(run_tests), cmd) # noqa: S606 — intentional + + # Textual UI import is deferred so `--help` and `--no-tui` do not pay + # the ~40 MB startup cost. + try: + tx = _import_textual() + except ImportError as exc: + print( + f"error: textual is not installed ({exc}). Install with: " + f"pip install -e '.[test]'", + file=sys.stderr, + ) + return 2 + + # Narrow-terminal warning (see plan §8 risk 2). Textual itself degrades, + # but a heads-up helps a first-time user. + term = os.environ.get("TERM", "") + if term in ("", "dumb", "screen") and not os.environ.get("TEXTUAL_NO_TERM_HINT"): + print( + f"[hint] TERM={term!r} may render poorly. Try " + f"`TERM=xterm-256color meshtastic-mcp-test-tui ...` if the layout " + f"looks broken.", + file=sys.stderr, + ) + + app = _build_app( + tx=tx, + root=root, + run_tests=run_tests, + reportlog=reportlog, + fwlog=fwlog, + flashlog=flashlog, + seed=seed, + run_number=run_number, + pytest_args=pytest_args, + ) + + # App.run() returns the subprocess exit code via `app.exit(returncode)`. + return_value = app.run() + if isinstance(return_value, int): + return return_value + return 0 + + +# --------------------------------------------------------------------------- +# Everything below is only reachable once Textual is importable. `tx` is +# the namespace returned by `_import_textual()` so we don't scatter `from +# textual import ...` across the file. +# --------------------------------------------------------------------------- + + +def _build_app( + *, + tx: Any, + root: pathlib.Path, + run_tests: pathlib.Path, + reportlog: pathlib.Path, + fwlog: pathlib.Path, + flashlog: pathlib.Path, + seed: str, + run_number: int, + pytest_args: list[str], +) -> Any: + """Assemble TestTuiApp with its Textual-dependent inner classes. + + Keeping the class definitions inside a factory means `main()` can + short-circuit (--no-tui, terminal-check, argparse error) before we + force Textual's import cost. + """ + + # Helper modules — lazy-imported here so the top-of-file import cost + # only kicks in when main() has decided to run the TUI. + from . import _flashlog as _flashlog_mod + from . import _fwlog as _fwlog_mod + from . import _history as _history_mod + from . import _reproducer as _reproducer_mod + + # ---------------- Messages ---------------- + + class ReportLogEvent(tx.Message): + def __init__(self, event: dict[str, Any]) -> None: + self.event = event + super().__init__() + + class PytestLine(tx.Message): + def __init__(self, source: str, line: str) -> None: + self.source = source # "stdout" | "stderr" + self.line = line + super().__init__() + + class FirmwareLogLine(tx.Message): + def __init__(self, record: dict[str, Any]) -> None: + # {"ts": float, "port": str | None, "line": str} + self.record = record + super().__init__() + + class FlashLogLine(tx.Message): + """Plain-text line from `tests/flash.log` — pio / esptool / nrfutil / + picotool output tee'd by `pio._run_capturing`. Routed to the pytest + pane so the operator sees live flash progress during `test_00_bake` + instead of 3 minutes of pytest-captured silence.""" + + def __init__(self, line: str) -> None: + self.line = line + super().__init__() + + class DeviceSnapshot(tx.Message): + def __init__(self, rows: list[DeviceRow]) -> None: + self.rows = rows + super().__init__() + + class RunFinished(tx.Message): + def __init__(self, returncode: int) -> None: + self.returncode = returncode + super().__init__() + + # ---------------- Workers ---------------- + + class ReportlogWorker(threading.Thread): + """Tail `reportlog.jsonl`, publish each event.""" + + def __init__(self, app: Any, path: pathlib.Path, stop: threading.Event) -> None: + super().__init__(daemon=True, name="reportlog-tail") + self._app = app + self._path = path + self._stop = stop + + def run(self) -> None: + # Wait up to 30 s for pytest to create the file (first call on + # a cold cache can be slow). + wait_deadline = time.monotonic() + 30.0 + while not self._path.is_file(): + if self._stop.is_set() or time.monotonic() > wait_deadline: + return + time.sleep(0.1) + try: + fh = self._path.open("r", encoding="utf-8") + except OSError: + return + try: + while not self._stop.is_set(): + line = fh.readline() + if not line: + time.sleep(0.05) + continue + line = line.strip() + if not line: + continue + try: + event = json.loads(line) + except json.JSONDecodeError: + continue + self._app.post_message(ReportLogEvent(event)) + finally: + fh.close() + + class SubprocessReaderWorker(threading.Thread): + """Read one stream line-by-line and publish PytestLine messages.""" + + def __init__( + self, + app: Any, + stream: Any, + source: str, + stop: threading.Event, + ) -> None: + super().__init__(daemon=True, name=f"subprocess-{source}") + self._app = app + self._stream = stream + self._source = source + self._stop = stop + + def run(self) -> None: + try: + for line in iter(self._stream.readline, ""): + if self._stop.is_set(): + break + self._app.post_message( + PytestLine(source=self._source, line=line.rstrip("\n")) + ) + except Exception: + # stream closed / subprocess died; not fatal. + pass + + class DevicePollerWorker(threading.Thread): + """Poll list_devices() + device_info() at startup and after RunFinished. + + Deliberately NOT polling during the run — `hub_devices` is a + session-scoped fixture holding SerialInterfaces across the whole + session, and device_info() would deadlock on the exclusive port + lock. Header shows "(stale)" during the gap. + """ + + def __init__(self, app: Any, state: State, stop: threading.Event) -> None: + super().__init__(daemon=True, name="device-poller") + self._app = app + self._state = state + self._stop = stop + self._trigger = threading.Event() + + def trigger(self) -> None: + self._trigger.set() + + def run(self) -> None: + # Perform one poll at startup; then wait for explicit triggers. + self._poll_once() + while not self._stop.is_set(): + if self._trigger.wait(timeout=0.5): + self._trigger.clear() + if self._stop.is_set(): + break + with self._state.lock: + active = self._state.run_active + if active: + continue + self._poll_once() + + def _poll_once(self) -> None: + try: + from meshtastic_mcp import devices as devices_mod + from meshtastic_mcp import info as info_mod + except Exception as exc: # pragma: no cover + self._app.post_message( + PytestLine( + source="stderr", line=f"[tui] device import failed: {exc!r}" + ) + ) + return + rows: list[DeviceRow] = [] + try: + raw = devices_mod.list_devices(include_unknown=True) + except Exception as exc: + self._app.post_message( + PytestLine( + source="stderr", line=f"[tui] list_devices failed: {exc!r}" + ) + ) + return + for d in raw: + vid_raw = d.get("vid") or "" + try: + vid_i = ( + int(vid_raw, 16) + if isinstance(vid_raw, str) and vid_raw.startswith("0x") + else int(vid_raw) + ) + except (TypeError, ValueError): + vid_i = 0 + role = None + if vid_i == 0x239A: + role = "nrf52" + elif vid_i in (0x303A, 0x10C4): + role = "esp32s3" + if not role and not d.get("likely_meshtastic"): + continue + row = DeviceRow( + role=role, + port=d.get("port", ""), + vid=str(vid_raw), + pid=str(d.get("pid") or ""), + description=d.get("description", "") or "", + ) + if role: + try: + row.info = info_mod.device_info(port=row.port, timeout_s=6.0) + except Exception as exc: + row.info = {"error": repr(exc)} + rows.append(row) + self._app.post_message(DeviceSnapshot(rows=rows)) + + # ---------------- Modals ---------------- + + class FailureDetailScreen(tx.ModalScreen): + """Show a failed test's longrepr + captured sections.""" + + BINDINGS = [tx.Binding("escape,q", "dismiss", "close")] + + def __init__(self, leaf: LeafReport, report_html: pathlib.Path) -> None: + self._leaf = leaf + self._report_html = report_html + super().__init__() + + def compose(self) -> Any: + yield tx.Static( + f"[bold]{self._leaf.nodeid}[/bold] " + f"outcome=[red]{self._leaf.outcome}[/red] " + f"duration={_format_duration(self._leaf.duration_s)}", + id="failure-detail-header", + ) + log = tx.RichLog( + highlight=False, markup=False, wrap=False, id="failure-detail-log" + ) + yield log + yield tx.Static( + f"[dim]Full HTML report: {self._report_html}[/dim] [esc] close", + id="failure-detail-footer", + ) + + def on_mount(self) -> None: + log = self.query_one("#failure-detail-log", tx.RichLog) + if self._leaf.longrepr: + log.write(self._leaf.longrepr) + log.write("") + for section_name, section_text in self._leaf.sections: + log.write(f"--- {section_name} ---") + log.write(section_text) + log.write("") + if not self._leaf.longrepr and not self._leaf.sections: + log.write("(no longrepr or captured sections in reportlog event)") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + class FilterInputScreen(tx.ModalScreen[str]): + """Prompt the user for a tree filter substring (empty clears).""" + + BINDINGS = [tx.Binding("escape", "cancel", "cancel")] + + def compose(self) -> Any: + yield tx.Static("filter test tree (substring, empty = clear):") + yield tx.Input(placeholder="nodeid substring", id="filter-input") + + def on_input_submitted(self, event: Any) -> None: + self.dismiss(event.value.strip()) + + def action_cancel(self) -> None: + self.dismiss(None) + + class CoverageModal(tx.ModalScreen): + """Read `tests/tool_coverage.json` (written by `tests/tool_coverage.py` + at `pytest_sessionfinish`) and render a two-column summary of which + MCP tools got exercised by the run. `(no coverage data yet)` while + the run is in flight.""" + + BINDINGS = [tx.Binding("escape,q,c", "dismiss", "close")] + + def __init__(self, coverage_path: pathlib.Path) -> None: + self._path = coverage_path + super().__init__() + + def compose(self) -> Any: + yield tx.Static("[bold]MCP tool coverage[/bold]", id="coverage-header") + yield tx.RichLog( + highlight=False, markup=True, wrap=False, id="coverage-log" + ) + yield tx.Static( + f"[dim]{self._path}[/dim] [esc] close", + id="coverage-footer", + ) + + def on_mount(self) -> None: + log = self.query_one("#coverage-log", tx.RichLog) + if not self._path.is_file(): + log.write("(no coverage data — tool_coverage.json not written yet)") + log.write("") + log.write("Coverage is emitted at pytest_sessionfinish; this") + log.write("file appears after the suite completes.") + return + try: + data = json.loads(self._path.read_text(encoding="utf-8")) + except Exception as exc: + log.write(f"[red]failed to read {self._path}:[/red] {exc!r}") + return + calls = data.get("calls") or {} + if not calls: + log.write("(tool_coverage.json present but no calls recorded)") + return + exercised = sorted( + ((n, c) for n, c in calls.items() if c > 0), key=lambda x: -x[1] + ) + unexercised = sorted(n for n, c in calls.items() if c == 0) + log.write(f"[b]{len(exercised)} / {len(calls)} MCP tools exercised[/b]") + log.write("") + log.write("[green]exercised[/green] (count):") + for name, count in exercised: + log.write(f" {count:>4} {name}") + if unexercised: + log.write("") + log.write("[dim]not exercised:[/dim]") + for name in unexercised: + log.write(f" {name}") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + class ReproducerResultModal(tx.ModalScreen): + """Show the exported reproducer tarball path with a short instruction.""" + + BINDINGS = [tx.Binding("escape,q,enter", "dismiss", "close")] + + def __init__( + self, archive_path: pathlib.Path, error: str | None = None + ) -> None: + self._archive = archive_path + self._error = error + super().__init__() + + def compose(self) -> Any: + if self._error: + yield tx.Static(f"[red]Reproducer export failed:[/red] {self._error}") + else: + yield tx.Static("[bold green]Reproducer bundle written[/bold green]") + yield tx.Static(f"[cyan]{self._archive}[/cyan]") + yield tx.Static("") + yield tx.Static( + "Contains: README.md, test_report.json, fwlog.jsonl (time-filtered)," + ) + yield tx.Static( + "devices.json, env.json. Attach to an issue / paste the path in chat." + ) + yield tx.Static("") + yield tx.Static("[dim][esc] close[/dim]") + + def action_dismiss(self, _result: Any = None) -> None: + self.dismiss() + + # ---------------- App ---------------- + + class TestTuiApp(tx.App): + CSS = """ + Screen { layout: vertical; } + #header-bar { height: 2; padding: 0 1; background: $panel; } + #tier-table { height: auto; max-height: 11; } + #body { height: 1fr; } + #tree-pane { width: 50%; border-right: solid $primary-background; } + #right-pane { width: 50%; layout: vertical; } + #pytest-pane { height: 50%; border-bottom: solid $primary-background; } + #fwlog-header { height: 1; padding: 0 1; background: $panel; } + #fwlog-pane { height: 1fr; } + Tree { height: 100%; } + RichLog { height: 100%; } + #device-table { height: auto; max-height: 6; } + """ + + TITLE = "mcp-server test runner" + + BINDINGS = [ + tx.Binding("r", "rerun_focused", "re-run focused"), + tx.Binding("f", "filter_tree", "filter"), + tx.Binding("d", "failure_detail", "failure detail"), + tx.Binding("g", "open_html_report", "open report.html"), + tx.Binding("x", "export_reproducer", "export reproducer"), + tx.Binding("c", "coverage_panel", "coverage"), + tx.Binding("l", "cycle_fwlog_filter", "fw log filter"), + tx.Binding("q,ctrl+c", "quit_app", "quit"), + ] + + def __init__(self) -> None: + super().__init__() + self._state = State() + self._root = root + self._run_tests = run_tests + self._reportlog = reportlog + self._fwlog = fwlog + self._flashlog = flashlog + self._report_html = root / _REPORT_HTML_RELATIVE + self._tool_coverage = root / _TOOL_COVERAGE_RELATIVE + self._repro_dir = root / _REPRODUCERS_RELATIVE + self._seed = seed + self._run_number = run_number + self._pytest_args = pytest_args + self._start_time = time.monotonic() + self._proc: subprocess.Popen[str] | None = None + self._stop = threading.Event() + self._reportlog_worker: ReportlogWorker | None = None + self._stdout_worker: SubprocessReaderWorker | None = None + self._stderr_worker: SubprocessReaderWorker | None = None + self._device_worker: DevicePollerWorker | None = None + self._fwlog_worker: _fwlog_mod.FirmwareLogTailer | None = None + self._flashlog_worker: _flashlog_mod.FlashLogTailer | None = None + self._tree_filter: str = "" + self._sigint_count = 0 + # Firmware-log port filter: None = all, else exact port match. + self._fwlog_filter: str | None = None + # Ordered set of distinct ports we've seen firmware log lines + # from — the `l` key cycles through these. + self._fwlog_ports: list[str] = [] + # Cross-run history. + self._history_store = _history_mod.HistoryStore( + root / _HISTORY_RELATIVE, keep_last=40 + ) + self._history_cache = self._history_store.read_recent() + + # -------- composition / mount -------- + + def compose(self) -> Any: + yield tx.Static(self._header_text(), id="header-bar") + tier_table = tx.DataTable(id="tier-table", show_cursor=False) + yield tier_table + with tx.Horizontal(id="body"): + with tx.Vertical(id="tree-pane"): + yield tx.Tree("tests", id="test-tree") + with tx.Vertical(id="right-pane"): + with tx.Vertical(id="pytest-pane"): + yield tx.RichLog( + id="pytest-log", + highlight=False, + markup=False, + wrap=False, + max_lines=5000, + ) + yield tx.Static(self._fwlog_header_text(), id="fwlog-header") + with tx.Vertical(id="fwlog-pane"): + yield tx.RichLog( + id="fwlog-log", + highlight=False, + markup=False, + # `wrap=True` so long firmware log lines (some + # hit ~200 chars — full packet hex dumps plus + # source tags) don't get truncated at the + # right edge. The right pane is ~50% of the + # terminal so even a wide terminal has a + # ~90-char cap; plain truncation dropped the + # uptime counter or packet id off the end. + wrap=True, + max_lines=5000, + ) + yield tx.DataTable(id="device-table", show_cursor=False) + yield tx.Footer() + + def _fwlog_header_text(self) -> str: + filt = self._fwlog_filter or "(all ports)" + return f"firmware log filter: [b]{filt}[/b] [l] cycle" + + def on_mount(self) -> None: + # Tier-counters table. `add_column` (singular) lets us pick + # the key explicitly — `add_columns` (plural) in textual 8.x + # returns auto-generated keys that are tedious to track + # separately, and update_cell(column_key=

)` — region, preset, channel_num, tx_power, hop_limit. - Optionally, if the device seems unhappy (fails to connect, `num_nodes==1` when ≥2 are plugged in, missing firmware*version), open a short firmware log window: `mcp__meshtastic__serial_open(port=

, env=)`, wait 3s, `serial_read(session_id=, max_lines=100)`, `serial_close(session_id=)`. The env should be inferred from the VID map in `mcp-server/run-tests.sh` (nrf52 → rak4631, esp32s3 → heltec-v3) unless `MESHTASTIC_MCP_ENV*` is set. -4. **Render per-device report** as: +4. **Hub health** (call once, not per-device): `mcp__meshtastic__uhubctl_list()` — enumerates every USB hub the host can see. Note which hubs advertise `ppps=true` and which hub hosts each Meshtastic device (cross-reference by VID). Flag it in the report if: + - No hub advertises PPPS → `tests/recovery/` can't run on this setup; hard-recovery via `uhubctl_cycle` isn't available. + - A Meshtastic device is on a non-PPPS hub → note it; operator may want to move the device to a PPPS hub to unlock auto-recovery. + - `uhubctl_list` raises `ConfigError: uhubctl not found` → just say `uhubctl not installed` in the report; don't treat as a fault. + +5. **Render per-device report** as: ```text [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 @@ -33,20 +38,22 @@ Call the meshtastic MCP tool bundle and format a structured health report for on tx_power : 30 dBm, hop_limit=3 peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) primary ch : McpTest + hub : 1-1.3 port 2 (PPPS, uhubctl-controllable) firmware : no panics in last 3s; NodeInfoModule emitted 2 broadcasts ``` - Keep it scannable. If a field is missing or abnormal (no pubkey for a known peer, region=UNSET, num_nodes inconsistent with the hub), flag it inline with a short `⚠︎ `. + Keep it scannable. If a field is missing or abnormal (no pubkey for a known peer, region=UNSET, num_nodes inconsistent with the hub, device on non-PPPS hub), flag it inline with a short `⚠︎ `. -5. **Cross-device correlation** (only when >1 device is inspected): +6. **Cross-device correlation** (only when >1 device is inspected): - Do both sides see each other in `nodesByNum`? If one does and the other doesn't, that's asymmetric NodeInfo — flag it. - Do the LoRa configs match? (region, channel_num, modem_preset should all agree; mismatch = no mesh) - Do the primary channel NAMES match? Mismatch = different PSK = no decode. -6. **Suggest next actions only for specific, recognisable failure modes**: +7. **Suggest next actions only for specific, recognisable failure modes**: - Stale PKI pubkey one-way → "run `/test tests/mesh/test_direct_with_ack.py` — the retry + nodeinfo-ping heals this in the test path." - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." - - Device unreachable → point at touch_1200bps + the CP2102-wedged-driver note in run-tests.sh. + - Device unreachable, reachable via DFU → `touch_1200bps(port=...)` + `pio_flash`. If not even DFU responds AND the device is on a PPPS hub, escalate to `uhubctl_cycle(role=..., confirm=True)`. + - CP2102-wedged-driver on macOS → see the note in `run-tests.sh`. ## What NOT to do diff --git a/.claude/commands/repro.md b/.claude/commands/repro.md index 52dcf222b..c5f466ce6 100644 --- a/.claude/commands/repro.md +++ b/.claude/commands/repro.md @@ -44,7 +44,8 @@ Re-run a single pytest node ID N times in isolation, track pass rate, and surfac - **LoRa airtime collision** → pass rate improves with fewer concurrent transmitters; propose a `time.sleep` gap or retry bump in the test body. - **PKI key staleness** → fails on first attempt, passes after self-heal; existing retry loop in `test_direct_with_ack.py` handles this. - **NodeInfo cooldown** → `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs `broadcast_nodeinfo_ping()` warmup. - - **Hardware-specific** (one direction fails, other passes; one device's firmware is older; driver wedged) → specific recovery pointer. + - **Hardware-specific** (one direction fails, other passes; one device's firmware is older; driver wedged) → specific recovery pointer. For a device that's wedged past `touch_1200bps`, the next escalation is `uhubctl_cycle(role=..., confirm=True)` to hard-power-cycle its hub port (requires `uhubctl` installed). + - **Device went dark mid-run** → fails from some attempt onward, never recovers, firmware log stops arriving. Almost always hardware: a Guru crash + frozen CDC. Hard-power-cycle via `uhubctl_cycle(role=..., confirm=True)` before the next iteration; if that also fails, escalate to replug. - **Genuinely unknown** → say so; don't invent a root cause. 7. **Report back** with: diff --git a/.claude/commands/test.md b/.claude/commands/test.md index 986ee1f31..46a753749 100644 --- a/.claude/commands/test.md +++ b/.claude/commands/test.md @@ -19,16 +19,21 @@ Run `mcp-server/run-tests.sh` and make sense of the output so the operator doesn 2. **Read the pre-flight header.** First ~6 lines print the detected hub (role → port → env). If that line reads `detected hub : (none)`, the wrapper will narrow to `tests/unit` only — say so explicitly in your summary so the operator knows hardware tiers were skipped. -3. **On pass**: one-line summary of the form `N passed, M skipped in `. Don't enumerate the 52 test names — the user can read those. Do mention if any test was SKIPPED for a NON-placeholder reason (e.g. "role not present on hub" is worth flagging). +3. **On pass**: one-line summary of the form `N passed, M skipped in `. Don't enumerate the test names — the user can read those. Do mention any SKIPPED tests and name the cause: + - `"role not present on hub"` → device unplugged; operator knows to reconnect. + - `"firmware not baked with USERPREFS_UI_TEST_LOG"` → tests/ui skipped because the macro isn't in firmware yet; suggest `--force-bake`. + - `"uhubctl not installed"` → tests/recovery + peer-offline skipped; suggest `brew install uhubctl` / `apt install uhubctl`. + - `"no PPPS-capable hubs detected"` → tests/recovery skipped because the hub doesn't support per-port power; the tier will never run on that setup. + - `"opencv-python-headless is not installed"` → tests/ui auto-deselected by run-tests.sh; suggest `pip install -e 'mcp-server/.[ui]'`. -4. **On failure**: for every FAILED test, open `mcp-server/tests/report.html` and extract the `Meshtastic debug` section for that test. pytest-html embeds the firmware log stream + device state dump there; the 200-line firmware log tail is usually enough to explain the failure. Summarise: which test, one-line assertion message, the firmware log lines that matter (things like `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`). +4. **On failure**: for every FAILED test, open `mcp-server/tests/report.html` and extract the `Meshtastic debug` section for that test. pytest-html embeds the firmware log stream + device state dump there; the 200-line firmware log tail is usually enough to explain the failure. Summarise: which test, one-line assertion message, the firmware log lines that matter (things like `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`). For UI-tier failures also glance at `mcp-server/tests/ui_captures///transcript.md` — it records each step's frame + OCR. 5. **Classify the failure** as one of: - **Transient/flake**: LoRa collision, timing-sensitive assertion, first-attempt NAK + successful retry pattern. Propose `/repro ` to confirm. - - **Environmental**: device unreachable, port busy, CP2102 driver wedged. Suggest the specific recovery (replug USB, `touch_1200bps`, check `git status userPrefs.jsonc`). + - **Environmental**: device unreachable, port busy, CP2102 driver wedged. Suggest the specific recovery in escalation order: (a) replug USB, (b) `touch_1200bps(port=...)` + `pio_flash` for nRF52 DFU, (c) `uhubctl_cycle(role="nrf52", confirm=True)` when a device is fully wedged past DFU (needs `uhubctl` installed — `baked_single`'s auto-recovery hook does this once automatically). Also check `git status userPrefs.jsonc`. - **Regression**: same assertion fails repeatedly, firmware log shows a new/unusual error. Surface the diff between expected and observed, identify the module likely responsible. -6. **Never run destructive recovery automatically.** If a failure looks like it needs a reflash, factory*reset, or USB replug, \_describe what to do* — don't execute. The operator decides. +6. **Never run destructive recovery automatically.** If a failure looks like it needs a reflash, factory*reset, `uhubctl_cycle`, or USB replug, \_describe what to do* — don't execute. The operator decides. ## Arguments handling diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d12244229..7c71a5014 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -474,7 +474,7 @@ The repo registers the server via `.mcp.json` at the repo root — Claude Code p **One MCP call per port at a time.** `SerialInterface` holds an exclusive OS-level lock on the serial port for its lifetime. If a `serial_*` session is open on `/dev/cu.usbmodem101`, calling `device_info` on the same port will fail fast pointing at the active session. Sequence calls: open → read/mutate → close, then next device. Never parallelize tool calls on the same port. -### MCP tool surface (~32 tools) +### MCP tool surface (43 tools) Grouped by purpose. Full argument shapes in `mcp-server/README.md`; a few high-value signatures are called out here. @@ -482,11 +482,13 @@ Grouped by purpose. Full argument shapes in `mcp-server/README.md`; a few high-v - **Build & flash**: `build`, `clean`, `pio_flash`, `erase_and_flash` (ESP32 only), `update_flash` (ESP32 OTA), `touch_1200bps` - **Serial sessions** (long-running, 10k-line ring buffer): `serial_open`, `serial_read`, `serial_list`, `serial_close` - **Device reads**: `device_info`, `list_nodes` -- **Device writes** (all require `confirm=True`): `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `reboot`, `shutdown`, `factory_reset`, `set_debug_log_api` +- **Device writes**: `set_owner`, `get_config`, `set_config`, `get_channel_url`, `set_channel_url`, `send_text`, `send_input_event` (inject a button/key press via the firmware's InputBroker), `set_debug_log_api`; destructive/power-state writes require `confirm=True`: `reboot`, `shutdown`, `factory_reset` - **userPrefs admin** (build-time constants, not runtime config): `userprefs_get`, `userprefs_set`, `userprefs_reset`, `userprefs_manifest`, `userprefs_testing_profile` - **Vendor escape hatches**: `esptool_chip_info`, `esptool_erase_flash`, `esptool_raw`, `nrfutil_dfu`, `nrfutil_raw`, `picotool_info`, `picotool_load`, `picotool_raw` +- **USB power control** (via `uhubctl`, per-port PPPS toggle): `uhubctl_list` (read-only), `uhubctl_power(action='on'|'off', confirm=True)`, `uhubctl_cycle(delay_s, confirm=True)`. Target by raw `(location, port)` or by `role` (`"nrf52"`, `"esp32s3"`); role lookup checks `MESHTASTIC_UHUBCTL_LOCATION_` + `_PORT_` env vars first, falls back to VID auto-detection. +- **Observability** (UI tier + operator ad-hoc): `capture_screen(role, ocr=True)` — grabs a USB-webcam frame of the device OLED and optionally OCRs it. Requires `mcp-server[ui]` extras (`opencv-python-headless`, `easyocr`) and `MESHTASTIC_UI_CAMERA_DEVICE_` env var; falls through to a 1×1 black PNG `NullBackend` when unconfigured. -`confirm=True` is a tool-level gate on top of whatever permission prompt your MCP host shows. **Don't bypass it** by asking the host to auto-approve — it exists specifically because MCP hosts sometimes remember "always allow this tool" and that's dangerous for `factory_reset` and `erase_and_flash`. +`confirm=True` is a tool-level gate on top of whatever permission prompt your MCP host shows. **Don't bypass it** by asking the host to auto-approve — it exists specifically because MCP hosts sometimes remember "always allow this tool" and that's dangerous for `factory_reset`, `erase_and_flash`, `uhubctl_power(action='off')`, and `uhubctl_cycle`. ### Hardware test suite (`mcp-server/run-tests.sh`) @@ -494,14 +496,16 @@ The wrapper auto-detects connected devices (VID → role map: `0x239A` → `nrf5 Suite tiers (collected + run in this order via `pytest_collection_modifyitems`): -1. `tests/unit/` — pure Python (boards parse, pio wrapper, userPrefs parse, testing profile). No hardware. +1. `tests/unit/` — pure Python (boards parse, pio wrapper, userPrefs parse, testing profile, uhubctl parser). No hardware. 2. `tests/test_00_bake.py` — flashes each detected device with current `userPrefs.jsonc` merged with the session's test profile. Has its own skip-if-already-baked check comparing region + primary channel to the session profile; skips cheaply on warm devices. -3. `tests/mesh/` — multi-device mesh: bidirectional send, broadcast delivery, direct-with-ACK, mesh formation within 60s. Parametrized `[nrf52->esp32s3]` and `[esp32s3->nrf52]`. +3. `tests/mesh/` — multi-device mesh: bidirectional send, broadcast delivery, direct-with-ACK, mesh formation within 60s. Parametrized `[nrf52->esp32s3]` and `[esp32s3->nrf52]`. Includes `test_peer_offline_recovery` which uses uhubctl to physically power off one peer mid-conversation (requires uhubctl; skips without). 4. `tests/telemetry/` — `DEVICE_METRICS_APP` broadcast timing. 5. `tests/monitor/` — boot-log panic check. -6. `tests/fleet/` — PSK seed session isolation. -7. `tests/admin/` — channel URL roundtrip, owner persistence across reboot. -8. `tests/provisioning/` — region + modem + slot bake, admin key presence, `UNSET` region blocks TX, userPrefs survive factory reset. +6. `tests/recovery/` — `uhubctl` power-cycle round-trip + NVS persistence across hard reset. Requires `uhubctl` installed and a PPPS-capable hub; entire tier auto-skips otherwise. +7. `tests/ui/` — input-broker-driven screen navigation with camera + OCR evidence. +8. `tests/fleet/` — PSK seed session isolation. +9. `tests/admin/` — channel URL roundtrip, owner persistence across reboot. +10. `tests/provisioning/` — region + modem + slot bake, admin key presence, `UNSET` region blocks TX, userPrefs survive factory reset. Invocation patterns: @@ -586,15 +590,19 @@ If you're modifying `StreamAPI`, `PhoneAPI`, `NodeInfoModule`, or `userPrefs` fl ### Recovery playbooks -| Symptom | First check | Fix | -| ---------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `userPrefs.jsonc` dirty after test run | `git status --porcelain userPrefs.jsonc` | If non-empty, re-run `./mcp-server/run-tests.sh` once — the pre-flight self-heal restores from sidecar. If still dirty, `git checkout userPrefs.jsonc`. | -| Port busy / wedged CP2102 on macOS | `lsof /dev/cu.usbserial-0001` | Kill the holder. USB replug if the kernel still reports busy. Often a stale `pio device monitor` or zombie `meshtastic_mcp` process. | -| nRF52 appears unresponsive | `list_devices` shows VID `0x239A` but `device_info` times out | `touch_1200bps(port=...)` drops it into the DFU bootloader → `pio_flash` re-installs. | -| Multiple MCP server processes | `ps aux \| grep meshtastic_mcp` shows >1 | Kill all but the one your MCP host spawned. Zombies hold ports and break tests. | -| Mesh formation fails, one side sees peer but other doesn't | `/diagnose` (or `list_nodes` on both sides) | Asymmetric NodeInfo. `test_direct_with_ack` has a heal path; `/repro` it a few times. If persistent, both devices' clocks may be out of sync with their NodeInfo cooldown. | -| "role not present on hub" in skip reasons | `list_devices` | Expected if a device is unplugged. Reconnect before re-running the tier. | -| Tests fail only on first attempt then pass on rerun | — | State leak from a prior session. Run with `--force-bake` to reset to a known state. | +| Symptom | First check | Fix | +| --------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `userPrefs.jsonc` dirty after test run | `git status --porcelain userPrefs.jsonc` | If non-empty, re-run `./mcp-server/run-tests.sh` once — the pre-flight self-heal restores from sidecar. If still dirty, `git checkout userPrefs.jsonc`. | +| Port busy / wedged CP2102 on macOS | `lsof /dev/cu.usbserial-0001` | Kill the holder. USB replug if the kernel still reports busy. Often a stale `pio device monitor` or zombie `meshtastic_mcp` process. | +| nRF52 appears unresponsive | `list_devices` shows VID `0x239A` but `device_info` times out | `touch_1200bps(port=...)` drops it into the DFU bootloader → `pio_flash` re-installs. | +| Device fully wedged (Guru Meditation, frozen CDC, no DFU) | `list_devices` shows the VID but every admin call times out | `uhubctl_cycle(role="nrf52", confirm=True)` hard-power-cycles the port via USB hub PPPS. `baked_single`'s auto-recovery hook does this once automatically if uhubctl is installed. Falls back to physical replug if no PPPS hub. | +| Multiple MCP server processes | `ps aux \| grep meshtastic_mcp` shows >1 | Kill all but the one your MCP host spawned. Zombies hold ports and break tests. | +| Mesh formation fails, one side sees peer but other doesn't | `/diagnose` (or `list_nodes` on both sides) | Asymmetric NodeInfo. `test_direct_with_ack` has a heal path; `/repro` it a few times. If persistent, both devices' clocks may be out of sync with their NodeInfo cooldown. | +| "role not present on hub" in skip reasons | `list_devices` | Expected if a device is unplugged. Reconnect before re-running the tier. | +| Entire `tests/recovery/` tier skipped | `command -v uhubctl` | Expected if `uhubctl` isn't on PATH. Install via `brew install uhubctl` (macOS) or `apt install uhubctl` (Debian/Ubuntu). Also skips if no hub advertises PPPS. | +| Entire `tests/ui/` tier skipped ("firmware not baked with USERPREFS_UI_TEST_LOG") | reportlog.jsonl for the skip reason | Re-run with `--force-bake` so the UI-log macro gets compiled into the fresh firmware. First run after the Round-3 landing always re-bakes. | +| `tests/ui/` runs but captures are all 1×1 black PNGs | `MESHTASTIC_UI_CAMERA_DEVICE_ESP32S3` | Env var not set → `NullBackend`. Point a USB webcam at the heltec-v3 OLED and set the device index; `.venv/bin/python -c "import cv2; [print(i, cv2.VideoCapture(i).read()[0]) for i in range(5)]"` discovers it. | +| Tests fail only on first attempt then pass on rerun | — | State leak from a prior session. Run with `--force-bake` to reset to a known state. | ### Never do these without asking diff --git a/.github/prompts/mcp-diagnose.prompt.md b/.github/prompts/mcp-diagnose.prompt.md index c86826030..1049858f8 100644 --- a/.github/prompts/mcp-diagnose.prompt.md +++ b/.github/prompts/mcp-diagnose.prompt.md @@ -26,7 +26,12 @@ This prompt assumes the meshtastic MCP server is registered with your VS Code Co - `get_config(section="lora", port=

)` → region, preset, channel_num, tx_power, hop_limit - If anything looks off (can't connect, `num_nodes` wrong, missing `firmware_version`), open a short firmware-log window: `serial_open(port=

, env=)`, wait 3 seconds, `serial_read(session_id, max_lines=100)`, `serial_close(session_id)`. Infer env from VID (0x239a → `rak4631`, 0x303a/0x10c4 → `heltec-v3`) unless an `MESHTASTIC_MCP_ENV_` env var overrides it. -4. **Render per-device report** as a compact block: +4. **Hub health** (call once, not per-device): `uhubctl_list()` — enumerates every USB hub the host sees. Cross-reference each Meshtastic device's VID to find which hub + port it's on. Flag in the report if: + - No hub advertises `ppps=true` → `tests/recovery/` can't run; hard-recovery via `uhubctl_cycle` isn't available. + - A Meshtastic device is on a non-PPPS hub → note it; moving to a PPPS hub unlocks auto-recovery. + - `uhubctl_list` raises `ConfigError: uhubctl not found` → report as "uhubctl not installed"; don't treat as a device fault. + +5. **Render per-device report** as a compact block: ```text [nrf52 @ /dev/cu.usbmodem1101] fw=2.7.23.bce2825, hw=RAK4631 @@ -35,20 +40,22 @@ This prompt assumes the meshtastic MCP server is registered with your VS Code Co tx_power : 30 dBm, hop_limit=3 peers : 1 (esp32s3 0x433c2428, pubkey ✓, SNR 6.0 / RSSI -24 dBm) primary ch : McpTest + hub : 1-1.3 port 2 (PPPS, uhubctl-controllable) firmware : no panics in last 3s ``` - Flag abnormalities inline with `⚠︎ ` — missing pubkey on a known peer, region UNSET, mismatched channel name, etc. + Flag abnormalities inline with `⚠︎ ` — missing pubkey on a known peer, region UNSET, mismatched channel name, device on non-PPPS hub, etc. -5. **Cross-device correlation** (when >1 device selected): +6. **Cross-device correlation** (when >1 device selected): - Do both see each other in `nodesByNum`? - Do `region`, `channel_num`, `modem_preset` match across devices? - Do the primary channel names match? (Different name → different PSK → no decode.) -6. **Suggest next steps only for recognizable failure modes**, never speculatively: +7. **Suggest next steps only for recognizable failure modes**, never speculatively: - Stale PKI one-way → "`/mcp-test tests/mesh/test_direct_with_ack.py` — the test's retry+nodeinfo-ping heals this." - Region mismatch → "re-bake one side via `./mcp-server/run-tests.sh --force-bake`." - - Device unreachable → refer operator to the touch_1200bps + CP2102-wedged-driver notes in `run-tests.sh`. + - Device unreachable, DFU reachable → `touch_1200bps(port=...)` + `pio_flash`. If not even DFU responds and the device is on a PPPS hub, escalate to `uhubctl_cycle(role=..., confirm=True)`. + - CP2102-wedged-driver on macOS → see `run-tests.sh` notes. ## Hard constraints diff --git a/.github/prompts/mcp-repro.prompt.md b/.github/prompts/mcp-repro.prompt.md index be2963c33..3a7c5c3de 100644 --- a/.github/prompts/mcp-repro.prompt.md +++ b/.github/prompts/mcp-repro.prompt.md @@ -46,7 +46,8 @@ Equivalent of `.claude/commands/repro.md`. Use when the operator says "that one - **LoRa airtime collision** — pass rate improves with fewer concurrent transmitters. Suggest a `time.sleep` gap or retry bump in the test body. - **PKI key staleness** — first attempt fails, subsequent ones pass; existing retry-loop pattern in `test_direct_with_ack.py` is the fix. - **NodeInfo cooldown** — `Skip send NodeInfo since we sent it <600s ago` in fail-only logs; needs a `broadcast_nodeinfo_ping()` warmup. - - **Hardware-specific** — one direction consistently fails, firmware versions differ, CP2102 driver wedged, etc. + - **Hardware-specific** — one direction consistently fails, firmware versions differ, CP2102 driver wedged, etc. For a device wedged past `touch_1200bps`, recommend `uhubctl_cycle(role=..., confirm=True)` to hard-power-cycle its hub port (requires `uhubctl` installed). + - **Device went dark mid-run** — fails from some iteration onward and never recovers; firmware log stops arriving. Almost always a Guru crash with frozen CDC. Recommend `uhubctl_cycle` before the next iteration; escalate to replug if that also fails. - **Unknown** — say so. Don't invent a root cause. 7. **Report back** with: diff --git a/.github/prompts/mcp-test.prompt.md b/.github/prompts/mcp-test.prompt.md index 092ad3d85..148569e83 100644 --- a/.github/prompts/mcp-test.prompt.md +++ b/.github/prompts/mcp-test.prompt.md @@ -21,19 +21,25 @@ Equivalent of the Claude Code `/test` slash command in `.claude/commands/test.md 2. **Read the pre-flight header** (first few lines of wrapper output). The `detected hub :` line lists role → port → env mappings. If it reads `(none)`, the wrapper narrowed to `tests/unit` only — call that out explicitly so the operator knows hardware tiers were skipped. -3. **On pass**: one-line summary like `N passed, M skipped in `. Don't enumerate test names. DO mention any non-placeholder SKIPs (things like "role not present on hub") because they indicate missing hardware or setup issues. +3. **On pass**: one-line summary like `N passed, M skipped in `. Don't enumerate test names. DO mention any non-placeholder SKIPs and name the cause: + - `"role not present on hub"` → device unplugged; operator should reconnect. + - `"firmware not baked with USERPREFS_UI_TEST_LOG"` → tests/ui skipped; the UI-log compile macro isn't in the baked firmware. Suggest `--force-bake`. + - `"uhubctl not installed"` → tests/recovery + `test_peer_offline_recovery` skipped. Suggest `brew install uhubctl` / `apt install uhubctl`. + - `"no PPPS-capable hubs detected"` → tests/recovery skipped because the attached hub doesn't support per-port power switching; won't run on that setup. + - `"opencv-python-headless is not installed"` → tests/ui auto-deselected by `run-tests.sh`. Suggest `pip install -e 'mcp-server/.[ui]'`. 4. **On failure**: open `mcp-server/tests/report.html` (pytest-html output, self-contained) and extract the `Meshtastic debug` section for each failed test. That section includes a firmware log stream (last 200 lines) and device state dump. For each failure, summarise: - test name - one-line assertion message - the specific firmware log lines that explain why (look for `PKI_UNKNOWN_PUBKEY`, `Skip send NodeInfo`, `Error=`, `Guru Meditation`, `assertion failed`, `No suitable channel`) + - for UI-tier failures also check `mcp-server/tests/ui_captures///transcript.md` (per-step frame + OCR) 5. **Classify each failure** as one of: - **Transient flake** — LoRa collision, first-attempt NAK with self-heal pattern, timing-sensitive assertion. Suggest `/mcp-repro ` to confirm. - - **Environmental** — device unreachable, port busy, CP2102 driver wedged on macOS. Suggest specific recovery (USB replug, `touch_1200bps`, `git status userPrefs.jsonc`). + - **Environmental** — device unreachable, port busy, CP2102 driver wedged on macOS. Suggest recovery in escalation order: (a) replug USB, (b) `touch_1200bps` + `pio_flash` for nRF52 DFU, (c) `uhubctl_cycle(role=..., confirm=True)` for a device wedged past DFU (needs `uhubctl` installed; `baked_single` does this once automatically when available). Also check `git status userPrefs.jsonc`. - **Regression** — same assertion fails repeatedly on re-runs, firmware log shows novel errors. Identify the firmware module likely responsible. -6. **Do NOT run destructive recovery automatically**. If a failure looks like it needs a reflash, factory*reset, or replug — \_describe the steps* and let the operator decide. Never burn airtime or flash cycles without approval. +6. **Do NOT run destructive recovery automatically**. If a failure looks like it needs a reflash, factory*reset, `uhubctl_cycle`, or replug — \_describe the steps* and let the operator decide. Never burn airtime or flash cycles without approval. ## Arguments convention diff --git a/AGENTS.md b/AGENTS.md index cd043c087..b3fa1970c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -89,25 +89,42 @@ Sequence these; don't parallelize on the same port. ## Where to look -| Path | What's there | -| --------------------------------- | ---------------------------------------------------------------------------------------------------- | -| `src/` | Firmware C++ source (`mesh/`, `modules/`, `platform/`, `graphics/`, `gps/`, `motion/`, `mqtt/`, …) | -| `src/mesh/` | Core: NodeDB, Router, Channels, CryptoEngine, radio interfaces, StreamAPI, PhoneAPI | -| `src/modules/` | Feature modules; `Telemetry/Sensor/` has 50+ I2C sensor drivers | -| `variants/` | 200+ hardware variant definitions (`variant.h` + `platformio.ini` per board) | -| `protobufs/` | `.proto` definitions; regenerate with `bin/regen-protos.sh` | -| `test/` | Firmware unit tests (12 suites; `pio test -e native`) | -| `mcp-server/` | Python MCP server + pytest hardware integration tests | -| `mcp-server/tests/` | Tiered pytest suite: `unit/`, `mesh/`, `telemetry/`, `monitor/`, `fleet/`, `admin/`, `provisioning/` | -| `.claude/commands/` | Claude Code slash command bodies | -| `.github/prompts/` | Copilot prompt bodies (mirrors of the Claude Code ones) | -| `.github/copilot-instructions.md` | **Primary agent instructions — read this** | -| `.github/workflows/` | CI pipelines | -| `.mcp.json` | MCP server registration for Claude Code | +| Path | What's there | +| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | +| `src/` | Firmware C++ source (`mesh/`, `modules/`, `platform/`, `graphics/`, `gps/`, `motion/`, `mqtt/`, …) | +| `src/mesh/` | Core: NodeDB, Router, Channels, CryptoEngine, radio interfaces, StreamAPI, PhoneAPI | +| `src/modules/` | Feature modules; `Telemetry/Sensor/` has 50+ I2C sensor drivers | +| `variants/` | 200+ hardware variant definitions (`variant.h` + `platformio.ini` per board) | +| `protobufs/` | `.proto` definitions; regenerate with `bin/regen-protos.sh` | +| `test/` | Firmware unit tests (12 suites; `pio test -e native`) | +| `mcp-server/` | Python MCP server + pytest hardware integration tests | +| `mcp-server/tests/` | Tiered pytest suite: `unit/`, `mesh/`, `telemetry/`, `monitor/`, `recovery/`, `ui/`, `fleet/`, `admin/`, `provisioning/` | +| `.claude/commands/` | Claude Code slash command bodies | +| `.github/prompts/` | Copilot prompt bodies (mirrors of the Claude Code ones) | +| `.github/copilot-instructions.md` | **Primary agent instructions — read this** | +| `.github/workflows/` | CI pipelines | +| `.mcp.json` | MCP server registration for Claude Code | ## Recovery one-liners - **`userPrefs.jsonc` dirty after a test run?** Re-run `./mcp-server/run-tests.sh` once (pre-flight self-heals from the sidecar). If still dirty: `git checkout userPrefs.jsonc`. - **nRF52 not responding?** `mcp__meshtastic__touch_1200bps(port=...)` drops it into the DFU bootloader, then `pio_flash` re-installs. +- **Device fully wedged (no DFU)?** `mcp__meshtastic__uhubctl_cycle(role="nrf52", confirm=True)` hard-power-cycles it via USB hub PPPS. Needs `uhubctl` installed (`brew install uhubctl` / `apt install uhubctl`); on Linux without udev rules, permission errors fail fast, so use `sudo uhubctl` yourself or configure udev access. - **Port busy?** `lsof ` to find the holder. Usually a stale `pio device monitor` or zombie `meshtastic_mcp` process. Kill it. - **Multiple MCP servers running?** `ps aux | grep meshtastic_mcp` — zombies hold ports. Kill all but the one your host spawned. + +## Environment variables (test harness) + +| Var | Purpose | +| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `MESHTASTIC_MCP_ENV_` | Override PlatformIO env for a role (e.g. `MESHTASTIC_MCP_ENV_NRF52=rak4631-dap`). Default map: `nrf52→rak4631`, `esp32s3→heltec-v3`. | +| `MESHTASTIC_MCP_SEED` | PSK seed for the session test profile. Defaults to `mcp--`. | +| `MESHTASTIC_MCP_FLASH_LOG` | File path to tee pio/esptool/nrfutil/picotool output. `run-tests.sh` sets this to `tests/flash.log` so the TUI can stream live flash progress. | +| `MESHTASTIC_UHUBCTL_BIN` | Absolute path to `uhubctl` binary. Default: PATH lookup. | +| `MESHTASTIC_UHUBCTL_LOCATION_` | Pin a role to a specific uhubctl hub location (e.g. `1-1.3`). Wins over VID auto-detection — use when multiple devices share a VID. | +| `MESHTASTIC_UHUBCTL_PORT_` | Pin a role to a specific hub port number. Required alongside `LOCATION_`. | +| `MESHTASTIC_UI_CAMERA_BACKEND` | Camera backend for UI tier + `capture_screen` tool: `opencv` / `ffmpeg` / `null` / `auto` (default). | +| `MESHTASTIC_UI_CAMERA_DEVICE` | Generic camera device (index or path). Used by the UI tier when no per-role var is set. | +| `MESHTASTIC_UI_CAMERA_DEVICE_` | Per-role camera pinning (e.g. `MESHTASTIC_UI_CAMERA_DEVICE_ESP32S3=0` for the OLED-bearing heltec-v3). | +| `MESHTASTIC_UI_OCR_BACKEND` | OCR engine selection: `easyocr` / `pytesseract` / `null` / `auto` (default). | +| `MESHTASTIC_UI_TUI_CAMERA` | Set to `1` to mount the live camera-feed panel in `meshtastic-mcp-test-tui`. | diff --git a/mcp-server/.gitignore b/mcp-server/.gitignore index f5180bc71..4cc892b2a 100644 --- a/mcp-server/.gitignore +++ b/mcp-server/.gitignore @@ -24,3 +24,6 @@ tests/.tui-runs tests/.history/ # Reproducer bundles (TUI `x` export on failed tests). tests/reproducers/ +# UI-tier camera captures + per-test transcripts. Regenerated every run; +# left on disk for human review between runs. +tests/ui_captures/ diff --git a/mcp-server/README.md b/mcp-server/README.md index 7d5fc551a..7a36a6fac 100644 --- a/mcp-server/README.md +++ b/mcp-server/README.md @@ -61,7 +61,7 @@ Replace `` with the absolute path, e.g. `/Users/you/GitHub/firmwa Same `mcpServers` block, but in `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). -## Tools (38) +## Tools (43) ### Discovery & metadata @@ -130,6 +130,34 @@ _The tool tables below document 38 currently registered MCP server tools._ | `picotool_load` | Load a UF2 | | `picotool_raw` | Pass-through | +### USB power control (uhubctl) + +| Tool | What it does | +| --------------- | ----------------------------------------------------------- | +| `uhubctl_list` | Enumerate USB hubs + attached-device VID/PID (read-only) | +| `uhubctl_power` | Drive a hub port `on` or `off`; `off` requires confirm=True | +| `uhubctl_cycle` | Off → wait `delay_s` → on; confirm=True required | + +Target a port by explicit `(location, port)` (raw uhubctl syntax like +`location="1-1.3", port=2`) or by `role` (`"nrf52"`, `"esp32s3"`). Role +lookup checks `MESHTASTIC_UHUBCTL_LOCATION_` + +`MESHTASTIC_UHUBCTL_PORT_` env vars first, then auto-detects via VID +against `uhubctl`'s output. + +Requires [`uhubctl`](https://github.com/mvp/uhubctl) on PATH: + +```bash +brew install uhubctl # macOS +apt install uhubctl # Debian/Ubuntu +``` + +Modern macOS + PPPS-capable hubs generally work without root. On Linux +without udev rules, or on old macOS with driver quirks, you may need +`sudo`. If uhubctl returns a permission error the MCP tool raises a +clear `UhubctlError` pointing at the +[udev-rules / sudo fallback](https://github.com/mvp/uhubctl#linux-usb-permissions) +rather than auto-`sudo`'ing mid-run. + ## Safety - **All destructive flash/admin tools require `confirm=True`** as a tool-level gate, on top of any permission prompt from Claude. @@ -182,10 +210,22 @@ in the pre-flight header. - **`unit`** — pure Python, no hardware. boards / PIO wrapper / userPrefs-parse / testing-profile fixtures. - **`mesh`** — 2-device mesh: formation, broadcast delivery, direct+ACK, - traceroute, bidirectional. Parametrized over both directions. + traceroute, bidirectional. Parametrized over both directions. Includes + `test_peer_offline_recovery` which uses uhubctl to power-cycle one peer + mid-conversation and verifies the mesh recovers (skips without uhubctl). - **`telemetry`** — periodic telemetry broadcast + on-demand request/reply (`TELEMETRY_APP` with `wantResponse=True`). - **`monitor`** — boot log has no panic markers within 60 s of reboot. +- **`recovery`** — `uhubctl` power-cycle round-trip: verifies the hub port + can be toggled off/on, the device re-enumerates with the same + `my_node_num`, and NVS-resident config (region, channel, modem preset) + survives a hard reset. Requires `uhubctl` on PATH; skips cleanly otherwise. +- **`ui`** — input-broker-driven screen navigation (`AdminMessage.send_input_event` + injection → `Screen::handleInputEvent` → frame transition). Parametrized + on the screen-bearing role (heltec-v3 OLED). Captures images via USB + webcam + OCRs them for HTML-report evidence. Requires `pip install -e '.[ui]'` + and `MESHTASTIC_UI_CAMERA_DEVICE_ESP32S3=`; tier is auto-deselected + if `cv2` isn't importable. - **`fleet`** — PSK-seed isolation: two labs with different seeds never overlap. - **`admin`** — owner persistence across reboot, channel URL round-trip, @@ -193,6 +233,42 @@ in the pre-flight header. - **`provisioning`** — region/channel baking, userPrefs survive `factory_reset(full=False)`. +#### UI tier setup + +The `tests/ui/` tier drives the on-device OLED via the firmware's existing +`AdminMessage.send_input_event` RPC (no firmware changes required) and +verifies transitions via a macro-gated log line + camera + OCR. Summary: + +1. Install extras: `pip install -e 'mcp-server/.[ui]'` — pulls in + `opencv-python-headless`, `numpy`, `easyocr`, `Pillow`. First easyocr + run downloads ~100 MB of models to `~/.EasyOCR/`; an autouse session + fixture pre-warms the reader so per-test OCR is <100 ms after that. +2. Point a USB webcam at the heltec-v3 OLED. Discover its index: + ```bash + .venv/bin/python -c "import cv2; [print(i, cv2.VideoCapture(i).read()[0]) for i in range(5)]" + ``` +3. Export the per-role device env var: + ```bash + export MESHTASTIC_UI_CAMERA_DEVICE_ESP32S3=0 + ``` +4. Run: + ```bash + ./run-tests.sh tests/ui -v + ``` + Captures land under `tests/ui_captures///`, one + PNG + `.ocr.txt` per `frame_capture()` call, with a per-test + `transcript.md` stepping through event → frame → OCR. The HTML report + embeds the full image strip inline (pass or fail). + +On macOS, `cv2.VideoCapture(0)` triggers the TCC Camera permission prompt +on first use. Pre-grant Terminal (or your IDE's terminal) before running. +The `OpenCVBackend` fails fast on 10 consecutive black frames so a silent +permission denial surfaces as a clear error, not an empty PNG strip. + +No camera? Set `MESHTASTIC_UI_CAMERA_BACKEND=null` (or leave the device var +unset). Tests still exercise the event-injection path and log assertions; +captures just become 1×1 black PNGs. + ### Artifacts (regenerated every run, under `tests/`) - `report.html` — self-contained pytest-html report. Each test gets a @@ -217,6 +293,14 @@ Key bindings: `r` re-run focused, `f` filter, `d` failure detail, `g` open `report.html`, `x` export reproducer bundle, `l` cycle fw-log filter, `q` quit (SIGINT → SIGTERM → SIGKILL escalation). +Set `MESHTASTIC_UI_TUI_CAMERA=1` to mount a bottom-of-screen **UI camera** +panel. Left side: the latest capture PNG rendered as Unicode half-blocks +(via `rich-pixels`, works in any terminal — no kitty/sixel required). +Right side: live transcript tail ("step 3 — frame 4/8 name=nodelist_nodes +— OCR: Nodes 2/2") so you can see every event-injection and its result +as each UI test runs. Requires the `[ui]` extras for image rendering; the +transcript alone works without them. + ### Slash commands Three AI-assisted workflows are wired up for Claude Code operators diff --git a/mcp-server/pyproject.toml b/mcp-server/pyproject.toml index d73bf795f..3241c843f 100644 --- a/mcp-server/pyproject.toml +++ b/mcp-server/pyproject.toml @@ -23,6 +23,21 @@ test = [ # consumers; revisit if install cost pushes back. "textual>=0.50", ] +# UI test tier + `capture_screen` MCP tool. Optional because the ML OCR +# model alone is ~100 MB and camera hardware is user-supplied. +# pip install -e '.[ui]' — full (OpenCV + easyocr) +# pip install -e '.[ui-min]' — image capture only, no OCR +ui = [ + "opencv-python-headless>=4.9", + "numpy>=1.26", + "easyocr>=1.7", + "Pillow>=10.0", + # Renders the latest camera capture as Unicode half-blocks in the TUI + # (MESHTASTIC_UI_TUI_CAMERA=1). Terminal-agnostic — no kitty / sixel + # dependency. Pure Python, tiny. + "rich-pixels>=3.0", +] +ui-min = ["opencv-python-headless>=4.9", "numpy>=1.26"] [project.scripts] meshtastic-mcp = "meshtastic_mcp.__main__:main" diff --git a/mcp-server/run-tests.sh b/mcp-server/run-tests.sh index 292e6e3a2..c84a8f751 100755 --- a/mcp-server/run-tests.sh +++ b/mcp-server/run-tests.sh @@ -217,6 +217,40 @@ if [[ $# -eq 0 ]]; then -v --tb=short fi +# UI tier requires opencv-python-headless (and ideally easyocr). If it's +# not installed, auto-deselect tests/ui so operators without the [ui] +# extra still get a green run. Printed in yellow; silent when cv2 is +# present. +_cv2_ok=0 +if "$VENV_PY" -c "import cv2" >/dev/null 2>&1; then + _cv2_ok=1 +fi +_running_ui=0 +for _arg in "$@"; do + case "$_arg" in + *tests/ui* | tests/) _running_ui=1 ;; + *) ;; + esac +done +if [[ $_running_ui -eq 1 && $_cv2_ok -eq 0 ]]; then + printf '\033[33m[pre-flight] tests/ui tier detected, but opencv-python-headless is not installed — deselecting.\033[0m\n' + printf ' install with: .venv/bin/pip install -e "mcp-server/.[ui]"\n' + echo + set -- "$@" --ignore=tests/ui +fi + +# Recovery tier needs `uhubctl` on PATH — it power-cycles devices via USB +# hub PPPS. The tier's conftest already skips cleanly, so this is just a +# friendly heads-up before the skip happens. `baked_single`'s auto- +# recovery hook also benefits from having uhubctl available across the +# whole suite. +if ! command -v uhubctl >/dev/null 2>&1; then + printf "\033[33m[pre-flight] uhubctl not found on PATH — recovery tier will skip, and\n" + printf " wedged-device auto-recovery is disabled.\033[0m\n" + printf " install with: brew install uhubctl (macOS) or apt install uhubctl (Debian/Ubuntu).\n" + echo +fi + # Always emit `tests/reportlog.jsonl` (unless the operator explicitly passed # their own `--report-log=...`). Consumers — notably the # `meshtastic-mcp-test-tui` TUI — tail the reportlog for live per-test state. diff --git a/mcp-server/src/meshtastic_mcp/admin.py b/mcp-server/src/meshtastic_mcp/admin.py index 6da92d860..33f3865dd 100644 --- a/mcp-server/src/meshtastic_mcp/admin.py +++ b/mcp-server/src/meshtastic_mcp/admin.py @@ -356,6 +356,46 @@ def shutdown( return {"ok": True, "shutting_down_in_s": seconds} +def send_input_event( + event_code: int | str, + kb_char: int = 0, + touch_x: int = 0, + touch_y: int = 0, + port: str | None = None, +) -> dict[str, Any]: + """Inject an InputBroker event (button press / key / gesture) into the UI. + + Wraps `AdminMessage.send_input_event` (handled in firmware at + src/modules/AdminModule.cpp::handleSendInputEvent). Local-only — no PKI + warmup needed since the admin message is addressed to `my_node_num`. + + `event_code` accepts an int, a case-insensitive name + (`"RIGHT"` / `"input_broker_right"`), or an `InputEventCode`. The + firmware-side enum lives in src/input/InputBroker.h and is mirrored in + `meshtastic_mcp.input_events`. + """ + from meshtastic.protobuf import admin_pb2 # type: ignore[import-untyped] + + from .input_events import coerce_event_code + + code = coerce_event_code(event_code) + if not 0 <= kb_char <= 255: + raise ValueError(f"kb_char out of u8 range: {kb_char}") + if not 0 <= touch_x <= 65535: + raise ValueError(f"touch_x out of u16 range: {touch_x}") + if not 0 <= touch_y <= 65535: + raise ValueError(f"touch_y out of u16 range: {touch_y}") + + with connect(port=port) as iface: + msg = admin_pb2.AdminMessage() + msg.send_input_event.event_code = code + msg.send_input_event.kb_char = kb_char + msg.send_input_event.touch_x = touch_x + msg.send_input_event.touch_y = touch_y + iface.localNode._sendAdmin(msg) + return {"ok": True, "event_code": code, "kb_char": kb_char} + + def factory_reset( port: str | None = None, confirm: bool = False, full: bool = False ) -> dict[str, Any]: diff --git a/mcp-server/src/meshtastic_mcp/camera.py b/mcp-server/src/meshtastic_mcp/camera.py new file mode 100644 index 000000000..5f1e5ede3 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/camera.py @@ -0,0 +1,286 @@ +"""Cross-platform USB-webcam capture for UI tests + the `capture_screen` tool. + +Backends: +- `opencv` — cv2.VideoCapture (AVFoundation on macOS, V4L2 on Linux). +- `ffmpeg` — subprocess shelling out to the system `ffmpeg` binary. Slower + per frame, but zero Python deps beyond stdlib. +- `null` — no-op stub returning a 1×1 black PNG. Used when no camera is + configured; keeps code paths alive without forcing every operator to + hook up hardware. + +Environment variables (read at `get_camera()` call time): +- `MESHTASTIC_UI_CAMERA_BACKEND` — one of `opencv` / `ffmpeg` / `null` / + `auto` (default). `auto` picks opencv if `cv2` imports, else ffmpeg if + `ffmpeg --version` resolves, else null. +- `MESHTASTIC_UI_CAMERA_DEVICE` — generic default (index or path). +- `MESHTASTIC_UI_CAMERA_DEVICE_` — per-role override, e.g. + `MESHTASTIC_UI_CAMERA_DEVICE_ESP32S3=0` for the OLED-bearing heltec-v3. + Role suffix is uppercased before lookup. + +Dependencies land in the optional `[ui]` extra; imports are lazy so clients +without `opencv-python-headless` installed can still import this module. +""" + +from __future__ import annotations + +import io +import os +import shutil +import subprocess +import sys +import time +import warnings +from pathlib import Path +from typing import Protocol + + +class CameraError(RuntimeError): + """Raised when a camera backend fails to initialize or capture.""" + + +class CameraBackend(Protocol): + name: str + + def capture(self) -> bytes: + """Return one PNG-encoded frame.""" + ... + + def close(self) -> None: ... + + +# ---------- OpenCV backend ------------------------------------------------- + + +class OpenCVBackend: + name = "opencv" + + def __init__(self, device: int | str, warmup_frames: int = 5) -> None: + try: + import cv2 # type: ignore[import-untyped] # noqa: PLC0415 + except ImportError as exc: + raise CameraError( + "opencv backend requested but `cv2` is not installed. " + "Install the mcp-server [ui] extra: pip install -e '.[ui]'" + ) from exc + + self._cv2 = cv2 + device_arg: int | str + if isinstance(device, str) and device.isdigit(): + device_arg = int(device) + else: + device_arg = device + self._cap = cv2.VideoCapture(device_arg) + if not self._cap.isOpened(): + raise CameraError( + f"cv2.VideoCapture({device_arg!r}) failed to open. " + "On macOS check TCC Camera permission; on Linux check /dev/video* and v4l2 access." + ) + + # Drop the first few frames — auto-exposure + white-balance settle. + for _ in range(warmup_frames): + self._cap.read() + # Detect a stuck black-frame camera early rather than silently + # producing all-black captures. + ok, frame = self._cap.read() + if not ok or frame is None: + self._cap.release() + raise CameraError(f"camera {device_arg!r} opened but returned no frames") + + def capture(self) -> bytes: + cv2 = self._cv2 + ok, frame = self._cap.read() + if not ok or frame is None: + raise CameraError("cv2.VideoCapture.read() returned no frame") + success, buf = cv2.imencode(".png", frame) + if not success: + raise CameraError("cv2.imencode('.png', ...) failed") + return bytes(buf) + + def close(self) -> None: + try: + self._cap.release() + except Exception: # noqa: BLE001 + pass + + +# ---------- ffmpeg subprocess backend -------------------------------------- + + +class FfmpegBackend: + name = "ffmpeg" + + def __init__(self, device: int | str) -> None: + if shutil.which("ffmpeg") is None: + raise CameraError("ffmpeg backend requested but `ffmpeg` is not on PATH") + + self._device = str(device) + # Platform-specific -f flag: + # macOS → avfoundation (index like "0") + # Linux → v4l2 (device like "/dev/video0" or "0") + if sys.platform == "darwin": + self._input_format = "avfoundation" + self._input_spec = self._device # bare index for avfoundation + else: + self._input_format = "v4l2" + self._input_spec = ( + self._device + if self._device.startswith("/dev/") + else f"/dev/video{self._device}" + ) + + def capture(self) -> bytes: + cmd = [ + "ffmpeg", + "-hide_banner", + "-loglevel", + "error", + "-f", + self._input_format, + "-i", + self._input_spec, + "-frames:v", + "1", + "-f", + "image2pipe", + "-vcodec", + "png", + "-", + ] + try: + out = subprocess.run( + cmd, capture_output=True, check=True, timeout=15 # noqa: S603 + ) + except subprocess.CalledProcessError as exc: + raise CameraError( + f"ffmpeg capture failed (rc={exc.returncode}): {exc.stderr.decode(errors='replace')[:200]}" + ) from exc + except subprocess.TimeoutExpired as exc: + raise CameraError("ffmpeg capture timed out after 15s") from exc + return out.stdout + + def close(self) -> None: + pass # stateless — each capture spawns a new process + + +# ---------- Null backend --------------------------------------------------- + + +# A tiny valid 1×1 transparent PNG so callers always get a decodable image. +_BLACK_1X1_PNG = bytes.fromhex( + "89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c489" + "0000000d49444154789c6300010000000500010d0a2db40000000049454e44ae426082" +) + + +class NullBackend: + name = "null" + + def capture(self) -> bytes: + return _BLACK_1X1_PNG + + def close(self) -> None: + pass + + +# ---------- Factory -------------------------------------------------------- + + +def _resolve_device(role: str | None) -> str | None: + if role: + specific = os.environ.get(f"MESHTASTIC_UI_CAMERA_DEVICE_{role.upper()}") + if specific: + return specific + return os.environ.get("MESHTASTIC_UI_CAMERA_DEVICE") + + +def get_camera(role: str | None = None) -> CameraBackend: + """Return a CameraBackend for the given device role (e.g. `"esp32s3"`). + + Falls back to `NullBackend` if no camera is configured or the selected + backend fails to init — tests should treat captures as best-effort + evidence, not a blocker. + """ + backend = os.environ.get("MESHTASTIC_UI_CAMERA_BACKEND", "auto").lower() + device = _resolve_device(role) + + if backend in ("null", "none") or device is None: + return NullBackend() + + if backend == "auto": + # Prefer opencv if importable; fall back to ffmpeg; else null. + try: + import cv2 # type: ignore[import-untyped] # noqa: F401,PLC0415 + + backend = "opencv" + except ImportError: + backend = "ffmpeg" if shutil.which("ffmpeg") else "null" + + if backend == "opencv": + try: + return OpenCVBackend(device) + except CameraError as exc: + warnings.warn( + f"camera backend {backend!r} failed to initialize for device " + f"{device!r}: {exc}; falling back to null backend", + RuntimeWarning, + stacklevel=2, + ) + return NullBackend() + if backend == "ffmpeg": + try: + return FfmpegBackend(device) + except CameraError as exc: + warnings.warn( + f"camera backend {backend!r} failed to initialize for device " + f"{device!r}: {exc}; falling back to null backend", + RuntimeWarning, + stacklevel=2, + ) + return NullBackend() + if backend == "null": + return NullBackend() + + raise CameraError(f"unknown MESHTASTIC_UI_CAMERA_BACKEND: {backend!r}") + + +def save_capture(png_bytes: bytes, path: Path) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(png_bytes) + + +def capture_to_file(role: str | None, path: Path) -> dict[str, object]: + """One-shot: open camera, capture, write PNG, close. Returns metadata.""" + started = time.monotonic() + cam = get_camera(role) + try: + data = cam.capture() + finally: + cam.close() + save_capture(data, path) + return { + "backend": cam.name, + "path": str(path), + "bytes": len(data), + "elapsed_s": round(time.monotonic() - started, 3), + } + + +def _is_png(data: bytes) -> bool: + return data.startswith(b"\x89PNG\r\n\x1a\n") + + +# Exposed so callers can sanity-check a capture without a full PIL import. +__all__ = [ + "CameraBackend", + "CameraError", + "FfmpegBackend", + "NullBackend", + "OpenCVBackend", + "capture_to_file", + "get_camera", + "save_capture", +] + +# Keep `io` import used (pyflakes is picky) via a small guard used at import +# time to normalize stdin/stdout if a subclass ever needs it. +_ = io.BytesIO # noqa: SLF001 diff --git a/mcp-server/src/meshtastic_mcp/cli/_uicap.py b/mcp-server/src/meshtastic_mcp/cli/_uicap.py new file mode 100644 index 000000000..448459954 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/cli/_uicap.py @@ -0,0 +1,83 @@ +"""UI-capture transcript tailer for ``meshtastic-mcp-test-tui``. + +Watches ``tests/ui_captures//`` for new transcript lines +(one per ``frame_capture()`` call from the UI tier) and posts them to +the TUI. Enabled by ``MESHTASTIC_UI_TUI_CAMERA=1``. + +Design mirrors ``_flashlog.py``: +- Daemon thread, cooperative stop via ``threading.Event``. +- Tolerates the captures directory not existing yet (UI tier hasn't run). +- Per-file seek state so we only forward genuinely-new lines. +""" + +from __future__ import annotations + +import pathlib +import threading +import time +from typing import Callable + + +class UiCaptureTailer(threading.Thread): + """Recursively watch a captures root for new `transcript.md` lines. + + Invokes ``post(test_id, line)`` for each new line, where ``test_id`` + is derived from the path — the sanitized nodeid directory name. + """ + + def __init__( + self, + root: pathlib.Path, + post: Callable[[str, str], None], + stop: threading.Event, + *, + poll_interval: float = 0.5, + ) -> None: + super().__init__(daemon=True, name="uicap-tail") + self._root = root + self._post = post + self._stop = stop + self._poll_interval = poll_interval + # path → byte offset we've already read through + self._offsets: dict[pathlib.Path, int] = {} + + def run(self) -> None: + while not self._stop.is_set(): + try: + self._scan_once() + except Exception: + # Best-effort tailer — never bring down the TUI because a + # directory vanished mid-scan. + pass + time.sleep(self._poll_interval) + + def _scan_once(self) -> None: + if not self._root.is_dir(): + return + for transcript in self._root.rglob("transcript.md"): + test_id = transcript.parent.name + offset = self._offsets.get(transcript, 0) + try: + size = transcript.stat().st_size + except OSError: + continue + if size < offset: + # File truncated / rewritten — reset and re-emit. + offset = 0 + if size == offset: + continue + try: + with transcript.open("rb") as fh: + fh.seek(offset) + chunk = fh.read(size - offset).decode("utf-8", errors="replace") + except OSError: + continue + for line in chunk.splitlines(): + line = line.rstrip() + if not line or line.startswith("#"): + continue + try: + self._post(test_id, line) + except Exception: + return + self._offsets[transcript] = size diff --git a/mcp-server/src/meshtastic_mcp/cli/test_tui.py b/mcp-server/src/meshtastic_mcp/cli/test_tui.py index 33201101b..7f3a2da36 100644 --- a/mcp-server/src/meshtastic_mcp/cli/test_tui.py +++ b/mcp-server/src/meshtastic_mcp/cli/test_tui.py @@ -518,6 +518,7 @@ def _build_app( from . import _fwlog as _fwlog_mod from . import _history as _history_mod from . import _reproducer as _reproducer_mod + from . import _uicap as _uicap_mod # ---------------- Messages ---------------- @@ -548,6 +549,16 @@ def _build_app( self.line = line super().__init__() + class UiCaptureLine(tx.Message): + """Live line from the UI-tier camera transcript — one per + `frame_capture()` call. Posted only when the camera panel is + enabled via `MESHTASTIC_UI_TUI_CAMERA=1`.""" + + def __init__(self, test_id: str, line: str) -> None: + self.test_id = test_id + self.line = line + super().__init__() + class DeviceSnapshot(tx.Message): def __init__(self, rows: list[DeviceRow]) -> None: self.rows = rows @@ -871,6 +882,10 @@ def _build_app( #pytest-pane { height: 50%; border-bottom: solid $primary-background; } #fwlog-header { height: 1; padding: 0 1; background: $panel; } #fwlog-pane { height: 1fr; } + #uicap-header { height: 1; padding: 0 1; background: $boost; } + #uicap-pane { height: 14; border-top: solid $primary-background; } + #uicap-image { width: 36; border-right: solid $primary-background; padding: 0 1; } + #uicap-log { width: 1fr; height: 14; } Tree { height: 100%; } RichLog { height: 100%; } #device-table { height: auto; max-height: 6; } @@ -912,6 +927,11 @@ def _build_app( self._device_worker: DevicePollerWorker | None = None self._fwlog_worker: _fwlog_mod.FirmwareLogTailer | None = None self._flashlog_worker: _flashlog_mod.FlashLogTailer | None = None + self._uicap_worker: _uicap_mod.UiCaptureTailer | None = None + # Env-gated; only mounts the UI-capture panel when operator asks for it. + self._ui_camera_enabled = bool( + int(os.environ.get("MESHTASTIC_UI_TUI_CAMERA", "0") or "0") + ) self._tree_filter: str = "" self._sigint_count = 0 # Firmware-log port filter: None = all, else exact port match. @@ -959,6 +979,22 @@ def _build_app( wrap=True, max_lines=5000, ) + if self._ui_camera_enabled: + yield tx.Static( + "UI camera — latest capture + transcript (MESHTASTIC_UI_TUI_CAMERA=1)", + id="uicap-header", + ) + with tx.Horizontal(id="uicap-pane"): + yield tx.Static( + "(waiting…)", id="uicap-image", markup=False + ) + yield tx.RichLog( + id="uicap-log", + highlight=False, + markup=False, + wrap=True, + max_lines=500, + ) yield tx.DataTable(id="device-table", show_cursor=False) yield tx.Footer() @@ -1023,6 +1059,21 @@ def _build_app( stop=self._stop, ) self._flashlog_worker.start() + # UI-capture transcript tailer — only runs when the camera panel + # is enabled. Watches tests/ui_captures/**/transcript.md for new + # lines as UI tests execute. + if self._ui_camera_enabled: + captures_root = self._root / "mcp-server" / "tests" / "ui_captures" + # When the TUI is launched from inside mcp-server (the usual + # case), `self._root` is already mcp-server/, so adjust: + if not captures_root.parent.name == "mcp-server": + captures_root = self._root / "tests" / "ui_captures" + self._uicap_worker = _uicap_mod.UiCaptureTailer( + root=captures_root, + post=lambda tid, line: self.post_message(UiCaptureLine(tid, line)), + stop=self._stop, + ) + self._uicap_worker.start() self._spawn_pytest(self._pytest_args) # Header tick (seed / runtime / sparkline re-renders at 1 Hz). # Also refreshes the device-status column so the per-test elapsed @@ -1217,6 +1268,84 @@ def _build_app( log = self.query_one("#pytest-log", tx.RichLog) log.write(f"[flash] {message.line}") + def on_ui_capture_line(self, message: Any) -> None: + """Route a UI-capture transcript line into the camera panel. + + Each line is already formatted by frame_capture — e.g. + `1. **initial** — frame 2/8 name=home — OCR: ...`. We write + the text into the RichLog AND try to render the corresponding + PNG on the left side (requires rich-pixels, Pillow). + """ + if not self._ui_camera_enabled: + return + try: + log_panel = self.query_one("#uicap-log", tx.RichLog) + except Exception: + return + log_panel.write(f"[{message.test_id}] {message.line}") + self._render_latest_ui_capture(message.test_id, message.line) + + def _render_latest_ui_capture(self, test_id: str, line: str) -> None: + """Find the PNG that corresponds to `line` and render it on the + left of the uicap pane. Soft-fails if rich-pixels isn't + installed or the PNG isn't found — operator still has the text + transcript on the right. + """ + try: + from PIL import Image # type: ignore[import-untyped] + from rich_pixels import Pixels # type: ignore[import-untyped] + except ImportError: + return + + # Transcript lines look like `1. **label** — ...`. Pull the leading + # integer to locate the capture file. + import re as _re + + m = _re.match(r"\s*(\d+)\.\s", line) + if not m: + return + step = int(m.group(1)) + + # Captures directory is sibling of tests/ — mirror the path the + # tailer watches. Search both likely layouts (in-mcp-server vs. + # firmware-root invocation). + candidates = [ + self._root / "tests" / "ui_captures", + self._root / "mcp-server" / "tests" / "ui_captures", + ] + captures_root = next((p for p in candidates if p.is_dir()), None) + if captures_root is None: + return + + # Drill into // — test_id is the + # sanitized nodeid the tailer already passed through. + matches = list(captures_root.rglob(f"{test_id}/{step:03d}-*.png")) + if not matches: + return + png_path = matches[-1] + + try: + img = Image.open(png_path).convert("RGB") + # Resize to fit ~32 cells wide × ~12 rows tall (half-block + # renderer gives 2× vertical resolution, so 32×24 px input + # lands at ~32×12 cells). Keep aspect ratio. + target_w = 60 + w, h = img.size + target_h = max(1, int(h * (target_w / max(1, w)))) + # Clamp: the image panel is 14 rows; half-blocks give 2 rows + # per vertical cell, so cap pixel height at ~26. + target_h = min(target_h, 26) + img = img.resize((target_w, target_h)) + pixels = Pixels.from_image(img) + except Exception: + return + + try: + image_widget = self.query_one("#uicap-image", tx.Static) + image_widget.update(pixels) + except Exception: + pass + def on_firmware_log_line(self, message: Any) -> None: rec = message.record port = rec.get("port") diff --git a/mcp-server/src/meshtastic_mcp/config.py b/mcp-server/src/meshtastic_mcp/config.py index 7ece10032..d3006a73e 100644 --- a/mcp-server/src/meshtastic_mcp/config.py +++ b/mcp-server/src/meshtastic_mcp/config.py @@ -135,3 +135,14 @@ def picotool_bin() -> Path: ("picotool",), "Install via `brew install picotool` or build from https://github.com/raspberrypi/picotool.", ) + + +def uhubctl_bin() -> Path: + return _hw_tool( + "MESHTASTIC_UHUBCTL_BIN", + ("uhubctl",), + "Install via `brew install uhubctl` (macOS) or `apt install uhubctl` " + "(Debian/Ubuntu). On Linux without the udev rules, or on older macOS " + "with certain hubs, you may need to run via `sudo`: " + "https://github.com/mvp/uhubctl#linux-usb-permissions", + ) diff --git a/mcp-server/src/meshtastic_mcp/input_events.py b/mcp-server/src/meshtastic_mcp/input_events.py new file mode 100644 index 000000000..f6b287ba3 --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/input_events.py @@ -0,0 +1,67 @@ +"""Python mirror of firmware `enum input_broker_event` (src/input/InputBroker.h). + +Used by `admin.send_input_event` + `tests/ui/` so callers can say +`InputEventCode.RIGHT` instead of hard-coding 20. Values MUST stay in sync +with the firmware enum — unit test `tests/unit/test_input_event_codes.py` +pins the mapping. +""" + +from __future__ import annotations + +from enum import IntEnum + + +class InputEventCode(IntEnum): + """Button / key / gesture events dispatched by the firmware InputBroker.""" + + NONE = 0 + SELECT = 10 + SELECT_LONG = 11 + UP_LONG = 12 + DOWN_LONG = 13 + UP = 17 + DOWN = 18 + LEFT = 19 + RIGHT = 20 + CANCEL = 24 + BACK = 27 + # Auto-incremented values in the C enum (27 + 1, +2, +3): + USER_PRESS = 28 + ALT_PRESS = 29 + ALT_LONG = 30 + SHUTDOWN = 0x9B + GPS_TOGGLE = 0x9E + SEND_PING = 0xAF + FN_F1 = 0xF1 + FN_F2 = 0xF2 + FN_F3 = 0xF3 + FN_F4 = 0xF4 + FN_F5 = 0xF5 + MATRIXKEY = 0xFE + ANYKEY = 0xFF + + +def coerce_event_code(value: int | str | InputEventCode) -> int: + """Accept an int, a case-insensitive name, or an `InputEventCode` and return + the u8 wire value. Raises ValueError on unknown names / out-of-range ints. + """ + if isinstance(value, InputEventCode): + return int(value) + if isinstance(value, int): + if not 0 <= value <= 255: + raise ValueError(f"event_code out of u8 range: {value}") + return value + if isinstance(value, str): + key = value.upper().replace("-", "_") + if key.startswith("INPUT_BROKER_"): + key = key[len("INPUT_BROKER_") :] + try: + return int(InputEventCode[key]) + except KeyError as exc: + known = ", ".join(m.name for m in InputEventCode) + raise ValueError( + f"unknown event code name {value!r}; known: {known}" + ) from exc + raise TypeError( + f"event_code must be int|str|InputEventCode, got {type(value).__name__}" + ) diff --git a/mcp-server/src/meshtastic_mcp/ocr.py b/mcp-server/src/meshtastic_mcp/ocr.py new file mode 100644 index 000000000..f40bc3cbd --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/ocr.py @@ -0,0 +1,147 @@ +"""OCR wrapper for UI tests + the `capture_screen` tool. + +Auto-selects a reader in priority order: + 1. `easyocr` (deep-learning, high quality on OLED screens — but ~100 MB + model download on first use). + 2. `pytesseract` (requires system `tesseract` binary on PATH). + 3. `null` — returns `""` with a warning. Tests fall back to log + image + evidence when OCR is unavailable. + +Override via `MESHTASTIC_UI_OCR_BACKEND=easyocr|pytesseract|null|auto` +(default `auto`). + +`ocr_text(png_bytes) -> str` is the only public entry point. The reader is +constructed lazily on first call and cached, so the easyocr cold-start cost +only hits once per process. +""" + +from __future__ import annotations + +import functools +import logging +import os +import shutil +import sys +from typing import Callable + +log = logging.getLogger(__name__) + + +def _backend_choice() -> str: + return os.environ.get("MESHTASTIC_UI_OCR_BACKEND", "auto").lower() + + +@functools.lru_cache(maxsize=1) +def _reader() -> tuple[str, Callable[[bytes], str]]: + """Return `(backend_name, callable)` for whichever OCR is available.""" + choice = _backend_choice() + + def _easyocr() -> tuple[str, Callable[[bytes], str]]: + import easyocr # type: ignore[import-untyped] # noqa: PLC0415 + import numpy as np # type: ignore[import-untyped] # noqa: PLC0415 + + reader = easyocr.Reader(["en"], gpu=False, verbose=False) + + def _run(png: bytes) -> str: + try: + import cv2 # type: ignore[import-untyped] # noqa: PLC0415 + + arr = np.frombuffer(png, dtype=np.uint8) + img = cv2.imdecode(arr, cv2.IMREAD_COLOR) + except ImportError: + # Fall back to PIL if cv2 isn't around. + from io import BytesIO # noqa: PLC0415 + + from PIL import Image # type: ignore[import-untyped] # noqa: PLC0415 + + img = np.array(Image.open(BytesIO(png)).convert("RGB")) + try: + results = reader.readtext(img, detail=0, paragraph=True) + except Exception as exc: # noqa: BLE001 + log.warning("easyocr failed: %s", exc) + return "" + return "\n".join(str(r) for r in results) + + return "easyocr", _run + + def _pytesseract() -> tuple[str, Callable[[bytes], str]]: + from io import BytesIO # noqa: PLC0415 + + import pytesseract # type: ignore[import-untyped] # noqa: PLC0415 + from PIL import Image # type: ignore[import-untyped] # noqa: PLC0415 + + if shutil.which("tesseract") is None: + raise ImportError("`tesseract` binary not on PATH") + + def _run(png: bytes) -> str: + try: + return str(pytesseract.image_to_string(Image.open(BytesIO(png)))) + except Exception as exc: # noqa: BLE001 + log.warning("pytesseract failed: %s", exc) + return "" + + return "pytesseract", _run + + def _null() -> tuple[str, Callable[[bytes], str]]: + log.warning( + "OCR backend is null; install easyocr or tesseract for text extraction" + ) + return "null", lambda _png: "" + + if choice == "easyocr": + return _easyocr() + if choice == "pytesseract": + return _pytesseract() + if choice == "null": + return _null() + if choice != "auto": + print( + f"[ocr] unknown MESHTASTIC_UI_OCR_BACKEND={choice!r}; falling back to auto", + file=sys.stderr, + ) + + # auto mode + try: + return _easyocr() + except ImportError: + pass + try: + return _pytesseract() + except ImportError: + pass + return _null() + + +def ocr_text(png_bytes: bytes) -> str: + """Run OCR on a PNG-encoded image and return the decoded text (possibly empty).""" + if not png_bytes: + return "" + _, run = _reader() + return run(png_bytes) + + +def backend_name() -> str: + """Return the currently-selected backend name, initializing if necessary.""" + name, _ = _reader() + return name + + +def warm() -> None: + """Run one dummy inference so the easyocr cold-start cost is paid upfront. + + Pytest session fixture calls this once so the first real capture doesn't + eat the model-load latency. + """ + # A 64×32 white PNG — decodes clean, no text to extract. + white_png = bytes.fromhex( + "89504e470d0a1a0a0000000d49484452000000400000002008060000007ccac28e" + "0000001c49444154785eedc1010d000000c2a0f74f6d0d370000000000000080" + "0b010000ffff030000000000000049454e44ae426082" + ) + try: + ocr_text(white_png) + except Exception as exc: # noqa: BLE001 + log.warning("ocr.warm() failed: %s", exc) + + +__all__ = ["backend_name", "ocr_text", "warm"] diff --git a/mcp-server/src/meshtastic_mcp/server.py b/mcp-server/src/meshtastic_mcp/server.py index 7cb8db65e..83aa80c45 100644 --- a/mcp-server/src/meshtastic_mcp/server.py +++ b/mcp-server/src/meshtastic_mcp/server.py @@ -1,4 +1,4 @@ -"""FastMCP server wiring — 38 tools across 7 categories. +"""FastMCP server wiring — 43 tools across 9 categories (adds uhubctl power control). Each tool handler is a thin delegation to a named module (pio.py, admin.py, etc.). Business logic does not live here. @@ -513,6 +513,152 @@ def factory_reset( return admin.factory_reset(port=port, confirm=confirm, full=full) +@app.tool() +def send_input_event( + event_code: int | str, + kb_char: int = 0, + touch_x: int = 0, + touch_y: int = 0, + port: str | None = None, +) -> dict[str, Any]: + """Inject an InputBroker event (button / key / gesture) into the device UI. + + Drives the same code path as a physical button press. Accepts a numeric + event code (0..255) or a name like `"RIGHT"`, `"SELECT"`, `"FN_F1"`. + + Common codes: SELECT=10, UP=17, DOWN=18, LEFT=19, RIGHT=20, CANCEL=24, + BACK=27, FN_F1..F5=241..245. + """ + return admin.send_input_event( + event_code=event_code, + kb_char=kb_char, + touch_x=touch_x, + touch_y=touch_y, + port=port, + ) + + +@app.tool() +def capture_screen(role: str | None = None, ocr: bool = True) -> dict[str, Any]: + """Grab a frame from the USB webcam pointed at the device screen. + + Returns PNG bytes (base64), optional OCR text, and backend metadata. + Requires the `[ui]` extras (opencv-python-headless) and a camera + configured via `MESHTASTIC_UI_CAMERA_DEVICE[_]`. Falls back to a + 1×1 black PNG from the null backend when no camera is configured. + """ + import base64 + + from . import camera as camera_mod + + cam = camera_mod.get_camera(role) + try: + png = cam.capture() + finally: + cam.close() + + result: dict[str, Any] = { + "backend": cam.name, + "bytes": len(png), + "image_base64": base64.b64encode(png).decode("ascii"), + } + if ocr: + from . import ocr as ocr_mod + + result["ocr_backend"] = ocr_mod.backend_name() + result["ocr_text"] = ocr_mod.ocr_text(png) + return result + + +# ---------- USB power control (uhubctl) ----------------------------------- + + +@app.tool() +def uhubctl_list() -> list[dict[str, Any]]: + """List every USB hub + per-port device attachment as seen by `uhubctl`. + + Read-only — no confirm required. Each hub entry includes its location + (`1-1.3`), descriptor, whether it supports Per-Port Power Switching, + and a list of populated ports with VID:PID of attached devices. + Useful for pre-flight checks before a destructive power-cycle call. + """ + from . import uhubctl as uhubctl_mod + + return uhubctl_mod.list_hubs() + + +@app.tool() +def uhubctl_power( + action: str, + location: str | None = None, + port: int | None = None, + role: str | None = None, + confirm: bool = False, +) -> dict[str, Any]: + """Power a USB hub port on or off via `uhubctl -a on|off`. + + Target the port by either (`location`, `port`) — raw uhubctl syntax, + e.g. `location="1-1.3", port=2` — OR by `role` ("nrf52", "esp32s3"). + Role lookup honors `MESHTASTIC_UHUBCTL_LOCATION_` + + `_PORT_` env vars first, falls back to VID auto-detection. + + `action="off"` requires `confirm=True` (destructive — the attached + device will immediately disappear from the OS). + """ + from . import uhubctl as uhubctl_mod + + action_lower = action.lower() + if action_lower not in {"on", "off"}: + raise ValueError(f"action must be 'on' or 'off', got {action!r}") + if action_lower == "off" and not confirm: + raise uhubctl_mod.UhubctlError( + "uhubctl_power action='off' requires confirm=True" + ) + loc, p = _resolve_uhubctl_target(location, port, role) + if action_lower == "on": + return uhubctl_mod.power_on(loc, p) + return uhubctl_mod.power_off(loc, p) + + +@app.tool() +def uhubctl_cycle( + location: str | None = None, + port: int | None = None, + role: str | None = None, + delay_s: int = 2, + confirm: bool = False, +) -> dict[str, Any]: + """Power a USB hub port off, wait `delay_s` seconds, then on. + + The typical hard-reset sequence — shorter than off+on as two RPCs + because uhubctl handles the timing in-process. Target by (location, + port) or by role (see `uhubctl_power`). Requires `confirm=True`. + """ + from . import uhubctl as uhubctl_mod + + if not confirm: + raise uhubctl_mod.UhubctlError("uhubctl_cycle requires confirm=True") + if delay_s < 0 or delay_s > 60: + raise ValueError(f"delay_s must be 0..60, got {delay_s}") + loc, p = _resolve_uhubctl_target(location, port, role) + return uhubctl_mod.cycle(loc, p, delay_s=delay_s) + + +def _resolve_uhubctl_target( + location: str | None, port: int | None, role: str | None +) -> tuple[str, int]: + """Shared arg-resolution for uhubctl_power + uhubctl_cycle.""" + from . import uhubctl as uhubctl_mod + + if role is not None: + if location is not None or port is not None: + raise ValueError("pass either `role` OR (`location` + `port`), not both") + return uhubctl_mod.resolve_target(role) + if location is None or port is None: + raise ValueError("must pass `role` or both `location` and `port`") + return (location, int(port)) + + # ---------- Direct hardware tools ----------------------------------------- diff --git a/mcp-server/src/meshtastic_mcp/uhubctl.py b/mcp-server/src/meshtastic_mcp/uhubctl.py new file mode 100644 index 000000000..e0306386b --- /dev/null +++ b/mcp-server/src/meshtastic_mcp/uhubctl.py @@ -0,0 +1,321 @@ +"""USB hub power control via `uhubctl` — hard-recovery for wedged devices + +deliberate offline-peer simulation for mesh tests. + +Why: when a Meshtastic device's serial port wedges (stuck in a boot loop, +frozen USB CDC, crashed firmware that didn't reboot), the only recovery is +a physical unplug. uhubctl toggles VBUS per-port on any hub with Per-Port +Power Switching (PPPS) support — which is most externally-powered hubs +from the last ~5 years — so the harness can power-cycle a device +programmatically. + +Architecture: +- `list_hubs()` parses `uhubctl` default output into structured records. +- `find_port_for_vid(vid)` walks the hubs to find which location+port + hosts a given USB VID. +- `resolve_target(role)` is the public entry for callers that know a role + (`nrf52`, `esp32s3`) but not a hub location: env-var pins win, VID + auto-detect falls back. +- `power_on`, `power_off`, `cycle` wrap the corresponding `uhubctl -a` + invocations, routed through `hw_tools._run` so they share tee-to-flash- + log + timeout handling with esptool / nrfutil / picotool. + +Sudo policy: **fail fast**. Modern macOS + most PPPS-capable hubs work +without root, but Linux without udev rules (or old macOS with specific +driver quirks) still needs it. We run uhubctl non-root; if stderr +matches the classic permission pattern we raise `UhubctlError` with an +install hint pointing at the uhubctl docs. Auto-wrapping with `sudo` +would prompt in the middle of test runs — bad for CI. +""" + +from __future__ import annotations + +import os +import re +from typing import Any, Sequence + +from . import config, hw_tools + +# ---------- Parser --------------------------------------------------------- + +# Hub descriptor line: +# Current status for hub 1-1.3 [2109:2817 VIA Labs, Inc. USB2.0 Hub, USB 2.10, 4 ports, ppps] +_HUB_RE = re.compile( + r"^Current status for hub (?P\S+)\s+\[(?P.+)\]\s*$" +) + +# Port line: +# " Port 2: 0103 power enable connect [239a:8029 RAKwireless ...]" +# The bracketed section is absent for empty ports. +_PORT_RE = re.compile( + r"^\s+Port\s+(?P\d+):\s+(?P\S+)\s+(?P.*?)" + r"(?:\s+\[(?P[0-9a-fA-F]{4}):(?P[0-9a-fA-F]{4})(?:\s+(?P.+))?\])?\s*$" +) + + +class UhubctlError(RuntimeError): + """Raised on uhubctl-specific failures: parse errors, permission denied, + hub-not-found, or PPPS not supported.""" + + +# ---------- Role → VID map ------------------------------------------------- + +# Mirrors the default hub_profile in `mcp-server/tests/conftest.py:335`. +# Note: esp32s3 and esp32s3_alt share a logical role — we search both. +ROLE_VIDS: dict[str, tuple[int, ...]] = { + "nrf52": (0x239A,), + "esp32s3": (0x303A, 0x10C4), +} + + +def _normalize_role(role: str) -> str: + """Collapse `esp32s3_alt` → `esp32s3` to match the tier conventions.""" + return role.split("_alt", 1)[0].lower() + + +# ---------- Core subprocess runner ----------------------------------------- + + +# If uhubctl hits a permission problem — most commonly Linux without the +# udev rules, or a macOS variant where the kernel holds the hub driver — +# it prints something like "Permission denied. Try running as root". +# Linux error text varies; we match a broad substring rather than exact. +_PERM_ERROR_PATTERNS = ( + "permission denied", + "operation not permitted", + "try running as root", + "need root", + "requires root", +) + + +def _run_uhubctl(args: Sequence[str], *, timeout: float = 30.0) -> dict[str, Any]: + """Invoke uhubctl with the given args. Returns `hw_tools._run`'s dict. + + Translates permission-denied failures into a `UhubctlError` with the + install hint, so callers don't have to match stderr themselves. Other + non-zero exits are returned as-is for the caller to interpret. + """ + binary = config.uhubctl_bin() + result = hw_tools._run(binary, args, timeout=timeout) # noqa: SLF001 + if result["exit_code"] != 0: + combined = (result.get("stderr") or "") + "\n" + (result.get("stdout") or "") + lower = combined.lower() + if any(pat in lower for pat in _PERM_ERROR_PATTERNS): + raise UhubctlError( + "uhubctl exited with a permission error. Install the udev " + "rules on Linux, or try `sudo` as a fallback: " + "https://github.com/mvp/uhubctl#linux-usb-permissions\n" + f"stderr: {result.get('stderr_tail')!r}" + ) + return result + + +# ---------- List / parse --------------------------------------------------- + + +def parse_list_output(output: str) -> list[dict[str, Any]]: + """Parse the default `uhubctl` stdout into structured hubs. + + Each hub: { + "location": "1-1.3", + "descriptor": "2109:2817 VIA Labs ...", + "vid": 0x2109, + "pid": 0x2817, + "ppps": bool, + "ports": [{"port": int, "status": str, "flags": str, + "device_vid": int | None, "device_pid": int | None, + "device_desc": str | None}, ...], + } + """ + hubs: list[dict[str, Any]] = [] + current: dict[str, Any] | None = None + + for line in output.splitlines(): + hm = _HUB_RE.match(line) + if hm: + descriptor = hm.group("descriptor") + hub_vid, hub_pid = None, None + vid_match = re.match(r"([0-9a-fA-F]{4}):([0-9a-fA-F]{4})", descriptor) + if vid_match: + hub_vid = int(vid_match.group(1), 16) + hub_pid = int(vid_match.group(2), 16) + current = { + "location": hm.group("location"), + "descriptor": descriptor, + "vid": hub_vid, + "pid": hub_pid, + "ppps": ", ppps" in descriptor or descriptor.endswith("ppps"), + "ports": [], + } + hubs.append(current) + continue + + pm = _PORT_RE.match(line) + if pm and current is not None: + device_vid = pm.group("device_vid") + device_pid = pm.group("device_pid") + current["ports"].append( + { + "port": int(pm.group("port")), + "status": pm.group("status"), + "flags": (pm.group("flags") or "").strip(), + "device_vid": int(device_vid, 16) if device_vid else None, + "device_pid": int(device_pid, 16) if device_pid else None, + "device_desc": (pm.group("device_desc") or "").strip() or None, + } + ) + return hubs + + +def list_hubs() -> list[dict[str, Any]]: + """Enumerate every hub uhubctl can see, with per-port device attachments. + + Pure read — no power state changes. Useful as a pre-flight check before + a destructive `power_off` call. + """ + result = _run_uhubctl([], timeout=15.0) + if result["exit_code"] != 0: + raise UhubctlError( + f"uhubctl list failed (exit {result['exit_code']}): {result.get('stderr_tail')!r}" + ) + return parse_list_output(result["stdout"]) + + +# ---------- Lookup / resolution ------------------------------------------- + + +def find_port_for_vid( + vid: int, pid: int | None = None, *, only_ppps: bool = True +) -> list[tuple[str, int]]: + """Return ALL (location, port) matches for a device VID (optionally +PID). + + `only_ppps=True` filters out hubs that don't advertise PPPS — we can't + control them anyway. Callers that want to diagnose a missing device can + pass `only_ppps=False` to see if the device is on a non-controllable + hub (and raise a clearer error). + """ + hubs = list_hubs() + matches: list[tuple[str, int]] = [] + for hub in hubs: + if only_ppps and not hub["ppps"]: + continue + for port in hub["ports"]: + if port["device_vid"] != vid: + continue + if pid is not None and port["device_pid"] != pid: + continue + matches.append((hub["location"], port["port"])) + return matches + + +def resolve_target(role: str) -> tuple[str, int]: + """Resolve a Meshtastic role to (hub_location, port_number). + + Priority: + 1. Env vars `MESHTASTIC_UHUBCTL_LOCATION_` + `_PORT_` + (e.g. `MESHTASTIC_UHUBCTL_LOCATION_NRF52=1-1.3`, `_PORT_NRF52=2`). + 2. VID auto-detect against `ROLE_VIDS[role]`, taking the first PPPS + match. + + Raises `UhubctlError` on ambiguity (multiple matches) or no-match. The + env-var path exists specifically to disambiguate when two devices share + a VID. + """ + role = _normalize_role(role) + env_key_loc = f"MESHTASTIC_UHUBCTL_LOCATION_{role.upper()}" + env_key_port = f"MESHTASTIC_UHUBCTL_PORT_{role.upper()}" + loc = os.environ.get(env_key_loc) + port_str = os.environ.get(env_key_port) + if loc and port_str: + try: + return (loc, int(port_str)) + except ValueError as exc: + raise UhubctlError( + f"{env_key_port}={port_str!r} is not a valid integer" + ) from exc + + if role not in ROLE_VIDS: + raise UhubctlError( + f"unknown role {role!r}; known roles: {sorted(ROLE_VIDS)}. " + f"Set {env_key_loc} + {env_key_port} to pin manually." + ) + + matches: list[tuple[str, int]] = [] + for vid in ROLE_VIDS[role]: + matches.extend(find_port_for_vid(vid)) + + if not matches: + vids = ", ".join(f"0x{v:04x}" for v in ROLE_VIDS[role]) + raise UhubctlError( + f"no controllable hub hosts a device with VID in {{{vids}}} " + f"for role={role!r}. Check the device is plugged into a " + f"PPPS-capable hub, or pin manually via {env_key_loc} + {env_key_port}." + ) + if len(matches) > 1: + shown = ", ".join(f"{loc}:port{p}" for loc, p in matches) + raise UhubctlError( + f"ambiguous: multiple devices match role={role!r} ({shown}). " + f"Pin the target via {env_key_loc} + {env_key_port}." + ) + return matches[0] + + +# ---------- Power actions -------------------------------------------------- + + +def _action( + action: str, + location: str, + port: int, + *, + delay_s: int | None = None, + timeout: float = 30.0, +) -> dict[str, Any]: + args: list[str] = ["-a", action, "-l", location, "-p", str(port)] + if delay_s is not None: + args.extend(["-d", str(delay_s)]) + # Suppress verbose "before" printout so our parser doesn't have to skip it. + args.append("-N") + result = _run_uhubctl(args, timeout=timeout) + if result["exit_code"] != 0: + raise UhubctlError( + f"uhubctl -a {action} -l {location} -p {port} failed " + f"(exit {result['exit_code']}): {result.get('stderr_tail')!r}" + ) + return { + "action": action, + "location": location, + "port": port, + "delay_s": delay_s, + "duration_s": result["duration_s"], + } + + +def power_on(location: str, port: int) -> dict[str, Any]: + """Drive the port VBUS high. Device re-enumerates in 1-3 s on healthy hubs.""" + return _action("on", location, port) + + +def power_off(location: str, port: int) -> dict[str, Any]: + """Drive the port VBUS low. Device disappears from `list_devices` immediately.""" + return _action("off", location, port) + + +def cycle(location: str, port: int, delay_s: int = 2) -> dict[str, Any]: + """Off → wait `delay_s` → on. The common hard-reset pattern.""" + # uhubctl's own `-a cycle` handles the delay internally; we use a + # slightly longer timeout to accommodate delay_s + enumeration. + return _action("cycle", location, port, delay_s=delay_s, timeout=30.0 + delay_s * 2) + + +__all__ = [ + "ROLE_VIDS", + "UhubctlError", + "cycle", + "find_port_for_vid", + "list_hubs", + "parse_list_output", + "power_off", + "power_on", + "resolve_target", +] diff --git a/mcp-server/src/meshtastic_mcp/userprefs.py b/mcp-server/src/meshtastic_mcp/userprefs.py index 59d7165f9..d5f8bab69 100644 --- a/mcp-server/src/meshtastic_mcp/userprefs.py +++ b/mcp-server/src/meshtastic_mcp/userprefs.py @@ -393,6 +393,7 @@ def build_testing_profile( long_name: str | None = None, disable_mqtt: bool = True, disable_position: bool = False, + enable_ui_log: bool = False, ) -> dict[str, Any]: """Build a USERPREFS dict for an isolated test-mesh device. @@ -423,6 +424,10 @@ def build_testing_profile( traffic never leaks to a public broker. disable_position: if True, disables GPS + position broadcasts — useful when test devices sit on a bench without antennas. + enable_ui_log: if True, stamps `USERPREFS_UI_TEST_LOG=true` so the + firmware emits one `Screen: frame N/M name=... reason=...` log + line per frame transition. Test-only; off by default because the + log is chatty (multiple times per second during UI interaction). """ if region not in KNOWN_REGIONS: @@ -475,6 +480,9 @@ def build_testing_profile( prefs["USERPREFS_CONFIG_OWNER_LONG_NAME"] = long_name if short_name is not None: prefs["USERPREFS_CONFIG_OWNER_SHORT_NAME"] = short_name + if enable_ui_log: + # Consumed by `#ifdef USERPREFS_UI_TEST_LOG` in src/graphics/Screen.cpp. + prefs["USERPREFS_UI_TEST_LOG"] = True return prefs diff --git a/mcp-server/tests/_power.py b/mcp-server/tests/_power.py new file mode 100644 index 000000000..0542bbed3 --- /dev/null +++ b/mcp-server/tests/_power.py @@ -0,0 +1,112 @@ +"""USB hub power control for tests — thin composition of the `uhubctl` +module + `_port_discovery.resolve_port_by_role`. + +Why separate from the production module: +- `meshtastic_mcp.uhubctl.cycle` returns as soon as uhubctl exits (VBUS is + back on, but the device hasn't finished enumerating as a CDC port yet). +- Tests that want to immediately issue a `connect(port=...)` need the NEW + `/dev/cu.*` path, which can differ from the pre-cycle path on nRF52 + boards (CDC re-enumeration assigns a fresh `cu.usbmodemNNNN`). +- `resolve_port_by_role` already handles that wait + path-resolution for + the `factory_reset` flow. Composing the two gives a one-call helper. + +Also exposes `is_uhubctl_available()` so fixtures can skip cleanly when +uhubctl isn't installed — we never want "no uhubctl" to look like a test +failure. +""" + +from __future__ import annotations + +import time +from typing import Any + +from meshtastic_mcp import config as config_mod +from meshtastic_mcp import uhubctl as uhubctl_mod + +from ._port_discovery import resolve_port_by_role + + +def is_uhubctl_available() -> bool: + """Return True iff `config.uhubctl_bin()` resolves AND the binary is callable. + + Soft-fails silently — fixtures use this to `pytest.skip` with an + actionable message when the operator hasn't installed uhubctl. + """ + try: + config_mod.uhubctl_bin() + except Exception: # noqa: BLE001 + return False + # Do NOT actually invoke uhubctl here — on macOS a non-sudo run would + # fail, which is a config issue, not a tool-missing issue. That gets + # surfaced to the user when they actually run a recovery action. + return True + + +def power_on(role: str) -> dict[str, Any]: + """Power on the hub port hosting `role`. Does NOT wait for re-enumeration. + Use `power_cycle` or follow with `resolve_port_by_role` to block on readiness. + """ + loc, port = uhubctl_mod.resolve_target(role) + return uhubctl_mod.power_on(loc, port) + + +def power_off(role: str) -> dict[str, Any]: + """Power off the hub port hosting `role`. The device disappears from + `list_devices` immediately. + """ + loc, port = uhubctl_mod.resolve_target(role) + return uhubctl_mod.power_off(loc, port) + + +def power_cycle( + role: str, + *, + delay_s: int = 2, + rediscover_timeout_s: float = 30.0, +) -> str: + """Cycle the port hosting `role`, wait for re-enumeration, return the + new port path. + + On nRF52 the post-cycle path typically matches the pre-cycle path, but + macOS may assign a different `/dev/cu.usbmodemNNNN` if the previous + CDC endpoint hasn't been fully released. `resolve_port_by_role` + handles that transparently. + """ + loc, port = uhubctl_mod.resolve_target(role) + uhubctl_mod.cycle(loc, port, delay_s=delay_s) + # After uhubctl exits, VBUS is on but the device may still be in + # bootloader init. Give it ~500 ms head-start before polling so we + # don't spam list_devices pointlessly. + time.sleep(0.5) + return resolve_port_by_role(role, timeout_s=rediscover_timeout_s) + + +def wait_for_absence(role: str, *, timeout_s: float = 10.0) -> None: + """Block until a device matching `role` is NOT in `list_devices`. + + Used by the recovery tier to assert power_off actually took effect. + Raises TimeoutError on failure. + """ + from meshtastic_mcp import devices as devices_mod + + from ._port_discovery import _ROLE_VIDS, _coerce_vid # type: ignore[attr-defined] + + if role not in _ROLE_VIDS: + raise ValueError(f"unknown role {role!r}") + wanted = _ROLE_VIDS[role] + deadline = time.monotonic() + timeout_s + while time.monotonic() < deadline: + found = devices_mod.list_devices(include_unknown=True) + if not any(_coerce_vid(d.get("vid")) in wanted for d in found): + return + time.sleep(0.3) + raise TimeoutError(f"role {role!r} still visible after {timeout_s}s of power_off") + + +__all__ = [ + "is_uhubctl_available", + "power_cycle", + "power_off", + "power_on", + "wait_for_absence", +] diff --git a/mcp-server/tests/conftest.py b/mcp-server/tests/conftest.py index 3d033b9b8..d4607b239 100644 --- a/mcp-server/tests/conftest.py +++ b/mcp-server/tests/conftest.py @@ -123,15 +123,24 @@ def pytest_collection_modifyitems( return (2, item.nodeid) if "/monitor/" in path or "tests/monitor" in path: return (3, item.nodeid) - if "/fleet/" in path or "tests/fleet" in path: + # Recovery tier: explicitly cycles device power via uhubctl. Slots + # between monitor (read-only) and ui (state-preserving) so any tier + # after it starts from a known re-enumerated + re-verified state. + if "/recovery/" in path or "tests/recovery" in path: return (4, item.nodeid) + # UI tier slots here — read-only w.r.t. mesh state, only mutates + # the on-screen UI (BACK×5 guard restores home before each test). + if "/ui/" in path or "tests/ui" in path: + return (5, item.nodeid) + if "/fleet/" in path or "tests/fleet" in path: + return (6, item.nodeid) # State-mutating tiers run last. if "/admin/" in path or "tests/admin" in path: - return (5, item.nodeid) + return (7, item.nodeid) if "/provisioning/" in path or "tests/provisioning" in path: - return (6, item.nodeid) + return (8, item.nodeid) # Top-level + anything else falls between. - return (7, item.nodeid) + return (9, item.nodeid) items.sort(key=sort_key) @@ -156,13 +165,20 @@ def session_seed(request: pytest.FixtureRequest) -> str: @pytest.fixture(scope="session") def test_profile(session_seed: str) -> dict[str, Any]: - """The canonical isolated-mesh test profile for this session.""" + """The canonical isolated-mesh test profile for this session. + + `enable_ui_log=True` stamps `USERPREFS_UI_TEST_LOG` so the firmware + emits `Screen: frame N/M name=... reason=...` log lines per UI + transition — consumed by the `tests/ui/` tier. Harmless on boards + without a screen (the `#ifdef` sits behind `HAS_SCREEN`). + """ return userprefs.build_testing_profile( psk_seed=session_seed, channel_name="McpTest", channel_num=88, region="US", modem_preset="LONG_FAST", + enable_ui_log=True, ) @@ -654,6 +670,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: def baked_single( baked_mesh: dict[str, Any], baked_single_role: str, + hub_devices: dict[str, str], ) -> dict[str, Any]: """Function-scoped: a single verified baked device. @@ -662,10 +679,75 @@ def baked_single( (e.g. `test_owner_survives_reboot[nrf52]` + `test_owner_survives_reboot[esp32s3]`). Tests never hardcode a role and never skip a device that happens to be connected. + + Auto-recovery: if the baked device fails a pre-test `device_info` probe + AND uhubctl is available, power-cycle the port once and retry. Without + uhubctl, surface the wedge as a clear skip. This catches "device got + stuck between tests" without masking persistent regressions (a second + wedge after cycling still skips). """ if baked_single_role not in baked_mesh: pytest.skip(f"role {baked_single_role!r} not present on the hub") - return {"role": baked_single_role, **baked_mesh[baked_single_role]} + + entry = baked_mesh[baked_single_role] + port = entry.get("port") + if port: + try: + _run_with_timeout(lambda: info.device_info(port=port, timeout_s=3.0), 5.0) + except Exception: + # Device didn't respond. Try a power-cycle recovery if uhubctl + # is installed; otherwise surface a skip that names the root + # cause clearly. + from tests import _power + + if not _power.is_uhubctl_available(): + pytest.skip( + f"device {baked_single_role!r} unresponsive on {port}; " + "install uhubctl (`brew install uhubctl` / `apt install " + "uhubctl`) for auto power-cycle recovery" + ) + try: + new_port = _power.power_cycle(baked_single_role, delay_s=2) + except Exception as exc: # noqa: BLE001 + pytest.skip( + f"device {baked_single_role!r} wedged and power-cycle " + f"failed: {exc}" + ) + # Mutate both the session-scoped `hub_devices` map AND the + # baked_mesh entry so downstream fixtures see the recovered port. + hub_devices[baked_single_role] = new_port + baked_mesh[baked_single_role]["port"] = new_port + entry = baked_mesh[baked_single_role] + return {"role": baked_single_role, **entry} + + +@pytest.fixture +def power_cycle( + hub_devices: dict[str, str], +) -> Callable[..., str]: + """Return a callable `(role, delay_s=2) -> new_port` that hard-resets the + hub port hosting `role`. Skips the test cleanly when uhubctl isn't + installed — never want "no uhubctl" to look like a test failure. + + The callable mutates `hub_devices[role]` in place so subsequent fixture + lookups pick up the post-cycle port (mirrors the pattern in + provisioning/test_userprefs_survive_factory_reset.py). + """ + from tests import _power + + if not _power.is_uhubctl_available(): + pytest.skip( + "uhubctl not installed; this test needs it for power control. " + "Install via `brew install uhubctl` (macOS) or `apt install " + "uhubctl` (Debian/Ubuntu)." + ) + + def _cycle(role: str, delay_s: int = 2) -> str: + new_port = _power.power_cycle(role, delay_s=delay_s) + hub_devices[role] = new_port + return new_port + + return _cycle _DEFAULT_ROLE_ENVS = { @@ -960,6 +1042,45 @@ def _run_with_timeout(fn: Callable[[], Any], timeout: float) -> Any: raise TimeoutError(f"operation did not complete within {timeout}s") from exc +def _attach_ui_captures(item: pytest.Item, report: Any) -> None: + """Embed per-step UI captures (PNG + OCR) into the pytest-html extras. + + Runs for every UI-tier test on BOTH pass and fail so the HTML report + always shows the image strip + OCR transcript. Silently no-ops if + pytest-html isn't installed or the test didn't use `frame_capture`. + """ + captures = getattr(item, "_ui_captures", None) + if not captures: + return + try: + from pytest_html import extras as html_extras # type: ignore[import-untyped] + except ImportError: + return + + existing = getattr(report, "extras", None) or [] + extras_list = list(existing) + for cap in captures: + png_path = cap.get("png_path") + label = f"{cap.get('step', '?')}: {cap.get('label', '')}" + frame = cap.get("frame") or {} + frame_str = ( + f" — frame {frame.get('idx')} {frame.get('name')!r}" if frame else "" + ) + if png_path: + try: + with open(png_path, "rb") as fh: + import base64 + + b64 = base64.b64encode(fh.read()).decode("ascii") + extras_list.append(html_extras.png(b64, name=f"{label}{frame_str}")) + except OSError: + pass + ocr = (cap.get("ocr_text") or "").strip() + if ocr: + extras_list.append(html_extras.text(ocr, name=f"OCR: {label}{frame_str}")) + report.extras = extras_list # type: ignore[attr-defined] + + @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo[Any]) -> Any: """On test failure, attach serial capture + device state as report artifacts. @@ -967,10 +1088,20 @@ def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo[Any]) -> Hard-bounded by `_run_with_timeout` — if the device is unreachable (stuck port, unbaked firmware, dead board), the dump is skipped rather than hanging the session. + + For UI-tier tests, also embeds per-step camera captures + OCR on every + test (pass or fail) so the HTML report shows visual evidence of what + the device did. """ outcome = yield report = outcome.get_result() + # Attach UI captures on any outcome (pass + fail) — these are the whole + # point of the UI tier. Do this before the failure-only branch below so + # passing tests still get their image strip. + if report.when == "call": + _attach_ui_captures(item, report) + if report.when != "call" or report.outcome != "failed": return diff --git a/mcp-server/tests/mesh/test_peer_offline_recovery.py b/mcp-server/tests/mesh/test_peer_offline_recovery.py new file mode 100644 index 000000000..b8d0f7a63 --- /dev/null +++ b/mcp-server/tests/mesh/test_peer_offline_recovery.py @@ -0,0 +1,155 @@ +"""Isolation test for peer-offline-then-back mid-conversation. + +Verifies the mesh stack's behavior when a peer is physically powered +off mid-send via uhubctl, then powered back on. + +Flow (parametrized over every directed mesh_pair): + 1. Bilateral PKI warmup (same pattern as test_direct_with_ack). + 2. TX sends a broadcast text "msg-1" — RX confirms receipt via pubsub. + 3. Power OFF RX via uhubctl. The RX device disappears from the OS. + 4. TX sends a directed text "msg-2" with wantAck=True. Firmware retries + internally for ~30s before giving up. Assertion: the packet object + was accepted by the TX stack (non-None) — we don't assert an ACK + since there's no peer to send one. + 5. Power ON RX. Wait for re-enumeration + boot. + 6. Bilateral PKI re-nudge — RX's in-RAM PKI cache was wiped on reboot, + so the first directed send may err=35 without a fresh NodeInfo ping. + 7. TX sends a directed "msg-3" — RX receives it via pubsub, confirming + the mesh recovered. + +Skips cleanly if uhubctl isn't installed (via the `power_cycle` fixture's +auto-skip). Skips for pair directions where RX isn't power-controllable +(e.g. a USB-IF hub that doesn't support PPPS for its port). +""" + +from __future__ import annotations + +import time +from typing import Any + +import pytest +from meshtastic_mcp.connection import connect +from tests import _power +from tests._port_discovery import resolve_port_by_role + +from ._receive import ReceiveCollector, nudge_nodeinfo + + +@pytest.mark.timeout(360) +def test_peer_offline_then_recovers( + mesh_pair: dict[str, Any], + power_cycle, # noqa: ARG001 — forces uhubctl-availability skip + hub_devices: dict[str, str], +) -> None: + tx_port = mesh_pair["tx"]["port"] + rx_node_num = mesh_pair["rx"]["my_node_num"] + tx_role = mesh_pair["tx_role"] + rx_role = mesh_pair["rx_role"] + + unique_pre = f"peer-offline-pre-{tx_role}-to-{rx_role}-{int(time.time())}" + unique_post = f"peer-offline-post-{tx_role}-to-{rx_role}-{int(time.time())}" + + # Step 1 + 2: warm up + confirm baseline delivery works before the test. + with ReceiveCollector( + mesh_pair["rx"]["port"], topic="meshtastic.receive.text" + ) as rx: + rx.broadcast_nodeinfo_ping() + with connect(port=tx_port) as tx_iface: + nudge_nodeinfo(tx_iface) + # Wait for bilateral PKI (RX pubkey in TX's nodesByNum). + deadline = time.monotonic() + 45.0 + last_nudge = time.monotonic() + while time.monotonic() < deadline: + rec = (tx_iface.nodesByNum or {}).get(rx_node_num, {}) + if rec.get("user", {}).get("publicKey"): + break + if time.monotonic() - last_nudge > 15.0: + rx.broadcast_nodeinfo_ping() + nudge_nodeinfo(tx_iface) + last_nudge = time.monotonic() + time.sleep(1.0) + else: + pytest.skip( + f"bilateral PKI never completed ({tx_role}→{rx_role}); " + "can't run the offline test without a warm baseline" + ) + + tx_iface.sendText(unique_pre, destinationId=rx_node_num, wantAck=True) + got = rx.wait_for( + lambda pkt: pkt.get("decoded", {}).get("text") == unique_pre, + timeout=30, + ) + assert got is not None, ( + f"baseline directed send ({tx_role}→{rx_role}) didn't land — " + "skipping offline test to avoid false positive" + ) + + # Step 3: power off RX. uhubctl skips the test with a clear message if + # the RX role isn't on a controllable hub. + try: + _power.power_off(rx_role) + except Exception as exc: # noqa: BLE001 + pytest.skip(f"can't power-control {rx_role!r}: {exc}") + + try: + _power.wait_for_absence(rx_role, timeout_s=10.0) + except TimeoutError: + _power.power_on(rx_role) # restore hub state before failing + resolve_port_by_role(rx_role, timeout_s=30.0) + pytest.fail(f"{rx_role!r} didn't disappear after power_off") + + # Step 4: send to a peer that isn't there. Firmware will retry + # internally. We don't wait for an ACK (there won't be one); we just + # confirm TX's stack accepts the packet without crashing. + try: + with connect(port=tx_port) as tx_iface: + packet = tx_iface.sendText( + f"while-offline-{rx_role}", + destinationId=rx_node_num, + wantAck=True, + ) + assert packet is not None + # Give firmware a moment to do a retry or two while RX is down. + time.sleep(5.0) + except Exception as exc: # noqa: BLE001 — TX should survive the peer being gone + # Restore RX before reraising so the bench state is sane. + _power.power_on(rx_role) + resolve_port_by_role(rx_role, timeout_s=30.0) + raise AssertionError(f"TX crashed when sending to offline peer: {exc}") from exc + + # Step 5: power RX back on + rediscover. + _power.power_on(rx_role) + time.sleep(0.5) + new_rx_port = resolve_port_by_role(rx_role, timeout_s=30.0) + hub_devices[rx_role] = new_rx_port + + # Step 6 + 7: bilateral re-warmup + directed send that should now work. + with ReceiveCollector(new_rx_port, topic="meshtastic.receive.text") as rx: + # RX rebooted → its PKI cache is gone. Re-warm. + rx.broadcast_nodeinfo_ping() + with connect(port=tx_port) as tx_iface: + nudge_nodeinfo(tx_iface) + time.sleep(3.0) + + got = None + for _attempt in range(3): + packet = tx_iface.sendText( + unique_post, + destinationId=rx_node_num, + wantAck=True, + ) + assert packet is not None + got = rx.wait_for( + lambda pkt: pkt.get("decoded", {}).get("text") == unique_post, + timeout=30, + ) + if got is not None: + break + rx.broadcast_nodeinfo_ping() + nudge_nodeinfo(tx_iface) + time.sleep(5.0) + + assert got is not None, ( + f"post-recovery directed send {unique_post!r} ({tx_role}→{rx_role}) " + "never landed — recovery path may be broken" + ) diff --git a/mcp-server/tests/recovery/__init__.py b/mcp-server/tests/recovery/__init__.py new file mode 100644 index 000000000..cf8f3919e --- /dev/null +++ b/mcp-server/tests/recovery/__init__.py @@ -0,0 +1,6 @@ +"""Recovery tier — exercises `uhubctl` power control end-to-end. + +Requires `uhubctl` installed AND at least one connected device on a +PPPS-capable hub. The whole tier skips cleanly via +`tests/recovery/conftest.py::_recovery_tier_guard` when either is missing. +""" diff --git a/mcp-server/tests/recovery/conftest.py b/mcp-server/tests/recovery/conftest.py new file mode 100644 index 000000000..21116d07a --- /dev/null +++ b/mcp-server/tests/recovery/conftest.py @@ -0,0 +1,44 @@ +"""Recovery-tier gating + shared helpers. + +Session-scoped guard skips the whole tier when uhubctl isn't installed. +Tests under this directory assume uhubctl is callable AND that at least +one hub role is detected on a PPPS-capable port. +""" + +from __future__ import annotations + +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def _recovery_tier_guard() -> None: + """Skip the tier when uhubctl is unavailable OR no device is on a + PPPS-capable hub. Prints the specific reason so operators know what + to fix.""" + from tests import _power + + if not _power.is_uhubctl_available(): + pytest.skip( + "uhubctl not installed; recovery tier needs it. " + "Install via `brew install uhubctl` or `apt install uhubctl`.", + allow_module_level=True, + ) + + # Probe: can we even list hubs? (A macOS user without sudo gets a + # permission error here — we'd rather find out once at tier-start than + # 6 tests later.) + from meshtastic_mcp import uhubctl + + try: + hubs = uhubctl.list_hubs() + except uhubctl.UhubctlError as exc: + pytest.skip( + f"uhubctl list failed: {exc}. Try the udev rules or `sudo` as a fallback.", + allow_module_level=True, + ) + + if not any(h["ppps"] for h in hubs): + pytest.skip( + "no PPPS-capable hubs detected — recovery tier has nothing to exercise.", + allow_module_level=True, + ) diff --git a/mcp-server/tests/recovery/test_list_hubs.py b/mcp-server/tests/recovery/test_list_hubs.py new file mode 100644 index 000000000..0a09a672a --- /dev/null +++ b/mcp-server/tests/recovery/test_list_hubs.py @@ -0,0 +1,43 @@ +"""Smoke test: `uhubctl_list` returns a well-formed structure. + +No destructive action. Runs first in the tier as a sanity check that the +tier's dependencies (uhubctl binary + permissions) are actually satisfied. +""" + +from __future__ import annotations + +import pytest +from meshtastic_mcp import uhubctl + + +@pytest.mark.timeout(30) +def test_list_hubs_returns_at_least_one_ppps_hub() -> None: + hubs = uhubctl.list_hubs() + assert hubs, "uhubctl found no hubs at all — is a USB hub connected?" + assert any(h["ppps"] for h in hubs), ( + "no PPPS-capable hubs detected; power control won't work. " + "Check that the hub supports Per-Port Power Switching." + ) + + +@pytest.mark.timeout(30) +def test_list_hubs_structure(hub_devices: dict[str, str]) -> None: + hubs = uhubctl.list_hubs() + for hub in hubs: + assert "location" in hub and hub["location"] + assert "ports" in hub and isinstance(hub["ports"], list) + for port in hub["ports"]: + assert "port" in port and isinstance(port["port"], int) + assert "status" in port + + # At least one of the detected Meshtastic roles should show up in some + # port's device_vid — otherwise the recovery tier can't drive them. + seen_vids = { + p["device_vid"] for h in hubs for p in h["ports"] if p["device_vid"] is not None + } + expected_any = {0x239A, 0x303A, 0x10C4} & seen_vids + assert expected_any or not hub_devices, ( + f"hub_devices detected roles {list(hub_devices)} but uhubctl sees " + f"VIDs {sorted(hex(v) for v in seen_vids)} — the devices may be on " + "a hub that uhubctl can't see (e.g. built-in laptop ports)." + ) diff --git a/mcp-server/tests/recovery/test_power_cycle_preserves_userprefs.py b/mcp-server/tests/recovery/test_power_cycle_preserves_userprefs.py new file mode 100644 index 000000000..9558a7fb4 --- /dev/null +++ b/mcp-server/tests/recovery/test_power_cycle_preserves_userprefs.py @@ -0,0 +1,60 @@ +"""Hard reset via uhubctl must NOT wipe NVS. Verify the test profile's +region + channel survive a power-cycle. + +Guards against a regression where a firmware change treats unexpected +power loss as a factory-reset trigger (e.g. bad EEPROM wear-leveling, +erase-on-boot-for-safety). Such a regression would be catastrophic for +field deployments. +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp import admin, info +from tests import _power +from tests._port_discovery import resolve_port_by_role + + +@pytest.mark.timeout(180) +def test_lora_config_survives_power_cycle( + baked_single: dict[str, object], + test_profile: dict[str, object], +) -> None: + role = baked_single["role"] + pre_port = baked_single["port"] + + pre_config = admin.get_config(section="lora", port=pre_port)["config"]["lora"] + pre_region = pre_config.get("region") + pre_preset = pre_config.get("modem_preset") + assert pre_region, f"lora.region not set pre-cycle on {role}" + + # Hard power-cycle. + _power.power_cycle(role, delay_s=2) + time.sleep(0.5) + new_port = resolve_port_by_role(role, timeout_s=30.0) + # Let the firmware complete boot before admin reads. + time.sleep(2.0) + # Quick readiness probe. + probe = info.device_info(port=new_port, timeout_s=10.0) + assert ( + probe.get("my_node_num") is not None + ), f"device {role!r} didn't respond after power-cycle" + + post_config = admin.get_config(section="lora", port=new_port)["config"]["lora"] + post_region = post_config.get("region") + post_preset = post_config.get("modem_preset") + + assert post_region == pre_region, ( + f"lora.region wiped by power-cycle on {role}: " + f"pre={pre_region!r} post={post_region!r}" + ) + assert post_preset == pre_preset, ( + f"lora.modem_preset wiped by power-cycle on {role}: " + f"pre={pre_preset!r} post={post_preset!r}" + ) + + # Channel-0 name should also match the test profile. + pri_ch = admin.get_channel_url(port=new_port) + assert pri_ch.get("url"), f"channel URL empty after power-cycle on {role}" diff --git a/mcp-server/tests/recovery/test_power_cycle_roundtrip.py b/mcp-server/tests/recovery/test_power_cycle_roundtrip.py new file mode 100644 index 000000000..37bc7c8d2 --- /dev/null +++ b/mcp-server/tests/recovery/test_power_cycle_roundtrip.py @@ -0,0 +1,61 @@ +"""Full power-cycle round-trip: off → verify gone → on → verify identity +preserved. + +Parametrized over every connected role. Validates both the uhubctl +plumbing AND that the device survives a hard reset with the same +`my_node_num` (no firmware-level identity regeneration). +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp import info +from tests import _power +from tests._port_discovery import resolve_port_by_role + + +@pytest.mark.timeout(180) +def test_power_cycle_preserves_node_identity( + baked_single: dict[str, object], +) -> None: + role = baked_single["role"] + pre_port = baked_single["port"] + pre_node_num = baked_single["my_node_num"] + pre_fw = baked_single.get("firmware_version") + + # Record pre-cycle state. + pre_info = info.device_info(port=pre_port, timeout_s=5.0) + assert pre_info.get("my_node_num") == pre_node_num + + # Power off; confirm the device actually disappears from list_devices. + _power.power_off(role) + try: + _power.wait_for_absence(role, timeout_s=10.0) + except TimeoutError: + # If it didn't disappear, power it back on so we don't leave the + # hub in a weird state for the next test. + _power.power_on(role) + resolve_port_by_role(role, timeout_s=30.0) + pytest.fail(f"device {role!r} stayed visible after power_off") + + # Power back on + re-discover port. + _power.power_on(role) + time.sleep(0.5) # head-start before polling + new_port = resolve_port_by_role(role, timeout_s=30.0) + + # Give the firmware a moment to finish boot before we hit it with admin. + time.sleep(2.0) + + post_info = info.device_info(port=new_port, timeout_s=10.0) + assert post_info.get("my_node_num") == pre_node_num, ( + f"my_node_num changed across power-cycle: pre={pre_node_num:#x} " + f"post={post_info.get('my_node_num'):#x}" + ) + # Firmware version must match (same bake, not a re-flash). + if pre_fw: + assert post_info.get("firmware_version") == pre_fw, ( + f"firmware changed across cycle: pre={pre_fw} " + f"post={post_info.get('firmware_version')}" + ) diff --git a/mcp-server/tests/tool_coverage.py b/mcp-server/tests/tool_coverage.py index b91bd4039..edf974e03 100644 --- a/mcp-server/tests/tool_coverage.py +++ b/mcp-server/tests/tool_coverage.py @@ -73,6 +73,13 @@ _TOOL_MAP: dict[str, tuple[str, str]] = { "reboot": ("meshtastic_mcp.admin", "reboot"), "shutdown": ("meshtastic_mcp.admin", "shutdown"), "factory_reset": ("meshtastic_mcp.admin", "factory_reset"), + "send_input_event": ("meshtastic_mcp.admin", "send_input_event"), + # `capture_screen` in server.py calls camera.get_camera — instrument that. + "capture_screen": ("meshtastic_mcp.camera", "get_camera"), + # USB power control via uhubctl. + "uhubctl_list": ("meshtastic_mcp.uhubctl", "list_hubs"), + "uhubctl_power": ("meshtastic_mcp.uhubctl", "power_on"), + "uhubctl_cycle": ("meshtastic_mcp.uhubctl", "cycle"), # USERPREFS "userprefs_manifest": ("meshtastic_mcp.userprefs", "build_manifest"), "userprefs_get": ("meshtastic_mcp.userprefs", "read_state"), diff --git a/mcp-server/tests/ui/__init__.py b/mcp-server/tests/ui/__init__.py new file mode 100644 index 000000000..006fc3c8e --- /dev/null +++ b/mcp-server/tests/ui/__init__.py @@ -0,0 +1,7 @@ +"""UI tier — input-broker-driven screen navigation tests. + +Only runs when a screen-bearing role (esp32s3/heltec-v3) is present on the +hub AND the firmware was baked with `enable_ui_log=True` (so the +`Screen: frame N/M name=... reason=...` log lines are emitted). The +`tests/ui/conftest.py` fixture forces that bake stamp. +""" diff --git a/mcp-server/tests/ui/_screen_log.py b/mcp-server/tests/ui/_screen_log.py new file mode 100644 index 000000000..97954db48 --- /dev/null +++ b/mcp-server/tests/ui/_screen_log.py @@ -0,0 +1,176 @@ +"""Parse `Screen: frame N/M name=X reason=Y` log lines from `_debug_log_buffer`. + +The firmware emits one line per frame transition when +`USERPREFS_UI_TEST_LOG` is defined (see src/graphics/Screen.cpp). Tests use +these helpers to assert which frame is shown / to wait for a transition to +settle before taking a camera capture. +""" + +from __future__ import annotations + +import re +import time +from dataclasses import dataclass +from typing import Iterable, Iterator + +FRAME_RE = re.compile( + r"Screen: frame (?P\d+)/(?P\d+) name=(?P\S+) reason=(?P\S+)" +) + + +@dataclass(frozen=True) +class FrameEvent: + idx: int + count: int + name: str + reason: str + raw: str + + @classmethod + def parse(cls, line: str) -> "FrameEvent | None": + m = FRAME_RE.search(line) + if not m: + return None + return cls( + idx=int(m["idx"]), + count=int(m["count"]), + name=m["name"], + reason=m["reason"], + raw=line, + ) + + +def iter_frame_events(lines: Iterable[str]) -> Iterator[FrameEvent]: + for line in lines: + evt = FrameEvent.parse(line) + if evt is not None: + yield evt + + +def get_current_frame(lines: list[str]) -> FrameEvent | None: + """Return the most recent FrameEvent in `lines`, or None if none found.""" + for line in reversed(lines): + evt = FrameEvent.parse(line) + if evt is not None: + return evt + return None + + +def wait_for_frame( + lines: list[str], + expected_name: str, + *, + timeout_s: float = 5.0, + poll_interval_s: float = 0.1, + reason: str | None = None, +) -> FrameEvent: + """Poll `lines` (the `_debug_log_buffer`) until a FrameEvent with + `name=expected_name` appears after the call started. Raises TimeoutError + with context if it doesn't arrive in `timeout_s`. + + `reason` optionally filters to events matching a specific cause + (e.g. `"fn_f1"`, `"next"`, `"rebuild"`). + """ + start_idx = len(lines) + deadline = time.monotonic() + timeout_s + last: FrameEvent | None = None + while time.monotonic() < deadline: + # Scan only lines appended since we started waiting. + for line in lines[start_idx:]: + evt = FrameEvent.parse(line) + if evt is None: + continue + last = evt + if evt.name == expected_name and (reason is None or evt.reason == reason): + return evt + time.sleep(poll_interval_s) + + seen = [e.name for e in iter_frame_events(lines[start_idx:])] + raise TimeoutError( + f"frame name={expected_name!r} reason={reason!r} not seen in {timeout_s}s; " + f"saw {len(seen)} transition(s): {seen!r}; last={last!r}" + ) + + +def wait_for_any_frame( + lines: list[str], + *, + timeout_s: float = 5.0, + poll_interval_s: float = 0.1, +) -> FrameEvent: + """Wait for ANY frame transition to appear after call-start. Useful for + `no-op` tests that want to confirm a transition did NOT happen (via + TimeoutError) vs. one that did. + """ + start_idx = len(lines) + deadline = time.monotonic() + timeout_s + while time.monotonic() < deadline: + for line in lines[start_idx:]: + evt = FrameEvent.parse(line) + if evt is not None: + return evt + time.sleep(poll_interval_s) + raise TimeoutError(f"no frame transition in {timeout_s}s") + + +def wait_for_reason( + lines: list[str], + reason: str, + *, + timeout_s: float = 5.0, + poll_interval_s: float = 0.1, +) -> FrameEvent: + """Wait for a frame event with `reason=` after call-start. + + Matches only on `reason` — useful when the caller knows *why* a + transition should happen (e.g. `fn_f1`, `rebuild`) but not which named + frame the firmware will land on for this particular board. + """ + start_idx = len(lines) + deadline = time.monotonic() + timeout_s + last: FrameEvent | None = None + while time.monotonic() < deadline: + for line in lines[start_idx:]: + evt = FrameEvent.parse(line) + if evt is None: + continue + last = evt + if evt.reason == reason: + return evt + time.sleep(poll_interval_s) + raise TimeoutError( + f"no frame with reason={reason!r} in {timeout_s}s; last={last!r}" + ) + + +def assert_no_frame_change( + lines: list[str], + *, + wait_s: float = 2.0, +) -> None: + """Assert that NO new FrameEvent lines arrive within `wait_s`. + + Used by idempotency / no-op tests (e.g. BACK on home frame). + """ + start_idx = len(lines) + time.sleep(wait_s) + new = [ + e for e in (FrameEvent.parse(ln) for ln in lines[start_idx:]) if e is not None + ] + if new: + raise AssertionError( + f"expected no frame change in {wait_s}s, but saw {len(new)} event(s): " + f"{[(e.reason, e.name) for e in new]!r}" + ) + + +__all__ = [ + "FRAME_RE", + "FrameEvent", + "assert_no_frame_change", + "get_current_frame", + "iter_frame_events", + "wait_for_any_frame", + "wait_for_frame", + "wait_for_reason", +] diff --git a/mcp-server/tests/ui/conftest.py b/mcp-server/tests/ui/conftest.py new file mode 100644 index 000000000..aedfdbc8f --- /dev/null +++ b/mcp-server/tests/ui/conftest.py @@ -0,0 +1,381 @@ +"""UI-tier fixtures: camera lifecycle, OCR warmup, per-test frame capture, +and a `ui_home_state` autouse guard that resets to the home frame before +every test (prevents state bleed if a prior test exited inside a menu). + +The camera + OCR modules live in `meshtastic_mcp/{camera,ocr}.py` (production +code, so the `capture_screen` MCP tool can share them). These fixtures wire +them into pytest + write per-test captures to `tests/ui_captures/…`. +""" + +from __future__ import annotations + +import re +import shutil +import time +from pathlib import Path +from typing import Any, Iterator + +import pytest +from meshtastic_mcp import admin as admin_mod +from meshtastic_mcp import camera as camera_mod +from meshtastic_mcp import ocr as ocr_mod +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import FrameEvent, get_current_frame, wait_for_frame + +# Roles that carry a screen the UI tier can drive. Only esp32s3 (heltec-v3 +# SSD1306) qualifies today — nrf52 (rak4631) has no display. +UI_CAPABLE_ROLES = ("esp32s3",) + +# Where per-test captures land. One subdirectory per session seed, then per +# sanitized test nodeid — identical pattern to other pytest artifacts. +CAPTURES_ROOT = Path(__file__).resolve().parent.parent / "ui_captures" + + +def _sanitize_nodeid(nodeid: str) -> str: + return re.sub(r"[^a-zA-Z0-9_.-]+", "_", nodeid) + + +# ---------- Role gating ---------------------------------------------------- + + +@pytest.fixture +def ui_capable_role(request: pytest.FixtureRequest, hub_devices: dict[str, Any]) -> str: + """Resolve the single role the UI tier drives. + + Today that's `esp32s3`. Skips if the hub doesn't have one. A future + multi-screen hub could pick a role per parametrization. + """ + for role in UI_CAPABLE_ROLES: + if role in hub_devices: + return role + pytest.skip( + f"no UI-capable role on hub; need one of {UI_CAPABLE_ROLES} in {sorted(hub_devices)}" + ) + + +@pytest.fixture +def ui_port(ui_capable_role: str, hub_devices: dict[str, Any]) -> str: + port = ( + hub_devices[ui_capable_role].get("port") + if isinstance(hub_devices[ui_capable_role], dict) + else hub_devices[ui_capable_role] + ) + if not port: + pytest.skip(f"{ui_capable_role!r} has no usable port") + return port + + +# ---------- Camera + OCR session fixtures --------------------------------- + + +@pytest.fixture(scope="session") +def camera(ui_capable_role_session: str | None) -> Iterator[camera_mod.CameraBackend]: + """Session-scoped camera backend. Closed at teardown. + + Backend + device selected by env vars (see `meshtastic_mcp.camera`). + Falls through to `NullBackend` when no camera is configured, so the + tests run end-to-end on machines without hardware; they just won't + have useful images. + """ + role = ui_capable_role_session or "esp32s3" + cam = camera_mod.get_camera(role) + try: + yield cam + finally: + cam.close() + + +@pytest.fixture(scope="session") +def ui_capable_role_session(hub_devices: dict[str, Any]) -> str | None: + """Session-scoped lookup mirroring `ui_capable_role` but non-skipping. + + Used by the `camera` session fixture so it doesn't depend on a + test-scoped skip. + """ + for role in UI_CAPABLE_ROLES: + if role in hub_devices: + return role + return None + + +@pytest.fixture(scope="session", autouse=True) +def _ocr_warm() -> None: + """Pay easyocr's ~100 MB / cold-start cost ONCE per session. + + Subsequent `ocr_text()` calls hit the cached reader and return quickly. + Swallows errors — if OCR isn't installed, warm is a no-op. + """ + try: + ocr_mod.warm() + except Exception: # noqa: BLE001 — belt: never block the suite on OCR init + pass + + +@pytest.fixture(scope="session") +def _ui_screen_kept_on( + ui_capable_role_session: str | None, hub_devices: dict[str, Any] +) -> Iterator[None]: + """Keep the OLED on throughout the UI tier so input events aren't dropped. + + Why: `InputBroker::handleInputEvent` (src/input/InputBroker.cpp:118-122) + silently DROPS any event that arrives while the screen is off — it just + wakes the screen and returns. Every first event in each test would + disappear. We set `display.screen_on_secs = 86400` at session start + (effectively "always on" for the test window) and restore the prior + value at teardown. + """ + if ui_capable_role_session is None: + yield + return + + hub_entry = hub_devices[ui_capable_role_session] + port = hub_entry.get("port") if isinstance(hub_entry, dict) else hub_entry + if not port: + yield + return + + original: int | None = None + try: + current = admin_mod.get_config(section="display", port=port) + original = int( + current.get("config", {}).get("display", {}).get("screen_on_secs") or 0 + ) + except Exception: # noqa: BLE001 + pass + + try: + admin_mod.set_config("display.screen_on_secs", 86400, port=port) + # Send one wake event so the screen is actually ON going into the + # first test. The event itself gets dropped (screenWasOff), but the + # wake side-effect sticks. + try: + admin_mod.send_input_event(event_code=int(InputEventCode.FN_F1), port=port) + except Exception: # noqa: BLE001 + pass + time.sleep(1.5) # Let the screen finish its wake transition. + except ( + Exception + ): # noqa: BLE001 — best-effort; ui_home_state surfaces the real error + pass + + try: + yield + finally: + if original is not None: + try: + admin_mod.set_config("display.screen_on_secs", original, port=port) + except Exception: # noqa: BLE001 + pass + + +# ---------- Per-test capture + transcript ---------------------------------- + + +class FrameCapture: + """Per-test capture recorder. Created once per test via the + `frame_capture` fixture; call with a label to snapshot the screen. + """ + + def __init__( + self, + cam: camera_mod.CameraBackend, + dir_path: Path, + lines: list[str], + nodeid: str, + ) -> None: + self._cam = cam + self._dir = dir_path + self._lines = lines + self._nodeid = nodeid + self._step = 0 + self.captures: list[dict[str, Any]] = [] + self._transcript_path = dir_path / "transcript.md" + self._dir.mkdir(parents=True, exist_ok=True) + self._transcript_path.write_text( + f"# {nodeid} — {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}\n\n", + encoding="utf-8", + ) + + def __call__(self, label: str) -> dict[str, Any]: + self._step += 1 + stem = f"{self._step:03d}-{re.sub(r'[^a-zA-Z0-9_-]+', '-', label)}" + png_path = self._dir / f"{stem}.png" + ocr_path = self._dir / f"{stem}.ocr.txt" + + try: + png = self._cam.capture() + except Exception as exc: # noqa: BLE001 + png = b"" + ocr_str = f"[capture error: {exc}]" + else: + camera_mod.save_capture(png, png_path) + try: + ocr_str = ocr_mod.ocr_text(png) + except Exception as exc: # noqa: BLE001 + ocr_str = f"[ocr error: {exc}]" + ocr_path.write_text(ocr_str or "", encoding="utf-8") + + frame = get_current_frame(self._lines) + entry: dict[str, Any] = { + "step": self._step, + "label": label, + "png_path": str(png_path) if png else None, + "ocr_text": ocr_str, + "frame": ( + { + "idx": frame.idx, + "name": frame.name, + "reason": frame.reason, + } + if frame is not None + else None + ), + } + self.captures.append(entry) + + with self._transcript_path.open("a", encoding="utf-8") as fh: + frame_str = ( + f"frame {frame.idx}/{frame.count} name={frame.name} reason={frame.reason}" + if frame is not None + else "frame " + ) + ocr_summary = (ocr_str or "").replace("\n", " / ")[:80] + fh.write( + f"{self._step}. **{label}** — {frame_str} — OCR: `{ocr_summary}`\n" + ) + return entry + + +@pytest.fixture +def frame_capture( + request: pytest.FixtureRequest, + camera: camera_mod.CameraBackend, + session_seed: str, +) -> Iterator[FrameCapture]: + nodeid = _sanitize_nodeid(request.node.nodeid) + dir_path = CAPTURES_ROOT / session_seed / nodeid + # Fresh directory per test run so reruns don't mix old and new images. + if dir_path.exists(): + shutil.rmtree(dir_path) + + lines = getattr(request.node, "_debug_log_buffer", []) + fc = FrameCapture(camera, dir_path, lines, nodeid) + # Stash so pytest_runtest_makereport can embed captures in HTML extras. + request.node._ui_captures = fc.captures # type: ignore[attr-defined] + yield fc + + +# ---------- Pre-test home-state reset -------------------------------------- + + +def _send_event(port: str, event: InputEventCode) -> None: + try: + admin_mod.send_input_event(event_code=int(event), port=port) + except Exception: # noqa: BLE001 + # Treat a failed event as soft — the subsequent frame-log assertion + # surfaces the real problem with better context. + pass + + +@pytest.fixture(autouse=True) +def ui_home_state( + request: pytest.FixtureRequest, + hub_devices: dict[str, Any], + _ui_screen_kept_on: None, +) -> Iterator[None]: + """Before every UI test, jump to frame 0 (usually `home`) via FN_F1 and + confirm the device emitted the expected frame log. + + Why FN_F1 (not BACK): FN_F1 maps to `switchToFrame(0)` and ALWAYS + produces a `reason=fn_f1` log line, regardless of whatever frame the + prior test left us on. BACK is context-sensitive (dismisses overlays + on some frames, no-op on others) and can silently fail to transition. + + This fixture doubles as the macro-presence detector: if no `fn_f1` + log arrives within 5 s, the firmware almost certainly wasn't baked + with `USERPREFS_UI_TEST_LOG`. Skip the tier with an actionable hint + instead of letting every test body fail with a confusing assertion. + + Autouse scope is restricted to `tests/ui/` by virtue of this fixture + living in that directory's conftest.py — no explicit nodeid guard + needed (and earlier attempts at one were wrong, matching `/tests/ui/` + against a nodeid that has no leading slash). + """ + role = next((r for r in UI_CAPABLE_ROLES if r in hub_devices), None) + if role is None: + yield + return + + hub_entry = hub_devices[role] + port = hub_entry.get("port") if isinstance(hub_entry, dict) else hub_entry + lines: list[str] = getattr(request.node, "_debug_log_buffer", []) + start_len = len(lines) + + # First: a wake event. The screen should already be kept on by + # `_ui_screen_kept_on`, but belt + suspenders — if it somehow + # powered off (sleep after factory_reset, etc.), this first FN_F1 + # gets dropped by InputBroker's screenWasOff guard. That's fine; + # the second FN_F1 below lands cleanly. + _send_event(port, InputEventCode.FN_F1) + time.sleep(0.4) + _send_event(port, InputEventCode.FN_F1) + + # Wait for the fn_f1 transition log. Any new `reason=fn_f1` line + # after call-start counts — we don't care about the name (it should + # be `home` or `deviceFocused` depending on board-specific frame order). + from ._screen_log import wait_for_reason + + try: + wait_for_reason(lines, "fn_f1", timeout_s=5.0) + except TimeoutError: + # One more try — FreeRTOS queue may be draining slowly. + _send_event(port, InputEventCode.FN_F1) + try: + wait_for_reason(lines, "fn_f1", timeout_s=5.0) + except TimeoutError: + # Look at what the _debug_log_buffer actually contains to + # disambiguate "macro off" from "macro on but event lost". + frame_lines = [ln for ln in lines[start_len:] if "Screen: frame" in ln] + processing_lines = [ + ln for ln in lines[start_len:] if "Processing input event" in ln + ] + if frame_lines: + pytest.skip( + f"ui_home_state: events fire but none reach Screen " + f"(saw {len(frame_lines)} frame line(s), " + f"{len(processing_lines)} admin inject(s)). " + f"Device may be in an unusual state — try `--force-bake`." + ) + else: + pytest.skip( + "ui_home_state: no `Screen: frame` log after FN_F1. " + "Firmware not baked with USERPREFS_UI_TEST_LOG — " + "run with `--force-bake` to reflash, or verify the " + "macro is active in the bake." + ) + yield + + +# ---------- Small helpers reused by tests --------------------------------- + + +def send_event( + port: str, event: InputEventCode | int | str, **kwargs: Any +) -> dict[str, Any]: + """Thin wrapper so tests read `send_event(port, InputEventCode.RIGHT)`.""" + return admin_mod.send_input_event(event_code=event, port=port, **kwargs) + + +__all__ = [ + "FrameCapture", + "UI_CAPABLE_ROLES", + "send_event", + "wait_for_frame", + "FrameEvent", +] + + +# Make the helpers discoverable to test modules via `from .conftest import …`. +# pytest auto-loads conftest.py, but the symbols above are also re-exported +# for readability in the test files. diff --git a/mcp-server/tests/ui/test_input_fn_jump.py b/mcp-server/tests/ui/test_input_fn_jump.py new file mode 100644 index 000000000..047aff7d2 --- /dev/null +++ b/mcp-server/tests/ui/test_input_fn_jump.py @@ -0,0 +1,61 @@ +"""FN_F1..F5 directly jumps to frame 0..4 via Screen::handleInputEvent. + +Parametrized over the 5 function keys. Each expects a +`Screen: frame / name=... reason=fn_f` log line, with +`idx == k-1`. We don't hardcode the frame *name* because the layout +depends on which modules are compiled in for this board. +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import get_current_frame, wait_for_reason +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(120) +@pytest.mark.parametrize( + "event,expected_idx,reason", + [ + (InputEventCode.FN_F1, 0, "fn_f1"), + (InputEventCode.FN_F2, 1, "fn_f2"), + (InputEventCode.FN_F3, 2, "fn_f3"), + (InputEventCode.FN_F4, 3, "fn_f4"), + (InputEventCode.FN_F5, 4, "fn_f5"), + ], + ids=["FN_F1", "FN_F2", "FN_F3", "FN_F4", "FN_F5"], +) +def test_fn_jump_direct_frame( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, + event: InputEventCode, + expected_idx: int, + reason: str, +) -> None: + lines: list[str] = request.node._debug_log_buffer + start = get_current_frame(lines) + assert start is not None, "no frame log yet — USERPREFS_UI_TEST_LOG not wired?" + assert start.name in ( + "home", + "deviceFocused", + ), f"setup expected frame 0 landing, got {start.name!r}" + frame_capture("initial") + + if start.count <= expected_idx: + pytest.skip( + f"device has {start.count} frames; FN_F{expected_idx + 1} needs > {expected_idx}" + ) + + send_event(ui_port, event) + time.sleep(0.1) + evt = wait_for_reason(lines, reason, timeout_s=5.0) + assert evt.idx == expected_idx, ( + f"FN_F{expected_idx + 1} expected idx={expected_idx}, got {evt.idx} " + f"(name={evt.name}, count={evt.count})" + ) + frame_capture(f"after-{reason}") diff --git a/mcp-server/tests/ui/test_input_fn_oob.py b/mcp-server/tests/ui/test_input_fn_oob.py new file mode 100644 index 000000000..a33ff1cc5 --- /dev/null +++ b/mcp-server/tests/ui/test_input_fn_oob.py @@ -0,0 +1,61 @@ +"""Out-of-bounds FN_F5 when the device has <5 frames: no crash, idx unchanged. + +`Screen::handleInputEvent` dispatches FN_F5 unconditionally to +`ui->switchToFrame(4)`. The OLEDDisplayUi library typically clamps or +silently ignores out-of-range indices, but firmware bugs have existed +here — this test protects against a regression that would wedge the UI. + +If this test fails, first check: did the device actually crash (Guru +Meditation in the log)? Or did switchToFrame accept an OOB index and +leave the UI blank? +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import get_current_frame, wait_for_reason +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(90) +def test_fn_f5_out_of_bounds( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + lines: list[str] = request.node._debug_log_buffer + start = get_current_frame(lines) + assert start is not None + + if start.count > 5: + pytest.skip( + f"device has {start.count} frames; FN_F5 is in-bounds — not testing OOB here" + ) + + frame_capture("initial-home") + send_event(ui_port, InputEventCode.FN_F5) + time.sleep(0.5) + + try: + wait_for_reason(lines, "fn_f5", timeout_s=3.0) + except TimeoutError: + # Firmware may have ignored the event entirely — acceptable. + pass + + # Capture whatever is on screen (OCR will tell us if something weird + # happened). Device must remain responsive — subsequent events should + # still land. + frame_capture("after-fn_f5-oob") + + # Send a RIGHT to confirm the UI is still alive. If this times out, + # the OOB switchToFrame wedged the UI. + send_event(ui_port, InputEventCode.RIGHT) + post = wait_for_reason(lines, "next", timeout_s=5.0) + assert ( + post is not None + ), "UI wedged after OOB FN_F5 — RIGHT no longer produces frame log" + frame_capture("after-recovery-right") diff --git a/mcp-server/tests/ui/test_input_menu.py b/mcp-server/tests/ui/test_input_menu.py new file mode 100644 index 000000000..8799d7dfb --- /dev/null +++ b/mcp-server/tests/ui/test_input_menu.py @@ -0,0 +1,68 @@ +"""SELECT on the home frame opens the home menu; BACK closes it. + +The home menu is an overlay (menuHandler::homeBaseMenu), not a frame +transition — so we verify via OCR difference between before/after +captures rather than a `Screen: frame` log line. The underlying +mechanism is still InputBroker → Screen::handleInputEvent → menu +callback. +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import get_current_frame +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(120) +def test_select_opens_home_menu( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + lines: list[str] = request.node._debug_log_buffer + start = get_current_frame(lines) + assert start is not None + if start.name not in ("home", "deviceFocused"): + pytest.skip( + f"SELECT on {start.name!r} doesn't open homeBaseMenu; " + "test is only valid when the landing frame is home/deviceFocused" + ) + + initial = frame_capture("initial") + send_event(ui_port, InputEventCode.SELECT) + time.sleep(0.8) + opened = frame_capture("after-select") + + # The menu is an overlay (not a frame change). We cannot use log + # assertion — instead, OCR should differ because a menu list is now + # drawn on top. + initial_text = (initial.get("ocr_text") or "").strip() + opened_text = (opened.get("ocr_text") or "").strip() + if initial_text and opened_text: + # When OCR is available, require *some* difference between the two + # frames — even a single menu title changes the transcribed text. + assert initial_text != opened_text, ( + f"expected OCR diff after SELECT; both read {initial_text!r}. " + "If both are empty, check camera alignment + OCR backend." + ) + + # Back out — the menu dismisses on BACK. + send_event(ui_port, InputEventCode.BACK) + time.sleep(0.8) + closed = frame_capture("after-back") + + # Soft check: OCR after BACK should look different from the menu + # (either back to home or onto a previous frame — BACK's exact + # behavior when the menu is up vs. not-up varies). We don't assert + # equality because OLED rendering is pixel-stable but camera sampling + # introduces noise. + if opened_text and closed.get("ocr_text"): + close_text = (closed.get("ocr_text") or "").strip() + assert ( + close_text != opened_text + ), f"after BACK, OCR still looks like the menu: {close_text!r}" diff --git a/mcp-server/tests/ui/test_input_message_scroll.py b/mcp-server/tests/ui/test_input_message_scroll.py new file mode 100644 index 000000000..85dc2d8e2 --- /dev/null +++ b/mcp-server/tests/ui/test_input_message_scroll.py @@ -0,0 +1,60 @@ +"""Once we navigate to the textMessage frame, UP/DOWN exercises the +message-scroll path (or opens CannedMessages on empty devices). + +Weaker than a "no frame change" assertion because on a fresh bench +device the message store is usually empty, and the firmware's UP +handler in that case launches CannedMessage — which DOES rebuild +frames. We just verify the path doesn't crash + produce captures for +visual inspection. +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import get_current_frame, wait_for_frame +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(180) +def test_up_down_on_textmessage_survives( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + lines: list[str] = request.node._debug_log_buffer + frame_capture("initial") + + # Walk RIGHT until we land on textMessage — up to 15 hops. + for _i in range(15): + send_event(ui_port, InputEventCode.RIGHT) + time.sleep(0.3) + current = get_current_frame(lines) + if current is not None and current.name == "textMessage": + break + else: + pytest.skip( + "couldn't reach textMessage frame within 15 RIGHTs — not present on this board" + ) + + wait_for_frame(lines, "textMessage", timeout_s=5.0) + frame_capture("on-textMessage") + + # UP and DOWN exercise the message-scroll / canned-message-launch path. + # Capture after each so the HTML report shows any visual effect. + send_event(ui_port, InputEventCode.UP) + time.sleep(0.3) + frame_capture("after-up") + + send_event(ui_port, InputEventCode.DOWN) + time.sleep(0.3) + frame_capture("after-down") + + # Soft check: we should still be in a reachable frame (not wedged). + # The next test's `ui_home_state` will error out if the device is + # unresponsive, so we don't need a stricter guarantee here. + final = get_current_frame(lines) + assert final is not None, "no frame log after UP/DOWN — event path broke" diff --git a/mcp-server/tests/ui/test_input_navigation.py b/mcp-server/tests/ui/test_input_navigation.py new file mode 100644 index 000000000..1fe00b134 --- /dev/null +++ b/mcp-server/tests/ui/test_input_navigation.py @@ -0,0 +1,93 @@ +"""INPUT_BROKER_RIGHT cycles forward through frames; INPUT_BROKER_LEFT backs. + +The simplest UI test: fire N RIGHT events and assert the frame index +moves forward by N (modulo frameCount). Each step captures an image + +OCR for the HTML report. +""" + +from __future__ import annotations + +import time +from typing import Any + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import get_current_frame, wait_for_frame +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(120) +def test_input_right_cycles_frames( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + lines: list[str] = request.node._debug_log_buffer + start = get_current_frame(lines) + assert start is not None, "no frame log yet — USERPREFS_UI_TEST_LOG not wired?" + # FN_F1 in ui_home_state lands on frame 0. The name at frame 0 varies + # by board (home on heltec-v3, deviceFocused on others) — accept either. + assert start.name in ( + "home", + "deviceFocused", + ), f"setup expected home/deviceFocused at frame 0, got {start.name!r}" + + frame_capture("initial") + visited = [start.idx] + + for step in range(4): + send_event(ui_port, InputEventCode.RIGHT) + # Each RIGHT should bump the frame index by 1. The log fires with + # `reason=next` from showFrame(NEXT). + before_count = len(list(_frame_events(lines))) + deadline = time.monotonic() + 5.0 + while time.monotonic() < deadline: + if len(list(_frame_events(lines))) > before_count: + break + time.sleep(0.1) + evt = get_current_frame(lines) + assert evt is not None + assert ( + evt.reason == "next" + ), f"step {step}: expected reason=next, got {evt.reason!r}" + visited.append(evt.idx) + frame_capture(f"after-right-{step + 1}") + + # Sanity: each index should differ from its predecessor. + diffs = [visited[i + 1] - visited[i] for i in range(len(visited) - 1)] + assert all( + d in (1, -(start.count - 1)) for d in diffs + ), f"expected monotonic +1 steps (or a wrap), got visited={visited} diffs={diffs}" + + +@pytest.mark.timeout(120) +def test_input_left_returns_to_home( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + """After RIGHT×3 + LEFT×3, we should end up back on the starting frame.""" + lines: list[str] = request.node._debug_log_buffer + start = get_current_frame(lines) + assert start is not None + start_name = start.name + frame_capture("initial") + for _ in range(3): + send_event(ui_port, InputEventCode.RIGHT) + time.sleep(0.3) + frame_capture("after-right-3") + + for _ in range(3): + send_event(ui_port, InputEventCode.LEFT) + time.sleep(0.3) + + # Back to whichever frame we started on (home or deviceFocused). + wait_for_frame(lines, start_name, timeout_s=5.0) + frame_capture(f"after-left-3-back-{start_name}") + + +def _frame_events(lines: list[str]) -> Any: + from ._screen_log import iter_frame_events + + return iter_frame_events(lines) diff --git a/mcp-server/tests/ui/test_input_node_scroll.py b/mcp-server/tests/ui/test_input_node_scroll.py new file mode 100644 index 000000000..594b358a0 --- /dev/null +++ b/mcp-server/tests/ui/test_input_node_scroll.py @@ -0,0 +1,51 @@ +"""On the nodelist_nodes frame, UP/DOWN scrolls the list via +`NodeListRenderer::scrollUp/scrollDown` (src/graphics/Screen.cpp:1779-1788). +The firmware returns 0 before notifying observers, so no frame-change +log fires. Verify the path doesn't crash and we stay on nodelist_nodes. +""" + +from __future__ import annotations + +import time + +import pytest +from meshtastic_mcp.input_events import InputEventCode + +from ._screen_log import assert_no_frame_change, get_current_frame, wait_for_frame +from .conftest import FrameCapture, send_event + + +@pytest.mark.timeout(180) +def test_up_down_on_nodelist_no_frame_change( + ui_port: str, + frame_capture: FrameCapture, + request: pytest.FixtureRequest, +) -> None: + lines: list[str] = request.node._debug_log_buffer + frame_capture("initial") + + # Walk RIGHT until we land on nodelist_nodes. + for _i in range(15): + send_event(ui_port, InputEventCode.RIGHT) + time.sleep(0.3) + current = get_current_frame(lines) + if current is not None and current.name == "nodelist_nodes": + break + else: + pytest.skip("couldn't reach nodelist_nodes within 15 RIGHTs") + + wait_for_frame(lines, "nodelist_nodes", timeout_s=5.0) + frame_capture("on-nodelist") + + # UP/DOWN on nodelist scroll internally + `return 0` before + # notifyObservers — no frame-change log. Verify. + send_event(ui_port, InputEventCode.UP) + assert_no_frame_change(lines, wait_s=1.5) + send_event(ui_port, InputEventCode.DOWN) + assert_no_frame_change(lines, wait_s=1.5) + + final = get_current_frame(lines) + assert ( + final is not None and final.name == "nodelist_nodes" + ), f"UP/DOWN moved us off nodelist_nodes; now on {final!r}" + frame_capture("after-up-down") diff --git a/mcp-server/tests/unit/test_input_event_codes.py b/mcp-server/tests/unit/test_input_event_codes.py new file mode 100644 index 000000000..f92698edf --- /dev/null +++ b/mcp-server/tests/unit/test_input_event_codes.py @@ -0,0 +1,90 @@ +"""Pin `InputEventCode` values to the firmware `input_broker_event` enum. + +If this test fails, someone changed the firmware enum (or this Python +mirror) and they must stay in sync — the admin RPC sends these as u8 +wire values directly. + +Also exercises `coerce_event_code` for the happy + error paths. +""" + +from __future__ import annotations + +import pytest +from meshtastic_mcp.input_events import InputEventCode, coerce_event_code + + +class TestInputEventCodeValues: + """These values MUST match src/input/InputBroker.h exactly.""" + + def test_navigation_keys(self) -> None: + assert int(InputEventCode.UP) == 17 + assert int(InputEventCode.DOWN) == 18 + assert int(InputEventCode.LEFT) == 19 + assert int(InputEventCode.RIGHT) == 20 + + def test_action_keys(self) -> None: + assert int(InputEventCode.SELECT) == 10 + assert int(InputEventCode.CANCEL) == 24 + assert int(InputEventCode.BACK) == 27 + + def test_long_press_variants(self) -> None: + assert int(InputEventCode.SELECT_LONG) == 11 + assert int(InputEventCode.UP_LONG) == 12 + assert int(InputEventCode.DOWN_LONG) == 13 + + def test_fn_keys(self) -> None: + assert int(InputEventCode.FN_F1) == 0xF1 + assert int(InputEventCode.FN_F2) == 0xF2 + assert int(InputEventCode.FN_F3) == 0xF3 + assert int(InputEventCode.FN_F4) == 0xF4 + assert int(InputEventCode.FN_F5) == 0xF5 + + def test_system_events(self) -> None: + assert int(InputEventCode.SHUTDOWN) == 0x9B + assert int(InputEventCode.GPS_TOGGLE) == 0x9E + assert int(InputEventCode.SEND_PING) == 0xAF + + def test_auto_increment_block(self) -> None: + # C enum: `BACK = 27, USER_PRESS, ALT_PRESS, ALT_LONG` → 28, 29, 30. + assert int(InputEventCode.USER_PRESS) == 28 + assert int(InputEventCode.ALT_PRESS) == 29 + assert int(InputEventCode.ALT_LONG) == 30 + + +class TestCoerceEventCode: + def test_int_passthrough(self) -> None: + assert coerce_event_code(20) == 20 + assert coerce_event_code(0) == 0 + assert coerce_event_code(255) == 255 + + def test_enum_passthrough(self) -> None: + assert coerce_event_code(InputEventCode.RIGHT) == 20 + assert coerce_event_code(InputEventCode.FN_F1) == 0xF1 + + def test_name_case_insensitive(self) -> None: + assert coerce_event_code("right") == 20 + assert coerce_event_code("RIGHT") == 20 + assert coerce_event_code("Right") == 20 + + def test_input_broker_prefix_stripped(self) -> None: + assert coerce_event_code("INPUT_BROKER_FN_F1") == 0xF1 + assert coerce_event_code("input_broker_select") == 10 + + def test_hyphen_and_underscore_equivalence(self) -> None: + assert coerce_event_code("fn-f1") == 0xF1 + + def test_int_out_of_range_raises(self) -> None: + with pytest.raises(ValueError, match="u8"): + coerce_event_code(256) + with pytest.raises(ValueError, match="u8"): + coerce_event_code(-1) + + def test_unknown_name_raises(self) -> None: + with pytest.raises(ValueError, match="unknown event code name"): + coerce_event_code("NOT_A_KEY") + + def test_wrong_type_raises(self) -> None: + with pytest.raises(TypeError): + coerce_event_code(1.5) # type: ignore[arg-type] + with pytest.raises(TypeError): + coerce_event_code(None) # type: ignore[arg-type] diff --git a/mcp-server/tests/unit/test_uhubctl_parser.py b/mcp-server/tests/unit/test_uhubctl_parser.py new file mode 100644 index 000000000..373147950 --- /dev/null +++ b/mcp-server/tests/unit/test_uhubctl_parser.py @@ -0,0 +1,148 @@ +"""Pin the `uhubctl` default-output parser against canned real-world samples. + +uhubctl's output format has been stable since v2.x but occasionally adds +new hub-descriptor fields (e.g. the `, ppps` marker). The parser uses loose +regexes to tolerate additions; this test keeps us honest. + +Samples captured from: +- v2.6.0 on macOS (Homebrew) — two USB2 hubs, one populated with an + nRF52 and a CP2102, plus chained USB3 hubs. +- v2.5.0 on Linux (hypothetical — reconstructed from the project README). +""" + +from __future__ import annotations + +import pytest +from meshtastic_mcp.uhubctl import ( + ROLE_VIDS, + UhubctlError, + parse_list_output, +) + +# Actual `uhubctl` stdout on the developer's macOS bench, Apr 2026. +_SAMPLE_MACOS_V26 = """\ +Current status for hub 1-1.3 [2109:2817 VIA Labs, Inc. USB2.0 Hub, USB 2.10, 4 ports, ppps] + Port 1: 0100 power + Port 2: 0103 power enable connect [239a:8029 RAKwireless WisCore RAK4631 Board 920456B1E6972262] + Port 3: 0103 power enable connect [10c4:ea60 Silicon Labs CP2102 USB to UART Bridge Controller 0001] + Port 4: 0100 power +Current status for hub 1-2.3 [2109:0817 VIA Labs, Inc. USB3.0 Hub, USB 3.10, 4 ports, ppps] + Port 1: 02a0 power 5gbps Rx.Detect + Port 2: 02a0 power 5gbps Rx.Detect + Port 3: 02a0 power 5gbps Rx.Detect + Port 4: 02a0 power 5gbps Rx.Detect +Current status for hub 1-1 [2109:2817 VIA Labs, Inc. USB2.0 Hub, USB 2.10, 4 ports, ppps] + Port 1: 0100 power + Port 2: 0100 power + Port 3: 0503 power highspeed enable connect [2109:2817 VIA Labs, Inc. USB2.0 Hub, USB 2.10, 4 ports, ppps] + Port 4: 0100 power +""" + + +# Minimal Linux-style sample (fewer hubs, shows a non-PPPS hub). +_SAMPLE_LINUX_NONPPPS = """\ +Current status for hub 2-1.4 [05e3:0608 GenesysLogic USB2.1 Hub, USB 2.10, 4 ports] + Port 1: 0507 power highspeed suspend enable connect [239a:0029 Adafruit Feather Bootloader] + Port 2: 0100 power + Port 3: 0100 power + Port 4: 0100 power +""" + + +class TestParseListOutput: + def test_parses_macos_sample_hub_count(self) -> None: + hubs = parse_list_output(_SAMPLE_MACOS_V26) + assert len(hubs) == 3 + + def test_parses_hub_location_and_vid(self) -> None: + hubs = parse_list_output(_SAMPLE_MACOS_V26) + via_hub = hubs[0] + assert via_hub["location"] == "1-1.3" + assert via_hub["vid"] == 0x2109 + assert via_hub["pid"] == 0x2817 + assert via_hub["ppps"] is True + + def test_parses_port_with_device(self) -> None: + hubs = parse_list_output(_SAMPLE_MACOS_V26) + nrf52_hub = hubs[0] + port2 = next(p for p in nrf52_hub["ports"] if p["port"] == 2) + assert port2["device_vid"] == 0x239A + assert port2["device_pid"] == 0x8029 + assert "RAKwireless" in port2["device_desc"] + + def test_empty_port_has_no_device(self) -> None: + hubs = parse_list_output(_SAMPLE_MACOS_V26) + nrf52_hub = hubs[0] + port1 = next(p for p in nrf52_hub["ports"] if p["port"] == 1) + assert port1["device_vid"] is None + assert port1["device_pid"] is None + assert port1["device_desc"] is None + + def test_ports_count(self) -> None: + hubs = parse_list_output(_SAMPLE_MACOS_V26) + for hub in hubs: + assert len(hub["ports"]) == 4 # each sample hub has 4 ports + + def test_non_ppps_hub_flagged(self) -> None: + hubs = parse_list_output(_SAMPLE_LINUX_NONPPPS) + assert len(hubs) == 1 + assert hubs[0]["ppps"] is False + + def test_handles_empty_input(self) -> None: + assert parse_list_output("") == [] + + def test_handles_malformed_lines_gracefully(self) -> None: + # Lines that don't match HUB_RE or PORT_RE are ignored silently. + garbage = "uhubctl: warning: something weird\n" + _SAMPLE_LINUX_NONPPPS + hubs = parse_list_output(garbage) + assert len(hubs) == 1 + + +class TestRoleVids: + def test_nrf52_mapped(self) -> None: + assert 0x239A in ROLE_VIDS["nrf52"] + + def test_esp32s3_covers_both_vids(self) -> None: + # Espressif native USB + CP2102 USB-UART on heltec-v3 boards. + assert 0x303A in ROLE_VIDS["esp32s3"] + assert 0x10C4 in ROLE_VIDS["esp32s3"] + + +class TestResolveTargetErrorPaths: + def test_unknown_role_raises(self, monkeypatch: pytest.MonkeyPatch) -> None: + from meshtastic_mcp.uhubctl import resolve_target + + # Clear any env-var pinning that might make this pass accidentally. + for key in ( + "MESHTASTIC_UHUBCTL_LOCATION_FLUX", + "MESHTASTIC_UHUBCTL_PORT_FLUX", + ): + monkeypatch.delenv(key, raising=False) + with pytest.raises(UhubctlError, match="unknown role"): + resolve_target("flux") + + def test_invalid_env_port_raises(self, monkeypatch: pytest.MonkeyPatch) -> None: + from meshtastic_mcp.uhubctl import resolve_target + + monkeypatch.setenv("MESHTASTIC_UHUBCTL_LOCATION_NRF52", "1-1.3") + monkeypatch.setenv("MESHTASTIC_UHUBCTL_PORT_NRF52", "not-an-int") + with pytest.raises(UhubctlError, match="not a valid integer"): + resolve_target("nrf52") + + def test_env_var_pinning_wins(self, monkeypatch: pytest.MonkeyPatch) -> None: + from meshtastic_mcp.uhubctl import resolve_target + + # Env-var pinning should NOT require uhubctl to be running / installed. + monkeypatch.setenv("MESHTASTIC_UHUBCTL_LOCATION_NRF52", "9-9.9") + monkeypatch.setenv("MESHTASTIC_UHUBCTL_PORT_NRF52", "7") + assert resolve_target("nrf52") == ("9-9.9", 7) + + def test_normalize_role_strips_alt_suffix( + self, monkeypatch: pytest.MonkeyPatch + ) -> None: + from meshtastic_mcp.uhubctl import resolve_target + + # esp32s3_alt collapses to esp32s3 for env-var lookup. + monkeypatch.setenv("MESHTASTIC_UHUBCTL_LOCATION_ESP32S3", "2-2") + monkeypatch.setenv("MESHTASTIC_UHUBCTL_PORT_ESP32S3", "3") + assert resolve_target("esp32s3_alt") == ("2-2", 3) diff --git a/mcp-server/tests/unit/test_ui_screen_log.py b/mcp-server/tests/unit/test_ui_screen_log.py new file mode 100644 index 000000000..55029b38c --- /dev/null +++ b/mcp-server/tests/unit/test_ui_screen_log.py @@ -0,0 +1,80 @@ +"""Pin the `Screen: frame N/M name=X reason=Y` regex + FrameEvent dataclass. + +The firmware-side format lives in `src/graphics/Screen.cpp::logFrameChange`; +if the format string changes, this test — and the parser in +`tests/ui/_screen_log.py` — have to be updated together. +""" + +from __future__ import annotations + +from tests.ui._screen_log import FRAME_RE, FrameEvent, iter_frame_events + + +class TestFrameEventParse: + def test_exact_firmware_output(self) -> None: + raw = "Screen: frame 2/8 name=home reason=next" + evt = FrameEvent.parse(raw) + assert evt is not None + assert evt.idx == 2 + assert evt.count == 8 + assert evt.name == "home" + assert evt.reason == "next" + assert evt.raw == raw + + def test_with_log_prefix(self) -> None: + """Log lines may be preamble-wrapped by the firmware LOG_INFO macro + (timestamp, severity, etc.) — the regex uses .search() not .match() + so prefixes are fine.""" + raw = "[INFO] 00:12:34 567 Screen: frame 4/12 name=nodelist_nodes reason=fn_f3 " + evt = FrameEvent.parse(raw) + assert evt is not None + assert evt.idx == 4 + assert evt.count == 12 + assert evt.name == "nodelist_nodes" + assert evt.reason == "fn_f3" + + def test_rebuild_reason(self) -> None: + evt = FrameEvent.parse("Screen: frame 0/5 name=deviceFocused reason=rebuild") + assert evt is not None + assert evt.reason == "rebuild" + + def test_all_fn_reasons(self) -> None: + for k in range(1, 6): + evt = FrameEvent.parse( + f"Screen: frame {k - 1}/8 name=settings reason=fn_f{k}" + ) + assert evt is not None and evt.reason == f"fn_f{k}" + + def test_unknown_name_is_preserved(self) -> None: + """If the reverse-map returns 'unknown', that still parses cleanly.""" + evt = FrameEvent.parse("Screen: frame 99/100 name=unknown reason=prev") + assert evt is not None and evt.name == "unknown" + + def test_non_matching_line_returns_none(self) -> None: + assert FrameEvent.parse("BOOT Booting firmware 2.7.23") is None + assert FrameEvent.parse("") is None + assert FrameEvent.parse("Screen: without the right format") is None + + +class TestIterFrameEvents: + def test_filters_non_matching_lines(self) -> None: + lines = [ + "Booting...", + "Screen: frame 1/5 name=home reason=rebuild", + "Some other log line", + "Screen: frame 2/5 name=textMessage reason=next", + ] + evts = list(iter_frame_events(lines)) + assert len(evts) == 2 + assert evts[0].reason == "rebuild" + assert evts[1].reason == "next" + + +class TestRegexAnchoring: + def test_regex_is_compiled(self) -> None: + assert FRAME_RE.search("Screen: frame 0/0 name=home reason=next") is not None + + def test_regex_allows_unusual_names(self) -> None: + r"""Name is `\S+`, so compound names with underscores/digits match.""" + m = FRAME_RE.search("Screen: frame 5/10 name=nodelist_hopsignal reason=fn_f2") + assert m is not None and m["name"] == "nodelist_hopsignal" diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index b9745b29a..3d13a68af 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -96,7 +96,6 @@ class ScanI2C CW2015, SCD30, ADS1115, - CST3530, } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 55ec93db5..60e1c43a6 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1265,6 +1265,10 @@ void Screen::setFrames(FrameFocus focus) // Store the info about this frameset, for future setFrames calls this->framesetInfo = fsi; +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("rebuild", ui->getUiState()->currentFrame); +#endif + setFastFramerate(); // Draw ASAP } @@ -1419,11 +1423,77 @@ void Screen::handleOnPress() } } +#ifdef USERPREFS_UI_TEST_LOG +void Screen::logFrameChange(const char *reason, uint8_t targetIdx) +{ + // Reverse-map an index to a stable name string keyed off FramePositions + // field names — so the pytest harness can assert `name=nodelist_nodes` + // without caring about how the positions were ordered this boot. + const auto &p = framesetInfo.positions; + const char *name = "unknown"; + if (targetIdx == p.home) + name = "home"; + else if (targetIdx == p.deviceFocused) + name = "deviceFocused"; + else if (targetIdx == p.textMessage) + name = "textMessage"; + else if (targetIdx == p.nodelist_nodes) + name = "nodelist_nodes"; + else if (targetIdx == p.nodelist_location) + name = "nodelist_location"; + else if (targetIdx == p.nodelist_lastheard) + name = "nodelist_lastheard"; + else if (targetIdx == p.nodelist_hopsignal) + name = "nodelist_hopsignal"; + else if (targetIdx == p.nodelist_distance) + name = "nodelist_distance"; + else if (targetIdx == p.nodelist_bearings) + name = "nodelist_bearings"; + else if (targetIdx == p.system) + name = "system"; + else if (targetIdx == p.gps) + name = "gps"; + else if (targetIdx == p.lora) + name = "lora"; + else if (targetIdx == p.clock) + name = "clock"; + else if (targetIdx == p.chirpy) + name = "chirpy"; + else if (targetIdx == p.fault) + name = "fault"; + else if (targetIdx == p.waypoint) + name = "waypoint"; + else if (targetIdx == p.focusedModule) + name = "focusedModule"; + else if (targetIdx == p.log) + name = "log"; + else if (targetIdx == p.settings) + name = "settings"; + else if (targetIdx == p.wifi) + name = "wifi"; + else if (p.firstFavorite != 255 && p.lastFavorite != 255 && targetIdx >= p.firstFavorite && targetIdx <= p.lastFavorite) + name = "favorite"; + LOG_INFO("Screen: frame %u/%u name=%s reason=%s", (unsigned)targetIdx, (unsigned)framesetInfo.frameCount, name, reason); +} +#endif + void Screen::showFrame(FrameDirection direction) { // Only advance frames when UI is stable if (ui->getUiState()->frameState == FIXED) { +#ifdef USERPREFS_UI_TEST_LOG + // Log the *intended* target before the (async) transition fires, so + // tests see a deterministic record of what was requested. + if (framesetInfo.frameCount > 0) { + uint8_t curr = ui->getUiState()->currentFrame; + uint8_t target = (direction == FrameDirection::NEXT) + ? (uint8_t)((curr + 1) % framesetInfo.frameCount) + : (uint8_t)((curr + framesetInfo.frameCount - 1) % framesetInfo.frameCount); + logFrameChange(direction == FrameDirection::NEXT ? "next" : "prev", target); + } +#endif + if (direction == FrameDirection::NEXT) { ui->nextFrame(); } else { @@ -1755,22 +1825,37 @@ int Screen::handleInputEvent(const InputEvent *event) showFrame(FrameDirection::NEXT); } else if (event->inputEvent == INPUT_BROKER_FN_F1) { this->ui->switchToFrame(0); +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("fn_f1", 0); +#endif lastScreenTransition = millis(); setFastFramerate(); } else if (event->inputEvent == INPUT_BROKER_FN_F2) { this->ui->switchToFrame(1); +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("fn_f2", 1); +#endif lastScreenTransition = millis(); setFastFramerate(); } else if (event->inputEvent == INPUT_BROKER_FN_F3) { this->ui->switchToFrame(2); +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("fn_f3", 2); +#endif lastScreenTransition = millis(); setFastFramerate(); } else if (event->inputEvent == INPUT_BROKER_FN_F4) { this->ui->switchToFrame(3); +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("fn_f4", 3); +#endif lastScreenTransition = millis(); setFastFramerate(); } else if (event->inputEvent == INPUT_BROKER_FN_F5) { this->ui->switchToFrame(4); +#ifdef USERPREFS_UI_TEST_LOG + logFrameChange("fn_f5", 4); +#endif lastScreenTransition = millis(); setFastFramerate(); } else if (event->inputEvent == INPUT_BROKER_UP_LONG) { diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index e259f7691..023f36f38 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -673,6 +673,16 @@ class Screen : public concurrency::OSThread void handleOnPress(); void handleStartFirmwareUpdateScreen(); +#ifdef USERPREFS_UI_TEST_LOG + // Test-only: emits one LOG_INFO line on every frame transition so the + // pytest harness can assert which frame is shown. Gated behind a macro + // so the chatty log doesn't ship in release builds. Enabled via + // build_testing_profile(enable_ui_log=True) in mcp-server/userprefs.py. + // Member function (not free) because FramesetInfo is a private nested + // type — only methods of Screen can reach it. + void logFrameChange(const char *reason, uint8_t targetIdx); +#endif + // Info collected by setFrames method. // Index location of specific frames. // - Used to apply the FrameFocus parameter of setFrames diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 7492d7361..8a1843bcb 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -1489,8 +1489,15 @@ void AdminModule::handleSendInputEvent(const meshtastic_AdminMessage_InputEvent LOG_DEBUG("Processing input event: event_code=%u, kb_char=%u, touch_x=%u, touch_y=%u", inputEvent.event_code, inputEvent.kb_char, inputEvent.touch_x, inputEvent.touch_y); - // Create InputEvent for injection - InputEvent event = {.inputEvent = (input_broker_event)inputEvent.event_code, + // Create InputEvent for injection. + // + // `.source` MUST be a non-null C string: the LOG_INFO below formats it + // with %s, and passing NULL to the esp-log formatter crashes with + // Guru Meditation LoadProhibited at strlen(NULL). Other InputBroker + // sources (buttons, rotary) always set this; the admin path was the + // only one leaving it default-null. + InputEvent event = {.source = "admin", + .inputEvent = (input_broker_event)inputEvent.event_code, .kbchar = (unsigned char)inputEvent.kb_char, .touchX = inputEvent.touch_x, .touchY = inputEvent.touch_y}; diff --git a/userPrefs.jsonc b/userPrefs.jsonc index b81f09362..a8201bab3 100644 --- a/userPrefs.jsonc +++ b/userPrefs.jsonc @@ -57,6 +57,7 @@ // "USERPREFS_MQTT_ROOT_TOPIC": "event/REPLACEME", // "USERPREFS_RINGTONE_NAG_SECS": "60", // "USERPREFS_NODEINFO_REPLY_SUPPRESS_SECS": "43200", + // "USERPREFS_UI_TEST_LOG": "true", // Test-only: emits `Screen: frame N/M name=... reason=...` log per UI transition (for the mcp-server ui test tier); off in release builds. "USERPREFS_RINGTONE_RTTTL": "24:d=32,o=5,b=565:f6,p,f6,4p,p,f6,p,f6,2p,p,b6,p,b6,p,b6,p,b6,p,b,p,b,p,b,p,b,p,b,p,b,p,b,p,b,1p.,2p.,p", // "USERPREFS_NETWORK_IPV6_ENABLED": "1", "USERPREFS_TZ_STRING": "tzplaceholder " From f396200d3856bf6f6453a4815dd6c6da96dabac2 Mon Sep 17 00:00:00 2001 From: Tom <116762865+NomDeTom@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:30:50 +0100 Subject: [PATCH 50/67] Add authoring guide for native unit tests in README.md (#10201) * Add authoring guide for native unit tests in README.md * Enhance documentation for agent tooling and native unit tests in README and related files --------- Co-authored-by: Ben Meadors --- .github/copilot-instructions.md | 19 ++ test/README.md | 322 ++++++++++++++++++++++++++++++++ 2 files changed, 341 insertions(+) create mode 100644 test/README.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 7c71a5014..89e1c5c11 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -296,6 +296,23 @@ Key defines in variant.h: ## Build System +## Agent Tooling Baseline + +Mirror counterpart: `AGENTS.md` under **Agent Tooling Baseline**. + +To reduce avoidable agent mistakes, assume these tools are available (or install them before significant repo work): + +- **Required CLI basics**: `bash`, `git`, `find`, `grep`, `sed`, `awk`, `xargs` +- **Strongly recommended**: `rg` (ripgrep) for fast file/text search, `jq` for JSON processing +- **Build/test tools**: `python3`, `pip`, virtualenv (`python3 -m venv`), `platformio` (`pio`) +- **Containerized native testing**: `docker` (especially important on macOS / non-Linux hosts) + +Fallback expectations for agents: + +- If `rg` is unavailable, use `find` + `grep` instead of failing. +- For native tests on hosts without Linux deps, prefer `./bin/test-native-docker.sh`. +- The simulator helper script is `./bin/test-simulator.sh`. + Uses **PlatformIO** with custom scripts: - `bin/platformio-pre.py` - Pre-build script @@ -448,6 +465,8 @@ Run with: `pio test -e native` Simulation testing: `bin/test-simulator.sh` +Quick entry point for new test modules: `test/README.md` (native unit-test authoring guide, skeleton, pitfalls, and setup checklist). + ### Hardware-in-the-loop tests (`mcp-server/tests/`) Separate pytest suite that exercises real USB-connected Meshtastic devices. See the **MCP Server & Hardware Test Harness** section below for invocation, tier layout, and agent usage rules. diff --git a/test/README.md b/test/README.md new file mode 100644 index 000000000..55dbd4775 --- /dev/null +++ b/test/README.md @@ -0,0 +1,322 @@ +# Native Unit Tests — Authoring Guide + +This directory contains C++ unit tests that run on the host machine via PlatformIO's native environment. Tests use the [Unity](http://www.throwtheswitch.org/unity) framework. + +## Running Tests + +```bash +# All test suites +pio test -e native + +# Single suite +pio test -e native -f test_your_module + +# Verbose (shows build errors in detail) +pio test -e native -f test_your_module -vvv +``` + +### Helper Scripts (Useful Shortcuts) + +These wrappers are handy when local host dependencies are missing or when you want repeatable commands. + +```bash +# Run native tests in Docker (recommended on macOS / non-Linux hosts) +./bin/test-native-docker.sh + +# Pass normal PlatformIO test args through to Dockerized test run +./bin/test-native-docker.sh -f test_your_module + +# Force Docker image rebuild (after dependency changes) +./bin/test-native-docker.sh --rebuild + +# Run simulator integration check (build native first) +pio run -e native && ./bin/test-simulator.sh + +# Build and run meshtasticd natively +./bin/native-run.sh + +# Build and run under gdbserver on localhost:2345 +./bin/native-gdbserver.sh + +# Build native release artifact into ./release/ +./bin/build-native.sh native +``` + +Notes: + +- The repository script name is `./bin/test-simulator.sh` (there is no `test-native-simulator.sh`). +- `./bin/test-native-docker.sh` is the closest match to CI behavior for native tests and avoids host package setup. + +### System Dependencies (Ubuntu/Debian) + +The native build requires several system libraries. Install them all at once: + +```bash +sudo apt-get install -y \ + libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev \ + libulfius-dev liborcania-dev libusb-1.0-0-dev libi2c-dev libuv1-dev +``` + +See `.github/actions/setup-native/action.yml` for the canonical list. + +## Creating a New Test Suite + +### 1. Directory Structure + +```text +test/test_your_module/test_main.cpp +``` + +One file per suite. No per-test `platformio.ini` is needed — tests build under the `[env:native]` environment defined in the root `platformio.ini`. + +### 2. File Skeleton + +```cpp +#include "MeshTypes.h" // Include BEFORE TestUtil.h (provides NodeNum, etc.) +#include "TestUtil.h" // initializeTestEnvironment(), testDelay() +#include + +#if YOUR_FEATURE_GUARD // Same #if guard as the module under test + +#include "FSCommon.h" +#include "gps/RTC.h" +#include "mesh/NodeDB.h" +#include "modules/YourModule.h" +#include +#include +#include + +// --- Test output helpers --- +// Unity swallows printf/stdout. Only TEST_MESSAGE() output appears in results. +#define MSG_BUF_LEN 200 +#define TEST_MSG_FMT(fmt, ...) do { \ + char _buf[MSG_BUF_LEN]; \ + snprintf(_buf, sizeof(_buf), fmt, __VA_ARGS__); \ + TEST_MESSAGE(_buf); \ +} while(0) + +// --- Tests --- + +void test_example() +{ + TEST_MESSAGE("=== Example test ==="); + TEST_ASSERT_TRUE(true); +} + +// --- Unity lifecycle --- + +void setUp(void) { /* runs before every test */ } +void tearDown(void) { /* runs after every test */ } + +void setup() +{ + initializeTestEnvironment(); // MUST call — sets up RTC, OSThread, console + UNITY_BEGIN(); + RUN_TEST(test_example); + exit(UNITY_END()); // exit() required — Unity runner expects it +} + +void loop() {} + +#else // !YOUR_FEATURE_GUARD + +void setUp(void) {} +void tearDown(void) {} + +void setup() +{ + initializeTestEnvironment(); + UNITY_BEGIN(); + exit(UNITY_END()); +} + +void loop() {} + +#endif +``` + +### 3. Feature Guard + +Wrap the entire test body in the same `#if` guard the module uses (e.g. `#if HAS_VARIABLE_HOPS`, `#if !MESHTASTIC_EXCLUDE_GPS`). When the feature is disabled, the `#else` branch produces an empty passing suite. + +## Common Patterns + +### MockNodeDB + +Most module tests need to inject nodes with controlled hop distances and ages: + +```cpp +class MockNodeDB : public NodeDB +{ + public: + void clearTestNodes() + { + testNodes.clear(); + numMeshNodes = 0; + } + + void addTestNode(NodeNum num, uint8_t hopsAway, bool hasHops, + uint32_t ageSecs, bool viaMqtt = false) + { + meshtastic_NodeInfoLite node = meshtastic_NodeInfoLite_init_zero; + node.num = num; + node.has_hops_away = hasHops; + node.hops_away = hopsAway; + node.via_mqtt = viaMqtt; + node.last_heard = getTime() - ageSecs; + testNodes.push_back(node); + meshNodes = &testNodes; + numMeshNodes = testNodes.size(); + } + + std::vector testNodes; +}; + +static MockNodeDB *mockNodeDB = nullptr; +``` + +Set `nodeDB = mockNodeDB;` in `setUp()`. + +### Test Shim (Exposing Protected/Private Members) + +Subclass the module under test to make protected methods callable and private members writable: + +```cpp +class YourModuleTestShim : public YourModule +{ + public: + // Expose protected methods + using YourModule::runOnce; + using YourModule::someProtectedMethod; + + // Access private members via friend (see below) + void setPrivateField(int x) { privateField = x; } +}; +``` + +In the module header, grant friend access under the `UNIT_TEST` define (set automatically by PlatformIO's test framework): + +```cpp +// In YourModule.h, inside the class body: +#ifdef UNIT_TEST + friend class YourModuleTestShim; +#endif +``` + +### Global Singleton Lifecycle + +Most modules use a global pointer (`extern YourModule *yourModule;`). Manage it carefully: + +```cpp +void setUp(void) { + // ... setup ... +} + +void tearDown(void) { + yourModule = nullptr; // prevent dangling pointer between tests +} + +void test_something() { + auto shim = std::unique_ptr(new YourModuleTestShim()); + yourModule = shim.get(); + // ... test ... + yourModule = nullptr; +} +``` + +## Pitfalls and How to Avoid Them + +### 1. Persisted Filesystem State Leaks Between Tests + +Modules that save state to `/prefs/*.bin` will have that state loaded by the next test's constructor via `loadState()`. This causes values from one test (e.g. rolling averages from a megamesh scenario) to bleed into unrelated tests. + +**Fix:** Delete state files at the start of `setUp()`: + +```cpp +void setUp(void) { + // ... +#ifdef FSCom + FSCom.remove("/prefs/your_module.bin"); +#endif +} +``` + +### 2. File-Scope Mutable Globals Persist Across Tests + +Variables like `static uint8_t someDenominator = 8;` in the module `.cpp` file retain mutations from previous tests. This is distinct from member variables — it affects all instances. + +**Fix:** Add a `static void resetGlobal()` method to the module and call it in `setUp()`. + +### 3. Randomness Breaks Determinism + +If the module uses `rand()` for jitter or similar, test results become non-reproducible. + +**Fix:** Add a static enable/disable flag: + +```cpp +// Module header: +static void setJitter(bool enabled) { s_jitterEnabled = enabled; } + +// Test setUp: +YourModule::setJitter(false); + +// Test tearDown: +YourModule::setJitter(true); +``` + +### 4. Time-Dependent Logic Produces Zeros + +Rolling averages weighted by `elapsedMs / ONE_HOUR_MS` collapse to zero when tests complete in microseconds. Sample windows, EMA alphas, and interval-based accumulators all suffer from this. + +**Fix:** Expose the timestamp via friend access and simulate realistic elapsed time: + +```cpp +// In test shim: +void setWindowStartMs(uint32_t ms) { windowStartMs = ms; } + +// In test: +shim.setWindowStartMs(millis() - 3600000UL); // pretend 1 hour elapsed +``` + +### 5. Capacity Limits Cause Cascading Failures + +Fixed-size data structures (hash sets, ring buffers) overflow when tests inject more data than fits. This triggers early flushes with near-zero time fractions, compounding the time-dependent-zeros problem. + +**Fix:** Simulate multiple realistic time windows rather than one massive burst. Let adaptive mechanisms (if any) self-tune over several rolls. + +## setUp/tearDown Checklist + +- [ ] Create and clear MockNodeDB (if needed) +- [ ] Zero global configs: `config`, `moduleConfig`, `myNodeInfo` +- [ ] Set `nodeDB = mockNodeDB` +- [ ] Delete persisted state files (`FSCom.remove(...)`) +- [ ] Reset file-scope mutable globals +- [ ] Disable randomness/jitter flags +- [ ] In `tearDown`: null the global singleton pointer, restore flags + +## Test Organization + +A well-structured test suite follows this pattern: + +1. **Topology/scenario builders** — static helper functions that set up specific test conditions +2. **Injection helpers** — simulate realistic traffic, time, or event patterns +3. **Scenario tests** — each builds a scenario, runs the module, asserts on outcomes +4. **Lifecycle tests** — state persistence, startup from blank, restart recovery +5. **Summary test** (optional) — emits a scenario table into the log for quick CI review + +## Existing Test Suites + +| Suite | Module Under Test | +| ---------------------------- | ----------------------------- | +| `test_crypto` | CryptoEngine | +| `test_mqtt` | MQTT integration | +| `test_radio` | Radio interface | +| `test_mesh_module` | Module framework | +| `test_meshpacket_serializer` | Packet serialization | +| `test_transmit_history` | Retransmission tracking | +| `test_atak` | ATAK integration | +| `test_default` | Default configuration helpers | +| `test_http_content_handler` | HTTP handling | +| `test_serial` | Serial communication | +| `test_hop_scaling` | Hop scaling algorithm | +| `test_traffic_management` | Traffic management | From d50caf231bd93ce45182bf20bcb4a070a15ee670 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 19 Apr 2026 16:05:28 -0500 Subject: [PATCH 51/67] Add encryption overview to agent instructions in AGENTS.md (#10207) * Add encryption overview to agent instructions in AGENTS.md * Update AGENTS.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Clarify nonce and wire overhead details in encryption section of copilot instructions * Enhance encryption documentation in copilot instructions and agents guide for clarity on key management and reset behaviors * Update .github/copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix botched merge conflict resolution --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 66 ++++++++++++++++++++++++++++++++- AGENTS.md | 9 +++++ src/detect/ScanI2C.h | 1 + 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 89e1c5c11..2d7457102 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -70,6 +70,70 @@ PKI (Public Key Infrastructure) messages have special handling: - Accepted on a special "PKI" channel - Allow encrypted DMs between nodes that discovered each other on downlink-enabled channels +## Encryption & Key Management + +Meshtastic packets on the air are typically encrypted one of two ways: the **per-channel symmetric** layer (AES-CTR with a shared PSK) for broadcasts and channel traffic, and the **per-peer PKI** layer (X25519 ECDH → AES-256-CCM) for direct messages and remote admin. A channel with a 0-byte PSK (or Ham mode, which wipes PSKs) transmits cleartext — see the size table below. Both are implemented in `src/mesh/CryptoEngine.cpp`; the send/receive dispatch lives in `src/mesh/Router.cpp`; admin authorization lives in `src/modules/AdminModule.cpp`. + +### High-level model + +- **Channels** are symmetric rooms: anyone with the PSK can read any message on the channel. Channel 0 is the "primary" channel and ships with the short-form default PSK on factory devices, forming the public mesh most users join. (The LoRa modem preset `LONG_FAST` lives on `config.lora.modem_preset` and is an independent field — don't conflate "channel 0 default PSK" with the modem preset name.) +- **DMs** addressed to a single node require PKI so that other holders of the channel PSK can't read them. Outside Ham mode, Meshtastic does not fall back to channel-symmetric encryption when the destination public key is unknown. +- **Remote admin** is a DM carrying an `AdminMessage`. The receiver only acts on it if the sender's public key is on its allowlist (`config.security.admin_key[0..2]`). +- **Ham mode** (`owner.is_licensed=true`, where `owner` is the local `meshtastic_User` record) disables PKI entirely and sends cleartext — FCC Part 97 prohibits encryption on amateur bands. +- **No ratchet, no session.** Every packet is encrypted from scratch — a stateless design that matches the high-loss, store-and-forward nature of LoRa. + +### Symmetric channel encryption (AES-CTR) + +`CryptoEngine::encryptPacket` / `decrypt` / `encryptAESCtr` in `src/mesh/CryptoEngine.cpp`. + +- **Cipher**: AES-CTR, AES-128 or AES-256 depending on key length. Same routine in both directions (CTR is a stream cipher, so encrypt == decrypt). +- **Key**: `ChannelSettings.psk` bytes. Size semantics: + - **0 bytes** → no encryption, cleartext on the air + - **1 byte** → short-form index into the well-known `defaultpsk[]` in `src/mesh/Channels.h`. Index 0 = cleartext; 1 = defaultpsk unchanged; 2..255 = defaultpsk with its last byte incremented by (index − 1). This is what the CLI's `--ch-set psk default` produces. + - **16 bytes** → raw AES-128 key + - **32 bytes** → raw AES-256 key + - **2..15 bytes** → zero-padded to 16 and used as AES-128 (with a warn log); **17..31 bytes** → zero-padded to 32 and used as AES-256 (with a warn log). Defensive fallback for malformed PSK input, not something to rely on. +- **Nonce (128 bit)**: `packet_id` (u64 LE) ‖ `from_node` (u32 LE) ‖ `block_counter` (u32, starts at 0). Built in `CryptoEngine::initNonce`. +- **No AEAD**: channel packets carry no MAC, so the channel-hash byte is not an integrity or authenticity check. `Channels::getHash` is a 1-byte XOR-derived hint over the channel name bytes and PSK bytes that helps receivers pick a candidate channel/PSK for decryption. Because it is only a small hint and collisions are easy to find, it should be described purely as a PSK-selection aid, not as a security filter an attacker cannot bypass. +- **Channel 0 is special in one way only**: it's the channel the Router attempts PKI decryption on before falling through to AES-CTR. Non-zero channels always go straight to AES-CTR. + +### PKI encryption for DMs (X25519 ECDH + AES-256-CCM) + +`CryptoEngine::encryptCurve25519` / `decryptCurve25519` in `src/mesh/CryptoEngine.cpp`. + +- **Keypair**: Curve25519 (aka X25519), 32-byte public + 32-byte private. Stored in `config.security.public_key` / `private_key`; the public half is mirrored into `owner.public_key` so it rides along in NodeInfo broadcasts and propagates through the mesh like any other identity field. +- **Key generation** (`generateKeyPair`): stirs `HardwareRNG::fill()` (64 B from platform TRNG when available), the 16-byte `myNodeInfo.device_id`, and a call to `random()` into the rweather/Crypto library's software RNG, then `Curve25519::dh1`. `regeneratePublicKey` recomputes the public half from a known private (used when restoring from backup). +- **Keygen entry points**: at boot, `NodeDB` calls `generateKeyPair` (or `regeneratePublicKey` when a stored private key is present and passes a low-entropy check) **directly** when `!owner.is_licensed` and `config.lora.region != UNSET`. `ensurePkiKeys` wraps the same logic for runtime/admin flows — it's the path `AdminModule::handleSetConfig` runs when first assigning a valid region or when security config is written; **do not assume it's the universal boot-time gate**, because the NodeDB path bypasses it. +- **Handshake**: `Curve25519::dh2(local_private, remote_public) → 32-byte shared secret → SHA-256 → 32-byte AES-256 key`. Recomputed per packet. The SHA-256 step is effectively a KDF over the raw ECDH output. +- **Cipher**: AES-256-CCM via `aes_ccm_ae` / `aes_ccm_ad` (`src/mesh/aes-ccm.cpp`). MAC length (the `M` parameter) is **8 bytes**. No AAD — the MAC covers ciphertext only. +- **Nonce (13 bytes / 104 bit)**: `aes_ccm_ae`/`aes_ccm_ad` use a 13-byte CCM nonce (`L = 2` is hardcoded in `src/mesh/aes-ccm.cpp`), not a 16-byte nonce. For PKI packets, `CryptoEngine::initNonce(fromNode, packetNum, extraNonce)` starts from the usual packet-derived nonce material, then overwrites nonce bytes `4..7` with a fresh 32-bit `extraNonce = random()`. The effective nonce bytes are therefore: bytes `0..3` = `packet_id`, bytes `4..7` = transmitted `extraNonce`, bytes `8..11` = `from_node`, byte `12` = `0x00`. The receiver reconstructs the same 13-byte nonce from the packet metadata plus the appended `extraNonce`. +- **Wire overhead**: 12 bytes appended to the ciphertext = 8-byte MAC ‖ 4-byte extraNonce. Defined as `MESHTASTIC_PKC_OVERHEAD = 12` in `src/mesh/RadioInterface.h`. Only the 4-byte `extraNonce` is sent; the rest of the 13-byte CCM nonce is reconstructed from packet fields as described above. The Router's send path checks this overhead against `MAX_LORA_PAYLOAD_LEN` before committing to PKI. +- **Send selection** (`Router::send`): the sender enters the PKI path when **all** hold — we're the originator AND not Ham mode AND not Portduino simradio AND not on the `serial`/`gpio` channels (unless the packet is already marked `pki_encrypted`) AND `config.security.private_key.size == 32` AND destination is a single node (not broadcast) AND the portnum isn't infrastructure. `TRACEROUTE_APP`, `NODEINFO_APP`, `ROUTING_APP`, and `POSITION_APP` are routed through channel encryption even when DMed (these need to be readable by relaying peers). Once on the PKI path, if the destination's public key isn't in our NodeDB the send **fails** with `PKI_SEND_FAIL_PUBLIC_KEY` — it does not silently fall back to channel encryption. If the client explicitly set `pki_encrypted=true` and any condition blocks PKI, the send fails with `PKI_FAILED`. +- **Receive selection** (`Router::perhapsDecode`): try PKI decrypt first when `channel == 0` AND `isToUs(p)` AND not broadcast AND both peers have public keys in NodeDB AND `rawSize > MESHTASTIC_PKC_OVERHEAD`. On success the packet gets `pki_encrypted=true` stamped and the sender's public key copied into `p->public_key` for downstream authorization. + +### Remote admin authorization + +Implemented in `src/modules/AdminModule.cpp` → `handleReceivedProtobuf`. The authorization check runs in this order: + +1. **Response messages** — if `messageIsResponse(r)` is true (the payload is a response to one of our earlier admin requests), it's accepted without any further check. The in-file comment flags this as a known-untightened gap: a stricter implementation would remember which `public_key` we last queried and reject responses that don't match. +2. **Local admin** — `mp.from == 0` (phone app over BLE, serial CLI, internal module); never travels over the air. **Rejected** if `config.security.is_managed` is true, because managed devices expect admin to arrive over the air through an authorized remote path. +3. **Legacy admin channel (deprecated)** — the packet arrived on a channel named literally `"admin"`. Gated by `config.security.admin_channel_enabled`; returns `NOT_AUTHORIZED` if the flag is false. Kept for backward compatibility; new deployments should use PKI admin. +4. **PKI admin (preferred for remote)** — `mp.pki_encrypted == true` AND `mp.public_key` matches one of `config.security.admin_key[0..2]` (up to three authorized 32-byte Curve25519 public keys, typically copied from the admin node's own `user.public_key`). +5. **Fallthrough** → `NOT_AUTHORIZED`. + +On top of authorization, any remote admin message that **mutates** state (not a request, not a response) also has to pass a session-key check (`checkPassKey`): the client must first pull a fresh 8-byte `session_passkey` via `get_admin_session_key_request`, then echo that passkey back in the mutating message. The device rotates the passkey after 150 s and rejects values older than 300 s — a narrow anti-replay window on top of the PKI layer. + +`config.security.is_managed = true` disables **local** admin writes (`mp.from == 0` is rejected). It does not by itself force every admin action through PKI — the legacy `"admin"` channel still authorizes remote admin when `config.security.admin_channel_enabled == true`. The AdminModule refuses to persist `is_managed=true` unless at least one `admin_key` is populated — a deliberate guard against operators locking themselves out. + +### Key-rotation hazards (actions that invalidate peers) + +- **`factory_reset_device`** (the "full" variant, calls `NodeDB::factoryReset(eraseBleBonds=true)`) → **wipes** the X25519 private key; a fresh keypair is generated on the next region-set. Every existing peer holds the old public key, so DMs to this node silently fail PKI decrypt until every peer re-exchanges NodeInfo. +- **`factory_reset_config`** (the "partial" variant, calls `NodeDB::factoryReset()` with `eraseBleBonds=false`) → **preserves** the X25519 private key in `installDefaultConfig(preserveKey=true)`; the public key is zeroed and gets rebuilt from the preserved private key on the next boot via the NodeDB path's `regeneratePublicKey` call. Identity is preserved and the mesh does not need to re-exchange keys. +- **`region=UNSET → valid region`** → `ensurePkiKeys` runs inside the same `handleSetConfig` path; missing keys get generated at that moment. +- **Ham mode transitions** — entering Ham mode (`user.is_licensed=true`) runs `Channels::ensureLicensedOperation`, which **wipes every channel PSK** (all traffic becomes cleartext) and disables the legacy admin channel. The X25519 private key is preserved on the device but not used because `Router::send` skips PKI when `owner.is_licensed` is true. Leaving Ham mode re-enables PKI with the preserved keypair but does not restore the wiped channel PSKs — the operator has to re-set them. +- **Channel 0 PSK change** → every peer must re-learn the channel hash; cached NodeInfo becomes temporarily unreachable until the next broadcast. +- **`security.private_key` blanked via admin** → regenerates both halves (unless in Ham mode) and propagates the new public key via NodeInfo. + ## Project Structure ``` @@ -80,7 +144,7 @@ firmware/ │ │ ├── NodeDB.* # Node database management │ │ ├── Router.* # Packet routing │ │ ├── Channels.* # Channel management -│ │ ├── CryptoEngine.* # AES-CCM encryption +│ │ ├── CryptoEngine.* # AES-CTR (channels) + X25519 ECDH→AES-256-CCM (PKI for DMs/admin) │ │ ├── *Interface.* # Radio interface implementations │ │ ├── api/ # WiFi/Ethernet server APIs (ServerAPI, PacketAPI) │ │ ├── http/ # HTTP server (WebServer, ContentHandler) diff --git a/AGENTS.md b/AGENTS.md index b3fa1970c..8f3474640 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,6 +48,15 @@ Three test-and-diagnose workflows exist as slash commands: Bodies live in `.claude/commands/` and `.github/prompts/` respectively. `.claude/commands/README.md` is the index. +## Encryption at a glance + +Two layers, both in `src/mesh/CryptoEngine.cpp`: + +- **Channel (symmetric)** — **AES-CTR** with a channel-wide PSK (AES-128 or AES-256). Nonce = packet_id ‖ from_node ‖ block_counter. No AEAD; integrity is soft (channel-hash filter). The well-known default PSK lives in `src/mesh/Channels.h`; a 1-byte PSK is a short-form index into it. +- **Per-peer PKI** — **X25519 ECDH** (Curve25519, 32-byte keys) → SHA-256 → **AES-256-CCM** with an 8-byte MAC. Fresh 32-bit `extraNonce` per packet, sent in the clear alongside the MAC. 12-byte wire overhead (`MESHTASTIC_PKC_OVERHEAD`). Used for DMs. Also used for remote admin (`src/modules/AdminModule.cpp`), where AdminMessage authorization is gated by `config.security.admin_key[0..2]`. Disabled entirely in Ham mode (`user.is_licensed=true`). + +Key rotation to never trigger casually: only the **full** factory reset (`factory_reset_device`, `eraseBleBonds=true`) wipes `security.private_key` and regenerates the keypair — every peer holds the old public key, so DMs silently fail PKI decrypt until NodeInfo re-exchanges. The **partial** config reset (`factory_reset_config`) preserves the private key and doesn't invalidate peer relationships. Explicitly blanking `security.private_key` via admin also triggers regen. See the **Encryption & Key Management** section of `.github/copilot-instructions.md` for the full spec (nonce layout, send/receive selection logic including infrastructure-portnum exceptions, admin-key + session-passkey authorization, `is_managed` scope, key-rotation hazards). + ## House rules - **No destructive device operations without operator approval.** `factory_reset`, `erase_and_flash`, `reboot`, `shutdown`, history-rewriting git ops — describe the action and stop. Operator authorizes. diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 3d13a68af..054c7854b 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -34,6 +34,7 @@ class ScanI2C SHT31, SHT4X, SHTC3, + SHTXX, LPS22HB, QMC6310U, QMC6310N, From 9da0ee9c51d14b7b32dd3fafbd017a99b15fdeb4 Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 21 Apr 2026 09:07:53 -0400 Subject: [PATCH 52/67] NimBLE-Arduino -> Arduino "BLE" (3.3.x) migration (#10164) * NimBLE-Arduino -> Arduino "BLE" (3.3.x) migration * More NimBLE * Fix Device Name in ATT Read Request (0x2A00). Device Name is exposed in two places: - Advertisement data: this is set properly in startAdvertising. - GATT attribute Device Name (0x2A00). This one is handled internally in NimBLE and comes from ble_svc_gap_device_name_set. This is set initially, but then BLEDevice::createServer calls ble_svc_gap_init which resets the device name. This causes the device to apparently "change name after pairing": < ACL Data TX:... flags 0x00 dlen 7 #113 [hci0] 14.241149 ATT: Read Request (0x0a) len 2 Handle: 0x0003 Type: Device Name (0x2a00) > ACL Data RX: Handle 2048 flags 0x02 dlen 11 #115 [hci0] 14.269050 ATT: Read Response (0x0b) len 6 Value[6]: 6e696d626c65 # "nimble" Workaround this by setting the device name once again after BLEDevice::createServer. * Temporarily lower CORE_DEBUG_LEVEL to INFO to avoid triggering an apparent ESP-IDF Bluetooth bug when re-connecting to Pixel 8 Android devices. Initial pairing works, but after ESP32 is rebooted, phone fails to reconnect. Meshtastic app shows it as disconnecting immediately. LightBlue shows a more detailed error "Peripheral Connection - Warning: onConnectionStatusChange: status 61" (0x3D - MIC Failure). Bug report to Espresssif: https://github.com/espressif/esp-idf/issues/18126#issuecomment-4286197744 * Temporarily disable ble_gap_set_data_len, causes crash with Pixel 8 Android reconnect. Crash looks like this: [ 11966][E][BLEAdvertising.cpp:341] setScanResponseData(): ble_gap_adv_rsp_set_data: 22 [ 11975][E][BLEAdvertising.cpp:1554] start(): Host reset, wait for sync. ERROR | ??:??:?? 11 BLE failed to start advertising Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. Core 0 register dump: PC : 0x420e6190 PS : 0x00060730 A0 : 0x820e158b A1 : 0x3fce50c0 A2 : 0x00000000 A3 : 0x3fcb8600 A4 : 0x3fcb85cc A5 : 0x00000000 A6 : 0x00000000 A7 : 0x00000c03 A8 : 0x00000000 A9 : 0x3fce50b0 A10 : 0x0000000e A11 : 0x00000000 A12 : 0x00000010 A13 : 0x3fce50e0 A14 : 0x00000c03 A15 : 0x00000001 SAR : 0x0000001e EXCCAUSE: 0x0000001c EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000 Backtrace: 0x420e618d:0x3fce50c0 0x420e1588:0x3fce5110 0x420dfe87:0x3fce5200 0x420dfefb:0x3fce5220 0x420dff3f:0x3fce5240 0x4219602b:0x3fce5260 0x4037b0e5:0x3fce5280 0x4201edf3:0x3fce52a0 Connection seems fast enough even without this. We'll investigate the reason for the crash and re-enable once it's safe. --------- Co-authored-by: Catalin Patulea --- src/nimble/NimbleBluetooth.cpp | 401 +++++++++++++------------------- src/nimble/NimbleBluetooth.h | 5 - variants/esp32/esp32-common.ini | 17 +- variants/esp32/esp32.ini | 2 - variants/esp32c3/esp32c3.ini | 6 +- variants/esp32c6/esp32c6.ini | 6 +- variants/esp32s3/esp32s3.ini | 6 +- 7 files changed, 177 insertions(+), 266 deletions(-) diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 3bb4ce817..71bdb3cb8 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -10,23 +10,18 @@ #include "mesh/PhoneAPI.h" #include "mesh/mesh-pb-constants.h" #include "sleep.h" -#include +#include +#include +#include +#include +#include #include #include -#ifdef NIMBLE_TWO -#include "NimBLEAdvertising.h" -#include "NimBLEExtAdvertising.h" #include "PowerStatus.h" -#endif -#if defined(CONFIG_NIMBLE_CPP_IDF) #include "host/ble_gap.h" -#else -#include "nimble/nimble/host/include/host/ble_gap.h" -#endif - -#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6) +#include "host/ble_store.h" namespace { @@ -34,7 +29,6 @@ constexpr uint16_t kPreferredBleMtu = 517; constexpr uint16_t kPreferredBleTxOctets = 251; constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8; } // namespace -#endif // Debugging options: careful, they slow things down quite a bit! // #define DEBUG_NIMBLE_ON_READ_TIMING // uncomment to time onRead duration @@ -44,10 +38,10 @@ constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8; #define NIMBLE_BLUETOOTH_TO_PHONE_QUEUE_SIZE 3 #define NIMBLE_BLUETOOTH_FROM_PHONE_QUEUE_SIZE 3 -NimBLECharacteristic *fromNumCharacteristic; -NimBLECharacteristic *BatteryCharacteristic; -NimBLECharacteristic *logRadioCharacteristic; -NimBLEServer *bleServer; +BLECharacteristic *fromNumCharacteristic; +BLECharacteristic *BatteryCharacteristic; +BLECharacteristic *logRadioCharacteristic; +BLEServer *bleServer; static bool passkeyShowing; static std::atomic nimbleBluetoothConnHandle{BLE_HS_CONN_HANDLE_NONE}; // BLE_HS_CONN_HANDLE_NONE means "no connection" @@ -118,7 +112,8 @@ 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. NOTIFY IS BROKEN: - - Adding NIMBLE_PROPERTY::NOTIFY to FromRadioCharacteristic appears to break things. It is NOT backwards compatible. + - Adding BLECharacteristic::PROPERTY_NOTIFY to FromRadioCharacteristic appears to break things. It is NOT backwards + compatible. 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 @@ -139,7 +134,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread std::mutex fromPhoneMutex; std::atomic fromPhoneQueueSize{0}; // We use array here (and pay the cost of memcpy) to avoid dynamic memory allocations and frees across FreeRTOS tasks. - std::array fromPhoneQueue{}; + std::array fromPhoneQueue{}; /* Packets to phone (BLE onRead callback) */ std::mutex toPhoneMutex; @@ -301,7 +296,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread LOG_DEBUG("NimbleBluetooth: handling ToRadio packet, fromPhoneQueueSize=%u", fromPhoneQueueSize.load()); // Pop the front of fromPhoneQueue, holding the mutex only briefly while we pop. - NimBLEAttValue val; + BLEValue val; { // scope for fromPhoneMutex mutex std::lock_guard guard(fromPhoneMutex); val = fromPhoneQueue[0]; @@ -316,7 +311,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread fromPhoneQueueSize--; } - handleToRadio(val.data(), val.length()); + handleToRadio(val.getData(), val.getLength()); } } @@ -328,9 +323,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread PhoneAPI::onNowHasData(fromRadioNum); #ifdef DEBUG_NIMBLE_NOTIFY - int currentNotifyCount = notifyCount.fetch_add(1); - uint8_t cc = bleServer->getConnectedCount(); // 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); @@ -340,13 +333,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread put_le32(val, fromRadioNum); 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(); -#endif } /// Check the current underlying physical link to see if the client is currently connected @@ -409,14 +396,9 @@ static BluetoothPhoneAPI *bluetoothPhoneAPI; // Last ToRadio value received from the phone static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE]; -class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks +class NimbleBluetoothToRadioCallback : public BLECharacteristicCallbacks { -#ifdef NIMBLE_TWO - virtual void onWrite(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo &connInfo) -#else - virtual void onWrite(NimBLECharacteristic *pCharacteristic) - -#endif + void onWrite(BLECharacteristic *pCharacteristic) override { // 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. @@ -428,15 +410,17 @@ class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks LOG_DEBUG("BLE onWrite(%d): start millis=%d", currentWriteCount, startMillis); #endif - auto val = pCharacteristic->getValue(); + // Create a BLEValue and populate it with the received data + BLEValue val; + val.setValue(pCharacteristic->getData(), pCharacteristic->getLength()); - if (memcmp(lastToRadio, val.data(), val.length()) != 0) { + if (memcmp(lastToRadio, val.getData(), val.getLength()) != 0) { 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* // fromPhoneQueueSize. (It's okay if fromPhoneQueueSize *decreases* in the main task meanwhile.) - memcpy(lastToRadio, val.data(), val.length()); + memcpy(lastToRadio, val.getData(), val.getLength()); - { // scope for fromPhoneMutex mutex + { // scope for fromPhoneMutex mutexv, pCharacteristic->getLen // Append to fromPhoneQueue, protected by fromPhoneMutex. Hold the mutex as briefly as possible. std::lock_guard guard(bluetoothPhoneAPI->fromPhoneMutex); bluetoothPhoneAPI->fromPhoneQueue.at(bluetoothPhoneAPI->fromPhoneQueueSize) = val; @@ -450,24 +434,21 @@ class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks #ifdef DEBUG_NIMBLE_ON_WRITE_TIMING int finishMillis = millis(); LOG_DEBUG("BLE onWrite(%d): append to fromPhoneQueue took %u ms. numBytes=%d", currentWriteCount, - finishMillis - startMillis, val.length()); + finishMillis - startMillis, val.getLength()); #endif } else { - LOG_WARN("BLE onWrite(%d): Drop ToRadio packet, fromPhoneQueue full (%u bytes)", currentWriteCount, val.length()); + LOG_WARN("BLE onWrite(%d): Drop ToRadio packet, fromPhoneQueue full (%u bytes)", currentWriteCount, + val.getLength()); } } else { - LOG_DEBUG("BLE onWrite(%d): Drop duplicate ToRadio packet (%u bytes)", currentWriteCount, val.length()); + LOG_DEBUG("BLE onWrite(%d): Drop duplicate ToRadio packet (%u bytes)", currentWriteCount, val.getLength()); } } }; -class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks +class NimbleBluetoothFromRadioCallback : public BLECharacteristicCallbacks { -#ifdef NIMBLE_TWO - virtual void onRead(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo &connInfo) -#else - virtual void onRead(NimBLECharacteristic *pCharacteristic) -#endif + void onRead(BLECharacteristic *pCharacteristic) override { // CAUTION: This callback runs in the NimBLE task!!! Don't do anything except communicate with the main task's runOnce. @@ -573,34 +554,15 @@ class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks } }; -class NimbleBluetoothServerCallback : public NimBLEServerCallbacks +class NimbleBluetoothSecurityCallback : public BLESecurityCallbacks { -#ifdef NIMBLE_TWO - public: - NimbleBluetoothServerCallback(NimbleBluetooth *ble) { this->ble = ble; } - - private: - NimbleBluetooth *ble; - - virtual uint32_t onPassKeyDisplay() -#else - virtual uint32_t onPassKeyRequest() -#endif + void onPassKeyNotify(uint32_t passkey) override { - uint32_t passkey = 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 - passkey = random(100000, 999999); - } - LOG_INFO("*** Enter passkey %d on the peer side ***", passkey); - + LOG_INFO("*** Enter passkey %06u on the peer side ***", passkey); powerFSM.trigger(EVENT_BLUETOOTH_PAIR); meshtastic::BluetoothStatus newStatus(std::to_string(passkey)); bluetoothStatus->updateStatus(&newStatus); - -#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus +#if HAS_SCREEN if (screen) { screen->startAlert([passkey](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void { char btPIN[16] = "888888"; @@ -630,15 +592,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks } #endif passkeyShowing = true; - - return passkey; } - -#ifdef NIMBLE_TWO - virtual void onAuthenticationComplete(NimBLEConnInfo &connInfo) -#else - virtual void onAuthenticationComplete(ble_gap_conn_desc *desc) -#endif + void onAuthenticationComplete(ble_gap_conn_desc *desc) override { LOG_INFO("BLE authentication complete"); @@ -646,58 +601,47 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks bluetoothStatus->updateStatus(&newStatus); clearPairingDisplay(); - // Store the connection handle for future use -#ifdef NIMBLE_TWO - nimbleBluetoothConnHandle = connInfo.getConnHandle(); -#else nimbleBluetoothConnHandle = desc->conn_handle; -#endif } +}; -#ifdef NIMBLE_TWO - virtual void onConnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo) +class NimbleBluetoothServerCallback : public BLEServerCallbacks +{ + public: + explicit NimbleBluetoothServerCallback(NimbleBluetooth *ble) : ble(ble) {} + + private: + NimbleBluetooth *ble; + + void onConnect(BLEServer *pServer, struct ble_gap_conn_desc *desc) { - LOG_INFO("BLE incoming connection %s", connInfo.getAddress().toString().c_str()); + BLEAddress peer_addr(desc->peer_id_addr); + LOG_INFO("BLE incoming connection %s", peer_addr.toString().c_str()); - 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 + const uint16_t connHandle = desc->conn_handle; + // 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); if (dataLenResult == 0) { LOG_INFO("BLE conn %u requested data length %u bytes", connHandle, kPreferredBleTxOctets); } else { LOG_WARN("Failed to raise data length for conn %u, rc=%d", connHandle, dataLenResult); } +#endif - LOG_INFO("BLE conn %u initial MTU %u (target %u)", connHandle, connInfo.getMTU(), kPreferredBleMtu); + LOG_INFO("BLE conn %u peer MTU %u (target %u)", connHandle, pServer->getPeerMTU(connHandle), kPreferredBleMtu); pServer->updateConnParams(connHandle, 6, 12, 0, 200); } -#endif -#ifdef NIMBLE_TWO - virtual void onDisconnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo, int reason) + void onDisconnect(BLEServer *pServer, struct ble_gap_conn_desc *desc) { - LOG_INFO("BLE disconnect reason: %d", reason); -#else - virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc) - { - LOG_INFO("BLE disconnect"); -#endif -#ifdef NIMBLE_TWO + LOG_INFO("BLE disconnected"); if (ble->isDeInit) return; -#else - if (nimbleBluetooth && nimbleBluetooth->isDeInit) - return; -#endif meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED); bluetoothStatus->updateStatus(&newStatus); @@ -722,43 +666,51 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks bluetoothPhoneAPI->writeCount = 0; } - // Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection memset(lastToRadio, 0, sizeof(lastToRadio)); - nimbleBluetoothConnHandle = BLE_HS_CONN_HANDLE_NONE; // BLE_HS_CONN_HANDLE_NONE means "no connection" + nimbleBluetoothConnHandle = BLE_HS_CONN_HANDLE_NONE; -#ifdef NIMBLE_TWO - // Restart Advertising 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 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() { - // No measurable power saving for ESP32 during light-sleep(?) #ifndef ARCH_ESP32 - // Shutdown bluetooth for minimum power draw LOG_INFO("Disable bluetooth"); - NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); + BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->reset(); pAdvertising->stop(); #endif } -// Proper shutdown for ESP32. Needs reboot to reverse. void NimbleBluetooth::deinit() { #ifdef ARCH_ESP32 @@ -768,21 +720,17 @@ void NimbleBluetooth::deinit() #ifdef BLE_LED digitalWrite(BLE_LED, LED_STATE_OFF); #endif -#ifndef NIMBLE_TWO - NimBLEDevice::deinit(); -#endif #endif } -// Has initial setup been completed bool NimbleBluetooth::isActive() { - return bleServer; + return bleServer != nullptr; } bool NimbleBluetooth::isConnected() { - return bleServer->getConnectedCount() > 0; + return bleServer && bleServer->getConnectedCount() > 0; } int NimbleBluetooth::getRssi() @@ -795,9 +743,9 @@ int NimbleBluetooth::getRssi() uint16_t connHandle = nimbleBluetoothConnHandle.load(); if (connHandle == BLE_HS_CONN_HANDLE_NONE) { - const auto peers = bleServer->getPeerDevices(); + const auto peers = bleServer->getPeerDevices(true); if (!peers.empty()) { - connHandle = peers.front(); + connHandle = peers.begin()->first; nimbleBluetoothConnHandle = connHandle; } } @@ -825,74 +773,84 @@ void NimbleBluetooth::setup() LOG_INFO("Init the NimBLE bluetooth module"); - NimBLEDevice::init(getDeviceName()); - NimBLEDevice::setPower(ESP_PWR_LVL_P9); + BLEDevice::init(getDeviceName()); + BLEDevice::setPower(ESP_PWR_LVL_P9); -#if NIMBLE_ENABLE_2M_PHY && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)) - int mtuResult = NimBLEDevice::setMTU(kPreferredBleMtu); + int mtuResult = BLEDevice::setMTU(kPreferredBleMtu); if (mtuResult == 0) { LOG_INFO("BLE MTU request set to %u", kPreferredBleMtu); } else { LOG_WARN("Unable to request MTU %u, rc=%d", kPreferredBleMtu, mtuResult); } - int phyResult = ble_gap_set_prefered_default_le_phy(BLE_GAP_LE_PHY_2M_MASK, BLE_GAP_LE_PHY_2M_MASK); - if (phyResult == 0) { - LOG_INFO("BLE default PHY preference set to 2M"); - } else { - LOG_WARN("Failed to prefer 2M PHY by default, rc=%d", phyResult); - } - - 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 - + BLESecurity *pSecurity = new BLESecurity(); + pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); + pSecurity->setRespEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); 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); + // 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 { + // No IO capability for no PIN mode + pSecurity->setCapability(ESP_IO_CAP_NONE); + // No PIN mode: no MITM protection + pSecurity->setAuthenticationMode(true, false, false); } - bleServer = NimBLEDevice::createServer(); -#ifdef NIMBLE_TWO - NimbleBluetoothServerCallback *serverCallbacks = new NimbleBluetoothServerCallback(this); -#else - NimbleBluetoothServerCallback *serverCallbacks = new NimbleBluetoothServerCallback(); -#endif - bleServer->setCallbacks(serverCallbacks, true); + // 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)); setupService(); startAdvertising(); } void NimbleBluetooth::setupService() { - NimBLEService *bleService = bleServer->createService(MESH_SERVICE_UUID); - NimBLECharacteristic *ToRadioCharacteristic; - NimBLECharacteristic *FromRadioCharacteristic; + BLEService *bleService = bleServer->createService(MESH_SERVICE_UUID); + BLECharacteristic *ToRadioCharacteristic; + BLECharacteristic *FromRadioCharacteristic; // Define the characteristics that the app is looking for if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) { - ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE); + ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, BLECharacteristic::PROPERTY_WRITE); // Allow notifications so phones can stream FromRadio without polling. - FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ); - fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ); - logRadioCharacteristic = - bleService->createCharacteristic(LOGRADIO_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ, 512U); - } else { - ToRadioCharacteristic = bleService->createCharacteristic( - TORADIO_UUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_AUTHEN | NIMBLE_PROPERTY::WRITE_ENC); - FromRadioCharacteristic = bleService->createCharacteristic( - FROMRADIO_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC); + FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, BLECharacteristic::PROPERTY_READ); fromNumCharacteristic = - bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ | - NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC); + bleService->createCharacteristic(FROMNUM_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ); + logRadioCharacteristic = bleService->createCharacteristic(LOGRADIO_UUID, BLECharacteristic::PROPERTY_NOTIFY | + BLECharacteristic::PROPERTY_READ); + } else { + ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, BLECharacteristic::PROPERTY_WRITE | + BLECharacteristic::PROPERTY_WRITE_AUTHEN | + BLECharacteristic::PROPERTY_WRITE_ENC); + FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_READ_AUTHEN | + BLECharacteristic::PROPERTY_READ_ENC); + fromNumCharacteristic = bleService->createCharacteristic( + FROMNUM_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_READ_AUTHEN | BLECharacteristic::PROPERTY_READ_ENC); logRadioCharacteristic = bleService->createCharacteristic( - LOGRADIO_UUID, - NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC, 512U); + LOGRADIO_UUID, BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_READ_AUTHEN | BLECharacteristic::PROPERTY_READ_ENC); } bluetoothPhoneAPI = new BluetoothPhoneAPI(); @@ -905,76 +863,31 @@ void NimbleBluetooth::setupService() bleService->start(); // Setup the battery service - NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service - BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic) - (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); + BLEService *batteryService = bleServer->createService(BLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service + BLE2904 *batteryLevelDescriptor = new BLE2904(); + batteryLevelDescriptor->setFormat(BLE2904::FORMAT_UINT8); batteryLevelDescriptor->setNamespace(1); 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(); } -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 void updateBatteryLevel(uint8_t level) { if ((config.bluetooth.enabled == true) && bleServer && nimbleBluetooth->isConnected()) { BatteryCharacteristic->setValue(&level, 1); -#ifdef NIMBLE_TWO - BatteryCharacteristic->notify(&level, 1, BLE_HS_CONN_HANDLE_NONE); -#else BatteryCharacteristic->notify(); -#endif } } void NimbleBluetooth::clearBonds() { LOG_INFO("Clearing bluetooth bonds!"); - NimBLEDevice::deleteAllBonds(); + ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_PEER_SEC, nullptr); + ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, nullptr); } void NimbleBluetooth::sendLog(const uint8_t *logMessage, size_t length) @@ -982,16 +895,14 @@ void NimbleBluetooth::sendLog(const uint8_t *logMessage, size_t length) if (!bleServer || !isConnected() || length > 512) { return; } -#ifdef NIMBLE_TWO - logRadioCharacteristic->notify(logMessage, length, BLE_HS_CONN_HANDLE_NONE); -#else - logRadioCharacteristic->notify(logMessage, length, true); -#endif + logRadioCharacteristic->setValue(logMessage, length); + logRadioCharacteristic->notify(); } void clearNVS() { - NimBLEDevice::deleteAllBonds(); + 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 diff --git a/src/nimble/NimbleBluetooth.h b/src/nimble/NimbleBluetooth.h index 458fa4a67..2956fe6d0 100644 --- a/src/nimble/NimbleBluetooth.h +++ b/src/nimble/NimbleBluetooth.h @@ -12,16 +12,11 @@ class NimbleBluetooth : BluetoothApi bool isConnected(); int getRssi(); void sendLog(const uint8_t *logMessage, size_t length); -#if defined(NIMBLE_TWO) void startAdvertising(); -#endif bool isDeInit = false; private: void setupService(); -#if !defined(NIMBLE_TWO) - void startAdvertising(); -#endif }; void setBluetoothEnable(bool enable); diff --git a/variants/esp32/esp32-common.ini b/variants/esp32/esp32-common.ini index 52de2acd5..6bc3cff6b 100644 --- a/variants/esp32/esp32-common.ini +++ b/variants/esp32/esp32-common.ini @@ -38,7 +38,11 @@ build_flags = -Isrc/platform/esp32 -std=gnu++17 -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG - -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + # DO NOT INCREASE THIS TO DEBUG. It appears to trigger a bug in ESP-IDF + # 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 -DAXP_DEBUG_PORT=Serial -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING @@ -70,9 +74,10 @@ lib_deps = lib_ignore = segger_rtt + NimBLE-Arduino ESP32 BLE Arduino ; Ignore builtin NimBLE libs - BLE + ; BLE BluetoothSerial SimpleBLE WiFiProv @@ -132,7 +137,8 @@ custom_component_remove = custom_sdkconfig = ; CONFIG_LOG_DEFAULT_LEVEL=4 ; CONFIG_LOG_MAXIMUM_LEVEL=4 - ; CONFIG_BT_NIMBLE_CPP_LOG_LEVEL=1 + '# 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 @@ -270,6 +276,7 @@ custom_sdkconfig = 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 @@ -281,7 +288,7 @@ custom_sdkconfig = CONFIG_BT_NIMBLE_TPS_SERVICE=n CONFIG_BT_NIMBLE_IAS_SERVICE=n CONFIG_BT_NIMBLE_LLS_SERVICE=n - CONFIG_BT_NIMBLE_SPS_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 @@ -320,7 +327,7 @@ custom_sdkconfig = CONFIG_ARDUINO_SELECTIVE_WiFi=y CONFIG_ARDUINO_SELECTIVE_NetworkClientSecure=y CONFIG_ARDUINO_SELECTIVE_WiFiProv=n - CONFIG_ARDUINO_SELECTIVE_BLE=n + CONFIG_ARDUINO_SELECTIVE_BLE=y CONFIG_ARDUINO_SELECTIVE_BluetoothSerial=n CONFIG_ARDUINO_SELECTIVE_SimpleBLE=n CONFIG_ARDUINO_SELECTIVE_RainMaker=n diff --git a/variants/esp32/esp32.ini b/variants/esp32/esp32.ini index 590a189be..8dbc25237 100644 --- a/variants/esp32/esp32.ini +++ b/variants/esp32/esp32.ini @@ -31,8 +31,6 @@ lib_deps = ${environmental_base.lib_deps} ${environmental_extra_no_bsec.lib_deps} ${radiolib_base.lib_deps} - # renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino - h2zero/NimBLE-Arduino@1.4.3 # TODO renovate https://github.com/mverch67/libpax/archive/6f52ee989301cdabaeef00bcbf93bff55708ce2f.zip # renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib diff --git a/variants/esp32c3/esp32c3.ini b/variants/esp32c3/esp32c3.ini index 53dde1311..02042047f 100644 --- a/variants/esp32c3/esp32c3.ini +++ b/variants/esp32c3/esp32c3.ini @@ -14,9 +14,9 @@ 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 + ; CONFIG_BT_NIMBLE_EXT_ADV=y + ; CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257 + ; CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2 lib_deps = ${esp32_common.lib_deps} diff --git a/variants/esp32c6/esp32c6.ini b/variants/esp32c6/esp32c6.ini index df6aaf746..ae91e6e81 100644 --- a/variants/esp32c6/esp32c6.ini +++ b/variants/esp32c6/esp32c6.ini @@ -20,9 +20,9 @@ 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 + ; CONFIG_BT_NIMBLE_EXT_ADV=y + ; CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257 + ; CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2 lib_ignore = ${esp32_common.lib_ignore} diff --git a/variants/esp32s3/esp32s3.ini b/variants/esp32s3/esp32s3.ini index 9423f650d..17b451d42 100644 --- a/variants/esp32s3/esp32s3.ini +++ b/variants/esp32s3/esp32s3.ini @@ -10,9 +10,9 @@ build_flags = custom_sdkconfig = ${esp32_common.custom_sdkconfig} - CONFIG_BT_NIMBLE_EXT_ADV=y - CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257 - CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2 + ; CONFIG_BT_NIMBLE_EXT_ADV=y + ; CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=257 + ; CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2 lib_deps = ${esp32_common.lib_deps} From fc871f42e475f4a8f79de0deb778ebe00c680176 Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 21 Apr 2026 09:15:09 -0400 Subject: [PATCH 53/67] Add extension from pioarduino nag "Jason2866.esp-decoder" --- .vscode/extensions.json | 1 + variants/esp32s3/CDEBYTE_EoRa-Hub/variant.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 670d668e2..66d8356e5 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ + "Jason2866.esp-decoder", "pioarduino.pioarduino-ide" ], "unwantedRecommendations": [ diff --git a/variants/esp32s3/CDEBYTE_EoRa-Hub/variant.h b/variants/esp32s3/CDEBYTE_EoRa-Hub/variant.h index 5decc7eb2..628ebcf8b 100644 --- a/variants/esp32s3/CDEBYTE_EoRa-Hub/variant.h +++ b/variants/esp32s3/CDEBYTE_EoRa-Hub/variant.h @@ -7,7 +7,7 @@ #define BUTTON_PIN 0 // BOOT button #define BATTERY_PIN 1 -#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_CHANNEL ADC_CHANNEL_0 #define ADC_MULTIPLIER 103.0 // Calibrated value #define ADC_ATTENUATION ADC_ATTEN_DB_0 #define ADC_CTRL 37 From 4090d9f2b39d98f7b28081fa74a8a5a89dddb056 Mon Sep 17 00:00:00 2001 From: nightjoker7 <47129685+nightjoker7@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:50:01 -0500 Subject: [PATCH 54/67] SX126x: re-apply 0x8B5 register in resetAGC() to preserve RX sensitivity (#10219) The CALIBRATE_ALL (0x7F) command inside resetAGC() clears bit 0 of the undocumented 0x8B5 register. That bit is set once in init() by #9571 and #9777 to improve SX1262 RX sensitivity, and the AGC-reset path was not re-applying it. Result: every SX1262 node silently loses the RX sensitivity patch ~60s after boot and never recovers until reboot. Empirically confirmed on Heltec Mesh Node T114 (nRF52840 + SX1262): - Post-calibration read of 0x8B5 = 0x04 (bit 0 cleared) - After re-apply: 0x05 (bit 0 set) Reproducible every AGC_RESET_INTERVAL_MS tick. Fix re-applies the register bit alongside the existing post-calibration re-applies (setDio2AsRfSwitch, setRxBoostedGainMode). --- src/mesh/SX126xInterface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index bcb08f2c5..44c4a805a 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -455,6 +455,15 @@ template void SX126xInterface::resetAGC() // RX boosted gain mode lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain); + // Re-apply the undocumented 0x8B5 RX sensitivity patch that was set in init(). + // The CALIBRATE_ALL (0x7F) command above clears bit 0 of register 0x8B5, which + // silently removes the RX sensitivity improvement introduced in #9571 / #9777. + // Without this re-apply, every SX1262 node loses its RX boost ~60s after boot + // and never recovers until reboot. See empirical evidence in the PR description. + if (module.SPIsetRegValue(0x8B5, 0x01, 0, 0) != RADIOLIB_ERR_NONE) { + LOG_WARN("SX126x resetAGC: failed to re-apply 0x8B5 RX sensitivity patch"); + } + // 6. Resume receiving startReceive(); } From 63bce1f01ae7d3efb154543b0b78057f21481b23 Mon Sep 17 00:00:00 2001 From: Jaime Roldan Date: Tue, 21 Apr 2026 09:52:19 -0500 Subject: [PATCH 55/67] fix(nodedb): force null-terminate name fields in UserLite/User conversions (#8174) (#10218) --- src/mesh/TypeConversions.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesh/TypeConversions.cpp b/src/mesh/TypeConversions.cpp index 75195bd42..201a703e2 100644 --- a/src/mesh/TypeConversions.cpp +++ b/src/mesh/TypeConversions.cpp @@ -81,7 +81,9 @@ meshtastic_UserLite TypeConversions::ConvertToUserLite(meshtastic_User user) meshtastic_UserLite lite = meshtastic_UserLite_init_default; strncpy(lite.long_name, user.long_name, sizeof(lite.long_name)); + lite.long_name[sizeof(lite.long_name) - 1] = '\0'; strncpy(lite.short_name, user.short_name, sizeof(lite.short_name)); + lite.short_name[sizeof(lite.short_name) - 1] = '\0'; lite.hw_model = user.hw_model; lite.role = user.role; lite.is_licensed = user.is_licensed; @@ -99,7 +101,9 @@ meshtastic_User TypeConversions::ConvertToUser(uint32_t nodeNum, meshtastic_User snprintf(user.id, sizeof(user.id), "!%08x", nodeNum); strncpy(user.long_name, lite.long_name, sizeof(user.long_name)); + user.long_name[sizeof(user.long_name) - 1] = '\0'; strncpy(user.short_name, lite.short_name, sizeof(user.short_name)); + user.short_name[sizeof(user.short_name) - 1] = '\0'; user.hw_model = lite.hw_model; user.role = lite.role; user.is_licensed = lite.is_licensed; From 0e38a15d4602a1165b7eb37b2863143792850a2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 17:13:55 +0200 Subject: [PATCH 56/67] Update protobufs (#10223) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/config.pb.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/protobufs b/protobufs index 4d5b500df..d004f503b 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 4d5b500df5af68a4f57d3e19705cc3bb1136358c +Subproject commit d004f503bbf3498fd689013a794e2a0e384b3f19 diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index c82dd5ff5..7e71f3f7a 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -285,7 +285,11 @@ typedef enum _meshtastic_Config_LoRaConfig_RegionCode { /* Nepal 865MHz */ meshtastic_Config_LoRaConfig_RegionCode_NP_865 = 25, /* Brazil 902MHz */ - meshtastic_Config_LoRaConfig_RegionCode_BR_902 = 26 + meshtastic_Config_LoRaConfig_RegionCode_BR_902 = 26, + /* ITU Region 1 Amateur Radio 2m band (144-146 MHz) */ + meshtastic_Config_LoRaConfig_RegionCode_ITU1_2M = 27, + /* ITU Region 2 / 3 Amateur Radio 2m band (144-148 MHz) */ + meshtastic_Config_LoRaConfig_RegionCode_ITU23_2M = 28 } meshtastic_Config_LoRaConfig_RegionCode; /* Standard predefined channel settings @@ -702,8 +706,8 @@ extern "C" { #define _meshtastic_Config_DisplayConfig_CompassOrientation_ARRAYSIZE ((meshtastic_Config_DisplayConfig_CompassOrientation)(meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270_INVERTED+1)) #define _meshtastic_Config_LoRaConfig_RegionCode_MIN meshtastic_Config_LoRaConfig_RegionCode_UNSET -#define _meshtastic_Config_LoRaConfig_RegionCode_MAX meshtastic_Config_LoRaConfig_RegionCode_BR_902 -#define _meshtastic_Config_LoRaConfig_RegionCode_ARRAYSIZE ((meshtastic_Config_LoRaConfig_RegionCode)(meshtastic_Config_LoRaConfig_RegionCode_BR_902+1)) +#define _meshtastic_Config_LoRaConfig_RegionCode_MAX meshtastic_Config_LoRaConfig_RegionCode_ITU23_2M +#define _meshtastic_Config_LoRaConfig_RegionCode_ARRAYSIZE ((meshtastic_Config_LoRaConfig_RegionCode)(meshtastic_Config_LoRaConfig_RegionCode_ITU23_2M+1)) #define _meshtastic_Config_LoRaConfig_ModemPreset_MIN meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST #define _meshtastic_Config_LoRaConfig_ModemPreset_MAX meshtastic_Config_LoRaConfig_ModemPreset_LONG_TURBO From 621aeb29b5fa296b1df488a1ea311fd139e134ee Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 21 Apr 2026 11:23:47 -0400 Subject: [PATCH 57/67] Cleanup after merge --- variants/esp32/esp32-common.ini | 8 +++----- variants/esp32c6/m5stack_unitc6l/platformio.ini | 6 ------ variants/esp32c6/tlora_c6/platformio.ini | 1 - variants/esp32s3/diy/my_esp32s3_diy_eink/platformio.ini | 2 -- variants/esp32s3/diy/my_esp32s3_diy_oled/platformio.ini | 4 ---- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/variants/esp32/esp32-common.ini b/variants/esp32/esp32-common.ini index 6bc3cff6b..fe62df46a 100644 --- a/variants/esp32/esp32-common.ini +++ b/variants/esp32/esp32-common.ini @@ -63,8 +63,6 @@ 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 https://github.com/meshtastic/esp32_https_server/archive/0c71f380390ad483ff134ad938e07f6cf1226c5b.zip - # renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino - h2zero/NimBLE-Arduino@1.4.3 # TODO renovate https://github.com/mverch67/libpax/archive/6f52ee989301cdabaeef00bcbf93bff55708ce2f.zip # renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib @@ -74,10 +72,10 @@ lib_deps = lib_ignore = segger_rtt - NimBLE-Arduino - ESP32 BLE Arduino - ; Ignore builtin NimBLE libs + ; ESP32 BLE Arduino ; BLE + ; Ignore select Bluetooth libs + NimBLE-Arduino BluetoothSerial SimpleBLE WiFiProv diff --git a/variants/esp32c6/m5stack_unitc6l/platformio.ini b/variants/esp32c6/m5stack_unitc6l/platformio.ini index 43e5391ee..59eca377b 100644 --- a/variants/esp32c6/m5stack_unitc6l/platformio.ini +++ b/variants/esp32c6/m5stack_unitc6l/platformio.ini @@ -17,12 +17,6 @@ board_build.partitions = default_16MB.csv ;Normal method upload_protocol = esptool ;upload_port = /dev/ttyACM2 -lib_deps = - ${esp32c6_base.lib_deps} - # renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel - adafruit/Adafruit NeoPixel@1.15.4 - # renovate: datasource=custom.pio depName=NimBLE-Arduino packageName=h2zero/library/NimBLE-Arduino - h2zero/NimBLE-Arduino@2.3.7 build_flags = ${esp32c6_base.build_flags} -D M5STACK_UNITC6L diff --git a/variants/esp32c6/tlora_c6/platformio.ini b/variants/esp32c6/tlora_c6/platformio.ini index 449cf7795..46d17c075 100644 --- a/variants/esp32c6/tlora_c6/platformio.ini +++ b/variants/esp32c6/tlora_c6/platformio.ini @@ -8,7 +8,6 @@ build_flags = -I variants/esp32c6/tlora_c6 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 - -ULED_BUILTIN ; Disable audio. ; ESP32-C6 with 4MB flash is TIGHT on space. -DMESHTASTIC_EXCLUDE_AUDIO=1 diff --git a/variants/esp32s3/diy/my_esp32s3_diy_eink/platformio.ini b/variants/esp32s3/diy/my_esp32s3_diy_eink/platformio.ini index 12aa5e78e..9448a670c 100644 --- a/variants/esp32s3/diy/my_esp32s3_diy_eink/platformio.ini +++ b/variants/esp32s3/diy/my_esp32s3_diy_eink/platformio.ini @@ -12,8 +12,6 @@ lib_deps = ${esp32s3_base.lib_deps} # renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2 zinggjm/GxEPD2@1.6.8 - # renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel - adafruit/Adafruit NeoPixel@1.15.4 build_flags = ${esp32s3_base.build_flags} -D PRIVATE_HW diff --git a/variants/esp32s3/diy/my_esp32s3_diy_oled/platformio.ini b/variants/esp32s3/diy/my_esp32s3_diy_oled/platformio.ini index d5ec059b4..b90325f51 100644 --- a/variants/esp32s3/diy/my_esp32s3_diy_oled/platformio.ini +++ b/variants/esp32s3/diy/my_esp32s3_diy_oled/platformio.ini @@ -8,10 +8,6 @@ board_build.f_cpu = 240000000L upload_protocol = esptool ;upload_port = /dev/ttyACM0 upload_speed = 921600 -lib_deps = - ${esp32s3_base.lib_deps} - # renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel - adafruit/Adafruit NeoPixel@1.15.4 build_flags = ${esp32s3_base.build_flags} -D PRIVATE_HW From 945f4780ea51c24af924450fcf569068edcb81ce Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:31:29 -0400 Subject: [PATCH 58/67] BaseUI: Nodelist screen/favorite screen cleanup (#10197) * nodelist screen cleanup * Update UIRenderer.cpp * Update src/graphics/draw/UIRenderer.cpp * removed brackets from hop and made signal mutually exclusive --- src/graphics/draw/NodeListRenderer.cpp | 46 ++++++---- src/graphics/draw/UIRenderer.cpp | 122 +++++++++---------------- 2 files changed, 73 insertions(+), 95 deletions(-) diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index e0c5df124..201d267e3 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -275,9 +275,12 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int int nameMaxWidth = getNodeNameMaxWidth(columnWidth, columnWidth - 25); int barsOffset = (currentResolution == ScreenResolution::High) ? (isLeftCol ? 20 : 24) : (isLeftCol ? 15 : 19); - int hopOffset = (currentResolution == ScreenResolution::High) ? (isLeftCol ? 21 : 29) : (isLeftCol ? 13 : 17); + constexpr int kBarCount = 4; + constexpr int kBarWidth = 2; + constexpr int kBarGap = 1; int barsXOffset = columnWidth - barsOffset; + int barsRightEdge = x + barsXOffset + ((kBarCount - 1) * (kBarWidth + kBarGap)) + kBarWidth; const int nameX = x + ((currentResolution == ScreenResolution::High) ? 6 : 3); char nodeName[96]; @@ -304,28 +307,35 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int } } - // Draw signal strength bars - int bars = (node->snr > 5) ? 4 : (node->snr > 0) ? 3 : (node->snr > -5) ? 2 : (node->snr > -10) ? 1 : 0; - int barWidth = 2; - int barStartX = x + barsXOffset; - int barStartY = y + 1 + (FONT_HEIGHT_SMALL / 2) + 2; + const bool isZeroHop = node->has_hops_away && node->hops_away == 0; - for (int b = 0; b < 4; b++) { - if (b < bars) { - int height = (b * 2); - display->fillRect(barStartX + (b * (barWidth + 1)), barStartY - height, barWidth, height); + // Show signal only for direct neighbors (0 hops) + if (isZeroHop) { + int bars = (node->snr > 5) ? 4 : (node->snr > 0) ? 3 : (node->snr > -5) ? 2 : (node->snr > -10) ? 1 : 0; + int barStartX = x + barsXOffset; + int barStartY = y + 1 + (FONT_HEIGHT_SMALL / 2) + 2; + + for (int b = 0; b < kBarCount; b++) { + if (b < bars) { + int height = (b * 2); + display->fillRect(barStartX + (b * (kBarWidth + kBarGap)), barStartY - height, kBarWidth, height); + } } } - // Draw hop count - char hopStr[6] = ""; - if (node->has_hops_away && node->hops_away > 0) - snprintf(hopStr, sizeof(hopStr), "[%d]", node->hops_away); + // Draw hop count + hop icon + if (node->has_hops_away && node->hops_away > 0) { + char hopCount[6]; + snprintf(hopCount, sizeof(hopCount), "%d", node->hops_away); - if (hopStr[0] != '\0') { - int rightEdge = x + columnWidth - hopOffset; - int textWidth = display->getStringWidth(hopStr); - display->drawString(rightEdge - textWidth, y, hopStr); + const int hopCountWidth = display->getStringWidth(hopCount); + const int gap = 1; + const int totalWidth = hopCountWidth + gap + hop_width; + const int hopX = barsRightEdge - totalWidth; + const int iconY = y + (FONT_HEIGHT_SMALL - hop_height) / 2; + + display->drawString(hopX, y, hopCount); + display->drawXbm(hopX + hopCountWidth + gap, iconY, hop_width, hop_height, hop); } } diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index b94c25a27..4bf4df4bf 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -405,10 +405,10 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat } #endif - // === 2. Signal and Hops (combined on one line, if available) === - char signalHopsStr[32] = ""; + // === 2. Signal/Hops line (if available) === bool haveSignal = false; int bars = 0; + const char *qualityLabel = nullptr; // Helper to get SNR limit based on modem preset auto getSnrLimit = [](meshtastic_Config_LoRaConfig_ModemPreset preset) -> float { @@ -429,80 +429,51 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat } }; - // Calculate signal grade using modem preset and SNR only - float snrLimit = getSnrLimit(config.lora.modem_preset); - float snr = node->snr; - - // Determine signal quality label and bars using SNR-only grading - const char *qualityLabel = nullptr; - - if (snr > snrLimit + 10) { - qualityLabel = "Good"; - bars = 4; - } else if (snr > snrLimit + 6) { - qualityLabel = "Good"; - bars = 3; - } else if (snr > snrLimit + 2) { - qualityLabel = "Good"; - bars = 2; - } else if (snr > snrLimit - 4) { - qualityLabel = "Fair"; - bars = 1; - } else { - qualityLabel = "Bad"; - bars = 1; - } - // Add extra spacing on the left if we have an API connection to account for the common footer icons const char *leftSideSpacing = graphics::isAPIConnected(service->api_state) ? (currentResolution == ScreenResolution::High ? " " : " ") : " "; + const bool isZeroHop = node->has_hops_away && node->hops_away == 0; - // --- Build the Signal/Hops line --- - // Only show signal if we have valid SNR - if (snr > -100 && snr != 0) { - snprintf(signalHopsStr, sizeof(signalHopsStr), "%sSig:%s", leftSideSpacing, qualityLabel); - haveSignal = true; - } - - if (node->hops_away > 0) { - size_t len = strlen(signalHopsStr); - if (haveSignal) { - snprintf(signalHopsStr + len, sizeof(signalHopsStr) - len, " [#]"); - } else { - snprintf(signalHopsStr, sizeof(signalHopsStr), "[#]"); - } - } - - if (signalHopsStr[0]) { - int yPos = getTextPositions(display)[line++]; - int curX = x; - - // Split combined string into signal text and hop suffix - char sigPart[20] = ""; - const char *hopPart = nullptr; - - char *bracket = strchr(signalHopsStr, '['); - if (bracket) { - size_t n = (size_t)(bracket - signalHopsStr); - if (n >= sizeof(sigPart)) - n = sizeof(sigPart) - 1; - memcpy(sigPart, signalHopsStr, n); - sigPart[n] = '\0'; - - // Trim trailing spaces - while (strlen(sigPart) && sigPart[strlen(sigPart) - 1] == ' ') { - sigPart[strlen(sigPart) - 1] = '\0'; + // Signal text/bars are only for direct (zero-hop) nodes with valid SNR. + if (isZeroHop) { + float snr = node->snr; + if (snr > -100 && snr != 0) { + float snrLimit = getSnrLimit(config.lora.modem_preset); + // Determine signal quality label and bars using SNR-only grading. + if (snr > snrLimit + 10) { + qualityLabel = "Good"; + bars = 4; + } else if (snr > snrLimit + 6) { + qualityLabel = "Good"; + bars = 3; + } else if (snr > snrLimit + 2) { + qualityLabel = "Good"; + bars = 2; + } else if (snr > snrLimit - 4) { + qualityLabel = "Fair"; + bars = 1; + } else { + qualityLabel = "Bad"; + bars = 1; } - hopPart = bracket; // "[n Hop(s)]" - } else { - strncpy(sigPart, signalHopsStr, sizeof(sigPart) - 1); - sigPart[sizeof(sigPart) - 1] = '\0'; + haveSignal = true; } + } - // Draw signal quality text - display->drawString(curX, yPos, sigPart); - curX += display->getStringWidth(sigPart) + 4; + const bool showHops = node->has_hops_away && node->hops_away > 0; + + if (haveSignal || showHops) { + int yPos = getTextPositions(display)[line++]; + int curX = x + display->getStringWidth(leftSideSpacing); + + // Draw signal quality text for zero-hop nodes when present. + if (haveSignal && qualityLabel) { + char signalLabel[20]; + snprintf(signalLabel, sizeof(signalLabel), "Sig:%s", qualityLabel); + display->drawString(curX, yPos, signalLabel); + curX += display->getStringWidth(signalLabel) + 4; + } // Draw signal bars (skip on UltraLow, text only) if (currentResolution != ScreenResolution::UltraLow && haveSignal && bars > 0) { @@ -541,12 +512,12 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat curX += (kMaxBars * barWidth) + ((kMaxBars - 1) * barGap) + 2; } - // Draw hops AFTER the bars as: [ number + hop icon ] - if (hopPart && node->hops_away > 0) { - - // open bracket - display->drawString(curX, yPos, "["); - curX += display->getStringWidth("[") + 1; + // Draw hops for non-zero-hop nodes as: number + hop icon. + // This path is mutually exclusive with the zero-hop signal-bars path above. + if (showHops) { + // hop label + display->drawString(curX, yPos, "Hop:"); + curX += display->getStringWidth("Hop:") + 2; // hop count char hopCount[6]; @@ -558,9 +529,6 @@ void UIRenderer::drawFavoriteNode(OLEDDisplay *display, OLEDDisplayUiState *stat const int iconY = yPos + (FONT_HEIGHT_SMALL - hop_height) / 2; display->drawXbm(curX, iconY, hop_width, hop_height, hop); curX += hop_width + 1; - - // closing bracket - display->drawString(curX, yPos, "]"); } } From 814773f50ebe765e5d933ced946f7be49587ee76 Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 21 Apr 2026 16:17:15 -0400 Subject: [PATCH 59/67] ESP32: Disable classic bluetooth --- variants/esp32/esp32.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/variants/esp32/esp32.ini b/variants/esp32/esp32.ini index 8dbc25237..d157ab78a 100644 --- a/variants/esp32/esp32.ini +++ b/variants/esp32/esp32.ini @@ -20,6 +20,8 @@ build_flags = custom_sdkconfig = ${esp32_common.custom_sdkconfig} + '# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set' + '# CONFIG_BTDM_CTRL_MODE_BTDM is not set' ; 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 From 3b4c66439d427c60ced97e562d77ef121bf497db Mon Sep 17 00:00:00 2001 From: George <509474+giannoug@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:35:02 +0300 Subject: [PATCH 60/67] feat(t5s3-epaper): add InkHUD port for LilyGo T5 E-Paper S3 Pro (#10211) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * niche: add InkHUD port for LilyGo T5-E-Paper-S3-Pro (ED047TC1) Add a NicheGraphics EInk driver adapter for the 4.7" ED047TC1 parallel e-paper display used on the T5-E-Paper-S3-Pro (H752-01). The driver wraps FastEPD and handles the polarity difference between InkHUD's buffer format (0xFF = white) and FastEPD's (0x00 = white). Rewrite variants/esp32s3/t5s3_epaper/nicheGraphics.h which was an incomplete copy of the Heltec VM-E290 setup referencing undefined SPI pin macros and a non-existent BUTTON_PIN_SECONDARY. The board uses a parallel display, not the small SPI DEPG0290BNS800 that was referenced. * fix: guard inputBroker null dereference in TouchScreenImpl1::init() When MESHTASTIC_EXCLUDE_INPUTBROKER is defined (e.g. InkHUD builds), inputBroker is nullptr. Calling inputBroker->registerSource() in that state caused a LoadProhibited panic on any board that has both HAS_TOUCHSCREEN=1 and the InputBroker excluded. Add a null check before registerSource() to prevent the crash. * niche: fix display rotation for T5-E-Paper-S3-Pro InkHUD port Set rotation=3 (270° CW) in nicheGraphics.h to correct for FastEPD scanning the ED047TC1 panel in portrait orientation, resulting in correct landscape display output. * fix: update buffer format descriptions and remove polarity inversion for InkHUD and FastEPD * fix: update ED047TC1 driver to handle inactive pixel borders and adjust safe-area dimensions * fix: comment out ruler diagnostic for E-Ink driver * feat: implement TouchInkHUDBridge for direct touch event handling in InkHUD * niche: add FreeSans 18pt/24pt Win1253 (Greek) fonts for larger InkHUD displays Add Win1253-encoded FreeSans 18pt and 24pt font headers to support Greek script on larger InkHUD screens (e.g., the 4.7" ED047TC1 at ~234 DPI). Register FREESANS_24PT_WIN1253 and FREESANS_18PT_WIN1253 macros in AppletFont.h. Set fontLarge=24pt, fontMedium=18pt, fontSmall=12pt in nicheGraphics.h for the T5-E-Paper-S3-Pro. * feat(ed047tc1): use true partial update for FAST refresh Replace fullUpdate(CLEAR_FAST) with partialUpdate() for FAST display updates. FastEPD's partialUpdate() diffs pCurrent against pPrevious and only applies the update waveform to rows that have changed, leaving unchanged rows with a neutral signal. This reduces visible flicker on routine updates (new messages, position changes) — only the affected region of the screen refreshes. Full-screen CLEAR_SLOW updates are preserved for periodic ghosting cleanup, driven by InkHUD's setDisplayResilience() ratio. * feat(t5s3-epaper): enable frontlight via LatchingBacklight Wire up BOARD_BL_EN (GPIO11) to InkHUD's LatchingBacklight driver. Enable the backlight menu item so users can toggle "Keep Backlight On" via Settings. The backlight turns on automatically when the menu opens and off when it closes. * Fix RTC chip (PCF8563 not PCF85063) and GT911 I2C address collision - variant.h used PCF85063_RTC but the board has a PCF8563. The difference is the RAM register: PCF85063 has 1 byte of RAM; PCF8563 does not. The PCF85063 driver was trying to write this register on init, failing every time, and setDateTime writes were silently discarded — RTC time was never persisted across reboots. Switch to PCF8563_RTC/PCF8563_INT. Before: [E][SensorPCF85063.hpp:375] initImpl(): Failed to write to RAM memory register. Maybe this chip is pcf8563. Read RTC time from PCF85063 getDateTime as 2026-04-05 00:00:23 PCF85063 setDateTime 2026-04-05 18:40:59 Read RTC time from PCF85063 getDateTime as 2026-04-05 00:00:19 ← lost After: PCF8563 found at address 0x51 Read RTC time from PCF8563 getDateTime as 2026-04-05 18:58:37 ← persisted PCF8563 setDateTime 2026-04-05 18:58:44 Read RTC time from PCF8563 getDateTime as 2026-04-05 18:58:44 ← round-trips - GT911 touch was initialized with GT911_SLAVE_ADDRESS_L (0x5D), which collides with the SFA30 air quality sensor also at 0x5D on the same I2C bus. Switch to GT911_SLAVE_ADDRESS_H (0x14): the library drives INT high during reset to program the GT911 to address 0x14, eliminating the address conflict. Before: SFA30 found at address 0x5d [I][TouchDrvGT911.hpp:568] initImpl(): Try using 0x5D as the device address After: SFA30 found at address 0x5d [I][TouchDrvGT911.hpp:544] initImpl(): Try using 0x14 as the device address * t5s3_epaper: fix GT911 ghost-SFA30 via early I2C address latch Investigation findings ---------------------- Boot logs showed "SFA30 found at address 0x5d" on every cold power-on, and AirQualityTelemetry was registering an SFA30 sensor. However, every readMeasuredValues() call returned error 268 (0x010C = Sensirion WriteError | I2cAddressNack), meaning the I2C write to 0x5D was being NACK'd — inconsistent with a real SFA30. Root cause: the GT911 touch controller latches its I2C address from the INT pin level at reset time (GT911 datasheet §4.3). GPIO3 (INT) defaults LOW on ESP32-S3 cold boot → GT911 always powers up at 0x5D (SLAVE_ADDRESS_L). The I2C scanner runs before lateInitVariant() had a chance to reprogram the chip. The scanner's SFA30 detection (ScanI2CTwoWire.cpp) sends the 2-byte command 0xD060 to 0x5D and requests 48 bytes back. GT911 ACKs the write (treating it as a register address) and returns 48 bytes of register data, passing the length check — a false-positive SFA30 detection. Confirmed via second cold-boot log: after the previous commit moved GT911 to 0x14 in lateInitVariant(), address 0x5D *still* appeared in the scan because the scanner runs first. The board has no physical SFA30 fitted. Fix --- Add the GT911 address-latch reset sequence to earlyInitVariant(), before Wire is initialised and before the I2C scan runs. Per the datasheet: drive RST LOW, drive INT HIGH (selects address 0x14 / SLAVE_ADDRESS_H), hold >100 µs, release RST, wait >5 ms startup. GPIO-only, no Wire dependency. lateInitVariant() then repeats this sequence internally via touch.begin(); the double-reset is harmless. Verified in boot log: Before: "SFA30 found at address 0x5d", 5 I2C devices, NACK errors After: no SFA30 entry, 4 I2C devices (TCA9535/PCF8563/BQ27220/BQ25896), GT911 found at 0x14 and touch initialised successfully, AirQualityTelemetry registers no sensors (correct — no SFA30 present) * t5s3_epaper: add variant_shutdown() for touch sleep and backlight off Put GT911 into low-power standby (command 0x05) and drive BOARD_BL_EN LOW before deep sleep to avoid unnecessary current draw. * t5s3_epaper: fix touch gesture routing and coordinate mapping readTouch() now transforms raw GT911 axes to visual-frame coordinates based on the current display rotation (rotation=3 is the hardware identity). This ensures TouchScreenBase detects swipe direction correctly regardless of which rotation the user has selected. TouchInkHUDBridge dynamically sets joystick.alignment = (4-rotation)%4 on each touch event so that (rotation+alignment)%4==0 always, keeping nav calls pass-through without remapping. nicheGraphics.h now calls loadSettings() first so that rotation is persisted across reboots. rotation=3 and other first-boot defaults are only applied when tips.firstBoot is set. alignment is recomputed from the loaded rotation on every boot. Co-Authored-By: Claude Sonnet 4.6 * t5s3_epaper: fix GT911 sleep timing via notifyDeepSleep observer touch.sleep() was called from variant_shutdown(), which runs inside cpuDeepSleep() — after Wire.end() had already torn down the I2C bus in doDeepSleep(). This caused Wire NULL TX buffer errors and left the GT911 awake during deep sleep. Register a CallbackObserver on notifyDeepSleep, which fires before Wire.end(), so the I2C command reaches the chip while the bus is live. Pattern matches LatchingBacklight and other NicheGraphics components. Co-Authored-By: Claude Sonnet 4.6 * t5s3_epaper: fix touch nav and applet defaults in nicheGraphics Enable joystick mode post-begin so menu scroll and swipe-up/down gestures are not silently dropped by the joystick.enabled gate in Events.cpp. Activate DMs and Channel 0/1 applets with correct autoshow defaults matching the mini-epaper-s3 reference pattern. Co-Authored-By: Claude Sonnet 4.6 * Update nicheGraphics.h * t5s3_epaper: fix ED047TC1 driver docs and remove spurious beginPolling Addressing PR review comments: Remove beginPolling(1, 0) after the blocking FastEPD update — it incorrectly set updateRunning=true for one loop cycle after the hardware was already done, causing busy() to briefly return true. Since isUpdateDone() always returns true, no polling is needed. Also fix stale comments: safe-area buffer size was 944×532, now 944×523; V_OFFSET_ROWS didn't exist, replaced with the actual V_OFFSET_TOP=9 / V_OFFSET_BOTTOM=8 constant names. * t5s3_epaper: clean up applet addition formatting in setupNicheGraphics * t5s3_epaper: guard ED047TC1.cpp against non-T5S3 InkHUD builds The InkHUD base config pulls in all of src/graphics/niche/ so every InkHUD device compiled ED047TC1.cpp, triggering the #error on line 48 for boards that define neither T5_S3_EPAPER_PRO_V1 nor V2. Wrap the file body with #ifdef T5_S3_EPAPER_PRO so it is only compiled for T5S3 targets. The #error is preserved inside the guard to catch future hardware revisions that forget to update the driver. Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 Co-authored-by: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> --- src/graphics/niche/Drivers/EInk/ED047TC1.cpp | 122 + src/graphics/niche/Drivers/EInk/ED047TC1.h | 90 + .../niche/Fonts/FreeSans18pt_Win1253.h | 1467 ++++++++++ .../niche/Fonts/FreeSans24pt_Win1253.h | 2429 +++++++++++++++++ src/graphics/niche/InkHUD/AppletFont.h | 4 + src/input/TouchScreenImpl1.cpp | 3 +- variants/esp32s3/t5s3_epaper/nicheGraphics.h | 89 +- variants/esp32s3/t5s3_epaper/variant.cpp | 141 +- variants/esp32s3/t5s3_epaper/variant.h | 4 +- 9 files changed, 4295 insertions(+), 54 deletions(-) create mode 100644 src/graphics/niche/Drivers/EInk/ED047TC1.cpp create mode 100644 src/graphics/niche/Drivers/EInk/ED047TC1.h create mode 100644 src/graphics/niche/Fonts/FreeSans18pt_Win1253.h create mode 100644 src/graphics/niche/Fonts/FreeSans24pt_Win1253.h diff --git a/src/graphics/niche/Drivers/EInk/ED047TC1.cpp b/src/graphics/niche/Drivers/EInk/ED047TC1.cpp new file mode 100644 index 000000000..f1189045b --- /dev/null +++ b/src/graphics/niche/Drivers/EInk/ED047TC1.cpp @@ -0,0 +1,122 @@ +/* + + NicheGraphics parallel E-Ink driver for the LilyGo T5-S3-ePaper-Pro (ED047TC1). + + InkHUD buffer format : 1bpp, horizontal bytes, MSB = leftmost pixel, 1 = white + FastEPD buffer format: 1bpp, horizontal bytes, MSB = leftmost pixel, 1 = white + + Both formats share the same pixel layout and polarity (1 = white, 0 = black). + The InkHUD safe-area buffer (944×523) is copied into the centre of the physical + 960×540 FastEPD buffer so content clears the panel's inactive edge border. + See ED047TC1.h for the H_OFFSET_BYTES / V_OFFSET_TOP / V_OFFSET_BOTTOM constants. + +*/ + +// Ruler diagnostic — uncomment to draw calibration lines at each physical edge. +// #define EINK_EDGE_LINES + +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS +#ifdef T5_S3_EPAPER_PRO + +#include "./ED047TC1.h" + +#include "FastEPD.h" +#include "configuration.h" + +using namespace NicheGraphics::Drivers; + +void ED047TC1::begin(SPIClass *spi, uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t pin_rst) +{ + // Parallel display — SPI parameters are not used + (void)spi; + (void)pin_dc; + (void)pin_cs; + (void)pin_busy; + (void)pin_rst; + + epaper = new FASTEPD; + +#if defined(T5_S3_EPAPER_PRO_V1) + epaper->initPanel(BB_PANEL_LILYGO_T5PRO, 28000000); +#elif defined(T5_S3_EPAPER_PRO_V2) + epaper->initPanel(BB_PANEL_LILYGO_T5PRO_V2, 28000000); + // Initialize all PCA9535 port-0 pins as outputs / HIGH + for (int i = 0; i < 8; i++) { + epaper->ioPinMode(i, OUTPUT); + epaper->ioWrite(i, HIGH); + } +#else +#error "ED047TC1 driver: unsupported variant — define T5_S3_EPAPER_PRO_V1 or T5_S3_EPAPER_PRO_V2" +#endif + + epaper->setMode(BB_MODE_1BPP); + epaper->clearWhite(); + epaper->fullUpdate(true); // Blocking initial clear +} + +void ED047TC1::update(uint8_t *imageData, UpdateTypes type) +{ + if (!epaper) + return; + + // InkHUD renders into a DISPLAY_WIDTH × DISPLAY_HEIGHT safe-area buffer. + // We need to place that into the centre of the physical 960×540 FastEPD buffer, + // leaving blank margins at every edge to avoid the panel's inactive border. + const uint32_t srcRowBytes = (DISPLAY_WIDTH + 7) / 8; // bytes per row in InkHUD buffer (118) + const uint32_t dstRowBytes = (960 + 7) / 8; // bytes per row in physical buffer (120) + const uint32_t dstTotalRows = 540; + + uint8_t *cur = epaper->currentBuffer(); + + // Fill physical buffer with white (0xFF = white in FastEPD 1bpp) + memset(cur, 0xFF, dstRowBytes * dstTotalRows); + + // Copy each InkHUD row into the physical buffer with horizontal + vertical offsets + for (uint32_t row = 0; row < DISPLAY_HEIGHT; row++) { + const uint8_t *srcRow = imageData + row * srcRowBytes; + uint8_t *dstRow = cur + (row + V_OFFSET_TOP) * dstRowBytes + H_OFFSET_BYTES; + memcpy(dstRow, srcRow, srcRowBytes); + } + +#ifdef EINK_EDGE_LINES + // Draw a 1px black box at the exact boundary of the safe area within the + // physical buffer. If the margins are correct, all 4 lines should be + // fully visible and right at the edge of the usable display area. + + auto setPixelBlack = [&](uint32_t col, uint32_t row) { cur[row * dstRowBytes + col / 8] &= ~(0x80 >> (col % 8)); }; + + const uint32_t safeX = H_OFFSET_BYTES * 8; + const uint32_t safeY = V_OFFSET_TOP; + const uint32_t safeW = DISPLAY_WIDTH; + const uint32_t safeH = DISPLAY_HEIGHT; + + // Top edge: horizontal line at safeY + for (uint32_t col = safeX; col < safeX + safeW; col++) + setPixelBlack(col, safeY); + + // Bottom edge: horizontal line at safeY + safeH - 1 + for (uint32_t col = safeX; col < safeX + safeW; col++) + setPixelBlack(col, safeY + safeH - 1); + + // Left edge: vertical line at safeX + for (uint32_t row = safeY; row < safeY + safeH; row++) + setPixelBlack(safeX, row); + + // Right edge: vertical line at safeX + safeW - 1 + for (uint32_t row = safeY; row < safeY + safeH; row++) + setPixelBlack(safeX + safeW - 1, row); +#endif + + if (type == FULL) { + epaper->fullUpdate(CLEAR_SLOW, false); + epaper->backupPlane(); // Sync pPrevious so next partialUpdate has a correct baseline + } else { + // FAST: true partial update — compares pCurrent vs pPrevious and only applies + // the update waveform to rows that actually changed. Unchanged rows get a neutral + // signal (no visible effect). partialUpdate() updates pPrevious internally. + epaper->partialUpdate(false, 0, dstTotalRows - 1); + } +} + +#endif // T5_S3_EPAPER_PRO +#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS diff --git a/src/graphics/niche/Drivers/EInk/ED047TC1.h b/src/graphics/niche/Drivers/EInk/ED047TC1.h new file mode 100644 index 000000000..3540481e7 --- /dev/null +++ b/src/graphics/niche/Drivers/EInk/ED047TC1.h @@ -0,0 +1,90 @@ +/* + + E-Ink display driver adapter + - ED047TC1 (via FastEPD library) + - Manufacturer: E Ink / used in LilyGo T5-E-Paper-S3-Pro + - Size: 4.7 inch + - Physical resolution: 960px x 540px + - Interface: 8-bit parallel (NOT SPI) + + Unlike the other NicheGraphics EInk drivers, this one drives a parallel e-paper + panel via the FastEPD library. SPI parameters passed to begin() are ignored. + + The ED047TC1 panel has an inactive pixel border on all four edges (~4–8 physical + pixels). DISPLAY_WIDTH / DISPLAY_HEIGHT expose a reduced "safe area" to InkHUD so + that content is never drawn into this dead zone. The update() method copies the + InkHUD frame buffer into the centre of the larger physical 960×540 buffer, using + H_OFFSET_BYTES (horizontal, whole bytes = 8 pixels per byte), + V_OFFSET_TOP and V_OFFSET_BOTTOM (vertical, pixel rows) to position it. + + Changing these constants shifts content inward from each physical edge: + H_OFFSET_BYTES = 1 → 8px left margin, 8px right margin (960 – 8 – 8 = 944) + V_OFFSET_TOP = 9 → 9px top margin (asymmetric: top ≠ bottom) + V_OFFSET_BOTTOM = 8 → 8px bottom margin (540 – 9 – 8 = 523) + +*/ + +#pragma once + +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS + +#include "configuration.h" + +#include "./EInk.h" + +// Forward declare to avoid pulling FastEPD into all translation units +class FASTEPD; + +namespace NicheGraphics::Drivers +{ + +class ED047TC1 : public EInk +{ + // Safe-area dimensions exposed to InkHUD (physical panel is 960×540). + // + // The ED047TC1 has an inactive pixel border on all physical edges. + // The physical buffer coordinates do NOT directly match the visual orientation + // due to FastEPD's portrait scan direction and InkHUD's rotation=3 (270° CW): + // + // Physical buffer Visual on device (rotation=3) + // ───────────────── ────────────────────────────── + // Physical LEFT cols → Visual TOP edge + // Physical RIGHT cols → Visual BOTTOM edge + // Physical TOP rows → Visual RIGHT edge + // Physical BOTTOM rows → Visual LEFT edge + // + // Offset constants shift the InkHUD safe-area away from each physical dead zone: + // H_OFFSET_BYTES : whole bytes from physical left (8px per byte, affects visual TOP) + // Physical right margin = 960 − H_OFFSET_BYTES×8 − DISPLAY_WIDTH (affects visual BOTTOM) + // V_OFFSET_TOP : pixel rows from physical top (affects visual RIGHT) + // V_OFFSET_BOTTOM: pixel rows from physical bottom (affects visual LEFT) + // + // Calibrated by flashing a 1px border box and adjusting until all 4 sides are visible. + + static constexpr uint16_t DISPLAY_WIDTH = 944; // 960 − H_OFFSET_BYTES×8 − right_margin (8+8 = 16px) + static constexpr uint16_t DISPLAY_HEIGHT = 523; // 540 − V_OFFSET_TOP − V_OFFSET_BOTTOM (9+8 = 17px) + + static constexpr uint8_t H_OFFSET_BYTES = 1; // visual TOP : 8px physical left margin + // visual BOTTOM: 960−8−944=8px physical right margin + static constexpr uint8_t V_OFFSET_TOP = 9; // visual RIGHT : CONFIRMED OK + static constexpr uint8_t V_OFFSET_BOTTOM = 8; // visual LEFT : 8px physical bottom margin + + static constexpr UpdateTypes supported = static_cast(FULL | FAST); + + public: + ED047TC1() : EInk(DISPLAY_WIDTH, DISPLAY_HEIGHT, supported) {} + + // EInk interface — SPI params are not used for this parallel display + void begin(SPIClass *spi, uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_busy, uint8_t pin_rst = 0xFF) override; + void update(uint8_t *imageData, UpdateTypes type) override; + + protected: + bool isUpdateDone() override { return true; } // FastEPD updates are blocking + + private: + FASTEPD *epaper = nullptr; +}; + +} // namespace NicheGraphics::Drivers + +#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS diff --git a/src/graphics/niche/Fonts/FreeSans18pt_Win1253.h b/src/graphics/niche/Fonts/FreeSans18pt_Win1253.h new file mode 100644 index 000000000..9b29f32b5 --- /dev/null +++ b/src/graphics/niche/Fonts/FreeSans18pt_Win1253.h @@ -0,0 +1,1467 @@ +// trunk-ignore-all(clang-format) +#pragma once +/* PROPERTIES + +FONT_NAME FreeSans18pt_Win1253 +*/ +const uint8_t FreeSans18pt_Win1253Bitmaps[] PROGMEM = { + 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x23, 0x00, + 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04, 0x30, + 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x01, 0x84, + 0x00, 0x00, 0x01, 0x82, 0x00, 0x00, 0x01, 0x83, 0x00, 0x00, 0x01, 0x81, + 0x80, 0x00, 0x03, 0x80, 0xBF, 0xC0, 0x03, 0x00, 0x7C, 0x30, 0x03, 0x00, + 0x60, 0x18, 0x01, 0x00, 0x20, 0x04, 0x01, 0x80, 0x10, 0x06, 0x7F, 0xC0, + 0x0C, 0x06, 0x30, 0x00, 0x07, 0xFF, 0xD8, 0x00, 0x03, 0xE0, 0x2C, 0x00, + 0x01, 0x80, 0x1E, 0x00, 0x01, 0xC0, 0x0F, 0x00, 0x01, 0xA0, 0x05, 0x80, + 0x03, 0x9C, 0x06, 0xC0, 0x03, 0x07, 0xFE, 0x60, 0x00, 0x06, 0x01, 0xB0, + 0x00, 0x03, 0x00, 0x58, 0x00, 0x01, 0x80, 0x2C, 0x00, 0x00, 0xC0, 0x16, + 0x00, 0x00, 0x3E, 0x1B, 0xF8, 0x00, 0x3F, 0xF9, 0xFF, 0x80, 0x10, 0x10, + 0x00, 0x60, 0x08, 0x08, 0x00, 0x1E, 0x06, 0x04, 0x00, 0x03, 0xFF, 0xFE, + 0x00, 0x00, 0x06, 0x1E, 0x00, 0x00, 0x00, 0x79, 0xF0, 0x00, 0x07, 0xFF, + 0xEC, 0x00, 0x0E, 0x03, 0x02, 0x00, 0x0C, 0x01, 0x01, 0x0F, 0xFC, 0x00, + 0x80, 0x87, 0xE0, 0x00, 0x7F, 0xF3, 0x00, 0x00, 0x1E, 0x0D, 0x80, 0x00, + 0x18, 0x02, 0xC0, 0x00, 0x0C, 0x01, 0x60, 0x00, 0x06, 0x00, 0xB0, 0x00, + 0x03, 0x80, 0xD8, 0x00, 0x60, 0xFF, 0xCC, 0x00, 0x1C, 0xC0, 0x36, 0x00, + 0x03, 0x40, 0x0B, 0x00, 0x00, 0xE0, 0x07, 0x80, 0x00, 0x38, 0x03, 0xC0, + 0x00, 0x1F, 0x81, 0x60, 0x00, 0x07, 0xFF, 0xBF, 0xE0, 0x06, 0x01, 0x00, + 0x30, 0x02, 0x00, 0xC0, 0x08, 0x01, 0x00, 0x20, 0x06, 0x00, 0xC0, 0x30, + 0x01, 0x80, 0x3F, 0x18, 0x00, 0x70, 0x13, 0xF8, 0x00, 0x0C, 0x0C, 0x00, + 0x00, 0x03, 0x06, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00, 0x30, 0x80, + 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x02, 0x18, + 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x46, + 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x07, + 0xFC, 0x00, 0x00, 0x07, 0x80, 0xE0, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, + 0xC0, 0x00, 0x18, 0x00, 0x20, 0x00, 0x01, 0x80, 0x08, 0x00, 0x00, 0x08, + 0x02, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, + 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x80, 0x70, 0x07, 0x00, 0xA0, + 0x31, 0x01, 0x18, 0x0C, 0x04, 0x30, 0x61, 0x01, 0x80, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x00, + 0x54, 0x18, 0x2A, 0x00, 0x12, 0x83, 0x05, 0x40, 0x02, 0xA0, 0x50, 0x00, + 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x40, 0x10, 0x01, 0x00, 0x44, + 0x03, 0x80, 0xE0, 0x10, 0x80, 0x0F, 0xE0, 0x02, 0x08, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, + 0x01, 0x00, 0x10, 0x00, 0x00, 0x40, 0x01, 0x80, 0x00, 0x30, 0x00, 0x0C, + 0x00, 0x18, 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, + 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x00, 0x00, 0x00, + 0x60, 0x00, 0xC0, 0x00, 0x00, 0x60, 0x00, 0x0C, 0x00, 0x00, 0x30, 0x00, + 0x01, 0x80, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x02, + 0x00, 0x06, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x0C, 0x00, 0x06, 0x10, 0x00, + 0x86, 0x00, 0x00, 0xC2, 0x00, 0x22, 0x00, 0x00, 0x08, 0x80, 0x11, 0x00, + 0x00, 0x01, 0x10, 0x04, 0x40, 0x00, 0x00, 0x44, 0x01, 0x03, 0xE0, 0x0F, + 0x81, 0x00, 0x81, 0x8C, 0x06, 0x30, 0x20, 0x20, 0x41, 0x01, 0x04, 0x08, + 0x08, 0x00, 0x00, 0x00, 0x02, 0x03, 0xE0, 0x00, 0x00, 0x0F, 0x83, 0x98, + 0x00, 0x00, 0x02, 0x31, 0x86, 0x00, 0x00, 0x00, 0xC2, 0xC1, 0x00, 0x00, + 0x00, 0x10, 0xE0, 0x4F, 0x80, 0x03, 0xE4, 0x18, 0x32, 0x1F, 0xFF, 0x09, + 0x06, 0x08, 0xE0, 0x00, 0x0E, 0x61, 0x4E, 0x1F, 0xFF, 0xFF, 0x0C, 0x8F, + 0x87, 0xFF, 0xFF, 0xC3, 0xC0, 0x20, 0xFF, 0xFF, 0xE0, 0x80, 0x0C, 0x0F, + 0x83, 0xE0, 0x60, 0x01, 0x81, 0xC0, 0x70, 0x30, 0x00, 0x20, 0x0F, 0xE0, + 0x18, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0xC0, 0x00, 0x06, 0x00, + 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, + 0x3C, 0x07, 0x80, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0C, + 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x08, 0x40, 0x00, 0x00, 0x71, 0xC0, 0x00, 0x03, 0x9F, 0x0C, 0x00, 0x00, + 0xFA, 0x30, 0x07, 0x00, 0x11, 0xC3, 0x01, 0xB0, 0x02, 0x18, 0x30, 0x62, + 0x00, 0x61, 0x83, 0x08, 0xC0, 0x06, 0x18, 0x31, 0x18, 0x01, 0xE1, 0x83, + 0x23, 0x00, 0x66, 0x18, 0x34, 0x20, 0x08, 0x61, 0x83, 0x84, 0x01, 0x86, + 0x18, 0x38, 0xC0, 0x18, 0x61, 0x83, 0x08, 0x03, 0x86, 0x10, 0x41, 0x00, + 0xF8, 0x60, 0x18, 0x30, 0x31, 0x86, 0x02, 0x02, 0x06, 0x18, 0x40, 0x40, + 0x60, 0xC1, 0x80, 0x08, 0x04, 0x0C, 0x18, 0x01, 0x00, 0x80, 0xC1, 0x00, + 0x20, 0x18, 0x0C, 0x00, 0x06, 0x01, 0x10, 0xC0, 0x00, 0xC0, 0x23, 0x8C, + 0x00, 0x0C, 0x06, 0x10, 0xC0, 0x00, 0x01, 0xE0, 0x0C, 0x00, 0x00, 0x37, + 0x00, 0xC0, 0x00, 0x04, 0x60, 0x0C, 0x00, 0x01, 0x80, 0x00, 0xC0, 0x00, + 0x20, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x07, + 0x00, 0xC0, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, + 0x00, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0xD0, 0x00, + 0x00, 0xE0, 0x12, 0x00, 0x00, 0x16, 0x04, 0x60, 0x00, 0x02, 0x71, 0x8C, + 0x00, 0x00, 0x63, 0x20, 0x80, 0x00, 0x0C, 0x1F, 0xD0, 0x78, 0x00, 0x8E, + 0x0F, 0xFD, 0x00, 0x12, 0x00, 0x30, 0x60, 0x02, 0x80, 0x02, 0x08, 0x00, + 0x60, 0x00, 0x22, 0x00, 0x7C, 0x00, 0x06, 0xC0, 0xFD, 0x00, 0x00, 0x50, + 0x30, 0x20, 0x00, 0x0C, 0x06, 0x08, 0x00, 0x00, 0x80, 0x71, 0x00, 0x00, + 0x18, 0x03, 0x20, 0x00, 0x02, 0xC0, 0x3C, 0x00, 0x00, 0x4C, 0x01, 0x80, + 0x00, 0x08, 0x60, 0x10, 0x00, 0x01, 0x06, 0x07, 0x00, 0x00, 0x40, 0xC0, + 0xA0, 0x00, 0x0B, 0xF0, 0x36, 0x00, 0x03, 0xE0, 0x04, 0x40, 0x00, 0x60, + 0x01, 0x04, 0x00, 0x14, 0x00, 0x60, 0xC0, 0x04, 0x80, 0x0B, 0xFF, 0x07, + 0x10, 0x01, 0xF0, 0xBF, 0xC3, 0x00, 0x00, 0x10, 0x4C, 0x60, 0x00, 0x03, + 0x18, 0xE4, 0x00, 0x00, 0x62, 0x06, 0x80, 0x00, 0x0C, 0xC0, 0x70, 0x00, + 0x00, 0xB0, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x03, 0x83, 0x80, 0x00, 0x00, + 0x30, 0x06, 0x00, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x30, 0x00, 0x60, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x07, 0xC0, + 0x00, 0x60, 0x00, 0xC3, 0x80, 0x01, 0x00, 0x0C, 0x04, 0x00, 0x08, 0x00, + 0xC0, 0x30, 0x00, 0x40, 0x04, 0x00, 0x80, 0x02, 0x00, 0x20, 0x04, 0x00, + 0x18, 0x0F, 0x00, 0x00, 0x01, 0xF1, 0xC0, 0x00, 0x00, 0x00, 0xC8, 0x00, + 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, + 0x00, 0x03, 0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x30, 0x03, 0x00, 0x38, 0x03, 0x80, + 0x38, 0x03, 0xC0, 0x3C, 0x03, 0xC0, 0x1E, 0x01, 0xE0, 0x1E, 0x00, 0xE0, + 0x0E, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x80, 0x30, 0x00, 0x00, 0x1C, 0x03, 0x80, 0x00, 0x01, 0xE0, + 0x3C, 0x00, 0x00, 0x0F, 0x01, 0xC0, 0x00, 0x00, 0x70, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x1C, 0x0C, 0x00, 0x00, 0x00, + 0x70, 0x02, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x80, 0x00, 0x01, 0x80, 0x00, 0x40, 0x00, 0x03, 0x00, 0x00, 0x40, 0x00, + 0x3F, 0x00, 0x00, 0x20, 0x00, 0xE1, 0xC0, 0x00, 0x20, 0x01, 0x80, 0x60, + 0x00, 0x20, 0x01, 0x00, 0x20, 0x00, 0x20, 0x02, 0x00, 0x10, 0x00, 0x20, + 0x02, 0x00, 0x10, 0x00, 0x20, 0x06, 0x00, 0x00, 0x00, 0x38, 0x1E, 0x00, + 0x00, 0x00, 0x0C, 0x70, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, + 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, + 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x02, 0x60, 0x00, 0x00, 0x00, 0x02, 0x18, 0x20, 0x00, 0x00, 0x0C, + 0x0F, 0xF0, 0x00, 0x00, 0x70, 0x00, 0x0F, 0xFC, 0x00, 0x80, 0x00, 0x03, + 0xE7, 0x03, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x01, 0xF0, 0x00, 0x1F, + 0x00, 0x0F, 0xFC, 0x01, 0xFF, 0x80, 0x39, 0xDC, 0x07, 0x3B, 0x80, 0xF2, + 0xDC, 0x1E, 0x5B, 0x83, 0xB4, 0xEC, 0x6E, 0x9D, 0x8D, 0x38, 0xCD, 0x93, + 0x19, 0x9E, 0x30, 0xCB, 0xA3, 0x19, 0x64, 0x31, 0x69, 0xC7, 0x3B, 0x8C, + 0x52, 0x71, 0x8B, 0x4F, 0x96, 0x94, 0x61, 0x93, 0x8F, 0xA7, 0x18, 0x63, + 0xA3, 0x0D, 0xC6, 0x18, 0xE4, 0xC3, 0x19, 0x86, 0x39, 0x68, 0x87, 0x31, + 0x8E, 0x5A, 0x71, 0xCB, 0x53, 0x96, 0x9C, 0x62, 0xD1, 0x25, 0xA7, 0x18, + 0x64, 0xE2, 0x69, 0xC6, 0x18, 0xE8, 0xC4, 0x70, 0x86, 0x39, 0x70, 0xD0, + 0xE1, 0x8E, 0x5A, 0x21, 0xE0, 0xE2, 0xD2, 0x9C, 0x62, 0x81, 0xA4, 0xE3, + 0x08, 0xB7, 0x01, 0x38, 0xC3, 0x19, 0x34, 0x01, 0x30, 0xC7, 0x2E, 0x30, + 0x01, 0x31, 0xCB, 0x4C, 0x40, 0x01, 0x72, 0xD3, 0x8D, 0x00, 0x03, 0xB4, + 0xE3, 0x1C, 0x00, 0x03, 0x38, 0xC3, 0x38, 0x00, 0x03, 0x30, 0xC7, 0x60, + 0x00, 0x01, 0x31, 0xCB, 0x00, 0x00, 0x01, 0x72, 0x54, 0x00, 0x00, 0x01, + 0xB4, 0x70, 0x00, 0x00, 0x01, 0x18, 0x40, 0x00, 0x00, 0x01, 0x93, 0x00, + 0x00, 0x00, 0x01, 0xBC, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x38, 0x00, + 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x01, 0xFE, + 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x0F, 0xFF, 0xC0, 0x00, 0x01, + 0xFF, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0xC0, 0x00, 0x07, 0xFF, 0xFC, 0x00, + 0x03, 0xFF, 0xFF, 0x80, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x3F, 0xFF, 0xFE, + 0x00, 0x07, 0xFF, 0xFF, 0xE0, 0x01, 0xFF, 0xFF, 0xFE, 0x00, 0x3F, 0xFF, + 0xFF, 0xE0, 0x07, 0xE1, 0xF8, 0xFC, 0x00, 0xF8, 0x1E, 0x0F, 0x80, 0x3E, + 0x71, 0x98, 0xF8, 0x1F, 0xCF, 0x37, 0x9F, 0xC7, 0xF9, 0xC6, 0x63, 0xFC, + 0xFF, 0x01, 0xE0, 0x7F, 0xBF, 0xF0, 0x7C, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, + 0x03, 0xFF, 0xBF, 0xF0, 0x00, 0x7F, 0xE7, 0xFE, 0x00, 0x1F, 0xFC, 0x7F, + 0xE0, 0x03, 0xFF, 0x0F, 0xFE, 0x00, 0xFF, 0xC0, 0xFF, 0xF0, 0x7F, 0xF0, + 0x07, 0xFF, 0xFF, 0xFC, 0x00, 0x7F, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, + 0x00, 0x00, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x0C, 0x20, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0x06, 0x30, 0x00, 0x00, 0x00, 0x7C, 0x00, + 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x1C, 0x07, 0x00, 0x00, 0x06, 0x00, + 0x30, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x43, 0x00, 0x30, 0x00, 0x18, + 0xC0, 0x03, 0x00, 0x02, 0x30, 0x00, 0x20, 0x00, 0x44, 0x00, 0x04, 0x00, + 0x11, 0x80, 0x00, 0xC0, 0x02, 0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x01, + 0x00, 0x08, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x04, 0x00, 0x20, 0x00, + 0x00, 0x80, 0x0C, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x03, 0x00, 0x20, + 0x00, 0x00, 0x20, 0x0D, 0xFF, 0xFE, 0x04, 0x01, 0xE0, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x44, 0x07, 0xFF, 0xFC, + 0x04, 0xFF, 0xF8, 0x0F, 0xFE, 0xBF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xE0, + 0x3F, 0xFF, 0xFF, 0xFE, 0x0F, 0xFF, 0xC7, 0xFF, 0xC1, 0xFF, 0xF0, 0x3F, + 0xFC, 0x7F, 0xF8, 0x00, 0x3F, 0xFF, 0xE0, 0x00, 0x00, 0x07, 0xFC, 0x00, + 0x00, 0x07, 0x00, 0xF0, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0xC0, 0x00, + 0x18, 0x00, 0x20, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x08, 0x02, 0x00, + 0x00, 0x00, 0x80, 0x82, 0x00, 0x02, 0x08, 0x11, 0xC0, 0x00, 0x71, 0x04, + 0xE0, 0x00, 0x03, 0x11, 0x90, 0x00, 0x00, 0x33, 0x26, 0x00, 0x00, 0x03, + 0x24, 0x0E, 0x00, 0x0F, 0x05, 0x87, 0xF0, 0x07, 0xF0, 0x61, 0xCF, 0x01, + 0xE7, 0x0C, 0x09, 0x80, 0x0C, 0x81, 0x81, 0x30, 0x01, 0x90, 0x30, 0x26, + 0x00, 0x32, 0x06, 0x04, 0xC0, 0x06, 0x40, 0xC0, 0x98, 0xF8, 0xC8, 0x18, + 0x13, 0xFF, 0xF9, 0x03, 0x02, 0x70, 0x07, 0x20, 0xD0, 0x4C, 0x00, 0x64, + 0x12, 0x09, 0x80, 0x0C, 0x82, 0x61, 0x3F, 0xFF, 0x90, 0xC4, 0x27, 0xFF, + 0xF2, 0x10, 0xC4, 0xFF, 0xFE, 0x46, 0x08, 0x9F, 0xDF, 0xC8, 0x80, 0x93, + 0x00, 0x19, 0x30, 0x1A, 0x60, 0x03, 0x2C, 0x01, 0xCC, 0x00, 0x67, 0x80, + 0xC1, 0x80, 0x1C, 0x18, 0x10, 0x18, 0x03, 0x01, 0x03, 0x03, 0xC1, 0xE0, + 0x60, 0x20, 0x18, 0x30, 0x08, 0x06, 0x03, 0xFF, 0x02, 0x00, 0x3F, 0x80, + 0x3F, 0x80, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, + 0x24, 0x80, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x06, 0xC8, 0x00, 0x00, + 0x01, 0x93, 0x00, 0x00, 0x00, 0x55, 0xC0, 0x00, 0x00, 0x1F, 0xF0, 0x00, + 0x00, 0x04, 0x44, 0x00, 0x00, 0x01, 0x11, 0x00, 0x00, 0x00, 0xC4, 0x40, + 0x00, 0x00, 0x31, 0x10, 0x00, 0x00, 0x0C, 0x46, 0x00, 0x00, 0x02, 0x11, + 0x80, 0x00, 0x00, 0x84, 0x20, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0x18, + 0x43, 0x00, 0x00, 0x04, 0x10, 0xC0, 0x00, 0x01, 0x04, 0x10, 0x00, 0x00, + 0x41, 0x04, 0x00, 0x00, 0x30, 0x41, 0x00, 0x00, 0x3C, 0x10, 0x78, 0x00, + 0x7E, 0x04, 0x0F, 0x80, 0x7A, 0x01, 0x01, 0xBC, 0x70, 0xC0, 0x40, 0x43, + 0xD0, 0x10, 0x10, 0x30, 0x10, 0x06, 0x0C, 0x0C, 0x00, 0x00, 0xC7, 0xC6, + 0x00, 0x00, 0x13, 0x1B, 0x00, 0x00, 0x07, 0x83, 0x80, 0x00, 0x00, 0xF1, + 0xE0, 0x00, 0x00, 0x1C, 0x70, 0x00, 0x00, 0x03, 0x18, 0x00, 0x00, 0x03, + 0x83, 0x80, 0x00, 0x01, 0x80, 0x30, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, + 0x07, 0xFC, 0x00, 0x00, 0x07, 0x80, 0xF0, 0x00, 0x01, 0x80, 0x03, 0x80, + 0x00, 0xC0, 0x00, 0x18, 0x00, 0x20, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, + 0x08, 0x02, 0x00, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0x08, 0x10, 0xE0, + 0x00, 0x01, 0x84, 0x30, 0x00, 0x00, 0x10, 0x8C, 0x00, 0x00, 0x03, 0x21, + 0x00, 0x00, 0x10, 0x24, 0x03, 0x00, 0x0E, 0x04, 0x80, 0xF0, 0x03, 0x00, + 0xE0, 0x1E, 0x01, 0xC0, 0x0C, 0x03, 0xC0, 0x3E, 0x01, 0x80, 0x30, 0x00, + 0xF0, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, + 0x00, 0x1E, 0x18, 0x00, 0x07, 0x07, 0xE1, 0x00, 0x00, 0x30, 0xFF, 0x90, + 0x00, 0x02, 0x1F, 0xFA, 0x00, 0x00, 0x43, 0xFF, 0x40, 0x00, 0x30, 0x7F, + 0xE4, 0x00, 0x01, 0x0F, 0xFC, 0x80, 0x00, 0x20, 0xFF, 0x88, 0x00, 0x0C, + 0x3F, 0xE1, 0x80, 0x06, 0x07, 0xF0, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xE0, 0x01, 0x80, 0x00, 0x30, 0x00, + 0x0C, 0x00, 0x1C, 0x00, 0x00, 0x70, 0x1E, 0x00, 0x00, 0x01, 0xFE, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xC0, 0x30, 0x00, 0xC0, 0xC0, + 0x00, 0x30, 0x30, 0x40, 0x30, 0x04, 0x04, 0x30, 0x04, 0x01, 0x00, 0x08, + 0x00, 0x00, 0x24, 0x02, 0x3C, 0x00, 0x09, 0x80, 0x99, 0x80, 0x02, 0x00, + 0x2C, 0x20, 0x00, 0x80, 0x06, 0x08, 0xF0, 0x20, 0x01, 0x86, 0x47, 0x18, + 0x1C, 0x3F, 0x10, 0x7C, 0x01, 0x0C, 0x04, 0x00, 0x00, 0x0F, 0x80, 0x80, + 0x00, 0x0C, 0x78, 0x21, 0x80, 0x02, 0x13, 0x08, 0x20, 0x01, 0x04, 0x7E, + 0x00, 0x00, 0x41, 0x1E, 0x00, 0x00, 0x30, 0x8D, 0x00, 0x0C, 0x0C, 0x66, + 0x23, 0x04, 0x07, 0x11, 0x08, 0x42, 0x01, 0x40, 0x41, 0x01, 0x80, 0x48, + 0x00, 0x40, 0x60, 0x32, 0x00, 0x7C, 0x10, 0x0C, 0x43, 0xE7, 0x8C, 0x07, + 0x88, 0x01, 0x3F, 0x01, 0x21, 0x00, 0x47, 0x80, 0xCC, 0x30, 0x20, 0x00, + 0x31, 0x83, 0xF0, 0x00, 0xCC, 0x38, 0xF0, 0x00, 0x05, 0x83, 0xF0, 0x04, + 0x01, 0x30, 0xE0, 0x01, 0x80, 0xC7, 0xE0, 0x00, 0x60, 0xA1, 0xE0, 0x00, + 0x00, 0x69, 0xC0, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x07, + 0xFC, 0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, + 0xC0, 0x00, 0x18, 0x00, 0x20, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x08, + 0x02, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, + 0x01, 0x04, 0x00, 0x00, 0x00, 0x11, 0x80, 0x00, 0x00, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x24, 0x01, 0x80, 0x18, 0x05, 0x80, 0x78, 0x07, 0x80, 0xA0, + 0x0F, 0x00, 0xF0, 0x0C, 0x01, 0xE0, 0x1E, 0x01, 0x80, 0x18, 0x01, 0x80, + 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, + 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x07, 0xC0, 0x01, 0xF0, 0x70, 0x87, + 0xFF, 0xC2, 0x12, 0x1C, 0x00, 0x01, 0xC2, 0x41, 0xFF, 0xFF, 0xF0, 0x4C, + 0x3F, 0xFF, 0xFE, 0x10, 0x83, 0xFF, 0xFF, 0x82, 0x08, 0x1F, 0x03, 0xC0, + 0x81, 0x01, 0xC0, 0x30, 0x10, 0x10, 0x07, 0xF8, 0x04, 0x01, 0x00, 0x00, + 0x01, 0x00, 0x10, 0x00, 0x00, 0x40, 0x01, 0x80, 0x00, 0x30, 0x00, 0x1C, + 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x0E, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, + 0x00, 0x07, 0xFC, 0x00, 0x00, 0x07, 0x80, 0xE0, 0x00, 0x01, 0x80, 0x03, + 0x00, 0x00, 0xC0, 0x00, 0x18, 0x00, 0x20, 0x00, 0x01, 0x80, 0x08, 0x00, + 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x18, 0x10, + 0x10, 0x01, 0x81, 0x04, 0x1C, 0x00, 0x1E, 0x10, 0x8E, 0x00, 0x00, 0xF2, + 0x20, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x80, 0xF0, 0x07, + 0xC0, 0xA0, 0x67, 0x81, 0x9C, 0x0C, 0x08, 0x70, 0x61, 0xC1, 0x83, 0x0F, + 0x18, 0x3C, 0x30, 0x63, 0xE3, 0x0F, 0x86, 0x0C, 0xFC, 0x73, 0xF0, 0xC1, + 0xFB, 0x8F, 0xEE, 0x18, 0x1F, 0xE0, 0xFF, 0x83, 0x03, 0xFC, 0x0F, 0xE0, + 0x50, 0x1E, 0x00, 0xF8, 0x12, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x44, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x02, 0x08, 0x00, + 0x00, 0x00, 0x81, 0x00, 0x3F, 0x80, 0x30, 0x10, 0x04, 0x10, 0x04, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x40, 0x01, 0x80, 0x00, 0x30, + 0x00, 0x0C, 0x00, 0x18, 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x00, 0x03, 0xFE, + 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x70, 0x0E, 0x02, 0x00, + 0x06, 0x00, 0x0E, 0x0C, 0x00, 0x60, 0x00, 0x0E, 0x58, 0x02, 0x00, 0x00, + 0x0F, 0x20, 0x10, 0x00, 0x00, 0x18, 0x40, 0x80, 0x00, 0x00, 0x41, 0x86, + 0x00, 0x00, 0x01, 0x02, 0x10, 0x00, 0x00, 0x08, 0x04, 0x80, 0x00, 0x00, + 0x20, 0x12, 0x00, 0x00, 0x00, 0x80, 0x50, 0x00, 0x00, 0x02, 0x01, 0x40, + 0x00, 0x00, 0x0C, 0x0D, 0x01, 0xF0, 0x1F, 0x18, 0x68, 0x0C, 0x60, 0xC6, + 0x3E, 0x20, 0x00, 0x82, 0x08, 0x08, 0x80, 0x00, 0x00, 0x00, 0x22, 0x00, + 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, + 0x08, 0x80, 0x00, 0x00, 0x00, 0x22, 0x0F, 0xC0, 0x03, 0xE0, 0x84, 0x21, + 0xFF, 0xF0, 0x84, 0x10, 0xE0, 0x00, 0x0E, 0x10, 0x41, 0xFF, 0xFF, 0xF8, + 0x40, 0x87, 0xFF, 0xFF, 0xC2, 0x02, 0x0F, 0xFF, 0xFE, 0x08, 0x04, 0x0F, + 0x83, 0xF0, 0x40, 0x10, 0x1C, 0x07, 0x03, 0x00, 0x20, 0x0F, 0xE0, 0x08, + 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x80, 0x00, 0x06, 0x00, 0x01, 0x80, + 0x00, 0x30, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, 0x03, 0xC0, 0x70, 0x00, + 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x01, 0xF8, 0x00, + 0x00, 0x0F, 0xC0, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x0F, 0xF0, + 0x00, 0x01, 0xFF, 0x80, 0x00, 0x3F, 0xF8, 0x00, 0x87, 0xFF, 0x80, 0x18, + 0x7F, 0x78, 0x03, 0x8F, 0xCF, 0x00, 0x38, 0xF8, 0xF0, 0x07, 0x9F, 0x0F, + 0x00, 0x79, 0xE0, 0xF0, 0x0F, 0xDE, 0x0F, 0x04, 0xFF, 0xC0, 0xF9, 0xCF, + 0xFC, 0x0F, 0xFE, 0xFF, 0xC0, 0x7F, 0xEF, 0xFC, 0x07, 0xFF, 0xFF, 0xC0, + 0x3F, 0xFF, 0xF6, 0x01, 0xFF, 0xFF, 0x60, 0x0F, 0xFF, 0xE0, 0x00, 0xFF, + 0x7E, 0x00, 0x07, 0xE7, 0xE0, 0x00, 0x7E, 0x7E, 0x00, 0x07, 0xE3, 0xE0, + 0x00, 0x7C, 0x1E, 0x00, 0x0F, 0xC1, 0xF0, 0x00, 0xF8, 0x0F, 0x80, 0x1F, + 0x00, 0x3E, 0x07, 0xC0, 0x01, 0xFF, 0xF8, 0x00, 0x03, 0xFC, 0x00, 0x00, + 0x0F, 0xFC, 0x00, 0x00, 0x01, 0xC0, 0x38, 0x00, 0x00, 0x38, 0x00, 0x60, + 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x02, 0x00, 0x01, 0x00, + 0x00, 0x18, 0x00, 0x18, 0x1F, 0x80, 0x60, 0x01, 0x81, 0x86, 0x01, 0x00, + 0x08, 0x08, 0x10, 0x0C, 0x00, 0xC0, 0xC0, 0xF8, 0x30, 0x04, 0x16, 0x03, + 0x60, 0x80, 0x60, 0xF0, 0x13, 0x06, 0x02, 0x01, 0x80, 0x10, 0x18, 0x30, + 0x04, 0x00, 0x80, 0x61, 0x00, 0x30, 0x0C, 0x01, 0x18, 0x00, 0xC0, 0x20, + 0x0C, 0xC0, 0x03, 0x01, 0x00, 0x34, 0x01, 0xF8, 0x04, 0x00, 0xA0, 0x00, + 0x60, 0x30, 0x05, 0x00, 0x01, 0x00, 0xC0, 0x38, 0x00, 0x0C, 0x01, 0x80, + 0xC0, 0x00, 0x20, 0x04, 0x06, 0x00, 0x01, 0x80, 0x00, 0x38, 0x00, 0x06, + 0x00, 0x01, 0xC0, 0x00, 0x18, 0x00, 0x1B, 0x00, 0x00, 0x60, 0x00, 0xCC, + 0x00, 0x01, 0x80, 0x0C, 0x38, 0x00, 0x06, 0x00, 0x40, 0x7C, 0x00, 0x7E, + 0x0E, 0x00, 0xFF, 0xFF, 0x3F, 0xC0, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x00, + 0x00, 0x70, 0x1C, 0x00, 0x00, 0x00, 0x30, 0x01, 0x80, 0x00, 0x00, 0x10, + 0x00, 0x30, 0x00, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, + 0xC0, 0x00, 0x03, 0x00, 0x00, 0x18, 0x01, 0xC0, 0x80, 0x00, 0x02, 0x0F, + 0xC8, 0x40, 0x00, 0x00, 0xC6, 0x71, 0x30, 0x70, 0x18, 0x19, 0x1C, 0x78, + 0x1C, 0x0E, 0x03, 0x85, 0x03, 0x03, 0x01, 0x81, 0x83, 0x60, 0x40, 0x00, + 0x00, 0xC0, 0x8C, 0x18, 0x00, 0x00, 0x20, 0x61, 0x83, 0x00, 0xE0, 0x18, + 0x30, 0x20, 0x40, 0x38, 0x04, 0x18, 0x0C, 0x18, 0x00, 0x03, 0x04, 0x03, + 0x82, 0x00, 0x00, 0x83, 0x80, 0xA0, 0x80, 0x00, 0x60, 0xA0, 0x6C, 0x30, + 0x00, 0x18, 0x68, 0x13, 0x0C, 0x00, 0x04, 0x13, 0x04, 0x41, 0x00, 0x01, + 0x04, 0x41, 0x10, 0x40, 0x00, 0x41, 0x10, 0x40, 0x10, 0x00, 0x10, 0x04, + 0x10, 0x04, 0x00, 0x04, 0x01, 0x04, 0x01, 0x00, 0x01, 0x00, 0x41, 0x80, + 0xC0, 0x00, 0x40, 0x30, 0x20, 0x3F, 0xFF, 0xF8, 0x08, 0x0E, 0x18, 0xFF, + 0xC3, 0x0C, 0x00, 0xFC, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x07, 0xFC, 0x00, + 0x00, 0x07, 0x80, 0xE0, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, 0xC0, 0x00, + 0x18, 0x00, 0x20, 0x00, 0x01, 0x80, 0x08, 0x00, 0x00, 0x08, 0x02, 0x00, + 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x01, 0x04, + 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x02, 0x20, 0x7E, 0x01, 0xF8, + 0x24, 0x1F, 0xE0, 0x7F, 0x84, 0x82, 0xF4, 0x0B, 0xD0, 0xA0, 0x9E, 0x42, + 0x79, 0x0C, 0x10, 0x88, 0x42, 0x21, 0x82, 0x01, 0x08, 0x04, 0x30, 0x40, + 0x21, 0x00, 0x86, 0x04, 0x08, 0x10, 0x20, 0xC0, 0xC3, 0x03, 0x0C, 0x18, + 0x07, 0x80, 0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, + 0x00, 0x10, 0x80, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00, 0x81, 0x00, + 0x7F, 0xE0, 0x30, 0x10, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, + 0x10, 0x00, 0x00, 0x40, 0x01, 0x80, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x18, + 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x00, + 0x7F, 0x80, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x00, + 0xC0, 0x00, 0x00, 0xC0, 0x00, 0x1C, 0x00, 0x00, 0x60, 0x00, 0x01, 0x80, + 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x18, 0x00, 0x00, 0x06, 0x00, 0x0C, + 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0xF0, 0x30, 0x01, 0x80, 0x00, + 0x66, 0x06, 0x00, 0x60, 0x78, 0x10, 0x81, 0x80, 0x30, 0x13, 0x04, 0x00, + 0x30, 0x0C, 0x08, 0x00, 0x00, 0x0C, 0x07, 0x02, 0x00, 0x00, 0x43, 0x01, + 0x80, 0x00, 0x00, 0x10, 0x60, 0x60, 0x00, 0x00, 0x08, 0x18, 0x18, 0x00, + 0x00, 0x04, 0x06, 0x06, 0x00, 0x00, 0x06, 0x01, 0x81, 0x81, 0xC0, 0x07, + 0x00, 0x60, 0x60, 0x3E, 0x0F, 0x00, 0x18, 0x18, 0x01, 0xFF, 0x00, 0x06, + 0x07, 0xE0, 0x00, 0x00, 0x0F, 0x87, 0xCD, 0xC0, 0x00, 0x66, 0x79, 0x31, + 0x50, 0x00, 0x27, 0x12, 0x46, 0x32, 0x00, 0x19, 0x88, 0x98, 0x8C, 0x80, + 0x04, 0x46, 0x7B, 0x11, 0x20, 0x01, 0x11, 0x36, 0x22, 0x08, 0x00, 0x40, + 0x99, 0xC4, 0x01, 0x00, 0x10, 0x0C, 0xF8, 0x80, 0x40, 0x08, 0x06, 0x79, + 0x80, 0x10, 0x02, 0x00, 0x26, 0x30, 0x04, 0x00, 0x80, 0x11, 0x40, 0x01, + 0x00, 0x20, 0x00, 0xD8, 0x00, 0xC0, 0x0C, 0x00, 0x61, 0x80, 0x38, 0x07, + 0x00, 0x60, 0x38, 0x37, 0xFF, 0xB0, 0x70, 0x01, 0xF8, 0x00, 0x07, 0xE0, + 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x07, 0x80, 0xE0, 0x00, 0x01, 0x80, + 0x03, 0x00, 0x00, 0xC0, 0x00, 0x18, 0x00, 0x20, 0x00, 0x01, 0x80, 0x08, + 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x80, 0x81, 0xC0, 0x00, 0x18, + 0x10, 0x70, 0x00, 0x01, 0x04, 0x18, 0x00, 0x00, 0x10, 0x86, 0x00, 0x00, + 0x02, 0x20, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x02, 0x04, 0x80, 0x30, + 0x01, 0xC0, 0xA0, 0x0F, 0x00, 0x60, 0x0C, 0x01, 0xE0, 0x18, 0x01, 0x80, + 0x3C, 0x07, 0xC0, 0x30, 0x03, 0x00, 0x1E, 0x06, 0x00, 0x00, 0x00, 0x00, + 0xC0, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x50, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x04, 0x02, 0x40, 0x38, + 0x01, 0x80, 0x44, 0x01, 0xC0, 0xE0, 0x10, 0x80, 0x07, 0xE0, 0x02, 0x08, + 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00, 0x04, + 0x01, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x40, 0x01, 0x80, 0x00, + 0x30, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x00, 0x03, + 0xFE, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x03, 0xB8, 0x1C, 0x00, + 0x00, 0x60, 0xC0, 0x30, 0x00, 0x18, 0x00, 0x00, 0x80, 0x03, 0x00, 0x07, + 0xE4, 0x00, 0x61, 0xC0, 0x03, 0x20, 0x0C, 0x1E, 0x00, 0x01, 0x00, 0x81, + 0xE0, 0x00, 0x08, 0x10, 0x1E, 0x01, 0x80, 0xC3, 0x00, 0xC0, 0x3C, 0x04, + 0x20, 0x00, 0x03, 0xC0, 0x26, 0x00, 0x00, 0x3C, 0x02, 0x60, 0x00, 0x01, + 0x80, 0x24, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x14, 0x00, + 0x7F, 0x00, 0x01, 0x40, 0x1C, 0x1C, 0x00, 0x14, 0x00, 0x00, 0x60, 0x01, + 0x40, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, + 0x00, 0x18, 0x80, 0xFC, 0x00, 0x03, 0x8C, 0xF0, 0x20, 0x00, 0x28, 0x78, + 0x06, 0x00, 0x02, 0x40, 0x07, 0x80, 0x00, 0x64, 0x01, 0xC0, 0x00, 0x04, + 0x40, 0x3C, 0x00, 0x00, 0xC4, 0x00, 0x40, 0x00, 0x18, 0x40, 0x04, 0x00, + 0x01, 0x04, 0x01, 0xC0, 0x00, 0x20, 0x40, 0x04, 0x00, 0x0C, 0x04, 0x00, + 0xC0, 0x01, 0x80, 0x60, 0x04, 0x00, 0x70, 0x03, 0x00, 0x60, 0x3C, 0x00, + 0x18, 0x1F, 0xFF, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xFC, + 0x00, 0x00, 0x0C, 0xC4, 0x80, 0x00, 0x06, 0x19, 0x9C, 0x00, 0x07, 0x06, + 0x66, 0xE0, 0x01, 0x03, 0x33, 0x43, 0x00, 0xC0, 0x8C, 0xD8, 0x30, 0x10, + 0x06, 0x66, 0x01, 0x04, 0x00, 0x31, 0x00, 0x10, 0x80, 0x00, 0xC0, 0x01, + 0x10, 0x00, 0x68, 0x00, 0x32, 0x07, 0xF3, 0x00, 0x02, 0x41, 0x84, 0xC0, + 0x00, 0x64, 0x00, 0x70, 0x00, 0x04, 0xC0, 0x18, 0x03, 0x80, 0x8C, 0x1F, + 0x00, 0x78, 0x1B, 0xFF, 0xE0, 0x0F, 0x01, 0x60, 0x3C, 0x01, 0xE0, 0x2C, + 0x03, 0x00, 0x38, 0x05, 0x80, 0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x02, 0xC0, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, + 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x20, 0x18, 0x00, 0x80, 0x46, 0x03, + 0xFF, 0xF0, 0x08, 0x40, 0x00, 0x00, 0x02, 0x0C, 0x00, 0x00, 0x00, 0x40, + 0x80, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x06, 0x01, 0x80, 0x00, 0x01, + 0x80, 0x18, 0x00, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x10, 0x00, 0x0C, 0x00, + 0x0C, 0x00, 0x00, 0x70, 0x0E, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, 0x01, + 0xC0, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x86, 0x00, 0x00, 0x41, 0xC0, 0x00, + 0x30, 0x30, 0x00, 0x1C, 0x0C, 0x00, 0x1B, 0x83, 0x80, 0x08, 0x60, 0x60, + 0x04, 0x18, 0x18, 0x03, 0x07, 0x04, 0x00, 0xC1, 0x83, 0x00, 0x30, 0x60, + 0x80, 0x1F, 0xF0, 0x60, 0x3C, 0x3E, 0x10, 0x30, 0x03, 0x8C, 0x70, 0x00, + 0x62, 0x60, 0x10, 0x11, 0x20, 0x7E, 0x0C, 0xF0, 0x61, 0x82, 0x6C, 0xE0, + 0x61, 0xB3, 0xC0, 0x10, 0x0B, 0x80, 0x08, 0x07, 0x60, 0x04, 0x03, 0x18, + 0x02, 0x03, 0x86, 0x03, 0x01, 0xC1, 0x01, 0x80, 0xE0, 0x61, 0x80, 0x58, + 0x1F, 0x80, 0x24, 0x00, 0x00, 0x33, 0x00, 0x00, 0x10, 0xC0, 0x00, 0x18, + 0x30, 0x00, 0x18, 0x0C, 0x00, 0x18, 0x03, 0x80, 0x18, 0x00, 0xFF, 0xF8, + 0x00, 0x0F, 0xE0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, + 0x00, 0x3F, 0xFC, 0xE1, 0xF8, 0x7E, 0x1F, 0x87, 0xE1, 0xF8, 0x7E, 0x1F, + 0x87, 0xE1, 0xC0, 0x00, 0x38, 0x30, 0x00, 0x30, 0x70, 0x00, 0x70, 0x70, + 0x00, 0x70, 0x70, 0x00, 0x70, 0xE0, 0x00, 0x60, 0xE0, 0x00, 0xE0, 0xE0, + 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x01, 0xC1, 0xC0, + 0x01, 0xC1, 0xC0, 0x01, 0xC1, 0x80, 0x03, 0x83, 0x80, 0x03, 0x83, 0x80, + 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFC, 0x07, 0x07, 0x00, + 0x07, 0x07, 0x00, 0x07, 0x06, 0x00, 0x0E, 0x0E, 0x00, 0x0E, 0x0E, 0x00, + 0x0E, 0x0E, 0x00, 0x0E, 0x0C, 0x00, 0x01, 0x80, 0x00, 0xC0, 0x00, 0x60, + 0x00, 0x30, 0x00, 0xFF, 0x81, 0xFF, 0xF1, 0xFF, 0xF8, 0xF3, 0x0C, 0xF1, + 0x80, 0x70, 0xC0, 0x38, 0x60, 0x1C, 0x30, 0x0F, 0x18, 0x03, 0xFC, 0x00, + 0xFF, 0xC0, 0x1F, 0xF8, 0x01, 0xFF, 0x00, 0xC7, 0x80, 0x61, 0xE0, 0x30, + 0x70, 0x18, 0x38, 0x0C, 0x1E, 0x06, 0x1F, 0xC3, 0x3E, 0xFF, 0xFE, 0x3F, + 0xFE, 0x03, 0xFC, 0x00, 0x30, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x06, 0x00, + 0x03, 0x00, 0x1F, 0x80, 0x06, 0x01, 0xFE, 0x00, 0x70, 0x1E, 0x78, 0x03, + 0x00, 0xE1, 0xC0, 0x30, 0x0E, 0x07, 0x03, 0x80, 0x70, 0x38, 0x18, 0x03, + 0x81, 0xC1, 0xC0, 0x1C, 0x0E, 0x0C, 0x00, 0xE0, 0x70, 0xC0, 0x07, 0x03, + 0x8E, 0x00, 0x1C, 0x38, 0x60, 0x00, 0xF3, 0xC7, 0x00, 0x03, 0xFC, 0x30, + 0xFC, 0x0F, 0xC3, 0x0F, 0xF0, 0x00, 0x38, 0xF3, 0xC0, 0x01, 0x87, 0x0E, + 0x00, 0x1C, 0x70, 0x38, 0x00, 0xC3, 0x81, 0xC0, 0x0C, 0x1C, 0x0E, 0x00, + 0xE0, 0xE0, 0x70, 0x06, 0x07, 0x03, 0x80, 0x70, 0x38, 0x1C, 0x03, 0x00, + 0xE1, 0xC0, 0x30, 0x07, 0x9E, 0x03, 0x80, 0x1F, 0xE0, 0x18, 0x00, 0x7E, + 0x00, 0x01, 0xFC, 0x00, 0x07, 0xFF, 0x00, 0x0F, 0xFF, 0x00, 0x1F, 0x03, + 0x00, 0x1E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x1C, 0x00, + 0x00, 0x0E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x1F, 0xC0, + 0x00, 0x3D, 0xE0, 0x0E, 0x78, 0xF0, 0x0E, 0x70, 0x78, 0x1E, 0xF0, 0x3C, + 0x1C, 0xE0, 0x1F, 0x1C, 0xE0, 0x0F, 0xB8, 0xE0, 0x07, 0xF8, 0xE0, 0x03, + 0xF0, 0xF0, 0x01, 0xF0, 0x78, 0x03, 0xF0, 0x3E, 0x0F, 0xF8, 0x3F, 0xFF, + 0x7C, 0x0F, 0xFE, 0x3E, 0x03, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, + 0x0E, 0x1E, 0x1C, 0x18, 0x38, 0x38, 0x70, 0x70, 0x70, 0x70, 0xE0, 0xE0, + 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x70, 0x70, 0x70, 0x38, + 0x38, 0x1C, 0x1C, 0x1C, 0x0E, 0x07, 0xE0, 0x70, 0x70, 0x38, 0x38, 0x1C, + 0x1C, 0x0E, 0x0E, 0x0E, 0x0E, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x0E, 0x0E, 0x0E, 0x0E, 0x1C, 0x1C, 0x38, 0x38, 0x78, 0x70, + 0xE0, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x41, 0x82, 0xF1, 0x8F, 0x39, + 0x9C, 0x1F, 0xF8, 0x07, 0xE0, 0x07, 0xE0, 0x1F, 0xF0, 0x39, 0x9C, 0xF1, + 0x8F, 0x41, 0x82, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x38, 0x00, + 0x00, 0x70, 0x00, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, 0x03, 0x80, 0x00, + 0x07, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, + 0x70, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, + 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x70, + 0x00, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, 0x03, 0x80, 0x00, 0x07, 0x00, + 0x00, 0x0E, 0x00, 0x00, 0x77, 0x77, 0x6E, 0xEC, 0xFF, 0xFF, 0xFF, 0xE0, + 0xFF, 0xF0, 0x00, 0x70, 0x0F, 0x00, 0xE0, 0x0E, 0x01, 0xE0, 0x1C, 0x01, + 0xC0, 0x1C, 0x03, 0x80, 0x38, 0x03, 0x80, 0x78, 0x07, 0x00, 0x70, 0x0F, + 0x00, 0xE0, 0x0E, 0x00, 0xE0, 0x1C, 0x01, 0xC0, 0x1C, 0x03, 0x80, 0x38, + 0x03, 0x80, 0x78, 0x07, 0x00, 0x70, 0x0F, 0x00, 0xE0, 0x00, 0x03, 0xF0, + 0x03, 0xFF, 0x01, 0xFF, 0xE0, 0xF8, 0x7C, 0x38, 0x07, 0x1E, 0x01, 0xE7, + 0x00, 0x39, 0xC0, 0x0E, 0xE0, 0x01, 0xF8, 0x00, 0x7E, 0x00, 0x1F, 0x80, + 0x07, 0xE0, 0x01, 0xF8, 0x00, 0x7E, 0x00, 0x1F, 0x80, 0x07, 0xE0, 0x01, + 0xF8, 0x00, 0x77, 0x00, 0x39, 0xC0, 0x0E, 0x78, 0x07, 0x8E, 0x01, 0xC3, + 0xE1, 0xF0, 0x7F, 0xF8, 0x0F, 0xFC, 0x00, 0xFC, 0x00, 0x1F, 0x81, 0xFF, + 0x03, 0xFE, 0x07, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, + 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, + 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, + 0x00, 0x70, 0x00, 0xE0, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x3F, 0xE0, + 0xFF, 0xF8, 0xFF, 0xFC, 0xF0, 0x3E, 0x80, 0x0E, 0x00, 0x0F, 0x00, 0x07, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x1E, 0x00, 0x1C, + 0x00, 0x38, 0x00, 0x78, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0x80, + 0x0F, 0x00, 0x1E, 0x00, 0x3C, 0x00, 0xF8, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x1F, 0xE0, 0x3F, 0xFC, 0x1F, 0xFF, 0x0C, 0x07, 0xC0, 0x00, + 0xF0, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x07, 0x00, + 0x07, 0x81, 0xFF, 0x80, 0xFF, 0x00, 0x7F, 0xE0, 0x00, 0x7C, 0x00, 0x0E, + 0x00, 0x07, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x78, 0x00, + 0x3B, 0x00, 0x7D, 0xFF, 0xFC, 0xFF, 0xFC, 0x1F, 0xF0, 0x00, 0x00, 0x3E, + 0x00, 0x07, 0xC0, 0x01, 0xF8, 0x00, 0x77, 0x00, 0x0E, 0xE0, 0x03, 0x9C, + 0x00, 0xE3, 0x80, 0x1C, 0x70, 0x07, 0x0E, 0x00, 0xE1, 0xC0, 0x38, 0x38, + 0x0E, 0x07, 0x01, 0xC0, 0xE0, 0x70, 0x1C, 0x1C, 0x03, 0x83, 0x80, 0x70, + 0xE0, 0x0E, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0xE0, + 0x00, 0x1C, 0x00, 0x03, 0x80, 0x00, 0x70, 0x00, 0x0E, 0x00, 0x01, 0xC0, + 0x7F, 0xFE, 0x3F, 0xFF, 0x1F, 0xFF, 0x8E, 0x00, 0x07, 0x00, 0x03, 0x80, + 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x3F, 0xF0, 0x1F, 0xFE, 0x0F, + 0xFF, 0xC6, 0x03, 0xE0, 0x00, 0x78, 0x00, 0x1E, 0x00, 0x07, 0x00, 0x03, + 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x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, 0xFE, 0x00, 0x07, 0xF0, + 0x07, 0xFF, 0x03, 0xFF, 0xE1, 0xF0, 0x7C, 0x70, 0x07, 0x3C, 0x01, 0xEE, + 0x00, 0x3B, 0x80, 0x0E, 0xE0, 0x03, 0xF8, 0x00, 0xFE, 0x00, 0x3F, 0xC0, + 0x1F, 0x70, 0x07, 0xDF, 0x07, 0xF3, 0xFF, 0xDC, 0x7F, 0xE7, 0x07, 0xF1, + 0xC0, 0x00, 0xF0, 0x00, 0x38, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xC3, + 0x03, 0xE0, 0xFF, 0xF0, 0x3F, 0xF8, 0x03, 0xF8, 0x00, 0xFF, 0xF0, 0x00, + 0x00, 0x00, 0x3F, 0xFC, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, + 0x77, 0x6E, 0xEC, 0x00, 0x00, 0x04, 0x00, 0x00, 0xF0, 0x00, 0x1F, 0xC0, + 0x03, 0xFE, 0x00, 0x3F, 0xC0, 0x07, 0xFC, 0x00, 0xFF, 0x80, 0x0F, 0xF0, + 0x00, 0xFF, 0x00, 0x03, 0xE0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, + 0x0F, 0xF8, 0x00, 0x07, 0xFC, 0x00, 0x03, 0xFC, 0x00, 0x03, 0xFE, 0x00, + 0x01, 0xFC, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, + 0x80, 0x00, 0x03, 0xC0, 0x00, 0x0F, 0xE0, 0x00, 0x1F, 0xF0, 0x00, 0x0F, + 0xF0, 0x00, 0x0F, 0xF8, 0x00, 0x07, 0xFC, 0x00, 0x03, 0xFC, 0x00, 0x03, + 0xFC, 0x00, 0x01, 0xF0, 0x00, 0x3F, 0xC0, 0x03, 0xFC, 0x00, 0x7F, 0xC0, + 0x0F, 0xF8, 0x00, 0xFF, 0x00, 0x1F, 0xF0, 0x00, 0xFE, 0x00, 0x03, 0xC0, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x1F, 0xC1, 0xFF, 0xCF, 0xFF, 0xBC, 0x1E, + 0x80, 0x3C, 0x00, 0x70, 0x01, 0xC0, 0x07, 0x00, 0x78, 0x03, 0xE0, 0x1F, + 0x00, 0xF8, 0x07, 0xC0, 0x3C, 0x00, 0xE0, 0x03, 0x80, 0x0E, 0x00, 0x38, + 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x80, 0x0E, + 0x00, 0x38, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x07, + 0xFF, 0xFE, 0x00, 0x1F, 0x80, 0x7E, 0x00, 0x7C, 0x00, 0x3E, 0x01, 0xE0, + 0x00, 0x1E, 0x07, 0x80, 0x00, 0x1E, 0x1E, 0x00, 0x00, 0x1E, 0x38, 0x0F, + 0x8E, 0x1C, 0xF0, 0x7F, 0xDC, 0x39, 0xC1, 0xFF, 0xF8, 0x3F, 0x83, 0xC1, + 0xF0, 0x7E, 0x0F, 0x01, 0xE0, 0xFC, 0x1C, 0x01, 0xC1, 0xF8, 0x38, 0x03, + 0x83, 0xF0, 0x70, 0x07, 0x07, 0xE0, 0xE0, 0x0E, 0x1F, 0xC1, 0xC0, 0x1C, + 0x3B, 0x83, 0xC0, 0x78, 0xF7, 0x83, 0xC1, 0xF3, 0xC7, 0x07, 0xFF, 0xFF, + 0x0E, 0x07, 0xFD, 0xF8, 0x0E, 0x03, 0xE3, 0xC0, 0x1E, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x02, 0x00, 0x3F, 0x00, 0x0E, 0x00, + 0x1F, 0x80, 0xFC, 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x0F, 0xFF, 0x80, 0x00, + 0x07, 0xF8, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0xF8, 0x00, 0x01, 0xF0, + 0x00, 0x07, 0x70, 0x00, 0x0E, 0xE0, 0x00, 0x1D, 0xC0, 0x00, 0x71, 0xC0, + 0x00, 0xE3, 0x80, 0x03, 0xC7, 0x80, 0x07, 0x07, 0x00, 0x0E, 0x0E, 0x00, + 0x3C, 0x1E, 0x00, 0x70, 0x1C, 0x00, 0xE0, 0x38, 0x03, 0x80, 0x38, 0x07, + 0x00, 0x70, 0x1E, 0x00, 0xF0, 0x3F, 0xFF, 0xE0, 0x7F, 0xFF, 0xC1, 0xFF, + 0xFF, 0xC3, 0x80, 0x03, 0x87, 0x00, 0x07, 0x1C, 0x00, 0x07, 0x38, 0x00, + 0x0E, 0x70, 0x00, 0x1D, 0xC0, 0x00, 0x1C, 0xFF, 0xF8, 0x3F, 0xFF, 0x8F, + 0xFF, 0xF3, 0x80, 0x3C, 0xE0, 0x07, 0xB8, 0x00, 0xEE, 0x00, 0x3B, 0x80, + 0x0E, 0xE0, 0x03, 0xB8, 0x01, 0xEE, 0x00, 0xF3, 0xFF, 0xF8, 0xFF, 0xFC, + 0x3F, 0xFF, 0xCE, 0x00, 0xFB, 0x80, 0x0E, 0xE0, 0x01, 0xF8, 0x00, 0x7E, + 0x00, 0x1F, 0x80, 0x07, 0xE0, 0x01, 0xF8, 0x00, 0xFE, 0x00, 0xFB, 0xFF, + 0xFC, 0xFF, 0xFE, 0x3F, 0xFE, 0x00, 0x00, 0x7F, 0x80, 0x1F, 0xFF, 0x83, + 0xFF, 0xFE, 0x3F, 0x01, 0xF3, 0xE0, 0x01, 0x9E, 0x00, 0x05, 0xE0, 0x00, + 0x0E, 0x00, 0x00, 0x70, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, + 0x00, 0x0E, 0x00, 0x00, 0x70, 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8, 0x00, 0x70, 0x00, 0xE0, 0x01, + 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, + 0x00, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0xFF, 0x80, 0x0F, 0xFF, 0xC0, 0xFF, + 0xFF, 0x87, 0xE0, 0x3E, 0x3E, 0x00, 0x18, 0xE0, 0x00, 0x27, 0x80, 0x00, + 0x1C, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x38, + 0x00, 0x00, 0xE0, 0x07, 0xFF, 0x80, 0x1F, 0xFE, 0x00, 0x7F, 0xF8, 0x00, + 0x07, 0xE0, 0x00, 0x1D, 0xC0, 0x00, 0x77, 0x00, 0x01, 0xDE, 0x00, 0x07, + 0x38, 0x00, 0x1C, 0xF8, 0x00, 0x71, 0xF8, 0x07, 0xC3, 0xFF, 0xFE, 0x03, + 0xFF, 0xE0, 0x03, 0xFE, 0x00, 0xE0, 0x00, 0xFC, 0x00, 0x1F, 0x80, 0x03, + 0xF0, 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, 0x00, 0x3F, 0x00, 0x07, + 0xE0, 0x00, 0xFC, 0x00, 0x1F, 0x80, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xF8, 0x00, 0x3F, 0x00, 0x07, 0xE0, 0x00, 0xFC, 0x00, 0x1F, + 0x80, 0x03, 0xF0, 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, 0x00, 0x3F, + 0x00, 0x07, 0xE0, 0x00, 0xFC, 0x00, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 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, 0x07, 0x38, 0x00, 0xE7, 0x00, 0x0E, 0xE0, 0x01, 0xDC, 0x00, + 0x1C, 0x07, 0xFC, 0x07, 0xFF, 0xC3, 0xFF, 0xF1, 0xF0, 0x0C, 0xF0, 0x00, + 0x38, 0x00, 0x0E, 0x00, 0x03, 0x80, 0x00, 0xE0, 0x00, 0x3C, 0x00, 0x07, + 0xC0, 0x00, 0xFF, 0x80, 0x1F, 0xFC, 0x00, 0xFF, 0xC0, 0x01, 0xF8, 0x00, + 0x1E, 0x00, 0x03, 0xC0, 0x00, 0x70, 0x00, 0x1C, 0x00, 0x07, 0x00, 0x01, + 0xE0, 0x00, 0xEF, 0x00, 0xFB, 0xFF, 0xFC, 0xFF, 0xFE, 0x0F, 0xFE, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xE0, 0x00, 0x07, + 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, + 0x03, 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, + 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, + 0x1C, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, + 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0xE0, 0x00, 0xFC, + 0x00, 0x1F, 0x80, 0x03, 0xF0, 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, + 0x00, 0x3F, 0x00, 0x07, 0xE0, 0x00, 0xFC, 0x00, 0x1F, 0x80, 0x03, 0xF0, + 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, 0x00, 0x3F, 0x00, 0x07, 0xE0, + 0x00, 0xFC, 0x00, 0x1F, 0x80, 0x03, 0xF8, 0x00, 0xF7, 0x00, 0x1C, 0xF0, + 0x07, 0x8F, 0x01, 0xE1, 0xFF, 0xFC, 0x0F, 0xFE, 0x00, 0x7F, 0x00, 0xE0, + 0x00, 0x0E, 0xE0, 0x00, 0x39, 0xC0, 0x00, 0x73, 0x80, 0x01, 0xE3, 0x80, + 0x03, 0x87, 0x00, 0x07, 0x0F, 0x00, 0x1E, 0x0E, 0x00, 0x38, 0x1C, 0x00, + 0x70, 0x3C, 0x01, 0xE0, 0x38, 0x03, 0x80, 0x70, 0x07, 0x00, 0x70, 0x1C, + 0x00, 0xE0, 0x38, 0x01, 0xE0, 0xF0, 0x01, 0xC1, 0xC0, 0x03, 0x83, 0x80, + 0x07, 0x8F, 0x00, 0x07, 0x1C, 0x00, 0x0E, 0x38, 0x00, 0x0E, 0xE0, 0x00, + 0x1D, 0xC0, 0x00, 0x3F, 0x80, 0x00, 0x3E, 0x00, 0x00, 0x7C, 0x00, 0x00, + 0xF8, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0x70, 0x07, + 0xE0, 0x0E, 0x70, 0x07, 0xE0, 0x0E, 0x70, 0x07, 0xE0, 0x0E, 0x70, 0x0F, + 0xF0, 0x0E, 0x38, 0x0E, 0x70, 0x1C, 0x38, 0x0E, 0x70, 0x1C, 0x38, 0x0E, + 0x70, 0x1C, 0x38, 0x1E, 0x78, 0x1C, 0x1C, 0x1C, 0x38, 0x38, 0x1C, 0x1C, + 0x38, 0x38, 0x1C, 0x1C, 0x38, 0x38, 0x1C, 0x1C, 0x38, 0x38, 0x0E, 0x38, + 0x1C, 0x70, 0x0E, 0x38, 0x1C, 0x70, 0x0E, 0x38, 0x1C, 0x70, 0x0E, 0x38, + 0x1C, 0x70, 0x0F, 0x70, 0x0E, 0xE0, 0x07, 0x70, 0x0E, 0xE0, 0x07, 0x70, + 0x0E, 0xE0, 0x07, 0x70, 0x0E, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xE0, + 0x07, 0xC0, 0x03, 0xE0, 0x07, 0xC0, 0x03, 0xE0, 0x07, 0xC0, 0x78, 0x00, + 0x78, 0xF0, 0x03, 0xC1, 0xC0, 0x0E, 0x07, 0x80, 0x78, 0x0F, 0x03, 0xC0, + 0x1C, 0x0E, 0x00, 0x78, 0x78, 0x00, 0xF3, 0xC0, 0x01, 0xCE, 0x00, 0x07, + 0xF8, 0x00, 0x0F, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x03, 0xF0, + 0x00, 0x0F, 0xC0, 0x00, 0x7F, 0x80, 0x03, 0xCF, 0x00, 0x0E, 0x1C, 0x00, + 0x78, 0x78, 0x03, 0xC0, 0xF0, 0x0E, 0x01, 0xC0, 0x78, 0x07, 0x83, 0xC0, + 0x0F, 0x0E, 0x00, 0x1C, 0x78, 0x00, 0x7B, 0xC0, 0x00, 0xF0, 0xF0, 0x00, + 0x7B, 0xC0, 0x07, 0x8E, 0x00, 0x38, 0x78, 0x03, 0xC1, 0xE0, 0x3C, 0x07, + 0x01, 0xC0, 0x3C, 0x1E, 0x00, 0xF1, 0xE0, 0x03, 0x8E, 0x00, 0x1E, 0xF0, + 0x00, 0x7F, 0x00, 0x01, 0xF0, 0x00, 0x0F, 0x80, 0x00, 0x38, 0x00, 0x01, + 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0x1C, 0x00, + 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, + 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, + 0xBF, 0xFF, 0xFC, 0x00, 0x01, 0xC0, 0x00, 0x1E, 0x00, 0x01, 0xE0, 0x00, + 0x1E, 0x00, 0x01, 0xE0, 0x00, 0x0E, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0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F, + 0x01, 0xC1, 0xC0, 0x38, 0x38, 0x07, 0x8F, 0x00, 0x71, 0xC0, 0x0E, 0x38, + 0x00, 0xEE, 0x00, 0x1D, 0xC0, 0x03, 0xF8, 0x00, 0x3E, 0x00, 0x07, 0xC0, + 0x00, 0xE0, 0x1E, 0x01, 0xFC, 0x0F, 0xC0, 0xF7, 0x03, 0xF0, 0x39, 0xC0, + 0xFC, 0x0E, 0x70, 0x3F, 0x03, 0x9E, 0x1C, 0xE1, 0xE3, 0x87, 0x38, 0x70, + 0xE1, 0xCE, 0x1C, 0x38, 0x73, 0x87, 0x07, 0x38, 0x73, 0x81, 0xCE, 0x1C, + 0xE0, 0x73, 0x87, 0x38, 0x1D, 0xE1, 0xEE, 0x03, 0xF0, 0x3F, 0x00, 0xFC, + 0x0F, 0xC0, 0x3F, 0x03, 0xF0, 0x0F, 0xC0, 0xFC, 0x01, 0xE0, 0x1E, 0x00, + 0x78, 0x07, 0x80, 0x78, 0x01, 0xE7, 0x80, 0x78, 0x78, 0x1E, 0x07, 0x03, + 0x80, 0xF0, 0xF0, 0x0F, 0x3C, 0x00, 0xFF, 0x00, 0x0F, 0xC0, 0x00, 0xF0, + 0x00, 0x1E, 0x00, 0x07, 0xE0, 0x01, 0xFE, 0x00, 0x79, 0xC0, 0x1E, 0x3C, + 0x03, 0x83, 0xC0, 0xF0, 0x38, 0x3C, 0x07, 0x8F, 0x00, 0x7B, 0xC0, 0x07, + 0x80, 0xE0, 0x00, 0xEE, 0x00, 0x39, 0xC0, 0x07, 0x1C, 0x01, 0xE3, 0x80, + 0x38, 0x78, 0x0F, 0x07, 0x01, 0xC0, 0xF0, 0x38, 0x0E, 0x0E, 0x01, 0xC1, + 0xC0, 0x1C, 0x78, 0x03, 0x8E, 0x00, 0x79, 0xC0, 0x07, 0x70, 0x00, 0xFE, + 0x00, 0x0F, 0xC0, 0x01, 0xF0, 0x00, 0x1E, 0x00, 0x03, 0x80, 0x00, 0x70, + 0x00, 0x1C, 0x00, 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0x00, 0x00, 0x3F, 0x80, 0x0F, 0xFE, 0x01, + 0xFF, 0xF0, 0x3E, 0x0F, 0x07, 0x80, 0x30, 0xF0, 0x01, 0x0E, 0x00, 0x00, + 0xE0, 0x00, 0x1C, 0x00, 0x07, 0xFF, 0xF0, 0xFF, 0xFE, 0x01, 0xC0, 0x00, + 0x1C, 0x00, 0x01, 0xC0, 0x00, 0x1C, 0x00, 0x07, 0xFF, 0xC0, 0xFF, 0xF8, + 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, 0x0F, 0x00, 0x10, 0x78, + 0x03, 0x03, 0xE0, 0xF0, 0x1F, 0xFF, 0x00, 0xFF, 0xE0, 0x03, 0xF8, 0x77, + 0x77, 0x6E, 0xEC, 0x00, 0x7E, 0x01, 0xFC, 0x07, 0xF8, 0x1E, 0x00, 0x38, + 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x1F, 0xFC, 0x3F, 0xF8, 0x7F, 0xF0, + 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, + 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, + 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x01, + 0xE0, 0x7F, 0x80, 0xFE, 0x01, 0xF8, 0x00, 0x71, 0xDC, 0x77, 0x1D, 0xC7, + 0x61, 0xB8, 0xEE, 0x3B, 0x0C, 0xE0, 0x0E, 0x00, 0xFC, 0x01, 0xC0, 0x1F, + 0x80, 0x38, 0x03, 0xF0, 0x07, 0x00, 0x70, 0x03, 0x80, 0x07, 0x00, 0x0E, + 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x7F, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFC, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, + 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, + 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, + 0x38, 0x00, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, + 0x70, 0x00, 0xE0, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x0E, 0x00, 0x1C, + 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, + 0x0E, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xE0, 0x01, 0xC0, 0x03, + 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x1F, 0x80, 0x06, + 0x00, 0x00, 0x07, 0xF8, 0x01, 0xC0, 0x00, 0x01, 0xE7, 0x80, 0x30, 0x00, + 0x00, 0x38, 0x70, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x03, 0x80, 0x00, 0x01, + 0xC0, 0xE0, 0x60, 0x00, 0x00, 0x38, 0x1C, 0x1C, 0x00, 0x00, 0x07, 0x03, + 0x83, 0x00, 0x00, 0x00, 0xE0, 0x70, 0xC0, 0x00, 0x00, 0x1C, 0x0E, 0x38, + 0x00, 0x00, 0x01, 0xC3, 0x86, 0x00, 0x00, 0x00, 0x3C, 0xF1, 0xC0, 0x00, + 0x00, 0x03, 0xFC, 0x30, 0xFC, 0x03, 0xF0, 0x3F, 0x0C, 0x3F, 0xC0, 0xFF, + 0x00, 0x03, 0x8F, 0x3C, 0x3C, 0xF0, 0x00, 0x61, 0xC3, 0x87, 0x0E, 0x00, + 0x1C, 0x70, 0x39, 0xC0, 0xE0, 0x03, 0x0E, 0x07, 0x38, 0x1C, 0x00, 0xC1, + 0xC0, 0xE7, 0x03, 0x80, 0x38, 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 0x73, 0xE0, 0x01, 0xC7, 0xC0, 0x07, + 0x1D, 0xC0, 0x00, 0x3B, 0x80, 0x00, 0x77, 0x00, 0x01, 0xC7, 0x00, 0x03, + 0x8E, 0x00, 0x0F, 0x1E, 0x00, 0x1C, 0x1C, 0x00, 0x38, 0x38, 0x00, 0xF0, + 0x78, 0x01, 0xC0, 0x70, 0x03, 0x80, 0xE0, 0x0E, 0x00, 0xE0, 0x1C, 0x01, + 0xC0, 0x78, 0x03, 0xC0, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, + 0x0E, 0x00, 0x0E, 0x1C, 0x00, 0x1C, 0x70, 0x00, 0x1C, 0xE0, 0x00, 0x39, + 0xC0, 0x00, 0x77, 0x00, 0x00, 0x70, 0x00, 0xFE, 0x00, 0xFF, 0xC0, 0xFF, + 0xE0, 0xF0, 0x30, 0x70, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0E, + 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x03, 0xFF, 0xE1, + 0xFF, 0xF0, 0xFF, 0xF8, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, + 0x00, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xC0, 0x40, 0x00, 0x5C, 0x00, 0x1D, 0xE7, 0xCF, 0x1F, 0xFF, 0xC1, + 0xFF, 0xF0, 0x3C, 0x1E, 0x07, 0x01, 0xC1, 0xC0, 0x1C, 0x38, 0x03, 0x87, + 0x00, 0x70, 0xE0, 0x0E, 0x1C, 0x01, 0xC1, 0xC0, 0x70, 0x3C, 0x1E, 0x0F, + 0xFF, 0xC1, 0xFF, 0xFC, 0x79, 0xF1, 0xDC, 0x00, 0x1D, 0x00, 0x01, 0x00, + 0xF0, 0x01, 0xEE, 0x00, 0x39, 0xE0, 0x0F, 0x1C, 0x01, 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+ 0x80, 0xF0, 0x1F, 0x07, 0x71, 0xC7, 0xF0, 0x7C, 0x00, 0x00, 0x38, 0x00, + 0x00, 0x70, 0x00, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, 0x03, 0x80, 0x00, + 0x07, 0x00, 0x00, 0x0E, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFC, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, 0x03, 0x80, 0x00, 0x07, + 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xC0, 0x7E, 0x3F, 0xEC, 0x1C, 0x03, 0x00, 0xC0, 0x70, 0x18, 0x0C, 0x0E, + 0x07, 0x03, 0x81, 0xC0, 0xFF, 0xFF, 0xF0, 0x1F, 0x8F, 0xF9, 0x83, 0x80, + 0x30, 0x0E, 0x3F, 0x87, 0xF0, 0x07, 0x00, 0x60, 0x0C, 0x01, 0xC0, 0xFF, + 0xFC, 0xFE, 0x00, 0x0F, 0x1E, 0x1C, 0x38, 0x70, 0xE0, 0x01, 0xE0, 0x78, + 0x0E, 0x03, 0x80, 0xE0, 0x38, 0x00, 0x07, 0x8F, 0xF1, 0xFE, 0x3F, 0xC7, + 0x80, 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x1D, 0xF0, 0x00, 0x73, 0xE0, + 0x01, 0xC7, 0xC0, 0x07, 0x1D, 0xC0, 0x00, 0x3B, 0x80, 0x00, 0x77, 0x00, + 0x01, 0xC7, 0x00, 0x03, 0x8E, 0x00, 0x0F, 0x1E, 0x00, 0x1C, 0x1C, 0x00, + 0x38, 0x38, 0x00, 0xF0, 0x78, 0x01, 0xC0, 0x70, 0x03, 0x80, 0xE0, 0x0E, + 0x00, 0xE0, 0x1C, 0x01, 0xC0, 0x78, 0x03, 0xC0, 0xFF, 0xFF, 0x81, 0xFF, + 0xFF, 0x07, 0xFF, 0xFF, 0x0E, 0x00, 0x0E, 0x1C, 0x00, 0x1C, 0x70, 0x00, + 0x1C, 0xE0, 0x00, 0x39, 0xC0, 0x00, 0x77, 0x00, 0x00, 0x70, 0xFF, 0xF0, + 0x07, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x77, 0xFF, 0xF9, 0xCF, 0xFF, 0xF7, + 0x1F, 0xFF, 0xEC, 0x38, 0x00, 0x00, 0x70, 0x00, 0x00, 0xE0, 0x00, 0x01, + 0xC0, 0x00, 0x03, 0x80, 0x00, 0x07, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, + 0x00, 0x00, 0x3F, 0xFF, 0x80, 0x7F, 0xFF, 0x00, 0xFF, 0xFE, 0x01, 0xC0, + 0x00, 0x03, 0x80, 0x00, 0x07, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, + 0x00, 0x38, 0x00, 0x00, 0x70, 0x00, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, + 0x03, 0xFF, 0xFC, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x07, 0x00, 0x00, + 0x03, 0x80, 0x00, 0x01, 0xDC, 0x00, 0x1C, 0xE7, 0x00, 0x07, 0x31, 0xC0, + 0x01, 0xD8, 0x70, 0x00, 0x70, 0x1C, 0x00, 0x1C, 0x07, 0x00, 0x07, 0x01, + 0xC0, 0x01, 0xC0, 0x70, 0x00, 0x70, 0x1C, 0x00, 0x1C, 0x07, 0x00, 0x07, + 0x01, 0xC0, 0x01, 0xC0, 0x7F, 0xFF, 0xF0, 0x1F, 0xFF, 0xFC, 0x07, 0xFF, + 0xFF, 0x01, 0xC0, 0x01, 0xC0, 0x70, 0x00, 0x70, 0x1C, 0x00, 0x1C, 0x07, + 0x00, 0x07, 0x01, 0xC0, 0x01, 0xC0, 0x70, 0x00, 0x70, 0x1C, 0x00, 0x1C, + 0x07, 0x00, 0x07, 0x01, 0xC0, 0x01, 0xC0, 0x70, 0x00, 0x70, 0x1C, 0x00, + 0x1C, 0x07, 0x00, 0x07, 0x07, 0x03, 0x81, 0xDC, 0xE7, 0x71, 0xD8, 0x70, + 0x1C, 0x07, 0x01, 0xC0, 0x70, 0x1C, 0x07, 0x01, 0xC0, 0x70, 0x1C, 0x07, + 0x01, 0xC0, 0x70, 0x1C, 0x07, 0x01, 0xC0, 0x70, 0x1C, 0x07, 0x01, 0xC0, + 0x70, 0x1C, 0x07, 0x81, 0x01, 0x83, 0x03, 0x87, 0x03, 0x87, 0x03, 0x87, + 0x03, 0x87, 0x03, 0x87, 0x03, 0x87, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE1, + 0xC3, 0x87, 0x0E, 0x1C, 0x38, 0x30, 0x60, 0x40, 0x80, 0x07, 0x00, 0x00, + 0x01, 0xC0, 0x00, 0x00, 0x70, 0x7F, 0x80, 0x1C, 0x3F, 0xFC, 0x03, 0x1F, + 0xFF, 0xC0, 0xC7, 0xE0, 0x7C, 0x01, 0xE0, 0x03, 0xC0, 0x78, 0x00, 0x3C, + 0x0E, 0x00, 0x03, 0x81, 0xC0, 0x00, 0x78, 0x70, 0x00, 0x07, 0x0E, 0x00, + 0x00, 0xE1, 0xC0, 0x00, 0x1E, 0x38, 0x00, 0x01, 0xC7, 0x00, 0x00, 0x38, + 0xE0, 0x00, 0x07, 0x1C, 0x00, 0x00, 0xE3, 0x80, 0x00, 0x3C, 0x70, 0x00, + 0x07, 0x0E, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x3C, 0x1C, 0x00, 0x07, 0x03, + 0xC0, 0x01, 0xE0, 0x3C, 0x00, 0x78, 0x03, 0xF0, 0x3E, 0x00, 0x3F, 0xFF, + 0x80, 0x03, 0xFF, 0xE0, 0x00, 0x0F, 0xE0, 0x00, 0x3C, 0x00, 0x07, 0x07, + 0xE0, 0x00, 0x30, 0x33, 0x00, 0x03, 0x00, 0x18, 0x00, 0x38, 0x00, 0xC0, + 0x01, 0x80, 0x06, 0x00, 0x1C, 0x00, 0x30, 0x01, 0xC0, 0x01, 0x80, 0x0C, + 0x00, 0x0C, 0x00, 0xE0, 0x00, 0x60, 0x06, 0x00, 0x03, 0x00, 0x60, 0x00, + 0x18, 0x07, 0x1F, 0x8F, 0xFC, 0x31, 0xFF, 0x7F, 0xE3, 0x08, 0x1C, 0x00, + 0x38, 0x00, 0x60, 0x01, 0x80, 0x03, 0x00, 0x18, 0x00, 0x30, 0x01, 0xC0, + 0x03, 0x80, 0x0C, 0x00, 0x38, 0x00, 0xE0, 0x03, 0x80, 0x06, 0x00, 0x38, + 0x00, 0x60, 0x03, 0x80, 0x07, 0x00, 0x38, 0x00, 0x30, 0x03, 0xFF, 0x03, + 0x00, 0x1F, 0xF8, 0x38, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xE0, + 0x00, 0x00, 0x1C, 0xE0, 0x00, 0xF3, 0x8F, 0x00, 0x0E, 0x70, 0x78, 0x01, + 0xE6, 0x03, 0x80, 0x3C, 0x00, 0x3C, 0x03, 0x80, 0x01, 0xE0, 0x78, 0x00, + 0x0E, 0x0F, 0x00, 0x00, 0xF0, 0xE0, 0x00, 0x07, 0x1E, 0x00, 0x00, 0x3B, + 0xC0, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x0E, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, + 0xE0, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x0E, 0x00, + 0x00, 0x00, 0xE0, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, + 0x0E, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x00, + 0x01, 0xC0, 0x00, 0x00, 0x70, 0x7F, 0x80, 0x1C, 0x3F, 0xFC, 0x07, 0x1F, + 0xFF, 0xE1, 0xC7, 0xE0, 0x7E, 0x01, 0xF0, 0x03, 0xE0, 0x38, 0x00, 0x3C, + 0x0F, 0x00, 0x03, 0xC1, 0xC0, 0x00, 0x38, 0x78, 0x00, 0x07, 0x0E, 0x00, + 0x00, 0x71, 0xC0, 0x00, 0x0E, 0x38, 0x00, 0x01, 0xC7, 0x00, 0x00, 0x38, + 0xE0, 0x00, 0x07, 0x1C, 0x00, 0x00, 0xE3, 0x80, 0x00, 0x3C, 0x38, 0x00, + 0x07, 0x07, 0x00, 0x00, 0xE0, 0xF0, 0x00, 0x38, 0x0E, 0x00, 0x07, 0x00, + 0xE0, 0x01, 0xC0, 0x0E, 0x00, 0x70, 0x00, 0xE0, 0x1C, 0x03, 0xFE, 0x07, + 0xFC, 0x7F, 0xC0, 0xFF, 0x8F, 0xF8, 0x1F, 0xF0, 0x00, 0xE0, 0x38, 0x0E, + 0x03, 0x80, 0x60, 0x18, 0x00, 0x07, 0x8F, 0xF1, 0xFE, 0x3F, 0xC7, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x03, 0x80, 0x70, 0x0E, 0x01, + 0xC0, 0x38, 0x07, 0x00, 0xE0, 0x1C, 0x03, 0x80, 0x70, 0x0E, 0x01, 0xC0, + 0x3C, 0x03, 0x80, 0x7F, 0x07, 0xE0, 0x7C, 0x00, 0x7C, 0x00, 0x00, 0xF8, + 0x00, 0x01, 0xF0, 0x00, 0x07, 0x70, 0x00, 0x0E, 0xE0, 0x00, 0x1D, 0xC0, + 0x00, 0x71, 0xC0, 0x00, 0xE3, 0x80, 0x03, 0xC7, 0x80, 0x07, 0x07, 0x00, + 0x0E, 0x0E, 0x00, 0x3C, 0x1E, 0x00, 0x70, 0x1C, 0x00, 0xE0, 0x38, 0x03, + 0x80, 0x38, 0x07, 0x00, 0x70, 0x1E, 0x00, 0xF0, 0x3F, 0xFF, 0xE0, 0x7F, + 0xFF, 0xC1, 0xFF, 0xFF, 0xC3, 0x80, 0x03, 0x87, 0x00, 0x07, 0x1C, 0x00, + 0x07, 0x38, 0x00, 0x0E, 0x70, 0x00, 0x1D, 0xC0, 0x00, 0x1C, 0xFF, 0xF8, + 0x3F, 0xFF, 0x8F, 0xFF, 0xF3, 0x80, 0x3C, 0xE0, 0x07, 0xB8, 0x00, 0xEE, + 0x00, 0x3B, 0x80, 0x0E, 0xE0, 0x03, 0xB8, 0x01, 0xEE, 0x00, 0xF3, 0xFF, + 0xF8, 0xFF, 0xFC, 0x3F, 0xFF, 0xCE, 0x00, 0xFB, 0x80, 0x0E, 0xE0, 0x01, + 0xF8, 0x00, 0x7E, 0x00, 0x1F, 0x80, 0x07, 0xE0, 0x01, 0xF8, 0x00, 0xFE, + 0x00, 0xFB, 0xFF, 0xFC, 0xFF, 0xFE, 0x3F, 0xFE, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, + 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, + 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, + 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x7C, + 0x00, 0x00, 0xF8, 0x00, 0x01, 0xF0, 0x00, 0x07, 0x70, 0x00, 0x0E, 0xE0, + 0x00, 0x1D, 0xC0, 0x00, 0x71, 0xC0, 0x00, 0xE3, 0x80, 0x03, 0xC7, 0x80, + 0x07, 0x07, 0x00, 0x0E, 0x0E, 0x00, 0x3C, 0x1E, 0x00, 0x70, 0x1C, 0x00, + 0xE0, 0x38, 0x03, 0x80, 0x38, 0x07, 0x00, 0x70, 0x1E, 0x00, 0xF0, 0x38, + 0x00, 0xE0, 0x70, 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 0x3F, 0x03, 0xC7, 0xE0, 0x38, 0xFC, + 0x07, 0x9F, 0x80, 0x73, 0xF0, 0x0F, 0x7E, 0x00, 0xEF, 0xC0, 0x1F, 0xF8, + 0x01, 0xFF, 0x00, 0x3F, 0xE0, 0x03, 0xFC, 0x00, 0x7C, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, + 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFF, 0x00, 0x03, 0xFF, 0xC0, 0x0F, 0xFF, 0xF0, 0x1F, 0x81, + 0xF8, 0x3E, 0x00, 0x7C, 0x3C, 0x00, 0x3C, 0x78, 0x00, 0x1E, 0x70, 0x00, + 0x0E, 0x70, 0x00, 0x0E, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, + 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, + 0x07, 0xE0, 0x00, 0x07, 0x70, 0x00, 0x0E, 0x70, 0x00, 0x0E, 0x78, 0x00, + 0x1E, 0x3C, 0x00, 0x3C, 0x3E, 0x00, 0x7C, 0x1F, 0x81, 0xF8, 0x0F, 0xFF, + 0xF0, 0x03, 0xFF, 0xC0, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xF0, 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, 0x00, 0x3F, + 0x00, 0x07, 0xE0, 0x00, 0xFC, 0x00, 0x1F, 0x80, 0x03, 0xF0, 0x00, 0x7E, + 0x00, 0x0F, 0xC0, 0x01, 0xF8, 0x00, 0x3F, 0x00, 0x07, 0xE0, 0x00, 0xFC, + 0x00, 0x1F, 0x80, 0x03, 0xF0, 0x00, 0x7E, 0x00, 0x0F, 0xC0, 0x01, 0xF8, + 0x00, 0x3F, 0x00, 0x07, 0xE0, 0x00, 0xFC, 0x00, 0x1C, 0xFF, 0xE0, 0xFF, + 0xF8, 0xFF, 0xFC, 0xE0, 0x3E, 0xE0, 0x0F, 0xE0, 0x07, 0xE0, 0x07, 0xE0, + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x0F, 0xE0, 0x3E, 0xFF, 0xFC, 0xFF, + 0xF8, 0xFF, 0xE0, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, + 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x78, 0x00, 0x3C, + 0x00, 0x1E, 0x00, 0x0F, 0x00, 0x07, 0x80, 0x03, 0xC0, 0x01, 0xE0, 0x00, + 0xF0, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x03, 0x80, 0x07, 0x80, 0x0F, + 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFE, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, + 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, + 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, + 0x70, 0x00, 0x03, 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, + 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, + 0x80, 0x00, 0xF0, 0x00, 0x7B, 0xC0, 0x07, 0x8E, 0x00, 0x38, 0x78, 0x03, + 0xC1, 0xE0, 0x3C, 0x07, 0x01, 0xC0, 0x3C, 0x1E, 0x00, 0xF1, 0xE0, 0x03, + 0x8E, 0x00, 0x1E, 0xF0, 0x00, 0x7F, 0x00, 0x01, 0xF0, 0x00, 0x0F, 0x80, + 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, + 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, + 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0x00, + 0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x07, 0x00, 0x00, 0x1F, 0xF0, 0x00, + 0x7F, 0xFF, 0x00, 0x7F, 0xFF, 0xC0, 0x7E, 0x73, 0xF0, 0x78, 0x38, 0x3C, + 0x78, 0x1C, 0x0F, 0x38, 0x0E, 0x03, 0xB8, 0x07, 0x00, 0xFC, 0x03, 0x80, + 0x7E, 0x01, 0xC0, 0x3F, 0x00, 0xE0, 0x1F, 0x80, 0x70, 0x0F, 0xC0, 0x38, + 0x07, 0x70, 0x1C, 0x07, 0x3C, 0x0E, 0x07, 0x8F, 0x07, 0x07, 0x83, 0xF3, + 0x9F, 0x80, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0x80, 0x03, 0xFE, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x78, 0x00, 0x78, + 0xF0, 0x03, 0xC1, 0xC0, 0x0E, 0x07, 0x80, 0x78, 0x0F, 0x03, 0xC0, 0x1C, + 0x0E, 0x00, 0x78, 0x78, 0x00, 0xF3, 0xC0, 0x01, 0xCE, 0x00, 0x07, 0xF8, + 0x00, 0x0F, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x03, 0xF0, 0x00, + 0x0F, 0xC0, 0x00, 0x7F, 0x80, 0x03, 0xCF, 0x00, 0x0E, 0x1C, 0x00, 0x78, + 0x78, 0x03, 0xC0, 0xF0, 0x0E, 0x01, 0xC0, 0x78, 0x07, 0x83, 0xC0, 0x0F, + 0x0E, 0x00, 0x1C, 0x78, 0x00, 0x7B, 0xC0, 0x00, 0xF0, 0xE0, 0x1C, 0x03, + 0xF0, 0x0E, 0x01, 0xF8, 0x07, 0x00, 0xFC, 0x03, 0x80, 0x7E, 0x01, 0xC0, + 0x3F, 0x00, 0xE0, 0x1F, 0x80, 0x70, 0x0F, 0xC0, 0x38, 0x07, 0xE0, 0x1C, + 0x03, 0xF0, 0x0E, 0x01, 0xF8, 0x07, 0x00, 0xFE, 0x03, 0x80, 0xE7, 0x01, + 0xC0, 0x73, 0x80, 0xE0, 0x38, 0xE0, 0x70, 0x38, 0x78, 0x38, 0x3C, 0x1E, + 0x1C, 0x3C, 0x07, 0xCE, 0x7C, 0x01, 0xFF, 0xFC, 0x00, 0x7F, 0xFC, 0x00, + 0x0F, 0xF8, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x38, 0x00, + 0x00, 0x1C, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x03, 0xFF, + 0xC0, 0x0F, 0xFF, 0xF0, 0x1F, 0x81, 0xF8, 0x3E, 0x00, 0x7C, 0x3C, 0x00, + 0x1C, 0x78, 0x00, 0x1E, 0x70, 0x00, 0x0E, 0xF0, 0x00, 0x0F, 0xE0, 0x00, + 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, + 0x07, 0xE0, 0x00, 0x07, 0xE0, 0x00, 0x07, 0x70, 0x00, 0x0E, 0x70, 0x00, + 0x0E, 0x78, 0x00, 0x1E, 0x38, 0x00, 0x1C, 0x1C, 0x00, 0x38, 0x0E, 0x00, + 0x70, 0x07, 0x00, 0xE0, 0xFF, 0x81, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0x81, + 0xFF, 0xF1, 0xFE, 0x3F, 0xC7, 0xF8, 0xF0, 0x00, 0x00, 0x03, 0x80, 0x70, + 0x0E, 0x01, 0xC0, 0x38, 0x07, 0x00, 0xE0, 0x1C, 0x03, 0x80, 0x70, 0x0E, + 0x01, 0xC0, 0x38, 0x07, 0x00, 0xE0, 0x1C, 0x03, 0x80, 0x70, 0x0E, 0x01, + 0xC0, 0x38, 0x07, 0x00, 0xE0, 0x1C, 0x03, 0x80, 0x70, 0x07, 0x8F, 0x00, + 0x3C, 0x78, 0x01, 0xE3, 0xC0, 0x0F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xC0, 0x01, 0xEF, 0x00, 0x1E, 0x38, 0x00, 0xE1, 0xE0, 0x0F, 0x07, + 0x80, 0xF0, 0x1C, 0x07, 0x00, 0xF0, 0x78, 0x03, 0xC7, 0x80, 0x0E, 0x38, + 0x00, 0x7B, 0xC0, 0x01, 0xFC, 0x00, 0x07, 0xC0, 0x00, 0x3E, 0x00, 0x00, + 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, + 0x00, 0x70, 0x00, 0x03, 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x00, 0x07, + 0x00, 0x00, 0x38, 0x00, 0x01, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, + 0x07, 0x80, 0x00, 0xE0, 0x00, 0x38, 0x00, 0x0E, 0x00, 0x03, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x38, 0x7F, 0xCF, 0x1F, + 0xFD, 0xC7, 0x87, 0xB8, 0xE0, 0x7F, 0x3C, 0x07, 0xC7, 0x00, 0xF8, 0xE0, + 0x1F, 0x1C, 0x03, 0xC3, 0x80, 0x38, 0x70, 0x07, 0x0E, 0x01, 0xE1, 0xC0, + 0x3C, 0x3C, 0x0F, 0xC3, 0x81, 0xF8, 0x78, 0x7F, 0x87, 0xFF, 0xFC, 0x7F, + 0xCF, 0x83, 0xF0, 0xF0, 0x00, 0x1C, 0x00, 0x70, 0x01, 0xC0, 0x07, 0x00, + 0x0C, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x7F, + 0xF1, 0xFF, 0xE7, 0x80, 0xCE, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0x3F, 0xE0, + 0x1F, 0xC0, 0x7F, 0x83, 0xC0, 0x0F, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x78, + 0x00, 0xF8, 0x06, 0xFF, 0xFC, 0xFF, 0xF8, 0x3F, 0xC0, 0x00, 0x0E, 0x00, + 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xE3, 0xF0, 0xEF, 0xFC, 0xFF, 0xFE, 0xFC, 0x1E, 0xF8, + 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, + 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x07, 0x07, 0x03, 0x83, 0x83, + 0x83, 0x80, 0x00, 0x00, 0x00, 0x70, 0x38, 0x1C, 0x0E, 0x07, 0x03, 0x81, + 0xC0, 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, 0x7F, 0xFF, 0x7F, 0xFF, 0x00, 0x7E, 0x00, 0xF8, 0x03, + 0xE0, 0x07, 0xC0, 0x0F, 0x80, 0x1E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x78, + 0x00, 0x70, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, + 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0x70, 0x00, 0x78, 0x00, 0x3E, + 0x00, 0x1F, 0xF8, 0x0F, 0xFE, 0x01, 0xFE, 0x00, 0x0F, 0x00, 0x07, 0x00, + 0x07, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1C, 0xE3, 0xF0, 0xEF, + 0xFC, 0xFF, 0xFE, 0xFC, 0x1E, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, + 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0x00, + 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, + 0x07, 0x03, 0xF0, 0x03, 0xFF, 0x01, 0xFF, 0xE0, 0xF8, 0x7C, 0x38, 0x07, + 0x1E, 0x01, 0xE7, 0x00, 0x39, 0xC0, 0x0E, 0xF0, 0x03, 0xF8, 0x00, 0x7E, + 0x00, 0x1F, 0x80, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, + 0x07, 0xE0, 0x01, 0xF8, 0x00, 0x7E, 0x00, 0x1D, 0xC0, 0x0E, 0x70, 0x03, + 0x9E, 0x01, 0xE3, 0x80, 0x70, 0xF8, 0x7C, 0x1F, 0xFE, 0x03, 0xFF, 0x00, + 0x3F, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, + 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0x7F, 0x3F, 0x1F, 0xE0, 0x3C, 0x70, + 0x3C, 0x38, 0x3C, 0x1C, 0x3C, 0x0E, 0x3C, 0x07, 0x3C, 0x03, 0xBC, 0x01, + 0xFE, 0x00, 0xFF, 0x80, 0x7F, 0xC0, 0x3C, 0xF0, 0x1C, 0x3C, 0x0E, 0x0F, + 0x07, 0x03, 0xC3, 0x80, 0xE1, 0xC0, 0x78, 0xE0, 0x1E, 0x70, 0x07, 0xB8, + 0x01, 0xE0, 0x1F, 0x00, 0x03, 0xF0, 0x00, 0x7F, 0x00, 0x01, 0xE0, 0x00, + 0x1E, 0x00, 0x01, 0xC0, 0x00, 0x38, 0x00, 0x07, 0x80, 0x00, 0x70, 0x00, + 0x1E, 0x00, 0x03, 0xE0, 0x00, 0xFC, 0x00, 0x1F, 0xC0, 0x07, 0xB8, 0x00, + 0xE7, 0x00, 0x3C, 0xF0, 0x07, 0x0E, 0x00, 0xE1, 0xC0, 0x38, 0x1C, 0x07, + 0x03, 0x81, 0xC0, 0x78, 0x38, 0x07, 0x0E, 0x00, 0xE1, 0xC0, 0x1E, 0x78, + 0x01, 0xCE, 0x00, 0x3B, 0xC0, 0x03, 0x80, 0xE0, 0x07, 0x38, 0x01, 0xCE, + 0x00, 0x73, 0x80, 0x1C, 0xE0, 0x07, 0x38, 0x01, 0xCE, 0x00, 0x73, 0x80, + 0x1C, 0xE0, 0x07, 0x38, 0x01, 0xCE, 0x00, 0x73, 0x80, 0x1C, 0xE0, 0x07, + 0x38, 0x01, 0xCF, 0x00, 0xF3, 0xE0, 0xFC, 0xFF, 0xFF, 0xFB, 0xFC, 0xFE, + 0x7E, 0x3B, 0x80, 0x00, 0xE0, 0x00, 0x38, 0x00, 0x0E, 0x00, 0x03, 0x80, + 0x00, 0xE0, 0x00, 0x38, 0x00, 0x00, 0xE0, 0x0E, 0x78,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 0x0F, + 0xCE, 0x01, 0xF3, 0x80, 0x7C, 0x03, 0xF8, 0x03, 0xFF, 0x81, 0xFF, 0xF0, + 0xF0, 0x3C, 0x78, 0x07, 0x9C, 0x00, 0xEE, 0x00, 0x3F, 0x80, 0x07, 0xE0, + 0x01, 0xF8, 0x00, 0x7E, 0x00, 0x1F, 0x80, 0x07, 0xE0, 0x03, 0xFC, 0x00, + 0xEF, 0x80, 0x7B, 0xF0, 0x3C, 0xEF, 0xFF, 0x39, 0xFF, 0x0E, 0x3F, 0x03, + 0x80, 0x00, 0xE0, 0x00, 0x38, 0x00, 0x0E, 0x00, 0x03, 0x80, 0x00, 0xE0, + 0x00, 0x38, 0x00, 0x00, 0x03, 0xF8, 0x1F, 0xFC, 0x7F, 0xF9, 0xF0, 0x37, + 0x80, 0x0E, 0x00, 0x3C, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, + 0x07, 0x00, 0x0F, 0x00, 0x0E, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x1F, 0xF0, + 0x1F, 0xF8, 0x0F, 0xF0, 0x00, 0xF0, 0x00, 0xE0, 0x01, 0xC0, 0x07, 0x80, + 0x1E, 0x00, 0x3C, 0x00, 0x70, 0x07, 0xFF, 0xF1, 0xFF, 0xFF, 0x3F, 0xFF, + 0xF7, 0xC0, 0xF0, 0x78, 0x07, 0x87, 0x00, 0x38, 0xE0, 0x03, 0xCE, 0x00, + 0x1C, 0xE0, 0x01, 0xCE, 0x00, 0x1C, 0xE0, 0x01, 0xCE, 0x00, 0x1C, 0xF0, + 0x03, 0xC7, 0x00, 0x38, 0x78, 0x07, 0x83, 0xC0, 0xF0, 0x3F, 0xFE, 0x00, + 0xFF, 0xC0, 0x03, 0xF0, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, + 0x38, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, + 0x00, 0xE0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x00, 0x00, 0x00, 0x07, 0x00, 0x07, + 0x07, 0x00, 0x01, 0xC3, 0x80, 0x00, 0xE3, 0x80, 0x00, 0x39, 0xC0, 0x00, + 0x1C, 0xE0, 0x00, 0x0E, 0xE0, 0x00, 0x03, 0xF0, 0x00, 0x01, 0xF8, 0x07, + 0x00, 0xFC, 0x03, 0x80, 0x7E, 0x01, 0xC0, 0x3F, 0x00, 0xE0, 0x1F, 0x80, + 0x70, 0x0F, 0xE0, 0x7C, 0x0F, 0x70, 0x36, 0x07, 0x3C, 0x3B, 0x87, 0x8F, + 0xFD, 0xFF, 0x83, 0xFC, 0x7F, 0x80, 0xFC, 0x1F, 0x80, +}; + +const GFXglyph FreeSans18pt_Win1253Glyphs[] PROGMEM = { +/* 0x01 */ { 0, 33, 36, 45, 6, -29 }, +/* 0x02 */ { 149, 33, 36, 45, 6, -29 }, +/* 0x03 */ { 298, 35, 36, 45, 5, -29 }, +/* 0x04 */ { 456, 42, 36, 45, 1, -29 }, +/* 0x05 */ { 645, 35, 36, 45, 5, -29 }, +/* 0x06 */ { 803, 35, 36, 45, 5, -29 }, +/* 0x07 */ { 961, 0, 0, 0, 0, 0 }, +/* 0x08 */ { 961, 37, 36, 45, 4, -29 }, +/* 0x09 */ { 1128, 40, 28, 45, 2, -25 }, +/* 0x0A */ { 1268, 0, 0, 0, 0, 0 }, +/* 0x0B */ { 1268, 39, 36, 45, 3, -29 }, +/* 0x0C */ { 1444, 35, 36, 45, 5, -29 }, +/* 0x0D */ { 1602, 0, 0, 0, 0, 0 }, +/* 0x0E */ { 1602, 35, 36, 45, 5, -29 }, +/* 0x0F */ { 1760, 35, 37, 45, 5, -29 }, +/* 0x10 */ { 1922, 34, 36, 45, 5, -29 }, +/* 0x11 */ { 2075, 35, 36, 45, 5, -29 }, +/* 0x12 */ { 2233, 34, 36, 45, 5, -29 }, +/* 0x13 */ { 2386, 35, 36, 45, 5, -29 }, +/* 0x14 */ { 2544, 35, 36, 45, 5, -29 }, +/* 0x15 */ { 2702, 38, 36, 45, 4, -29 }, +/* 0x16 */ { 2873, 28, 36, 45, 8, -29 }, +/* 0x17 */ { 2999, 37, 30, 45, 4, -26 }, +/* 0x18 */ { 3138, 42, 30, 45, 1, -26 }, +/* 0x19 */ { 3296, 35, 36, 45, 5, -29 }, +/* 0x1A */ { 3454, 0, 0, 0, 0, 0 }, +/* 0x1B */ { 3454, 42, 37, 45, 1, -29 }, +/* 0x1C */ { 3649, 35, 36, 45, 5, -29 }, +/* 0x1D */ { 3807, 36, 36, 45, 4, -28 }, +/* 0x1E */ { 3969, 35, 36, 45, 4, -29 }, +/* 0x1F */ { 4127, 25, 36, 45, 10, -29 }, +/* 0x20 */ { 4240, 1, 1, 11, 0, 0 }, +/* 0x21 */ { 4241, 3, 26, 14, 5, -25 }, +/* 0x22 */ { 4251, 10, 9, 16, 3, -25 }, +/* 0x23 */ { 4263, 24, 25, 29, 3, -24 }, +/* 0x24 */ { 4338, 17, 32, 22, 3, -26 }, +/* 0x25 */ { 4406, 29, 26, 33, 2, -25 }, +/* 0x26 */ { 4501, 24, 26, 27, 2, -25 }, +/* 0x27 */ { 4579, 3, 9, 10, 3, -25 }, +/* 0x28 */ { 4583, 8, 31, 14, 3, -26 }, +/* 0x29 */ { 4614, 8, 31, 14, 3, -26 }, +/* 0x2A */ { 4645, 16, 16, 18, 1, -25 }, +/* 0x2B */ { 4677, 23, 23, 29, 4, -22 }, +/* 0x2C */ { 4744, 4, 8, 11, 3, -3 }, +/* 0x2D */ { 4748, 9, 3, 13, 2, -10 }, +/* 0x2E */ { 4752, 3, 4, 11, 4, -3 }, +/* 0x2F */ { 4754, 12, 29, 12, 0, -25 }, +/* 0x30 */ { 4798, 18, 26, 22, 2, -25 }, +/* 0x31 */ { 4857, 15, 26, 22, 4, -25 }, +/* 0x32 */ { 4906, 16, 26, 22, 3, -25 }, +/* 0x33 */ { 4958, 17, 26, 22, 3, -25 }, +/* 0x34 */ { 5014, 19, 26, 22, 2, -25 }, +/* 0x35 */ { 5076, 17, 26, 22, 3, -25 }, +/* 0x36 */ { 5132, 18, 26, 22, 2, -25 }, +/* 0x37 */ { 5191, 16, 26, 22, 3, -25 }, +/* 0x38 */ { 5243, 18, 26, 22, 2, -25 }, +/* 0x39 */ { 5302, 18, 26, 22, 2, -25 }, +/* 0x3A */ { 5361, 3, 18, 12, 4, -17 }, +/* 0x3B */ { 5368, 4, 22, 12, 3, -17 }, +/* 0x3C */ { 5379, 22, 19, 29, 4, -19 }, +/* 0x3D */ { 5432, 22, 10, 29, 4, -15 }, +/* 0x3E */ { 5460, 22, 19, 29, 4, -19 }, +/* 0x3F */ { 5513, 14, 26, 19, 3, -25 }, +/* 0x40 */ { 5559, 31, 31, 35, 2, -24 }, +/* 0x41 */ { 5680, 23, 26, 24, 0, -25 }, +/* 0x42 */ { 5755, 18, 26, 24, 3, -25 }, +/* 0x43 */ { 5814, 21, 26, 24, 2, -25 }, +/* 0x44 */ { 5883, 21, 26, 27, 3, -25 }, +/* 0x45 */ { 5952, 16, 26, 22, 3, -25 }, +/* 0x46 */ { 6004, 15, 26, 20, 3, -25 }, +/* 0x47 */ { 6053, 22, 26, 27, 2, -25 }, +/* 0x48 */ { 6125, 19, 26, 26, 3, -25 }, +/* 0x49 */ { 6187, 3, 26, 10, 3, -25 }, +/* 0x4A */ { 6197, 8, 33, 10, -2, -25 }, +/* 0x4B */ { 6230, 20, 26, 23, 3, -25 }, +/* 0x4C */ { 6295, 16, 26, 20, 3, -25 }, +/* 0x4D */ { 6347, 23, 26, 30, 3, -25 }, +/* 0x4E */ { 6422, 19, 26, 26, 3, -25 }, +/* 0x4F */ { 6484, 24, 26, 28, 2, -25 }, +/* 0x50 */ { 6562, 16, 26, 21, 3, -25 }, +/* 0x51 */ { 6614, 24, 31, 28, 2, -25 }, +/* 0x52 */ { 6707, 19, 26, 24, 3, -25 }, +/* 0x53 */ { 6769, 18, 26, 22, 2, -25 }, +/* 0x54 */ { 6828, 21, 26, 21, 0, -25 }, +/* 0x55 */ { 6897, 19, 26, 26, 3, -25 }, +/* 0x56 */ { 6959, 23, 26, 24, 0, -25 }, +/* 0x57 */ { 7034, 32, 26, 35, 1, -25 }, +/* 0x58 */ { 7138, 22, 26, 24, 1, -25 }, +/* 0x59 */ { 7210, 21, 26, 21, 0, -25 }, +/* 0x5A */ { 7279, 21, 26, 24, 2, -25 }, +/* 0x5B */ { 7348, 7, 31, 14, 3, -26 }, +/* 0x5C */ { 7376, 12, 29, 12, 0, -25 }, +/* 0x5D */ { 7420, 7, 31, 14, 3, -26 }, +/* 0x5E */ { 7448, 22, 10, 29, 4, -25 }, +/* 0x5F */ { 7476, 18, 3, 18, 0, 6 }, +/* 0x60 */ { 7483, 8, 6, 18, 3, -27 }, +/* 0x61 */ { 7489, 16, 19, 21, 2, -18 }, +/* 0x62 */ { 7527, 17, 27, 22, 3, -26 }, +/* 0x63 */ { 7585, 15, 19, 19, 2, -18 }, +/* 0x64 */ { 7621, 17, 27, 22, 2, -26 }, +/* 0x65 */ { 7679, 18, 19, 22, 2, -18 }, +/* 0x66 */ { 7722, 12, 27, 12, 1, -26 }, +/* 0x67 */ { 7763, 17, 26, 22, 2, -18 }, +/* 0x68 */ { 7819, 16, 27, 22, 3, -26 }, +/* 0x69 */ { 7873, 3, 27, 10, 3, -26 }, +/* 0x6A */ { 7884, 7, 34, 10, -1, -26 }, +/* 0x6B */ { 7914, 17, 27, 20, 3, -26 }, +/* 0x6C */ { 7972, 3, 27, 10, 3, -26 }, +/* 0x6D */ { 7983, 29, 19, 34, 3, -18 }, +/* 0x6E */ { 8052, 16, 19, 22, 3, -18 }, +/* 0x6F */ { 8090, 18, 19, 21, 2, -18 }, +/* 0x70 */ { 8133, 17, 26, 22, 3, -18 }, +/* 0x71 */ { 8189, 17, 26, 22, 2, -18 }, +/* 0x72 */ { 8245, 11, 19, 14, 3, -18 }, +/* 0x73 */ { 8272, 15, 19, 18, 2, -18 }, +/* 0x74 */ { 8308, 11, 24, 14, 1, -23 }, +/* 0x75 */ { 8341, 16, 19, 22, 3, -18 }, +/* 0x76 */ { 8379, 19, 19, 21, 1, -18 }, +/* 0x77 */ { 8425, 26, 19, 29, 1, -18 }, +/* 0x78 */ { 8487, 19, 19, 21, 1, -18 }, +/* 0x79 */ { 8533, 19, 26, 21, 1, -18 }, +/* 0x7A */ { 8595, 15, 19, 18, 2, -18 }, +/* 0x7B */ { 8631, 13, 32, 22, 5, -26 }, +/* 0x7C */ { 8683, 3, 35, 12, 4, -26 }, +/* 0x7D */ { 8697, 13, 32, 22, 4, -26 }, +/* 0x7E */ { 8749, 22, 6, 29, 4, -13 }, +/* 0x7F */ { 8766, 0, 0, 0, 0, 0 }, +/* 0x80 */ { 8766, 20, 26, 22, 0, -25 }, +/* 0x81 */ { 8831, 0, 0, 0, 0, 0 }, +/* 0x82 */ { 8831, 4, 8, 11, 3, -3 }, +/* 0x83 */ { 8835, 15, 34, 12, -2, -26 }, +/* 0x84 */ { 8899, 10, 8, 18, 3, -3 }, +/* 0x85 */ { 8909, 27, 4, 35, 4, -3 }, +/* 0x86 */ { 8923, 15, 29, 18, 1, -25 }, +/* 0x87 */ { 8978, 15, 29, 18, 1, -25 }, +/* 0x88 */ { 9033, 0, 0, 0, 0, 0 }, +/* 0x89 */ { 9033, 43, 26, 47, 2, -25 }, +/* 0x8A */ { 9173, 0, 0, 0, 0, 0 }, +/* 0x8B */ { 9173, 8, 16, 14, 3, -17 }, +/* 0x8C */ { 9189, 0, 0, 0, 0, 0 }, +/* 0x8D */ { 9189, 0, 0, 0, 0, 0 }, +/* 0x8E */ { 9189, 0, 0, 0, 0, 0 }, +/* 0x8F */ { 9189, 0, 0, 0, 0, 0 }, +/* 0x90 */ { 9189, 0, 0, 0, 0, 0 }, +/* 0x91 */ { 9189, 4, 8, 11, 3, -25 }, +/* 0x92 */ { 9193, 4, 8, 11, 3, -25 }, +/* 0x93 */ { 9197, 10, 8, 18, 3, -25 }, +/* 0x94 */ { 9207, 10, 8, 18, 3, -25 }, +/* 0x95 */ { 9217, 10, 10, 21, 5, -17 }, +/* 0x96 */ { 9230, 14, 3, 18, 2, -10 }, +/* 0x97 */ { 9236, 32, 3, 35, 2, -10 }, +/* 0x98 */ { 9248, 0, 0, 0, 0, 0 }, +/* 0x99 */ { 9248, 22, 10, 35, 5, -25 }, +/* 0x9A */ { 9276, 0, 0, 0, 0, 0 }, +/* 0x9B */ { 9276, 8, 16, 14, 3, -17 }, +/* 0x9C */ { 9292, 0, 0, 0, 0, 0 }, +/* 0x9D */ { 9292, 0, 0, 0, 0, 0 }, +/* 0x9E */ { 9292, 0, 0, 0, 0, 0 }, +/* 0x9F */ { 9292, 0, 0, 0, 0, 0 }, +/* 0xA0 */ { 9292, 1, 1, 11, 0, 0 }, +/* 0xA1 */ { 9293, 11, 11, 18, 4, -33 }, +/* 0xA2 */ { 9309, 23, 28, 24, 0, -27 }, +/* 0xA3 */ { 9390, 17, 26, 22, 2, -25 }, +/* 0xA4 */ { 9446, 19, 19, 22, 2, -19 }, +/* 0xA5 */ { 9492, 19, 26, 22, 1, -25 }, +/* 0xA6 */ { 9554, 3, 31, 12, 4, -24 }, +/* 0xA7 */ { 9566, 14, 29, 18, 2, -25 }, +/* 0xA8 */ { 9617, 11, 4, 18, 4, -26 }, +/* 0xA9 */ { 9623, 25, 25, 35, 5, -24 }, +/* 0xAA */ { 9702, 0, 0, 0, 0, 0 }, +/* 0xAB */ { 9702, 15, 16, 21, 3, -17 }, +/* 0xAC */ { 9732, 22, 10, 29, 4, -14 }, +/* 0xAD */ { 9760, 9, 3, 13, 2, -10 }, +/* 0xAE */ { 9764, 25, 25, 35, 5, -24 }, +/* 0xAF */ { 9843, 35, 3, 35, 0, -10 }, +/* 0xB0 */ { 9857, 11, 11, 18, 3, -25 }, +/* 0xB1 */ { 9873, 23, 22, 29, 3, -21 }, +/* 0xB2 */ { 9937, 10, 14, 14, 2, -25 }, +/* 0xB3 */ { 9955, 11, 14, 14, 2, -25 }, +/* 0xB4 */ { 9975, 8, 6, 18, 7, -27 }, +/* 0xB5 */ { 9981, 11, 11, 18, 4, -33 }, +/* 0xB6 */ { 9997, 23, 28, 24, 0, -27 }, +/* 0xB7 */ { 10078, 3, 4, 11, 4, -13 }, +/* 0xB8 */ { 10080, 23, 28, 26, 0, -27 }, +/* 0xB9 */ { 10161, 26, 28, 30, 0, -27 }, +/* 0xBA */ { 10252, 10, 28, 14, 0, -27 }, +/* 0xBB */ { 10287, 15, 16, 21, 3, -17 }, +/* 0xBC */ { 10317, 27, 28, 28, 0, -27 }, +/* 0xBD */ { 10412, 29, 26, 34, 3, -25 }, +/* 0xBE */ { 10507, 28, 28, 29, 0, -27 }, +/* 0xBF */ { 10605, 27, 28, 29, 0, -27 }, +/* 0xC0 */ { 10700, 11, 34, 12, 0, -33 }, +/* 0xC1 */ { 10747, 23, 26, 24, 0, -25 }, +/* 0xC2 */ { 10822, 18, 26, 24, 3, -25 }, +/* 0xC3 */ { 10881, 15, 26, 19, 3, -25 }, +/* 0xC4 */ { 10930, 23, 26, 24, 0, -25 }, +/* 0xC5 */ { 11005, 16, 26, 22, 3, -25 }, +/* 0xC6 */ { 11057, 21, 26, 24, 2, -25 }, +/* 0xC7 */ { 11126, 19, 26, 26, 3, -25 }, +/* 0xC8 */ { 11188, 24, 26, 28, 2, -25 }, +/* 0xC9 */ { 11266, 3, 26, 10, 3, -25 }, +/* 0xCA */ { 11276, 20, 26, 23, 3, -25 }, +/* 0xCB */ { 11341, 23, 26, 24, 0, -25 }, +/* 0xCC */ { 11416, 23, 26, 30, 3, -25 }, +/* 0xCD */ { 11491, 19, 26, 26, 3, -25 }, +/* 0xCE */ { 11553, 16, 26, 22, 3, -25 }, +/* 0xCF */ { 11605, 24, 26, 28, 2, -25 }, +/* 0xD0 */ { 11683, 19, 26, 25, 3, -25 }, +/* 0xD1 */ { 11745, 16, 26, 21, 3, -25 }, +/* 0xD2 */ { 11797, 0, 0, 0, 0, 0 }, +/* 0xD3 */ { 11797, 16, 26, 22, 3, -25 }, +/* 0xD4 */ { 11849, 21, 26, 21, 0, -25 }, +/* 0xD5 */ { 11918, 21, 26, 21, 0, -25 }, +/* 0xD6 */ { 11987, 25, 26, 29, 2, -25 }, +/* 0xD7 */ { 12069, 22, 26, 24, 1, -25 }, +/* 0xD8 */ { 12141, 25, 26, 29, 2, -25 }, +/* 0xD9 */ { 12223, 24, 26, 28, 2, -25 }, +/* 0xDA */ { 12301, 11, 32, 10, -1, -31 }, +/* 0xDB */ { 12345, 21, 32, 21, 0, -31 }, +/* 0xDC */ { 12429, 19, 28, 23, 2, -27 }, +/* 0xDD */ { 12496, 15, 28, 19, 2, -27 }, +/* 0xDE */ { 12549, 16, 35, 22, 3, -27 }, +/* 0xDF */ { 12619, 9, 28, 12, 3, -27 }, +/* 0xE0 */ { 12651, 16, 35, 21, 3, -33 }, +/* 0xE1 */ { 12721, 19, 19, 23, 2, -18 }, +/* 0xE2 */ { 12767, 17, 34, 22, 3, -26 }, +/* 0xE3 */ { 12840, 19, 26, 21, 1, -18 }, +/* 0xE4 */ { 12902, 18, 26, 22, 2, -25 }, +/* 0xE5 */ { 12961, 15, 19, 19, 2, -18 }, +/* 0xE6 */ { 12997, 16, 34, 20, 2, -26 }, +/* 0xE7 */ { 13065, 16, 26, 22, 3, -18 }, +/* 0xE8 */ { 13117, 18, 27, 22, 2, -26 }, +/* 0xE9 */ { 13178, 8, 19, 12, 3, -18 }, +/* 0xEA */ { 13197, 17, 19, 21, 3, -18 }, +/* 0xEB */ { 13238, 19, 27, 21, 1, -26 }, +/* 0xEC */ { 13303, 18, 26, 22, 3, -18 }, +/* 0xED */ { 13362, 17, 19, 20, 1, -18 }, +/* 0xEE */ { 13403, 15, 34, 19, 2, -26 }, +/* 0xEF */ { 13467, 18, 19, 21, 2, -18 }, +/* 0xF0 */ { 13510, 18, 19, 21, 2, -18 }, +/* 0xF1 */ { 13553, 18, 26, 23, 3, -18 }, +/* 0xF2 */ { 13612, 15, 26, 20, 2, -18 }, +/* 0xF3 */ { 13661, 20, 19, 23, 2, -18 }, +/* 0xF4 */ { 13709, 17, 19, 21, 2, -18 }, +/* 0xF5 */ { 13750, 16, 19, 21, 3, -17 }, +/* 0xF6 */ { 13788, 19, 26, 23, 2, -18 }, +/* 0xF7 */ { 13850, 18, 26, 20, 1, -18 }, +/* 0xF8 */ { 13909, 19, 26, 23, 2, -18 }, +/* 0xF9 */ { 13971, 25, 19, 29, 2, -17 }, +/* 0xFA */ { 14031, 11, 27, 12, 0, -26 }, +/* 0xFB */ { 14069, 16, 28, 21, 3, -26 }, +/* 0xFC */ { 14125, 18, 28, 21, 2, -27 }, +/* 0xFD */ { 14188, 16, 29, 21, 3, -27 }, +/* 0xFE */ { 14246, 25, 29, 29, 2, -27 }, +/* 0xFF */ { 14337, 0, 0, 0, 0, 0 }, +}; + +const GFXfont FreeSans18pt_Win1253 PROGMEM = { +(uint8_t*)FreeSans18pt_Win1253Bitmaps, +(GFXglyph*)FreeSans18pt_Win1253Glyphs, +0x01, 0xFF, 41 +}; diff --git a/src/graphics/niche/Fonts/FreeSans24pt_Win1253.h b/src/graphics/niche/Fonts/FreeSans24pt_Win1253.h new file mode 100644 index 000000000..7efefd443 --- /dev/null +++ b/src/graphics/niche/Fonts/FreeSans24pt_Win1253.h @@ -0,0 +1,2429 @@ +// trunk-ignore-all(clang-format) +#pragma once +/* PROPERTIES + +FONT_NAME FreeSans24pt_Win1253 +*/ +const uint8_t FreeSans24pt_Win1253Bitmaps[] PROGMEM = { + 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x0C, 0xE0, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, + 0x60, 0xC0, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x01, 0x83, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x00, + 0x00, 0x00, 0x00, 0xC1, 0x80, 0x00, 0x00, 0x00, 0x18, 0x30, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x01, 0xC0, 0xC0, 0x00, 0x00, 0x00, + 0x70, 0x30, 0x00, 0x00, 0x00, 0x1C, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, + 0xC0, 0x00, 0x00, 0x03, 0x80, 0x13, 0xFF, 0x00, 0x00, 0xE0, 0x07, 0xFF, + 0xF0, 0x00, 0x70, 0x00, 0xF0, 0x06, 0x00, 0x0C, 0x00, 0x38, 0x00, 0xC0, + 0x03, 0x00, 0x06, 0x00, 0x18, 0x00, 0x60, 0x00, 0xC0, 0x03, 0x01, 0xFC, + 0x00, 0x18, 0x00, 0x67, 0xFF, 0x00, 0x03, 0x80, 0x38, 0xC0, 0x00, 0x00, + 0x3F, 0xFF, 0xD8, 0x00, 0x00, 0x07, 0xFE, 0x1F, 0x00, 0x00, 0x01, 0xE0, + 0x01, 0xE0, 0x00, 0x00, 0x3C, 0x00, 0x1C, 0x00, 0x00, 0x0F, 0x00, 0x03, + 0x80, 0x00, 0x03, 0xA0, 0x00, 0xF0, 0x00, 0x00, 0xE6, 0x00, 0x1E, 0x00, + 0x00, 0x78, 0xF0, 0x1F, 0xC0, 0x00, 0x1C, 0x0F, 0xFF, 0xD8, 0x00, 0x02, + 0x01, 0xC0, 0x7B, 0x00, 0x00, 0x00, 0x60, 0x03, 0xE0, 0x00, 0x00, 0x0C, + 0x00, 0x3C, 0x00, 0x00, 0x01, 0x80, 0x07, 0x80, 0x00, 0x00, 0x30, 0x00, + 0xF0, 0x00, 0x00, 0x07, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x7F, 0x86, 0xFF, + 0x80, 0x00, 0x1F, 0xFF, 0x9F, 0xFE, 0x00, 0x03, 0x00, 0xC0, 0x01, 0xF0, + 0x00, 0xC0, 0x18, 0x00, 0x07, 0x00, 0x18, 0x03, 0x00, 0x00, 0x3C, 0x01, + 0x80, 0x60, 0x00, 0x03, 0xFC, 0x7E, 0x1C, 0x00, 0x00, 0x0F, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x01, 0x80, 0xF8, 0x00, + 0x00, 0x0F, 0xFF, 0xFF, 0x80, 0x00, 0x07, 0xE0, 0x78, 0x38, 0x00, 0x03, + 0xC0, 0x0C, 0x03, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x60, 0x00, 0xF8, 0x00, + 0x60, 0x0C, 0x3F, 0xFC, 0x00, 0x06, 0x03, 0xC7, 0xF8, 0x00, 0x00, 0xFF, + 0xFC, 0xC0, 0x00, 0x00, 0x0F, 0xE0, 0xD8, 0x00, 0x00, 0x03, 0x80, 0x0F, + 0x00, 0x00, 0x00, 0x60, 0x01, 0xE0, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, + 0x00, 0x01, 0x80, 0x07, 0x80, 0x00, 0x00, 0x30, 0x01, 0xB0, 0x00, 0x04, + 0x03, 0xFF, 0xF6, 0x00, 0x00, 0xE0, 0x7F, 0xFE, 0xC0, 0x00, 0x0F, 0x1C, + 0x01, 0xF8, 0x00, 0x00, 0x73, 0x00, 0x0F, 0x00, 0x00, 0x07, 0xC0, 0x01, + 0xE0, 0x00, 0x00, 0x78, 0x00, 0x1C, 0x00, 0x00, 0x07, 0x80, 0x07, 0x80, + 0x00, 0x00, 0xF8, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0xFF, 0x3F, 0xC0, 0x00, + 0x01, 0xFF, 0xFE, 0xFF, 0xE0, 0x00, 0x70, 0x03, 0x80, 0x7E, 0x00, 0x0C, + 0x00, 0x30, 0x00, 0xC0, 0x01, 0x80, 0x06, 0x00, 0x18, 0x00, 0x30, 0x00, + 0xC0, 0x01, 0x80, 0x07, 0x00, 0x18, 0x00, 0x18, 0x00, 0x78, 0x03, 0x00, + 0x01, 0xC0, 0x0F, 0xFF, 0xC0, 0x00, 0x1E, 0x00, 0x8F, 0xF0, 0x00, 0x00, + 0xE0, 0x18, 0x00, 0x00, 0x00, 0x0E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x60, + 0x60, 0x00, 0x00, 0x00, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, + 0x00, 0x00, 0x00, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x01, 0x83, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x00, 0x00, 0x00, + 0x00, 0xC1, 0x80, 0x00, 0x00, 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x03, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x61, 0x80, 0x00, 0x00, 0x00, 0x06, 0x70, + 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x00, 0xF8, 0x00, + 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, + 0x00, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, + 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x60, + 0x0E, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x70, 0x00, 0x00, 0x00, 0x00, 0x0C, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x03, 0xC0, 0x03, 0xC0, 0x06, + 0x60, 0x07, 0xE0, 0x07, 0xE0, 0x06, 0xC0, 0x0C, 0x30, 0x0C, 0x30, 0x03, + 0xC0, 0x18, 0x30, 0x0C, 0x38, 0x03, 0xC0, 0x18, 0x18, 0x18, 0x18, 0x03, + 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x0D, 0x00, 0x00, 0x4A, 0x03, + 0xC0, 0x69, 0x00, 0x00, 0xD2, 0x03, 0xC0, 0x4B, 0x00, 0x00, 0x96, 0x03, + 0xC0, 0xD2, 0x00, 0x01, 0xA4, 0x03, 0x60, 0x10, 0x00, 0x00, 0x20, 0x06, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0xC0, 0x03, 0x00, 0x0C, + 0x38, 0x01, 0xF0, 0x0F, 0x80, 0x1C, 0x18, 0x00, 0x7F, 0xFE, 0x00, 0x18, + 0x1C, 0x00, 0x0F, 0xF0, 0x00, 0x30, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x70, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, + 0x03, 0x80, 0x00, 0x00, 0x01, 0x80, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, + 0x00, 0x1F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, + 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFC, + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x1F, + 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x1E, 0x00, 0x00, + 0x00, 0x1C, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x1C, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x38, + 0x38, 0x00, 0x0C, 0x3C, 0x00, 0x00, 0x0F, 0x0C, 0x00, 0x0E, 0x38, 0x00, + 0x00, 0x01, 0xC7, 0x00, 0x06, 0x38, 0x00, 0x00, 0x00, 0x71, 0x80, 0x07, + 0x18, 0x00, 0x00, 0x00, 0x18, 0xE0, 0x03, 0x08, 0x00, 0x00, 0x00, 0x04, + 0x30, 0x01, 0x80, 0x3E, 0x00, 0x07, 0xC0, 0x18, 0x00, 0xC0, 0x71, 0xC0, + 0x0C, 0x38, 0x0C, 0x00, 0xC0, 0x60, 0x30, 0x0C, 0x06, 0x03, 0x00, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xC0, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1F, 0x60, 0x00, 0x00, + 0x00, 0x06, 0xF8, 0x3C, 0x30, 0x00, 0x00, 0x00, 0x03, 0x0E, 0x38, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x83, 0x98, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, + 0xD8, 0x0C, 0x60, 0x00, 0x00, 0x06, 0x30, 0x3C, 0x04, 0x6F, 0xC0, 0x00, + 0xFF, 0x98, 0x1E, 0x02, 0x30, 0x1F, 0xFF, 0xE0, 0xC4, 0x0F, 0x03, 0x1C, + 0x00, 0x00, 0x00, 0xE2, 0x07, 0x81, 0x07, 0xE0, 0x00, 0x07, 0xE1, 0x83, + 0x61, 0x83, 0xFF, 0xFF, 0xFF, 0xF0, 0x63, 0x1F, 0xC0, 0xFF, 0xFF, 0xFF, + 0xF0, 0x3F, 0x86, 0x30, 0x3F, 0xFF, 0xFF, 0xF0, 0x32, 0x00, 0x18, 0x0F, + 0xFF, 0xFF, 0xF0, 0x18, 0x00, 0x06, 0x03, 0xFC, 0x0F, 0xF0, 0x18, 0x00, + 0x03, 0x80, 0x78, 0x01, 0xE0, 0x1C, 0x00, 0x00, 0xE0, 0x0E, 0x01, 0xC0, + 0x1C, 0x00, 0x00, 0x30, 0x00, 0xFF, 0x00, 0x0C, 0x00, 0x00, 0x0E, 0x00, + 0x00, 0x00, 0x1C, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x1C, 0x00, 0x00, + 0x00, 0xE0, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, + 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x00, 0x01, 0xF8, + 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xE0, 0x00, 0x00, 0x00, + 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0C, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x03, 0x80, 0x00, 0x00, + 0x1F, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x7F, 0xC3, 0x00, 0x07, 0x80, 0x00, + 0xC7, 0x83, 0x00, 0x1F, 0x80, 0x03, 0x07, 0x03, 0x00, 0x63, 0x00, 0x06, + 0x07, 0x03, 0x01, 0xC6, 0x00, 0x06, 0x07, 0x03, 0x03, 0x0C, 0x00, 0x06, + 0x07, 0x03, 0x06, 0x18, 0x00, 0x0E, 0x07, 0x03, 0x0C, 0x30, 0x00, 0x7E, + 0x07, 0x03, 0x18, 0x60, 0x00, 0xC6, 0x07, 0x03, 0x30, 0xC0, 0x03, 0x06, + 0x07, 0x03, 0x61, 0x80, 0x06, 0x06, 0x07, 0x03, 0xC1, 0x80, 0x0E, 0x06, + 0x07, 0x03, 0x83, 0x00, 0x0E, 0x06, 0x07, 0x03, 0x06, 0x00, 0x0E, 0x06, + 0x06, 0x06, 0x06, 0x00, 0x3E, 0x06, 0x00, 0x18, 0x0C, 0x00, 0xFE, 0x06, + 0x00, 0x30, 0x18, 0x03, 0x8E, 0x06, 0x00, 0x40, 0x18, 0x06, 0x0E, 0x06, + 0x01, 0x80, 0x30, 0x0C, 0x0E, 0x00, 0x03, 0x00, 0x30, 0x1C, 0x0E, 0x00, + 0x06, 0x00, 0x60, 0x1C, 0x0E, 0x00, 0x0C, 0x00, 0x60, 0x1C, 0x0E, 0x00, + 0x18, 0x00, 0xC0, 0x1C, 0x08, 0x00, 0x30, 0x01, 0x80, 0x1C, 0x00, 0x00, + 0x30, 0x03, 0x0C, 0x1C, 0x00, 0x00, 0x60, 0x02, 0x0C, 0x1C, 0x00, 0x00, + 0x60, 0x0F, 0x0E, 0x1C, 0x00, 0x00, 0xC0, 0x1B, 0x0C, 0x1C, 0x00, 0x00, + 0x00, 0x36, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x67, 0x00, 0x1C, 0x00, 0x00, + 0x00, 0xC7, 0x80, 0x1C, 0x00, 0x00, 0x03, 0x07, 0x00, 0x1C, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1C, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x0C, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x0E, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x0F, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x07, 0x80, 0xF0, + 0x00, 0x00, 0x00, 0x03, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xB0, 0x00, 0x00, 0x01, 0x80, 0x06, 0x60, 0x00, 0x00, + 0x07, 0x80, 0x1C, 0xC0, 0x00, 0x00, 0x0F, 0xC0, 0x31, 0x80, 0x00, 0x00, + 0x19, 0xC0, 0xC3, 0x00, 0x00, 0x00, 0x11, 0xE1, 0x82, 0x00, 0x00, 0x00, + 0x30, 0xE6, 0x06, 0x00, 0x00, 0x00, 0x60, 0xFF, 0xCC, 0x00, 0x00, 0x00, + 0xC1, 0xFF, 0xF8, 0x3F, 0x80, 0x01, 0x8F, 0x80, 0xFF, 0xFF, 0x00, 0x01, + 0xBC, 0x00, 0x7E, 0x06, 0x00, 0x03, 0xE0, 0x00, 0x38, 0x18, 0x00, 0x07, + 0x80, 0x00, 0x38, 0x70, 0x00, 0x0E, 0x00, 0x00, 0x39, 0xC0, 0x01, 0xF8, + 0x00, 0x00, 0x33, 0x00, 0xFF, 0xF0, 0x00, 0x00, 0x7C, 0x03, 0xF0, 0xC0, + 0x00, 0x00, 0x78, 0x06, 0x03, 0x80, 0x00, 0x00, 0xE0, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0xC0, 0x0F, 0x0C, 0x00, 0x00, 0x01, 0xE0, 0x07, 0x18, 0x00, + 0x00, 0x03, 0xE0, 0x07, 0xB0, 0x00, 0x00, 0x06, 0xF0, 0x03, 0xE0, 0x00, + 0x00, 0x0C, 0x70, 0x01, 0xC0, 0x00, 0x00, 0x18, 0x78, 0x01, 0x80, 0x00, + 0x00, 0x30, 0x38, 0x03, 0x80, 0x00, 0x00, 0xC0, 0x30, 0x0F, 0x00, 0x00, + 0x01, 0x8F, 0xE0, 0x3F, 0x00, 0x00, 0x07, 0xFF, 0x00, 0x66, 0x00, 0x00, + 0x0F, 0xC0, 0x01, 0x8E, 0x00, 0x00, 0x38, 0x00, 0x07, 0x0E, 0x00, 0x00, + 0xF0, 0x00, 0x0C, 0x0E, 0x00, 0x03, 0xE0, 0x00, 0x30, 0x3F, 0x00, 0x1E, + 0xC0, 0x00, 0x6F, 0xFF, 0x80, 0xF8, 0x80, 0x00, 0xFE, 0x0F, 0xFF, 0xC1, + 0x80, 0x00, 0xC0, 0x19, 0xFF, 0x83, 0x00, 0x00, 0x00, 0x30, 0x33, 0x86, + 0x00, 0x00, 0x00, 0x60, 0xE3, 0xCC, 0x00, 0x00, 0x00, 0x41, 0x81, 0xCC, + 0x00, 0x00, 0x00, 0xC6, 0x01, 0xF8, 0x00, 0x00, 0x01, 0x9C, 0x00, 0xF0, + 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x06, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1F, 0x00, + 0x00, 0x00, 0x00, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x70, + 0x00, 0x00, 0x00, 0xE0, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x01, 0x80, 0x00, 0x00, 0x30, 0x00, 0x00, + 0xC0, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x30, 0x00, 0x07, 0xFE, 0x00, 0x00, + 0x18, 0x00, 0x07, 0x83, 0xC0, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x60, 0x00, + 0x02, 0x00, 0x03, 0x00, 0x18, 0x00, 0x01, 0x00, 0x03, 0x80, 0x06, 0x00, + 0x01, 0x80, 0x01, 0x80, 0x03, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x01, 0x80, + 0x00, 0x70, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x3E, 0x0F, 0xF0, 0x00, 0x00, + 0x00, 0x01, 0xCF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9E, 0x00, 0x00, + 0x00, 0x00, 0x03, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0x00, 0x60, 0x00, 0x60, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x78, + 0x00, 0x78, 0x00, 0x78, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x3E, + 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x07, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x00, + 0x00, 0x70, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x00, + 0x00, 0x7C, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x00, + 0x00, 0x1E, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF8, + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x78, + 0x00, 0x70, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0xE0, 0x00, 0x00, 0x00, + 0x1C, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x80, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x0C, + 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x30, 0x00, 0x00, 0xFF, 0xE0, 0x00, + 0x00, 0xE0, 0x00, 0x07, 0x83, 0xC0, 0x00, 0x01, 0x80, 0x00, 0x38, 0x03, + 0x80, 0x00, 0x06, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x18, 0x00, 0x06, + 0x00, 0x0C, 0x00, 0x00, 0x60, 0x00, 0x38, 0x00, 0x38, 0x00, 0x01, 0x80, + 0x00, 0xC0, 0x00, 0x60, 0x00, 0x06, 0x00, 0x03, 0x00, 0x01, 0x80, 0x00, + 0x1C, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x03, 0xF0, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xB8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x19, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x81, 0x80, 0x00, 0x00, 0x00, 0x38, + 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x07, 0xF7, 0x00, 0x60, 0x00, + 0x7C, 0x00, 0x00, 0x0F, 0xFF, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x07, 0xF3, + 0xC0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x1F, 0xE0, 0x00, + 0x1F, 0xFE, 0x00, 0x07, 0xFF, 0x80, 0x07, 0xCF, 0xF8, 0x01, 0xF3, 0xBE, + 0x00, 0xFC, 0xD9, 0xC0, 0x38, 0x3C, 0xF0, 0x1F, 0xEC, 0xFE, 0x07, 0xE3, + 0x6F, 0x83, 0xB7, 0xC7, 0xB0, 0xDF, 0x33, 0xD8, 0x33, 0x1C, 0x39, 0x99, + 0xBB, 0x1C, 0xC7, 0xF0, 0xC1, 0xD9, 0xD9, 0xF0, 0xCE, 0x6F, 0x0E, 0x1E, + 0xFF, 0x8F, 0x0E, 0x66, 0x70, 0xF1, 0xB6, 0x78, 0x30, 0xF6, 0xC3, 0x8D, + 0x99, 0xE1, 0x83, 0x8D, 0xBC, 0x3C, 0xCD, 0x8E, 0x1C, 0x3C, 0xCF, 0xE3, + 0x6C, 0x78, 0x61, 0xE3, 0x6C, 0x7F, 0x33, 0xC3, 0x87, 0x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8E, 0x1C, + 0x00, 0x00, 0x00, 0x00, 0x0C, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, + 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x00, 0x01, + 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x07, + 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x1F, + 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x80, 0x00, 0x01, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x3F, 0xFF, + 0xFF, 0xFC, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xF8, 0x00, 0x01, 0xFF, 0xFF, + 0xFF, 0xF8, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xFF, + 0xFF, 0xF8, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x3F, 0xE3, 0xFF, + 0x1F, 0xF0, 0x00, 0x7F, 0x03, 0xF8, 0x0F, 0xE0, 0x00, 0xFC, 0x03, 0xE0, + 0x0F, 0xE0, 0x07, 0xF0, 0xC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, 0x00, 0x00, 0x00, 0x06, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x03, + 0xC0, 0x3C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x60, + 0x00, 0x0E, 0x00, 0x00, 0x01, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x06, 0x04, + 0x00, 0x0C, 0x00, 0x00, 0x08, 0x38, 0x00, 0x0C, 0x00, 0x00, 0x30, 0xE0, + 0x00, 0x08, 0x00, 0x00, 0x43, 0x00, 0x00, 0x18, 0x00, 0x01, 0x86, 0x00, + 0x00, 0x10, 0x00, 0x03, 0x18, 0x00, 0x00, 0x30, 0x00, 0x04, 0x30, 0x00, + 0x00, 0x60, 0x00, 0x18, 0x40, 0x00, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x60, 0x00, 0x00, 0x01, 0x00, 0x00, 0xC0, 0x00, 0x00, + 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x80, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x3F, 0xFF, 0xFE, 0x00, + 0x80, 0x07, 0xE0, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x60, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x03, + 0x86, 0x00, 0x00, 0x00, 0x00, 0x03, 0x18, 0x00, 0xFF, 0xFF, 0xF0, 0x03, + 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFB, + 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x1F, 0xFF, 0xFB, + 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xF3, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0x81, + 0xFF, 0xFF, 0x87, 0xFF, 0xFC, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, + 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x0E, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x03, + 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x0E, 0x08, 0x00, 0x00, 0x30, 0x70, 0x1C, + 0x3C, 0x00, 0x00, 0x3C, 0x38, 0x18, 0xE0, 0x00, 0x00, 0x0F, 0x18, 0x39, + 0xC0, 0x00, 0x00, 0x03, 0x9C, 0x33, 0x80, 0x00, 0x00, 0x01, 0xCC, 0x73, + 0x00, 0x00, 0x00, 0x00, 0xCC, 0x60, 0x1F, 0x00, 0x00, 0xF8, 0x06, 0x60, + 0x7F, 0xC0, 0x03, 0xFE, 0x06, 0x60, 0xF3, 0xE0, 0x07, 0x8F, 0x06, 0xC0, + 0xF3, 0xA0, 0x07, 0x8F, 0x03, 0xC0, 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, + 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, + 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, + 0x33, 0x80, 0x03, 0x8C, 0x03, 0xC0, 0x33, 0xBF, 0xFB, 0x8C, 0x03, 0xC0, + 0x33, 0xFC, 0x7F, 0x8C, 0x03, 0xC0, 0x33, 0xC0, 0x07, 0x8C, 0x03, 0x60, + 0x33, 0x80, 0x03, 0x8C, 0x06, 0x60, 0x33, 0x80, 0x03, 0x8C, 0x06, 0x60, + 0x33, 0x80, 0x03, 0x8C, 0x06, 0x30, 0x33, 0xFF, 0xFF, 0x8C, 0x0C, 0x30, + 0x33, 0xFF, 0xFF, 0x8C, 0x0C, 0x38, 0x33, 0xFF, 0xFF, 0x8C, 0x18, 0x18, + 0x33, 0xFF, 0xFF, 0x8C, 0x18, 0x0C, 0x33, 0xFF, 0xFF, 0x8C, 0x30, 0x0E, + 0x33, 0xF0, 0x1F, 0x8C, 0x70, 0x06, 0x33, 0x80, 0x03, 0x8C, 0x60, 0x03, + 0x33, 0x80, 0x03, 0x8C, 0xC0, 0x01, 0xB3, 0x80, 0x03, 0x8D, 0x80, 0x07, + 0xF3, 0x80, 0x03, 0x8F, 0xC0, 0x0E, 0x03, 0x80, 0x03, 0x80, 0xF0, 0x0C, + 0x01, 0xE0, 0x0F, 0x00, 0x30, 0x07, 0x00, 0x78, 0x1C, 0x00, 0xE0, 0x03, + 0x00, 0x18, 0x18, 0x00, 0xC0, 0x03, 0x80, 0x3F, 0xFC, 0x03, 0xC0, 0x01, + 0xFF, 0xF7, 0xEF, 0xFF, 0x80, 0x00, 0x7F, 0xC0, 0x03, 0xFE, 0x00, 0x00, + 0x00, 0x1D, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, + 0x03, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xCC, 0x00, 0x00, 0x00, 0x00, + 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x06, + 0x33, 0x00, 0x00, 0x00, 0x00, 0x18, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x63, + 0x18, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x07, 0x7B, + 0x80, 0x00, 0x00, 0x00, 0x18, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x43, 0x18, + 0x00, 0x00, 0x00, 0x03, 0x0C, 0x60, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x80, + 0x00, 0x00, 0x00, 0x30, 0xC3, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x0C, 0x00, + 0x00, 0x00, 0x03, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0xC0, 0x00, + 0x00, 0x00, 0x60, 0xC3, 0x00, 0x00, 0x00, 0x01, 0x83, 0x06, 0x00, 0x00, + 0x00, 0x06, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, 0x00, 0x00, + 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, + 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x00, 0x01, + 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x36, 0x03, 0x01, 0xA0, 0x00, 0x03, 0xF0, + 0x0C, 0x07, 0xF0, 0x00, 0x3F, 0x80, 0x30, 0x07, 0xF0, 0x03, 0xCC, 0x00, + 0xC0, 0x18, 0xF0, 0x7C, 0x18, 0x03, 0x00, 0x60, 0xF3, 0xC0, 0x60, 0x0C, + 0x01, 0x80, 0xE0, 0x01, 0xC0, 0x30, 0x0C, 0x00, 0x80, 0x03, 0x01, 0xE0, + 0x70, 0x00, 0x00, 0x06, 0x1F, 0xC1, 0x80, 0x00, 0x00, 0x1C, 0x63, 0x8C, + 0x00, 0x00, 0x00, 0x3B, 0x03, 0x70, 0x00, 0x00, 0x00, 0x7C, 0x0F, 0x80, + 0x00, 0x00, 0x00, 0xF0, 0x7C, 0x00, 0x00, 0x00, 0x01, 0xE1, 0xE0, 0x00, + 0x00, 0x00, 0x03, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x07, 0x00, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, + 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, + 0xE0, 0x00, 0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, + 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x03, 0x00, 0x00, 0x00, 0x60, 0x0E, + 0x0F, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x30, 0x18, + 0x30, 0x00, 0x00, 0x00, 0x18, 0x38, 0x60, 0x00, 0x00, 0x00, 0x1C, 0x30, + 0x40, 0x00, 0x00, 0x18, 0x0C, 0x70, 0x03, 0xC0, 0x00, 0x78, 0x0C, 0x60, + 0x03, 0xC0, 0x00, 0xE0, 0x06, 0x60, 0x07, 0xE0, 0x03, 0xC0, 0x06, 0x60, + 0x07, 0xE0, 0x07, 0x00, 0x06, 0xC0, 0x07, 0xE0, 0x0F, 0xC0, 0x03, 0xC0, + 0x03, 0xC0, 0x07, 0xF8, 0x03, 0xC0, 0x03, 0xC0, 0x00, 0x38, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x1F, 0x83, 0xC0, 0x00, 0x00, 0xE0, 0x3F, 0xC3, 0xC0, + 0x00, 0x00, 0xF0, 0x3F, 0xC0, 0x60, 0x00, 0x00, 0x38, 0x3F, 0xFC, 0x60, + 0x00, 0x00, 0x18, 0x3F, 0xFE, 0x60, 0x00, 0x00, 0x38, 0x3F, 0xFF, 0x70, + 0x00, 0x00, 0x70, 0x3F, 0xFF, 0x30, 0x00, 0x00, 0x70, 0x1F, 0xFF, 0x38, + 0x00, 0x00, 0x18, 0x1F, 0xFF, 0x18, 0x00, 0x00, 0x18, 0x1F, 0xFE, 0x1C, + 0x00, 0x00, 0x38, 0x3F, 0xFC, 0x0E, 0x00, 0x00, 0xF0, 0x3F, 0xF8, 0x07, + 0x00, 0x00, 0xE0, 0x0F, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, + 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x01, 0x80, 0x00, 0x00, + 0x07, 0xE0, 0x06, 0x00, 0x00, 0xC0, 0x3C, 0x00, 0x00, 0x38, 0x03, 0x01, + 0xC0, 0x18, 0x00, 0x60, 0x1C, 0x06, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x38, + 0x00, 0xC0, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x0E, 0x00, 0x03, 0x0E, + 0x00, 0x00, 0x19, 0x80, 0x0C, 0xFE, 0x00, 0x00, 0x67, 0x00, 0x37, 0x18, + 0x00, 0x01, 0x84, 0x00, 0xF8, 0x30, 0xF0, 0x06, 0x00, 0x01, 0xC0, 0xC7, + 0xF0, 0x18, 0x00, 0x03, 0x02, 0x38, 0xF0, 0xE0, 0x1C, 0x0F, 0xF8, 0xC0, + 0xF7, 0x00, 0x78, 0x3F, 0xC3, 0x00, 0xF8, 0x00, 0x40, 0x40, 0x0C, 0x00, + 0x00, 0x00, 0x1F, 0x80, 0x18, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x60, 0x60, + 0x00, 0x0F, 0x1F, 0x80, 0xC1, 0x80, 0x00, 0x30, 0x67, 0x03, 0x06, 0x00, + 0x01, 0xC1, 0x8E, 0x38, 0x00, 0x00, 0x06, 0x06, 0x0F, 0xE0, 0x00, 0x00, + 0x18, 0x18, 0x3E, 0x00, 0x07, 0x00, 0xE0, 0xE3, 0xF0, 0x00, 0x3C, 0x03, + 0x83, 0x0C, 0xC1, 0x81, 0xC0, 0x1E, 0x18, 0x71, 0x87, 0x0C, 0x00, 0x78, + 0x61, 0x86, 0x08, 0x30, 0x01, 0xF0, 0x06, 0x18, 0x00, 0x80, 0x0C, 0xC0, + 0x00, 0x30, 0x06, 0x00, 0x33, 0x00, 0x00, 0xC0, 0x18, 0x01, 0xC6, 0x00, + 0x1F, 0xC0, 0x60, 0x07, 0x1C, 0x0F, 0xEF, 0x81, 0x00, 0x1C, 0x38, 0x3E, + 0x37, 0x8C, 0x00, 0xD8, 0x70, 0x00, 0xCF, 0xE0, 0x03, 0x30, 0xE0, 0x06, + 0x0F, 0x00, 0x18, 0xE1, 0xF0, 0x38, 0x00, 0x00, 0x61, 0xC1, 0xFF, 0xC0, + 0x00, 0x73, 0xC3, 0x81, 0xFC, 0x00, 0x01, 0xCF, 0x07, 0x87, 0xC0, 0x00, + 0x00, 0x36, 0x07, 0xFC, 0x00, 0x20, 0x01, 0x9C, 0x0F, 0x80, 0x00, 0xC0, + 0x06, 0x3C, 0xF8, 0x00, 0x03, 0x00, 0x30, 0x3F, 0x00, 0x00, 0x04, 0x0C, + 0xC1, 0xF0, 0x00, 0x00, 0x00, 0x3B, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x6F, + 0xE0, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x07, 0x80, 0x00, 0x00, + 0x07, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x0C, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0C, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, + 0x03, 0xC0, 0x03, 0xC0, 0x0C, 0x60, 0x03, 0xC0, 0x03, 0xC0, 0x06, 0x60, + 0x07, 0xE0, 0x07, 0xE0, 0x06, 0x60, 0x07, 0xE0, 0x07, 0xE0, 0x06, 0xC0, + 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, + 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, + 0x60, 0x00, 0x00, 0x06, 0x03, 0xC0, 0xDF, 0x80, 0x01, 0xFF, 0x03, 0x60, + 0xC0, 0x7F, 0xFF, 0x83, 0x06, 0x60, 0xE0, 0x00, 0x00, 0x07, 0x06, 0x60, + 0xFE, 0x00, 0x00, 0x7F, 0x06, 0x30, 0x7F, 0xFF, 0xFF, 0xFE, 0x0C, 0x30, + 0x3F, 0xFF, 0xFF, 0xFC, 0x0C, 0x38, 0x1F, 0xFF, 0xFF, 0xF8, 0x18, 0x18, + 0x0F, 0xFF, 0xFF, 0xF0, 0x18, 0x0C, 0x07, 0xF8, 0x1F, 0xE0, 0x30, 0x0C, + 0x01, 0xE0, 0x07, 0x80, 0x30, 0x06, 0x00, 0x70, 0x0E, 0x00, 0x60, 0x03, + 0x00, 0x0F, 0xF0, 0x00, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, + 0xC0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, + 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x00, 0x00, 0xE0, 0x00, 0x00, + 0x01, 0xE0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, + 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, + 0xE0, 0x00, 0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, + 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0E, + 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x03, 0x00, 0x01, 0x80, 0x30, 0x18, + 0x07, 0x00, 0x00, 0xE0, 0x18, 0x38, 0x3C, 0x00, 0x00, 0x7C, 0x1C, 0x30, + 0xF8, 0x00, 0x00, 0x1F, 0x0C, 0x70, 0x40, 0x00, 0x00, 0x02, 0x0C, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, + 0x0F, 0xC0, 0x03, 0xF0, 0x06, 0xC0, 0x11, 0xE0, 0x06, 0x38, 0x03, 0xC0, + 0x60, 0xF8, 0x18, 0x1E, 0x03, 0xC0, 0x40, 0xF8, 0x10, 0x1E, 0x03, 0xC0, + 0xC0, 0xFC, 0x30, 0x1F, 0x03, 0xC0, 0xC1, 0xFC, 0x30, 0x3F, 0x03, 0xC0, + 0xE3, 0xFC, 0x38, 0xFF, 0x03, 0xC0, 0xFF, 0x3C, 0x3F, 0xCF, 0x03, 0xC0, + 0xFF, 0x3C, 0x3F, 0xCF, 0x03, 0xC0, 0x7F, 0xF8, 0x1F, 0xFE, 0x03, 0xC0, + 0x7F, 0xF8, 0x1F, 0xFE, 0x03, 0x60, 0x3F, 0xF0, 0x0F, 0xFC, 0x06, 0x60, + 0x0F, 0xC0, 0x03, 0xF0, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x70, + 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x38, + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x0E, 0x00, 0x07, 0xE0, 0x00, 0x70, 0x06, + 0x00, 0x1F, 0xF0, 0x00, 0x60, 0x03, 0x00, 0x08, 0x10, 0x00, 0xC0, 0x03, + 0x80, 0x00, 0x00, 0x01, 0x80, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, + 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xE0, 0x00, 0x00, + 0x00, 0x1F, 0x80, 0x1F, 0x00, 0x60, 0x00, 0x0F, 0x80, 0x00, 0x78, 0x0E, + 0x00, 0x03, 0xC0, 0x00, 0x03, 0xC3, 0xC0, 0x00, 0xE0, 0x00, 0x00, 0x1C, + 0xCC, 0x00, 0x38, 0x00, 0x00, 0x01, 0xF8, 0xC0, 0x1C, 0x00, 0x00, 0x00, + 0x1E, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x01, 0x81, 0x80, 0xC0, 0x00, 0x00, + 0x00, 0x70, 0x38, 0x38, 0x00, 0x00, 0x00, 0x0C, 0x03, 0x0E, 0x00, 0x00, + 0x00, 0x03, 0x80, 0x71, 0x80, 0x00, 0x00, 0x00, 0x60, 0x06, 0x70, 0x00, + 0x00, 0x00, 0x0C, 0x00, 0xCC, 0x00, 0x00, 0x00, 0x01, 0x80, 0x1B, 0x80, + 0x00, 0x00, 0x00, 0x30, 0x03, 0x60, 0x00, 0x00, 0x00, 0x06, 0x00, 0x6C, + 0x00, 0x00, 0x00, 0x20, 0x60, 0x19, 0x80, 0x1F, 0xC0, 0x3F, 0x86, 0x06, + 0x60, 0x06, 0x1C, 0x0E, 0x38, 0x3F, 0x8C, 0x00, 0x81, 0x81, 0x01, 0x00, + 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x06, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0C, 0x60, 0x30, 0x00, 0x00, 0x07, 0x01, 0x8C, 0x0D, 0xF8, + 0x00, 0x1F, 0xE0, 0x70, 0xC1, 0x80, 0xFF, 0xFE, 0x06, 0x0C, 0x18, 0x38, + 0x00, 0x00, 0x01, 0x81, 0x83, 0x07, 0xF0, 0x00, 0x03, 0xF0, 0x30, 0x70, + 0x7F, 0xFF, 0xFF, 0xFC, 0x0C, 0x06, 0x07, 0xFF, 0xFF, 0xFF, 0x81, 0x80, + 0xE0, 0x7F, 0xFF, 0xFF, 0xE0, 0x70, 0x0C, 0x07, 0xFF, 0xFF, 0xF8, 0x0C, + 0x01, 0xC0, 0x7F, 0x81, 0xFE, 0x03, 0x00, 0x1C, 0x07, 0xC0, 0x0F, 0x00, + 0xE0, 0x01, 0x80, 0x1C, 0x03, 0x80, 0x38, 0x00, 0x18, 0x00, 0xFF, 0x80, + 0x0E, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x1C, 0x00, 0x00, + 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x1E, 0x00, + 0x00, 0x1E, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x0F, + 0xC0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x0F, + 0xE0, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, + 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x03, 0xFF, + 0x00, 0x00, 0x00, 0x1F, 0x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F8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF8, 0x00, + 0x00, 0x00, 0x00, 0xFC, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x38, + 0x00, 0x00, 0x00, 0x70, 0x00, 0x07, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x06, 0x00, 0x00, + 0x01, 0x80, 0x00, 0x03, 0x00, 0x10, 0x00, 0x30, 0x00, 0x01, 0x80, 0x3F, + 0x80, 0x0E, 0x00, 0x00, 0x60, 0x1C, 0x70, 0x01, 0x80, 0x00, 0x30, 0x0E, + 0x06, 0x00, 0x30, 0x00, 0x18, 0x03, 0x00, 0xC0, 0x0E, 0x00, 0x06, 0x00, + 0x80, 0x37, 0x81, 0x80, 0x03, 0x00, 0x60, 0x07, 0x60, 0x30, 0x00, 0xC1, + 0xF8, 0x01, 0x98, 0x0C, 0x00, 0x60, 0x1E, 0x00, 0x46, 0x01, 0x80, 0x18, + 0x00, 0x80, 0x01, 0x80, 0x30, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x0E, 0x03, + 0x00, 0x0C, 0x00, 0x30, 0x01, 0x81, 0x80, 0x01, 0x80, 0x0C, 0x00, 0x30, + 0x60, 0x00, 0x70, 0x03, 0x00, 0x06, 0x18, 0x00, 0x0E, 0x00, 0x60, 0x01, + 0x8C, 0x00, 0x0F, 0xC0, 0x18, 0x00, 0x33, 0x00, 0x0F, 0xF0, 0x03, 0x00, + 0x0C, 0xC0, 0x01, 0x06, 0x00, 0x60, 0x01, 0xB0, 0x00, 0x01, 0x80, 0x0C, + 0x00, 0x6C, 0x00, 0x00, 0x20, 0x01, 0xC0, 0x0B, 0x00, 0x00, 0x0C, 0x00, + 0x38, 0x03, 0xC0, 0x00, 0x01, 0x80, 0x06, 0x00, 0xF0, 0x00, 0x00, 0x60, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0D, 0x80, 0x00, 0x03, + 0x80, 0x00, 0x03, 0x60, 0x00, 0x00, 0x70, 0x00, 0x00, 0x9C, 0x00, 0x00, + 0x0E, 0x00, 0x00, 0x63, 0x80, 0x00, 0x01, 0xC0, 0x00, 0x18, 0x70, 0x00, + 0x00, 0x38, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0xF8, + 0x00, 0x00, 0x70, 0x03, 0x80, 0x0F, 0xFF, 0x7F, 0xFF, 0xFF, 0xC0, 0x00, + 0x7F, 0xFF, 0xF0, 0xFF, 0xC0, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0xC3, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x38, + 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xE0, + 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xC0, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x70, 0x0C, 0x00, 0x00, + 0x00, 0x60, 0x1C, 0xFC, 0x0C, 0x00, 0x00, 0x00, 0x30, 0x3E, 0xC6, 0x18, + 0x04, 0x00, 0x60, 0x18, 0x63, 0xC6, 0x38, 0x0E, 0x00, 0xF0, 0x18, 0xC3, + 0xC3, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x83, 0xC1, 0xF0, 0x0F, 0x00, 0xF0, + 0x0F, 0x83, 0x60, 0x30, 0x0E, 0x00, 0x60, 0x18, 0x06, 0x60, 0x18, 0x00, + 0x00, 0x00, 0x18, 0x0E, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x38, + 0x0C, 0x00, 0x38, 0x00, 0x60, 0x18, 0x1C, 0x06, 0x00, 0x3C, 0x00, 0x60, + 0x30, 0x0C, 0x06, 0x00, 0x7C, 0x00, 0xC0, 0x70, 0x06, 0x03, 0x00, 0x38, + 0x00, 0xC0, 0x60, 0x07, 0x03, 0x00, 0x00, 0x01, 0x80, 0xE0, 0x07, 0x01, + 0x80, 0x00, 0x01, 0x81, 0xE0, 0x0D, 0x81, 0x80, 0x00, 0x01, 0x81, 0xA0, + 0x0D, 0x81, 0x80, 0x00, 0x03, 0x03, 0x30, 0x08, 0xC0, 0xC0, 0x00, 0x03, + 0x03, 0x30, 0x18, 0xC0, 0xC0, 0x00, 0x03, 0x03, 0x10, 0x18, 0xC0, 0xC0, + 0x00, 0x03, 0x02, 0x10, 0x18, 0xC0, 0xC0, 0x00, 0x02, 0x02, 0x18, 0x18, + 0x00, 0xC0, 0x00, 0x02, 0x00, 0x18, 0x18, 0x00, 0xC0, 0x00, 0x06, 0x00, + 0x18, 0x18, 0x00, 0xC0, 0x00, 0x02, 0x00, 0x18, 0x18, 0x00, 0xC0, 0x00, + 0x02, 0x00, 0x18, 0x18, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x10, 0x08, 0x00, + 0xC0, 0x00, 0x03, 0x00, 0x30, 0x0C, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x70, + 0x06, 0x03, 0xFF, 0xFF, 0xFF, 0x80, 0xE0, 0x03, 0xFF, 0x00, 0x00, 0x00, + 0xFF, 0xC0, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x1F, + 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x07, 0xE0, + 0x07, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x3C, 0x00, + 0x00, 0x3C, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, + 0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x70, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x30, 0x00, 0x00, + 0x00, 0x00, 0x0C, 0x70, 0x0F, 0xC0, 0x03, 0xF0, 0x0C, 0x60, 0x3F, 0xF0, + 0x0F, 0xFC, 0x06, 0x60, 0x6F, 0xD8, 0x1B, 0xF6, 0x06, 0x60, 0x6F, 0xD8, + 0x1B, 0xF6, 0x06, 0xC0, 0xC7, 0x8C, 0x31, 0xE3, 0x03, 0xC0, 0xC0, 0x0C, + 0x30, 0x03, 0x03, 0xC0, 0xC0, 0x0C, 0x30, 0x03, 0x03, 0xC0, 0xC0, 0x0C, + 0x30, 0x03, 0x03, 0xC0, 0xE0, 0x1C, 0x38, 0x07, 0x03, 0xC0, 0x60, 0x18, + 0x18, 0x06, 0x03, 0xC0, 0x38, 0x70, 0x0E, 0x1C, 0x03, 0xC0, 0x1F, 0xE0, + 0x07, 0xF8, 0x03, 0xC0, 0x0F, 0xC0, 0x03, 0xF0, 0x03, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x70, 0x00, 0x00, + 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x1C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x0E, 0x00, 0x3F, 0xFC, 0x00, 0x70, 0x06, 0x00, 0x3F, + 0xFC, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x80, 0x00, + 0x00, 0x01, 0x80, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x70, 0x00, + 0x00, 0x0E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x01, 0xFF, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x0F, 0x80, + 0x00, 0x00, 0x03, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0xE0, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, + 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x00, + 0x00, 0x60, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x78, 0x03, 0x80, 0x01, 0x80, 0x00, + 0x01, 0x8C, 0x01, 0x80, 0x03, 0x80, 0x00, 0x01, 0x06, 0x01, 0xC0, 0x03, + 0x00, 0x7C, 0x03, 0x00, 0x00, 0xC0, 0x03, 0x00, 0xC7, 0x03, 0x00, 0x00, + 0xC0, 0x06, 0x01, 0x83, 0x00, 0x00, 0x00, 0x60, 0x06, 0x01, 0x80, 0x00, + 0x00, 0x00, 0x60, 0x06, 0x01, 0x80, 0x00, 0x00, 0x60, 0x60, 0x0C, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x70, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, + 0x0C, 0x00, 0x00, 0x00, 0x01, 0x80, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x30, 0x0C, 0x02, 0x00, + 0x00, 0x1C, 0x00, 0x30, 0x0C, 0x03, 0xC0, 0x00, 0x70, 0x00, 0x30, 0x0C, + 0x00, 0xF8, 0x03, 0xC0, 0x00, 0x30, 0x0C, 0x00, 0x1F, 0xFF, 0x00, 0x00, + 0x30, 0x0D, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xB0, 0x1E, 0x60, 0x00, 0x00, + 0x00, 0x04, 0xF8, 0x3E, 0x31, 0xC0, 0x00, 0x03, 0x88, 0x7C, 0x22, 0x1A, + 0x60, 0x00, 0x06, 0x58, 0xC4, 0x23, 0x0E, 0x30, 0x00, 0x0C, 0x70, 0xC4, + 0x31, 0x8C, 0x30, 0x00, 0x0C, 0x61, 0x8C, 0x70, 0x84, 0x30, 0x00, 0x0C, + 0x63, 0x0E, 0xC8, 0xC2, 0x30, 0x00, 0x0C, 0x42, 0x1B, 0xC4, 0x60, 0x18, + 0x00, 0x18, 0x04, 0x23, 0xE6, 0x20, 0x18, 0x00, 0x18, 0x04, 0x47, 0x63, + 0x00, 0x18, 0x00, 0x18, 0x00, 0x86, 0x71, 0x80, 0x0C, 0x00, 0x30, 0x01, + 0x0E, 0xCC, 0x00, 0x0C, 0x00, 0x30, 0x00, 0x3B, 0xC6, 0x00, 0x0C, 0x00, + 0x30, 0x00, 0x63, 0xC2, 0x00, 0x0C, 0x00, 0x30, 0x00, 0x43, 0x60, 0x00, + 0x0C, 0x00, 0x30, 0x00, 0x06, 0x30, 0x00, 0x18, 0x00, 0x18, 0x00, 0x0C, + 0x1C, 0x00, 0x18, 0x00, 0x18, 0x00, 0x38, 0x07, 0x00, 0x3F, 0xC3, 0xFC, + 0x00, 0xE0, 0x01, 0xC0, 0xE7, 0xFF, 0xE7, 0x03, 0x80, 0x00, 0x3F, 0x80, + 0x00, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x1F, + 0x00, 0x00, 0xF8, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x70, + 0x00, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x01, 0x80, + 0x00, 0x00, 0x01, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x0E, 0x03, 0x80, 0x00, 0x00, 0x70, 0x1C, 0x0F, + 0x80, 0x00, 0x00, 0x30, 0x18, 0x1C, 0x00, 0x00, 0x00, 0x18, 0x38, 0x38, + 0x00, 0x00, 0x00, 0x1C, 0x30, 0x70, 0x00, 0x00, 0x00, 0x0C, 0x70, 0x60, + 0x00, 0x00, 0x00, 0x0C, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, + 0x00, 0x00, 0x18, 0x06, 0x60, 0x03, 0xC0, 0x00, 0x78, 0x06, 0xC0, 0x03, + 0xC0, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x03, 0xC0, 0x03, 0xC0, 0x07, + 0xE0, 0x07, 0x00, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xC0, 0x03, 0xC0, 0x03, + 0xC0, 0x07, 0xF8, 0x03, 0xC0, 0x03, 0x80, 0x00, 0x38, 0x03, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0x03, + 0x00, 0x00, 0x40, 0x06, 0x70, 0x03, 0xC0, 0x01, 0xC0, 0x0C, 0x30, 0x01, + 0xF0, 0x0F, 0x80, 0x0C, 0x38, 0x00, 0x7F, 0xFE, 0x00, 0x1C, 0x18, 0x00, + 0x0F, 0xF0, 0x00, 0x18, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0E, 0x00, + 0x00, 0x00, 0x00, 0x70, 0x06, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, + 0x00, 0x00, 0x00, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x01, 0x80, 0x01, 0xE0, + 0x00, 0x00, 0x07, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x3C, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x1F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x07, + 0xE0, 0x07, 0xE0, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, + 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x7F, 0xEF, 0xF8, 0x00, 0x00, 0x00, + 0xFB, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0xF0, 0x70, 0x03, 0xC0, 0x00, 0x01, + 0xE0, 0x08, 0x00, 0x78, 0x00, 0x01, 0xC0, 0x00, 0x3F, 0x8E, 0x00, 0x01, + 0xC1, 0xE0, 0x1F, 0xF3, 0x80, 0x01, 0xC0, 0xF0, 0x00, 0x3C, 0xE0, 0x01, + 0xC0, 0xFC, 0x00, 0x00, 0x38, 0x01, 0xC0, 0x7E, 0x00, 0x00, 0x0E, 0x00, + 0xC0, 0x3F, 0x00, 0x78, 0x03, 0x00, 0xE0, 0x1F, 0x00, 0x3C, 0x01, 0xC0, + 0x60, 0x07, 0x80, 0x3F, 0x00, 0x60, 0x60, 0x00, 0x00, 0x1F, 0x80, 0x18, + 0x30, 0x00, 0x00, 0x0F, 0xC0, 0x0C, 0x38, 0x00, 0x00, 0x03, 0xC0, 0x03, + 0x18, 0x00, 0x00, 0x01, 0xE0, 0x01, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xCE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x80, 0x00, 0x7F, 0x00, 0x00, + 0x06, 0xC0, 0x01, 0xFF, 0xE0, 0x00, 0x03, 0x60, 0x00, 0xE0, 0x3C, 0x00, + 0x01, 0xB0, 0x00, 0x00, 0x07, 0x00, 0x00, 0xD8, 0x00, 0x00, 0x01, 0x80, + 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x1E, 0x30, 0x01, 0xFC, 0x00, 0x00, 0x1B, 0x0C, 0x07, 0x03, 0x00, + 0x00, 0x0D, 0x86, 0x0C, 0x01, 0x80, 0x00, 0x06, 0x61, 0x98, 0x03, 0xC0, + 0x00, 0x03, 0x30, 0x70, 0x0F, 0xC0, 0x00, 0x03, 0x08, 0x00, 0x1F, 0x80, + 0x00, 0x01, 0x86, 0x00, 0x1E, 0x00, 0x00, 0x01, 0x83, 0x00, 0x3E, 0x00, + 0x00, 0x01, 0xC1, 0x80, 0x1B, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x08, 0x80, + 0x00, 0x00, 0xC0, 0x60, 0x00, 0x40, 0x00, 0x00, 0xE0, 0x30, 0x00, 0xF0, + 0x00, 0x00, 0xE0, 0x18, 0x00, 0xD8, 0x00, 0x00, 0xE0, 0x0C, 0x00, 0x0C, + 0x00, 0x00, 0xE0, 0x06, 0x00, 0x0C, 0x00, 0x01, 0xE0, 0x01, 0x00, 0x0F, + 0x00, 0x03, 0xC0, 0x00, 0xC0, 0x01, 0x80, 0x07, 0x80, 0x00, 0x30, 0x01, + 0xFE, 0xFF, 0x00, 0x00, 0x0E, 0x03, 0xBF, 0xFC, 0x00, 0x00, 0x01, 0xFE, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0xF0, 0x00, 0x00, 0x00, + 0x03, 0x9C, 0xC8, 0x00, 0x00, 0x00, 0x0E, 0x19, 0x8E, 0x00, 0x00, 0x00, + 0x78, 0x33, 0x9F, 0xC0, 0x00, 0x03, 0xC0, 0x67, 0x3D, 0xF0, 0x00, 0x0E, + 0x01, 0xCC, 0x6C, 0x3C, 0x00, 0x18, 0x07, 0x38, 0xC8, 0x0E, 0x00, 0x30, + 0x04, 0x63, 0x10, 0x03, 0x80, 0x60, 0x00, 0xC6, 0x60, 0x01, 0xC0, 0x60, + 0x00, 0x18, 0xC0, 0x00, 0xE0, 0xC0, 0x00, 0x13, 0x00, 0x00, 0x60, 0xC0, + 0x00, 0x0F, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x1B, 0x00, 0x00, 0x38, 0xC0, + 0x3F, 0x63, 0x00, 0x00, 0x18, 0xC0, 0x60, 0x8E, 0x00, 0x00, 0x0C, 0xC0, + 0x00, 0x1C, 0x00, 0x00, 0x0C, 0x60, 0x00, 0x78, 0x00, 0x00, 0x06, 0x70, + 0x00, 0xE0, 0x01, 0xC0, 0x06, 0x38, 0x03, 0xE0, 0x03, 0xE0, 0x06, 0x1C, + 0x1F, 0xF0, 0x03, 0xF0, 0x07, 0x1F, 0xFB, 0xF0, 0x03, 0xF0, 0x03, 0x30, + 0x83, 0xF0, 0x03, 0xF0, 0x03, 0x30, 0x01, 0xE0, 0x03, 0xE0, 0x03, 0x30, + 0x01, 0xE0, 0x01, 0xC0, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0x03, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x18, 0x00, 0x00, 0x00, 0x00, 0x06, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x00, 0xE0, 0x01, 0x80, 0x0E, 0x0C, + 0x00, 0xFF, 0xFF, 0xC0, 0x0C, 0x0C, 0x00, 0x1F, 0xFE, 0x00, 0x1C, 0x06, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x70, 0x01, 0x80, 0x00, 0x00, 0x00, 0x60, 0x00, + 0xC0, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x00, 0x03, 0x80, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x1E, 0x00, 0x00, + 0x0F, 0x80, 0x00, 0x7C, 0x00, 0x00, 0x03, 0xF0, 0x03, 0xF0, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0xFC, 0x00, 0x00, 0x00, + 0x3C, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x06, 0x38, 0x00, 0x00, + 0x03, 0x07, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0x00, 0x00, 0x18, 0x0E, 0x00, + 0x00, 0x07, 0x01, 0xC0, 0x00, 0x03, 0xE0, 0x3C, 0x00, 0x01, 0xDC, 0x03, + 0x80, 0x00, 0x61, 0xC0, 0x70, 0x00, 0x18, 0x38, 0x06, 0x00, 0x06, 0x07, + 0x00, 0xC0, 0x00, 0xC0, 0xF0, 0x30, 0x00, 0x38, 0x0C, 0x06, 0x00, 0x07, + 0x01, 0x81, 0xC0, 0x00, 0xE0, 0x60, 0x30, 0x00, 0x1F, 0xEC, 0x06, 0x00, + 0x3F, 0x7F, 0x01, 0x80, 0x1C, 0x01, 0xF8, 0x30, 0x1E, 0x00, 0x0F, 0x0C, + 0x0E, 0x00, 0x00, 0xE3, 0x0E, 0x00, 0x00, 0x18, 0x63, 0x00, 0x7C, 0x03, + 0x19, 0x80, 0x7F, 0xC0, 0xC6, 0x60, 0x78, 0x38, 0x19, 0x98, 0x38, 0x06, + 0x06, 0x23, 0xFC, 0x00, 0xC0, 0xCC, 0x7C, 0x00, 0x30, 0x03, 0x3C, 0x00, + 0x0C, 0x00, 0xDF, 0x80, 0x03, 0x00, 0x3E, 0x30, 0x00, 0xC0, 0x0F, 0x0E, + 0x00, 0x30, 0x03, 0xC1, 0x80, 0x0C, 0x00, 0xB0, 0x30, 0x06, 0x00, 0x6C, + 0x0E, 0x03, 0x80, 0x1B, 0x01, 0xC1, 0xC0, 0x06, 0x60, 0x3F, 0xE0, 0x03, + 0x18, 0x03, 0xE0, 0x00, 0xC7, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x06, 0x07, 0x00, 0x00, 0x03, 0x00, 0xE0, 0x00, + 0x01, 0xC0, 0x1C, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x00, 0xF0, 0x00, 0x3E, + 0x01, 0xF0, 0x00, 0x03, 0xFF, 0xF0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xC0, 0xF0, 0x7F, + 0x83, 0xFC, 0x1F, 0xE0, 0xFF, 0x07, 0xF8, 0x3F, 0xC1, 0xFE, 0x0F, 0xF0, + 0x7F, 0x83, 0xFC, 0x1F, 0xE0, 0xFF, 0x07, 0x80, 0x00, 0x07, 0x81, 0xE0, + 0x00, 0x07, 0x81, 0xE0, 0x00, 0x07, 0x01, 0xE0, 0x00, 0x0F, 0x01, 0xC0, + 0x00, 0x0F, 0x03, 0xC0, 0x00, 0x0F, 0x03, 0xC0, 0x00, 0x0E, 0x03, 0xC0, + 0x00, 0x1E, 0x03, 0x80, 0x00, 0x1E, 0x03, 0x80, 0x00, 0x1E, 0x07, 0x80, + 0x1F, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0xFF, + 0x1F, 0xFF, 0xFF, 0xFF, 0x00, 0x3C, 0x0F, 0x00, 0x00, 0x38, 0x0F, 0x00, + 0x00, 0x78, 0x0E, 0x00, 0x00, 0x78, 0x1E, 0x00, 0x00, 0x70, 0x1E, 0x00, + 0x00, 0xF0, 0x1E, 0x00, 0x00, 0xF0, 0x1C, 0x00, 0xFF, 0xFF, 0xFF, 0xF8, + 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0xF8, + 0x01, 0xE0, 0x78, 0x00, 0x01, 0xC0, 0x78, 0x00, 0x01, 0xC0, 0x78, 0x00, + 0x03, 0xC0, 0x70, 0x00, 0x03, 0xC0, 0xF0, 0x00, 0x03, 0xC0, 0xF0, 0x00, + 0x03, 0x80, 0xF0, 0x00, 0x07, 0x80, 0xE0, 0x00, 0x07, 0x80, 0xE0, 0x00, + 0x07, 0x81, 0xE0, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, + 0x00, 0x0C, 0x00, 0x00, 0x30, 0x00, 0x07, 0xFF, 0x00, 0xFF, 0xFF, 0x07, + 0xFF, 0xFC, 0x3F, 0xFF, 0xF1, 0xF8, 0xC1, 0xCF, 0x83, 0x00, 0x3C, 0x0C, + 0x00, 0xF0, 0x30, 0x03, 0xC0, 0xC0, 0x0F, 0x03, 0x00, 0x3E, 0x0C, 0x00, + 0x7E, 0x30, 0x01, 0xFF, 0xC0, 0x03, 0xFF, 0xE0, 0x03, 0xFF, 0xF0, 0x03, + 0xFF, 0xE0, 0x00, 0xFF, 0xC0, 0x03, 0x1F, 0x80, 0x0C, 0x1F, 0x00, 0x30, + 0x7C, 0x00, 0xC0, 0xF0, 0x03, 0x03, 0xC0, 0x0C, 0x0F, 0x00, 0x30, 0x7E, + 0x00, 0xC3, 0xEF, 0x83, 0x3F, 0xBF, 0xFF, 0xFC, 0xFF, 0xFF, 0xE1, 0xFF, + 0xFF, 0x00, 0x7F, 0xE0, 0x00, 0x0C, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC0, + 0x00, 0x03, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC0, 0x00, + 0x07, 0xE0, 0x00, 0x0E, 0x00, 0x3F, 0xF0, 0x00, 0x3C, 0x00, 0xFF, 0xF0, + 0x00, 0x70, 0x03, 0xE1, 0xE0, 0x01, 0xE0, 0x07, 0x81, 0xE0, 0x03, 0x80, + 0x0F, 0x03, 0xC0, 0x0F, 0x00, 0x3C, 0x03, 0xC0, 0x3C, 0x00, 0x78, 0x07, + 0x80, 0x70, 0x00, 0xF0, 0x0F, 0x01, 0xE0, 0x01, 0xE0, 0x1E, 0x03, 0x80, + 0x03, 0xC0, 0x3C, 0x0F, 0x00, 0x07, 0x80, 0x78, 0x1C, 0x00, 0x0F, 0x00, + 0xF0, 0x70, 0x00, 0x0F, 0x03, 0xC1, 0xE0, 0x00, 0x1E, 0x07, 0x83, 0x80, + 0x00, 0x3E, 0x1F, 0x0F, 0x00, 0x00, 0x3F, 0xFC, 0x1C, 0x00, 0x00, 0x3F, + 0xF0, 0x78, 0x1F, 0x80, 0x1F, 0x81, 0xE0, 0xFF, 0xC0, 0x00, 0x03, 0x83, + 0xFF, 0xC0, 0x00, 0x0F, 0x0F, 0x87, 0xC0, 0x00, 0x1C, 0x1E, 0x07, 0x80, + 0x00, 0x78, 0x3C, 0x0F, 0x00, 0x00, 0xE0, 0xF0, 0x0F, 0x00, 0x03, 0x81, + 0xE0, 0x1E, 0x00, 0x0F, 0x03, 0xC0, 0x3C, 0x00, 0x1C, 0x07, 0x80, 0x78, + 0x00, 0x78, 0x0F, 0x00, 0xF0, 0x00, 0xE0, 0x1E, 0x01, 0xE0, 0x03, 0xC0, + 0x3C, 0x03, 0xC0, 0x07, 0x00, 0x3C, 0x0F, 0x00, 0x1C, 0x00, 0x78, 0x1E, + 0x00, 0x78, 0x00, 0xF8, 0x78, 0x00, 0xE0, 0x00, 0xFF, 0xF0, 0x03, 0xC0, + 0x00, 0xFF, 0xC0, 0x07, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x3F, 0x80, 0x00, + 0x00, 0xFF, 0xF0, 0x00, 0x03, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xF8, 0x00, + 0x07, 0xE0, 0x78, 0x00, 0x0F, 0x80, 0x08, 0x00, 0x0F, 0x80, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, + 0x07, 0xE0, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, + 0x1F, 0xFC, 0x00, 0x00, 0x1E, 0x7E, 0x00, 0x3C, 0x3E, 0x3F, 0x00, 0x3C, + 0x7C, 0x1F, 0x80, 0x7C, 0x78, 0x0F, 0xC0, 0x78, 0xF8, 0x07, 0xE0, 0x78, + 0xF0, 0x03, 0xF0, 0x78, 0xF0, 0x01, 0xF8, 0xF0, 0xF0, 0x00, 0xFC, 0xF0, + 0xF0, 0x00, 0x7E, 0xE0, 0xF0, 0x00, 0x3F, 0xE0, 0xF8, 0x00, 0x1F, 0xC0, + 0x78, 0x00, 0x0F, 0xC0, 0x7C, 0x00, 0x0F, 0xC0, 0x3E, 0x00, 0x3F, 0xE0, + 0x3F, 0xC0, 0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0x0E, 0x1F, 0xF0, 0x70, 0x7A, 0x03, 0x80, 0x80, 0x1C, + 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x80, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xE0, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x03, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFC, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xE0, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, + 0x00, 0x00, 0x3C, 0xF3, 0xCF, 0x3C, 0xE7, 0x9C, 0x73, 0xCE, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0F, 0x00, 0x1F, + 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x3C, + 0x00, 0x78, 0x00, 0x78, 0x00, 0x78, 0x00, 0xF8, 0x00, 0xF0, 0x00, 0xF0, + 0x01, 0xF0, 0x01, 0xE0, 0x01, 0xE0, 0x01, 0xE0, 0x03, 0xC0, 0x03, 0xC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0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0x00, 0xFF, 0xFE, 0x0F, 0xFF, 0xFE, 0x3F, + 0xFF, 0xFC, 0xFE, 0x03, 0xF3, 0x80, 0x03, 0xE8, 0x00, 0x07, 0x80, 0x00, + 0x1F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x0F, + 0x00, 0x00, 0x3C, 0x00, 0x01, 0xE0, 0x00, 0x0F, 0x80, 0x00, 0x3C, 0x00, + 0x01, 0xF0, 0x00, 0x0F, 0x80, 0x00, 0x7C, 0x00, 0x03, 0xE0, 0x00, 0x1F, + 0x00, 0x00, 0xF8, 0x00, 0x07, 0xC0, 0x00, 0x3E, 0x00, 0x01, 0xF0, 0x00, + 0x0F, 0x80, 0x00, 0x7C, 0x00, 0x03, 0xE0, 0x00, 0x1F, 0x00, 0x00, 0xF8, + 0x00, 0x07, 0xC0, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xC0, 0x0F, 0xFE, 0x00, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, + 0x83, 0xFF, 0xFF, 0x87, 0x00, 0x3F, 0x80, 0x00, 0x1F, 0x00, 0x00, 0x1F, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x78, 0x00, 0x00, 0xF0, + 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1F, 0x00, 0x00, 0xFC, 0x01, + 0xFF, 0xF0, 0x03, 0xFF, 0x80, 0x07, 0xFF, 0x80, 0x0F, 0xFF, 0xC0, 0x00, + 0x1F, 0xC0, 0x00, 0x0F, 0xC0, 0x00, 0x07, 0x80, 0x00, 0x0F, 0x80, 0x00, + 0x0F, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x78, 0x00, 0x00, + 0xF0, 0x00, 0x03, 0xE0, 0x00, 0x0F, 0xA0, 0x00, 0x3F, 0x7C, 0x01, 0xFC, + 0xFF, 0xFF, 0xF1, 0xFF, 0xFF, 0xC1, 0xFF, 0xFE, 0x00, 0x3F, 0xE0, 0x00, + 0x00, 0x03, 0xF0, 0x00, 0x03, 0xF8, 0x00, 0x01, 0xFC, 0x00, 0x01, 0xFE, + 0x00, 0x01, 0xEF, 0x00, 0x00, 0xE7, 0x80, 0x00, 0xF3, 0xC0, 0x00, 0xF1, + 0xE0, 0x00, 0x78, 0xF0, 0x00, 0x78, 0x78, 0x00, 0x78, 0x3C, 0x00, 0x3C, + 0x1E, 0x00, 0x3C, 0x0F, 0x00, 0x3C, 0x07, 0x80, 0x1E, 0x03, 0xC0, 0x1E, + 0x01, 0xE0, 0x1E, 0x00, 0xF0, 0x0F, 0x00, 0x78, 0x0F, 0x00, 0x3C, 0x0F, + 0x80, 0x1E, 0x07, 0x80, 0x0F, 0x07, 0x80, 0x07, 0x83, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x3C, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x07, 0x80, 0x00, 0x03, + 0xC0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x7F, + 0xFF, 0xE1, 0xFF, 0xFF, 0x87, 0xFF, 0xFE, 0x1F, 0xFF, 0xF8, 0x78, 0x00, + 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x01, + 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0xFE, 0x00, 0x7F, 0xFF, 0x01, 0xFF, + 0xFF, 0x07, 0xFF, 0xFE, 0x1E, 0x03, 0xFC, 0x40, 0x01, 0xF0, 0x00, 0x03, + 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, + 0x00, 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, + 0x07, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0xFA, 0x00, 0x07, 0xCF, 0x00, 0x7F, + 0x3F, 0xFF, 0xF8, 0xFF, 0xFF, 0xC3, 0xFF, 0xFC, 0x01, 0xFF, 0xC0, 0x00, + 0x00, 0x1F, 0xF0, 0x00, 0xFF, 0xFC, 0x03, 0xFF, 0xFC, 0x07, 0xFF, 0xFC, + 0x0F, 0xE0, 0x0C, 0x1F, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x3E, 0x00, 0x00, + 0x3C, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, + 0xF8, 0x7F, 0x00, 0xF1, 0xFF, 0xE0, 0xF3, 0xFF, 0xF0, 0xF7, 0xFF, 0xF8, + 0xFF, 0xC1, 0xFC, 0xFF, 0x00, 0x7E, 0xFE, 0x00, 0x3E, 0xFC, 0x00, 0x1E, + 0xFC, 0x00, 0x1F, 0xF8, 0x00, 0x0F, 0xF8, 0x00, 0x0F, 0xF8, 0x00, 0x0F, + 0x78, 0x00, 0x0F, 0x78, 0x00, 0x0F, 0x78, 0x00, 0x0F, 0x7C, 0x00, 0x1F, + 0x3C, 0x00, 0x1E, 0x3E, 0x00, 0x3E, 0x1F, 0x00, 0x7C, 0x1F, 0xC1, 0xFC, + 0x0F, 0xFF, 0xF8, 0x07, 0xFF, 0xF0, 0x03, 0xFF, 0xE0, 0x00, 0x7F, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, + 0x00, 0x78, 0x00, 0x03, 0xE0, 0x00, 0x0F, 0x00, 0x00, 0x7C, 0x00, 0x01, + 0xE0, 0x00, 0x07, 0x80, 0x00, 0x3E, 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, + 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x03, 0xE0, 0x00, 0x0F, 0x00, 0x00, + 0x3C, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x3E, 0x00, 0x00, 0xF0, + 0x00, 0x03, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x03, 0xE0, 0x00, + 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x3E, + 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x07, 0xFF, 0xE0, 0x0F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF8, 0x3F, 0x81, + 0xFC, 0x3E, 0x00, 0x7C, 0x7C, 0x00, 0x3E, 0x78, 0x00, 0x1E, 0x78, 0x00, + 0x1E, 0x78, 0x00, 0x1E, 0x78, 0x00, 0x1E, 0x78, 0x00, 0x1E, 0x3C, 0x00, + 0x3C, 0x3E, 0x00, 0x7C, 0x1F, 0x81, 0xF8, 0x0F, 0xFF, 0xF0, 0x03, 0xFF, + 0xC0, 0x07, 0xFF, 0xE0, 0x1F, 0xFF, 0xF8, 0x3F, 0x81, 0xFC, 0x7C, 0x00, + 0x3E, 0x78, 0x00, 0x1E, 0xF8, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, + 0x0F, 0xF0, 0x00,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0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0xFE, 0x00, 0x00, + 0x3F, 0xF0, 0x00, 0x07, 0xFF, 0x00, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0xF8, + 0x00, 0x1F, 0xFE, 0x00, 0x03, 0xFF, 0x80, 0x00, 0xFF, 0xF0, 0x00, 0x3F, + 0xFC, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x7F, 0xC0, + 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x03, 0xFF, 0x80, + 0x00, 0x07, 0xFF, 0x80, 0x00, 0x07, 0xFF, 0x80, 0x00, 0x07, 0xFF, 0x80, + 0x00, 0x07, 0xFF, 0x00, 0x00, 0x0F, 0xFC, 0x00, 0x00, 0x0F, 0xE0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x80, 0x00, 0x00, + 0x07, 0x80, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x07, + 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x0F, + 0xFF, 0x00, 0x00, 0x0F, 0xFE, 0x00, 0x00, 0x1F, 0xFE, 0x00, 0x00, 0x1F, + 0xFE, 0x00, 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x07, 0xFC, + 0x00, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0xF8, 0x00, 0x0F, 0xFE, 0x00, 0x03, + 0xFF, 0xC0, 0x00, 0xFF, 0xF0, 0x00, 0x3F, 0xFC, 0x00, 0x07, 0xFF, 0x00, + 0x00, 0x7F, 0xE0, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x0F, 0xFF, 0x07, 0xFF, 0xF3, 0xFF, + 0xFE, 0xF8, 0x1F, 0xB8, 0x01, 0xF8, 0x00, 0x7C, 0x00, 0x0F, 0x00, 0x03, + 0xC0, 0x00, 0xF0, 0x00, 0x3C, 0x00, 0x1E, 0x00, 0x0F, 0x80, 0x07, 0xC0, + 0x03, 0xE0, 0x01, 0xF8, 0x00, 0xFC, 0x00, 0x7E, 0x00, 0x1F, 0x00, 0x0F, + 0x80, 0x03, 0xC0, 0x00, 0xF0, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x03, 0xC0, + 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, + 0x3E, 0x00, 0x0F, 0x80, 0x03, 0xE0, 0x00, 0xF8, 0x00, 0x3E, 0x00, 0x00, + 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x03, 0xFF, 0xFC, 0x00, 0x00, 0x07, 0xFF, + 0xFF, 0xC0, 0x00, 0x0F, 0xFF, 0xFF, 0xF0, 0x00, 0x0F, 0xF8, 0x03, 0xFE, + 0x00, 0x0F, 0xE0, 0x00, 0x3F, 0x80, 0x0F, 0xC0, 0x00, 0x07, 0xE0, 0x0F, + 0x80, 0x00, 0x01, 0xF8, 0x0F, 0x80, 0x00, 0x00, 0x7C, 0x0F, 0x80, 0x00, + 0x00, 0x1F, 0x07, 0x80, 0x00, 0x00, 0x07, 0x87, 0xC0, 0x1F, 0x87, 0x81, + 0xE3, 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 0xF0, 0x00, 0x1F, 0xF0, 0x00, 0x3E, 0xF0, 0x00, 0xFE, + 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0x80, + 0x00, 0x0F, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x01, 0xFF, 0xFF, 0xE0, 0x3F, + 0xFF, 0xFF, 0x07, 0xF0, 0x07, 0xF0, 0xFC, 0x00, 0x0F, 0x1F, 0x00, 0x00, + 0x31, 0xE0, 0x00, 0x01, 0x3E, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x78, + 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x78, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x03, 0xE0, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x11, 0xF0, 0x00, 0x03, 0x0F, 0xC0, 0x00, + 0xF0, 0x7F, 0x80, 0x7F, 0x03, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFE, 0x00, + 0x7F, 0xFF, 0x80, 0x00, 0xFF, 0xC0, 0xFF, 0xFF, 0x00, 0x07, 0xFF, 0xFF, + 0x80, 0x3F, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFC, 0x0F, 0x00, 0x1F, 0xF8, + 0x78, 0x00, 0x0F, 0xE3, 0xC0, 0x00, 0x1F, 0x1E, 0x00, 0x00, 0x7C, 0xF0, + 0x00, 0x01, 0xE7, 0x80, 0x00, 0x0F, 0xBC, 0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xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, + 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, + 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xFF, 0xEF, 0xFF, 0xFE, + 0xFF, 0xFF, 0xEF, 0xFF, 0xFE, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, + 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0xFC, + 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x1F, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFE, + 0x07, 0xF8, 0x07, 0xF8, 0x3F, 0x00, 0x01, 0xE1, 0xF0, 0x00, 0x01, 0x8F, + 0x80, 0x00, 0x02, 0x3E, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x07, 0x80, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x03, 0xC0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x03, 0xC0, 0x00, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFC, 0x00, 0x0F, 0xFF, + 0xF0, 0x00, 0x3F, 0xFF, 0xC0, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x03, 0xDE, + 0x00, 0x00, 0x0F, 0x78, 0x00, 0x00, 0x3D, 0xE0, 0x00, 0x00, 0xF7, 0xC0, + 0x00, 0x03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, 0xC0, 0x78, 0x0F, 0x01, 0xE0, 0x3C, 0x07, 0x80, 0xF0, + 0x1E, 0x03, 0xC0, 0x78, 0x0F, 0x01, 0xE0, 0x3C, 0x07, 0x80, 0xF0, 0x1E, + 0x03, 0xC0, 0x78, 0x0F, 0x01, 0xE0, 0x3C, 0x07, 0x80, 0xF0, 0x3C, 0x07, + 0x83, 0xF7, 0xFC, 0xFF, 0x9F, 0xC3, 0xE0, 0x00, 0xF0, 0x00, 0x1F, 0x9E, + 0x00, 0x07, 0xE3, 0xC0, 0x01, 0xF8, 0x78, 0x00, 0x7E, 0x0F, 0x00, 0x1F, + 0x81, 0xE0, 0x07, 0xE0, 0x3C, 0x01, 0xF8, 0x07, 0x80, 0x7E, 0x00, 0xF0, + 0x1F, 0x80, 0x1E, 0x07, 0xE0, 0x03, 0xC3, 0xF0, 0x00, 0x78, 0xFC, 0x00, + 0x0F, 0x3F, 0x00, 0x01, 0xEF, 0xC0, 0x00, 0x3F, 0xF0, 0x00, 0x07, 0xFC, + 0x00, 0x00, 0xFF, 0x80, 0x00, 0x1F, 0xF8, 0x00, 0x03, 0xDF, 0x80, 0x00, + 0x79, 0xF8, 0x00, 0x0F, 0x1F, 0x80, 0x01, 0xE0, 0xF8, 0x00, 0x3C, 0x0F, + 0x80, 0x07, 0x80, 0xF8, 0x00, 0xF0, 0x0F, 0x80, 0x1E, 0x00, 0xF8, 0x03, + 0xC0, 0x0F, 0x80, 0x78, 0x00, 0xF8, 0x0F, 0x00, 0x0F, 0x81, 0xE0, 0x00, + 0xF8, 0x3C, 0x00, 0x0F, 0x87, 0x80, 0x00, 0xF8, 0xF0, 0x00, 0x0F, 0x9E, + 0x00, 0x00, 0xFC, 0xF0, 0x00, 0x07, 0x80, 0x00, 0x3C, 0x00, 0x01, 0xE0, + 0x00, 0x0F, 0x00, 0x00, 0x78, 0x00, 0x03, 0xC0, 0x00, 0x1E, 0x00, 0x00, + 0xF0, 0x00, 0x07, 0x80, 0x00, 0x3C, 0x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00, 0x0F, + 0xF0, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x03, 0xFF, + 0xFF, 0xC0, 0x07, 0xF0, 0x0F, 0xE0, 0x0F, 0xC0, 0x03, 0xF0, 0x1F, 0x80, + 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x7C, 0x3E, 0x00, 0x00, 0x7C, 0x7C, 0x00, + 0x00, 0x3C, 0x78, 0x00, 0x00, 0x3E, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, + 0x00, 0x1E, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, + 0x00, 0x1E, 0x78, 0x00, 0x00, 0x1E, 0x7C, 0x00, 0x00, 0x3E, 0x3E, 0x00, + 0x00, 0x7C, 0x3E, 0x00, 0x00, 0x7C, 0x1F, 0x80, 0x01, 0xF8, 0x0F, 0xC0, + 0x03, 0xF0, 0x07, 0xF0, 0x0F, 0xE0, 0x03, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, + 0xFF, 0x80, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x00, + 0x1F, 0x80, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, + 0x03, 0xF0, 0x00, 0x00, 0x01, 0xF8, 0xFF, 0xFE, 0x00, 0x1F, 0xFF, 0xF8, + 0x03, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xF8, 0x0F, 0x00, 0x3F, 0x81, 0xE0, + 0x01, 0xF0, 0x3C, 0x00, 0x1F, 0x07, 0x80, 0x01, 0xE0, 0xF0, 0x00, 0x3C, + 0x1E, 0x00, 0x07, 0x83, 0xC0, 0x00, 0xF0, 0x78, 0x00, 0x1E, 0x0F, 0x00, + 0x03, 0xC1, 0xE0, 0x00, 0xF8, 0x3C, 0x00, 0x3E, 0x07, 0x80, 0x1F, 0xC0, + 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFC, 0x03, 0xFF, 0xFE, 0x00, 0x7F, 0xFF, + 0xF0, 0x0F, 0x00, 0x7E, 0x01, 0xE0, 0x03, 0xE0, 0x3C, 0x00, 0x3E, 0x07, + 0x80, 0x07, 0xC0, 0xF0, 0x00, 0x7C, 0x1E, 0x00, 0x07, 0x83, 0xC0, 0x00, + 0xF8, 0x78, 0x00, 0x0F, 0x0F, 0x00, 0x01, 0xF1, 0xE0, 0x00, 0x1E, 0x3C, + 0x00, 0x03, 0xE7, 0x80, 0x00, 0x3E, 0xF0, 0x00, 0x03, 0xDE, 0x00, 0x00, + 0x7C, 0x00, 0xFF, 0x80, 0x07, 0xFF, 0xF8, 0x1F, 0xFF, 0xFC, 0x3F, 0xFF, + 0xFC, 0x3F, 0x00, 0xFC, 0x7C, 0x00, 0x1C, 0x78, 0x00, 0x04, 0xF0, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0xF0, 0x00, 0x00, 0xF0, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0xF8, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x3F, 0xFE, + 0x00, 0x3F, 0xFF, 0xC0, 0x0F, 0xFF, 0xF0, 0x03, 0xFF, 0xF8, 0x00, 0x7F, + 0xFC, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x3F, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x1E, 0xE0, 0x00, 0x3E, 0xFE, 0x01, + 0xFC, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xF8, 0x3F, 0xFF, 0xE0, 0x03, 0xFF, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x3F, 0xC0, 0x00, + 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x3F, 0xC0, + 0x00, 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x3F, + 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, 0x00, + 0x3F, 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, + 0x00, 0x3F, 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x03, 0xFE, 0x00, 0x01, + 0xF7, 0x80, 0x00, 0x79, 0xE0, 0x00, 0x1E, 0x7C, 0x00, 0x0F, 0x8F, 0x80, + 0x07, 0xC3, 0xF8, 0x07, 0xF0, 0x7F, 0xFF, 0xF8, 0x0F, 0xFF, 0xFC, 0x00, + 0xFF, 0xFC, 0x00, 0x0F, 0xFC, 0x00, 0xF0, 0x00, 0x00, 0x1E, 0xF0, 0x00, + 0x00, 0x79, 0xE0, 0x00, 0x00, 0xF3, 0xE0, 0x00, 0x03, 0xE3, 0xC0, 0x00, + 0x07, 0x87, 0x80, 0x00, 0x0F, 0x0F, 0x80, 0x00, 0x3E, 0x0F, 0x00, 0x00, + 0x78, 0x1F, 0x00, 0x01, 0xF0, 0x1E, 0x00, 0x03, 0xC0, 0x3C, 0x00, 0x07, + 0x80, 0x7C, 0x00, 0x1F, 0x00, 0x78, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0x78, + 0x00, 0xF0, 0x01, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x03, 0xE0, 0x0F, 0x80, + 0x03, 0xC0, 0x1E, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x0F, 0x80, 0xF8, 0x00, + 0x0F, 0x01, 0xE0, 0x00, 0x1E, 0x03, 0xC0, 0x00, 0x1E, 0x0F, 0x00, 0x00, + 0x3C, 0x1E, 0x00, 0x00, 0x7C, 0x7C, 0x00, 0x00, 0x78, 0xF0, 0x00, 0x00, + 0xF1, 0xE0, 0x00, 0x01, 0xF7, 0xC0, 0x00, 0x01, 0xEF, 0x00, 0x00, 0x03, + 0xFE, 0x00, 0x00, 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0x07, 0xF0, 0x00, 0x7F, 0x00, 0x00, 0xFE, + 0x00, 0x0F, 0xE0, 0x00, 0x1F, 0x80, 0x00, 0xFC, 0x00, 0x3E, 0x00, 0x01, + 0xF0, 0xF8, 0x00, 0x1F, 0x03, 0xC0, 0x01, 0xF0, 0x1F, 0x00, 0x0F, 0x80, + 0x7C, 0x00, 0xF8, 0x01, 0xE0, 0x0F, 0x80, 0x0F, 0x80, 0x7C, 0x00, 0x3E, + 0x07, 0xC0, 0x00, 0xF0, 0x7C, 0x00, 0x07, 0xC3, 0xE0, 0x00, 0x1F, 0x3E, + 0x00, 0x00, 0xFB, 0xE0, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x7F, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, + 0xFE, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x07, 0xDF, + 0x00, 0x00, 0x3C, 0x7C, 0x00, 0x03, 0xE1, 0xF0, 0x00, 0x3E, 0x0F, 0x80, + 0x03, 0xE0, 0x3E, 0x00, 0x1F, 0x00, 0xF0, 0x01, 0xF0, 0x07, 0xC0, 0x1F, + 0x00, 0x1F, 0x00, 0xF8, 0x00, 0x78, 0x0F, 0x80, 0x03, 0xE0, 0xF8, 0x00, + 0x0F, 0x87, 0xC0, 0x00, 0x3C, 0x7C, 0x00, 0x01, 0xF7, 0xC0, 0x00, 0x07, + 0xC0, 0xF8, 0x00, 0x01, 0xF7, 0xC0, 0x00, 0x3E, 0x3E, 0x00, 0x07, 0xC3, + 0xE0, 0x00, 0x7C, 0x1F, 0x00, 0x0F, 0x80, 0xF8, 0x01, 0xF0, 0x0F, 0x80, + 0x1F, 0x00, 0x7C, 0x03, 0xE0, 0x03, 0xE0, 0x7C, 0x00, 0x3E, 0x07, 0xC0, + 0x01, 0xF0, 0xF8, 0x00, 0x0F, 0x9F, 0x00, 0x00, 0xF9, 0xF0, 0x00, 0x07, + 0xFE, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x1F, 0x80, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0x7F, 0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xE7, 0xFF, + 0xFF, 0xFE, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, + 0x80, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, + 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x3E, + 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x00, 0x00, + 0x01, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, + 0x00, 0x00, 0x1F, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, + 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x03, 0xF0, + 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF,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x00, + 0x07, 0xE0, 0x00, 0x03, 0xF0, 0x00, 0x03, 0xF8, 0x00, 0x01, 0xFE, 0x00, + 0x01, 0xFF, 0x80, 0x01, 0xF7, 0xC0, 0x01, 0xF1, 0xF0, 0x00, 0xF8, 0x7C, + 0x00, 0xF8, 0x3E, 0x00, 0xF8, 0x0F, 0x80, 0xF8, 0x03, 0xE0, 0x7C, 0x00, + 0xF8, 0x7C, 0x00, 0x7C, 0x7C, 0x00, 0x1F, 0x7C, 0x00, 0x07, 0xC0, 0xF8, + 0x00, 0x0F, 0xBC, 0x00, 0x07, 0x9E, 0x00, 0x03, 0xCF, 0x80, 0x03, 0xE3, + 0xC0, 0x01, 0xE1, 0xF0, 0x01, 0xF0, 0x78, 0x00, 0xF0, 0x3C, 0x00, 0x78, + 0x1F, 0x00, 0x7C, 0x07, 0x80, 0x3C, 0x03, 0xE0, 0x3E, 0x00, 0xF0, 0x1E, + 0x00, 0x78, 0x0F, 0x00, 0x3E, 0x0F, 0x80, 0x0F, 0x07, 0x80, 0x07, 0xC7, + 0xC0, 0x01, 0xE3, 0xC0, 0x00, 0xF1, 0xE0, 0x00, 0x7D, 0xE0, 0x00, 0x1E, + 0xF0, 0x00, 0x0F, 0xF8, 0x00, 0x03, 0xF8, 0x00, 0x01, 0xFC, 0x00, 0x00, + 0xFC, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x0F, 0x80, 0x00, 0x07, 0x80, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xE0, 0x00, + 0x07, 0xE0, 0x00, 0x3F, 0xF0, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, + 0x07, 0xE0, 0x00, 0x00, 0x7F, 0xFF, 0xFB, 0xFF, 0xFF, 0xDF, 0xFF, 0xFE, + 0xFF, 0xFF, 0xF0, 0x00, 0x1F, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x00, + 0xF8, 0x00, 0x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E, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00, 0x78, + 0x00, 0x1E, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00, 0x78, 0x00, 0x1E, 0x00, + 0x07, 0x80, 0x01, 0xE0, 0x00, 0x7C, 0x00, 0x0F, 0x80, 0x03, 0xFF, 0x00, + 0x3F, 0xC0, 0x0F, 0xF0, 0x07, 0xFC, 0x03, 0xF0, 0x01, 0xF0, 0x00, 0x7C, + 0x00, 0x1E, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00, 0x78, 0x00, 0x1E, 0x00, + 0x07, 0x80, 0x01, 0xE0, 0x00, 0x78, 0x00, 0x1E, 0x00, 0x07, 0x80, 0x01, + 0xE0, 0x00, 0xF8, 0x00, 0x7E, 0x03, 0xFF, 0x00, 0xFF, 0xC0, 0x3F, 0xE0, + 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x47, 0xFF, + 0x80, 0x0E, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x0F, 0xFF, + 0xFB, 0x80, 0x0F, 0xFF, 0x18, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0xF8, 0x00, 0x07, 0xFF, 0xC0, 0x03, 0xFF, 0xF8, 0x03, 0xFF, + 0xFF, 0x00, 0xFC, 0x07, 0xC0, 0x7C, 0x00, 0x70, 0x3E, 0x00, 0x0C, 0x0F, + 0x00, 0x01, 0x07, 0xC0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x3E, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x0F, 0xFF, 0xFF, + 0x80, 0x3C, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x7F, 0xFF, 0xC0, 0x1F, 0xFF, 0xE0, 0x0F, + 0xFF, 0xF8, 0x00, 0x3E, 0x00, 0x00, 0x07, 0x80, 0x00, 0x01, 0xE0, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x40, 0xF8, + 0x00, 0x30, 0x1F, 0x80, 0x1C, 0x03, 0xF8, 0x1F, 0x00, 0x7F, 0xFF, 0xC0, + 0x0F, 0xFF, 0xE0, 0x01, 0xFF, 0xF0, 0x00, 0x0F, 0xE0, 0x3C, 0xF3, 0xCF, + 0x3C, 0xE7, 0x9C, 0x73, 0xCE, 0x00, 0x00, 0x0F, 0xF0, 0x03, 0xFF, 0x00, + 0x7F, 0xF0, 0x07, 0xFF, 0x00, 0xF8, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x0F, 0xFF, 0xE0, 0xFF, 0xFE, + 0x0F, 0xFF, 0xE0, 0xFF, 0xFE, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, + 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, + 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x01, 0xF0, + 0x00, 0x3E, 0x00, 0xFF, 0xE0, 0x0F, 0xFC, 0x00, 0xFF, 0x80, 0x0F, 0xF0, + 0x00, 0x3C, 0x1E, 0x78, 0x3C, 0xF0, 0x79, 0xE0, 0xF3, 0xC1, 0xE7, 0x03, + 0x9E, 0x0F, 0x38, 0x1C, 0x70, 0x39, 0xE0, 0xF3, 0x81, 0xC0, 0xF0, 0x00, + 0xF0, 0x00, 0xFF, 0x00, 0x0F, 0x00, 0x0F, 0xF0, 0x00, 0xF0, 0x00, 0xFF, + 0x00, 0x0F, 0x00, 0x0F, 0xF0, 0x00, 0xF0, 0x00, 0xFF, 0x00, 0x0F, 0x00, + 0x0F, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, + 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, + 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, + 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, + 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xF0, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x00, + 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x07, 0xE0, 0x00, 0x0E, 0x00, 0x00, 0x00, + 0x07, 0xFE, 0x00, 0x07, 0x80, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x01, 0xC0, + 0x00, 0x00, 0x01, 0xF0, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x78, 0x1E, + 0x00, 0x38, 0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x1E, 0x00, 0x00, 0x00, + 0x0F, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x3C, 0x03, 0x80, + 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x3C, 0x03, + 0xC0, 0x70, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x3C, 0x00, 0x00, 0x00, + 0x03, 0xC0, 0x3C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x1E, 0x07, 0x83, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x81, + 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xF0, 0xF8, 0x78, 0x00, 0x00, 0x00, + 0x00, 0x3F, 0xFC, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFE, 0x0F, 0x03, + 0xF0, 0x00, 0x7E, 0x00, 0x7E, 0x07, 0x83, 0xFF, 0x00, 0x7F, 0xE0,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 0x00, + 0xF0, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0x03, 0xE1, 0xF7, 0xC3, 0xEF, 0x87, + 0xDF, 0x0F, 0xBE, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x01, 0xE0, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x00, + 0x00, 0xF1, 0xFC, 0x00, 0x03, 0xC3, 0xF8, 0x00, 0x0F, 0x07, 0xF0, 0x00, + 0x1C, 0x1F, 0xF0, 0x00, 0x00, 0x3D, 0xE0, 0x00, 0x00, 0xFB, 0xE0, 0x00, + 0x01, 0xE3, 0xC0, 0x00, 0x03, 0xC7, 0x80, 0x00, 0x0F, 0x8F, 0x80, 0x00, + 0x1E, 0x0F, 0x00, 0x00, 0x3C, 0x1E, 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x01, + 0xE0, 0x3C, 0x00, 0x07, 0xC0, 0x7C, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x1E, + 0x00, 0xF0, 0x00, 0x7C, 0x01, 0xF0, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xE0, + 0x03, 0xE0, 0x07, 0x80, 0x03, 0xC0, 0x0F, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, + 0xFF, 0x80, 0x7F, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFE, 0x03, 0xE0, 0x00, + 0x3E, 0x07, 0x80, 0x00, 0x3C, 0x1F, 0x00, 0x00, 0x7C, 0x3C, 0x00, 0x00, + 0x78, 0x78, 0x00, 0x00, 0xF1, 0xF0, 0x00, 0x01, 0xF3, 0xC0, 0x00, 0x01, + 0xE7, 0x80, 0x00, 0x03, 0xDE, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x1F, 0xF0, + 0x01, 0xFF, 0xF0, 0x0F, 0xFF, 0xC0, 0x7F, 0xFF, 0x03, 0xF0, 0x0C, 0x0F, + 0x80, 0x00, 0x3C, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0x00, + 0x00, 0x78, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0x00, 0x00, + 0x78, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x03, 0xFF, 0xFF, 0x0F, 0xFF, + 0xFC, 0x3F, 0xFF, 0xF0, 0xFF, 0xFF, 0xC0, 0x1E, 0x00, 0x00, 0x78, 0x00, + 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x01, + 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x3F, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20, 0x00, + 0x01, 0x1C, 0x00, 0x00, 0xEF, 0x80, 0x00, 0x7D, 0xF0, 0xFC, 0x3E, 0x3E, + 0xFF, 0xDF, 0x07, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xC0, 0x1F, 0x87, 0xE0, + 0x0F, 0x80, 0x7C, 0x03, 0xC0, 0x0F, 0x01, 0xF0, 0x03, 0xE0, 0x78, 0x00, + 0x78, 0x1E, 0x00, 0x1E, 0x07, 0x80, 0x07, 0x81, 0xE0, 0x01, 0xE0, 0x7C, + 0x00, 0xF8, 0x0F, 0x00, 0x3C, 0x03, 0xE0, 0x1F, 0x00, 0x7E, 0x1F, 0x80, + 0x3F, 0xFF, 0xF0, 0x1F, 0xFF, 0xFE, 0x0F, 0xBF, 0xF7, 0xC7, 0xC3, 0xF0, + 0xFB, 0xE0, 0x00, 0x1F, 0x70, 0x00, 0x03, 0x88, 0x00, 0x00, 0x40, 0xF8, + 0x00, 0x07, 0xDE, 0x00, 0x01, 0xE7, 0xC0, 0x00, 0xF8, 0xF8, 0x00, 0x7C, + 0x1E, 0x00, 0x1E, 0x07, 0xC0, 0x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, 0x00, 0x1E, 0x00, 0x03, 0xE0, + 0x00, 0x3C, 0x00, 0x07, 0x80, 0x00, 0xF0, 0x80, 0x3E, 0x1E, 0x0F, 0x83, + 0xFF, 0xE0, 0x7F, 0xF8, 0x03, 0xFC, 0x00, 0xF8, 0x7F, 0xE1, 0xFF, 0x87, + 0xFE, 0x1F, 0xF8, 0x7C, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x0F, 0xFF, 0xC0, + 0x00, 0x0F, 0x80, 0x7C, 0x00, 0x07, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, + 0x70, 0x01, 0x80, 0x00, 0x06, 0x00, 0xC0, 0x3F, 0xC0, 0xC0, 0x60, 0x3F, + 0xFC, 0x18, 0x38, 0x3F, 0xFF, 0x07, 0x0C, 0x1F, 0x80, 0xC0, 0xC6, 0x07, + 0xC0, 0x00, 0x19, 0x83, 0xE0, 0x00, 0x06, 0x60, 0xF0, 0x00, 0x01, 0xB0, + 0x7C, 0x00, 0x00, 0x3C, 0x1E, 0x00, 0x00, 0x0F, 0x07, 0x80, 0x00, 0x03, + 0xC1, 0xE0, 0x00, 0x00, 0xF0, 0x78, 0x00, 0x00, 0x3C, 0x1E, 0x00, 0x00, + 0x0F, 0x07, 0x80, 0x00, 0x03, 0xC1, 0xF0, 0x00, 0x00, 0xD8, 0x3C, 0x00, + 0x00, 0x66, 0x0F, 0x80, 0x00, 0x19, 0x81, 0xF0, 0x00, 0x06, 0x30, 0x7E, + 0x03, 0x03, 0x0E, 0x0F, 0xFF, 0xC1, 0xC1, 0x80, 0xFF, 0xF0, 0x60, 0x30, + 0x0F, 0xF0, 0x30, 0x06, 0x00, 0x00, 0x18, 0x00, 0xE0, 0x00, 0x1C, 0x00, + 0x1C, 0x00, 0x0E, 0x00, 0x03, 0xE0, 0x1F, 0x00, 0x00, 0x3F, 0xFF, 0x00, + 0x00, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x08, 0x03, 0x00, 0xC0, 0x38, + 0x0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x00, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x00, + 0x00, 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xC3, 0xFF, 0xCF, 0xFF, 0xB0, + 0x1F, 0x00, 0x3C, 0x00, 0x70, 0x01, 0xC0, 0x0E, 0x00, 0x78, 0x03, 0xC0, + 0x1E, 0x00, 0xF0, 0x07, 0x80, 0x3C, 0x03, 0xE0, 0x1E, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xC0, 0x1F, 0xC1, 0xFF, 0xC7, 0xFF, 0x98, 0x0F, 0x00, + 0x1C, 0x00, 0x70, 0x03, 0x83, 0xFE, 0x0F, 0xE0, 0x3F, 0xE0, 0x07, 0x80, + 0x07, 0x00, 0x1C, 0x00, 0x70, 0x03, 0xF0, 0x1F, 0xFF, 0xFB, 0xFF, 0xC3, + 0xFC, 0x00, 0x03, 0xE0, 0xF8, 0x1E, 0x07, 0x81, 0xE0, 0x78, 0x0F, 0x03, + 0xC0, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0xF8, 0x01, 0xE0, 0x07, 0x80, 0x1E, + 0x00, 0x78, 0x00, 0xF0, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0x03, 0xE1, 0xF7, + 0xC3, 0xEF, 0x87, 0xDF, 0x0F, 0xBE, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x01, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, + 0x7C, 0x7C, 0x00, 0x00, 0xF1, 0xFC, 0x00, 0x03, 0xC3, 0xF8, 0x00, 0x0F, + 0x07, 0xF0, 0x00, 0x1C, 0x1F, 0xF0, 0x00, 0x00, 0x3D, 0xE0, 0x00, 0x00, + 0xFB, 0xE0, 0x00, 0x01, 0xE3, 0xC0, 0x00, 0x03, 0xC7, 0x80, 0x00, 0x0F, + 0x8F, 0x80, 0x00, 0x1E, 0x0F, 0x00, 0x00, 0x3C, 0x1E, 0x00, 0x00, 0xF0, + 0x1E, 0x00, 0x01, 0xE0, 0x3C, 0x00, 0x07, 0xC0, 0x7C, 0x00, 0x0F, 0x00, + 0x78, 0x00, 0x1E, 0x00, 0xF0, 0x00, 0x7C, 0x01, 0xF0, 0x00, 0xF0, 0x01, + 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x07, 0x80, 0x03, 0xC0, 0x0F, 0xFF, 0xFF, + 0x80, 0x3F, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFE, + 0x03, 0xE0, 0x00, 0x3E, 0x07, 0x80, 0x00, 0x3C, 0x1F, 0x00, 0x00, 0x7C, + 0x3C, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, 0xF1, 0xF0, 0x00, 0x01, 0xF3, + 0xC0, 0x00, 0x01, 0xE7, 0x80, 0x00, 0x03, 0xDE, 0x00, 0x00, 0x03, 0xC0, + 0xFF, 0xFF, 0xFF, 0x03, 0xC0, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x1E, + 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xE7, 0xFF, 0xFF, 0xE7, 0x8F, + 0xFF, 0xFF, 0xCF, 0x1F, 0xFF, 0xFF, 0xBC, 0x3F, 0xFF, 0xFF, 0xF0, 0x78, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1E, 0x00, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x03, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, + 0xC0, 0x0F, 0xFF, 0xFF, 0x80, 0x1E, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, + 0x03, 0xC0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF8, 0x03, 0xFF, 0xFF, 0xF0, 0x07, + 0xFF, 0xFF, 0xE0, 0x0F, 0xFF, 0xFF, 0xC0, 0x03, 0xE0, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, + 0x01, 0xE7, 0x80, 0x00, 0x1E, 0x3C, 0xF0, 0x00, 0x03, 0xCF, 0x1E, 0x00, + 0x00, 0x7B, 0xC3, 0xC0, 0x00, 0x0F, 0x70, 0x78, 0x00, 0x01, 0xE0, 0x0F, + 0x00, 0x00, 0x3C, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x00, 0xF0, + 0x07, 0x80, 0x00, 0x1E, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x1E, 0x00, 0x00, + 0x78, 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x01, 0xE0, 0x0F, 0x00, + 0x00, 0x3C, 0x01, 0xFF, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0xFF, 0xF0, 0x07, + 0xFF, 0xFF, 0xFE, 0x00, 0xFF, 0xFF, 0xFF, 0xC0, 0x1E, 0x00, 0x00, 0x78, + 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x01, 0xE0, 0x0F, 0x00, 0x00, + 0x3C, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x00, 0xF0, 0x07, 0x80, + 0x00, 0x1E, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x1E, 0x00, 0x00, 0x78, 0x03, + 0xC0, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x01, 0xE0, 0x0F, 0x00, 0x00, 0x3C, + 0x01, 0xE0, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, + 0x1E, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x03, 0xE0, 0x3E, 0x01, 0xE0, 0x1E, + 0x01, 0xE7, 0x8E, 0x3C, 0xF1, 0xEF, 0x0F, 0xF0, 0x78, 0x03, 0xC0, 0x1E, + 0x00, 0xF0, 0x07, 0x80, 0x3C, 0x01, 0xE0, 0x0F, 0x00, 0x78, 0x03, 0xC0, + 0x1E, 0x00, 0xF0, 0x07, 0x80, 0x3C, 0x01, 0xE0, 0x0F, 0x00, 0x78, 0x03, + 0xC0, 0x1E, 0x00, 0xF0, 0x07, 0x80, 0x3C, 0x01, 0xE0, 0x0F, 0x00, 0x78, + 0x03, 0xC0, 0x1E, 0x00, 0xF0, 0x07, 0x80, 0x3C, 0x80, 0x20, 0x06, 0x01, + 0x80, 0x38, 0x0E, 0x01, 0xE0, 0x78, 0x07, 0x81, 0xE0, 0x1E, 0x07, 0x80, + 0x78, 0x1E, 0x01, 0xF0, 0x7C, 0x07, 0xC1, 0xF0, 0x1F, 0x07, 0xC0, 0x78, + 0x1E, 0x07, 0xC1, 0xF0, 0x7C, 0x1F, 0x07, 0xC1, 0xF0, 0x78, 0x1E, 0x07, + 0x81, 0xE0, 0x78, 0x1E, 0x07, 0x81, 0xE0, 0x38, 0x0E, 0x01, 0x80, 0x60, + 0x08, 0x02, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0xF0, 0x00, 0x1E, 0x07, + 0xFF, 0xE0, 0x01, 0xE1, 0xFF, 0xFF, 0x80, 0x3C, 0x3F, 0xFF, 0xFC, 0x07, + 0x87, 0xF0, 0x0F, 0xE0, 0x70, 0xFC, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x01, + 0xF8, 0x03, 0xE0, 0x00, 0x0F, 0x80, 0x3E, 0x00, 0x00, 0x7C, 0x07, 0xC0, + 0x00, 0x03, 0xC0, 0x78, 0x00, 0x00, 0x3E, 0x07, 0x80, 0x00, 0x01, 0xE0, + 0xF8, 0x00, 0x00, 0x1E, 0x0F, 0x00, 0x00, 0x01, 0xF0, 0xF0, 0x00, 0x00, + 0x0F, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x0F, 0x0F, 0x00, + 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0xF0, + 0xF0, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, + 0x1F, 0x0F, 0x80, 0x00, 0x01, 0xE0, 0x78, 0x00, 0x00, 0x1E, 0x07, 0x80, + 0x00, 0x03, 0xE0, 0x7C, 0x00, 0x00, 0x3C, 0x03, 0xE0, 0x00, 0x07, 0xC0, + 0x3E, 0x00, 0x00, 0xF8, 0x01, 0xF0, 0x00, 0x1F, 0x80, 0x0F, 0xC0, 0x03, + 0xF0, 0x00, 0x7F, 0x00, 0xFE, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 0x1F, + 0xFF, 0xF8, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0x1E, 0x01, 0xFE, 0x00, 0x00, 0x78, 0x03, 0xFC, 0x00, + 0x00, 0xE0, 0x07, 0x38, 0x00, 0x03, 0xC0, 0x00, 0x70, 0x00, 0x07, 0x00, + 0x00, 0xE0, 0x00, 0x1E, 0x00, 0x01, 0xC0, 0x00, 0x78, 0x00, 0x03, 0x80, + 0x00, 0xE0, 0x00, 0x07, 0x00, 0x03, 0xC0, 0x00, 0x0E, 0x00, 0x07, 0x00, + 0x00, 0x1C, 0x00, 0x1E, 0x00, 0x00, 0x38, 0x00, 0x78, 0x00, 0x00, 0x70, + 0x00, 0xE0, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x00, 0x01, 0xC0, 0x07, 0x00, + 0x00, 0x03, 0x80, 0x1E, 0x0F, 0xF0, 0xFF, 0xF8, 0x78, 0x7F, 0xF9, 0xFF, + 0xF0, 0xE0, 0xFF, 0xFB, 0xFF, 0xE3, 0xC1, 0x80, 0xF0, 0x00, 0x07, 0x00, + 0x00, 0xF0, 0x00, 0x1E, 0x00, 0x00, 0xE0, 0x00, 0x78, 0x00, 0x01, 0x80, + 0x00, 0xE0, 0x00, 0x07, 0x00, 0x03, 0xC0, 0x00, 0x1C, 0x00, 0x07, 0x00, + 0x00, 0x78, 0x00, 0x1E, 0x00, 0x01, 0xE0, 0x00, 0x38, 0x00, 0x07, 0x80, + 0x00, 0xE0, 0x00, 0x1E, 0x00, 0x03, 0xC0, 0x00, 0xF8, 0x00, 0x07, 0x00, + 0x03, 0xE0, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x00, 0x38, 0x00, 0x3F, 0xFF, + 0x00, 0xE0, 0x00, 0x7F, 0xFE, 0x03, 0xC0, 0x00, 0xFF, 0xFC, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, + 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x00, 0x1E, 0x3E, 0x00, 0x00, 0x78, 0xF0, 0x7C, 0x00, 0x03, + 0xE3, 0x81, 0xF0, 0x00, 0x1F, 0x1E, 0x03, 0xE0, 0x00, 0x78, 0xF0, 0x07, + 0xC0, 0x03, 0xE0, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x3E, 0x00, 0x78, + 0x00, 0x00, 0x7C, 0x03, 0xE0, 0x00, 0x00, 0xF0, 0x1F, 0x00, 0x00, 0x03, + 0xE0, 0x78, 0x00, 0x00, 0x07, 0xC3, 0xE0, 0x00, 0x00, 0x0F, 0x1F, 0x00, + 0x00, 0x00, 0x3E, 0x78, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x03, 0xC0, 0x00, + 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0xF0, + 0x0F, 0xF8, 0x00, 0x1E, 0x07, 0xFF, 0xE0, 0x03, 0xC1, 0xFF, 0xFF, 0x80, + 0x78, 0x3F, 0xFF, 0xFE, 0x07, 0x07, 0xF8, 0x0F, 0xF0, 0xF0, 0xFC, 0x00, + 0x3F, 0x80, 0x1F, 0x80, 0x00, 0xF8, 0x03, 0xE0, 0x00, 0x07, 0xC0, 0x3E, + 0x00, 0x00, 0x3E, 0x07, 0xC0, 0x00, 0x01, 0xE0, 0x78, 0x00, 0x00, 0x1E, + 0x07, 0x80, 0x00, 0x01, 0xF0, 0x78, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0xF0, + 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x0F, + 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x78, 0x00, 0x00, 0x0F, 0x07, 0x80, 0x00, + 0x01, 0xF0, 0x78, 0x00, 0x00, 0x1E, 0x03, 0xC0, 0x00, 0x01, 0xE0, 0x3C, + 0x00, 0x00, 0x3E, 0x01, 0xE0, 0x00, 0x07, 0xC0, 0x1F, 0x00, 0x00, 0x78, + 0x00, 0xF8, 0x00, 0x0F, 0x80, 0x07, 0xC0, 0x01, 0xF0, 0x00, 0x3E, 0x00, + 0x3E, 0x00, 0x01, 0xF0, 0x0F, 0xC0, 0x0F, 0xFF, 0x81, 0xFF, 0xF0, 0xFF, + 0xF8, 0x1F, 0xFF, 0x0F, 0xFF, 0x81, 0xFF, 0xF0, 0xFF, 0xF8, 0x1F, 0xFF, + 0x00, 0x3E, 0x00, 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x3C, 0x00, + 0xF0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x03, 0xE1, 0xF7, 0xC3, 0xEF, 0x87, + 0xDF, 0x0F, 0xBE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0x80, 0x0F, 0x00, 0x1E, + 0x00, 0x3C, 0x00, 0x78, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0x80, + 0x0F, 0x00, 0x1E, 0x00, 0x3C, 0x00, 0x78, 0x00, 0xF0, 0x01, 0xE0, 0x03, + 0xC0, 0x03, 0xC0, 0x07, 0x80, 0x0F, 0x80, 0x1F, 0xF0, 0x1F, 0xE0, 0x1F, + 0xC0, 0x0F, 0x80, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, + 0x3F, 0x80, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x03, + 0xDE, 0x00, 0x00, 0x0F, 0xBE, 0x00, 0x00, 0x1E, 0x3C, 0x00, 0x00, 0x3C, + 0x78, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x01, 0xE0, 0xF0, 0x00, 0x03, 0xC1, + 0xE0, 0x00, 0x0F, 0x01, 0xE0, 0x00, 0x1E, 0x03, 0xC0, 0x00, 0x7C, 0x07, + 0xC0, 0x00, 0xF0, 0x07, 0x80, 0x01, 0xE0, 0x0F, 0x00, 0x07, 0xC0, 0x1F, + 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x78, 0x00, 0x3C, + 0x00, 0xFF, 0xFF, 0xF8, 0x03, 0xFF, 0xFF, 0xF8, 0x07, 0xFF, 0xFF, 0xF0, + 0x0F, 0xFF, 0xFF, 0xE0, 0x3E, 0x00, 0x03, 0xE0, 0x78, 0x00, 0x03, 0xC1, + 0xF0, 0x00, 0x07, 0xC3, 0xC0, 0x00, 0x07, 0x87, 0x80, 0x00, 0x0F, 0x1F, + 0x00, 0x00, 0x1F, 0x3C, 0x00, 0x00, 0x1E, 0x78, 0x00, 0x00, 0x3D, 0xE0, + 0x00, 0x00, 0x3C, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 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0x80, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, + 0x3F, 0x80, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x01, 0xEF, 0x00, 0x00, 0x03, + 0xDE, 0x00, 0x00, 0x0F, 0xBE, 0x00, 0x00, 0x1E, 0x3C, 0x00, 0x00, 0x3C, + 0x78, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x01, 0xE0, 0xF0, 0x00, 0x03, 0xC1, + 0xE0, 0x00, 0x0F, 0x01, 0xE0, 0x00, 0x1E, 0x03, 0xC0, 0x00, 0x7C, 0x07, + 0xC0, 0x00, 0xF0, 0x07, 0x80, 0x01, 0xE0, 0x0F, 0x00, 0x07, 0xC0, 0x1F, + 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x78, 0x00, 0x3C, + 0x00, 0xF0, 0x00, 0x78, 0x03, 0xE0, 0x00, 0xF8, 0x07, 0x80, 0x00, 0xF0, + 0x0F, 0x00, 0x01, 0xE0, 0x3E, 0x00, 0x01, 0xE0, 0x78, 0x00, 0x03, 0xC1, + 0xF0, 0x00, 0x07, 0xC3, 0xC0, 0x00, 0x07, 0x87, 0x80, 0x00, 0x0F, 0x1F, + 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xFD, 0xFF, + 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, + 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x0F, 0xFF, 0xFF, 0xBF, 0xFF, 0xFE, 0xFF, + 0xFF, 0xFB, 0xFF, 0xFF, 0xEF, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, + 0x03, 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x03, + 0xC0, 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, + 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0x7F, 0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xE7, + 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x1F, 0x80, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, + 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x01, 0xF0, 0x00, 0x00, + 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x01, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, + 0xF8, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x3E, 0x00, + 0x00, 0x07, 0xC0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x03, + 0xF0, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x3F, 0xC0, 0x00, + 0x0F, 0xF0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x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F, 0x9E, + 0x00, 0x00, 0xFC, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, + 0x3F, 0x80, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x01, 0xEF, 0x00, 0x00, 0x03, + 0xDE, 0x00, 0x00, 0x0F, 0xBE, 0x00, 0x00, 0x1E, 0x3C, 0x00, 0x00, 0x3C, + 0x78, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x01, 0xE0, 0xF0, 0x00, 0x03, 0xC1, + 0xE0, 0x00, 0x0F, 0x01, 0xE0, 0x00, 0x1E, 0x03, 0xC0, 0x00, 0x7C, 0x07, + 0xC0, 0x00, 0xF0, 0x07, 0x80, 0x01, 0xE0, 0x0F, 0x00, 0x07, 0xC0, 0x1F, + 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x78, 0x00, 0x3C, + 0x00, 0xF0, 0x00, 0x78, 0x03, 0xE0, 0x00, 0xF8, 0x07, 0x80, 0x00, 0xF0, + 0x0F, 0x00, 0x01, 0xE0, 0x3E, 0x00, 0x03, 0xE0, 0x78, 0x00, 0x03, 0xC1, + 0xF0, 0x00, 0x07, 0xC3, 0xC0, 0x00, 0x07, 0x87, 0x80, 0x00, 0x0F, 0x1F, + 0x00, 0x00, 0x1F, 0x3C, 0x00, 0x00, 0x1E, 0x78, 0x00, 0x00, 0x3D, 0xE0, + 0x00, 0x00, 0x3C, 0xFE, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x01, 0xFF, 0xFC, + 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x1F, 0xFE, 0xF0, + 0x00, 0x7B, 0xFD, 0xE0, 0x00, 0xF7, 0xFB, 0xE0, 0x03, 0xEF, 0xF3, 0xC0, + 0x07, 0x9F, 0xE7, 0x80, 0x0F, 0x3F, 0xC7, 0x80, 0x3C, 0x7F, 0x8F, 0x00, + 0x78, 0xFF, 0x1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xFC, 0x00, 0x0F, 0xFF, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x7F, 0xF0, + 0x00, 0x1F, 0xFC, 0x00, 0x03, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x87, 0xFF, 0xFC, + 0x3F, 0xFF, 0xE1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, + 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x80, + 0x03, 0xFF, 0xFF, 0xC0, 0x07, 0xF0, 0x0F, 0xE0, 0x0F, 0xC0, 0x03, 0xF0, + 0x1F, 0x80, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x7C, 0x3E, 0x00, 0x00, 0x7C, + 0x7C, 0x00, 0x00, 0x3C, 0x78, 0x00, 0x00, 0x3E, 0x78, 0x00, 0x00, 0x1E, + 0x78, 0x00, 0x00, 0x1E, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, + 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, + 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 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, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, + 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x00, + 0x01, 0xF7, 0xC0, 0x00, 0x3E, 0x3E, 0x00, 0x07, 0xC3, 0xE0, 0x00, 0x7C, + 0x1F, 0x00, 0x0F, 0x80, 0xF8, 0x01, 0xF0, 0x0F, 0x80, 0x1F, 0x00, 0x7C, + 0x03, 0xE0, 0x03, 0xE0, 0x7C, 0x00, 0x3E, 0x07, 0xC0, 0x01, 0xF0, 0xF8, + 0x00, 0x0F, 0x9F, 0x00, 0x00, 0xF9, 0xF0, 0x00, 0x07, 0xFE, 0x00, 0x00, + 0x3F, 0xC0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 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, 0x03, 0xC0, + 0x0F, 0x78, 0x03, 0xC0, 0x1E, 0x78, 0x03, 0xC0, 0x1E, 0x78, 0x03, 0xC0, + 0x1E, 0x7C, 0x03, 0xC0, 0x3C, 0x3E, 0x03, 0xC0, 0x7C, 0x3E, 0x03, 0xC0, + 0x7C, 0x1F, 0x03, 0xC0, 0xF8, 0x0F, 0xC3, 0xC3, 0xF0, 0x07, 0xF3, 0xCF, + 0xE0, 0x03, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0xFF, 0xFF, + 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, + 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x0F, 0xF0, + 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x03, 0xFF, 0xFF, + 0xC0, 0x07, 0xF0, 0x0F, 0xE0, 0x0F, 0xC0, 0x03, 0xF0, 0x1F, 0x00, 0x00, + 0xF8, 0x3E, 0x00, 0x00, 0x7C, 0x3C, 0x00, 0x00, 0x3C, 0x7C, 0x00, 0x00, + 0x3E, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, 0x00, 0x1E, 0xF0, 0x00, 0x00, + 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, + 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, + 0x0F, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x1F, 0x78, 0x00, 0x00, + 0x1E, 0x78, 0x00, 0x00, 0x1E, 0x7C, 0x00, 0x00, 0x3E, 0x3C, 0x00, 0x00, + 0x3C, 0x3E, 0x00, 0x00, 0x7C, 0x1E, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, + 0xF0, 0x0F, 0x80, 0x01, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xF0, 0x0F, + 0xC0, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xF8, 0x1F, + 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xF8, 0x7F, 0xE1, 0xFF, 0x87, 0xFE, 0x1F, + 0xF8, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, + 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, + 0x00, 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x78, 0x01, 0xE0, 0x07, + 0x80, 0x1E, 0x00, 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x78, 0x01, + 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, + 0x78, 0x01, 0xE0, 0x07, 0x80, 0x1E, 0x00, 0x78, 0x01, 0xE0, 0x01, 0xF0, + 0xF8, 0x00, 0x1F, 0x0F, 0x80, 0x01, 0xF0, 0xF8, 0x00, 0x1F, 0x0F, 0x80, + 0x01, 0xF0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x01, + 0xF7, 0xC0, 0x00, 0x3E, 0x3E, 0x00, 0x07, 0xC3, 0xE0, 0x00, 0x7C, 0x1F, + 0x00, 0x0F, 0x80, 0xF8, 0x01, 0xF0, 0x0F, 0x80, 0x1F, 0x00, 0x7C, 0x03, + 0xE0, 0x03, 0xE0, 0x7C, 0x00, 0x3E, 0x07, 0xC0, 0x01, 0xF0, 0xF8, 0x00, + 0x0F, 0x9F, 0x00, 0x00, 0xF9, 0xF0, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x3F, + 0xC0, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0xF0, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, + 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x00, + 0x00, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x0F, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x03, 0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x70, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x07, + 0xFF, 0x07, 0x83, 0xFF, 0xE3, 0xE1, 0xFF, 0xFC, 0xF0, 0xFC, 0x3F, 0x3C, + 0x3C, 0x03, 0xDF, 0x1F, 0x00, 0xFF, 0x87, 0x80, 0x1F, 0xE1, 0xE0, 0x07, + 0xF8, 0xF8, 0x01, 0xFC, 0x3C, 0x00, 0x7F, 0x0F, 0x00, 0x0F, 0x83, 0xC0, + 0x03, 0xE0, 0xF0, 0x00, 0xF8, 0x3C, 0x00, 0x3C, 0x0F, 0x00, 0x0F, 0x03, + 0xC0, 0x03, 0xE0, 0xF0, 0x01, 0xF8, 0x3C, 0x00, 0x7E, 0x07, 0x80, 0x1F, + 0x81, 0xE0, 0x0F, 0xE0, 0x7C, 0x03, 0xFC, 0x0F, 0x81, 0xFF, 0x83, 0xF0, + 0xFB, 0xFC, 0x7F, 0xFE, 0xFF, 0x0F, 0xFF, 0x1F, 0xC1, 0xFF, 0x81, 0xF0, + 0x1F, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xF8, 0x00, 0x3E, 0x00, 0x07, + 0x80, 0x01, 0xE0, 0x00, 0x78, 0x00, 0x0E, 0x00, 0x03, 0xC0, 0x00, 0xF0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0xFF, 0xFC, 0x3F, 0xFF, + 0x8F, 0xFF, 0xF3, 0xF8, 0x06, 0x7C, 0x00, 0x0F, 0x00, 0x01, 0xE0, 0x00, + 0x3C, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x07, 0xC0, 0x00, 0x3F, 0xE0, + 0x0F, 0xFC, 0x03, 0xFF, 0x81, 0xFF, 0xF0, 0x3F, 0x00, 0x0F, 0x80, 0x01, + 0xE0, 0x00, 0x3C, 0x00, 0x07, 0x80, 0x00, 0xF0, 0x00, 0x1F, 0x00, 0x01, + 0xF8, 0x01, 0x9F, 0xFF, 0xF3, 0xFF, 0xFE, 0x1F, 0xFF, 0xC0, 0x7F, 0xE0, + 0x00, 0x00, 0xF0, 0x00, 0x07, 0x80, 0x00, 0x3C, 0x00, 0x01, 0xF0, 0x00, + 0x07, 0x80, 0x00, 0x3C, 0x00, 0x01, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x38, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0xF1, 0xFF, 0xC3, + 0xCF, 0xFF, 0x8F, 0x7F, 0xFF, 0x3F, 0xE0, 0x7E, 0xFE, 0x00, 0xFB, 0xF0, + 0x01, 0xEF, 0x80, 0x07, 0xFE, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xC0, 0x00, + 0xFF, 0x00, 0x03, 0xFC, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xC0, 0x00, 0xFF, + 0x00, 0x03, 0xFC, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xC0, 0x00, 0xFF, 0x00, + 0x03, 0xFC, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xC0, 0x00, 0xFF, 0x00, 0x03, + 0xFC, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xC0, 0x00, 0xF0, 0x00, 0x03, 0xC0, + 0x00, 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x00, + 0x0F, 0x00, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x03, 0xC0, 0x00, 0x0F, + 0x01, 0xE0, 0x3C, 0x07, 0xC0, 0x78, 0x0F, 0x01, 0xE0, 0x1C, 0x03, 0xC0, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, + 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, + 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x00, + 0xF8, 0x07, 0xC0, 0x7F, 0xC3, 0xFC, 0x1F, 0xC0, 0xFC, 0x00, 0x0F, 0x00, + 0x00, 0xF0, 0x00, 0x0F, 0x80, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x78, + 0x00, 0x07, 0x80, 0x00, 0x38, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, + 0x87, 0xC0, 0x7C, 0x3E, 0x03, 0xE1, 0xF0, 0x1F, 0x0F, 0x80, 0xF8, 0x7C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xE3, 0xC0, 0x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, 0x00, 0x00, 0x3F, 0x00, + 0x00, 0x07, 0x80, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x1E, + 0x00, 0x00, 0x07, 0x80, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x07, 0x80, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, + 0x00, 0xFF, 0xC0, 0x03, 0xFF, 0xF0, 0x0F, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, + 0x1F, 0x80, 0x38, 0x1E, 0x00, 0x08, 0x1E, 0x00, 0x00, 0x1E, 0x00, 0x00, + 0x1F, 0x80, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xFF, 0x00, 0x07, 0xFF, 0xC0, + 0x07, 0xFF, 0xF0, 0x1F, 0x1F, 0xF8, 0x1E, 0x01, 0xFC, 0x3C, 0x00, 0x7C, + 0x78, 0x00, 0x3E, 0x78, 0x00, 0x1E, 0x70, 0x00, 0x1F, 0xF0, 0x00, 0x0F, + 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, + 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF8, 0x00, 0x1F, 0x78, 0x00, 0x1E, + 0x78, 0x00, 0x3E, 0x7C, 0x00, 0x3E, 0x3E, 0x00, 0x7C, 0x3F, 0x81, 0xFC, + 0x1F, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x03, 0xFF, 0xC0, 0x00, 0xFF, 0x00, + 0x03, 0xFF, 0x01, 0xFF, 0xF8, 0x7F, 0xFF, 0x1F, 0xFF, 0xE7, 0xF0, 0x0C, + 0xF8, 0x00, 0x1E, 0x00, 0x03, 0xC0, 0x00, 0x78, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x00, 0x0F, 0x80, 0x00, 0x7F, 0xC0, 0x1F, 0xF8, 0x07, 0xFF, 0x03, + 0xFF, 0xE0, 0x7E, 0x00, 0x1F, 0x00, 0x03, 0xC0, 0x00, 0x78, 0x00, 0x0F, + 0x00, 0x01, 0xE0, 0x00, 0x3E, 0x00, 0x03, 0xF0, 0x03, 0x3F, 0xFF, 0xE7, + 0xFF, 0xFC, 0x3F, 0xFF, 0x80, 0xFF, 0xC0, 0x7F, 0xFF, 0xFB, 0xFF, 0xFF, + 0xDF, 0xFF, 0xFE, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0x00, 0x0F, 0xE0, 0x00, + 0xFC, 0x00, 0x1F, 0xC0, 0x01, 0xF8, 0x00, 0x1F, 0x80, 0x01, 0xF8, 0x00, + 0x1F, 0x80, 0x00, 0xF8, 0x00, 0x0F, 0x80, 0x00, 0xF8, 0x00, 0x07, 0x80, + 0x00, 0x7C, 0x00, 0x03, 0xC0, 0x00, 0x1E, 0x00, 0x01, 0xF0, 0x00, 0x0F, + 0x00, 0x00, 0x78, 0x00, 0x03, 0xC0, 0x00, 0x1E, 0x00, 0x00, 0xF0, 0x00, + 0x07, 0x80, 0x00, 0x3C, 0x00, 0x01, 0xF0, 0x00, 0x07, 0x80, 0x00, 0x3E, + 0x00, 0x01, 0xF0, 0x00, 0x07, 0xE0, 0x00, 0x3F, 0xC0, 0x00, 0xFF, 0xFC, + 0x01, 0xFF, 0xF8, 0x07, 0xFF, 0xE0, 0x07, 0xFF, 0x00, 0x00, 0x7C, 0x00, + 0x01, 0xE0, 0x00, 0x0F, 0x00, 0x00, 0x78, 0x00, 0x03, 0xC0, 0x00, 0x3E, + 0x00, 0x07, 0xE0, 0x00, 0x3F, 0x00, 0x01, 0xF0, 0x00, 0x0E, 0x00, 0x00, + 0x7F, 0x03, 0xC7, 0xFF, 0x0F, 0x3F, 0xFE, 0x3D, 0xFF, 0xFC, 0xFF, 0x81, + 0xFB, 0xF8, 0x03, 0xEF, 0xC0, 0x07, 0xBE, 0x00, 0x1F, 0xF8, 0x00, 0x3F, + 0xC0, 0x00, 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, 0x83, 0xC0, 0x07, 0x81, 0xE0, 0x07, 0xC0, 0xF8, 0x03, + 0xC0, 0x3C, 0x03, 0xE0, 0x1F, 0x01, 0xE0, 0x07, 0x80, 0xF0, 0x03, 0xC0, + 0xF8, 0x01, 0xF0, 0x78, 0x00, 0x78, 0x7C, 0x00, 0x3C, 0x3C, 0x00, 0x1F, + 0x3E, 0x00, 0x07, 0x9E, 0x00, 0x03, 0xDF, 0x00, 0x00, 0xF0, 0xF0, 0x00, + 0x3C, 0x78, 0x00, 0x1E, 0x3C, 0x00, 0x0F, 0x1E, 0x00, 0x07, 0x8F, 0x00, + 0x03, 0xC7, 0x80, 0x01, 0xE3, 0xC0, 0x00, 0xF1, 0xE0, 0x00, 0x78, 0xF0, + 0x00, 0x3C, 0x78, 0x00, 0x1E, 0x3C, 0x00, 0x0F, 0x1E, 0x00, 0x07, 0x8F, + 0x00, 0x03, 0xC7, 0x80, 0x01, 0xE3, 0xC0, 0x00, 0xF1, 0xE0, 0x00, 0x78, + 0xF0, 0x00, 0x3C, 0x78, 0x00, 0x1E, 0x3C, 0x00, 0x0F, 0x1F, 0x00, 0x0F, + 0x8F, 0x80, 0x07, 0xC7, 0xE0, 0x07, 0xE3, 0xFC, 0x0F, 0xFB, 0xFF, 0xFF, + 0xFF, 0xF7, 0xFF, 0x9F, 0xF9, 0xFF, 0x8F, 0xFC, 0x3F, 0x03, 0xDE, 0x00, + 0x00, 0x0F, 0x00, 0x00, 0x07, 0x80, 0x00, 0x03, 0xC0, 0x00, 0x01, 0xE0, + 0x00, 0x00, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x1E, + 0x00, 0x00, 0x00, 0xF0, 0x01, 0xE3, 0xE0, 0x03, 0xC7, 0x80, 0x0F, 0x1E, + 0x00, 0x1E, 0x7C, 0x00, 0x78, 0xF0, 0x01, 0xE3, 0xC0, 0x03, 0xCF, 0x80, + 0x0F, 0x1E, 0x00, 0x3C, 0x78, 0x00, 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, 0x00, 0x00, 0x78, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x07, + 0x80, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x1E, 0x00, 0x00, + 0x07, 0x80, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x78, 0x00, 0x0F, 0x00, 0x00, + 0xF0, 0x1E, 0x00, 0x00, 0x78, 0x1E, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x00, + 0x3C, 0x3C, 0x00, 0x00, 0x3C, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, 0x00, + 0x1E, 0x78, 0x00, 0x00, 0x1E, 0x70, 0x00, 0x00, 0x0E, 0xF0, 0x00, 0x00, + 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, + 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, + 0x0F, 0xF0, 0x07, 0xC0, 0x0F, 0xF8, 0x07, 0xE0, 0x1F, 0x78, 0x07, 0xE0, + 0x1E, 0x78, 0x07, 0xE0, 0x1E, 0x7C, 0x0F, 0xF0, 0x3E, 0x3E, 0x1E, 0xF8, + 0x7C, 0x3F, 0xFE, 0x7F, 0xFC, 0x1F, 0xFC, 0x7F, 0xF8, 0x0F, 0xFC, 0x3F, + 0xF0, 0x03, 0xF0, 0x0F, 0xC0, 0xF8, 0x7F, 0xE1, 0xFF, 0x87, 0xFE, 0x1F, + 0xF8, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, + 0x03, 0xC0, 0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0, 0x0F, 0x00, 0x3C, + 0x00, 0xF0, 0x03, 0xC0, 0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0, 0x0F, + 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0, 0x0F, 0x00, 0x1E, 0x00, 0x78, 0x01, + 0xF0, 0x07, 0xFC, 0x0F, 0xF0, 0x1F, 0xC0, 0x1F, 0x3E, 0x1F, 0x01, 0xF0, + 0xF8, 0x0F, 0x87, 0xC0, 0x7C, 0x3E, 0x03, 0xE1, 0xF0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xE0, 0x07, 0x8F, 0x00, 0x1E, 0x78, 0x00, 0xF3, 0xC0, 0x03, 0xDE, + 0x00, 0x1E, 0xF0, 0x00, 0xF7, 0x80, 0x03, 0xFC, 0x00, 0x1F, 0xE0, 0x00, + 0xFF, 0x00, 0x07, 0xF8, 0x00, 0x3F, 0xC0, 0x01, 0xFE, 0x00, 0x0F, 0xF0, + 0x00, 0x7F, 0x80, 0x07, 0xFC, 0x00, 0x3D, 0xE0, 0x01, 0xEF, 0x00, 0x1F, + 0x78, 0x00, 0xF3, 0xE0, 0x0F, 0x8F, 0x00, 0xF8, 0x7E, 0x1F, 0xC1, 0xFF, + 0xFC, 0x0F, 0xFF, 0xC0, 0x1F, 0xF8, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x01, + 0xE0, 0x00, 0x03, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x07, 0x80, 0x00, 0x0F, + 0x00, 0x00, 0x1E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x03, 0xFF, + 0xC0, 0x0F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF8, 0x1F, 0x81, 0xF8, 0x3E, 0x00, + 0x7C, 0x7C, 0x00, 0x3E, 0x7C, 0x00, 0x3E, 0x78, 0x00, 0x1E, 0xF8, 0x00, + 0x1F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, + 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, + 0x0F, 0xF8, 0x00, 0x1F, 0x78, 0x00, 0x1E, 0x7C, 0x00, 0x3E, 0x7C, 0x00, + 0x3E, 0x3E, 0x00, 0x7C, 0x1F, 0x81, 0xF8, 0x1F, 0xFF, 0xF8, 0x0F, 0xFF, + 0xF0, 0x03, 0xFF, 0xC0, 0x00, 0xFF, 0x00, 0x00, 0x0F, 0x00, 0x00, 0xF8, + 0x00, 0x0F, 0x80, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x03, + 0x80, 0x00, 0x3C, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xE3, 0xC0, 0x07, 0x9E, 0x00, + 0x3C, 0xF0, 0x00, 0xF7, 0x80, 0x07, 0xBC, 0x00, 0x3D, 0xE0, 0x00, 0xFF, + 0x00, 0x07, 0xF8, 0x00, 0x3F, 0xC0, 0x01, 0xFE, 0x00, 0x0F, 0xF0, 0x00, + 0x7F, 0x80, 0x03, 0xFC, 0x00, 0x1F, 0xE0, 0x01, 0xFF, 0x00, 0x0F, 0x78, + 0x00, 0x7B, 0xC0, 0x07, 0xDE, 0x00, 0x3C, 0xF8, 0x03, 0xE3, 0xC0, 0x3E, + 0x1F, 0x87, 0xF0, 0x7F, 0xFF, 0x03, 0xFF, 0xF0, 0x07, 0xFE, 0x00, 0x1F, + 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x1E, 0x00, + 0x00, 0x78, 0x1E, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x00, 0x3C, 0x3C, 0x00, + 0x00, 0x3C, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, 0x00, 0x1E, 0x78, 0x00, + 0x00, 0x1E, 0x70, 0x00, 0x00, 0x0E, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x03, + 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, + 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x03, 0xC0, 0x0F, 0xF0, 0x07, + 0xC0, 0x0F, 0xF8, 0x07, 0xE0, 0x1F, 0x78, 0x07, 0xE0, 0x1E, 0x78, 0x07, + 0xE0, 0x1E, 0x7C, 0x0F, 0xF0, 0x3E, 0x3E, 0x1E, 0xF8, 0x7C, 0x3F, 0xFE, + 0x7F, 0xFC, 0x1F, 0xFC, 0x7F, 0xF8, 0x0F, 0xFC, 0x3F, 0xF0, 0x03, 0xF0, + 0x0F, 0xC0, +}; + +const GFXglyph FreeSans24pt_Win1253Glyphs[] PROGMEM = { +/* 0x01 */ { 0, 43, 48, 60, 8, -39 }, +/* 0x02 */ { 258, 43, 48, 60, 8, -39 }, +/* 0x03 */ { 516, 48, 48, 60, 6, -39 }, +/* 0x04 */ { 804, 57, 48, 60, 1, -39 }, +/* 0x05 */ { 1146, 47, 48, 60, 6, -39 }, +/* 0x06 */ { 1428, 47, 48, 60, 6, -39 }, +/* 0x07 */ { 1710, 0, 0, 0, 0, 0 }, +/* 0x08 */ { 1710, 49, 48, 60, 5, -39 }, +/* 0x09 */ { 2004, 54, 38, 60, 3, -34 }, +/* 0x0A */ { 2261, 0, 0, 0, 0, 0 }, +/* 0x0B */ { 2261, 52, 48, 60, 4, -39 }, +/* 0x0C */ { 2573, 47, 48, 60, 6, -39 }, +/* 0x0D */ { 2855, 0, 0, 0, 0, 0 }, +/* 0x0E */ { 2855, 47, 48, 60, 6, -39 }, +/* 0x0F */ { 3137, 48, 49, 60, 6, -39 }, +/* 0x10 */ { 3431, 46, 48, 60, 7, -39 }, +/* 0x11 */ { 3707, 48, 48, 60, 6, -39 }, +/* 0x12 */ { 3995, 46, 48, 60, 7, -39 }, +/* 0x13 */ { 4271, 48, 46, 60, 6, -38 }, +/* 0x14 */ { 4547, 48, 48, 60, 6, -39 }, +/* 0x15 */ { 4835, 51, 48, 60, 4, -39 }, +/* 0x16 */ { 5141, 37, 47, 60, 11, -38 }, +/* 0x17 */ { 5359, 50, 40, 60, 5, -35 }, +/* 0x18 */ { 5609, 56, 40, 60, 2, -35 }, +/* 0x19 */ { 5889, 48, 48, 60, 6, -39 }, +/* 0x1A */ { 6177, 0, 0, 0, 0, 0 }, +/* 0x1B */ { 6177, 56, 49, 60, 2, -39 }, +/* 0x1C */ { 6520, 48, 48, 60, 6, -39 }, +/* 0x1D */ { 6808, 49, 49, 60, 5, -39 }, +/* 0x1E */ { 7109, 48, 47, 60, 5, -38 }, +/* 0x1F */ { 7391, 34, 48, 60, 13, -39 }, +/* 0x20 */ { 7595, 1, 1, 15, 0, 0 }, +/* 0x21 */ { 7596, 5, 34, 19, 7, -33 }, +/* 0x22 */ { 7618, 13, 13, 22, 4, -33 }, +/* 0x23 */ { 7640, 32, 35, 39, 4, -34 }, +/* 0x24 */ { 7780, 22, 42, 30, 4, -34 }, +/* 0x25 */ { 7896, 39, 36, 45, 3, -34 }, +/* 0x26 */ { 8072, 32, 36, 37, 3, -34 }, +/* 0x27 */ { 8216, 4, 13, 13, 4, -33 }, +/* 0x28 */ { 8223, 11, 42, 18, 4, -35 }, +/* 0x29 */ { 8281, 11, 42, 18, 4, -35 }, +/* 0x2A */ { 8339, 21, 22, 24, 1, -34 }, +/* 0x2B */ { 8397, 30, 30, 39, 5, -29 }, +/* 0x2C */ { 8510, 6, 11, 15, 4, -5 }, +/* 0x2D */ { 8519, 12, 4, 17, 2, -14 }, +/* 0x2E */ { 8525, 4, 6, 15, 6, -5 }, +/* 0x2F */ { 8528, 16, 39, 16, 0, -33 }, +/* 0x30 */ { 8606, 24, 36, 30, 3, -34 }, +/* 0x31 */ { 8714, 20, 34, 30, 5, -33 }, +/* 0x32 */ { 8799, 22, 35, 30, 4, -34 }, +/* 0x33 */ { 8896, 23, 36, 30, 4, -34 }, +/* 0x34 */ { 9000, 25, 34, 30, 2, -33 }, +/* 0x35 */ { 9107, 22, 35, 30, 4, -33 }, +/* 0x36 */ { 9204, 24, 36, 30, 3, -34 }, +/* 0x37 */ { 9312, 22, 34, 30, 4, -33 }, +/* 0x38 */ { 9406, 24, 36, 30, 3, -34 }, +/* 0x39 */ { 9514, 24, 36, 30, 3, -34 }, +/* 0x3A */ { 9622, 5, 24, 16, 6, -23 }, +/* 0x3B */ { 9637, 6, 29, 16, 4, -23 }, +/* 0x3C */ { 9659, 29, 25, 39, 5, -26 }, +/* 0x3D */ { 9750, 29, 14, 39, 5, -21 }, +/* 0x3E */ { 9801, 29, 25, 39, 5, -26 }, +/* 0x3F */ { 9892, 18, 35, 25, 3, -34 }, +/* 0x40 */ { 9971, 41, 41, 47, 3, -32 }, +/* 0x41 */ { 10182, 31, 34, 32, 0, -33 }, +/* 0x42 */ { 10314, 24, 34, 32, 4, -33 }, +/* 0x43 */ { 10416, 28, 36, 33, 3, -34 }, +/* 0x44 */ { 10542, 29, 34, 36, 4, -33 }, +/* 0x45 */ { 10666, 22, 34, 30, 4, -33 }, +/* 0x46 */ { 10760, 20, 34, 27, 4, -33 }, +/* 0x47 */ { 10845, 30, 36, 36, 3, -34 }, +/* 0x48 */ { 10980, 26, 34, 35, 4, -33 }, +/* 0x49 */ { 11091, 4, 34, 14, 4, -33 }, +/* 0x4A */ { 11108, 11, 43, 14, -3, -33 }, +/* 0x4B */ { 11168, 27, 34, 31, 4, -33 }, +/* 0x4C */ { 11283, 21, 34, 26, 4, -33 }, +/* 0x4D */ { 11373, 31, 34, 41, 4, -33 }, +/* 0x4E */ { 11505, 26, 34, 35, 4, -33 }, +/* 0x4F */ { 11616, 32, 36, 37, 3, -34 }, +/* 0x50 */ { 11760, 22, 34, 28, 4, -33 }, +/* 0x51 */ { 11854, 32, 41, 37, 3, -34 }, +/* 0x52 */ { 12018, 27, 34, 33, 4, -33 }, +/* 0x53 */ { 12133, 24, 36, 30, 3, -34 }, +/* 0x54 */ { 12241, 28, 34, 29, 0, -33 }, +/* 0x55 */ { 12360, 26, 35, 34, 5, -33 }, +/* 0x56 */ { 12474, 31, 34, 32, 0, -33 }, +/* 0x57 */ { 12606, 43, 34, 46, 2, -33 }, +/* 0x58 */ { 12789, 29, 34, 31, 1, -33 }, +/* 0x59 */ { 12913, 28, 34, 29, 0, -33 }, +/* 0x5A */ { 13032, 28, 34, 32, 2, -33 }, +/* 0x5B */ { 13151, 10, 42, 18, 4, -35 }, +/* 0x5C */ { 13204, 16, 39, 16, 0, -33 }, +/* 0x5D */ { 13282, 9, 42, 18, 4, -35 }, +/* 0x5E */ { 13330, 29, 13, 39, 5, -33 }, +/* 0x5F */ { 13378, 24, 4, 24, 0, 8 }, +/* 0x60 */ { 13390, 11, 9, 24, 4, -37 }, +/* 0x61 */ { 13403, 22, 28, 29, 3, -26 }, +/* 0x62 */ { 13480, 23, 37, 30, 4, -35 }, +/* 0x63 */ { 13587, 20, 28, 26, 3, -26 }, +/* 0x64 */ { 13657, 23, 37, 30, 3, -35 }, +/* 0x65 */ { 13764, 24, 28, 29, 3, -26 }, +/* 0x66 */ { 13848, 16, 36, 17, 1, -35 }, +/* 0x67 */ { 13920, 23, 37, 30, 3, -26 }, +/* 0x68 */ { 14027, 22, 36, 30, 4, -35 }, +/* 0x69 */ { 14126, 4, 36, 13, 4, -35 }, +/* 0x6A */ { 14144, 9, 46, 13, -1, -35 }, +/* 0x6B */ { 14196, 23, 36, 27, 4, -35 }, +/* 0x6C */ { 14300, 4, 36, 13, 4, -35 }, +/* 0x6D */ { 14318, 38, 27, 46, 4, -26 }, +/* 0x6E */ { 14447, 22, 27, 30, 4, -26 }, +/* 0x6F */ { 14522, 24, 28, 29, 3, -26 }, +/* 0x70 */ { 14606, 23, 37, 30, 4, -26 }, +/* 0x71 */ { 14713, 23, 37, 30, 3, -26 }, +/* 0x72 */ { 14820, 15, 27, 19, 4, -26 }, +/* 0x73 */ { 14871, 19, 28, 24, 3, -26 }, +/* 0x74 */ { 14938, 16, 33, 18, 1, -32 }, +/* 0x75 */ { 15004, 22, 28, 30, 4, -26 }, +/* 0x76 */ { 15081, 25, 26, 28, 1, -25 }, +/* 0x77 */ { 15163, 35, 26, 38, 2, -25 }, +/* 0x78 */ { 15277, 25, 26, 28, 1, -25 }, +/* 0x79 */ { 15359, 25, 36, 28, 1, -25 }, +/* 0x7A */ { 15472, 21, 26, 25, 2, -25 }, +/* 0x7B */ { 15541, 18, 43, 30, 6, -35 }, +/* 0x7C */ { 15638, 4, 47, 16, 6, -35 }, +/* 0x7D */ { 15662, 18, 43, 30, 6, -35 }, +/* 0x7E */ { 15759, 29, 9, 39, 5, -18 }, +/* 0x7F */ { 15792, 0, 0, 0, 0, 0 }, +/* 0x80 */ { 15792, 26, 36, 30, 0, -34 }, +/* 0x81 */ { 15909, 0, 0, 0, 0, 0 }, +/* 0x82 */ { 15909, 6, 11, 15, 4, -5 }, +/* 0x83 */ { 15918, 20, 46, 17, -3, -35 }, +/* 0x84 */ { 16033, 15, 11, 24, 4, -5 }, +/* 0x85 */ { 16054, 36, 6, 47, 5, -5 }, +/* 0x86 */ { 16081, 20, 39, 24, 2, -33 }, +/* 0x87 */ { 16179, 20, 39, 24, 2, -33 }, +/* 0x88 */ { 16277, 0, 0, 0, 0, 0 }, +/* 0x89 */ { 16277, 58, 36, 63, 3, -34 }, +/* 0x8A */ { 16538, 0, 0, 0, 0, 0 }, +/* 0x8B */ { 16538, 11, 21, 19, 4, -23 }, +/* 0x8C */ { 16567, 0, 0, 0, 0, 0 }, +/* 0x8D */ { 16567, 0, 0, 0, 0, 0 }, +/* 0x8E */ { 16567, 0, 0, 0, 0, 0 }, +/* 0x8F */ { 16567, 0, 0, 0, 0, 0 }, +/* 0x90 */ { 16567, 0, 0, 0, 0, 0 }, +/* 0x91 */ { 16567, 6, 11, 15, 4, -33 }, +/* 0x92 */ { 16576, 6, 11, 15, 4, -33 }, +/* 0x93 */ { 16585, 15, 11, 24, 4, -33 }, +/* 0x94 */ { 16606, 15, 11, 24, 4, -33 }, +/* 0x95 */ { 16627, 14, 14, 28, 7, -23 }, +/* 0x96 */ { 16652, 19, 4, 24, 2, -14 }, +/* 0x97 */ { 16662, 42, 4, 47, 2, -14 }, +/* 0x98 */ { 16683, 0, 0, 0, 0, 0 }, +/* 0x99 */ { 16683, 31, 13, 47, 6, -33 }, +/* 0x9A */ { 16734, 0, 0, 0, 0, 0 }, +/* 0x9B */ { 16734, 11, 21, 19, 4, -23 }, +/* 0x9C */ { 16763, 0, 0, 0, 0, 0 }, +/* 0x9D */ { 16763, 0, 0, 0, 0, 0 }, +/* 0x9E */ { 16763, 0, 0, 0, 0, 0 }, +/* 0x9F */ { 16763, 0, 0, 0, 0, 0 }, +/* 0xA0 */ { 16763, 1, 1, 15, 0, 0 }, +/* 0xA1 */ { 16764, 15, 15, 24, 5, -45 }, +/* 0xA2 */ { 16793, 31, 38, 33, 0, -37 }, +/* 0xA3 */ { 16941, 22, 35, 30, 3, -34 }, +/* 0xA4 */ { 17038, 26, 26, 30, 2, -26 }, +/* 0xA5 */ { 17123, 26, 34, 30, 2, -33 }, +/* 0xA6 */ { 17234, 4, 40, 16, 6, -31 }, +/* 0xA7 */ { 17254, 19, 39, 24, 2, -34 }, +/* 0xA8 */ { 17347, 14, 5, 24, 5, -35 }, +/* 0xA9 */ { 17356, 34, 34, 47, 7, -33 }, +/* 0xAA */ { 17501, 0, 0, 0, 0, 0 }, +/* 0xAB */ { 17501, 21, 21, 29, 4, -23 }, +/* 0xAC */ { 17557, 29, 13, 39, 5, -19 }, +/* 0xAD */ { 17605, 12, 4, 17, 2, -14 }, +/* 0xAE */ { 17611, 34, 34, 47, 7, -33 }, +/* 0xAF */ { 17756, 47, 4, 47, 0, -14 }, +/* 0xB0 */ { 17780, 15, 15, 24, 4, -34 }, +/* 0xB1 */ { 17809, 30, 30, 39, 5, -29 }, +/* 0xB2 */ { 17922, 14, 19, 19, 2, -34 }, +/* 0xB3 */ { 17956, 14, 19, 19, 2, -34 }, +/* 0xB4 */ { 17990, 11, 9, 24, 9, -37 }, +/* 0xB5 */ { 18003, 15, 15, 24, 5, -45 }, +/* 0xB6 */ { 18032, 31, 38, 33, 0, -37 }, +/* 0xB7 */ { 18180, 4, 6, 15, 5, -18 }, +/* 0xB8 */ { 18183, 31, 38, 35, 0, -37 }, +/* 0xB9 */ { 18331, 35, 38, 41, 0, -37 }, +/* 0xBA */ { 18498, 13, 38, 19, 0, -37 }, +/* 0xBB */ { 18560, 21, 21, 29, 4, -23 }, +/* 0xBC */ { 18616, 36, 39, 38, 0, -37 }, +/* 0xBD */ { 18792, 39, 36, 46, 4, -34 }, +/* 0xBE */ { 18968, 38, 38, 39, 0, -37 }, +/* 0xBF */ { 19149, 36, 38, 39, 0, -37 }, +/* 0xC0 */ { 19320, 15, 46, 16, 0, -45 }, +/* 0xC1 */ { 19407, 31, 34, 32, 0, -33 }, +/* 0xC2 */ { 19539, 24, 34, 32, 4, -33 }, +/* 0xC3 */ { 19641, 21, 34, 25, 4, -33 }, +/* 0xC4 */ { 19731, 31, 34, 32, 0, -33 }, +/* 0xC5 */ { 19863, 22, 34, 30, 4, -33 }, +/* 0xC6 */ { 19957, 28, 34, 32, 2, -33 }, +/* 0xC7 */ { 20076, 26, 34, 35, 4, -33 }, +/* 0xC8 */ { 20187, 32, 36, 38, 3, -34 }, +/* 0xC9 */ { 20331, 4, 34, 14, 4, -33 }, +/* 0xCA */ { 20348, 27, 34, 31, 4, -33 }, +/* 0xCB */ { 20463, 31, 34, 32, 0, -33 }, +/* 0xCC */ { 20595, 31, 34, 41, 4, -33 }, +/* 0xCD */ { 20727, 26, 34, 35, 4, -33 }, +/* 0xCE */ { 20838, 21, 34, 29, 4, -33 }, +/* 0xCF */ { 20928, 32, 36, 37, 3, -34 }, +/* 0xD0 */ { 21072, 26, 34, 34, 4, -33 }, +/* 0xD1 */ { 21183, 22, 34, 28, 4, -33 }, +/* 0xD2 */ { 21277, 0, 0, 0, 0, 0 }, +/* 0xD3 */ { 21277, 22, 34, 29, 4, -33 }, +/* 0xD4 */ { 21371, 28, 34, 29, 0, -33 }, +/* 0xD5 */ { 21490, 28, 34, 29, 0, -33 }, +/* 0xD6 */ { 21609, 32, 34, 38, 3, -33 }, +/* 0xD7 */ { 21745, 29, 34, 31, 1, -33 }, +/* 0xD8 */ { 21869, 32, 34, 38, 3, -33 }, +/* 0xD9 */ { 22005, 32, 35, 38, 3, -34 }, +/* 0xDA */ { 22145, 14, 44, 14, -1, -43 }, +/* 0xDB */ { 22222, 28, 44, 29, 0, -43 }, +/* 0xDC */ { 22376, 26, 39, 31, 3, -37 }, +/* 0xDD */ { 22503, 19, 39, 25, 3, -37 }, +/* 0xDE */ { 22596, 22, 48, 30, 4, -37 }, +/* 0xDF */ { 22728, 12, 38, 16, 4, -37 }, +/* 0xE0 */ { 22785, 21, 47, 28, 4, -45 }, +/* 0xE1 */ { 22909, 26, 28, 31, 3, -26 }, +/* 0xE2 */ { 23000, 22, 46, 29, 4, -35 }, +/* 0xE3 */ { 23127, 26, 36, 28, 1, -25 }, +/* 0xE4 */ { 23244, 24, 36, 30, 3, -34 }, +/* 0xE5 */ { 23352, 19, 28, 25, 3, -26 }, +/* 0xE6 */ { 23419, 21, 47, 25, 2, -35 }, +/* 0xE7 */ { 23543, 22, 37, 30, 4, -26 }, +/* 0xE8 */ { 23645, 24, 37, 30, 3, -35 }, +/* 0xE9 */ { 23756, 10, 26, 16, 4, -25 }, +/* 0xEA */ { 23789, 22, 26, 27, 4, -25 }, +/* 0xEB */ { 23861, 25, 36, 27, 1, -35 }, +/* 0xEC */ { 23974, 25, 36, 30, 4, -25 }, +/* 0xED */ { 24087, 22, 26, 26, 2, -25 }, +/* 0xEE */ { 24159, 20, 47, 25, 2, -35 }, +/* 0xEF */ { 24277, 24, 28, 29, 3, -26 }, +/* 0xF0 */ { 24361, 25, 27, 28, 2, -25 }, +/* 0xF1 */ { 24446, 24, 37, 31, 4, -26 }, +/* 0xF2 */ { 24557, 20, 38, 28, 3, -26 }, +/* 0xF3 */ { 24652, 26, 27, 30, 3, -25 }, +/* 0xF4 */ { 24740, 24, 26, 28, 2, -25 }, +/* 0xF5 */ { 24818, 21, 26, 28, 4, -24 }, +/* 0xF6 */ { 24887, 26, 37, 32, 3, -26 }, +/* 0xF7 */ { 25008, 24, 36, 26, 1, -25 }, +/* 0xF8 */ { 25116, 26, 36, 32, 3, -25 }, +/* 0xF9 */ { 25233, 32, 26, 38, 3, -24 }, +/* 0xFA */ { 25337, 14, 36, 16, 0, -35 }, +/* 0xFB */ { 25400, 21, 37, 28, 4, -35 }, +/* 0xFC */ { 25498, 24, 39, 29, 3, -37 }, +/* 0xFD */ { 25615, 21, 39, 28, 4, -37 }, +/* 0xFE */ { 25718, 32, 39, 38, 3, -37 }, +/* 0xFF */ { 25874, 0, 0, 0, 0, 0 }, +}; + +const GFXfont FreeSans24pt_Win1253 PROGMEM = { +(uint8_t*)FreeSans24pt_Win1253Bitmaps, +(GFXglyph*)FreeSans24pt_Win1253Glyphs, +0x01, 0xFF, 55 +}; diff --git a/src/graphics/niche/InkHUD/AppletFont.h b/src/graphics/niche/InkHUD/AppletFont.h index 8374c7f61..c97c12c36 100644 --- a/src/graphics/niche/InkHUD/AppletFont.h +++ b/src/graphics/niche/InkHUD/AppletFont.h @@ -88,8 +88,12 @@ class AppletFont // Greek #include "graphics/niche/Fonts/FreeSans12pt_Win1253.h" +#include "graphics/niche/Fonts/FreeSans18pt_Win1253.h" +#include "graphics/niche/Fonts/FreeSans24pt_Win1253.h" #include "graphics/niche/Fonts/FreeSans6pt_Win1253.h" #include "graphics/niche/Fonts/FreeSans9pt_Win1253.h" +#define FREESANS_24PT_WIN1253 InkHUD::AppletFont(FreeSans24pt_Win1253, InkHUD::AppletFont::WINDOWS_1253, -5, 3) +#define FREESANS_18PT_WIN1253 InkHUD::AppletFont(FreeSans18pt_Win1253, InkHUD::AppletFont::WINDOWS_1253, -4, 2) #define FREESANS_12PT_WIN1253 InkHUD::AppletFont(FreeSans12pt_Win1253, InkHUD::AppletFont::WINDOWS_1253, -3, 1) #define FREESANS_9PT_WIN1253 InkHUD::AppletFont(FreeSans9pt_Win1253, InkHUD::AppletFont::WINDOWS_1253, -2, -1) #define FREESANS_6PT_WIN1253 InkHUD::AppletFont(FreeSans6pt_Win1253, InkHUD::AppletFont::WINDOWS_1253, -1, -2) diff --git a/src/input/TouchScreenImpl1.cpp b/src/input/TouchScreenImpl1.cpp index 69dcab04e..14f95b73a 100644 --- a/src/input/TouchScreenImpl1.cpp +++ b/src/input/TouchScreenImpl1.cpp @@ -29,7 +29,8 @@ void TouchScreenImpl1::init() return; #else TouchScreenBase::init(true); - inputBroker->registerSource(this); + if (inputBroker) + inputBroker->registerSource(this); #endif } diff --git a/variants/esp32s3/t5s3_epaper/nicheGraphics.h b/variants/esp32s3/t5s3_epaper/nicheGraphics.h index 699a82de0..18217800b 100644 --- a/variants/esp32s3/t5s3_epaper/nicheGraphics.h +++ b/variants/esp32s3/t5s3_epaper/nicheGraphics.h @@ -6,26 +6,27 @@ NicheGraphics attempts a different approach: Per-device config takes place in this setupNicheGraphics() method (And a small amount in platformio.ini) -This file sets up InkHUD for Heltec VM-E290. -Different NicheGraphics UIs and different hardware variants will each have their own setup procedure. +This file sets up InkHUD for the LilyGo T5-E-Paper-S3-Pro. + +The board uses a 4.7" ED047TC1 parallel e-paper display (960×540, 8-bit parallel interface). +This is driven via the FastEPD library through the NicheGraphics ED047TC1 driver adapter. */ #pragma once #include "configuration.h" -#include "mesh/MeshModule.h" #ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS // InkHUD-specific components // --------------------------- -// #include "graphics/niche/InkHUD/InkHUD.h" -#include "graphics/niche/InkHUD/WindowManager.h" +#include "graphics/niche/InkHUD/InkHUD.h" // Applets #include "graphics/niche/InkHUD/Applets/User/AllMessage/AllMessageApplet.h" #include "graphics/niche/InkHUD/Applets/User/DM/DMApplet.h" +#include "graphics/niche/InkHUD/Applets/User/FavoritesMap/FavoritesMapApplet.h" #include "graphics/niche/InkHUD/Applets/User/Heard/HeardApplet.h" #include "graphics/niche/InkHUD/Applets/User/Positions/PositionsApplet.h" #include "graphics/niche/InkHUD/Applets/User/RecentsList/RecentsListApplet.h" @@ -34,26 +35,20 @@ Different NicheGraphics UIs and different hardware variants will each have their // Shared NicheGraphics components // -------------------------------- #include "graphics/niche/Drivers/Backlight/LatchingBacklight.h" -#include "graphics/niche/Drivers/EInk/DEPG0290BNS800.h" +#include "graphics/niche/Drivers/EInk/ED047TC1.h" #include "graphics/niche/Inputs/TwoButton.h" void setupNicheGraphics() { using namespace NicheGraphics; - // SPI - // ----------------------------- - - // Display is connected to HSPI - SPIClass *hspi = new SPIClass(HSPI); - hspi->begin(PIN_EINK_SCLK, -1, PIN_EINK_MOSI, PIN_EINK_CS); - // E-Ink Driver // ----------------------------- + // The ED047TC1 is a parallel display — no SPI bus setup needed. + // begin() args are part of the EInk interface but are ignored for parallel displays. - // Use E-Ink driver - Drivers::EInk *driver = new Drivers::DEPG0290BNS800; - driver->begin(hspi, PIN_EINK_DC, PIN_EINK_CS, PIN_EINK_BUSY); + Drivers::EInk *driver = new Drivers::ED047TC1; + driver->begin(nullptr, 0, 0, 0); // InkHUD // ---------------------------- @@ -67,57 +62,57 @@ void setupNicheGraphics() // Set how unhealthy additional FAST updates beyond this number are inkhud->setDisplayResilience(7, 1.5); - // Prepare fonts - InkHUD::Applet::fontLarge = FREESANS_9PT_WIN1252; - InkHUD::Applet::fontSmall = FREESANS_6PT_WIN1252; + // Prepare fonts — use larger sizes to suit the 4.7" screen at ~234 DPI + InkHUD::Applet::fontLarge = FREESANS_24PT_WIN1253; + InkHUD::Applet::fontMedium = FREESANS_18PT_WIN1253; + InkHUD::Applet::fontSmall = FREESANS_12PT_WIN1253; - // Init settings, and customize defaults + // Customize default settings inkhud->persistence->settings.userTiles.maxCount = 2; // How many tiles can the display handle? - inkhud->persistence->settings.rotation = 1; // 90 degrees clockwise + inkhud->persistence->settings.rotation = 3; // 270 degrees clockwise inkhud->persistence->settings.userTiles.count = 1; // One tile only by default, keep things simple for new users - inkhud->persistence->settings.optionalMenuItems.nextTile = false; // Behavior handled by aux button instead - inkhud->persistence->settings.optionalFeatures.batteryIcon = true; // Device definitely has a battery + inkhud->persistence->settings.optionalFeatures.batteryIcon = true; + inkhud->persistence->settings.optionalMenuItems.backlight = true; - // Setup backlight - // Note: AUX button behavior configured further down - Drivers::LatchingBacklight *backlight = Drivers::LatchingBacklight::getInstance(); - backlight->setPin(PIN_EINK_EN); + // Alignment must cancel rotation for visual-frame touch input: (rotation + alignment) % 4 == 0. + inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4; // Pick applets // Note: order of applets determines priority of "auto-show" feature - // Optional arguments for defaults: - // - is activated? - // - is autoshown? - // - is foreground on a specific tile (index)? - inkhud->addApplet("All Messages", new InkHUD::AllMessageApplet, true, true); // Activated, autoshown - inkhud->addApplet("DMs", new InkHUD::DMApplet); - inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0)); - inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1)); - inkhud->addApplet("Positions", new InkHUD::PositionsApplet, true); // Activated - inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet); + inkhud->addApplet("All Messages", new InkHUD::AllMessageApplet, false, false); // Not Active, not autoshown + inkhud->addApplet("DMs", new InkHUD::DMApplet, true, true); // Activated, Autoshown + inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0), true, true); // Activated, Autoshown + inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1), false, false); // Not Active, not autoshown + inkhud->addApplet("Positions", new InkHUD::PositionsApplet, true, false); // Activated, not autoshown + inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet, true, false); // Activated, not autoshown inkhud->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, not autoshown, default on tile 0 - // inkhud->addApplet("Basic", new InkHUD::BasicExampleApplet); - // inkhud->addApplet("NewMsg", new InkHUD::NewMsgExampleApplet); + inkhud->addApplet("Favorites Map", new InkHUD::FavoritesMapApplet, false, false); // Not Active, not autoshown + + // Backlight + // ---------------------------- + Drivers::LatchingBacklight *backlight = Drivers::LatchingBacklight::getInstance(); + backlight->setPin(BOARD_BL_EN); // GPIO11 on V2 // Start running InkHUD inkhud->begin(); + // Touch navigation requires joystick mode — enforce post-begin so flash cannot override. + inkhud->persistence->settings.joystick.enabled = true; + inkhud->persistence->settings.joystick.aligned = true; + // Buttons // -------------------------- Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // A shared NicheGraphics component - // Setup the main user button (0) + // Setup the main user button (boot button, GPIO 0) buttons->setWiring(0, BUTTON_PIN); - buttons->setHandlerShortPress(0, []() { InkHUD::InkHUD::getInstance()->shortpress(); }); - buttons->setHandlerLongPress(0, []() { InkHUD::InkHUD::getInstance()->longpress(); }); + buttons->setHandlerShortPress(0, [inkhud]() { inkhud->shortpress(); }); + buttons->setHandlerLongPress(0, [inkhud]() { inkhud->longpress(); }); - // Setup the aux button (1) - // Bonus feature of VME290 - buttons->setWiring(1, BUTTON_PIN_SECONDARY); - buttons->setHandlerShortPress(1, []() { InkHUD::InkHUD::getInstance()->nextTile(); }); + // No dedicated aux button on this board buttons->start(); } -#endif \ No newline at end of file +#endif diff --git a/variants/esp32s3/t5s3_epaper/variant.cpp b/variants/esp32s3/t5s3_epaper/variant.cpp index e10d7c347..3bc010ce0 100644 --- a/variants/esp32s3/t5s3_epaper/variant.cpp +++ b/variants/esp32s3/t5s3_epaper/variant.cpp @@ -2,21 +2,123 @@ #ifdef T5_S3_EPAPER_PRO +#include "Observer.h" #include "TouchDrvGT911.hpp" #include "Wire.h" +#include "input/InputBroker.h" #include "input/TouchScreenImpl1.h" +#include "sleep.h" + +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS +#include "graphics/niche/InkHUD/InkHUD.h" +#include "graphics/niche/InkHUD/SystemApplet.h" + +// Bridges touch events from TouchScreenImpl1 directly into InkHUD, +// bypassing the InputBroker (which is excluded in InkHUD builds). +// Routing mirrors the mini-epaper-s3 two-way rocker pattern: +// - Nav left/right: prevApplet/nextApplet when idle, navUp/Down when a system applet has focus (e.g. menu) +// - Nav up/down: navUp/navDown always (menu scroll) +// - Tap: shortpress (cycle applets / confirm in menu) +// - Long press: longpress (open menu / back) +class TouchInkHUDBridge : public Observer +{ + int onNotify(const InputEvent *e) override + { + auto *inkhud = NicheGraphics::InkHUD::InkHUD::getInstance(); + + // Keep alignment in sync with the current rotation so that visual-frame gestures + // always pass through nav functions without remapping: (rotation + alignment) % 4 == 0. + inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4; + + // Check whether a system applet (e.g. menu) is currently handling input + bool systemHandlingInput = false; + for (NicheGraphics::InkHUD::SystemApplet *sa : inkhud->systemApplets) { + if (sa->handleInput) { + systemHandlingInput = true; + break; + } + } + + switch (e->inputEvent) { + case INPUT_BROKER_USER_PRESS: + inkhud->shortpress(); + break; + case INPUT_BROKER_SELECT: + inkhud->longpress(); + break; + case INPUT_BROKER_LEFT: + if (systemHandlingInput) + inkhud->navUp(); + else + inkhud->prevApplet(); + break; + case INPUT_BROKER_RIGHT: + if (systemHandlingInput) + inkhud->navDown(); + else + inkhud->nextApplet(); + break; + case INPUT_BROKER_UP: + inkhud->navUp(); + break; + case INPUT_BROKER_DOWN: + inkhud->navDown(); + break; + default: + break; + } + return 0; + } +}; + +static TouchInkHUDBridge touchBridge; +#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS TouchDrvGT911 touch; +// Commands the GT911 into standby before the Wire bus is torn down. +// notifyDeepSleep fires before Wire.end() in doDeepSleep(), so I2C is still available here. +struct TouchDeepSleepObserver { + int onDeepSleep(void *) + { + touch.sleep(); + return 0; + } + CallbackObserver observer{this, &TouchDeepSleepObserver::onDeepSleep}; +} static touchDeepSleepObserver; + bool readTouch(int16_t *x, int16_t *y) { if (!digitalRead(GT911_PIN_INT)) { int16_t raw_x; int16_t raw_y; if (touch.getPoint(&raw_x, &raw_y)) { - // rotate 90° for landscape - *x = raw_y; - *y = EPD_WIDTH - 1 - raw_x; +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS + // Transform raw GT911 axes to visual-frame coordinates for the current display rotation. + // rotation=3 is the physical identity (device's default orientation). + switch (NicheGraphics::InkHUD::InkHUD::getInstance()->persistence->settings.rotation) { + default: + case 3: + *x = raw_x; + *y = raw_y; + break; // identity + case 2: + *x = (EPD_WIDTH - 1) - raw_y; + *y = raw_x; + break; // 90° CW tilt + case 1: + *x = (EPD_HEIGHT - 1) - raw_x; + *y = (EPD_WIDTH - 1) - raw_y; + break; // 180° flip + case 0: + *x = raw_y; + *y = (EPD_HEIGHT - 1) - raw_x; + break; // 90° CCW tilt + } +#else + *x = raw_x; + *y = raw_y; +#endif LOG_DEBUG("touched(%d/%d)", *x, *y); return true; } @@ -31,15 +133,46 @@ void earlyInitVariant() pinMode(SDCARD_CS, OUTPUT); digitalWrite(SDCARD_CS, HIGH); pinMode(BOARD_BL_EN, OUTPUT); + + // Program GT911 touch controller to I2C address 0x14 (GT911_SLAVE_ADDRESS_H) before + // the I2C bus scan runs. GPIO3 (INT) defaults LOW on ESP32-S3 cold boot, which would + // leave the GT911 at 0x5D (GT911_SLAVE_ADDRESS_L) — the same address as the SFA30 + // air quality sensor — causing a false-positive SFA30 detection during the I2C scan. + // + // GT911 datasheet §4.3 "Address Selection": + // Pull INT HIGH before releasing RST → device latches address 0x14 (SLAVE_ADDRESS_H) + // Pull INT LOW before releasing RST → device latches address 0x5D (SLAVE_ADDRESS_L) + // Minimum RST assert time: 100 µs; minimum startup time after RST deassert: 5 ms. + // + // lateInitVariant() calls touch.begin() which repeats this sequence internally while + // also performing full I2C initialisation; the double-reset is harmless. + pinMode(GT911_PIN_RST, OUTPUT); + digitalWrite(GT911_PIN_RST, LOW); + pinMode(GT911_PIN_INT, OUTPUT); + digitalWrite(GT911_PIN_INT, HIGH); // HIGH → latch address 0x14 + delay(1); // > 100 µs + digitalWrite(GT911_PIN_RST, HIGH); + delay(10); // > 5 ms startup + pinMode(GT911_PIN_INT, INPUT); // release INT for interrupt use +} + +void variant_shutdown() +{ + // Ensure frontlight is off during deep sleep + digitalWrite(BOARD_BL_EN, LOW); } // T5-S3-ePaper Pro specific (late-) init void lateInitVariant(void) { touch.setPins(GT911_PIN_RST, GT911_PIN_INT); - if (touch.begin(Wire, GT911_SLAVE_ADDRESS_L, GT911_PIN_SDA, GT911_PIN_SCL)) { + if (touch.begin(Wire, GT911_SLAVE_ADDRESS_H, GT911_PIN_SDA, GT911_PIN_SCL)) { + touchDeepSleepObserver.observer.observe(¬ifyDeepSleep); touchScreenImpl1 = new TouchScreenImpl1(EPD_WIDTH, EPD_HEIGHT, readTouch); touchScreenImpl1->init(); +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS + touchBridge.observe(touchScreenImpl1); +#endif } else { LOG_ERROR("Failed to find touch controller!"); } diff --git a/variants/esp32s3/t5s3_epaper/variant.h b/variants/esp32s3/t5s3_epaper/variant.h index c2c001373..803b582af 100644 --- a/variants/esp32s3/t5s3_epaper/variant.h +++ b/variants/esp32s3/t5s3_epaper/variant.h @@ -26,9 +26,9 @@ #define GT911_PIN_RST 9 #endif -#define PCF85063_RTC 0x51 +#define PCF8563_RTC 0x51 #define HAS_RTC 1 -#define PCF85063_INT 2 +#define PCF8563_INT 2 #define USE_POWERSAVE #define SLEEP_TIME 120 From fb7d34afb93a1e97e61574f234e44e77f55ae45b Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 21 Apr 2026 17:08:29 -0400 Subject: [PATCH 61/67] Cleanup: Fix ADC channels on new variants --- variants/esp32s3/m5stack_cardputer_adv/variant.h | 2 +- variants/esp32s3/mini-epaper-s3/variant.h | 2 +- variants/esp32s3/t-beam-1w/variant.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/variants/esp32s3/m5stack_cardputer_adv/variant.h b/variants/esp32s3/m5stack_cardputer_adv/variant.h index 5fdb1436e..98a970471 100644 --- a/variants/esp32s3/m5stack_cardputer_adv/variant.h +++ b/variants/esp32s3/m5stack_cardputer_adv/variant.h @@ -83,7 +83,7 @@ #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) #define BATTERY_PIN 10 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define ADC_CHANNEL ADC1_GPIO10_CHANNEL +#define ADC_CHANNEL ADC_CHANNEL_9 #define ADC_MULTIPLIER 2 * 1.02 // 100k + 100k, and add 2% to kick the voltage over the max voltage to show charging. // BMI270 6-axis IMU on internal I2C bus diff --git a/variants/esp32s3/mini-epaper-s3/variant.h b/variants/esp32s3/mini-epaper-s3/variant.h index 0b640f9cf..1ac0a1e74 100644 --- a/variants/esp32s3/mini-epaper-s3/variant.h +++ b/variants/esp32s3/mini-epaper-s3/variant.h @@ -18,7 +18,7 @@ #define BATTERY_PIN 2 // A battery voltage measurement pin, voltage divider connected here to // measure battery voltage ratio of voltage divider = 2.0 (assumption) #define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. -#define ADC_CHANNEL ADC1_GPIO2_CHANNEL +#define ADC_CHANNEL ADC_CHANNEL_1 // Display (E-Ink) #define PIN_EINK_EN 42 diff --git a/variants/esp32s3/t-beam-1w/variant.h b/variants/esp32s3/t-beam-1w/variant.h index 52e99320e..673b7c4c0 100644 --- a/variants/esp32s3/t-beam-1w/variant.h +++ b/variants/esp32s3/t-beam-1w/variant.h @@ -72,7 +72,7 @@ // Battery ADC #define BATTERY_PIN 4 -#define ADC_CHANNEL ADC1_GPIO4_CHANNEL +#define ADC_CHANNEL ADC_CHANNEL_3 #define BATTERY_SENSE_SAMPLES 30 #define ADC_MULTIPLIER 2.9333 From db9fdd6794a365f2593bc93b770194dbd47e145e Mon Sep 17 00:00:00 2001 From: Tom <116762865+NomDeTom@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:43:35 +0100 Subject: [PATCH 62/67] Fix: filter out SKIPPED tests in PlatformIO output to improve log clarity (#10214) --- .github/workflows/test_native.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_native.yml b/.github/workflows/test_native.yml index 2fabf0591..1e22d74d1 100644 --- a/.github/workflows/test_native.yml +++ b/.github/workflows/test_native.yml @@ -86,7 +86,13 @@ jobs: run: sed -i 's/-DBUILD_EPOCH=$UNIX_TIME/#-DBUILD_EPOCH=$UNIX_TIME/' platformio.ini - name: PlatformIO Tests - run: platformio test -e coverage -v --junit-output-path testreport.xml + run: | + set -o pipefail + # Filter out SKIPPED summary rows for hardware variants that can't run on the + # native host. They flood the log and make it harder to spot real failures. + # The JUnit XML is written directly to testreport.xml before the pipe, so + # the test artifact is unaffected. + platformio test -e coverage -v --junit-output-path testreport.xml 2>&1 | grep -v "[[:space:]]SKIPPED$" - name: Save test results if: always() # run this step even if previous step failed From 6c74052ec359d21c4c4c1d3d9e2526933822be96 Mon Sep 17 00:00:00 2001 From: Austin Lane Date: Tue, 21 Apr 2026 17:56:35 -0400 Subject: [PATCH 63/67] InkHUD: Fix type casting for message size in saveToFlash method inkhud compiles again! --- src/graphics/niche/InkHUD/MessageStore.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/graphics/niche/InkHUD/MessageStore.cpp b/src/graphics/niche/InkHUD/MessageStore.cpp index 44a1ef633..671f38057 100644 --- a/src/graphics/niche/InkHUD/MessageStore.cpp +++ b/src/graphics/niche/InkHUD/MessageStore.cpp @@ -53,10 +53,11 @@ void InkHUD::MessageStore::saveToFlash() f.write(reinterpret_cast(&m.timestamp), sizeof(m.timestamp)); // Write timestamp. 4 bytes f.write(reinterpret_cast(&m.sender), sizeof(m.sender)); // Write sender NodeId. 4 Bytes f.write(reinterpret_cast(&m.channelIndex), sizeof(m.channelIndex)); // Write channel index. 1 Byte - f.write(reinterpret_cast(m.text.c_str()), min(MAX_MESSAGE_SIZE, m.text.size())); // Write message text - f.write('\0'); // Append null term - LOG_DEBUG("Wrote message %u, length %u, text \"%s\"", static_cast(i), min(MAX_MESSAGE_SIZE, m.text.size()), - m.text.c_str()); + f.write(reinterpret_cast(m.text.c_str()), + min((size_t)MAX_MESSAGE_SIZE, m.text.size())); // Write message text + f.write('\0'); // Append null term + LOG_DEBUG("Wrote message %u, length %u, text \"%s\"", static_cast(i), + min((size_t)MAX_MESSAGE_SIZE, m.text.size()), m.text.c_str()); } // Release firmware's SPI lock, because SafeFile::close needs it From b53fe7a1e7d20f9b063d56a61181cfddb2a671e4 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 21 Apr 2026 20:02:56 -0500 Subject: [PATCH 64/67] T watch pinfix (#10231) * Minor button debugging bits * pin0 is a pin, pin -1 means disabled --- src/input/ButtonThread.cpp | 10 ++++++++-- variants/esp32s3/t-watch-s3/variant.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/input/ButtonThread.cpp b/src/input/ButtonThread.cpp index df8de4905..3b0a46e88 100644 --- a/src/input/ButtonThread.cpp +++ b/src/input/ButtonThread.cpp @@ -143,6 +143,10 @@ int32_t ButtonThread::runOnce() leadUpSequenceActive = false; resetLeadUpSequence(); } +#ifdef INPUT_DEBUG + if (buttonCurrentlyPressed) + LOG_WARN("Button held for %u ms", millis() - buttonPressStartTime); +#endif // Progressive lead-up sound system if (!_suppressLeadUp && buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS) { @@ -311,7 +315,8 @@ int32_t ButtonThread::runOnce() void ButtonThread::attachButtonInterrupts() { // Interrupt for user button, during normal use. Improves responsiveness. - attachInterrupt(_pinNum, _intRoutine, CHANGE); + if (_intRoutine != nullptr) + attachInterrupt(_pinNum, _intRoutine, CHANGE); } /* @@ -320,7 +325,8 @@ void ButtonThread::attachButtonInterrupts() */ void ButtonThread::detachButtonInterrupts() { - detachInterrupt(_pinNum); + if (_intRoutine != nullptr) + detachInterrupt(_pinNum); } #ifdef ARCH_ESP32 diff --git a/variants/esp32s3/t-watch-s3/variant.h b/variants/esp32s3/t-watch-s3/variant.h index df275c31d..507d6b7dc 100644 --- a/variants/esp32s3/t-watch-s3/variant.h +++ b/variants/esp32s3/t-watch-s3/variant.h @@ -39,7 +39,7 @@ #define DAC_I2S_BCK 48 #define DAC_I2S_WS 15 #define DAC_I2S_DOUT 46 -#define DAC_I2S_MCLK 0 +#define DAC_I2S_MCLK -1 #define HAS_AXP2101 From e49dab1f08821a4a18aa56bbdea1f1337a543e12 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Wed, 22 Apr 2026 14:04:12 +0200 Subject: [PATCH 65/67] update p4 esp_hosted for BT --- variants/esp32p4/esp32p4.ini | 45 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/variants/esp32p4/esp32p4.ini b/variants/esp32p4/esp32p4.ini index c8caf8b05..f51ed1975 100644 --- a/variants/esp32p4/esp32p4.ini +++ b/variants/esp32p4/esp32p4.ini @@ -8,14 +8,12 @@ build_unflags= 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} - - - - - - - - -monitor_speed = 460800 -monitor_filters = esp32_c3_exception_decoder + ${esp32_common.build_src_filter} - - - - - - - ; Override esp32_common component pruning: keep esp_hosted + esp_wifi_remote for P4 hosted BT custom_component_remove = @@ -42,33 +40,54 @@ custom_component_remove = custom_sdkconfig = ${esp32_common.custom_sdkconfig} CONFIG_ARDUINO_SELECTIVE_SD_MMC=y - CONFIG_BT_ENABLED=y - CONFIG_BT_NIMBLE_ENABLED=y - CONFIG_BT_NIMBLE_EXT_ADV=n - CONFIG_ESP_WIFI_REMOTE_ENABLED=n + 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 - ; Prefer conservative reset behavior across P4 hosts - CONFIG_ESP_HOSTED_SLAVE_RESET_ON_EVERY_HOST_BOOTUP=n - CONFIG_ESP_HOSTED_SLAVE_RESET_ONLY_IF_NECESSARY=y - ; SOC_LCD (MUI / lovyanGFX) + # 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 - NimBLE-Arduino bsec2 esp32_idf5_https_server esp_driver_cam From a4b55bc6f24ae6528251dd816c7ef7fe9f85b2d3 Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 22 Apr 2026 12:41:49 -0400 Subject: [PATCH 66/67] cardputer-adv: Move variant.cpp -> extra_variants/variant.cpp (#10242) Fixes issues with #includes inherited from `configuration.h` when building for pioarduino. Aligns cardputer-adv with other variants like t_deck_pro. --- .../extra_variants}/m5stack_cardputer_adv/variant.cpp | 7 ++++++- variants/esp32s3/m5stack_cardputer_adv/platformio.ini | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) rename {variants/esp32s3 => src/platform/extra_variants}/m5stack_cardputer_adv/variant.cpp (97%) diff --git a/variants/esp32s3/m5stack_cardputer_adv/variant.cpp b/src/platform/extra_variants/m5stack_cardputer_adv/variant.cpp similarity index 97% rename from variants/esp32s3/m5stack_cardputer_adv/variant.cpp rename to src/platform/extra_variants/m5stack_cardputer_adv/variant.cpp index 2bbe8e2e3..7ec9dca80 100644 --- a/variants/esp32s3/m5stack_cardputer_adv/variant.cpp +++ b/src/platform/extra_variants/m5stack_cardputer_adv/variant.cpp @@ -1,6 +1,9 @@ -#include "AudioBoard.h" #include "configuration.h" +#ifdef M5STACK_CARDPUTER_ADV + +#include "AudioBoard.h" + DriverPins PinsAudioBoardES8311; AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311); @@ -38,3 +41,5 @@ void lateInitVariant() es8311_write_reg(0x32, 0xBF); // DAC volume (0dB) es8311_write_reg(0x37, 0x08); // EQ bypass } + +#endif diff --git a/variants/esp32s3/m5stack_cardputer_adv/platformio.ini b/variants/esp32s3/m5stack_cardputer_adv/platformio.ini index 3b378ed94..69c4f52a5 100644 --- a/variants/esp32s3/m5stack_cardputer_adv/platformio.ini +++ b/variants/esp32s3/m5stack_cardputer_adv/platformio.ini @@ -10,9 +10,6 @@ build_flags = -D M5STACK_CARDPUTER_ADV -D ARDUINO_USB_CDC_ON_BOOT=1 -I variants/esp32s3/m5stack_cardputer_adv -build_src_filter = - ${esp32s3_base.build_src_filter} - +<../variants/esp32s3/m5stack_cardputer_adv> lib_deps = ${esp32s3_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main From fcb9ec0c2d8cd7b1dc6d4c2fe22e35ee1aa84358 Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 22 Apr 2026 12:42:02 -0400 Subject: [PATCH 67/67] t5s3-epaper: Move variant.cpp -> extra_variants/variant.cpp (#10241) Fixes issues with #includes inherited from `configuration.h` when building for pioarduino. Aligns t5s3_epaper with other variants like t_deck_pro. --- .../extra_variants/t5s3_epaper/variant.cpp | 144 +++++++++++++++++ variants/esp32s3/t5s3_epaper/platformio.ini | 2 +- variants/esp32s3/t5s3_epaper/variant.cpp | 147 +----------------- 3 files changed, 148 insertions(+), 145 deletions(-) create mode 100644 src/platform/extra_variants/t5s3_epaper/variant.cpp diff --git a/src/platform/extra_variants/t5s3_epaper/variant.cpp b/src/platform/extra_variants/t5s3_epaper/variant.cpp new file mode 100644 index 000000000..827b3f5bd --- /dev/null +++ b/src/platform/extra_variants/t5s3_epaper/variant.cpp @@ -0,0 +1,144 @@ +#include "configuration.h" + +#ifdef T5_S3_EPAPER_PRO + +#include "Observer.h" +#include "TouchDrvGT911.hpp" +#include "Wire.h" +#include "input/InputBroker.h" +#include "input/TouchScreenImpl1.h" +#include "sleep.h" + +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS +#include "graphics/niche/InkHUD/InkHUD.h" +#include "graphics/niche/InkHUD/SystemApplet.h" + +// Bridges touch events from TouchScreenImpl1 directly into InkHUD, +// bypassing the InputBroker (which is excluded in InkHUD builds). +// Routing mirrors the mini-epaper-s3 two-way rocker pattern: +// - Nav left/right: prevApplet/nextApplet when idle, navUp/Down when a system applet has focus (e.g. menu) +// - Nav up/down: navUp/navDown always (menu scroll) +// - Tap: shortpress (cycle applets / confirm in menu) +// - Long press: longpress (open menu / back) +class TouchInkHUDBridge : public Observer +{ + int onNotify(const InputEvent *e) override + { + auto *inkhud = NicheGraphics::InkHUD::InkHUD::getInstance(); + + // Keep alignment in sync with the current rotation so that visual-frame gestures + // always pass through nav functions without remapping: (rotation + alignment) % 4 == 0. + inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4; + + // Check whether a system applet (e.g. menu) is currently handling input + bool systemHandlingInput = false; + for (NicheGraphics::InkHUD::SystemApplet *sa : inkhud->systemApplets) { + if (sa->handleInput) { + systemHandlingInput = true; + break; + } + } + + switch (e->inputEvent) { + case INPUT_BROKER_USER_PRESS: + inkhud->shortpress(); + break; + case INPUT_BROKER_SELECT: + inkhud->longpress(); + break; + case INPUT_BROKER_LEFT: + if (systemHandlingInput) + inkhud->navUp(); + else + inkhud->prevApplet(); + break; + case INPUT_BROKER_RIGHT: + if (systemHandlingInput) + inkhud->navDown(); + else + inkhud->nextApplet(); + break; + case INPUT_BROKER_UP: + inkhud->navUp(); + break; + case INPUT_BROKER_DOWN: + inkhud->navDown(); + break; + default: + break; + } + return 0; + } +}; + +static TouchInkHUDBridge touchBridge; +#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS + +TouchDrvGT911 touch; + +// Commands the GT911 into standby before the Wire bus is torn down. +// notifyDeepSleep fires before Wire.end() in doDeepSleep(), so I2C is still available here. +struct TouchDeepSleepObserver { + int onDeepSleep(void *) + { + touch.sleep(); + return 0; + } + CallbackObserver observer{this, &TouchDeepSleepObserver::onDeepSleep}; +} static touchDeepSleepObserver; + +bool readTouch(int16_t *x, int16_t *y) +{ + if (!digitalRead(GT911_PIN_INT)) { + int16_t raw_x; + int16_t raw_y; + if (touch.getPoint(&raw_x, &raw_y)) { +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS + // Transform raw GT911 axes to visual-frame coordinates for the current display rotation. + // rotation=3 is the physical identity (device's default orientation). + switch (NicheGraphics::InkHUD::InkHUD::getInstance()->persistence->settings.rotation) { + default: + case 3: + *x = raw_x; + *y = raw_y; + break; // identity + case 2: + *x = (EPD_WIDTH - 1) - raw_y; + *y = raw_x; + break; // 90° CW tilt + case 1: + *x = (EPD_HEIGHT - 1) - raw_x; + *y = (EPD_WIDTH - 1) - raw_y; + break; // 180° flip + case 0: + *x = raw_y; + *y = (EPD_HEIGHT - 1) - raw_x; + break; // 90° CCW tilt + } +#else + *x = raw_x; + *y = raw_y; +#endif + LOG_DEBUG("touched(%d/%d)", *x, *y); + return true; + } + } + return false; +} + +// T5-S3-ePaper Pro specific (late-) init +void lateInitVariant(void) +{ + touch.setPins(GT911_PIN_RST, GT911_PIN_INT); + if (touch.begin(Wire, GT911_SLAVE_ADDRESS_H, GT911_PIN_SDA, GT911_PIN_SCL)) { + touchDeepSleepObserver.observer.observe(¬ifyDeepSleep); + touchScreenImpl1 = new TouchScreenImpl1(EPD_WIDTH, EPD_HEIGHT, readTouch); + touchScreenImpl1->init(); +#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS + touchBridge.observe(touchScreenImpl1); +#endif + } else { + LOG_ERROR("Failed to find touch controller!"); + } +} +#endif diff --git a/variants/esp32s3/t5s3_epaper/platformio.ini b/variants/esp32s3/t5s3_epaper/platformio.ini index bad36706c..2001133c7 100644 --- a/variants/esp32s3/t5s3_epaper/platformio.ini +++ b/variants/esp32s3/t5s3_epaper/platformio.ini @@ -5,7 +5,7 @@ board_build.partition = default_16MB.csv board_check = true upload_protocol = esptool build_flags = -fno-strict-aliasing - ${esp32_base.build_flags} + ${esp32s3_base.build_flags} -I variants/esp32s3/t5s3_epaper -D T5_S3_EPAPER_PRO -D USE_EINK diff --git a/variants/esp32s3/t5s3_epaper/variant.cpp b/variants/esp32s3/t5s3_epaper/variant.cpp index 3bc010ce0..6cae0e5c0 100644 --- a/variants/esp32s3/t5s3_epaper/variant.cpp +++ b/variants/esp32s3/t5s3_epaper/variant.cpp @@ -1,130 +1,6 @@ -#include "configuration.h" - -#ifdef T5_S3_EPAPER_PRO - -#include "Observer.h" -#include "TouchDrvGT911.hpp" -#include "Wire.h" -#include "input/InputBroker.h" -#include "input/TouchScreenImpl1.h" -#include "sleep.h" - -#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS -#include "graphics/niche/InkHUD/InkHUD.h" -#include "graphics/niche/InkHUD/SystemApplet.h" - -// Bridges touch events from TouchScreenImpl1 directly into InkHUD, -// bypassing the InputBroker (which is excluded in InkHUD builds). -// Routing mirrors the mini-epaper-s3 two-way rocker pattern: -// - Nav left/right: prevApplet/nextApplet when idle, navUp/Down when a system applet has focus (e.g. menu) -// - Nav up/down: navUp/navDown always (menu scroll) -// - Tap: shortpress (cycle applets / confirm in menu) -// - Long press: longpress (open menu / back) -class TouchInkHUDBridge : public Observer -{ - int onNotify(const InputEvent *e) override - { - auto *inkhud = NicheGraphics::InkHUD::InkHUD::getInstance(); - - // Keep alignment in sync with the current rotation so that visual-frame gestures - // always pass through nav functions without remapping: (rotation + alignment) % 4 == 0. - inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4; - - // Check whether a system applet (e.g. menu) is currently handling input - bool systemHandlingInput = false; - for (NicheGraphics::InkHUD::SystemApplet *sa : inkhud->systemApplets) { - if (sa->handleInput) { - systemHandlingInput = true; - break; - } - } - - switch (e->inputEvent) { - case INPUT_BROKER_USER_PRESS: - inkhud->shortpress(); - break; - case INPUT_BROKER_SELECT: - inkhud->longpress(); - break; - case INPUT_BROKER_LEFT: - if (systemHandlingInput) - inkhud->navUp(); - else - inkhud->prevApplet(); - break; - case INPUT_BROKER_RIGHT: - if (systemHandlingInput) - inkhud->navDown(); - else - inkhud->nextApplet(); - break; - case INPUT_BROKER_UP: - inkhud->navUp(); - break; - case INPUT_BROKER_DOWN: - inkhud->navDown(); - break; - default: - break; - } - return 0; - } -}; - -static TouchInkHUDBridge touchBridge; -#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS - -TouchDrvGT911 touch; - -// Commands the GT911 into standby before the Wire bus is torn down. -// notifyDeepSleep fires before Wire.end() in doDeepSleep(), so I2C is still available here. -struct TouchDeepSleepObserver { - int onDeepSleep(void *) - { - touch.sleep(); - return 0; - } - CallbackObserver observer{this, &TouchDeepSleepObserver::onDeepSleep}; -} static touchDeepSleepObserver; - -bool readTouch(int16_t *x, int16_t *y) -{ - if (!digitalRead(GT911_PIN_INT)) { - int16_t raw_x; - int16_t raw_y; - if (touch.getPoint(&raw_x, &raw_y)) { -#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS - // Transform raw GT911 axes to visual-frame coordinates for the current display rotation. - // rotation=3 is the physical identity (device's default orientation). - switch (NicheGraphics::InkHUD::InkHUD::getInstance()->persistence->settings.rotation) { - default: - case 3: - *x = raw_x; - *y = raw_y; - break; // identity - case 2: - *x = (EPD_WIDTH - 1) - raw_y; - *y = raw_x; - break; // 90° CW tilt - case 1: - *x = (EPD_HEIGHT - 1) - raw_x; - *y = (EPD_WIDTH - 1) - raw_y; - break; // 180° flip - case 0: - *x = raw_y; - *y = (EPD_HEIGHT - 1) - raw_x; - break; // 90° CCW tilt - } -#else - *x = raw_x; - *y = raw_y; -#endif - LOG_DEBUG("touched(%d/%d)", *x, *y); - return true; - } - } - return false; -} +#include "variant.h" +#include "Arduino.h" +#include "pins_arduino.h" void earlyInitVariant() { @@ -161,20 +37,3 @@ void variant_shutdown() // Ensure frontlight is off during deep sleep digitalWrite(BOARD_BL_EN, LOW); } - -// T5-S3-ePaper Pro specific (late-) init -void lateInitVariant(void) -{ - touch.setPins(GT911_PIN_RST, GT911_PIN_INT); - if (touch.begin(Wire, GT911_SLAVE_ADDRESS_H, GT911_PIN_SDA, GT911_PIN_SCL)) { - touchDeepSleepObserver.observer.observe(¬ifyDeepSleep); - touchScreenImpl1 = new TouchScreenImpl1(EPD_WIDTH, EPD_HEIGHT, readTouch); - touchScreenImpl1->init(); -#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS - touchBridge.observe(touchScreenImpl1); -#endif - } else { - LOG_ERROR("Failed to find touch controller!"); - } -} -#endif \ No newline at end of file