From b563da634f8f6ab6a86c0990bf355738348da79c Mon Sep 17 00:00:00 2001 From: issey sandei Date: Fri, 3 Jan 2025 16:37:48 +0000 Subject: [PATCH 1/5] increased buffer size to 1024 --- src/mqtt/MQTT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 46fb607b5..3db3c37bb 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -435,7 +435,7 @@ void MQTT::reconnect() serverAddr = hostAndPort.first.c_str(); serverPort = hostAndPort.second; pubSub.setServer(serverAddr, serverPort); - pubSub.setBufferSize(512); + pubSub.setBufferSize(1024); LOG_INFO("Connect directly to MQTT server %s, port: %d, username: %s, password: %s", serverAddr, serverPort, mqttUsername, mqttPassword); From 11902d8a1c23a03872cf35a38822551b98e6041b Mon Sep 17 00:00:00 2001 From: issey sandei Date: Sun, 5 Jan 2025 14:08:49 +0000 Subject: [PATCH 2/5] better readability --- src/modules/Telemetry/PowerTelemetry.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index 10133fca5..f1df2d361 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -99,11 +99,11 @@ bool PowerTelemetryModule::wantUIFrame() void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { display->setTextAlignment(TEXT_ALIGN_LEFT); - display->setFont(FONT_MEDIUM); + display->setFont(FONT_SMALL); display->drawString(x, y, "Power Telemetry"); if (lastMeasurementPacket == nullptr) { display->setFont(FONT_SMALL); - display->drawString(x, y += _fontHeight(FONT_MEDIUM), "No measurement"); + display->drawString(x, y += _fontHeight(FONT_SMALL), "No measurement"); return; } @@ -122,21 +122,21 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s // Display current and voltage based on ...power_metrics.has_[channel/voltage/current]... flags display->setFont(FONT_SMALL); - display->drawString(x, y += _fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); + display->drawString(x, y += _fontHeight(FONT_SMALL) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); if (lastMeasurement.variant.power_metrics.has_ch1_voltage || lastMeasurement.variant.power_metrics.has_ch1_current) { display->drawString(x, y += _fontHeight(FONT_SMALL), - "Ch1 Volt: " + String(lastMeasurement.variant.power_metrics.ch1_voltage, 2) + - "V / Curr: " + String(lastMeasurement.variant.power_metrics.ch1_current, 0) + "mA"); + "Ch1: " + String(lastMeasurement.variant.power_metrics.ch1_voltage, 2) + + "V " + String(lastMeasurement.variant.power_metrics.ch1_current, 0) + "mA"); } if (lastMeasurement.variant.power_metrics.has_ch2_voltage || lastMeasurement.variant.power_metrics.has_ch2_current) { display->drawString(x, y += _fontHeight(FONT_SMALL), - "Ch2 Volt: " + String(lastMeasurement.variant.power_metrics.ch2_voltage, 2) + - "V / Curr: " + String(lastMeasurement.variant.power_metrics.ch2_current, 0) + "mA"); + "Ch2: " + String(lastMeasurement.variant.power_metrics.ch2_voltage, 2) + + "V " + String(lastMeasurement.variant.power_metrics.ch2_current, 0) + "mA"); } if (lastMeasurement.variant.power_metrics.has_ch3_voltage || lastMeasurement.variant.power_metrics.has_ch3_current) { display->drawString(x, y += _fontHeight(FONT_SMALL), - "Ch3 Volt: " + String(lastMeasurement.variant.power_metrics.ch3_voltage, 2) + - "V / Curr: " + String(lastMeasurement.variant.power_metrics.ch3_current, 0) + "mA"); + "Ch3: " + String(lastMeasurement.variant.power_metrics.ch3_voltage, 2) + + "V " + String(lastMeasurement.variant.power_metrics.ch3_current, 0) + "mA"); } } From 5cbce9248c38f0f2358aceece2be4d9a17ea1721 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 6 Jan 2025 13:09:11 +0100 Subject: [PATCH 3/5] better readability 2 --- src/modules/Telemetry/PowerTelemetry.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index f1df2d361..9c794e31e 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -100,29 +100,30 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s { display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_SMALL); - display->drawString(x, y, "Power Telemetry"); + if (lastMeasurementPacket == nullptr) { - display->setFont(FONT_SMALL); + // In case of no valid packet, display "Power Telemetry", "No measurement" + display->drawString(x, y, "Power Telemetry"); display->drawString(x, y += _fontHeight(FONT_SMALL), "No measurement"); return; } + // Decode the last power packet meshtastic_Telemetry lastMeasurement; - uint32_t agoSecs = service->GetTimeSinceMeshPacket(lastMeasurementPacket); const char *lastSender = getSenderShortName(*lastMeasurementPacket); const meshtastic_Data &p = lastMeasurementPacket->decoded; if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) { - display->setFont(FONT_SMALL); - display->drawString(x, y += _fontHeight(FONT_MEDIUM), "Measurement Error"); + display->drawString(x, y, "Measurement Error"); LOG_ERROR("Unable to decode last packet"); return; } + // Display "Pow. From: ..." + display->drawString(x, y, "Pow. From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); + // Display current and voltage based on ...power_metrics.has_[channel/voltage/current]... flags - display->setFont(FONT_SMALL); - display->drawString(x, y += _fontHeight(FONT_SMALL) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); if (lastMeasurement.variant.power_metrics.has_ch1_voltage || lastMeasurement.variant.power_metrics.has_ch1_current) { display->drawString(x, y += _fontHeight(FONT_SMALL), "Ch1: " + String(lastMeasurement.variant.power_metrics.ch1_voltage, 2) + From c675a73719eda2825c6428d9b1362aceaa2a25f9 Mon Sep 17 00:00:00 2001 From: isseysandei Date: Thu, 9 Jan 2025 18:45:38 +0100 Subject: [PATCH 4/5] added lux and white lux to environmental sensor screens --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index e72b03bd4..30522ae81 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -264,6 +264,16 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt if (lastMeasurement.variant.environment_metrics.radiation != 0) display->drawString(x, y += _fontHeight(FONT_SMALL), "Rad: " + String(lastMeasurement.variant.environment_metrics.radiation, 2) + "µR/h"); + + if (lastMeasurement.variant.environment_metrics.lux != 0) { + display->drawString(x, y += _fontHeight(FONT_SMALL), + "Illuminance: " + String(lastMeasurement.variant.environment_metrics.lux, 2) + "lx"); + } + + if (lastMeasurement.variant.environment_metrics.white_lux != 0) { + display->drawString(x, y += _fontHeight(FONT_SMALL), + "W_Lux: " + String(lastMeasurement.variant.environment_metrics.white_lux, 2) + "lx"); + } } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) From a84f19ca51fc964d863d1351bd40a8cbbb581fd9 Mon Sep 17 00:00:00 2001 From: isseysandei Date: Sun, 12 Jan 2025 18:07:13 +0100 Subject: [PATCH 5/5] clang --- .trunk/configs/.bandit | 2 - .trunk/configs/.clang-format | 6 --- .trunk/configs/.flake8 | 3 -- .trunk/configs/.hadolint.yaml | 4 -- .trunk/configs/.isort.cfg | 2 - .trunk/configs/.markdownlint.yaml | 10 ----- .trunk/configs/.shellcheckrc | 10 ----- .trunk/configs/.yamllint.yaml | 10 ----- .trunk/configs/ruff.toml | 5 --- .trunk/configs/svgo.config.js | 14 ------ .trunk/trunk.yaml | 51 +++------------------- package.json | 27 ++++++++++++ trunk.ps1 | 72 +++++++++++++++++++++++++++++++ 13 files changed, 105 insertions(+), 111 deletions(-) delete mode 100644 .trunk/configs/.bandit delete mode 100644 .trunk/configs/.clang-format delete mode 100644 .trunk/configs/.flake8 delete mode 100644 .trunk/configs/.hadolint.yaml delete mode 100644 .trunk/configs/.isort.cfg delete mode 100644 .trunk/configs/.markdownlint.yaml delete mode 100644 .trunk/configs/.shellcheckrc delete mode 100644 .trunk/configs/.yamllint.yaml delete mode 100644 .trunk/configs/ruff.toml delete mode 100644 .trunk/configs/svgo.config.js create mode 100644 package.json create mode 100644 trunk.ps1 diff --git a/.trunk/configs/.bandit b/.trunk/configs/.bandit deleted file mode 100644 index d286ded89..000000000 --- a/.trunk/configs/.bandit +++ /dev/null @@ -1,2 +0,0 @@ -[bandit] -skips = B101 \ No newline at end of file diff --git a/.trunk/configs/.clang-format b/.trunk/configs/.clang-format deleted file mode 100644 index a0e638725..000000000 --- a/.trunk/configs/.clang-format +++ /dev/null @@ -1,6 +0,0 @@ -Language: Cpp -IndentWidth: 4 -ColumnLimit: 130 -PointerAlignment: Right -BreakBeforeBraces: Linux -AllowShortFunctionsOnASingleLine: Inline diff --git a/.trunk/configs/.flake8 b/.trunk/configs/.flake8 deleted file mode 100644 index 5ba6e2ffe..000000000 --- a/.trunk/configs/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -# Autoformatter friendly flake8 config (all formatting rules disabled) -[flake8] -extend-ignore = D1, D2, E1, E2, E3, E501, W1, W2, W3, W5 diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml deleted file mode 100644 index 98bf0cd2e..000000000 --- a/.trunk/configs/.hadolint.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Following source doesn't work in most setups -ignored: - - SC1090 - - SC1091 diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg deleted file mode 100644 index b9fb3f3e8..000000000 --- a/.trunk/configs/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml deleted file mode 100644 index fb940393d..000000000 --- a/.trunk/configs/.markdownlint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Autoformatter friendly markdownlint config (all formatting rules disabled) -default: true -blank_lines: false -bullet: false -html: false -indentation: false -line_length: false -spaces: false -url: false -whitespace: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc deleted file mode 100644 index b2e8a14cc..000000000 --- a/.trunk/configs/.shellcheckrc +++ /dev/null @@ -1,10 +0,0 @@ -enable=all -source-path=SCRIPTDIR -disable=SC2154 -disable=SC2248 -disable=SC2250 - -# If you're having issues with shellcheck following source, disable the errors via: -# disable=SC1090 -# disable=SC1091 -# \ No newline at end of file diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml deleted file mode 100644 index 790846156..000000000 --- a/.trunk/configs/.yamllint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -rules: - quoted-strings: - required: only-when-needed - extra-allowed: ["{|}"] - empty-values: - forbid-in-block-mappings: false - forbid-in-flow-mappings: true - key-duplicates: {} - octal-values: - forbid-implicit-octal: true diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml deleted file mode 100644 index 346b1d9aa..000000000 --- a/.trunk/configs/ruff.toml +++ /dev/null @@ -1,5 +0,0 @@ -# Generic, formatter-friendly config. -select = ["B", "D3", "D4", "E", "F"] - -# Never enforce `E501` (line length violations). This should be handled by formatters. -ignore = ["E501"] diff --git a/.trunk/configs/svgo.config.js b/.trunk/configs/svgo.config.js deleted file mode 100644 index b257d1349..000000000 --- a/.trunk/configs/svgo.config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - plugins: [ - { - name: "preset-default", - params: { - overrides: { - removeViewBox: false, // https://github.com/svg/svgo/issues/1128 - sortAttrs: true, - removeOffCanvasPaths: true, - }, - }, - }, - ], -}; diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index f2393592c..29d56ed1f 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,50 +1,11 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml version: 0.1 cli: - version: 1.22.8 + version: 1.22.2 +# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) plugins: sources: - id: trunk - ref: v1.6.6 - uri: https://github.com/trunk-io/plugins -lint: - enabled: - - prettier@3.4.2 - - trufflehog@3.86.1 - - yamllint@1.35.1 - - bandit@1.8.0 - - checkov@3.2.334 - - terrascan@1.19.9 - - trivy@0.58.0 - #- trufflehog@3.63.2-rc0 - - taplo@0.9.3 - - ruff@0.8.3 - - isort@5.13.2 - - markdownlint@0.43.0 - - oxipng@9.1.3 - - svgo@3.3.2 - - actionlint@1.7.4 - - flake8@7.1.1 - - hadolint@2.12.1-beta - - shfmt@3.6.0 - - shellcheck@0.10.0 - - black@24.10.0 - - git-diff-check - - gitleaks@8.21.2 - - clang-format@16.0.3 - #- prettier@3.3.3 - ignore: - - linters: [ALL] - paths: - - bin/** -runtimes: - enabled: - - python@3.10.8 - - go@1.21.0 - - node@18.20.5 -actions: - disabled: - - trunk-announce - enabled: - - trunk-fmt-pre-commit - - trunk-check-pre-push - - trunk-upgrade-available + ref: v1.6.1 + uri: https://github.com/trunk-io/plugins \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..8b3fe8084 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "firmware", + "version": "1.0.0", + "description": "![GitHub release downloads](https://img.shields.io/github/downloads/meshtastic/firmware/total) [![CI](https://img.shields.io/github/actions/workflow/status/meshtastic/firmware/main_matrix.yml?branch=master&label=actions&logo=github&color=yellow)](https://github.com/meshtastic/firmware/actions/workflows/ci.yml) [![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/firmware)](https://cla-assistant.io/meshtastic/firmware) [![Fiscal Contributors](https://opencollective.com/meshtastic/tiers/badge.svg?label=Fiscal%20Contributors&color=deeppink)](https://opencollective.com/meshtastic/) [![Vercel](https://img.shields.io/static/v1?label=Powered%20by&message=Vercel&style=flat&logo=vercel&color=000000)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "trunk": "trunk", + "lint": "trunk check", + "fmt": "trunk fmt" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/isseysandei/firmware.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/isseysandei/firmware/issues" + }, + "homepage": "https://github.com/isseysandei/firmware#readme" + +} diff --git a/trunk.ps1 b/trunk.ps1 new file mode 100644 index 000000000..9d20e6c7a --- /dev/null +++ b/trunk.ps1 @@ -0,0 +1,72 @@ +$ErrorActionPreference = 'Stop' + +$Env:TRUNK_LAUNCHER_VERSION="1.3.4" # warning: this line is auto-updated +$Env:TRUNK_LAUNCHER_PATH = $PSCommandPath + +# Try to get the version from trunk.yaml. +function TryGetTrunkVersion { + $currentDir = (Get-Location).Path + while ($currentDir -ne '') { + $trunkYamlPath = "$currentDir\.trunk\trunk.yaml" + if (Test-Path "$trunkYamlPath") { + $yamlContent = Get-Content "$trunkYamlPath" -Raw + return $yamlContent -replace '(?s).*\s+version:\s*([0-9a-z.-]+).*','$1' + } + $currentDir = Split-Path $currentDir -Parent + } + return $null +} + +# Get the latest version of trunk. +function GetLatestTrunkVersion { + $latestReleaseInfo = Invoke-RestMethod 'https://trunk.io/releases/latest' -UseBasicParsing + return $latestReleaseInfo -replace '(?s).*version:\s*([0-9a-z.-]+).*','$1' +} + +# Download a particular version of trunk to the specified directory. +function DownloadTrunk($version, $trunkDir) { + $null = New-Item -Type Directory -Force -Path (Split-Path $trunkDir -Parent) + $guid = [System.Guid]::NewGuid() + $downloadPath = "$trunkDir.$guid.zip" + $destinationPath = "$trunkDir.$guid" + try { + # Download the zip file. + $zipFile = "trunk-$version.windows.zip" + $zipFilePath = "$tempDir\$zipFile" + $downloadUrl = "https://trunk.io/releases/$version/$zipFile" + Invoke-RestMethod -Uri $downloadUrl -OutFile $downloadPath + # Extract the zip file to a uniquely named directory. + Expand-Archive -Path $downloadPath -DestinationPath $destinationPath + # Remove the trunk directory if it already exists. + if (Test-Path $trunkDir) { + Remove-Item -Path $trunkDir -Recurse -Force + } + # Move the uniquely named trunk directory to the final location. + Move-Item -Path $destinationPath -Destination $trunkDir + } + finally { + # Cleanup. + Remove-Item -Path $downloadPath -Force -ea 0 + Remove-Item -Path $destinationPath -Recurse -Force -ea 0 + } +} + +# Get the version to run. +$version = TryGetTrunkVersion +if ($version -eq $null) { + $version = GetLatestTrunkVersion +} + +# Determine the expected path to trunk.exe. +$localApplicationData = [Environment]::GetFolderPath('LocalApplicationData') +$trunkDir = "$localApplicationData\trunk\cli\trunk-${version}-windows" +$trunkExe = "$trunkDir\trunk.exe" + +# Download trunk.exe if it doesn't exist. +if (!(Test-Path $trunkExe)) { + DownloadTrunk $version $trunkDir +} + +# Execute trunk with all arguments +& $trunkExe $args +exit $LastExitCode